]> Cypherpunks repositories - gostls13.git/log
gostls13.git
4 years agostrconv: fix incorrect bit size in ParseComplex; add tests
Ben Hoyt [Fri, 14 Aug 2020 10:58:49 +0000 (22:58 +1200)]
strconv: fix incorrect bit size in ParseComplex; add tests

In ParseComplex, the "size" passed to parseFloatPrefix should be 64 for
complex128, not 128. It still works because of how parseFloatPrefix
is forgiving about the size if it's not 32, but worth fixing anyway.

Make ParseComplex and ParseFloat return a bit size error for anything
other than 128 or 64 (for ParseComplex), or 64 or 32 (for ParseFloat).
Add "InvalidBitSize" tests for these cases.

Add tests for ParseComplex with bitSize==64: this is done in a similar
way to how the ParseFloat 32-bit tests work, re-using the tests for the
larger bit size.

Add tests for FormatComplex -- there were none before.

Fixes #40706

Change-Id: I16ddd546e5237207cc3b8c2181dd708eca42b04f
Reviewed-on: https://go-review.googlesource.com/c/go/+/248219
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Minux Ma <minux@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agostrings: complete documentation of strings.Reader
Norman B. Lancaster [Thu, 1 Oct 2020 19:14:04 +0000 (19:14 +0000)]
strings: complete documentation of strings.Reader

There is no documentation on a number of methods of the strings.Reader
struct, so this change adds documentation referring to the relevant
io.* interfaces implemented. This is consistent with pre-existing
documentation in this struct.

Fixes #40381

Change-Id: I3dec65ecafca5b79d85d30a676d297e5ee9ab47e
GitHub-Last-Rev: f42429946a2b90b9fbfbd1ea5943f0c50e0439b5
GitHub-Pull-Request: golang/go#40654
Reviewed-on: https://go-review.googlesource.com/c/go/+/247523
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>

4 years agomath/big: reduce allocations for building decimal strings
surechen [Fri, 15 May 2020 14:59:38 +0000 (22:59 +0800)]
math/big: reduce allocations for building decimal strings

Append operations in the decimal String function may cause several allocations.
Use make to pre allocate slices in String that have enough capacity to avoid additional allocations in append operations.

name                 old time/op  new time/op  delta
DecimalConversion-8   139µs ± 7%   109µs ± 2%  -21.06%  (p=0.000 n=10+10)

Change-Id: Id0284d204918a179a0421c51c35d86a3408e1bd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/233980
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Giovanni Bajo <rasky@develer.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Giovanni Bajo <rasky@develer.com>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Giovanni Bajo <rasky@develer.com>
Trust: Martin Möhrmann <moehrmann@google.com>

4 years agostrconv: make Eisel-Lemire handle long mantissas
Rémy Oudompheng [Fri, 23 Oct 2020 20:23:21 +0000 (22:23 +0200)]
strconv: make Eisel-Lemire handle long mantissas

In many cases, it is not necessary to parse long
decimal mantissas entirely to produce the correctly
rounded floating-point number. It is enough to parse
the short, rounded lower and upper bounds and in most cases
they round to the same floating point number because uint64
can hold 19 digits.

Previously this case was handled by the extFloat code path
(Grisu3 algorithm).

name                      old time/op  new time/op  delta
Atof64Big-4               1.07µs ± 2%  0.11µs ± 2%  -89.61%  (p=0.000 n=10+9)
Atof64RandomLongFloats-4  8.03µs ± 2%  0.14µs ± 7%  -98.24%  (p=0.000 n=10+10)
Atof32RandomLong-4         760ns ± 1%   156ns ± 0%  -79.46%  (p=0.000 n=10+8)

Benchmarks versus extFloat:

name                      old time/op  new time/op  delta
Atof64Big-4                121ns ± 3%   111ns ± 2%   -7.93%  (p=0.000 n=10+9)
Atof64RandomLongFloats-4   144ns ± 1%   142ns ± 7%     ~     (p=0.167 n=10+10)
Atof32RandomLong-4         129ns ± 1%   156ns ± 0%  +21.12%  (p=0.000 n=10+8)

Change-Id: Id734b8c11e74b49a444fda67ee72870ae9422e60
Reviewed-on: https://go-review.googlesource.com/c/go/+/264677
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
4 years agocmd/link: put C static symbols in the symbol table, attempt 2
Cherry Zhang [Thu, 29 Oct 2020 02:46:41 +0000 (22:46 -0400)]
cmd/link: put C static symbols in the symbol table, attempt 2

We don't put Go static symbols in the symbol table, as they are
always compiler-generated (there is no way to define a static
symbol in user code in Go). We retain static symbols in assembly
code, as it may be user-defined. Also retain static symbols in C.

This is the second attempt of CL 263259, which was reverted
because it broke AIX tests in that it brought TOC.stmp symbols
in the symbol table. This time we use SymPkg(s) == "" to identify
non-Go symbols, instead of IsExternal(s), as the latter also
includes linker-modified Go symbols.

Change-Id: I5c752c54f0fc6ac4cde6a0e8161dac5b72a47d56
Reviewed-on: https://go-review.googlesource.com/c/go/+/266237
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocrypto/x509: add comment to blank imports done for init side effects
Brad Fitzpatrick [Thu, 29 Oct 2020 20:47:12 +0000 (13:47 -0700)]
crypto/x509: add comment to blank imports done for init side effects

To educate future readers.

Change-Id: I1ef79178b6997cc96ca066c91b9fec822478674b
Reviewed-on: https://go-review.googlesource.com/c/go/+/266301
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Katie Hockman <katie@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agogo/build: remove two erroneous uses of os.Stat
Russ Cox [Thu, 29 Oct 2020 18:54:47 +0000 (14:54 -0400)]
go/build: remove two erroneous uses of os.Stat

go/build should use the ctxt routines, not os directly.
These snuck in.

Change-Id: I918d4de923eb485bfd524e4f1b1310a7a165ad03
Reviewed-on: https://go-review.googlesource.com/c/go/+/266357
Trust: Russ Cox <rsc@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agoapi: update next.txt
Russ Cox [Thu, 29 Oct 2020 20:44:08 +0000 (16:44 -0400)]
api: update next.txt

The output from all.bash has gotten big again.

Change-Id: Ia2399d78c1fd443fd8de03c25655e2f84bd89886
Reviewed-on: https://go-review.googlesource.com/c/go/+/266397
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agocmd/internal/obj: use panic instead of log.Fatalf for two messages
Russ Cox [Thu, 29 Oct 2020 17:57:12 +0000 (13:57 -0400)]
cmd/internal/obj: use panic instead of log.Fatalf for two messages

These messages can happen if there are
duplicate body-less function declarations.
Using panic gives the panic handler
a chance to handle the panic by printing the
queued error messages instead of an internal error.

And if there are no queued error messages,
using panic pinpoints the stack trace leading
to the incorrect use of NewFuncInfo/NewFileInfo.

Change-Id: I7e7ea9822ff9a1e7140f5e5b7cfd6437ff9318a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/266338
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: gracefully fail when devirtualization fails
Matthew Dempsky [Thu, 29 Oct 2020 19:47:15 +0000 (12:47 -0700)]
cmd/compile: gracefully fail when devirtualization fails

We should still be able to devirtualize here, but I need to understand
the AST better. While I'm doing that, at least switch to a graceful
failure case (i.e., skip the optimization and print a warning message)
to fix the x/text builders.

Updates #42279.

Change-Id: Ie2b0b701fccf590d0cabfead703fc2fa999072cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/266359
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: early devirtualization of interface method calls
Matthew Dempsky [Thu, 29 Oct 2020 01:49:10 +0000 (18:49 -0700)]
cmd/compile: early devirtualization of interface method calls

After inlining, add a pass that looks for interface calls where we can
statically determine the interface value's concrete type. If such a
case is found, insert an explicit type assertion to the concrete type
so that escape analysis can see it.

Fixes #33160.

Change-Id: I36932c691693f0069e34384086d63133e249b06b
Reviewed-on: https://go-review.googlesource.com/c/go/+/264837
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agocmd/compile: improve inlining and static analysis
Matthew Dempsky [Sat, 24 Oct 2020 09:08:06 +0000 (02:08 -0700)]
cmd/compile: improve inlining and static analysis

When inlining a function call "f()", if "f" contains exactly 1
"return" statement and doesn't name its result parameters, it's
inlined to declare+initialize the result value using the AST
representation that's compatible with staticValue.

Also, extend staticValue to skip over OCONVNOP nodes (often introduced
by inlining), and fix various bits of code related to handling method
expressions.

Updates #33160.

Change-Id: If8652e319f0a5700cf9d40a7a62e369a2a359229
Reviewed-on: https://go-review.googlesource.com/c/go/+/266199
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agocmd/link: add loadelf support for riscv64
Joel Sing [Tue, 20 Oct 2020 11:04:55 +0000 (22:04 +1100)]
cmd/link: add loadelf support for riscv64

Update #36641

Change-Id: I8618da30d8940a56d6cc86a37a2f54b31ee029e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/263601
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoRevert "cmd/compile,cmd/internal/sys: enable additional build modes on linux/riscv64"
Joel Sing [Thu, 29 Oct 2020 17:32:18 +0000 (04:32 +1100)]
Revert "cmd/compile,cmd/internal/sys: enable additional build modes on linux/riscv64"

This reverts CL 263457.

It turns out that this still missed changes to cmd/link/internal/ld/config.go
and some of these build modes also fail once cgo is enabled. Disable again for
now.

Change-Id: Iaf40d44e1551afd5b040d357f04af134f55a64a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/266317
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Joel Sing <joel@sing.id.au>

