]> Cypherpunks repositories - gostls13.git/log
gostls13.git
4 years agocrypto/ed25519: add comprehensive edge-case test vectors
Filippo Valsorda [Wed, 24 Mar 2021 13:41:25 +0000 (14:41 +0100)]
crypto/ed25519: add comprehensive edge-case test vectors

This will allow us to make changes to the internals confidently, without
risking causing issues in consensus applications. It will also prevent
architecture-specific divergence, like #40475.

Fixes #40478

Change-Id: I8c2b31406ca88add6941f14d8df8cecb96379cde
Reviewed-on: https://go-review.googlesource.com/c/go/+/304349
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
Trust: Katie Hockman <katie@golang.org>

4 years agoflag: use strings.Builder instead of concatenating strings
James Fennell [Mon, 5 Apr 2021 18:21:59 +0000 (18:21 +0000)]
flag: use strings.Builder instead of concatenating strings

There is a single function in the flag package whose implementation
uses string concatenation instead of the recommended strings.Builder.
The function was last touched before strings.Builder was introduced
in Go 1.10, which explains the old style code. This PR updates
the implementation.

Fixes #45392

Change-Id: Id2d8f1788765a0c4faaeb1e6870914f72b3c8442
GitHub-Last-Rev: 0e12fe304593afc627fc4f1597670efd354809b0
GitHub-Pull-Request: golang/go#45393
Reviewed-on: https://go-review.googlesource.com/c/go/+/307329
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>

4 years agocmd/compile: add "surprised by IData of Arg" case for register args
David Chase [Mon, 5 Apr 2021 13:47:22 +0000 (09:47 -0400)]
cmd/compile: add "surprised by IData of Arg" case for register args

This fixes a compile crash for
GOEXPERIMENT=regabi,regabiargs go test -c  go/constant

Updates #40724.

Change-Id: I238cef436e045647815326fc8fdb025c30ba1f5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/307309
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/go: print deprecation notice for 'go get cmd'
Jay Conrod [Mon, 29 Mar 2021 21:00:15 +0000 (17:00 -0400)]
cmd/go: print deprecation notice for 'go get cmd'

The notice is shown when 'go get' is invoked with the -d flag, and
the arguments match at least one main package.

This reverts CL 274552.

For #43684

Change-Id: I42e6731455f22988bf72dde1d5a76d197e9e3954
Reviewed-on: https://go-review.googlesource.com/c/go/+/305670
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd/cgo: pass end position info for C function arguments.
wolf1996 [Fri, 13 Nov 2020 11:30:15 +0000 (14:30 +0300)]
cmd/cgo: pass end position info for C function arguments.

Pass information about original end position for c function arguments
processed in pointer checking generated code.

Fixes #42580

Change-Id: Ic8a578168362f0ca6055064dbbea092ad37477a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/269760
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

4 years agonet: make ErrClosed and ParseError implement net.Error
Ian Lance Taylor [Fri, 2 Apr 2021 21:36:36 +0000 (14:36 -0700)]
net: make ErrClosed and ParseError implement net.Error

Fixes #45357

Change-Id: Iafd41fff232a89be4c88d4b1d66bc3c04d888bcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/307030
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
4 years agocmd/internal/obj: remove duplicate ppc64 spr MOV* optab entries
Paul E. Murphy [Tue, 9 Mar 2021 22:55:06 +0000 (16:55 -0600)]
cmd/internal/obj: remove duplicate ppc64 spr MOV* optab entries

The matching rules will match C_SPR for the commonly used SPR
entries (xer, lr, ctr).

Change-Id: I93759c1ce2891f6825661b99c5cbb89250b64ab7
Reviewed-on: https://go-review.googlesource.com/c/go/+/304429
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>

4 years agotime: use offset and isDST when caching zone from extend string
Martin Sucha [Sun, 4 Apr 2021 17:20:47 +0000 (19:20 +0200)]
time: use offset and isDST when caching zone from extend string

If the current time is computed from extend string
and the zone file contains multiple zones with the
same name, the lookup by name might find incorrect
zone.

This happens for example with the slim Europe/Dublin
time zone file in the embedded zip. This zone file
has last transition in 1996 and rest is covered by
extend string.
tzset returns IST as the zone name to use, but there
are two records with IST name. Lookup by name finds
the wrong one. We need to check offset and isDST too.

In case we can't find an existing zone, we allocate
a new zone so that we use correct offset and isDST.

I have renamed zone variable to zones as it shadowed
the zone type that we need to allocate the cached zone.

Fixes #45370

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

4 years agocmd/compile, runtime: use ABI-aware function converting float to interface
Cherry Zhang [Sun, 4 Apr 2021 00:49:03 +0000 (20:49 -0400)]
cmd/compile, runtime: use ABI-aware function converting float to interface

Currently, when converting a float (say float64), we use convT64
function. In the runtime convT64 expects a uint64 argument. In
the compiler, convT64 is defined as taking an "any" argument (so
it works with also uint64-like types such as [1]uint64). The "any"
type is instantiated with the concrete type in walk. So the
backend will see instances such as convT64([1]uint64).

Currently, float64 is treated as uint64-like. So the backend will
see convT64(float64). With a memory-based calling convention this
is fine. With a register-based calling convention, however, it
will pass the argument in a floating point register, whereas the
runtime expects the argument in an integer register (as it is
declared as uint64).

To fix this, this CL introduces runtime functions convT32F and
convT64F. They behave the same as convT32/convT64, but with a
float argument. In the compiler, use convT32F/convT64F to convert
float-like type to interface.

With this, "GOEXPERIMENT=regabi,regabiargs go test math fmt"
works.

Updates #40724.

Change-Id: I8b2e232096a95e4a7c4ab81795d77ef224ffaab3
Reviewed-on: https://go-review.googlesource.com/c/go/+/307232
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoall: update references to symbols moved from io/ioutil to io
KimMachineGun [Sat, 3 Apr 2021 08:10:47 +0000 (08:10 +0000)]
all: update references to symbols moved from io/ioutil to io

Update references missed in CL 263142.

For #41190

Change-Id: I778760a6a69bd0440fec0848bdef539c9ccb4ee1
GitHub-Last-Rev: dda42b09fff36dc08ec1cdec50cc19e3da5058e5
GitHub-Pull-Request: golang/go#42874
Reviewed-on: https://go-review.googlesource.com/c/go/+/273946
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 agocmd/compile/internal/ssagen: conditon not need
cui [Mon, 5 Apr 2021 12:38:12 +0000 (12:38 +0000)]
cmd/compile/internal/ssagen: conditon not need

 n.Op() == ir.OFOR so n.Op() != ir.OFORUNTIL is always true

Change-Id: I97191783c1fb31ef76e0601f626b45af1e8d316e
GitHub-Last-Rev: f68f9fecfb7adf37af060afb77d6615839aabc6e
GitHub-Pull-Request: golang/go#45389
Reviewed-on: https://go-review.googlesource.com/c/go/+/307251
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>

4 years agocmd/compile: untangle Wrapper and ABIWrapper flags
Cherry Zhang [Sun, 4 Apr 2021 16:46:21 +0000 (12:46 -0400)]
cmd/compile: untangle Wrapper and ABIWrapper flags

Currently, there are Wrapper and ABIWrapper attributes. Wrapper
is set when compiler generates an wrapper function (e.g. method
wrapper). ABIWrapper is set when compiler generates an ABI
wrapper. It also sets Wrapper flag for ABI wrappers.

Currently, they have the following meanings:
- Wrapper flag hides the frame from (normal) traceback.
- Wrapper flag enables special panic+recover adjustment, so it
  can correctly recover when a wrapper function is deferred.
- ABIWrapper flag disables the panic+recover adjustment, because
  we never defer an ABI wrapper that can recover.

This CL changes them to:
- Both Wrapper and ABIWrapper flags hide the frame from (normal)
  traceback. (Setting one is enough.)
- Wrapper flag enables special panic+recover adjustment.
  ABIWrapper flag no longer has effect on this.

This makes it clearer if we do want an ABI wrapper that also does
the panic+recover adjustment. In the old mechanism we'd have to
unset ABIWrapper flag, even if the function is actually an ABI
wrapper. In the new mechanism we just need to set both ABIWrapper
and Wrapper flags.

