]> Cypherpunks repositories - gostls13.git/log
gostls13.git
4 years agocmd: update x/arch to pull in CL 315572
Bryan C. Mills [Sun, 2 May 2021 12:52:06 +0000 (08:52 -0400)]
cmd: update x/arch to pull in CL 315572

Because x/arch is now lazy, this removes the checksum for rsc.io/pdf
from the go.sum file: the requirements of rsc.io/pdf are known not to
be relevant to any package imported within the cmd packages.

For #36460
Updates #36905

Change-Id: I3abb6a8029cd0c9099b592ccb01ca5606c93edec
Reviewed-on: https://go-review.googlesource.com/c/go/+/316110
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years agoos/user: implement (*User).GroupIds on solaris
Tobias Klauser [Sat, 1 May 2021 15:41:34 +0000 (15:41 +0000)]
os/user: implement (*User).GroupIds on solaris

It seems like getgrouplist is supported since Solaris 11.3 (released in
2016):
https://docs.oracle.com/cd/E86824_01/html/E54766/getgrouplist-3c.html

Use it to implement (*User).GroupIds on solaris, like on other Unix
platforms.

Unfortunately it looks like getgrouplist was added to illumos only
fairly recently, see
https://github.com/illumos/illumos-gate/commit/f2c438c5058c64b7373448f239156bf60009abcb

Thus, don't use it on GOOS=illumos for now.

Updates #14709

Change-Id: Ibfcdbfca6b7d1af96630512d08921e5637ca76d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/315278
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 agoos, syscall: use wait6 to avoid wait/kill race on dragonfly
Tobias Klauser [Sat, 1 May 2021 17:43:55 +0000 (19:43 +0200)]
os, syscall: use wait6 to avoid wait/kill race on dragonfly

Follow CL 23967 and CL 24021 which did the same on linux and freebsd,
respectively.

Updates #13987
Updates #16028

Change-Id: Ia30ef8b5cffd8f9eb75c29ee5fe350dac2be6d44
Reviewed-on: https://go-review.googlesource.com/c/go/+/315279
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 agosyscall: add //go:build lines to files generated with with mksyscall_libc.pl
Tobias Klauser [Sat, 1 May 2021 13:37:44 +0000 (15:37 +0200)]
syscall: add //go:build lines to files generated with with mksyscall_libc.pl

Change-Id: I2e02d02d9208fc2dbf01c0cea4a67c288967cd07
Reviewed-on: https://go-review.googlesource.com/c/go/+/315276
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 agotime: make time.Time print a valid Go string with %#v
Kevin Burke [Thu, 25 Mar 2021 19:33:35 +0000 (12:33 -0700)]
time: make time.Time print a valid Go string with %#v

Previously calling fmt.Sprintf("%#v", t) on a time.Time value would
yield a result like:

    time.Time{wall:0x0, ext:63724924180, loc:(*time.Location)(nil)}

which does not compile when embedded in a Go program, and does not
tell you what value is represented at a glance.

This change adds a GoString method that returns much more legible
output:

    "time.Date(2009, time.February, 5, 5, 0, 57, 12345600, time.UTC)"

which gives you more information about the time.Time and also can be
usefully embedded in a Go program without additional work.

Update Quote() to hex escape non-ASCII characters (copying logic
from strconv), which makes it safer to embed them in the output of
GoString().

Fixes #39034.

Change-Id: Ic985bafe4e556f64e82223c643f65143c9a45c3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/267017
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agocmd/compile: implement unsafe.Add and unsafe.Slice
Matthew Dempsky [Wed, 21 Apr 2021 09:11:15 +0000 (02:11 -0700)]
cmd/compile: implement unsafe.Add and unsafe.Slice

Updates #19367.
Updates #40481.

Change-Id: Iabd2afdd0d520e5d68fd9e6dedd013335a4b3886
Reviewed-on: https://go-review.googlesource.com/c/go/+/312214
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoos: document that Windows Symlink to missing target creates file symlink
Ian Lance Taylor [Tue, 27 Apr 2021 23:55:04 +0000 (16:55 -0700)]
os: document that Windows Symlink to missing target creates file symlink

Fixes #39183

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

4 years agopath/filepath: fix documentation typo (was "each each")
Vitaly Zdanevich [Sat, 1 May 2021 21:13:38 +0000 (21:13 +0000)]
path/filepath: fix documentation typo (was "each each")

Change-Id: I8dcf6c4489e16e91b8685c31569297cfeb700f9d
GitHub-Last-Rev: f6b40e029874230789a7ae2b750a42a355ae42cf
GitHub-Pull-Request: golang/go#45905
Reviewed-on: https://go-review.googlesource.com/c/go/+/316009
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Kevin Burke <kev@inburke.com>
Trust: Kevin Burke <kev@inburke.com>

4 years agocmd/link: emit better error for duplicated definition
Cherry Zhang [Sat, 1 May 2021 00:53:14 +0000 (20:53 -0400)]
cmd/link: emit better error for duplicated definition

Print the packages where the duplicates come from.

Change-Id: Ib3dc9aa0a3f5ddd97b03744be6d01d4bfcb33996
Reviewed-on: https://go-review.googlesource.com/c/go/+/315949
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/link: mangle ABI name for shared linkage
Cherry Zhang [Fri, 30 Apr 2021 21:21:22 +0000 (17:21 -0400)]
cmd/link: mangle ABI name for shared linkage

Currently, when ABI wrappers are used, we don't use ABI aliases.
One exception is shared linkage. When loading a shared library, if
a symbol has only one ABI, and the name is not mangled, we don't
know what ABI it is, so we have to use ABI aliases.

This CL makes it always mangle ABIInternal function name in shared
linkage, so we know what ABI to choose when loading a shared
library. And we now can fully stop using ABI aliases when ABI
wrappers are used.

Change-Id: Id15d9cd72a59f391f54574710ebba7dc44cb6e23
Reviewed-on: https://go-review.googlesource.com/c/go/+/315869
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agogo/types: list errors by default in TestManual
Rob Findley [Fri, 30 Apr 2021 19:38:11 +0000 (15:38 -0400)]
go/types: list errors by default in TestManual

This is a port of CL 315729 to go/types, adjusted for the slightly
different test set-up in go/types.

Added a TODO to reconcile these differences.

Change-Id: I71cae712d8fc23b7311ce35e09168b258e07fa35
Reviewed-on: https://go-review.googlesource.com/c/go/+/315850
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agogo/types: simplify use of TestManual
Rob Findley [Fri, 30 Apr 2021 18:55:11 +0000 (14:55 -0400)]
go/types: simplify use of TestManual

This is a 1:1 port of CL 315689 to go/types.

Change-Id: If71186b3719be8433c9d21b22c51ffde2cadd55b
Reviewed-on: https://go-review.googlesource.com/c/go/+/315849
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agogo/types: slice-to-array-pointer conversion requires go1.17
Rob Findley [Fri, 30 Apr 2021 18:49:40 +0000 (14:49 -0400)]
go/types: slice-to-array-pointer conversion requires go1.17

This is a port of CL 315169 to go/types. It uses a slightly different
mechanism for evaluating the convertibility error message, to be
consistent with operand.assignableTo.

Change-Id: Iea2e2a9fbb4cf17d472b2b7392786118e079528a
Reviewed-on: https://go-review.googlesource.com/c/go/+/315809
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agoruntime,syscall: convert syscall on openbsd/386 to libc
Joel Sing [Thu, 28 Jan 2021 12:50:30 +0000 (23:50 +1100)]
runtime,syscall: convert syscall on openbsd/386 to libc

Convert the syscall package on openbsd/386 to use libc rather than performing
direct system calls.

Updates #36435

Change-Id: Ifcfbca0e6b933762596a564243caa850dac01442
Reviewed-on: https://go-review.googlesource.com/c/go/+/287654
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: switch runtime to libc for openbsd/386
Joel Sing [Thu, 28 Jan 2021 12:43:33 +0000 (23:43 +1100)]
runtime: switch runtime to libc for openbsd/386

Use libc rather than performing direct system calls for the runtime on
openbsd/386.

Updates #36435

Change-Id: I0cd65368bc824c81f5f98ea24e4f82db5468b170
Reviewed-on: https://go-review.googlesource.com/c/go/+/287653
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: break up large calls to memclrNoHeapPointers to allow preemption
David Chase [Wed, 18 Nov 2020 00:54:31 +0000 (19:54 -0500)]
runtime: break up large calls to memclrNoHeapPointers to allow preemption

If something "huge" is allocated, and the zeroing is trivial (no pointers
involved) then zero it by chunks in a loop so that preemption can occur,
not all in a single non-preemptible call.

Benchmarking suggests that 256K is the best chunk size.

Updates #42642.