4 years agosyscall: handle undefined r2 value on linux-ppc64x
Andrew G. Morgan [Wed, 28 Oct 2020 20:35:57 +0000 (13:35 -0700)]
syscall: handle undefined r2 value on linux-ppc64x

This change fixes two failng tests on linux-ppc64x:

- TestAllThreadsSyscall() exposed a real bug in the ppc64x support:
  - It turns out that the r2 syscall return value is not defined
    on all architectures. Notably linux-ppc64x so address that by
    introducing a private architectural constant in the syscall
    package, archHonorsR2: true if r2 has a determanistic value.

- TestSetuidEtc() was sensitive to /proc/<PID>/status content:
  - The amount of padding space has changed with kernel vintage.
  - Stress testing revealed a race with /proc files disappearing.

Fixes #42178

Change-Id: Ie6fc0b8f2f94a409ac0e5756e73bfce113274709
Reviewed-on: https://go-review.googlesource.com/c/go/+/266202
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: inline functions evaluated in go and defer statements
Branden J Brown [Sun, 25 Oct 2020 18:26:19 +0000 (14:26 -0400)]
cmd/compile: inline functions evaluated in go and defer statements

The inlining pass previously bailed upon encountering a go or defer statement, so it would not inline functions e.g. used to provide arguments to the deferred function. This change preserves the behavior of not inlining the
deferred function itself, but it allows the inlining walk to proceed into its arguments.

Fixes #42194

Change-Id: I4e82029d8dcbe69019cc83ae63a4b29af45ec777
Reviewed-on: https://go-review.googlesource.com/c/go/+/264997
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>

4 years agocmd/go: add //go:embed support
Russ Cox [Wed, 8 Jul 2020 21:13:16 +0000 (17:13 -0400)]
cmd/go: add //go:embed support

The final piece of //go:embed support: have the go command stitch
together parsing in go/build, low-level data initialization in cmd/compile,
and the new data structures in package embed, to make the //go:embed
feature actually function.

And test, now that all the pieces are available to work together.

For #41191.
(Issue not fixed: still need to add a tool for use by Bazel.)

Change-Id: Ib1d198345c3b4d557d340f292eda13b984b65d65
Reviewed-on: https://go-review.googlesource.com/c/go/+/243945
Trust: Russ Cox <rsc@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Johan Brandhorst <johan.brandhorst@gmail.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Johan Brandhorst <johan.brandhorst@gmail.com>
4 years agoRevert "reflect,runtime: use internal ABI for selected ASM routines"
Than McIntosh [Thu, 29 Oct 2020 15:37:35 +0000 (15:37 +0000)]
Revert "reflect,runtime: use internal ABI for selected ASM routines"

This reverts commit 50af50d136551e2009b2b52e829570536271cdaa.

Reason for revert: Causes failures in the runtime package test on Darwin, apparently.

Change-Id: I006bc1b3443fa7207e92fb4a93e3fb438d4d3de3
Reviewed-on: https://go-review.googlesource.com/c/go/+/266257
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/go: allow 'go get' to downgrade to replacement-only versions
Bryan C. Mills [Wed, 28 Oct 2020 18:20:31 +0000 (14:20 -0400)]
cmd/go: allow 'go get' to downgrade to replacement-only versions

This fixes a case missed in CL 258220.

For #36460
Updates #26241
Updates #37438

Change-Id: I5e8c2ee1e08e41cc2eb34e54c617cb5e4bf69c5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/266018
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agoRevert "crypto/x509: fix duplicate import"
Katie Hockman [Mon, 26 Oct 2020 13:39:56 +0000 (13:39 +0000)]
Revert "crypto/x509: fix duplicate import"

This reverts CL 250497. It also moves all blank identifier imports below the rest of the imports for clarity.

Reason for revert: The blank identifier import was intentional to show that it's needed for its registration side effect. The duplicate import should stay since it communicates that the side-effect is important to tools and to future developers updating this file.

Change-Id: I626e6329db50f47453aa71085a05d21bf6efe0ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/265078
Run-TryBot: Katie Hockman <katie@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agoreflect,runtime: use internal ABI for selected ASM routines
Than McIntosh [Wed, 14 Oct 2020 12:36:11 +0000 (08:36 -0400)]
reflect,runtime: use internal ABI for selected ASM routines

Change the definitions of selected runtime assembly routines
from ABI0 (the default) to ABIInternal. The ABIInternal def is
intended to indicate that these functions don't follow the existing Go
runtime ABI. In addition, convert the assembly reference to
runtime.main (from runtime.mainPC) to ABIInternal. Finally, for
functions such as "runtime.duffzero" that are called directly from
generated code, make sure that the compiler looks up the correct
ABI version.

This is intended to support the register abi work, however these
changes should not have any issues even when GOEXPERIMENT=regabi is
not in effect.

Updates #27539, #40724.

Change-Id: I9846f8dcaccc95718cf2e61a18b7e924a0677e4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/262319
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: run rulegen to include missing condition
Alberto Donizetti [Thu, 29 Oct 2020 11:12:19 +0000 (12:12 +0100)]
cmd/compile: run rulegen to include missing condition

Rulegen was not run again between patchsets 2 and 3 of CL 264683, so
the rewritegeneric.go file is out of sync. Run rulegen.

Change-Id: I67d8d267c4f666943ed9bf8c33aac2ac6013336a
Reviewed-on: https://go-review.googlesource.com/c/go/+/266080
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rémy Oudompheng <remyoudompheng@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/link: ignore "operation not permitted" fallocate errors.
Jeremy Faller [Wed, 28 Oct 2020 14:52:02 +0000 (10:52 -0400)]
cmd/link: ignore "operation not permitted" fallocate errors.

Ignore an additional class of errors form fallocate, falling back to
heap allocated buffers for output.

Fixes #41356

Change-Id: Iaaa91620cec644c78978e0b258f166bc204a3f85
Reviewed-on: https://go-review.googlesource.com/c/go/+/254777
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: move ppc64/aix cpu feature detection to internal/cpu
Martin Möhrmann [Wed, 28 Oct 2020 21:43:59 +0000 (22:43 +0100)]
runtime: move ppc64/aix cpu feature detection to internal/cpu

Additionally removed unused PPC64.IsPOWER8 CPU feature detection.

Change-Id: I1411b03d396a72e08d6d51f8a1d1bad49eaa720e
Reviewed-on: https://go-review.googlesource.com/c/go/+/266077
Trust: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
4 years agosyscall: add support for openbsd/mips64
Joel Sing [Tue, 25 Aug 2020 08:18:59 +0000 (18:18 +1000)]
syscall: add support for openbsd/mips64

Update #40995

Change-Id: I7afa520ab5ddd6d1b8c7960f400b7b3a1b67d976
Reviewed-on: https://go-review.googlesource.com/c/go/+/250581
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
4 years agoruntime: add support for openbsd/mips64
Joel Sing [Tue, 25 Aug 2020 08:04:47 +0000 (18:04 +1000)]
runtime: add support for openbsd/mips64

Update #40995

Change-Id: Ie028dfd87ef8731804567a0501f1f7758e8dd203
Reviewed-on: https://go-review.googlesource.com/c/go/+/250580
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>

4 years agocmd/asm: remove X27 and S11 register names on riscv64
Joel Sing [Tue, 27 Oct 2020 12:03:11 +0000 (23:03 +1100)]
cmd/asm: remove X27 and S11 register names on riscv64

The X27 register (known as S11 via its ABI name) is the g register on riscv64.
Prevent assembly from referring to it by either of these names.

Change-Id: Iba389eb8e44e097c0142c5b3d92e72bcae8a244a
Reviewed-on: https://go-review.googlesource.com/c/go/+/265519
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime: optimise gcWriteBarrier for riscv64
Joel Sing [Tue, 27 Oct 2020 12:30:14 +0000 (23:30 +1100)]
runtime: optimise gcWriteBarrier for riscv64

Avoid saving unnecessary registers in gcWriteBarrier on riscv64, which also
removes references to X4 and X27 (TP and g registers).

Change-Id: I2854161dcdf0c6047a45347165371827dcf8c1cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/265518
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/internal/obj/arm64: add CASx/CASPx instructions
fanzha02 [Fri, 8 May 2020 02:51:29 +0000 (10:51 +0800)]
cmd/internal/obj/arm64: add CASx/CASPx instructions

This patch adds support for CASx and CASPx atomic instructions.

  go syntax                 gnu syntax
CASD Rs, (Rn|RSP), Rt => cas Xs, Xt, (Xn|SP)
CASALW Rs, (Rn|RSP), Rt => casal Ws, Wt, (Xn|SP)
CASPD (Rs, Rs+1), (Rn|RSP), (Rt, Rt+1) => casp Xs, Xs+1, Xt, Xt+1, (Xn|SP)
CASPW (Rs, Rs+1), (Rn|RSP), (Rt, Rt+1) => casp Ws, Ws+1, Wt, Wt+1, (Xn|SP)

This patch changes the type of prog.RestArgs from "[]Addr" to
"[]struct{Addr, Pos}", Pos is a enum, indicating the position of
the operand.

This patch also adds test cases.

Change-Id: Ib971cfda7890b7aa895d17bab22dea326c7fcaa4
Reviewed-on: https://go-review.googlesource.com/c/go/+/233277
Trust: fannie zhang <Fannie.Zhang@arm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/asm: sort test cases in the arm64.s file
fanzha02 [Fri, 16 Oct 2020 11:06:18 +0000 (19:06 +0800)]
cmd/asm: sort test cases in the arm64.s file