Updates #40724.

Change-Id: I7fbc83f85d23676dc94db51dfda63dcacdf1fc19
Reviewed-on: https://go-review.googlesource.com/c/go/+/307235
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/compile: disable tail call for method wrappers when RegabiArgs is enabled
Cherry Zhang [Sun, 4 Apr 2021 16:20:35 +0000 (12:20 -0400)]
cmd/compile: disable tail call for method wrappers when RegabiArgs is enabled

Currently, the IR of tailcall does not connect the arguments with
the OTAILCALL node, so the arguments are not marshaled correctly.
Disable tail call for now.

Updates #40724.

Change-Id: I39de3ea8e19a23eb63768ab7282d2f870e9c266e
Reviewed-on: https://go-review.googlesource.com/c/go/+/307234
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/compile: reference ABIInternal memequal_varlen
Cherry Zhang [Sun, 4 Apr 2021 16:15:13 +0000 (12:15 -0400)]
cmd/compile: reference ABIInternal memequal_varlen

memequal_varlen is put into a closure and is called in internal
ABI in the runtime. Emit an ABIInternal reference.

Updates #40724.

Change-Id: I914555f8188561882625e008b595389e50a3a167
Reviewed-on: https://go-review.googlesource.com/c/go/+/307233
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/compile: add a debug flag to enable/disable open-coded defers
Cherry Zhang [Sat, 3 Apr 2021 01:48:00 +0000 (21:48 -0400)]
cmd/compile: add a debug flag to enable/disable open-coded defers

For debugging.

Change-Id: I831947376569cd2285b713ad304329951adf60ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/307230
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>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/link: mangle function name with ABI on Mach-O
Cherry Zhang [Sat, 3 Apr 2021 01:04:31 +0000 (21:04 -0400)]
cmd/link: mangle function name with ABI on Mach-O

This is not strictly necessary. But as we already do this on
ELF and PE, do it here as well.

Updates #40724.

Change-Id: Ie6e5211aba116634bc9ed82eb8d22a7fed3b7776
Reviewed-on: https://go-review.googlesource.com/c/go/+/307229
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/internal/objabi: remove StackPreempt
Austin Clements [Sat, 3 Apr 2021 20:29:34 +0000 (16:29 -0400)]
cmd/internal/objabi: remove StackPreempt