Change-Id: I94015e467eaa098c59870e479d6d83bc88efbfb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/270943
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agocmd/compile: fix abbrev selection for output params
Than McIntosh [Fri, 30 Apr 2021 15:15:44 +0000 (11:15 -0400)]
cmd/compile: fix abbrev selection for output params

In Cl 302071 we changed the compiler to use a different recipe for
selecting the DWARF frame offset for output parameters, to reflect the
fact that registerized output params don't have a stack memory
location on entry to the function. In the process, however, we
switched from using an abbrev pf DW_ABRV_PARAM to an abbrev of
DW_ABRV_AUTO, which means that Delve can't recognize them correctly.
To fix the problem, switch back to picking the correct abbrev entry,
while leaving the new offset recipe intact.

Updates #40724.
Updates #45720.

Change-Id: If721c9255bcd030177806576cde3450563f7a235
Reviewed-on: https://go-review.googlesource.com/c/go/+/315610
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/compile: handle field padding for register-passed structs
Than McIntosh [Thu, 29 Apr 2021 15:47:18 +0000 (11:47 -0400)]
cmd/compile: handle field padding for register-passed structs

When constructing multi-piece DWARF location expressions for
struct-typed parameters using the register ABI, make sure that the
location expressions generated properly reflect padding between
elements (this is required by debuggers). Example:

   type small struct { x uint16 ; y uint8 ; z int32 }
   func ABC(p1 int, p2 small, f1 float32) {
     ...

In the DWARF location expression for "p2" on entry to the routine, we
need pieces for each field, but for debuggers (such as GDB) to work
properly, we also need to describe the padding between elements. Thus
instead of

  <rbx> DW_OP_piece 2 <rcx> DW_OP_piece 1 <rdi> DW_OP_piece 4

we need to emit

  <rbx> DW_OP_piece 2 <rcx> DW_OP_piece 1 DW_OP_piece 1 <rdi> DW_OP_piece 4

This patch adds a new helper routine in abiutils to compute the
correct padding amounts for a struct type, a unit test for the helper,
and updates the debug generation code to call the helper and insert
apadding "piece" ops in the right spots.

Updates #40724.
Updates #45720.

Change-Id: Ie208bee25776b9eb70642041869e65e4fa65a005
Reviewed-on: https://go-review.googlesource.com/c/go/+/315071
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agocmd/compile: regabi support for DWARF location expressions
Than McIntosh [Tue, 27 Apr 2021 16:40:43 +0000 (12:40 -0400)]
cmd/compile: regabi support for DWARF location expressions

Revise the code that generates DWARF location expressions for input
parameters to get it to work properly with the new register ABI when
optimization is turned off.

The previously implementation assumed stack locations for all
input+output parameters when -N (disable optimization) was in effect.
In the new implementation, a register-resident input parameter is
given a 2-element location list, the first list element pointing to
the ABI register(s) containing the param, and the second element
pointing to the stack home once it has been spilled.

NB, this change fixes a bunch of the Delve pkg/proc unit tests (maybe
about half of the outstanding failures). Still a good number that need
to be investigated, however.

Updates #40724.
Updates #45720.

Change-Id: I743bbb9af187bcdebeb8e690fdd6db58094ca415
Reviewed-on: https://go-review.googlesource.com/c/go/+/314431
Trust: Than McIntosh <thanm@google.com>
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
4 years agobufio: mention ErrFinalToken in SplitFunc documentation
Matt Harden [Fri, 30 Apr 2021 01:34:44 +0000 (01:34 +0000)]
bufio: mention ErrFinalToken in SplitFunc documentation

It is documented elsewhere in the package documentation but this additional
mention of it will hopefully reduce confusion.

Fixes #44261

Change-Id: I4e9d8f4564ebb7fbe047c92ee2cdffedb39f2a31
GitHub-Last-Rev: 64b6421503dfb9396e46f94f9805ff7f8bf2b31b
GitHub-Pull-Request: golang/go#45839
Reviewed-on: https://go-review.googlesource.com/c/go/+/314969
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agoruntime: work around vet asmdecl checks for openbsd/386 mstart_stub
Joel Sing [Fri, 30 Apr 2021 18:47:00 +0000 (04:47 +1000)]
runtime: work around vet asmdecl checks for openbsd/386 mstart_stub

Include a NOP with the SP in order to disable/bypass vet asmdecl checks
for runtime.mstart_stub on openbsd/386. Without this we get:

runtime/sys_openbsd_386.s:33:1: [386] mstart_stub: use of 32(SP) points beyond argument frame

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

4 years agocmd/compile: revise block/func end sentinels in debug analysis
Than McIntosh [Wed, 28 Apr 2021 22:26:54 +0000 (18:26 -0400)]
cmd/compile: revise block/func end sentinels in debug analysis

The SSA code for debug variable location analysis (for DWARF) has two
special 'sentinel' values that it uses to handshake with the
debugInfo.GetPC callback when capturing the PC values of debug
variable ranges after prog generatoin: "BlockStart" and "BlockEnd".

"BlockStart" has the expected semantics: it means "the PC value of the
first instruction of block B", but "BlockEnd" does not mean "PC value
of the last instruction of block B", but rather it is implemented as
"the PC value of the last instruction of the function". This causes
confusion when reading the code, and seems to to result in implementation
flaws in the past, leading to incorrect ranges in some cases.

To help with this, add a new sentinel "FuncEnd" (which has the "last
inst in the function" semantics) and change the implementation of
"BlockEnd" to actually mean what its name implies (last inst in
block).

Updates #45720.

Change-Id: Ic3497fb60413e898d2bfe27805c3db56483d12a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/314930
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>
Reviewed-by: David Chase <drchase@google.com>
4 years agocmd/internal/archive: make error message contain printable characters only
Cherry Zhang [Fri, 30 Apr 2021 17:57:12 +0000 (13:57 -0400)]
cmd/internal/archive: make error message contain printable characters only

Use %q instead of %s to print unchecked bytes. Also strip the
"\x00" byte, as "go116ld" reads better than "\x00go116ld".

Change-Id: Id3d1f426ea91d53a55b928dac4a68e1333b80158
Reviewed-on: https://go-review.googlesource.com/c/go/+/315750
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime: switch openbsd/386 locking to libc
Joel Sing [Thu, 28 Jan 2021 12:06:56 +0000 (23:06 +1100)]
runtime: switch openbsd/386 locking to libc

Switch openbsd/386 to locking via libc, rather than performing direct
system calls.

Update #36435

Change-Id: I8198171e21f9acf28846ad723ea9ff48f7c8a69d
Reviewed-on: https://go-review.googlesource.com/c/go/+/287652
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: switch openbsd/386 to pthreads
Joel Sing [Tue, 25 Aug 2020 17:23:42 +0000 (03:23 +1000)]
runtime: switch openbsd/386 to pthreads

This switches openbsd/386 to thread creation via pthreads, rather than doing
direct system calls.

Update #36435

Change-Id: I000a815fc0edd0272c3285954f3f007229bc60a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/250577
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/go: remove the special case for "unsafe" in importFromModules
Bryan C. Mills [Fri, 30 Apr 2021 05:51:16 +0000 (01:51 -0400)]
cmd/go: remove the special case for "unsafe" in importFromModules

The comment for this special case claims:
> There's no directory for import "C" or import "unsafe".

However, there clearly is a directory for "unsafe" in
GOROOT/src/unsafe, and all of our integration tests seem to pass
without this special case. As far as I can tell, it's just confusing.

Also note that the internal/goroot package explicitly considers
package "unsafe" to be in the standard library; see CL 137435.

For #36460

Change-Id: Ib857d18f731a7f3c911c1bd116a34e3a9b3d74a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/315412
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>
4 years agocmd/go: add GODEBUG tokens for debugging lazy module loading
Bryan C. Mills [Fri, 30 Apr 2021 05:29:57 +0000 (01:29 -0400)]
cmd/go: add GODEBUG tokens for debugging lazy module loading

GODEBUG=lazymod=log causes the go command to log a stack dump whenever
the full module graph is loaded in a lazy module.

GODEBUG=lazymod=strict does the same, but also terminates the command
with a nonzero exit code.

For #36460

Change-Id: Ia5a4c46069044bcc157b285f64c2392990d70bd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/315411
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>
4 years agocmd/go: prune go.mod and go.sum files from vendored dependencies
Bryan C. Mills [Fri, 30 Apr 2021 04:34:54 +0000 (00:34 -0400)]
cmd/go: prune go.mod and go.sum files from vendored dependencies

Fixes #42970

Change-Id: I79246ef7fc16ae05c8e7b40ffb239a61f6415447
Reviewed-on: https://go-review.googlesource.com/c/go/+/315410
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>
4 years agocmd/go: annotate versions in vendor/modules.txt
Bryan C. Mills [Fri, 30 Apr 2021 04:04:19 +0000 (00:04 -0400)]
cmd/go: annotate versions in vendor/modules.txt

In order to prevent edit wars with previous cmd/go releases,
the new version annotations are only included if the main module
specifies 'go 1.17' or higher.

Fixes #36876

Change-Id: Iba15e47dd1ac2c16d754679a9b501db4069fa250
Reviewed-on: https://go-review.googlesource.com/c/go/+/315409
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>
4 years agocmd/go: smooth out upgrade paths for lazy loading
Bryan C. Mills [Thu, 29 Apr 2021 13:27:40 +0000 (09:27 -0400)]
cmd/go: smooth out upgrade paths for lazy loading

This change adds two possible upgrade paths for lazy loading:

1. Run 'go mod tidy -go=1.17'.

2. Starting in a module with no existing 'go' directive,
   run any 'go' command that updates the go.mod file.

In the latter case, commands other than 'go mod tidy'
may leave the go.mod file *very* untidy if it had non-trivial
dependencies. (The 'go' invocation will promote all
implicit eager dependencies to explicit lazy ones,
which preserves the original module graph — most of which is
not actually relevant.)

'go mod tidy -go=1.17' can be used to enable lazy loading without
accidentally downgrading existing transitive dependencies.

'go mod tidy -go=1.16' can be used to disable lazy loading and clear
away redundant roots in a single step (if reducing the go version), or
to prune away dependencies of tests-of-external-tests (if increasing
the go version).

'go mod tidy -go=1.15' can be used to add dependencies of
tests-of-external-tests, although there isn't much point to that.

DO NOT MERGE

This change still needs an explicit test and a release note.

Fixes #45094
For #36460

Change-Id: I68f057e39489dfd6a667cd11dc1e320c1ee1aec1
Reviewed-on: https://go-review.googlesource.com/c/go/+/315210
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>
4 years agocmd/go/internal/modload: avoid loading the full module graph when listing specific...
Bryan C. Mills [Sat, 10 Apr 2021 03:40:22 +0000 (23:40 -0400)]
cmd/go/internal/modload: avoid loading the full module graph when listing specific modules

For #36460
For #41297
Updates #29666

Change-Id: I5f324c0ef9a164f8043d2188101d141bb5fa7454
Reviewed-on: https://go-review.googlesource.com/c/go/+/309191
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 agocmd/go/internal/modload: avoid loading the module graph to list only the name of...
Bryan C. Mills [Sat, 10 Apr 2021 02:51:07 +0000 (22:51 -0400)]
cmd/go/internal/modload: avoid loading the module graph to list only the name of the main module

For #36460
For #29666

Change-Id: I9e46f7054d52c053be80c483757cdd34b22822d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/309190
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 agocmd/go/internal/modload: avoid loading the full module graph to determine which check...
Bryan C. Mills [Sat, 10 Apr 2021 02:00:14 +0000 (22:00 -0400)]
cmd/go/internal/modload: avoid loading the full module graph to determine which checksums to add to go.sum

For #36460

Change-Id: I606314054bd9064f7c4053f56049fabbaec54143
Reviewed-on: https://go-review.googlesource.com/c/go/+/309189
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 agocmd/go/internal/modload: avoid loading the full module graph for imports satisfied...
Bryan C. Mills [Wed, 28 Apr 2021 16:57:55 +0000 (12:57 -0400)]
cmd/go/internal/modload: avoid loading the full module graph for imports satisfied by lazy roots

For #36460

Change-Id: Ibdbaa893ded772617e22f12db7a0463604db5195
Reviewed-on: https://go-review.googlesource.com/c/go/+/308516
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>
4 years agocmd/go: verify lazy-loading invariants when loading the vendor list for a lazy module
Bryan C. Mills [Thu, 29 Apr 2021 14:27:43 +0000 (10:27 -0400)]
cmd/go: verify lazy-loading invariants when loading the vendor list for a lazy module

For #36460

Change-Id: Ib4b1baea35826c3e359456f8dba09a49283e7fee
Reviewed-on: https://go-review.googlesource.com/c/go/+/315069
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>
4 years agocmd/go: enable lazy loading
Bryan C. Mills [Wed, 28 Apr 2021 16:57:38 +0000 (12:57 -0400)]
cmd/go: enable lazy loading

This change activates the dormant “lazy loading” codepaths added in CL
265777 and its predecessors. Dependencies of modules that declare 'go
1.17' or higher are loaded lazily, and the dependencies in the go.mod
file maintain additional invariants to support more efficient lazy
loading for downstream dependent modules.

See https://golang.org/design/36460-lazy-module-loading for the
detailed design.

For #36460

Change-Id: Ic12ee7842aef9580357fcf8909d87654fcb2ad12
Reviewed-on: https://go-review.googlesource.com/c/go/+/314634
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>
4 years agocmd/go/internal/modload: implement lazy loading
Bryan C. Mills [Wed, 28 Apr 2021 15:30:48 +0000 (11:30 -0400)]
cmd/go/internal/modload: implement lazy loading

For #36460
Updates #41297

Change-Id: I1b82176a45df499e52f1a3a0ffe23eab2a1ca86e
Reviewed-on: https://go-review.googlesource.com/c/go/+/265777
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>
4 years agointernal/buildcfg: enable regabi for Android
Ian Lance Taylor [Fri, 30 Apr 2021 04:10:05 +0000 (21:10 -0700)]
internal/buildcfg: enable regabi for Android

This will permit us to write ABIInternal assembler code for linux-amd64.

For #40724

Change-Id: I681866651554eda4229d6faa7f0c1ba42d07e57d
Reviewed-on: https://go-review.googlesource.com/c/go/+/315390
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile/internal/types2: list errors by default in TestManual
Robert Griesemer [Fri, 30 Apr 2021 17:20:38 +0000 (10:20 -0700)]
cmd/compile/internal/types2: list errors by default in TestManual

TestManual is used for debugging; in this case we usually want to
see error messages reported rather than checked against ERROR comments
in the provided files. Make this the default. Use the new -verify
flag to verify reported errors against ERROR comments.

With this change we cannot get an error list for the non-manual
tests, but that is usually not useful anyway because there are
usually many errors in those test files. Run those tests manually
instead.

Also, corrected -lang flag synopsys: it applies to all tests, not
just TestManual.

Change-Id: I56e0ea0583840fc3ea150d9ccfc330370b66191c
Reviewed-on: https://go-review.googlesource.com/c/go/+/315729
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile/internal/types2: simplify use of TestManual
Robert Griesemer [Fri, 30 Apr 2021 16:43:39 +0000 (09:43 -0700)]
cmd/compile/internal/types2: simplify use of TestManual

Running the TestManual test (for manual debugging) requires
user-provided files as input. Rather than using another flag
(-files) to provide these files, just use the (remaining)
command line arguments.

Change-Id: I9b20d9f1a6a7ce839bbd690c311ce3f0d0a10496
Reviewed-on: https://go-review.googlesource.com/c/go/+/315689
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/internal/objfile: emit better error for Go object of a different version
Cherry Zhang [Fri, 30 Apr 2021 01:49:15 +0000 (21:49 -0400)]
cmd/internal/objfile: emit better error for Go object of a different version

The Go object file format can change from version to version.
Tools like cmd/objdump and cmd/nm only onderstand the current
version of the object file. Currently, when it encounters an
object built with a different version of the toolchain, it emits
a generic error "unrecognized object file", which is not very
helpful for users. This CL makes it emit a clearer error. Now it
emits

objdump: open go116.o: go object of a different version: go116ld

Change-Id: I063c6078ed1da78f97cea65796779ae093a1a8cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/315609
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agonet/url: add Values.Has
Ian Mckay [Thu, 29 Apr 2021 06:30:44 +0000 (06:30 +0000)]
net/url: add Values.Has

Adds a method within Values for detecting whether a query parameter is set.

Fixes #45100

Change-Id: I6bb49417e8547e11cc7e8d55c5211d24ee436ec1
GitHub-Last-Rev: 0b27cdab9024b93bad1eab9941aff8928a29fa76
GitHub-Pull-Request: golang/go#45835
Reviewed-on: https://go-review.googlesource.com/c/go/+/314850
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Zhang <cherryyz@google.com>

4 years agoA+C: add Weixie Cui (individual CLA)
cuiweixie [Thu, 29 Apr 2021 15:04:15 +0000 (15:04 +0000)]
A+C: add Weixie Cui (individual CLA)

Change-Id: I897864984bd4b79f2e224ea1a7f323e0bd5e2ef0
GitHub-Last-Rev: b85415541d12128c7515af91b02c098617478a50
GitHub-Pull-Request: golang/go#45849
Reviewed-on: https://go-review.googlesource.com/c/go/+/314991
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ben Shi <powerman1st@163.com>
Trust: Matthew Dempsky <mdempsky@google.com>

4 years agocmd/gofmt: always format non-directory arguments again
Daniel Martí [Thu, 29 Apr 2021 21:54:26 +0000 (22:54 +0100)]
cmd/gofmt: always format non-directory arguments again

golang.org/cl/284138 introduced a regression: running "gofmt foo" would
silently ignore the file due to its lack of a ".go" extension, whereas
the tool is documented otherwise:

Given a file, it operates on that file; given a directory, it
operates on all .go files in that directory, recursively.

This wasn't caught as there were no tests for these edge cases. gofmt's
own tests are regular Go tests, so it's hard to test it properly without
adding an abstraction layer on top of func main.

Luckily, this kind of test is a great fit for cmd/go's own script tests,
and it just takes a few straightforward lines.

Finally, add the relevant logic back, with documentation to clarify its
intentional purpose.

Fixes #45859.

Change-Id: Ic5bf5937b8f95fcdad2b6933227c8b504ef38a82
Reviewed-on: https://go-review.googlesource.com/c/go/+/315270
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Robert Griesemer <gri@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agogo/ast: print CommentMap contents in source order
Robert Griesemer [Fri, 30 Apr 2021 04:38:43 +0000 (21:38 -0700)]
go/ast: print CommentMap contents in source order

Sort the comment map entries before printing.
Makes it easier to use the output for debugging.

For #39753.

Change-Id: Ic8e7d27dd2df59173e2c3a04a6b71ae966703885
Reviewed-on: https://go-review.googlesource.com/c/go/+/315370
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/internal/obj/ppc64: simplify got/toc address classification
Paul E. Murphy [Tue, 9 Mar 2021 22:55:15 +0000 (16:55 -0600)]
cmd/internal/obj/ppc64: simplify got/toc address classification

These generate similar machine code sequences to
other symbol accesses, therefore we should merge them.

Change-Id: Id8ead284d430fadd2e58bad255deb465498dfade
Reviewed-on: https://go-review.googlesource.com/c/go/+/314109
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agocmd/internal/obj/arm64: fix the size of STP series instructions in optab
eric fang [Thu, 29 Apr 2021 06:33:21 +0000 (06:33 +0000)]
cmd/internal/obj/arm64: fix the size of STP series instructions in optab

When the class of p.To is C_NAUTO4K, STP series instructions will be translated
into add/sub + stp instructions, the total size is 8. Currently this size
value in optab is 12, this CL fixes it.

Change-Id: Ife1b9e9f8a28edca9b59f62b45a80d83f38993b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/314210
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: eric fang <eric.fang@arm.com>
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoapi: update next.txt
Dmitri Shuralyov [Thu, 29 Apr 2021 16:32:44 +0000 (12:32 -0400)]
api: update next.txt

There's no reason not to, and it'll help me test an upcoming fix
for #43956. The API additions look reasonable to me, and they'll
go through a more comprehensive API audit during the freeze.

Change-Id: I0daa6e978b199d69568f5100fdfc1b4bcfaeaef2
Reviewed-on: https://go-review.googlesource.com/c/go/+/315349
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agomath: increase precision of math.SmallestNonzeroFloat64
Robert Griesemer [Thu, 29 Apr 2021 22:01:29 +0000 (15:01 -0700)]
math: increase precision of math.SmallestNonzeroFloat64

The original value was rounded too early, which lead to the
surprising behavior that float64(math.SmallestNonzeroFloat64 / 2)
wasn't 0. That is, the exact compile-time computation of
math.SmallestNonzeroFloat64 / 2 resulted in a value that was
rounded up when converting to float64. To address this, added 3
more digits to the mantissa, ending in a 0.

While at it, also slightly increased the precision of MaxFloat64
to end in a 0.

Computed exact values via https://play.golang.org/p/yt4KTpIx_wP.

Added a test to verify expected behavior.

In contrast to the other (irrational) constants, expanding these
extreme values to more digits is unlikely to be important as they
are not going to appear in numeric computations except for tests
verifying their correctness (as is the case here).

Re-enabled a disabled test in go/types and types2.

Updates #44057.
Fixes #44058.

Change-Id: I8f363155e02331354e929beabe993c8d8de75646
Reviewed-on: https://go-review.googlesource.com/c/go/+/315170
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile, runtime: emit only GC data for stack objects
Cherry Zhang [Sat, 24 Apr 2021 16:41:17 +0000 (12:41 -0400)]
cmd/compile, runtime: emit only GC data for stack objects

Currently, for stack objects, the compiler emits metadata that
includes the offset and type descriptor for each object. The type
descriptor symbol has many fields, and it references many other
symbols, e.g. field/element types, equality functions, names.

Observe that what we actually need at runtime is only the GC
metadata that are needed to scan the object, and the GC metadata
are "leaf" symbols (which doesn't reference other symbols). Emit
only the GC data instead. This avoids bringing live the type
descriptor as well as things referenced by it (if it is not
otherwise live).

This reduces binary sizes:

                     old          new
hello (println)    1187776      1133856 (-4.5%)
hello (fmt)        1902448      1844416 (-3.1%)
cmd/compile       22670432     22438576 (-1.0%)
cmd/link           6346272      6225408 (-1.9%)

No significant change in compiler speed.

name        old time/op       new time/op       delta
Template          184ms ± 2%        186ms ± 5%    ~     (p=0.905 n=9+10)
Unicode          78.4ms ± 5%       76.3ms ± 3%  -2.60%  (p=0.009 n=10+10)
GoTypes           1.09s ± 1%        1.08s ± 1%  -0.73%  (p=0.027 n=10+8)
Compiler         85.6ms ± 3%       84.6ms ± 4%    ~     (p=0.143 n=10+10)
SSA               7.23s ± 1%        7.25s ± 1%    ~     (p=0.780 n=10+9)
Flate             116ms ± 5%        115ms ± 6%    ~     (p=0.912 n=10+10)
GoParser          201ms ± 4%        195ms ± 1%    ~     (p=0.089 n=10+10)
Reflect           455ms ± 1%        458ms ± 2%    ~     (p=0.050 n=9+9)
Tar               155ms ± 2%        155ms ± 3%    ~     (p=0.436 n=10+10)
XML               202ms ± 2%        200ms ± 2%    ~     (p=0.053 n=10+9)

Change-Id: I33a7f383d79afba1a482cac6da0cf5b7de9c0ec4
Reviewed-on: https://go-review.googlesource.com/c/go/+/313514
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile/internal/types2: slice-to-array-pointer conversion requires go1.17
Robert Griesemer [Thu, 29 Apr 2021 17:02:01 +0000 (10:02 -0700)]
cmd/compile/internal/types2: slice-to-array-pointer conversion requires go1.17

Add missing version check. Even though this is a new types2 error
we separate between the compiler and the types2 error message: we
have the compiler error message to match the compiler style, and
we have a types2-specific error message to match the types2 style
for these kinds of errors (for now).

Eventually we need to decide which style we like better and clean
this up.

Follow-up on https://golang.org/cl/301650.

Updates #395.

Change-Id: I5b779f345994c66b1f4a4db466466f98b7d3c491
Reviewed-on: https://go-review.googlesource.com/c/go/+/315169
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile: make GC prog symbol content-addressable
Cherry Zhang [Sat, 24 Apr 2021 05:05:19 +0000 (01:05 -0400)]
cmd/compile: make GC prog symbol content-addressable

Change-Id: I759ac021ae5882429f26455fd849613a33e41783
Reviewed-on: https://go-review.googlesource.com/c/go/+/313513
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile: skip types.Sym for GC mask symbols
Cherry Zhang [Sat, 24 Apr 2021 02:30:38 +0000 (22:30 -0400)]
cmd/compile: skip types.Sym for GC mask symbols

For GC mask symbols, we don't need to create types.Sym, just the
LSym.

Change-Id: I285b518cfd60bfaa3202a02b3005a7122daeb338
Reviewed-on: https://go-review.googlesource.com/c/go/+/313512
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoruntime/metrics: add additional allocation metrics
Michael Anthony Knyszek [Tue, 20 Apr 2021 19:30:21 +0000 (19:30 +0000)]
runtime/metrics: add additional allocation metrics

This change adds four additional metrics to the runtime/metrics package
to fill in a few gaps with runtime.MemStats that were overlooked. The
biggest one is TotalAlloc, which is impossible to find with the
runtime/metrics package, but also add a few others for convenience and
clarity. For instance, the total number of objects allocated and freed
are technically available via allocs-by-size and frees-by-size, but it's
onerous to get them (one needs to sum the sample counts in the
histograms).

The four additional metrics are:
- /gc/heap/allocs:bytes   -- total bytes allocated (TotalAlloc)
- /gc/heap/allocs:objects -- total objects allocated (Mallocs - [tiny])
- /gc/heap/frees:bytes    -- total bytes frees (TotalAlloc-HeapAlloc)
- /gc/heap/frees:objects  -- total objects freed (Frees - [tiny])

This change also updates the descriptions of allocs-by-size and
frees-by-size to be more precise.

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

4 years agocmd/compile: minor doc enhancements
Than McIntosh [Thu, 29 Apr 2021 18:52:24 +0000 (14:52 -0400)]
cmd/compile: minor doc enhancements

Add a little more detail to the ssa README relating to GOSSAFUNC.

Update the -d=ssa help section to give a little more detail on what
to expect with applying the /debug=X qualifier to a phase.

Change-Id: I7027735f1f2955dbb5b9be36d9a648e8dc655048
Reviewed-on: https://go-review.googlesource.com/c/go/+/315229
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agocrypto/elliptic: store P-256 precomputed basepoint table in source
Roland Shoemaker [Thu, 29 Apr 2021 17:11:56 +0000 (10:11 -0700)]
crypto/elliptic: store P-256 precomputed basepoint table in source

Store the precomputed P-256 basepoint table in source rather than
computing it at runtime, saving ~88kB from the heap. The flip side
is that this increases binary sizes by ~77kB.

Fixes #44992

Change-Id: Ia5421eae87b41522b0d8cecba051cba1d2ed73db
Reviewed-on: https://go-review.googlesource.com/c/go/+/315189
Run-TryBot: Roland Shoemaker <roland@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
4 years agoarchive/zip: only return directory once via io/fs.FS
Ian Lance Taylor [Mon, 19 Apr 2021 20:51:53 +0000 (13:51 -0700)]
archive/zip: only return directory once via io/fs.FS

While we're here fix the ModTime value for directories.

Fixes #43872
Fixes #45345

Change-Id: I155e6517713ef6a9482b9431f1167a44337c6ad2
Reviewed-on: https://go-review.googlesource.com/c/go/+/311530
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years agoencoding/csv: add FieldPos method
Roger Peppe [Thu, 11 Feb 2021 13:54:45 +0000 (13:54 +0000)]
encoding/csv: add FieldPos method

This enables a consumer of a CSV to find out the position
of a CSV field without implementing an intermediate buffer.
This is useful to produce good higher level error messages when
the CSV syntax is OK but the field values don't match expectations.

This also changes the existing semantics of the `ParseError.Column`
field to bring it in line with precedent elsewhere in the Go
standard library (notably go/token.Position) - the column is
now 1-based and indicates a byte count rather than a rune count,
and the error position reporting at the end of a last line without
a newline is now fixed.

This change has some impact on performance:

```
name                                     old time/op    new time/op    delta
Read-8                                     2.14µs ± 0%    2.15µs ± 0%    ~     (p=0.056 n=5+5)
ReadWithFieldsPerRecord-8                  2.15µs ± 2%    2.15µs ± 1%    ~     (p=0.151 n=5+5)
ReadWithoutFieldsPerRecord-8               2.15µs ± 0%    2.15µs ± 0%  +0.37%  (p=0.024 n=5+5)
ReadLargeFields-8                          3.55µs ± 2%    3.59µs ± 0%    ~     (p=0.206 n=5+5)
ReadReuseRecord-8                          1.18µs ± 1%    1.22µs ± 1%  +2.93%  (p=0.008 n=5+5)
ReadReuseRecordWithFieldsPerRecord-8       1.18µs ± 0%    1.21µs ± 0%  +2.54%  (p=0.008 n=5+5)
ReadReuseRecordWithoutFieldsPerRecord-8    1.18µs ± 0%    1.22µs ± 1%  +3.66%  (p=0.008 n=5+5)
ReadReuseRecordLargeFields-8               2.53µs ± 1%    2.57µs ± 1%  +1.70%  (p=0.008 n=5+5)
Write-8                                    1.02µs ± 1%    1.01µs ± 0%  -1.18%  (p=0.016 n=5+4)
```

Fixes #44221.

Change-Id: Id37c50fc396024eef406c5bad45380ecd414f5ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/291290
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Paul Jolly <paul@myitcv.org.uk>

4 years agoruntime: top align tinyallocs in race mode
Keith Randall [Thu, 29 Apr 2021 06:07:38 +0000 (23:07 -0700)]
runtime: top align tinyallocs in race mode

Top align allocations in tinyalloc buckets when in race mode.
This will make checkptr checks more reliable, because any code
that modifies a pointer past the end of the object will trigger
a checkptr error.

No test, because we need -race for this to actually kick in.  We could
add it to the race detector tests, but the race detector tests are all
geared towards race detector reports, not checkptr reports. Mucking
with parsing reports is more than a test is worth.

Fixes #38872

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

4 years agocmd/compile/internal/walk: merge operations when calling ir.NewSlic…
cuiweixie [Thu, 29 Apr 2021 14:28:43 +0000 (14:28 +0000)]
cmd/compile/internal/walk: merge operations when calling ir.NewSlic…

Change-Id: I55ef35a9d8157063c4a41b23cd1ac0002838d30a
GitHub-Last-Rev: e716c5200545a944313ae0d995fcb6eb17d2720e
GitHub-Pull-Request: golang/go#45814
Reviewed-on: https://go-review.googlesource.com/c/go/+/314569
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>
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime: use 4 MiB heap arenas on iOS
Michael Anthony Knyszek [Mon, 16 Nov 2020 22:03:17 +0000 (22:03 +0000)]
runtime: use 4 MiB heap arenas on iOS

iOS arm64 is a 64-bit platform but with a strictly 32-bit address space
(technically 33 bits, but the bottom half is unavailable to the
application). Since address space is limited, use 4 MiB arenas instead
of 64 MiB arenas. No changes are needed to the arena index because it's
still relatively small; this change just brings iOS more in line with
32-bit platforms.

Change-Id: I484e2d273d896fd0a57cd5c25012df0aef160290
Reviewed-on: https://go-review.googlesource.com/c/go/+/270538
Trust: Michael Knyszek <mknyszek@google.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agogo/types: add additional test data from types2
Rob Findley [Thu, 29 Apr 2021 15:42:35 +0000 (11:42 -0400)]
go/types: add additional test data from types2

Add some test data files that were not included in go/types.

- Issue 43125 only pertained to types2 because go/ast differentiates
  StarExpr, UnaryExpr, and BinaryExpr, so typexpr.go was already
  catching the invalid type expressions.
- Issues 42987 and 43190 are handled differently by go/parser.
- main.go2 was not added when ported to go/types, because this work
  happened on the dev.regabi branch, which didn't support generics.

Test files are modified to adjust errors messages and positions, and to
update the copyright year.

Change-Id: Ia737eaab9afb2b59600b661ccf3eec3cbbb2d66c
Reviewed-on: https://go-review.googlesource.com/c/go/+/315070
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/link: test trampolines with cgo
Cherry Zhang [Tue, 27 Apr 2021 18:57:11 +0000 (14:57 -0400)]
cmd/link: test trampolines with cgo

Updates #40492, #30949.

Change-Id: I6d7923ac83275c5ab08958f7a501f7975aea151a
Reviewed-on: https://go-review.googlesource.com/c/go/+/314456
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile/internal/types2: nest all test data under the testdata directory
Robert Griesemer [Wed, 28 Apr 2021 22:08:47 +0000 (15:08 -0700)]
cmd/compile/internal/types2: nest all test data under the testdata directory

This matches https://golang.org/cl/314829 for go/types.

Change-Id: If3d127af0557bb13d504581920ea03e39db0eb07
Reviewed-on: https://go-review.googlesource.com/c/go/+/314772
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/link: support trampoline insertion for PLT calls on ARM
Cherry Zhang [Tue, 27 Apr 2021 21:11:03 +0000 (17:11 -0400)]
cmd/link: support trampoline insertion for PLT calls on ARM

This is CL 314452, for ARM.

Fixes #30949.

Change-Id: Ib4e46a5bd11c698c4f8ea3bc4e7a605d7a538efc
Reviewed-on: https://go-review.googlesource.com/c/go/+/314455
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/link: support trampoline insertion for PLT calls on ARM64
Cherry Zhang [Tue, 27 Apr 2021 14:57:09 +0000 (10:57 -0400)]
cmd/link: support trampoline insertion for PLT calls on ARM64

When internal linking with C objects, some C object relocations
may be turned into a CALL via PLT. For very large programs, the
PLT stub may be laid too far.

PLT stubs are generated late in the linker, and laid out after
the end of the text section. So if the text section is big, the
PLT stubs are likely too far.

To avoid this situation, add trampolines for PLT calls in the
trampoline pass. Only do this when the program is known too large
(i.e. the second pass of the two-pass algorithm).

Updates #40492.

Change-Id: I21f65d6cbc6bde84e3cf9c2ae05f5233df6cfa72
Reviewed-on: https://go-review.googlesource.com/c/go/+/314452
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/link: support trampoline insertion on ARM64
Cherry Zhang [Tue, 27 Apr 2021 02:25:20 +0000 (22:25 -0400)]
cmd/link: support trampoline insertion on ARM64

Compared to ARM32 or PPC64, ARM64 has larger range for direct jumps.
But for very large programs it can still go over the limit. Add
trampoline insertion for ARM64.

Updates #40492.

Change-Id: Id97301dbc35fb577ba3f8d5f3316a8424d4f53c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/314451
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoruntime: remove linux-amd64 walltime function
Ian Lance Taylor [Wed, 28 Apr 2021 20:06:55 +0000 (13:06 -0700)]
runtime: remove linux-amd64 walltime function

It's never called.

Change-Id: I8956743b21301816b5f37a9b34e3f50ef7b2e70a
Reviewed-on: https://go-review.googlesource.com/c/go/+/314771
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agoruntime: rename walltime1 to walltime
Ian Lance Taylor [Wed, 28 Apr 2021 18:42:34 +0000 (11:42 -0700)]
runtime: rename walltime1 to walltime

Change-Id: Iec9de5ca56eb68d524bbaa0668515dbd09ad38a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/314770
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agocmd/compile/internal/ir: fix doc
kumakichi [Thu, 29 Apr 2021 05:45:35 +0000 (05:45 +0000)]
cmd/compile/internal/ir: fix doc

Change-Id: I8fc77e29cb44fef264a62ff00452b9fcf6e30be8
GitHub-Last-Rev: 414cda8ce6e64fb53d3d1ec01caa7e33c0219236
GitHub-Pull-Request: golang/go#45842
Reviewed-on: https://go-review.googlesource.com/c/go/+/314990
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>

4 years agocmd/link: use a two-pass approach for trampoline insertion
Cherry Zhang [Mon, 26 Apr 2021 23:26:34 +0000 (19:26 -0400)]
cmd/link: use a two-pass approach for trampoline insertion

Currently in the linker, for trampoline insertion it does a one-pass
approach, where it assigns addresses for each function and inserts
trampolines on the go. For this to work and not to emit too many
unnecessary trampolines, the functions need to be laid out in
dependency order, so a direct call's target is always as a known
address (or known to be not too far).

This mostly works, but there are a few exceptions:
- linkname can break dependency tree and cause cycles.
- in internal linking mode, on some platforms, some calls are turned
  into calls via PLT, but the PLT stubs are inserted rather late.

Also, this is expensive in that it has to investigate all CALL
relocations.

This CL changes it to use a two-pass approach. The first pass is
just to assign addresses without inserting any trampolines, assuming
the program is not too big. If this succeeds, no extra work needs to
be done. If this fails, start over and insert trampolines for too-
far targets as well as targets with unknown addresses. This should
make it faster for small programs (most cases) and generate fewer
conservative trampolines.

Change-Id: Ib13e01f38ec6dfbef1cd446b06da33ee17bded5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/314450
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/link: update comment for PLT/GOT helper functions
Cherry Zhang [Wed, 28 Apr 2021 23:36:54 +0000 (19:36 -0400)]
cmd/link: update comment for PLT/GOT helper functions

PLT and GOT are used more than on PE. Update the comment.

Change-Id: Iaddb326680a7709a1442675a38c021331be32472
Reviewed-on: https://go-review.googlesource.com/c/go/+/314929
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agogo/types: improve error messages for unexpected ListExprs
Rob Findley [Wed, 28 Apr 2021 20:32:38 +0000 (16:32 -0400)]
go/types: improve error messages for unexpected ListExprs

This CL is a mix of CL 312149 and CL 314409, adding the
Checker.singleIndex method to provide better error messages when an
unexpected ListExpr is encountered.

Change-Id: I45d6de9b4dfc299dc2d356ca14d05c9191de818d
Reviewed-on: https://go-review.googlesource.com/c/go/+/314869
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agogo/types: ensure that error code values do not change in 1.17
Rob Findley [Wed, 28 Apr 2021 19:49:17 +0000 (15:49 -0400)]
go/types: ensure that error code values do not change in 1.17

Over this cycle some error code values have changed due to codes being
added/removed. This is probably OK to do once more before we export
error codes in a later Go version, but for now let's keep them stable.

Move things around to correct the changes, and update comments in
errorcodes.go to make it clearer that new codes should be added at the
end.

Change-Id: Id32827ef1a72cfd876ccc039da11d0a1be7470e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/314830
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agogo/types: nest all test data under the testdata directory
Rob Findley [Wed, 28 Apr 2021 18:40:53 +0000 (14:40 -0400)]
go/types: nest all test data under the testdata directory

Having multiple subdirectories of go/types containing test data is
slightly problematic:
 - If ever we were to include a .go file in one of these directories,
   we'd inadvertently create a visible package.
 - It's difficult to add other content in testdata/, since TestTestdata
   scans the entire directory.

Move everything down a level, into testdata/{fixedbugs,examples,check},
and update tests accordingly.

Change-Id: Idd074c94b7b261d678934330539e41a48c2a9dc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/314829
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/compile/internal/walk: delete unused statement
cuiweixie [Wed, 28 Apr 2021 05:21:33 +0000 (05:21 +0000)]
cmd/compile/internal/walk: delete unused statement

Change-Id: I3f118c868b13ec51b2e501424b35564929eed56d
GitHub-Last-Rev: d15ae124c582417cd10bceaef0b5c0ebbf100f7e
GitHub-Pull-Request: golang/go#45816
Reviewed-on: https://go-review.googlesource.com/c/go/+/314570
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile/internal/types2: match compiler error for invalid type alias decl
Robert Griesemer [Thu, 29 Apr 2021 01:00:16 +0000 (18:00 -0700)]
cmd/compile/internal/types2: match compiler error for invalid type alias decl

Fixes #45594.

Change-Id: I2fcc784e6908403dd96b009546e1ac2f53b9f0e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/314776
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
4 years agoruntime: remove walltime function
Ian Lance Taylor [Wed, 28 Apr 2021 18:10:07 +0000 (11:10 -0700)]
runtime: remove walltime function

There was only one meaningful caller, which changes to call time_now.

This clearly separates systems that use walltime1 to be just those
that use the stub version of time_now. That is to say, those that do
not provide an assembler version of time_now.

Change-Id: I14c06cc402070bd705f953af6f9966785015e2a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/314769
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agoruntime: implement time.now in assembly for linux-amd64
Ian Lance Taylor [Tue, 27 Apr 2021 23:46:53 +0000 (16:46 -0700)]
runtime: implement time.now in assembly for linux-amd64

name                                                       old time/op      new time/op      delta
AfterFunc-12                                                   66.7µs ± 3%      66.8µs ± 4%     ~     (p=0.836 n=20+20)
After-12                                                       99.4µs ± 4%      98.1µs ± 3%   -1.31%  (p=0.013 n=20+20)
Stop-12                                                        66.1µs ±12%      65.4µs ±10%     ~     (p=0.602 n=20+20)
SimultaneousAfterFunc-12                                        110µs ± 1%       114µs ± 2%   +3.98%  (p=0.000 n=19+18)
StartStop-12                                                   32.1µs ±15%      32.2µs ±13%     ~     (p=0.620 n=20+20)
Reset-12                                                       3.66µs ± 2%      3.63µs ± 5%   -0.92%  (p=0.018 n=20+17)
Sleep-12                                                        134µs ± 1%       139µs ± 4%   +3.97%  (p=0.000 n=20+18)
Ticker-12                                                      32.8µs ± 1%      32.6µs ± 2%   -0.63%  (p=0.017 n=18+20)
TickerReset-12                                                 3.72µs ± 3%      3.71µs ± 3%     ~     (p=0.753 n=20+20)
TickerResetNaive-12                                            68.9µs ±11%      65.8µs ± 8%   -4.44%  (p=0.008 n=20+20)
Now-12                                                         33.3ns ± 1%      29.6ns ± 0%  -11.06%  (p=0.000 n=18+16)
NowUnixNano-12                                                 34.6ns ± 0%      31.2ns ± 0%   -9.94%  (p=0.000 n=20+17)
NowUnixMilli-12                                                35.0ns ± 1%      30.9ns ± 0%  -11.75%  (p=0.000 n=19+15)
NowUnixMicro-12                                                35.0ns ± 0%      30.9ns ± 0%  -11.85%  (p=0.000 n=20+19)
Format-12                                                       302ns ± 3%       306ns ± 3%   +1.22%  (p=0.009 n=20+20)
FormatNow-12                                                    184ns ± 5%       187ns ± 2%   +1.25%  (p=0.046 n=20+19)
MarshalJSON-12                                                  262ns ± 2%       270ns ± 3%   +2.99%  (p=0.000 n=20+20)
MarshalText-12                                                  262ns ± 3%       268ns ± 3%   +2.37%  (p=0.000 n=19+19)
Parse-12                                                        145ns ± 1%       148ns ± 0%   +2.27%  (p=0.000 n=18+19)
ParseDuration-12                                               82.3ns ± 1%      79.7ns ± 1%   -3.06%  (p=0.000 n=20+20)
Hour-12                                                        4.48ns ± 1%      4.42ns ± 1%   -1.32%  (p=0.000 n=19+19)
Second-12                                                      4.44ns ± 1%      4.42ns ± 1%   -0.39%  (p=0.000 n=20+18)
Year-12                                                        11.2ns ± 1%      11.1ns ± 1%     ~     (p=0.193 n=20+20)
Day-12                                                         14.8ns ± 0%      14.8ns ± 1%     ~     (p=0.873 n=19+20)
ISOWeek-12                                                     17.2ns ± 0%      17.2ns ± 0%     ~     (p=0.605 n=18+20)

name                                                       old avg-late-ns  new avg-late-ns  delta
ParallelTimerLatency-12                                          375k ± 3%        377k ± 3%     ~     (p=0.445 n=20+20)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=1-12         136k ± 2%        137k ± 2%     ~     (p=0.242 n=20+20)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=2-12        97.4k ±11%       96.4k ±10%     ~     (p=0.336 n=19+20)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=3-12        74.8k ± 3%       74.2k ± 3%     ~     (p=0.158 n=20+19)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=4-12        70.7k ± 7%       70.4k ± 6%     ~     (p=0.879 n=20+19)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=5-12        65.8k ± 9%       66.3k ±14%     ~     (p=0.594 n=17+19)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=6-12        55.5k ±29%       56.7k ±30%     ~     (p=0.758 n=20+20)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=7-12        45.3k ±29%       43.6k ±33%     ~     (p=0.212 n=19+19)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=8-12        64.7k ±46%       65.2k ±78%     ~     (p=0.480 n=18+19)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=9-12         147k ±88%        119k ±83%     ~     (p=0.092 n=19+18)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=10-12       2.63M ±29%       2.70M ±59%     ~     (p=0.989 n=19+20)
StaggeredTickerLatency/work-dur=2ms/tickers-per-P=1-12          81.4k ± 4%       80.2k ± 3%   -1.55%  (p=0.009 n=17+18)

name                                                       old max-late-ns  new max-late-ns  delta
ParallelTimerLatency-12                                        7.66M ±102%      6.98M ±131%     ~     (p=0.445 n=20+20)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=1-12         381k ±12%        382k ±17%     ~     (p=0.901 n=17+16)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=2-12         388k ±69%        356k ±10%     ~     (p=0.363 n=17+16)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=3-12         350k ±17%        347k ±25%     ~     (p=0.538 n=19+18)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=4-12         378k ±52%        341k ±30%     ~     (p=0.153 n=18+17)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=5-12         392k ±54%        410k ±78%     ~     (p=0.730 n=18+19)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=6-12         467k ±80%       527k ±129%     ~     (p=0.616 n=17+19)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=7-12        915k ±138%      1023k ±227%     ~     (p=0.696 n=20+18)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=8-12       1.84M ±155%      1.74M ±158%     ~     (p=0.893 n=18+19)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=9-12        6.95M ±92%       7.66M ±91%     ~     (p=0.687 n=19+20)
StaggeredTickerLatency/work-dur=300µs/tickers-per-P=10-12       18.6M ±22%       16.2M ±28%  -12.78%  (p=0.003 n=19+19)
StaggeredTickerLatency/work-dur=2ms/tickers-per-P=1-12          1.01M ± 8%       1.04M ±10%     ~     (p=0.111 n=19+18)

Change-Id: I96aa2e0206a6e9286bcbfc8be372e84608ed4e2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/314277
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agocmd/compile: remove an unused function
Than McIntosh [Wed, 28 Apr 2021 22:10:22 +0000 (18:10 -0400)]
cmd/compile: remove an unused function

Remove unused function AddrForParamSlot.

Change-Id: I8e3ed8cc6607d30ad6da7bc6ccbaa87b7e001e79
Reviewed-on: https://go-review.googlesource.com/c/go/+/314909
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 agogo/types: respect IgnoreFuncBodies for function literals
Rob Findley [Wed, 28 Apr 2021 15:13:35 +0000 (11:13 -0400)]
go/types: respect IgnoreFuncBodies for function literals

This is a 1:1 port of CL 313650 to go/types.

Change-Id: Iec01ac2831f21162d9977a139549e081ee769f90
Reviewed-on: https://go-review.googlesource.com/c/go/+/314631
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agogo/types: better errors for invalid short var decls
Rob Findley [Wed, 28 Apr 2021 14:35:53 +0000 (10:35 -0400)]
go/types: better errors for invalid short var decls

This is a port of CL 312170 to go/types, adjusted to use go/ast and to
add error codes. go/parser already emits errors for non-identifiers on
the LHS of a short var decl, so a TODO is added to reconsider this
redundancy.

A new error code is added for repeated identifiers in short var decls.
This is a bit specific, but I considered it to be a unique kind of
error.

The x/tools tests for this port turned up a bug: the new logic failed to
call recordDef for blank identifiers. Patchset #2 contains the fix for
this bug, both in go/types and cmd/compile/internal/types2.

Change-Id: Ibdc40b8b4ad0e0696111d431682e1f1056fd5eeb
Reviewed-on: https://go-review.googlesource.com/c/go/+/314629
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agogo/types: fix type inference
Rob Findley [Wed, 28 Apr 2021 14:07:18 +0000 (10:07 -0400)]
go/types: fix type inference

This is a 1:1 port of CL 311651 to go/types.

Change-Id: I9d91b45cc5fa7ce686d6a91d4dde274d9f80e0d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/314595
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agoruntime: use a single definition of time_now for faketime
Ian Lance Taylor [Tue, 27 Apr 2021 23:22:25 +0000 (16:22 -0700)]
runtime: use a single definition of time_now for faketime

Build other definitions with the !faketime build tag.

This makes it easy for us to add new assembly implementations of time.now.

Change-Id: I4e48e41a4a04ab001030e6d1cdd9cebfa0161b0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/314274
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agoruntime: move Windows time.now implementations into separate files
Ian Lance Taylor [Tue, 27 Apr 2021 23:04:56 +0000 (16:04 -0700)]
runtime: move Windows time.now implementations into separate files

This is a step toward separating whether time.now is implemented in
assembly from whether we are using faketime.

Change-Id: I8bf059b44a103b034835e3d3b799319cc05e9552
Reviewed-on: https://go-review.googlesource.com/c/go/+/314273
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agogo/types: use a global atomic counter for type parameter ids
Rob Findley [Wed, 28 Apr 2021 14:02:16 +0000 (10:02 -0400)]
go/types: use a global atomic counter for type parameter ids

This is a 1:1 port of CL 309830 to go/types.

Change-Id: Ibf709f8194dd5e93a87145e5f9db674ce93af529
Reviewed-on: https://go-review.googlesource.com/c/go/+/314594
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agogo/types: add example test for type inference
Rob Findley [Wed, 28 Apr 2021 13:54:56 +0000 (09:54 -0400)]
go/types: add example test for type inference

This is a port of CL 308973. The only change is to remove a TODO at
inference.go2:100 to improve the error position. The go/types error
position is fine.

Change-Id: Ibf61f3458adde91dec9c7531cbd892ca654a5497
Reviewed-on: https://go-review.googlesource.com/c/go/+/314593
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agogo/types: use combined type and ordinary args for type inference
Rob Findley [Wed, 28 Apr 2021 02:52:56 +0000 (22:52 -0400)]
go/types: use combined type and ordinary args for type inference

This is a port of CL 308372 to go/types. The only meaningful change was
to add TODOs to improve the positioning error messages.

Change-Id: I8314615d0851a59c2b5fd30eb897d581652eacc3
Reviewed-on: https://go-review.googlesource.com/c/go/+/314435
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocrypto/cipher: make AES-GCM benchmarks match ChaCha20Poly1305 ones
Filippo Valsorda [Wed, 28 Apr 2021 06:12:17 +0000 (02:12 -0400)]
crypto/cipher: make AES-GCM benchmarks match ChaCha20Poly1305 ones

It's useful to compare TLS AEADs. Here are the numbers on my MacBook
with an Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz.

name                            speed
AESGCM/Open-128-64-8             692MB/s ± 2%
AESGCM/Seal-128-64-8             568MB/s ± 1%
AESGCM/Open-128-1350-8          3.96GB/s ± 1%
AESGCM/Seal-128-1350-8          3.17GB/s ± 4%
AESGCM/Open-128-8192-8          5.46GB/s ± 2%
AESGCM/Seal-128-8192-8          4.40GB/s ± 3%

name                            speed
AESGCM/Open-256-64-8             602MB/s ± 2%
AESGCM/Seal-256-64-8             508MB/s ± 1%
AESGCM/Open-256-1350-8          3.06GB/s ± 1%
AESGCM/Seal-256-1350-8          2.65GB/s ± 2%
AESGCM/Open-256-8192-8          4.02GB/s ± 3%
AESGCM/Seal-256-8192-8          3.53GB/s ± 2%

name                            speed
Chacha20Poly1305/Open-64-8       385MB/s ± 3%
Chacha20Poly1305/Seal-64-8       396MB/s ± 3%
Chacha20Poly1305/Open-1350-8    1.67GB/s ± 2%
Chacha20Poly1305/Seal-1350-8    1.62GB/s ± 1%
Chacha20Poly1305/Open-8192-8    2.04GB/s ± 2%
Chacha20Poly1305/Seal-8192-8    2.04GB/s ± 3%

Change-Id: I9373ab85bf132b45b41078205259100fa2d46dda
Reviewed-on: https://go-review.googlesource.com/c/go/+/314610
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
4 years agospec: clarify conditions for switch expression type
Robert Griesemer [Wed, 28 Apr 2021 01:05:20 +0000 (18:05 -0700)]
spec: clarify conditions for switch expression type

1. The existing prose implied that a switch expression type must
   be comparable because it is tested for equality against all case
   expressions. But for an empty switch (no case expressions), it
   was not clear if the switch expression needed to be comparable.
   Require it to match the behavior of compiler and type checkers.

2. While making this change, remove redundant language explaining
   what happens with untyped boolean switch expression values: the
   default type of an untyped boolean value is bool, this is already
   covered by the first part of the relevant sentence.

Fixes #43200.

Change-Id: Id8e0f29cfa8722b57cd2b7b58cba85b58c5f842b
Reviewed-on: https://go-review.googlesource.com/c/go/+/314411
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Rob Pike <r@golang.org>
4 years agotypes2: disambiguate package qualifiers in error messages
Robert Griesemer [Tue, 27 Apr 2021 19:54:39 +0000 (12:54 -0700)]
types2: disambiguate package qualifiers in error messages

This is a port of the go/types CL https://golang.org/cl/313035
with minor adjustments (use of package syntax rather than go/ast).

Change-Id: I89410efb3d27be85fdbe827f966c2c91ee5693b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/314410
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile/internal/types2: catch unexpected expression lists
Robert Griesemer [Tue, 27 Apr 2021 19:12:01 +0000 (12:12 -0700)]
cmd/compile/internal/types2: catch unexpected expression lists

This is a modified port of the https://golang.org/cl/313909
change for go/types.

- add catch-all cases for unexpected expression lists
- add Checker.singleIndex function to check single indices
- better syntax error handling in parser for invalid type
  instantiations that are missing a type argument

Change-Id: I6f0f396d637ad66b79f803d886fdc20ee55a98b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/314409
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/go/internal/modfetch: fix comment that mentions no-longer returned error
Jeff Widman [Wed, 28 Apr 2021 17:21:43 +0000 (17:21 +0000)]
cmd/go/internal/modfetch: fix comment that mentions no-longer returned error

In c9211577eb77df9c51f0565f1da7d20ff91d59df @bcmills removed the returned error from
`Lookup`. However, the function docstring still mentions that this can return an error.

So this corrects the docs.

Change-Id: Idca74a200dfdb024e3d7ff6c439c70632cfec11a
GitHub-Last-Rev: 62eaacf70c3886d8aba25b79212c61485a89fde0
GitHub-Pull-Request: golang/go#45822
Reviewed-on: https://go-review.googlesource.com/c/go/+/314572
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/gofmt: simplify arg handling
Daniel Martí [Fri, 15 Jan 2021 23:10:48 +0000 (23:10 +0000)]
cmd/gofmt: simplify arg handling

First, we can use flag.Args instead of flag.NArg and flag.Arg.

Second, just call filepath.WalkDir directly on each argument. We don't
need to check if each argument is a directory or not, since the function
will still work on regular files as expected.

To continue giving an error in the "gofmt does-not-exist.go" case, we
now need to return and handle errors from filepath.WalkDir, too.
Arguably, that should have always been the case.

While at it, I noticed that the printinf of the "diff" command did not
obey the "out" parameter. Fix that.

Finally, remove the code to ignore IsNotExist errors. It was added in CL
19301, though it didn't include tests and its reasoning is dubious.
Using gofmt on a directory treewhile another program is concurrently
editing or removing files is inherently racy. Hiding errors can hide
valid problems from the user, and such racy usages aren't supported.

Change-Id: I2e74cc04c53eeefb25231d804752b53562b97371
Reviewed-on: https://go-review.googlesource.com/c/go/+/284138
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/go/internal/modload: in importFromModules, do not wrap module graph errors in...
Bryan C. Mills [Wed, 28 Apr 2021 15:47:49 +0000 (11:47 -0400)]
cmd/go/internal/modload: in importFromModules, do not wrap module graph errors in ImportMissingError

If an error occurs in loading the module graph (such as a missing
checksum for a relevant go.mod file), that error should be terminal
and we should not look elsewhere to try to resolve the import. An
ImportMissingError instructs the caller to do exactly that, so don't
use that error type for this case.

(This behavior is tested incidentally in a later CL in this stack.)

For #36460

Change-Id: I963e39cc7fbc457c12a626c1402c0be29203d23b
Reviewed-on: https://go-review.googlesource.com/c/go/+/314633
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>
4 years agogo/types: split out function instantiation from index expr
Rob Findley [Tue, 27 Apr 2021 20:54:58 +0000 (16:54 -0400)]
go/types: split out function instantiation from index expr

This is a port of CL 308371 to go/types. The only meaningful change from
that CL is to use explicit return values in Checker.indexExpr, which I
felt was more readable. I made the same change in types2 to keep them in
sync

Change-Id: I3380c03fe49d3bf4167cadad305abe942785af19
Reviewed-on: https://go-review.googlesource.com/c/go/+/314432
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/compile: use desired register only if it satisfies register mask
Cherry Zhang [Wed, 28 Apr 2021 15:00:15 +0000 (11:00 -0400)]
cmd/compile: use desired register only if it satisfies register mask

In the register allocator, if possible, we allocate a value to its
desired register (the ideal register for its next use). In some
cases the desired register does not satisfies the value's output
register mask. We should not use the register in this case.

In the following example, v33 is going to be returned as a
function result, so it is allocated to its desired register AX.
However, its Op cannot use AX as output, causing miscompilation.

v33 = CMOVQEQF <int> v24 v28 v29 : AX (~R0[int])
v35 = MakeResult <int,int,mem> v33 v26 v18
Ret v35

Change-Id: Id0f4f27c4b233ee297e83077e3c8494fe193e664
Reviewed-on: https://go-review.googlesource.com/c/go/+/314630
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agotesting: add -shuffle=off|on|N to alter the execution order of tests and benchmarks
Paschalis Tsilias [Wed, 14 Apr 2021 20:55:38 +0000 (23:55 +0300)]
testing: add -shuffle=off|on|N to alter the execution order of tests and benchmarks

This CL adds a new flag to the testing package and the go test command
which randomizes the execution order for tests and benchmarks.
This can be useful for identifying unwanted dependencies
between test or benchmark functions.
The flag is off by default. If `-shuffle` is set to `on` then the system
clock will be used as the seed value. If `-shuffle` is set to an integer
N, then N will be used as the seed value. In both cases, the seed will
be reported for failed runs so that they can reproduced later on.

Fixes #28592

Change-Id: I62e7dfae5f63f97a0cbd7830ea844d9f7beac335
Reviewed-on: https://go-review.googlesource.com/c/go/+/310033
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Bryan C. Mills <bcmills@google.com>

4 years agoruntime: consolidate Windows time constants into single copy
Ian Lance Taylor [Tue, 27 Apr 2021 17:58:54 +0000 (10:58 -0700)]
runtime: consolidate Windows time constants into single copy

Change-Id: I1a583d3da9cca4ac51f3fec9b508b7638b452d60
Reviewed-on: https://go-review.googlesource.com/c/go/+/314270
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agocmd/go: include C/C++/Fortran compiler version in build ID
Ian Lance Taylor [Wed, 28 Apr 2021 00:32:02 +0000 (17:32 -0700)]
cmd/go: include C/C++/Fortran compiler version in build ID

This will force a rebuild if the C/C++/Fortran compiler changes.

No test because a real test requires installing two different compilers.

Fixes #40042

Change-Id: I83cc88ade90d665a6fce06435068f39c811e43af
Reviewed-on: https://go-review.googlesource.com/c/go/+/314276
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>