This patch sorts the test cases in the arm64.s file by instruction
category and deletes comments related to the old parser.

Change-Id: I9bbf56281e247a4fd8d5e670e8ad67c923aef1ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/263458
Trust: fannie zhang <Fannie.Zhang@arm.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/asm: add several arm64 SIMD instructions
fanzha02 [Mon, 28 Sep 2020 10:58:51 +0000 (18:58 +0800)]
cmd/asm: add several arm64 SIMD instructions

This patch enables VSLI, VUADDW(2), VUSRA and FMOVQ SIMD instructions
required by the issue #40725. And the GNU syntax of 'FMOVQ' is 128-bit
ldr/str(immediate, simd&fp).

Add test cases.

Fixes #40725

Change-Id: Ide968ef4a9385ce4cd8f69bce854289014d30456
Reviewed-on: https://go-review.googlesource.com/c/go/+/258397
Trust: fannie zhang <Fannie.Zhang@arm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: delay expansion of OpArg until expand_calls
David Chase [Tue, 13 Oct 2020 23:24:04 +0000 (19:24 -0400)]
cmd/compile: delay expansion of OpArg until expand_calls

As it says, delay expanpsion of OpArg to the expand_calls phase,
to enable (eventually) interprocedural SSA optimizations, and
(sooner) change to a register ABI.

Includes a round of cleanup to function names and comments,
largely to match the expanded scope of the functions.

This CL removes the per-function dependence on GOSSAHASH,
but the go116lateCallExpansion kill switch remains (and was
tested locally to ensure it worked).

Two functions in expand_calls.go that performed overlapping
things were combined into a single function that is called
twice.

Fixes #42236.
For #40724.

Change-Id: Icbb78947eaa39f17f2c1210d5c2caef20abd6571
Reviewed-on: https://go-review.googlesource.com/c/go/+/262117
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agostrconv: remove extfloat.go atof code path
Nigel Tao [Fri, 23 Oct 2020 01:11:35 +0000 (12:11 +1100)]
strconv: remove extfloat.go atof code path