None of the stack check prologues depend on this constant at this
point (and, indeed, they shouldn't).

Change-Id: Iaa40d9c47285b26952f02a7bdde574e8385ffe95
Reviewed-on: https://go-review.googlesource.com/c/go/+/307152
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/internal/obj/s390x: simplify huge frame prologue
Austin Clements [Fri, 2 Apr 2021 21:20:15 +0000 (17:20 -0400)]
cmd/internal/obj/s390x: simplify huge frame prologue

CL 307010 for s390x.

Change-Id: I43e1f93dd01c814417f8ef7480aa82c05b2b6b66
Reviewed-on: https://go-review.googlesource.com/c/go/+/307151
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/internal/obj/riscv: simplify huge frame prologue
Austin Clements [Fri, 2 Apr 2021 21:20:15 +0000 (17:20 -0400)]
cmd/internal/obj/riscv: simplify huge frame prologue

CL 307010 for riscv64.

Some of the comments on the other prologue paths were wrong, so this
CL also fixes them up.

Change-Id: Icdca1ade3a47ae6e2467af832690d40689dbe1b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/307150
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/internal/obj/ppc64: simplify huge frame prologue
Austin Clements [Fri, 2 Apr 2021 21:20:15 +0000 (17:20 -0400)]
cmd/internal/obj/ppc64: simplify huge frame prologue

CL 307010 for ppc64.

I spent a long time trying to figure out how to use the carry bit from
ADDCCC to further simplify this (like what we do on arm64), but gave
up after I couldn't figure out how to access the carry bit without
just adding more instructions.

Change-Id: I6cad51b93616865b203cb16554f16121375aabbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/307149
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/internal/obj/mips: simplify huge frame prologue
Austin Clements [Fri, 2 Apr 2021 21:20:15 +0000 (17:20 -0400)]
cmd/internal/obj/mips: simplify huge frame prologue

CL 307010 for mips.

Change-Id: Ie9addea728548315fdbb8e46f75da4010a9796bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/307051
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/internal/obj/arm64: simplify huge frame prologue
Austin Clements [Fri, 2 Apr 2021 21:20:15 +0000 (17:20 -0400)]
cmd/internal/obj/arm64: simplify huge frame prologue

CL 307010 for arm64.

Change-Id: I6c6e1bd6065df059e50c3632a9eb669b64fce899
Reviewed-on: https://go-review.googlesource.com/c/go/+/307050
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/internal/obj/arm: simplify huge frame prologue
Austin Clements [Fri, 2 Apr 2021 20:59:22 +0000 (16:59 -0400)]
cmd/internal/obj/arm: simplify huge frame prologue

CL 307010 for arm.

Change-Id: I14d939eb8aa6f594927054a2595f8c270a0b607f
Reviewed-on: https://go-review.googlesource.com/c/go/+/307049
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/internal/obj/x86: simplify huge frame prologue
Austin Clements [Fri, 2 Apr 2021 19:57:46 +0000 (15:57 -0400)]
cmd/internal/obj/x86: simplify huge frame prologue

For stack frames larger than StackBig, the stack split prologue needs
to guard against potential wraparound. Currently, it carefully
arranges to avoid underflow, but this is complicated and requires a
special check for StackPreempt. StackPreempt is no longer the only
stack poison value, so this check will incorrectly succeed if the
stack bound is poisoned with any other value.

This CL simplifies the logic of the check, reduces its length, and
accounts for any possible poison value by directly checking for
underflow.

Change-Id: I917a313102d6a21895ef7c4b0f304fb84b292c81
Reviewed-on: https://go-review.googlesource.com/c/go/+/307010
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoruntime: extend internal atomics to comply with sync/atomic
Ruslan Andreev [Wed, 13 Jan 2021 14:36:19 +0000 (22:36 +0800)]
runtime: extend internal atomics to comply with sync/atomic

The CV add changes according to TODO in Go source-code.
Internal atomic set does not comply with sync/atomic library and has shortage
operations for signed integers.
This patch extend internal atomic set by Int32 and Int64 operations. It's
implemented new aliases and asm versions of operations. As a result Cas64 was
replaced by Casint64 in findRunnableGCWorker without type casting.
Another purpose is unified structure of internal atomics' source code. Before,
assembly impementations for different archs were in different files. For
example, filename for AMD64 was asm_amd64.s, but filename for RISC-V was
atomic_riscv64.s. Some arches have both files without any meaning. So, assembly
files were merged and renamed to atomic_{$ARCH}.s filenames.

Change-Id: I29a05a7cbf5f4a9cc146e8315536c038af545677
Reviewed-on: https://go-review.googlesource.com/c/go/+/289152
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: get rid of Fields in types.Interface, use allMethods in types.Type instead
Dan Scales [Fri, 2 Apr 2021 23:52:58 +0000 (16:52 -0700)]
cmd/compile: get rid of Fields in types.Interface, use allMethods in types.Type instead

Confusingly, the set of all methods of an interface is currently set in
Fields field of types.Interface. This is true, even though there is
already an allMethods field (and AllMethods method) of types.Type.
Change so the set of all methods of an interface are stored in
Type.allMethods, and Interface.Fields is removed. Update the comments
for Methods and AllMethods.

Change-Id: Ibc32bafae86831cba62606b079a855690612c759
Reviewed-on: https://go-review.googlesource.com/c/go/+/307209
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/go: refactor modload.CheckRetractions
Jay Conrod [Wed, 31 Mar 2021 18:25:33 +0000 (14:25 -0400)]
cmd/go: refactor modload.CheckRetractions

Extract queryLatestVersionIgnoringRetractions, which returns the
version we should load retractions and deprecations from. This will be
shared with CheckDeprecations.

Rename ShortRetractionRationale to ShortMessage. This will be used to
shorten deprecation warnings as well.

For #40357

Change-Id: Ic1e0c670396bdb3bd87c7a97cf2b14ca58ea1d80
Reviewed-on: https://go-review.googlesource.com/c/go/+/306332
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd/go: refactor modload.ListModules to accept bit flags
Jay Conrod [Wed, 31 Mar 2021 18:19:41 +0000 (14:19 -0400)]
cmd/go: refactor modload.ListModules to accept bit flags

Instead of accepting bool flags, ListModules now accepts ListMode, a
set of bit flags.

Four flags are defined. listRetracted is split into ListRetracted and
ListRetractedVersion to avoid ambiguity with -u, -retracted, and
-versions.

For #40357

Change-Id: Ibbbe44dc1e285ed17f27a6581f3392679f2124fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/306331
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agoos: don't use T.Cleanup in TestRemoveAllLongPath
Tobias Klauser [Sun, 4 Apr 2021 11:44:21 +0000 (13:44 +0200)]
os: don't use T.Cleanup in TestRemoveAllLongPath

Revert CL 306290 changes to TestRemoveAllLongPath. This breaks the test
on aix, illumos and solaris. We need to chdir out of startPath before
attempting to remove it.

Updates #45182

Change-Id: Ic14fa1962d6f2cc83238f6fc2c6932fd9a6e52a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/307189
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
4 years agoruntime/pprof: skip tests for AIX
Clément Chigot [Thu, 1 Apr 2021 08:06:05 +0000 (10:06 +0200)]
runtime/pprof: skip tests for AIX

Most of the time, the pprof tests are passing, except
for the builder. The reason is still unknown but I'd rather release
the builder to avoid missing other more important bugs.

Updates #45170

Change-Id: I667543ee1ae309b7319c5b3676a0901b4d0ecf2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/306489
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>

4 years agoos, path/filepath: use T.Cleanup to restore the original working directory
ianwoolf [Wed, 31 Mar 2021 17:27:29 +0000 (01:27 +0800)]
os, path/filepath: use T.Cleanup to restore the original working directory

Updates #45182

Change-Id: Iaf3bdcc345c72fa9669fdc99908ada4e89904edd
Reviewed-on: https://go-review.googlesource.com/c/go/+/306290
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoos: reuse readdir buffers on unix with a sync.Pool
Tom Thorogood [Tue, 16 Mar 2021 02:05:35 +0000 (12:35 +1030)]
os: reuse readdir buffers on unix with a sync.Pool

(*File).readdir allocates a fixed-size 8KiB buffer on unix systems that
cannot be reused. While it accounts for just a single allocation, it's
more than large enough to show up in profiles and make things quite a
bit slower.

Instead of allocating so often, use a sync.Pool to allow these buffers to
be reused. This has a large impact on readdir heavy workloads.

Package os benchmarks:

name            old time/op    new time/op    delta
Readdirname-12    35.6µs ± 5%    18.1µs ± 4%  -49.00%  (p=0.000 n=10+10)
Readdir-12         142µs ± 1%     121µs ± 0%  -14.87%  (p=0.000 n=10+9)
ReadDir-12        44.0µs ± 6%    28.4µs ± 8%  -35.58%  (p=0.000 n=9+10)

name            old alloc/op   new alloc/op   delta
Readdirname-12    14.4kB ± 0%     6.2kB ± 0%  -57.08%  (p=0.000 n=10+10)
Readdir-12        41.6kB ± 0%    33.4kB ± 0%  -19.77%  (p=0.000 n=10+9)
ReadDir-12        21.9kB ± 0%    13.7kB ± 0%  -37.39%  (p=0.000 n=10+10)

name            old allocs/op  new allocs/op  delta
Readdirname-12       131 ± 0%       130 ± 0%   -0.76%  (p=0.000 n=10+10)
Readdir-12           367 ± 0%       366 ± 0%   -0.27%  (p=0.000 n=10+10)
ReadDir-12           249 ± 0%       248 ± 0%   -0.40%  (p=0.000 n=10+10)

A clunky benchmark I threw together that calls filepath.WalkDir on $GOMODCACHE:

name        old time/op    new time/op    delta
WalkDir-12    91.2ms ±19%    48.7ms ± 0%  -46.54%  (p=0.000 n=10+10)

name        old alloc/op   new alloc/op   delta
WalkDir-12    54.0MB ± 0%     7.6MB ± 0%  -85.92%  (p=0.000 n=8+9)

name        old allocs/op  new allocs/op  delta
WalkDir-12      136k ± 0%      130k ± 0%   -4.15%  (p=0.000 n=8+8)

Change-Id: I00e4d48726da0e46c528ab205409afd03127b844
Reviewed-on: https://go-review.googlesource.com/c/go/+/302169
Reviewed-by: 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 agoarchive/zip: fix character device handling in fileModeToUnixMode
Tom Thorogood [Fri, 12 Mar 2021 13:57:30 +0000 (00:27 +1030)]
archive/zip: fix character device handling in fileModeToUnixMode

The switch case for fs.ModeDevice can only be reached for block devices
while character devices match fs.ModeDevice | fs.ModeCharDevice. This
would cause character devices to wrongly be reported as regular files.

This bug has existed since the switch was first introduced in CL 5624048.

Change-Id: Icdbedb015e5376b385b3115d2e4574daa052f796
Reviewed-on: https://go-review.googlesource.com/c/go/+/300891
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 agoio/fs: implement subFS.Sub
Drew Richardson [Fri, 2 Apr 2021 00:05:24 +0000 (17:05 -0700)]
io/fs: implement subFS.Sub

Calling fs.Sub with the result of fs.Sub multiple times creates a deep
call stack for Open and other methods. Enhance the fs.FS returned by
fs.Sub to implement fs.SubFS and reduce the call stack.

Fixes #45349

Change-Id: I10e10501e030176e10e2ae5ad260212e5c784bed
Reviewed-on: https://go-review.googlesource.com/c/go/+/306769
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 agocmd/compile: rename newNamedTypeWithSym, add some commemnts
Dan Scales [Fri, 2 Apr 2021 21:31:15 +0000 (14:31 -0700)]
cmd/compile: rename newNamedTypeWithSym, add some commemnts

Renamed newNamedTypeWithSym to newIncompleteNamedType. Added some extra
comments to types.NewNamed and types.SetUnderlying.

Change-Id: Idc5a6379991c26b429d91bae9fe1adef8457a75c
Reviewed-on: https://go-review.googlesource.com/c/go/+/307029
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Ingo Oeser <nightlyone@googlemail.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
4 years agocmd/dist: include "go1.x-" in devel go version strings
Daniel Martí [Mon, 26 Oct 2020 09:42:54 +0000 (09:42 +0000)]
cmd/dist: include "go1.x-" in devel go version strings

This way, "go version" will report the "base version" or major version
that the tool corresponds to. This is the same version number that is
matched against build tags such as "go1.14" or "!go1.16".

Obtaining this version being built is non-trivial, since we can't just
import a package or query git. The added comments document the chosen
mechanism, based on a regular expression. It was chosen over AST parsing
as it would add a significant amount of code without much gain, given
how simple the goversion.go file is.

For #41116.

Change-Id: I653ae935e27c13267f23898f89c84020dcd6e194
Reviewed-on: https://go-review.googlesource.com/c/go/+/264938
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
4 years agocmd/compile/internal/types2: review of errors.go
Robert Griesemer [Mon, 29 Mar 2021 21:59:39 +0000 (14:59 -0700)]
cmd/compile/internal/types2: review of errors.go

The changes between (equivalent, and reviewed) go/types/errors.go
and errors.go can be seen by comparing patchset 1 and 2. The actual
changes are removing the "// UNREVIEWED" marker.

The go/types version is significantly different as it handles
error codes but doesn't have some of the types2 changes.

Change-Id: I48f79ce31490db938c830df7d38e247d55d54f2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/305577
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile/internal/types2: review of stmt.go
Robert Griesemer [Mon, 29 Mar 2021 20:36:53 +0000 (13:36 -0700)]
cmd/compile/internal/types2: review of stmt.go

The changes between (equivalent, and reviewed) go/types/stmt.go
and stmt.go can be seen by comparing patchset 1 and 2. The actual
changes are removing the "// UNREVIEWED" marker, and minor adjustments
to get the code slightly closer to go/types/stmt.go.

The primary differences compared to go/types are:
- use of syntax rather than go/ast package, with significant
  differences in the representation of switch and select statements,
  range clauses of for statements, and inc/dec statements.
- no reporting of error codes
- use or error_ for collecting addition error information

Change-Id: I4409f62ecafd0653e4c8ef087c2580d8f0544efc
Reviewed-on: https://go-review.googlesource.com/c/go/+/305576
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile/internal/types2: review of check_test.go
Robert Griesemer [Mon, 29 Mar 2021 19:33:45 +0000 (12:33 -0700)]
cmd/compile/internal/types2: review of check_test.go

The changes between (equivalent, and reviewed) go/types/check_test.go
and check_test.go can be seen by comparing patchset 1 and 2. The actual
changes are removing the "// UNREVIEWED" marker, and minor adjustments
to get the code slightly closer to go/types/check_test.go.

The primary differences compared to go/types are:
- use of syntax rather than go/ast package
- re-implemented mechanism for error matching and elimination
  based on the syntax.ErrorMap mechanism (there's no exported
  access to the syntax scanner)
- error matching permits for column tolerances because types2
  column information doesn't match go/types column information

Change-Id: I8ae6bc93dfa2b517673b642064a1f09166755286
Reviewed-on: https://go-review.googlesource.com/c/go/+/305573
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/compile/internal/types2: review of resolver.go
Robert Griesemer [Mon, 29 Mar 2021 19:22:01 +0000 (12:22 -0700)]
cmd/compile/internal/types2: review of resolver.go

The changes between (equivalent, and reviewed) go/types/resolver.go
and resolver.go can be seen by comparing patchset 1 and 2. The actual
changes are removing the "// UNREVIEWED" marker.

The primary differences compared to go/types are:
- use of syntax rather than go/ast package
- not using a walkDecl abstraction for const/var/type declarations

Change-Id: Id8d7b069813149ca4eadbb61d1124b22c56a91b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/305572
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/obj: use REGENTRYTMP* in a few more places
Austin Clements [Fri, 2 Apr 2021 17:32:08 +0000 (13:32 -0400)]
cmd/internal/obj: use REGENTRYTMP* in a few more places

There are a few remaining places in obj6 where we hard-code
safe-on-entry registers. Fix those to use the consts.

For #40724.

Change-Id: Ie640521aa67d6c99bc057553dc122160049c6edc
Reviewed-on: https://go-review.googlesource.com/c/go/+/307009
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agotesting: clarify when Cleanup is called
Carlo Alberto Ferraris [Fri, 2 Apr 2021 08:36:54 +0000 (17:36 +0900)]
testing: clarify when Cleanup is called

Change-Id: I2ed394fccec83aac09a49673554cbf504787965b
Reviewed-on: https://go-review.googlesource.com/c/go/+/306810
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

4 years agoruntime: make concatstring{2,3,4,5} consistent w/ compiler's use
David Chase [Fri, 2 Apr 2021 19:51:45 +0000 (15:51 -0400)]
runtime: make concatstring{2,3,4,5} consistent w/ compiler's use

Internally the compiler uses a0,a1,a3 string, not [3]string,
and this lead to different parameter passing (memory, versus registers)
which of course did not work.

Updates #40724.

Change-Id: I1dbf479b88134559ba54b4b00a042b9a0fd128b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/306910
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoreflect: fix methodValueCall frame size on mips64
Michael Anthony Knyszek [Fri, 2 Apr 2021 19:06:33 +0000 (19:06 +0000)]
reflect: fix methodValueCall frame size on mips64

Fixes a mistake from golang.org/cl/298670.

Change-Id: I2f789f9fe003c856a993f7d462a2e84936743a1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/306930
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoreflect: remove short-circuits for zero-sized types in ABI algorithm
Michael Anthony Knyszek [Fri, 2 Apr 2021 18:58:56 +0000 (18:58 +0000)]
reflect: remove short-circuits for zero-sized types in ABI algorithm

This change removes two short-circuits for zero-sized types (zero-sized
structs and zero-sized struct fields) in the recursive cases of the ABI
algorithm, because this does not match the spec's algorithm, nor the
compiler's algorithm.

The failing case here is a struct with a field that is an array of
non-zero length but whose element type is zero-sized. This struct must
be stack-assigned because of the array, according to the algorithm.
The reflect package was register-assigning it.

Because there were two short-circuits, this can also appear if a struct
has a field that is a zero-sized struct but contains such an array,
also.

This change adds regression tests for both of these cases.

For #44816.
For #40724.

Change-Id: I956804170962448197a1c9853826e3436fc8b1ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/306929
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: mark unused values as invalid to prevent problems in expandCalls
David Chase [Fri, 2 Apr 2021 16:33:23 +0000 (12:33 -0400)]
cmd/compile: mark unused values as invalid to prevent problems in expandCalls

Leftover values that have been replaced can cause problems in later
passes (within expandCalls).  For example, a struct select that
itself yields a struct will have a problematic rewrite, if the chance
is presented.

Updates #40724.

Change-Id: I1b445c47c301c3705f7fc0a9d39f1f5c84f4e190
Reviewed-on: https://go-review.googlesource.com/c/go/+/306869
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoreflect: add register ABI support for makeFuncStub and methodValueCall
Michael Anthony Knyszek [Thu, 28 Jan 2021 15:23:05 +0000 (15:23 +0000)]
reflect: add register ABI support for makeFuncStub and methodValueCall

This change finishes off functionality register ABI for the reflect
package.

Specifically, it implements a call on a MakeFunc'd value by performing
the reverse process that reflect.Value.Call does, using the same ABI
steps. It implements a call on a method value created by reflect by
translating between the method value's ABI to the method's ABI.

Tests are added for both cases.

For #40724.

Change-Id: I302820b61fc0a8f94c5525a002bc02776aef41af
Reviewed-on: https://go-review.googlesource.com/c/go/+/298670
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: use ABI0 for cgo_unsafe_args functions
Cherry Zhang [Thu, 1 Apr 2021 15:11:04 +0000 (11:11 -0400)]
cmd/compile: use ABI0 for cgo_unsafe_args functions

cgo_unsafe_args paragma indicates that the function (or its
callee) uses address and offsets to dispatch arguments, which
currently using ABI0 frame layout. Pin them to ABI0.

With this, "GOEXPERIMENT=regabi,regabiargs go run hello.go" works
on Darwin/AMD64.

Change-Id: I3eadd5a3646a9de8fa681fa0a7f46e7cdc217d24
Reviewed-on: https://go-review.googlesource.com/c/go/+/306609
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agosyscall: delete asm_windows.s
Cherry Zhang [Thu, 1 Apr 2021 23:22:12 +0000 (19:22 -0400)]
syscall: delete asm_windows.s

asm_windows.s contains dummy references of syscall.loadlibrary
and syscall.getprocaddress, to trigger ABI wrapper/alias
generation to get ABI0 symbols for them. The comment says they
are called from assembly in other packages, but I couldn't find
where. They are defined in Go and only referenced in Go.

CL 179862 removed dummy references in the runtime. This CL
is similar, for the syscall package.

Also, with CL 306609, they will have ABI0 definitions anyway.

Change-Id: I5c7b0efb9762e4ad9c94f0beea8d053d8c8b2cd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/306709
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agogo/src/cmd/go/internal/work: compile "internal/abi" with "-+"
Himanshu Kishna Srivastava [Wed, 31 Mar 2021 15:52:49 +0000 (21:22 +0530)]
go/src/cmd/go/internal/work: compile "internal/abi" with "-+"

"internal/abi" package depends on runtime package and are supposed to
compile with "-+" option.Added internal/abi in the known list of package
that runtime depends on,so that "internal/abi" compiles with "-+".

Fixes #45144

Change-Id: Iad9e2589f2fbd014260cb8ef9f943d2126015fe1
Reviewed-on: https://go-review.googlesource.com/c/go/+/306289
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/link: delete CompilationUnit.Pkg field
Cherry Zhang [Fri, 2 Apr 2021 00:08:32 +0000 (20:08 -0400)]
cmd/link: delete CompilationUnit.Pkg field

It is never used. It is actually CompilationUnit.Lib.Pkg that
contains the package path.

Change-Id: I18189644ea080080868d144e81dfee02f4549133
Reviewed-on: https://go-review.googlesource.com/c/go/+/306710
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: remove an unused function from linker dwarf gen
Than McIntosh [Fri, 2 Apr 2021 10:58:13 +0000 (06:58 -0400)]
cmd/link: remove an unused function from linker dwarf gen

Remove a no-longer-used function.

Change-Id: Iad383a9d158d31d4c8b65dd39b71849b44c6b52e
Reviewed-on: https://go-review.googlesource.com/c/go/+/306829
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years agocmd/link: remove unnecessary attrReachable test
Tao Qingyun [Fri, 2 Apr 2021 12:02:17 +0000 (12:02 +0000)]
cmd/link: remove unnecessary attrReachable test

Change-Id: I5a6fde3ce57be1760cc8c92910fe77beb8b9c655
GitHub-Last-Rev: 0b2f3cb3a81336d94d288afe7c324a5a54114ebb
GitHub-Pull-Request: golang/go#45259
Reviewed-on: https://go-review.googlesource.com/c/go/+/305169
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: David Chase <drchase@google.com>

4 years agocmd/compile: fix bug in phiopt pass
Keith Randall [Thu, 1 Apr 2021 06:58:54 +0000 (23:58 -0700)]
cmd/compile: fix bug in phiopt pass

The math to invert the input index was wrong.

Fixes #45323

Change-Id: I7c68cac280e8f01a9c806ecb0f195f169267437e
Reviewed-on: https://go-review.googlesource.com/c/go/+/306431
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: fannie zhang <Fannie.Zhang@arm.com>
Reviewed-by: David Chase <drchase@google.com>
4 years agoruntime: make gcTestMoveStackOnNextCall not double the stack
Austin Clements [Thu, 1 Apr 2021 20:50:53 +0000 (16:50 -0400)]
runtime: make gcTestMoveStackOnNextCall not double the stack

Currently, gcTestMoveStackOnNextCall doubles the stack allocation on
each call because stack movement always doubles the stack. That's
rather unfortunate if you're doing a bunch of stack movement tests in
a row that don't actually have to grow the stack because you'll
quickly hit the stack size limit even though you're hardly using any
of the stack.

Fix this by adding a special stack poison value for
gcTestMoveStackOnNextCall that newstack recognizes and inhibits the
allocation doubling.

Change-Id: Iace7055a0f33cb48dc97b8f4b46e45304bee832c
Reviewed-on: https://go-review.googlesource.com/c/go/+/306672
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime: fix TestGCTestMoveStackOnNextCall flakes
Austin Clements [Wed, 31 Mar 2021 16:13:58 +0000 (12:13 -0400)]
runtime: fix TestGCTestMoveStackOnNextCall flakes

gcTestMoveStackOnNextCall can fail to move the stack in very rare
cases if there's an unfortunately timed preemption that clobbers the
stack guard. This won't happen multiple times in quick succession, so
make the test just retry a few times.

Change-Id: I247dc0551514e269e7132cee7945291429b0e865
Reviewed-on: https://go-review.googlesource.com/c/go/+/306671
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: in expand calls, preserve pointer store type but decompose aggregate...
Cherry Zhang [Thu, 1 Apr 2021 18:21:12 +0000 (14:21 -0400)]
cmd/compile: in expand calls, preserve pointer store type but decompose aggregate args

In CL 305672 we preserve the pointer type of a store by just not
decomposing it. But this can be problematic when the source of
the store is a direct interface aggregate type (e.g.
struct { x map[int]int }.

In this CL we take a different approach: we preserve the store
type when generating the new store, but also decompose the source.

Fixes #45344.

Change-Id: If5dd496458dee95aa649c6d106b96a6cdcf3e60d
Reviewed-on: https://go-review.googlesource.com/c/go/+/306669
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agoreflect,runtime: assume register ABI with GOEXPERIMENT=regabiargs
Michael Anthony Knyszek [Thu, 1 Apr 2021 15:02:11 +0000 (15:02 +0000)]
reflect,runtime: assume register ABI with GOEXPERIMENT=regabiargs

This change causes finalizers, reflect calls, and Windows syscall
callbacks to assume the register ABI when GOEXPERIMENT=regabiargs is
set. That is, when all Go functions are using the new ABI by default,
these features should assume the new ABI too.

For #40724.

Change-Id: Ie4ee66b8085b692e1ff675f01134c9a4703ae1b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/306571
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoreflect: undo register count increments on register assignment failure
Michael Anthony Knyszek [Tue, 30 Mar 2021 22:33:28 +0000 (22:33 +0000)]
reflect: undo register count increments on register assignment failure

Currently when register assignment fails we roll back all the abiParts
that were generated in the process. However, the total number of
registers also increases, but does not get rolled back. The result is
a very incorrect register assignment.

For #40724.
For #44816.

Change-Id: I1934ea5f95f7608ff2067166255099dbc9135e8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/306109
Trust: Michael Knyszek <mknyszek@google.com>
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 agocmd/compile: fix register/offset calculation for trailing empty field case.
David Chase [Thu, 1 Apr 2021 02:51:44 +0000 (22:51 -0400)]
cmd/compile: fix register/offset calculation for trailing empty field case.

Includes test.
Long term, need to make the offending code be more in terms
of official types package offsets, instead of duplicating that
logic.

For #40724.

Change-Id: Id33a153f10aed3289cc48d1f99a8e0f6ece9474d
Reviewed-on: https://go-review.googlesource.com/c/go/+/306469
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agonet/url: use camelCase names
Cluas [Thu, 1 Apr 2021 05:25:23 +0000 (05:25 +0000)]
net/url: use camelCase names

Change-Id: I191b98b846c9de58b1892e695058c727402b5400
GitHub-Last-Rev: f241ddd96b4e847ee3608133a41e1b2bb553982d
GitHub-Pull-Request: golang/go#45291
Reviewed-on: https://go-review.googlesource.com/c/go/+/305770
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: fix parameter offset calculation
Cherry Zhang [Thu, 1 Apr 2021 00:02:26 +0000 (20:02 -0400)]
cmd/compile: fix parameter offset calculation

For struct like { { a int64; b int16 }; c int32 }, on 64-bit
machines the offset of c is 16, as the inner struct takes 16
bytes because we round up type size to its alignment. Update the
abi package's offset calculation to include this.

We only need to do this for struct type, because for all other
types its size is naturally aligned.

TODO: add a test.

Change-Id: I0c661768cb1ed3cb409b20a88b7e23e059f8e3e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/306449
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>
Reviewed-by: David Chase <drchase@google.com>
4 years agoruntime: fix uses of ABIInternal PCs in assembly
Austin Clements [Mon, 29 Mar 2021 21:38:20 +0000 (17:38 -0400)]
runtime: fix uses of ABIInternal PCs in assembly

The covers three kinds of uses:

1. Calls of closures from assembly. These are always ABIInternal calls
without wrappers. I went through every indirect call in the runtime
and I think mcall is the only case of assembly calling a Go closure in
a way that's affected by ABIInternal. systemstack also calls a
closure, but it takes no arguments.

2. Calls of Go functions that expect raw ABIInternal pointers. I also
only found one of these: callbackasm1 -> cgocallback on Windows. These
are trickier to find, though.

3. Finally, I found one case on NetBSD where new OS threads were
directly calling the Go runtime entry-point from assembly via a PC,
rather than going through a wrapper. This meant new threads may not
have special registers set up. In this case, a change on all other
OSes had already forced new thread entry to go through an ABI wrapper,
so I just caught NetBSD up with that change.

With this change, I'm able to run a "hello world" with
GOEXPERIMENT=regabi,regabiargs.

For #40724.

Change-Id: I2a6d0e530c4fd4edf13484d923891c6160d683aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/305669
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: fix outgoing calls with GOEXPERIMENT=regabiargs
Austin Clements [Wed, 31 Mar 2021 21:41:07 +0000 (17:41 -0400)]
cmd/compile: fix outgoing calls with GOEXPERIMENT=regabiargs

The logic for constructing calls in (*state).call is based around
targeted experiments with register-based calls. However, when the
register ABI is turned on everywhere, it currently doesn't account for
direct calls to non-ABIInternal functions. This CL adds a much simpler
path to (*state).call when regabiargs is turned on that looks at the
ABI of the target function.

For #40724.

Change-Id: I7f4f5fed8a5ec131bcf1ce5b9d94d45672a304cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/306410
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: fix incoming ABI with GOEXPERIMENT=regabiargs
Austin Clements [Wed, 31 Mar 2021 20:40:52 +0000 (16:40 -0400)]
cmd/compile: fix incoming ABI with GOEXPERIMENT=regabiargs

When regabiargs is enabled, a function's incoming ABI should be
determined solely by the function's own definition ABI (which is
usually ABIInternal, but can be ABI0 for ABI wrappers).

For example, the current code miscompiles ABI0 -> ABIInternal wrappers
when the experiment is enabled because it treats the wrapper itself as
being called as ABIInternal. This causes it to assume the incoming
arguments are already in registers, so usually the wrapper doesn't do
anything with the arguments because it thinks they're already in the
right place. With this fix, these wrappers now correctly load the
arguments from the stack and put them in registers.

For #40724.

Change-Id: Iec784e88ebc55d9e95e830ed7533aa336f3b1ca2
Reviewed-on: https://go-review.googlesource.com/c/go/+/306409
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/internal/obj/x86: use ABI scratch registers for WRAPPER prologue
Michael Anthony Knyszek [Fri, 19 Mar 2021 20:04:38 +0000 (20:04 +0000)]
cmd/internal/obj/x86: use ABI scratch registers for WRAPPER prologue

Currently the prologue generated for WRAPPER assembly functions uses BX
and DI, but these are argument registers in the register-based calling
convention. Thus, these end up being clobbered when we want to have an
ABIInternal assembly function.

Define REGENTRYTMP0 and REGENTRYTMP1, aliases for the dedicated function
entry scratch registers R12 and R13, and use those instead.

For #40724.

Change-Id: Ica78c4ccc67a757359900a66b56ef28c83d88b3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/303314
Trust: Michael Knyszek <mknyszek@google.com>
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 agocmd/compile: deduplicate OpArg's across types
Cherry Zhang [Wed, 31 Mar 2021 16:41:20 +0000 (12:41 -0400)]
cmd/compile: deduplicate OpArg's across types

For in-register arguments, it must have only a single copy of it
present in the function. If there are multiple copies, it confuses
the register allocator, as they are in the same register.

Change-Id: I55cb06746f08aa7c9168026d0f411bce0a9f93f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/306330
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agogo/parser: switch to resolving objects as a post-processing pass
Rob Findley [Wed, 24 Mar 2021 13:36:04 +0000 (09:36 -0400)]
go/parser: switch to resolving objects as a post-processing pass

Coupling object resolution to parsing complicates the parsing code, and
is a barrier to improvement. It requires passing around context such as
'lhs' or 'keyOk', and even then sometimes requires guess-work, such as
whether to resolve the key in a composite literal.

In this CL we delay object resolution to a separate pass after the file
parse completes. This makes it easier to see logic of scoping, and
removes state from the parsing code. This can enable subsequent
improvements such as optionally skipping object resolution, aligning the
parser with cmd/compile/internal/syntax, and allowing alternative
parsers to reuse object resolution.

The additional AST traversal appears to slow down parsing by around 4%.
That seems small enough not to worry about, especially since performance
sensitive users may eventually be able to disable object resolution
entirely, saving around 18% off the previous baseline. I'll also mail a
speculative CL showing how we can significantly mitigate the cost of
object resolution by transposing scopes.

For #45104

Change-Id: I98d9143fd77ae29e84ec7c3ae2fdb1139510da37
Reviewed-on: https://go-review.googlesource.com/c/go/+/304455
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 agoruntime: support register ABI Go functions from Windows callbacks
Michael Anthony Knyszek [Tue, 9 Mar 2021 21:13:34 +0000 (21:13 +0000)]
runtime: support register ABI Go functions from Windows callbacks

This change modifies the system that allows Go functions to be set as
callbacks in various Windows systems to support the new register ABI.

For #40724.

Change-Id: Ie067f9e8a76c96d56177d7aa88f89cbe7223e12e
Reviewed-on: https://go-review.googlesource.com/c/go/+/300113
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@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: schedule in-register OpArg first
Cherry Zhang [Wed, 31 Mar 2021 14:27:06 +0000 (10:27 -0400)]
cmd/compile: schedule in-register OpArg first

OpArgXXXReg values must be scheduled at the very top, as their
registers need to be live at the beginning before any other use
of the register.

Change-Id: Ic76768bb74da402adbe61db3b2d174ecd3f9fffc
Reviewed-on: https://go-review.googlesource.com/c/go/+/306329
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/go/internal/load/test: parse overlay files for test functions
Kevin Herro [Fri, 26 Mar 2021 15:58:11 +0000 (08:58 -0700)]
cmd/go/internal/load/test: parse overlay files for test functions

The existing implementation implicitly reads from the filesystem
instead of using the overlay file data (due to src == nil), so
pass in the overlaid source if we have an overlay for this file.

Fixes #44946

Change-Id: I61ce09d10c5edac1b47332583efdcd3c1241f58a
Reviewed-on: https://go-review.googlesource.com/c/go/+/305071
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: make expandCalls preserve types of pointer stores
David Chase [Tue, 30 Mar 2021 00:14:51 +0000 (20:14 -0400)]
cmd/compile: make expandCalls preserve types of pointer stores

This is accomplished by checking for simple stores of pointer types
and leaving them alone.  The failure case was when a *mspan
(not in heap) stored type was replaced by unsafe.Pointer.

Updates #40724.

Change-Id: I529e1705bf58fb0e64e60d48fd550b3a407e57e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/305672
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: replace reflectcall of defers with direct call
Austin Clements [Tue, 30 Mar 2021 21:55:22 +0000 (17:55 -0400)]
runtime: replace reflectcall of defers with direct call

With GOEXPERIMENT=regabidefer, all deferred functions take no
arguments and have no results (their signature is always func()).
Since the signature is fixed, we can replace all of the reflectcalls
in the defer code with direct closure calls.

For #40724.

Change-Id: I3acd6742fe665610608a004c675f473b9d0e65ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/306010
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile/internal/types2: review of operand.go
Robert Griesemer [Mon, 29 Mar 2021 19:14:58 +0000 (12:14 -0700)]
cmd/compile/internal/types2: review of operand.go

The changes between (equivalent, and reviewed) go/types/operand.go
and operand.go can be seen by comparing patchset 1 and 2. The actual
changes are removing the "// UNREVIEWED" marker.

The primary differences compared to go/types are:
- use of syntax rather than go/ast package
- explicit mode for untyped nil (rather than relying on the type)

Change-Id: I0c9c1c6153c55cb0550096bd966c9f0f1c766734
Reviewed-on: https://go-review.googlesource.com/c/go/+/305571
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile/internal/types2: review of decl.go
Robert Griesemer [Mon, 29 Mar 2021 18:36:44 +0000 (11:36 -0700)]
cmd/compile/internal/types2: review of decl.go

The changes between (equivalent, and reviewed) go/types/decl.go
and decl.go can be seen by comparing patchset 1 and 2. The actual
changes are removing the "// UNREVIEWED" marker and a minor comment
update.

The primary differences to go/types/decl.go are:
- use of syntax rather than go/ast package
- use of error_ objects to collect follow-on error info
- use of check.conf.Trace rather than global trace flag
- more aggressively marking variables as used in the presence errors
- not using a walkDecl abstraction for const/var/type declarations

Change-Id: I5cf26779c9939b686a3dbaa4d38fdd0c154a92ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/305570
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agoruntime: check for sysAlloc failures in pageAlloc
Ian Lance Taylor [Tue, 30 Mar 2021 19:21:20 +0000 (12:21 -0700)]
runtime: check for sysAlloc failures in pageAlloc

Change-Id: I78c5744bb01988f1f599569703d83fd21542ac7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/305911
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 agonet/http: use consistent case in URL in names
徐志伟 [Tue, 30 Mar 2021 23:25:56 +0000 (23:25 +0000)]
net/http: use consistent case in URL in names

Change-Id: Iff5074713e1a4484c04b8628fb2611b6d4e154c7
GitHub-Last-Rev: bb0861bbbe31bc2bbda667c05402b5ef886a762b
GitHub-Pull-Request: golang/go#45294
Reviewed-on: https://go-review.googlesource.com/c/go/+/305772
Reviewed-by: Ben Shi <powerman1st@163.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agogo/parser: remove redundant list argument to Parser.shortVarDecl
Rob Findley [Tue, 23 Mar 2021 02:31:28 +0000 (22:31 -0400)]
go/parser: remove redundant list argument to Parser.shortVarDecl

Change-Id: I75d089a7c1c3cdd50e5d2dafdb3386620efff4c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/304454
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/parser: add resolution tests for type params
Rob Findley [Wed, 24 Mar 2021 21:36:40 +0000 (17:36 -0400)]
go/parser: add resolution tests for type params

For #45104
For #45221

Change-Id: I8966555f4e8844d5b6766d00d48f7a81868ccf40
Reviewed-on: https://go-review.googlesource.com/c/go/+/304453
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: deal with call.Use correctly for noder2, allow inlining of stenciled...
Dan Scales [Tue, 30 Mar 2021 23:03:26 +0000 (16:03 -0700)]
cmd/compile: deal with call.Use correctly for noder2, allow inlining of stenciled functions

The setting of n.Use for a call node in transformCall() (and previously
in Call()), was not corrrect, since it was trying to use the number of
results of the call, rather than whether the call result was actually
used. We are already setting n.Use to ir.CallUseStmt if the call node is
directly a statement, so we just need to initialize n.Use to
ir.CallExprStmt in Call(), which will get changed to ir.CallUseStmt at
the statement level if it's used as a statement.

Enable inlining of stenciled functions (just disabled for testing,
easier debugging). The above n.Use fix was required for the inlining
to work for two cases.

Change-Id: Ie4ef6cd53fd4b20a4f3be31e629280909a545b7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/305913
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/compile: deal correctly with unnamed function params during stenciling
Dan Scales [Tue, 30 Mar 2021 20:42:14 +0000 (13:42 -0700)]
cmd/compile: deal correctly with unnamed function params during stenciling

During substitution of the function type during stenciling, we must set
the Name nodes of the param/result fields of the func type. We get those
name nodes from the substituted Dcl nodes of the PPARAMS and PPARAMOUTs.
But we must check that the names match with the Dcl nodes, so that we
skip any param fields that correspond to unnamed (in) parameters.

Added a few tests to typelist.go by removing a variety of unneeded
function parameter names.

Change-Id: If786961b64549da6f18eeeb5060ea58fab874eb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/305912
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agogo/ast: add missing handling for ListExpr in Walk
Rob Findley [Wed, 24 Mar 2021 12:51:44 +0000 (08:51 -0400)]
go/ast: add missing handling for ListExpr in Walk

Change-Id: I96170f1ca481b5fe21c85f99e877fa090e4dccc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/304452
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/parser: resolve the type name when parsing a composite lit value
Rob Findley [Tue, 23 Mar 2021 02:27:25 +0000 (22:27 -0400)]
go/parser: resolve the type name when parsing a composite lit value

parsePrimaryExpr has to be careful to resolve identifiers used in
composite expressions when parsing in LHS mode. It missed the literal
type name.

Fixes #45136

Change-Id: I3e12f91e3ef5fdb43faa436cdf1240eb3293fe1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/304451
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/parser: add data-driven tests for object resolution
Rob Findley [Tue, 23 Mar 2021 02:10:13 +0000 (22:10 -0400)]
go/parser: add data-driven tests for object resolution

Add new tests for object resolution driven by source files with
declarations and uses marked via special comments. This made it easier
to add test coverage while refactoring object resolution for #45104.

Tests are added to a new resolver_test.go file. In a subsequent CL the
resolver.go file will be added, making this choice of file name more
sensible.

For #45104
For #45136
For #45160

Change-Id: I240fccc0de95aa8f2d03e39c77146d4c61f1ef9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/304450
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: avoid generating duplicated in-register Arg
Cherry Zhang [Tue, 30 Mar 2021 20:28:48 +0000 (16:28 -0400)]
cmd/compile: avoid generating duplicated in-register Arg

In expand_calls, when rewriting OpArg to OpArgIntReg/OpArgFloatReg,
avoid generating duplicates. Otherwise it will confuse the
register allocator: it would think the second occurance clobbers
the first's register, causing it to generate copies, which may
clobber other args.

Change-Id: I4f1dc0519afb77500eae1c0e6ac8745e51f7aa4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/306029
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
4 years agoruntime: fix G passed to schedEnabled and cleanup
Michael Pratt [Thu, 11 Feb 2021 15:44:34 +0000 (10:44 -0500)]
runtime: fix G passed to schedEnabled and cleanup

exitsyscall0 contains two G variables: _g_ and gp. _g_ is the active G,
g0, while gp is the G to run (which just exited from a syscall).

It is passing _g_ to schedEnabled, which is incorrect; we are about to
execute gp, so that is what we should be checking the schedulability of.

While this is incorrect and should be fixed, I don't think it has ever
caused a problem in practice:

 * g0 does not have g.startpc set, so schedEnabled simplifies to
   just !sched.disable.user.
 * This is correct provided gp is never a system goroutine.
 * As far as I know, system goroutines never use entersyscall /
   exitsyscall.

As far I can tell, this was a simple copy/paste error from exitsyscall,
where variable _g_ is the G to run.

While we are here, eliminate _g_ entirely, as the one other use is
identical to using gp.

Change-Id: I5df98a34569238b89ab13ff7012cd756fefb10dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/291329
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agoruntime: check that defer/go frames are empty
Austin Clements [Tue, 30 Mar 2021 18:45:00 +0000 (14:45 -0400)]
runtime: check that defer/go frames are empty

With GOEXPERIMENT=regabidefer, these frames should always be empty.
Check that.

For #40724.

Change-Id: Id8e418a9e06b4f94543cb16b868a7e10e013c2d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/306009
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: handle partial type inference that doesn't require function args
Dan Scales [Mon, 29 Mar 2021 23:07:18 +0000 (16:07 -0700)]
cmd/compile: handle partial type inference that doesn't require function args

Handle the case where types can be partially inferred for an
instantiated function that is not immediately called. The key for the
Inferred map is the CallExpr (if inferring types required the function
arguments) or the IndexExpr (if types could be inferred without the
function arguments).

Added new tests for the case where the function isn't immediately called
to typelist.go.

Change-Id: I60f503ad67cd192da2f2002060229efd4930dc39
Reviewed-on: https://go-review.googlesource.com/c/go/+/305909
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: make amd64 version of zerorange regabi-friendly
Than McIntosh [Tue, 30 Mar 2021 12:49:42 +0000 (08:49 -0400)]
cmd/compile: make amd64 version of zerorange regabi-friendly

Change the amd64 version of 'zerorange' to avoid using RAX/RDI, since
it can be called in a context when one of these registers is live
(contains an incoming parameter).

Updates #40724.

Change-Id: Ibfa2b4e156b876354d4f8bd04eb8773c7056d948
Reviewed-on: https://go-review.googlesource.com/c/go/+/305829
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
4 years agogo/doc: avoid panic on references to functions with no body
Norman B. Lancaster [Tue, 30 Mar 2021 17:30:45 +0000 (17:30 +0000)]
go/doc: avoid panic on references to functions with no body

This change guards a call to ast.Inspect with a nil check on the first
argument. This avoids a panic when inspecting a reference to a function
with a nil body. This can only happen when a function body is defined outside Go.

Fixes #42706

Change-Id: I91bc607b24b6224920c24cfd07e76ce7737a98d4
GitHub-Last-Rev: 08072b9ce5c1fd4ee77eba6f1acc0a84e838ad7b
GitHub-Pull-Request: golang/go#43011
Reviewed-on: https://go-review.googlesource.com/c/go/+/275516
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoreflect: cache IsVariadic calls in Call
Ignacio Hagopian [Tue, 30 Mar 2021 17:18:06 +0000 (17:18 +0000)]
reflect: cache IsVariadic calls in Call

These calls are cacheable, so do that to avoid doing extra work.

This opportunity was discovered while taking a look at a CPU profile
while investigating #7818.

I added a BenchmarkCallMethod, which is similar to BechmarkCall but
for a method receiver.

Benchmark results, including the new BenchmarkCallMethod:

name                       old time/op    new time/op    delta
Call-16                      22.0ns ±19%    20.2ns ±17%  -8.08%  (p=0.000 n=40+40)
CallMethod-16                 100ns ± 3%      91ns ± 2%  -9.13%  (p=0.000 n=40+39)
CallArgCopy/size=128-16      15.7ns ± 1%    14.3ns ± 4%  -8.98%  (p=0.000 n=38+37)
CallArgCopy/size=256-16      15.9ns ± 3%    15.0ns ± 5%  -6.12%  (p=0.000 n=39+39)
CallArgCopy/size=1024-16     18.8ns ± 6%    17.1ns ± 6%  -9.03%  (p=0.000 n=38+38)
CallArgCopy/size=4096-16     26.6ns ± 3%    25.2ns ± 4%  -5.19%  (p=0.000 n=39+40)
CallArgCopy/size=65536-16     379ns ± 3%     371ns ± 5%  -2.11%  (p=0.000 n=39+40)

name                       old alloc/op   new alloc/op   delta
Call-16                       0.00B          0.00B         ~     (all equal)
CallMethod-16                 0.00B          0.00B         ~     (all equal)

name                       old allocs/op  new allocs/op  delta
Call-16                        0.00           0.00         ~     (all equal)
CallMethod-16                  0.00           0.00         ~     (all equal)

name                       old speed      new speed      delta
CallArgCopy/size=128-16    8.13GB/s ± 1%  8.92GB/s ± 4%  +9.77%  (p=0.000 n=38+38)
CallArgCopy/size=256-16    16.1GB/s ± 3%  17.1GB/s ± 5%  +6.56%  (p=0.000 n=39+39)
CallArgCopy/size=1024-16   54.6GB/s ± 6%  60.1GB/s ± 5%  +9.93%  (p=0.000 n=38+38)
CallArgCopy/size=4096-16    154GB/s ± 5%   163GB/s ± 4%  +5.63%  (p=0.000 n=40+40)
CallArgCopy/size=65536-16   173GB/s ± 3%   177GB/s ± 5%  +2.18%  (p=0.000 n=39+40)

Updates #7818.

Change-Id: I94f88811ea9faf3dc2543984a13b360b5db66a4b
GitHub-Last-Rev: 9bbaa1854aa32cade905eddb05737e6224c372a1
GitHub-Pull-Request: golang/go#43475
Reviewed-on: https://go-review.googlesource.com/c/go/+/281252
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/go: fix documentation on how to create new go.mod file
Shulhan [Sun, 28 Mar 2021 16:04:33 +0000 (23:04 +0700)]
cmd/go: fix documentation on how to create new go.mod file

The correct command to create new go.mod file should be 'go mod init',
not 'go help init'.

Change-Id: I1150621987d989997f8b75e6a13fe96423a11cf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/305289
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: emit writebarriers in specified ABI
David Chase [Mon, 29 Mar 2021 22:46:37 +0000 (18:46 -0400)]
cmd/compile: emit writebarriers in specified ABI

old code was always ABI0, new code tracks the default
this may cause some write barrier removals to fail to fire

Updates #40724.

Change-Id: I656bdd5511c5bd6ee6e021999e30d842a6b9f0a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/305671
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile/internal/noder: limit the number of goroutine
hqpko [Tue, 30 Mar 2021 14:53:24 +0000 (14:53 +0000)]
cmd/compile/internal/noder: limit the number of goroutine

Change-Id: I7f05108fea351a4895dde6090bf86beb822f2c28
GitHub-Last-Rev: e4a2d3a11aa258f2ddf5e39ab4769883f94e3dab
GitHub-Pull-Request: golang/go#45289
Reviewed-on: https://go-review.googlesource.com/c/go/+/305869
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime: non-strict InlTreeIndex lookup in Frames.Next
Michael Pratt [Thu, 11 Mar 2021 17:28:45 +0000 (12:28 -0500)]
runtime: non-strict InlTreeIndex lookup in Frames.Next

When using cgo, some of the frames can be provided by cgoTraceback, a
cgo-provided function to generate C tracebacks. Unlike Go tracebacks,
cgoTraceback has no particular guarantees that it produces valid
tracebacks.

If one of the (invalid) frames happens to put the PC in the alignment
region at the end of a function (filled with int 3's on amd64), then
Frames.Next will find a valid funcInfo for the PC, but pcdatavalue will
panic because PCDATA doesn't cover this PC.

Tolerate this case by doing a non-strict PCDATA lookup. We'll still show
a bogus frame, but at least avoid throwing.

Fixes #44971

Change-Id: I9eed728470d6f264179a7615bd19845c941db78c
Reviewed-on: https://go-review.googlesource.com/c/go/+/301369
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocrypto/elliptic: fix some typos
chenjie [Tue, 30 Mar 2021 07:23:53 +0000 (07:23 +0000)]
crypto/elliptic: fix some typos

Change-Id: I1c2900d4e1c0b6108f13c4060d994d966f3e18f3
GitHub-Last-Rev: 3fde453686ab3fdeb77d2f73c09e4a679056adf3
GitHub-Pull-Request: golang/go#45295
Reviewed-on: https://go-review.googlesource.com/c/go/+/305773
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ben Shi <powerman1st@163.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: fix creation of named generic types (setting of t.nod)
Dan Scales [Wed, 10 Mar 2021 23:25:21 +0000 (15:25 -0800)]
cmd/compile: fix creation of named generic types (setting of t.nod)

The correct setting of t.nod is needed when exporting types. Make sure
we create instantiated named types correctly so t.nod is set.

New test file interfacearg.go that tests this (by instantiating a type
with an interface). Also has tests for various kinds of method
expressions.

Change-Id: Ia7fd9debd495336b73788af9e35d72331bb7d2b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/305730
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agoruntime: fix typos in comments
Lizzzcai [Mon, 29 Mar 2021 10:51:06 +0000 (18:51 +0800)]
runtime: fix typos in comments

Change-Id: Ia70e8bdc6d2cf1195d7a3b5d33f180ae2db73e29
Reviewed-on: https://go-review.googlesource.com/c/go/+/305369
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ben Shi <powerman1st@163.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: update default ABI choices for calls and bodyless fn stack maps
David Chase [Wed, 24 Mar 2021 18:20:12 +0000 (14:20 -0400)]
cmd/compile: update default ABI choices for calls and bodyless fn stack maps

After recent discussion about bodyless functions, their wrappers,
their stack maps, nosplit, and callbacks, I was inspired to go and
be sure that more defaults were sensible.  This may not be all --
currently rtcall is "ABIDefault" which I think is correct, but I
am not 100% certain.

Updates #40724.

Change-Id: I95b14ee0e5952fa53e7fea9f6f5192358aa24f23
Reviewed-on: https://go-review.googlesource.com/c/go/+/304549
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile: fix various small bugs related to type lists
Dan Scales [Mon, 29 Mar 2021 15:28:01 +0000 (08:28 -0700)]
cmd/compile: fix various small bugs related to type lists

Fix various small bugs related to delaying transformations due to type
params. Most of these relate to the need to delay a transformation when
an argument of an expression or statement has a type parameter that has
a structural constraint. The structural constraint implies the operation
should work, but the transformation can't happen until the actual value
of the type parameter is known.

 - delay transformations for send statements and return statements if
   any args/values have type params.

 - similarly, delay transformation of a call where the function arg has
   type parameters. This is mainly important for the case where the
   function arg is a pure type parameter, but has a structural
   constraint that requires it to be a function. Move the setting of
   n.Use to transformCall(), since we may not know how many return
   values there are until then, if the function arg is a type parameter.

 - set the type of unary expressions from the type2 type (as we do with
   most other expressions), since that works better with expressions
   with type params.

 - deal with these delayed transformations in subster.node() and convert
   the CALL checks to a switch statement.

 - make sure ir.CurFunc is set properly during stenciling, including
   closures (needed for transforming return statements during
   stenciling).

New test file typelist.go with tests for these cases.

Change-Id: I1b82f949d8cec47d906429209e846f4ebc8ec85e
Reviewed-on: https://go-review.googlesource.com/c/go/+/305729
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>