Prior to this commit, strconv.ParseFloat (known in C as atof) takes the
first of four algorithms to succeed: atof64exact, eiselLemire64,
extFloat, fallback. The Eisel-Lemire implementation is a recent addition
but, now that it exists, the extFloat implementation (based on the
algorithm used by https://github.com/google/double-conversion) is
largely redundant. This Go program:

func parseOneMillionFloats(bitSize int, normallyDistributed bool) {
  rng := rand.New(rand.NewSource(1))
  for i := 0; i < 1_000_000; {
    x := 0.0
    if normallyDistributed {
      x = rng.NormFloat64()
    } else if bitSize == 32 {
      x = float64(math.Float32frombits(rng.Uint32()))
    } else {
      x = math.Float64frombits(
          uint64(rng.Uint32())<<32 | uint64(rng.Uint32()))
    }
    if math.IsInf(x, 0) {
      continue
    }
    s := strconv.FormatFloat(x, 'g', -1, bitSize)
    strconv.ParseFloat(s, bitSize)
    i++
  }
}

triggers the four algorithms by these percentages:

bitSize=32, normallyDistributed=false
07.4274% atof32exact
91.2982% eiselLemire32
00.8673% extFloat
00.0269% fallback

bitSize=32, normallyDistributed=true
27.6356% atof32exact
72.3641% eiselLemire32
00.0003% extFloat
00.0000% fallback

bitSize=64, normallyDistributed=false
01.2076% atof64exact
98.6216% eiselLemire64
00.1081% extFloat
00.0130% fallback

bitSize=64, normallyDistributed=true
24.8826% atof64exact
75.1174% eiselLemire64
00.0000% extFloat
00.0000% fallback

This commit removes the extfloat.go atof code (but keeps the extfloat.go
ftoa code for now), reducing the number of atof algorithms from 4 to 3.

The benchmarks (below) show some regressions but these are arguably
largely artificial situations.

Atof*RandomBits generates uniformly distributed uint32/uint64 values and
reinterprets the bits as float32/float64 values. The change in headline
numbers (arithmetic means) are primarily due to relatively large changes
for relatively rare cases.

Atof64Big parses a hard-coded "123456789123456789123456789".

name                  old time/op  new time/op  delta
Atof64Decimal-4       47.1ns ± 1%  47.4ns ± 2%      ~     (p=0.516 n=5+5)
Atof64Float-4         56.4ns ± 1%  55.9ns ± 2%      ~     (p=0.206 n=5+5)
Atof64FloatExp-4      68.8ns ± 0%  68.7ns ± 1%      ~     (p=0.516 n=5+5)
Atof64Big-4            157ns ± 2%  1528ns ± 2%  +875.99%  (p=0.008 n=5+5)
Atof64RandomBits-4     156ns ± 1%   186ns ± 1%   +19.49%  (p=0.008 n=5+5)
Atof64RandomFloats-4   144ns ± 0%   143ns ± 1%      ~     (p=0.365 n=5+5)
Atof32Decimal-4       47.6ns ± 1%  47.5ns ± 2%      ~     (p=0.714 n=5+5)
Atof32Float-4         54.3ns ± 2%  54.1ns ± 1%      ~     (p=0.532 n=5+5)
Atof32FloatExp-4      75.2ns ± 1%  75.7ns ± 3%      ~     (p=0.794 n=5+5)
Atof32Random-4         108ns ± 1%   120ns ± 1%   +10.54%  (p=0.008 n=5+5)

Fixes #36657

Change-Id: Id3c4e1700f969f885b580be54c8892b4fe042a79
Reviewed-on: https://go-review.googlesource.com/c/go/+/264518
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Nigel Tao <nigeltao@golang.org>

4 years agocmd/asm: refactor some encoding functions for load/store with immediate offset on...
fanzha02 [Fri, 16 Oct 2020 10:35:30 +0000 (18:35 +0800)]
cmd/asm: refactor some encoding functions for load/store with immediate offset on arm64

Some of the current functions for encoding load/store with
immediate offset instructions, like opstr12(), opstr9(),
opldr12(), opldr9() and opldrpp(), etc., they have the same
code, so this patch refactors them and merges them into two
functions opstr() and opldr().

Change-Id: I60367f8b720b77c7ebe6d66905a950dcf7701836
Reviewed-on: https://go-review.googlesource.com/c/go/+/263479
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: fannie zhang <Fannie.Zhang@arm.com>

4 years agodatabase/sql: fix TestTxStmtDeadlock test
Tzu-Chiao Yeh [Wed, 28 Oct 2020 22:03:08 +0000 (06:03 +0800)]
database/sql: fix TestTxStmtDeadlock test

Drop error check because errors can be
not only ErrTxDone for tx stmt executions,
and the purpose of the test is just reproducing
deadlock.

Fixes #42259

Change-Id: I9e7105ada1403ec7064dcc1c3385b36893a1c195
Reviewed-on: https://go-review.googlesource.com/c/go/+/266097
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: use magic multiply for unsigned values less than 1<<16 on 32-bit archite...
Rémy Oudompheng [Sun, 25 Oct 2020 10:52:29 +0000 (11:52 +0100)]
cmd/compile: use magic multiply for unsigned values less than 1<<16 on 32-bit architectures

This is done by decomposing the number to be divided in 32-bit
components and using the 32-bit magic multiply. For the lowering to be
effective the constant must fit in 16 bits.

On ARM the expression n / 5 compiles to 25 instructions.

Benchmark for GOARCH=arm (Cortex-A53)

name                     old time/op  new time/op  delta
DivconstU64/3-6          1.19µs ± 0%  0.03µs ± 1%  -97.40%  (p=0.000 n=9+9)
DivconstU64/5-6          1.18µs ± 1%  0.03µs ± 1%  -97.38%  (p=0.000 n=10+8)
DivconstU64/37-6         1.13µs ± 1%  0.04µs ± 1%  -96.51%  (p=0.000 n=10+8)
DivconstU64/1234567-6     852ns ± 0%   901ns ± 1%   +5.73%  (p=0.000 n=8+9)

Benchmark for GOARCH=386 (Haswell)

name                     old time/op  new time/op  delta
DivconstU64/3-4          18.0ns ± 2%   5.6ns ± 1%  -69.06%  (p=0.000 n=10+10)
DivconstU64/5-4          17.8ns ± 1%   5.5ns ± 1%  -68.87%  (p=0.000 n=9+10)
DivconstU64/37-4         17.8ns ± 1%   7.3ns ± 0%  -58.90%  (p=0.000 n=10+10)
DivconstU64/1234567-4    17.5ns ± 1%  16.0ns ± 0%   -8.55%  (p=0.000 n=10+9)

Change-Id: I38a19b4d59093ec021ef2e5241364a3dad4eae73
Reviewed-on: https://go-review.googlesource.com/c/go/+/264683
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agocmd/buildid: move and reuse duplicated HashToString code to cmd/internal/buildid...
Mikhail Fesenko [Wed, 28 Oct 2020 20:35:23 +0000 (20:35 +0000)]
cmd/buildid: move and reuse duplicated HashToString code to cmd/internal/buildid/buildid

Change-Id: I1e1ac770d4aac12d7d7ec57ef95f77a3e14a678c
GitHub-Last-Rev: c01db4346eb08ffe0c1953892fb4222764048e30
GitHub-Pull-Request: golang/go#42052
Reviewed-on: https://go-review.googlesource.com/c/go/+/263418
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Michael Matloob <matloob@golang.org>

4 years agonet/url: improve performance for resolvePath
imxyb [Wed, 28 Oct 2020 21:26:04 +0000 (21:26 +0000)]
net/url: improve performance for resolvePath

benchmark compare results:

benchmark                   old ns/op     new ns/op     delta
BenchmarkResolvePath-12     297           141           -52.53%

benchmark                   old allocs     new allocs     delta
BenchmarkResolvePath-12     5              3              -40.00%

benchmark                   old bytes     new bytes     delta
BenchmarkResolvePath-12     181           24            -86.74%

Change-Id: Ia69e9fb36abb5930ed49217b5219be62b57ec429
GitHub-Last-Rev: e16dd9f7415178120f67f472bf45a2b006e00a93
GitHub-Pull-Request: golang/go#42180
Reviewed-on: https://go-review.googlesource.com/c/go/+/264817
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agocmd/go: use internal/testenv instead of computing canRun and skipExternal ad-hoc
Bryan C. Mills [Wed, 28 Oct 2020 14:44:24 +0000 (10:44 -0400)]
cmd/go: use internal/testenv instead of computing canRun and skipExternal ad-hoc

Fixes #42223

Change-Id: Icf9bb61d48f0a6c7fd6f74e80e333a4837aa52ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/265781
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agodoc: mention Trust+1 in contribution guide
Ian Lance Taylor [Mon, 5 Oct 2020 23:00:08 +0000 (16:00 -0700)]
doc: mention Trust+1 in contribution guide

For #40699

Change-Id: If753a073488880433ae3319dcf2a2dfaa887fd0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/259737
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Russ Cox <rsc@golang.org>
4 years agocmd/compile: rename mergeSymTyped to mergeSym
Alberto Donizetti [Wed, 28 Oct 2020 09:10:55 +0000 (10:10 +0100)]
cmd/compile: rename mergeSymTyped to mergeSym

Also make canMergeSym take Syms instead of interface{}

Change-Id: I4926a1fc586aa90e198249d67e5b520404b40869
Reviewed-on: https://go-review.googlesource.com/c/go/+/265817
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: delete log2, switch to log64
Alberto Donizetti [Tue, 27 Oct 2020 10:30:14 +0000 (11:30 +0100)]
cmd/compile: delete log2, switch to log64

rewrite.go has two identical functions log2 and log64; the former has
been there for a while, while the latter was added together with
log{8,16,32} for use in typed rules.

This change deletes log2 and switches to using log64 everywhere.

Change-Id: I759b878814e4c115a5fa470274f22477738d69ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/265457
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: add defs for openbsd/mips64
Joel Sing [Tue, 25 Aug 2020 07:53:08 +0000 (17:53 +1000)]
runtime: add defs for openbsd/mips64

Update #40995

Change-Id: I6963ead1a7c4520092361cce80edb17010e7f436
Reviewed-on: https://go-review.googlesource.com/c/go/+/250579
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
4 years agoruntime: remove new g register (X27) from preempt save/restore
Joel Sing [Tue, 27 Oct 2020 12:10:13 +0000 (23:10 +1100)]
runtime: remove new g register (X27) from preempt save/restore

The g register is now in X27 (previously X4, which collided with TP usage). Remove
X27 from preempt save/restore.

Change-Id: I9dd38ec3a8222fa0710757463769dbfac8ae7d20
Reviewed-on: https://go-review.googlesource.com/c/go/+/265517
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime: try to elide timer stealing if P has no timers
Michael Pratt [Mon, 5 Oct 2020 22:12:35 +0000 (18:12 -0400)]
runtime: try to elide timer stealing if P has no timers

Following golang.org/cl/259578, findrunnable still must touch every
other P in checkTimers in order to look for timers to steal. This scales
poorly with GOMAXPROCS and potentially performs poorly by pulling remote
Ps into cache.

Add timerpMask, a bitmask that tracks whether each P may have any timers
on its timer heap.

Ideally we would update this field on any timer add / remove to always
keep it up to date. Unfortunately, updating a shared global structure is
antithetical to sharding timers by P, and doing so approximately doubles
the cost of addtimer / deltimer in microbenchmarks.

Instead we only (potentially) clear the mask when the P goes idle. This
covers the best case of avoiding looking at a P _at all_ when it is idle
and has no timers. See the comment on updateTimerPMask for more details
on the trade-off. Future CLs may be able to expand cases we can avoid
looking at the timers.

Note that the addition of idlepMask to p.init is a no-op. The zero value
of the mask is the correct init value so it is not necessary, but it is
included for clarity.

Benchmark results from WakeupParallel/syscall/pair/race/1ms (see
golang.org/cl/228577). Note that these are on top of golang.org/cl/259578:

name                        old msec           new msec   delta
Perf-task-clock-8           244 ± 4%           246 ± 4%     ~     (p=0.841 n=5+5)
Perf-task-clock-16          247 ±11%           252 ± 4%     ~     (p=1.000 n=5+5)
Perf-task-clock-32          270 ± 1%           268 ± 2%     ~     (p=0.548 n=5+5)
Perf-task-clock-64          302 ± 3%           296 ± 1%     ~     (p=0.222 n=5+5)
Perf-task-clock-128         358 ± 3%           352 ± 2%     ~     (p=0.310 n=5+5)
Perf-task-clock-256         483 ± 3%           458 ± 1%   -5.16%  (p=0.008 n=5+5)
Perf-task-clock-512         663 ± 1%           612 ± 4%   -7.61%  (p=0.008 n=5+5)
Perf-task-clock-1024      1.06k ± 1%         0.95k ± 2%  -10.24%  (p=0.008 n=5+5)

Updates #28808
Updates #18237

Change-Id: I4239cd89f21ad16dfbbef58d81981da48acd0605
Reviewed-on: https://go-review.googlesource.com/c/go/+/264477
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Trust: Michael Pratt <mpratt@google.com>

4 years agoRevert "cmd/compile: split exported/non-exported methods for interface type"
Cuong Manh Le [Wed, 21 Oct 2020 17:25:17 +0000 (00:25 +0700)]
Revert "cmd/compile: split exported/non-exported methods for interface type"

This reverts commit 8f26b57f9afc238bdecb9b7030bc2f4364093885.

Reason for revert: break a bunch of code, include standard library.

Fixes #42123

Change-Id: Ife90ecbafd2cb395623d1db555fbfc9c1b0098e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/264026
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
4 years agoos: do not use procfs for os.Executable in dragonfly
Antonio Huete Jimenez [Wed, 28 Oct 2020 11:44:26 +0000 (11:44 +0000)]
os: do not use procfs for os.Executable in dragonfly

  procfs(5) is not always mounted in DragonFly BSD, for example during
  the binary package build with synth. os.Executable() consumers
  will then fail, we've spotted this when trying to build tinygo:

    [...]

    copying source files
    ./build/tinygo build-builtins -target=armv6m-none-eabi [...]
    panic: could not get executable path: readlink /proc/curproc/file:
    no such file or directory

    [...]

  Use KERN_PROC_PATHNAME as FreeBSD does.

Change-Id: Ic65bea02cd0309fb24dec8ba8d2b151d1acde67b
GitHub-Last-Rev: 083120a43b3158bb45d7e1a66fa32e3335a2d407
GitHub-Pull-Request: golang/go#36826
Reviewed-on: https://go-review.googlesource.com/c/go/+/216622
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>

4 years agodatabase/sql: fix tx stmt deadlock when rollback
Tzu-Chiao Yeh [Mon, 24 Aug 2020 14:04:17 +0000 (22:04 +0800)]
database/sql: fix tx stmt deadlock when rollback

Tx acquires tx.closemu W-lock and then acquires stmt.closemu.W-lock
to fully close the transaction and associated prepared statement.
Stmt query and execution run in reverse ways - acquires
stmt.closemu.R-lock and then acquires tx.closemu.R-lock to grab tx
connection, which may cause deadlock.

Prevent the lock is held around tx.closePrepared to ensure no
deadlock happens.

Fixes #40985

Change-Id: If53909822b87bce11861a6e3035ecb9476d2cd17
Reviewed-on: https://go-review.googlesource.com/c/go/+/250178
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agocmd/go/internal/modfetch: drop gopkg.in/russross/blackfriday.v2 from TestCodeRepoVersions
Tobias Klauser [Wed, 28 Oct 2020 12:44:53 +0000 (13:44 +0100)]
cmd/go/internal/modfetch: drop gopkg.in/russross/blackfriday.v2 from TestCodeRepoVersions

Follow-up for CL 265819.

Given the -pre tag added recently, a new stable version is likely
tagged soon. This would break TestCodeRepoVersions on the longtest
builders again. Since the other test cases in codeRepoVersionsTests
already provide enough coverage, drop gopkg.in/russross/blackfriday.v2
to avoid breaking TestCodeRepoVersions once the release happens.

Updates #28856

Change-Id: If86a637b5e47f59faf9048fc1cbbae6e8f1dcc53
Reviewed-on: https://go-review.googlesource.com/c/go/+/265917
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime: add edge lockRankSysmon -> lockRankRwmutexR
Dan Scales [Tue, 27 Oct 2020 22:52:42 +0000 (15:52 -0700)]
runtime: add edge lockRankSysmon -> lockRankRwmutexR

Sysmon can actually get the RW lock execLock while holding the sysmon
lock (if no M is available), so there is an edge from lockRankSysmon to
lockRankRwmutexR. The stack trace is sysmon() [gets sched.sysmonlock] ->
startm() -> newm() -> newm1() -> execLock.runlock() [gets
execLock.rLock]

Change-Id: I9658659ba3899afb5219114d66b989abd50540db
Reviewed-on: https://go-review.googlesource.com/c/go/+/265721
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agocmd/link: enable internal linking by default on darwin/arm64
Cherry Zhang [Sun, 25 Oct 2020 00:58:38 +0000 (20:58 -0400)]
cmd/link: enable internal linking by default on darwin/arm64

With previous CLs, internal linking without cgo should work well.
Enable it by default. And stop always requiring cgo.

Enable tests that were previously disabled due to the lack of
internal linking.

Updates #38485.

Change-Id: I45125b9c263fd21d6847aa6b14ecaea3a2989b29
Reviewed-on: https://go-review.googlesource.com/c/go/+/265121
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoruntime: always enable async preemption on darwin/arm64
Cherry Zhang [Sat, 24 Oct 2020 20:34:12 +0000 (16:34 -0400)]
runtime: always enable async preemption on darwin/arm64

Now that we have the G register saved, we can enable asynchronous
preemption for pure Go programs on darwin/arm64.

Updates #38485, #36365.

Change-Id: Ic654fa4dce369efe289b38d59cf1a184b358fe9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/265120
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoruntime: save/restore g unconditionally on darwin/arm64
Cherry Zhang [Sat, 24 Oct 2020 20:29:26 +0000 (16:29 -0400)]
runtime: save/restore g unconditionally on darwin/arm64

Now that we always have TLS set up, we can always save the G
register, regardless of whether cgo is used. This makes pure Go
programs signal-safe.

Updates #38485.

Change-Id: Icbc69acf0e2a5652fbcbbd074258a1a5efe87f1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/265119
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
4 years agoruntime: set up TLS without cgo on darwin/arm64
Cherry Zhang [Sat, 24 Oct 2020 17:14:36 +0000 (13:14 -0400)]
runtime: set up TLS without cgo on darwin/arm64

Currently, on darwin/arm64 we set up TLS using cgo. TLS is not
set for pure Go programs. As we use libc for syscalls on darwin,
we need to save the G register before the libc call. Otherwise it
is not signal-safe, as a signal may land during the execution of
a libc function, where the G register may be clobbered.

This CL initializes TLS in Go, by calling the pthread functions
directly without cgo. This makes it possible to save the G
register to TLS in pure Go programs (done in a later CL).

Inspired by Elias's CL 209197. Write the logic in Go instead of
assembly.

Updates #38485, #35853.

Change-Id: I257ba2a411ad387b2f4d50d10129d37fec7a226e
Reviewed-on: https://go-review.googlesource.com/c/go/+/265118
Trust: Cherry Zhang <cherryyz@google.com>
Trust: Elias Naur <mail@eliasnaur.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/go/internal/modfetch: update expected tags for TestCodeRepoVersions
Tobias Klauser [Wed, 28 Oct 2020 11:07:31 +0000 (12:07 +0100)]
cmd/go/internal/modfetch: update expected tags for TestCodeRepoVersions

Updates #28856

Change-Id: I89c564cefd7c5777904bc00c74617dab693373bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/265819
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile,cmd/internal/obj/riscv,runtime: use Duff's devices on riscv64
Michał Derkacz [Sat, 13 Jun 2020 22:06:24 +0000 (00:06 +0200)]
cmd/compile,cmd/internal/obj/riscv,runtime: use Duff's devices on riscv64

Implement runtime.duffzero and runtime.duffcopy for riscv64.
Use obj.ADUFFZERO/obj.ADUFFCOPY for medium size, word aligned
zeroing/moving.

Change-Id: I42ec622055630c94cb77e286d8d33dbe7c9f846c
Reviewed-on: https://go-review.googlesource.com/c/go/+/237797
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: optimize generated struct/array equality code
Keith Randall [Wed, 16 Sep 2020 17:13:37 +0000 (10:13 -0700)]
cmd/compile: optimize generated struct/array equality code

Use a standard "not-equal" label that we can jump to when we
detect that the arguments are not equal. This prevents the
recombination that was noticed in #39428.

Fixes #39428

Change-Id: Ib7c6b3539f4f6046043fd7148f940fcdcab70427
Reviewed-on: https://go-review.googlesource.com/c/go/+/255317
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
4 years agoruntime: move TestNeedmDeadlock to crash_cgo_test.go
Ian Lance Taylor [Wed, 28 Oct 2020 04:05:13 +0000 (21:05 -0700)]
runtime: move TestNeedmDeadlock to crash_cgo_test.go

It requires cgo. Also, skip the test on windows and plan9.

For #42207

Change-Id: I8522773f93bc3f9826506a41a08b86a083262e31
Reviewed-on: https://go-review.googlesource.com/c/go/+/265778
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agocmd/compile: make sure field offset is aligned for structure splitting
David Chase [Mon, 26 Oct 2020 23:06:39 +0000 (19:06 -0400)]
cmd/compile: make sure field offset is aligned for structure splitting

Always use the aligned form -- the old code sometimes could
at least nominally use a misaligned field in an SSA-able struct,
even if not actually.

Fixes #42181.

Change-Id: Ibdce0985f9349da70921a37423054b85ee4200d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/265277
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: David Chase <drchase@google.com>

4 years agocmd/link: remove all constants of elf
Meng Zhuo [Tue, 27 Oct 2020 06:18:13 +0000 (14:18 +0800)]
cmd/link: remove all constants of elf

Use debug/elf instead.

Related:
CL 252478
CL 265317

Change-Id: If63b0458d9a6e825b40616bfb7a5a2c2e32402b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/265318
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoruntime: block signals in needm before allocating M
Ian Lance Taylor [Tue, 27 Oct 2020 23:09:40 +0000 (16:09 -0700)]
runtime: block signals in needm before allocating M

Otherwise, if a signal occurs just after we allocated the M,
we can deadlock if the signal handler needs to allocate an M
itself.

Fixes #42207

Change-Id: I76f44547f419e8b1c14cbf49bf602c6e645d8c14
Reviewed-on: https://go-review.googlesource.com/c/go/+/265759
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: add -include to cgo whitelist
Dave Pifke [Thu, 2 Jul 2020 00:48:37 +0000 (00:48 +0000)]
cmd/go: add -include to cgo whitelist

Fixes #39988.

Change-Id: Ia6f5b73e6508f27e3badbcbd29dbeadffd55a932
Reviewed-on: https://go-review.googlesource.com/c/go/+/240739
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoruntime: handle signal 34 for musl setgid
George Tsilias [Thu, 4 Jun 2020 20:11:56 +0000 (23:11 +0300)]
runtime: handle signal 34 for musl setgid

It has been observed that setgid hangs when using cgo with musl.
This fix ensures that signal 34 gets handled in an appropriate way,
like signal 33 when using glibc.

Fixes #39343

Change-Id: I89565663e2c361f62cbccfe80aaedf290bd58d57
Reviewed-on: https://go-review.googlesource.com/c/go/+/236518
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/dist: use GOOS=ios for iOS simulator test
Cherry Zhang [Sun, 25 Oct 2020 02:02:50 +0000 (22:02 -0400)]
cmd/dist: use GOOS=ios for iOS simulator test

Updates #42100.

Change-Id: Ib59432bea99a9dd6e25fbd759b31e423dc250f42
Reviewed-on: https://go-review.googlesource.com/c/go/+/265197
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agotime: fix LoadLocationFromTZData with slim tzdata
Christopher Hlubek [Mon, 26 Oct 2020 12:44:44 +0000 (13:44 +0100)]
time: fix LoadLocationFromTZData with slim tzdata

The extend information of a time zone file with last transition < now
could result in a wrong cached zone because it used the zone of the
last transition.

This could lead to wrong zones in systems with slim zoneinfo.

Fixes #42216

Change-Id: I7c57c35b5cfa58482ac7925b5d86618c52f5444d
Reviewed-on: https://go-review.googlesource.com/c/go/+/264939
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocrypto/tls: document the ClientAuthType consts
Roland Shoemaker [Wed, 21 Oct 2020 17:59:22 +0000 (10:59 -0700)]
crypto/tls: document the ClientAuthType consts

Fixes #34023

Change-Id: Ib7552a8873a79a91e8d971f906c6d7283da7a80c
Reviewed-on: https://go-review.googlesource.com/c/go/+/264027
Trust: Roland Shoemaker <roland@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
4 years agoruntime: don't always adjust timers
Ian Lance Taylor [Wed, 30 Sep 2020 00:01:33 +0000 (17:01 -0700)]
runtime: don't always adjust timers

Some programs have a lot of timers that they adjust both forward and
backward in time. This can cause a large number of timerModifiedEarlier
timers. In practice these timers are used for I/O deadlines and are
rarely reached. The effect is that the runtime spends a lot of time
in adjusttimers making sure that there are no timerModifiedEarlier
timers, but the effort is wasted because none of the adjusted timers
are near the top of the timer heap anyhow.

Avoid much of this extra work by keeping track of the earliest known
timerModifiedEarlier timer. This lets us skip adjusttimers if we know
that none of the timers will be ready to run anyhow. We will still
eventually run it, when we reach the deadline of the earliest known
timerModifiedEarlier, although in practice that timer has likely
been removed. When we do run adjusttimers, we will reset all of the
timerModifiedEarlier timers, and clear our notion of when we need
to run adjusttimers again.

This effect should be to significantly reduce the number of times we
walk through the timer list in adjusttimers.

Fixes #41699

Change-Id: I38eb2be611fb34e3017bb33d0a9ed40d75fb414f
Reviewed-on: https://go-review.googlesource.com/c/go/+/258303
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agocmd/compile: print pointers to go:notinheap types without converting to unsafe.Pointer
Keith Randall [Tue, 27 Oct 2020 21:15:00 +0000 (14:15 -0700)]
cmd/compile: print pointers to go:notinheap types without converting to unsafe.Pointer

Pretty minor concern, but after auditing the compiler/runtime for
conversions from pointers to go:notinheap types to unsafe.Pointer,
this is the only remaining one I found.

Update #42076

Change-Id: I81d5b893c9ada2fc19a51c2559262f2e9ff71c35
Reviewed-on: https://go-review.googlesource.com/c/go/+/265757
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile, runtime: store pointers to go:notinheap types indirectly
Keith Randall [Thu, 22 Oct 2020 23:37:19 +0000 (16:37 -0700)]
cmd/compile, runtime: store pointers to go:notinheap types indirectly

pointers to go:notinheap types should be treated as scalars. That
means they shouldn't be stored directly in interfaces, or directly
in reflect.Value.ptr.

Also be sure to use uintpr to compare such pointers in reflect.DeepEqual.

Fixes #42076

Change-Id: I53735f6d434e9c3108d4940bd1bae14c61ef2a74
Reviewed-on: https://go-review.googlesource.com/c/go/+/264480
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: fix storeType to handle pointers to go:notinheap types
Keith Randall [Thu, 22 Oct 2020 20:11:16 +0000 (13:11 -0700)]
cmd/compile: fix storeType to handle pointers to go:notinheap types

storeType splits compound stores up into a scalar parts and a pointer parts.
The scalar part happens unconditionally, and the pointer part happens
under the guard of a write barrier check.

Types which are declared as pointers, but are represented as scalars because
they might have "bad" values, were not handled correctly here. They ended
up not getting stored in either set.

Fixes #42032

Change-Id: I46f6600075c0c370e640b807066247237f93c7ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/264300
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agogo/internal/gccgoimporter: support notinheap annotation
Ian Lance Taylor [Tue, 27 Oct 2020 19:59:54 +0000 (12:59 -0700)]
go/internal/gccgoimporter: support notinheap annotation

The gofrontend has started emitting a notinheap annotation for types
marked go:notinheap.

For #41761

Change-Id: Ic8f7ffc32dbfe98ec09b3d835957f1be8e6c1208
Reviewed-on: https://go-review.googlesource.com/c/go/+/265702
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agodoc/go1.16: document BuildID in 'go list -export'
Daniel Martí [Thu, 22 Oct 2020 15:30:26 +0000 (16:30 +0100)]
doc/go1.16: document BuildID in 'go list -export'

This corresponds to the feature in https://golang.org/cl/263542, since
this can be a noteworthy change to people writing tools to inspect Go
builds.

Also amend the wording to clarify that build IDs are for an entire
compiled package, not just their export data or object file.

Change-Id: I2eb295492807d5d2997a35e5e2371914cb3ad3a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/264158
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/compile: replace int32(b2i(x)) with b2i32(x) in rules
Alberto Donizetti [Tue, 27 Oct 2020 13:04:10 +0000 (14:04 +0100)]
cmd/compile: replace int32(b2i(x)) with b2i32(x) in rules

Change-Id: I7fbb0c1ead6e29a7445c8ab43f7050947597f3e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/265497
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: delete isPowerOfTwo, switch to isPowerOfTwo64
Alberto Donizetti [Tue, 27 Oct 2020 10:03:21 +0000 (11:03 +0100)]
cmd/compile: delete isPowerOfTwo, switch to isPowerOfTwo64

rewrite.go has two identical functions isPowerOfTwo and
isPowerOfTwo64; the former has been there for a while, while the
latter was added together with isPowerOfTwo{8,16,32} for use in typed
rules.

This change deletes isPowerOfTwo and switch to using isPowerOfTwo64
everywhere.

Change-Id: If26c94565d2393fac6f0ba117ee7ee2fc915f7cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/265417
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: clean up ValAndOff funcs after untyped aux removal
Alberto Donizetti [Tue, 27 Oct 2020 08:38:52 +0000 (09:38 +0100)]
cmd/compile: clean up ValAndOff funcs after untyped aux removal

Changes:
- makeValAndOff is deleted in favour of MakeValAndOff{32,64}
- canAdd is renamed to canAdd64 to uniform with existing canAdd32
- addOffset{32,64} is simplified by directly using MakeValAndOff{32,64}
- ValAndOff.Int64 is removed

Change-Id: Ic01db7fa31ddfe0aaaf1d1d77af823d48a7bee84
Reviewed-on: https://go-review.googlesource.com/c/go/+/265357
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

4 years agocmd/compile: remove support for untyped ssa rules
Alberto Donizetti [Sat, 24 Oct 2020 15:27:52 +0000 (17:27 +0200)]
cmd/compile: remove support for untyped ssa rules

This change removes support in rulegen for untyped -> ssa rules.

Change-Id: I202018e191fc74f027243351bc8cf96145f2482c
Reviewed-on: https://go-review.googlesource.com/c/go/+/264679
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

4 years agoruntime: add 2-byte and 8-byte sub-benchmarks for memmove load/store
Heisenberg [Tue, 8 Sep 2020 06:31:39 +0000 (14:31 +0800)]
runtime: add 2-byte and 8-byte sub-benchmarks for memmove load/store

Change-Id: I6389d7efe90836b6ece44d2e75053d1ad9f35d08
Reviewed-on: https://go-review.googlesource.com/c/go/+/253417
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agonet/http: use exponential backoff for polling in Server.Shutdown
Dan Peterson [Thu, 22 Oct 2020 22:25:56 +0000 (19:25 -0300)]
net/http: use exponential backoff for polling in Server.Shutdown

Instead of always polling 500ms, start with an interval of 1ms and
exponentially back off to at most 500ms. 10% jitter is added to each
interval.

This makes Shutdown more responsive when connections and listeners
close quickly.

Also removes the need for the polling interval to be changed in tests
since if tests' connections and listeners close quickly Shutdown will
also return quickly.

Fixes #42156

Change-Id: I5e59844a2980c09adebff57ae8b58817965e6db4
Reviewed-on: https://go-review.googlesource.com/c/go/+/264479
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Bryan C. Mills <bcmills@google.com>

4 years agocmd/compile: combine more 32 bit shift and mask operations on ppc64
Paul E. Murphy [Fri, 23 Oct 2020 17:12:34 +0000 (12:12 -0500)]
cmd/compile: combine more 32 bit shift and mask operations on ppc64

Combine (AND m (SRWconst x)) or (SRWconst (AND m x)) when mask m is
and the shift value produce constant which can be encoded into an
RLWINM instruction.

Combine (CLRLSLDI (SRWconst x)) if the combining of the underling rotate
masks produces a constant which can be encoded into RLWINM.

Likewise for (SLDconst (SRWconst x)) and (CLRLSDI (RLWINM x)).

Combine rotate word + and operations which can be encoded as a single
RLWINM/RLWNM instruction.

The most notable performance improvements arise from the crypto
benchmarks below (GOARCH=power8 on a ppc64le/linux):

pkg:golang.org/x/crypto/blowfish goos:linux goarch:ppc64le
ExpandKeyWithSalt                               52.2µs ± 0%    47.5µs ± 0%  -8.88%
ExpandKey                                       44.4µs ± 0%    40.3µs ± 0%  -9.15%

pkg:golang.org/x/crypto/ssh/internal/bcrypt_pbkdf goos:linux goarch:ppc64le
Key                                             57.6ms ± 0%    52.3ms ± 0%  -9.13%

pkg:golang.org/x/crypto/bcrypt goos:linux goarch:ppc64le
Equal                                           90.9ms ± 0%    82.6ms ± 0%  -9.13%
DefaultCost                                     91.0ms ± 0%    82.7ms ± 0%  -9.12%

Change-Id: I59a0ca29face38f4ab46e37124c32906f216c4ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/260798
Run-TryBot: Carlos Eduardo Seo <carlos.seo@linaro.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>

4 years agocmd/compile: remove isLiteral
Cuong Manh Le [Tue, 27 Oct 2020 10:08:57 +0000 (17:08 +0700)]
cmd/compile: remove isLiteral

It has duplicated logic with "n.isGoConst".

Passes toolstash-check.

Change-Id: I5bf871ef81c7188ca09dae29c7ff55b3a254d972
Reviewed-on: https://go-review.googlesource.com/c/go/+/265437
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agomisc/cgo/test: test C.enum_*
HowJMay [Tue, 27 Oct 2020 17:03:48 +0000 (17:03 +0000)]
misc/cgo/test: test C.enum_*

Allocate a C enum object, and test if it can be assigned a value
successfully.

For #39537

Change-Id: I7b5482112486440b9d99f2ee4051328d87f45dca
GitHub-Last-Rev: 81890f40acc5589563ec1206fe119873fb46dc1b
GitHub-Pull-Request: golang/go#39977
Reviewed-on: https://go-review.googlesource.com/c/go/+/240697
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agoruntime: reduce timer latency
Chris Hines [Fri, 1 May 2020 21:04:36 +0000 (17:04 -0400)]
runtime: reduce timer latency

Change the scheduler to treat expired timers with the same approach it
uses to steal runnable G's.

Previously the scheduler ignored timers on P's not marked for
preemption. That had the downside that any G's waiting on those expired
timers starved until the G running on their P completed or was
preempted. That could take as long as 20ms if sysmon was in a 10ms
wake up cycle.

In addition, a spinning P that ignored an expired timer and found no
other work would stop despite there being available work, missing the
opportunity for greater parallelism.

With this change the scheduler no longer ignores timers on
non-preemptable P's or relies on sysmon as a backstop to start threads
when timers expire. Instead it wakes an idle P, if needed, when
creating a new timer because it cannot predict if the current P will
have a scheduling opportunity before the new timer expires. The P it
wakes will determine how long to sleep and block on the netpoller for
the required time, potentially stealing the new timer when it wakes.

This change also eliminates a race between a spinning P transitioning
to idle concurrently with timer creation using the same pattern used
for submission of new goroutines in the same window.

Benchmark analysis:

CL 232199, which was included in Go 1.15 improved timer latency over Go
1.14 by allowing P's to steal timers from P's not marked for preemption.
The benchmarks added in this CL measure that improvement in the
ParallelTimerLatency benchmark seen below. However, Go 1.15 still relies
on sysmon to notice expired timers in some situations and sysmon can
sleep for up to 10ms before waking to check timers. This CL fixes that
shortcoming with modest regression on other benchmarks.

name \ avg-late-ns                                        go14.time.bench  go15.time.bench  fix.time.bench
ParallelTimerLatency-8                                         17.3M ± 3%        7.9M ± 0%       0.2M ± 3%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=1-8        53.4k ±23%       50.7k ±31%     252.4k ± 9%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=2-8         204k ±14%         90k ±58%       188k ±12%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=3-8        1.17M ± 0%       0.11M ± 5%      0.11M ± 2%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=4-8        1.81M ±44%       0.10M ± 4%      0.10M ± 2%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=5-8        2.28M ±66%       0.09M ±13%      0.08M ±21%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=6-8        2.84M ±85%       0.07M ±15%      0.07M ±18%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=7-8        2.13M ±27%       0.06M ± 4%      0.06M ± 9%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=8-8        2.63M ± 6%       0.06M ±11%      0.06M ± 9%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=9-8        3.32M ±17%       0.06M ±16%      0.07M ±14%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=10-8       8.46M ±20%       4.37M ±21%      5.03M ±23%
StaggeredTickerLatency/work-dur=2ms/tickers-per-P=1-8          1.02M ± 1%       0.20M ± 2%      0.20M ± 2%

name \ max-late-ns                                        go14.time.bench  go15.time.bench  fix.time.bench
ParallelTimerLatency-8                                         18.3M ± 1%        8.2M ± 0%       0.5M ±12%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=1-8         141k ±19%        127k ±19%      1129k ± 3%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=2-8        2.78M ± 4%       1.23M ±15%      1.26M ± 5%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=3-8        6.05M ± 5%       0.67M ±56%      0.81M ±33%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=4-8        7.93M ±20%       0.71M ±46%      0.76M ±41%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=5-8        9.41M ±30%       0.92M ±23%      0.81M ±44%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=6-8        10.8M ±42%        0.8M ±41%       0.8M ±30%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=7-8        9.62M ±24%       0.77M ±38%      0.88M ±27%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=8-8        10.6M ±10%        0.8M ±32%       0.7M ±27%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=9-8        11.9M ±36%        0.6M ±46%       0.8M ±38%
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=10-8       36.8M ±21%       24.7M ±21%      27.5M ±16%
StaggeredTickerLatency/work-dur=2ms/tickers-per-P=1-8          2.12M ± 2%       1.02M ±11%      1.03M ± 7%

Other time benchmarks:
name \ time/op          go14.time.bench  go15.time.bench  fix.time.bench
AfterFunc-8                  137µs ± 4%       123µs ± 4%      131µs ± 2%
After-8                      212µs ± 3%       195µs ± 4%      204µs ± 7%
Stop-8                       165µs ± 6%       156µs ± 2%      151µs ±12%
SimultaneousAfterFunc-8      260µs ± 3%       248µs ± 3%      284µs ± 2%
StartStop-8                 65.8µs ± 9%      64.4µs ± 7%     67.3µs ±15%
Reset-8                     13.6µs ± 2%       9.6µs ± 2%      9.1µs ± 4%
Sleep-8                      307µs ± 4%       306µs ± 3%      320µs ± 2%
Ticker-8                    53.0µs ± 5%      54.5µs ± 5%     57.0µs ±11%
TickerReset-8                                9.24µs ± 2%     9.51µs ± 3%
TickerResetNaive-8                            149µs ± 5%      145µs ± 5%

Fixes #38860
Updates #25471
Updates #27707

Change-Id: If52680509b0f3b66dbd1d0c13fa574bd2d0bbd57
Reviewed-on: https://go-review.googlesource.com/c/go/+/232298
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Trust: Ian Lance Taylor <iant@golang.org>

4 years agocmd/dist: fix build failure of misc/cgo/test on arm64
xd [Wed, 14 Oct 2020 18:02:49 +0000 (11:02 -0700)]
cmd/dist: fix build failure of misc/cgo/test on arm64

misc/cgo/test fails in 'dist test' on arm64 if the C compiler is of GCC-9.4 or
above and its 'outline atomics' feature is enabled, since the internal linking
hasn't yet supported "__attribute__((constructor))" and also mis-handles hidden
visibility.

This change addresses the problem by skipping the internal linking cases of
misc/cgo/test on linux/arm64. It fixes 'dist test' failure only, user is expected to
pass a GCC option '-mno-outline-atomics' via CGO_CFLAGS if running into the same
problem when building cgo programs using internal linking.

Updates #39466

Change-Id: I57f9e85fca881e5fd2dae6c1b4446bce9e0c1975
Reviewed-on: https://go-review.googlesource.com/c/go/+/262357
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agocmd/go/internal/fsys: add Glob
Russ Cox [Fri, 23 Oct 2020 01:33:02 +0000 (21:33 -0400)]
cmd/go/internal/fsys: add Glob

Glob is needed for //go:embed processing.

Also change TestReadDir to be deterministic
and print more output about failures.

Change-Id: Ie22a9c5b32bda753579ff98cec1d28e3244c4e06
Reviewed-on: https://go-review.googlesource.com/c/go/+/264538
Trust: Russ Cox <rsc@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agomime: look up mime types on Arch Linux
Andy Williams [Fri, 5 Jun 2020 10:18:47 +0000 (10:18 +0000)]
mime: look up mime types on Arch Linux

Some systems use "httpd" directory structure instead of "apache"

Change-Id: I77600baf356f0c0c3359b331505b0426112daebb
GitHub-Last-Rev: c64766f88cc28899d3d387e3eebfa4fcc3eef808
GitHub-Pull-Request: golang/go#39416
Reviewed-on: https://go-review.googlesource.com/c/go/+/236677
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agocmd/go/internal/imports: make Tags and AnyTags safe for concurrent use
Bryan C. Mills [Tue, 27 Oct 2020 07:09:26 +0000 (03:09 -0400)]
cmd/go/internal/imports: make Tags and AnyTags safe for concurrent use

AnyTags turned up as a data race while running 'go test -race cmd/go'.
I'm not sure how long the race has been present.

==================
WARNING: DATA RACE
Read at 0x000001141ec0 by goroutine 8:
  cmd/go/internal/imports.AnyTags()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/imports/tags.go:45 +0x10e
  cmd/go/internal/modload.QueryPattern.func2()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:539 +0x11d
  cmd/go/internal/modload.QueryPattern.func4.1()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:607 +0x3db
  cmd/go/internal/modload.queryPrefixModules.func1()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:677 +0xa7

Previous write at 0x000001141ec0 by goroutine 7:
  cmd/go/internal/imports.AnyTags()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/imports/tags.go:46 +0x26b
  cmd/go/internal/modload.QueryPattern.func2()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:539 +0x11d
  cmd/go/internal/modload.QueryPattern.func4.1()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:607 +0x3db
  cmd/go/internal/modload.queryPrefixModules.func1()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:677 +0xa7

Goroutine 8 (running) created at:
  cmd/go/internal/modload.queryPrefixModules()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:676 +0x284
  cmd/go/internal/modload.QueryPattern.func4()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:624 +0x2e4
  cmd/go/internal/modfetch.TryProxies()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modfetch/proxy.go:220 +0x107
  cmd/go/internal/modload.QueryPattern()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:590 +0x69e
  cmd/go/internal/work.installOutsideModule()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/work/build.go:744 +0x4b0
  cmd/go/internal/work.runInstall()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/work/build.go:556 +0x217
  main.main()
      /usr/local/google/home/bcmills/go/src/cmd/go/main.go:194 +0xb94

Goroutine 7 (finished) created at:
  cmd/go/internal/modload.queryPrefixModules()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:676 +0x284
  cmd/go/internal/modload.QueryPattern.func4()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:624 +0x2e4
  cmd/go/internal/modfetch.TryProxies()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modfetch/proxy.go:220 +0x107
  cmd/go/internal/modload.QueryPattern()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/modload/query.go:590 +0x69e
  cmd/go/internal/work.installOutsideModule()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/work/build.go:744 +0x4b0
  cmd/go/internal/work.runInstall()
      /usr/local/google/home/bcmills/go/src/cmd/go/internal/work/build.go:556 +0x217
  main.main()
      /usr/local/google/home/bcmills/go/src/cmd/go/main.go:194 +0xb94
==================

Change-Id: Id394978fd6ea0c30614caf8f90ee4f8e2d272843
Reviewed-on: https://go-review.googlesource.com/c/go/+/265278
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agodatabase/sql: fix comment on DB.stop()
Ayzat Sadykov [Sat, 24 Oct 2020 22:11:51 +0000 (22:11 +0000)]
database/sql: fix comment on DB.stop()

Previously, 2 goroutines were created in OpenDB and a comment in the DB.close() field indicated that they were canceled. Later, session Resetter () was removed, but the comment remained the same. This commit just fixes this message

Change-Id: Ie81026f51d7770e9cf8004818154021f626fb2e8
GitHub-Last-Rev: 38b338a0d1cd713d71fa547aa842d395e6d75484
GitHub-Pull-Request: golang/go#42191
Reviewed-on: https://go-review.googlesource.com/c/go/+/264838
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>

4 years agocmd/go: fix bug introduced in CL 264537
Russ Cox [Tue, 27 Oct 2020 14:41:25 +0000 (10:41 -0400)]
cmd/go: fix bug introduced in CL 264537

Shadowing bug noted after submit by Tom Thorogood.

Change-Id: I5f40cc3863dcd7dba5469f8530e9d0460e7c3e7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/265537
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: eliminate unnecessary sign/zero extension for riscv64
Joel Sing [Sat, 24 Oct 2020 14:34:17 +0000 (01:34 +1100)]
cmd/compile: eliminate unnecessary sign/zero extension for riscv64

Add additional rules to eliminate unnecessary sign/zero extension for riscv64.
Also where possible, replace an extension following a load with a different typed
load. This removes almost another 8,000 instructions from the go binary.

Of particular note, change Eq16/Eq8/Neq16/Neq8 to zero extend each value before
subtraction, rather than zero extending after subtraction. While this appears to
double the number of zero extensions, it often lets us completely eliminate them
as the load can already be performed in a properly typed manner.

As an example, prior to this change runtime.memequal16 was:

0000000000013028 <runtime.memequal16>:
   13028:       00813183                ld      gp,8(sp)
   1302c:       00019183                lh      gp,0(gp)
   13030:       01013283                ld      t0,16(sp)
   13034:       00029283                lh      t0,0(t0)
   13038:       405181b3                sub     gp,gp,t0
   1303c:       03019193                slli    gp,gp,0x30
   13040:       0301d193                srli    gp,gp,0x30
   13044:       0011b193                seqz    gp,gp
   13048:       00310c23                sb      gp,24(sp)
   1304c:       00008067                ret

Whereas it now becomes:

0000000000012fa8 <runtime.memequal16>:
   12fa8:       00813183                ld      gp,8(sp)
   12fac:       0001d183                lhu     gp,0(gp)
   12fb0:       01013283                ld      t0,16(sp)
   12fb4:       0002d283                lhu     t0,0(t0)
   12fb8:       405181b3                sub     gp,gp,t0
   12fbc:       0011b193                seqz    gp,gp
   12fc0:       00310c23                sb      gp,24(sp)
   12fc4:       00008067                ret

Change-Id: I16321feb18381241cab121c0097a126104c56c2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/264659
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocrypto/rand: generate random numbers using RtlGenRandom on Windows
Jason A. Donenfeld [Thu, 5 Dec 2019 17:48:21 +0000 (18:48 +0100)]
crypto/rand: generate random numbers using RtlGenRandom on Windows

CryptGenRandom appears to be unfavorable these days, whereas the classic
RtlGenRandom is still going strong.

This commit also moves the warnBlocked function into rand_unix, rather
than rand, because it's now only used on unix.

Fixes #33542

Change-Id: I5c02a5917572f54079d627972401efb6e1ce4057
Reviewed-on: https://go-review.googlesource.com/c/go/+/210057
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>

4 years agocmd/compile: use MOV pseudo-instructions for sign/zero extension
Joel Sing [Sat, 24 Oct 2020 13:32:23 +0000 (00:32 +1100)]
cmd/compile: use MOV pseudo-instructions for sign/zero extension

Rather than handling sign and zero extension via rules, defer to the assembler
and use MOV pseudo-instructions. The instruction can also be omitted where the
type and size is already correct. This change results in more than 6,000
instructions being removed from the go binary (in part due to omitted
instructions, in part due to MOVBU having a more efficient implementation in
the assembler than what is used in the current ZeroExt8to{16,32,64} rules).

This will also allow for further rewriting to remove redundant sign/zero
extension.

Change-Id: I05e42fd9f09f40a69948be7de772cce8946c8744
Reviewed-on: https://go-review.googlesource.com/c/go/+/264658
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/go/internal/modload: embed PackageOpts in loaderParams
Bryan C. Mills [Tue, 13 Oct 2020 14:58:13 +0000 (10:58 -0400)]
cmd/go/internal/modload: embed PackageOpts in loaderParams

Instead of duplicating PackageOpts fields in the loaderParams struct,
embed the PackageOpts directly. Many of the fields are duplicated, and
further fields that would also be duplicated will be added in
subsequent changes.

For #36460

Change-Id: I3b0770d162e901d23ec1643183eb07c413d51e0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/263138
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agoRevert "cmd/link: remove all constants of elf"
Meng Zhuo [Tue, 27 Oct 2020 05:13:24 +0000 (05:13 +0000)]
Revert "cmd/link: remove all constants of elf"

This reverts CL 252478.

Reason for revert: debug/Elfhdr has no Flags fields, some other CLs has removed it.

Change-Id: Ie199ac29f382c56aaf37a2e8338f2dafe6e79297
Reviewed-on: https://go-review.googlesource.com/c/go/+/265317
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Meng Zhuo <mzh@golangcn.org>

4 years agocmd/link: remove all constants of elf
Meng Zhuo [Wed, 23 Sep 2020 16:22:05 +0000 (00:22 +0800)]
cmd/link: remove all constants of elf

Use debug/elf instead.

Change-Id: Ia6580648b6440e4a352f5c5ed59ac4d1c95e0175
Reviewed-on: https://go-review.googlesource.com/c/go/+/252478
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/link,cmd/internal/obj/riscv: add TLS support for linux/riscv64
Joel Sing [Tue, 19 May 2020 08:55:10 +0000 (18:55 +1000)]
cmd/link,cmd/internal/obj/riscv: add TLS support for linux/riscv64

Add support for Thread Local Storage (TLS) for linux/riscv64 with external
linking, using the initial-exec model.

Update #36641

Change-Id: I3106ef9a29cde73215830b00deff43dbec1c76e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/263478
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile,cmd/internal/sys: enable additional build modes on linux/riscv64
Joel Sing [Tue, 2 Jun 2020 13:34:06 +0000 (23:34 +1000)]
cmd/compile,cmd/internal/sys: enable additional build modes on linux/riscv64

Enable c-archive, c-shared, shared and pie build modes for linux/riscv64.

Change-Id: I15a8a51b84dbbb82a5b6592aec84a7f09f0cc37f
Reviewed-on: https://go-review.googlesource.com/c/go/+/263457
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: defer lowering OANDNOT until SSA
Cuong Manh Le [Sat, 24 Oct 2020 03:40:09 +0000 (10:40 +0700)]
cmd/compile: defer lowering OANDNOT until SSA

Currently, "x &^ y" gets rewriten into "x & ^y" during walk. It adds
unnecessary complexity to other parts, which must aware about this.

Instead, we can just implement "&^" in the conversion to SSA, so "&^"
can be handled like other binary operators.

However, this CL does not pass toolstash-check. It seems that implements
"&^" in the conversion to SSA causes registers allocation change.

With the parent:

obj: 00212 (.../src/runtime/complex.go:47)    MOVQ    X0, AX
obj: 00213 (.../src/runtime/complex.go:47)    BTRQ    $63, AX
obj: 00214 (.../src/runtime/complex.go:47)    MOVQ    "".n(SP), CX
obj: 00215 (.../src/runtime/complex.go:47)    MOVQ    $-9223372036854775808, DX
obj: 00216 (.../src/runtime/complex.go:47)    ANDQ    DX, CX
obj: 00217 (.../src/runtime/complex.go:47)    ORQ AX, CX

With this CL:

obj: 00212 (.../src/runtime/complex.go:47)    MOVQ    X0, AX
obj: 00213 (.../src/runtime/complex.go:47)    BTRQ    $63, AX
obj: 00214 (.../src/runtime/complex.go:47)    MOVQ    $-9223372036854775808, CX
obj: 00215 (.../src/runtime/complex.go:47)    MOVQ    "".n(SP), DX
obj: 00216 (.../src/runtime/complex.go:47)    ANDQ    CX, DX
obj: 00217 (.../src/runtime/complex.go:47)    ORQ AX, DX

Change-Id: I80acf8496a91be4804fb7ef3df04c19baae2754c
Reviewed-on: https://go-review.googlesource.com/c/go/+/264660
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agotest: add index bounds check elided with "&^"
Cuong Manh Le [Mon, 26 Oct 2020 04:28:02 +0000 (11:28 +0700)]
test: add index bounds check elided with "&^"

For follow up CL, which will defer lowering OANDNOT until SSA.

Change-Id: I5a988d0b8f0ae664580f08b123811b2a31ef55c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/265040
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agoruntime: implement addrRanges.findSucc with a binary search
Michael Anthony Knyszek [Tue, 14 Jul 2020 21:45:16 +0000 (21:45 +0000)]
runtime: implement addrRanges.findSucc with a binary search

This change modifies addrRanges.findSucc to more efficiently find the
successor range in an addrRanges by using a binary search to narrow down
large addrRanges and iterate over no more than 8 addrRanges.

This change makes the runtime more robust against systems that may
aggressively randomize the address space mappings it gives the runtime
(e.g. Fuchsia).

For #40191.

Change-Id: If529df2abd2edb1b1496d8690ddd284ecd7138c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/242679
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 years agocmd/compile: port last ARM rules to typed
Alberto Donizetti [Sat, 24 Oct 2020 17:07:14 +0000 (19:07 +0200)]
cmd/compile: port last ARM rules to typed

Passes

  GOARCH=arm gotip build -toolexec 'toolstash -cmp' -a std

Change-Id: I4a1cace82c5d957774ea20572406af276f02bf97
Reviewed-on: https://go-review.googlesource.com/c/go/+/264680
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>