1
0
mirror of https://github.com/golang/go synced 2024-11-17 21:04:43 -07:00
Commit Graph

47414 Commits

Author SHA1 Message Date
Cherry Zhang
0723f062ff cmd/compile: enable panic+recover adjustment for some ABI wrappers
For most ABI wrappers we don't need it because we're never going
to defer an ABI wrapper for a function that then recovers, so
that's would just be unnecessary code in the ABI wrapper.

However, for functions that could be on the path of invoking a
deferred function that can recover (runtime.reflectcall,
reflect.callReflect, and reflect.callMethod), we do want the
panic+recover adjustment. Set the Wrapper flag for them.

Currently, those functions are defined as ABIInternal to avoid
the ABI wrappers. But the assembly code still follows ABI0
calling convention, which would not work with the register-based
calling convention. In particlar, it is not possible to make
runtime.reflectcall ABIInternal, because it tail calls
runtime.callNN functions, which are splittable. Later CLs will
make them ABI0 and use the wrappers.

Updates #40724.

Change-Id: Ic7a45bbc6f726d29b5cb4932951a9d71578dcaf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/307236
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2021-04-05 22:38:48 +00:00
Filippo Valsorda
79b2e14b1a 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>
2021-04-05 20:53:42 +00:00
James Fennell
27015152ec 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: 0e12fe3045
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>
2021-04-05 20:39:06 +00:00
David Chase
ee40bb666b 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>
2021-04-05 20:11:08 +00:00
Jay Conrod
254fb85c12 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>
2021-04-05 20:05:34 +00:00
wolf1996
d5b9dc1317 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>
2021-04-05 19:29:17 +00:00
Ian Lance Taylor
e985245cd5 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>
2021-04-05 19:15:53 +00:00
Paul E. Murphy
a1a45afd4a 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>
2021-04-05 18:59:09 +00:00
Martin Sucha
a11244e95e 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>
2021-04-05 18:52:42 +00:00
Cherry Zhang
cf148f3d46 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>
2021-04-05 18:22:47 +00:00
KimMachineGun
a040ebeb98 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: dda42b09ff
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>
2021-04-05 17:51:15 +00:00
cui
9abedf4827 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: f68f9fecfb
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>
2021-04-05 17:42:13 +00:00
Cherry Zhang
5cc5576a9c 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>
2021-04-05 17:27:18 +00:00
Cherry Zhang
45e87cd3ec 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>
2021-04-05 17:25:15 +00:00
Cherry Zhang
411860251e 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>
2021-04-05 17:22:53 +00:00
Cherry Zhang
e617b2b0dd 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>
2021-04-05 17:22:26 +00:00
Cherry Zhang
dcf85b30ba 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>
2021-04-05 16:37:20 +00:00
Austin Clements
9e3328e740 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>
2021-04-05 16:22:19 +00:00
Austin Clements
191167c2b2 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>
2021-04-05 16:22:18 +00:00
Austin Clements
042f4cbb6f 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>
2021-04-05 16:22:17 +00:00
Austin Clements
a06b08e7d1 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>
2021-04-05 16:22:16 +00:00
Austin Clements
2b63404ddb 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>
2021-04-05 16:22:14 +00:00
Austin Clements
4702dd67a7 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>
2021-04-05 16:22:13 +00:00
Austin Clements
24dd8cfe23 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>
2021-04-05 16:22:12 +00:00
Austin Clements
ef3122e909 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>
2021-04-05 16:22:10 +00:00
Ruslan Andreev
af1789a61c 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>
2021-04-05 15:56:14 +00:00
Dan Scales
a4b8241d97 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>
2021-04-05 15:30:15 +00:00
Jay Conrod
6ed045b365 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>
2021-04-05 15:29:16 +00:00
Jay Conrod
ee51e3d895 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>
2021-04-05 15:29:05 +00:00
Tobias Klauser
4230a6ebdd 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>
2021-04-04 20:04:37 +00:00
Clément Chigot
7bfd681c2f 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>
2021-04-04 12:04:33 +00:00
ianwoolf
776d8d387c 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>
2021-04-04 00:01:03 +00:00
Tom Thorogood
9e7bc80b31 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>
2021-04-03 21:06:18 +00:00
Tom Thorogood
dac136f87b 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>
2021-04-03 20:16:00 +00:00
Drew Richardson
971c7154b0 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>
2021-04-03 20:14:37 +00:00
Dan Scales
6986c02d72 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>
2021-04-03 18:16:29 +00:00
Daniel Martí
fe587ce856 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>
2021-04-03 10:58:19 +00:00
Robert Griesemer
01821137c2 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>
2021-04-03 01:45:17 +00:00
Robert Griesemer
93dcaba119 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>
2021-04-03 01:45:13 +00:00
Robert Griesemer
a1e4657d5a 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>
2021-04-03 01:45:06 +00:00
Robert Griesemer
6454b2720f 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>
2021-04-03 01:45:04 +00:00
Austin Clements
2ebe77a2fd 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>
2021-04-02 21:59:37 +00:00
Carlo Alberto Ferraris
f25d78f8e2 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>
2021-04-02 21:57:58 +00:00
David Chase
35a8bbc9ea 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>
2021-04-02 20:26:12 +00:00
Michael Anthony Knyszek
41cf18eda7 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>
2021-04-02 19:45:52 +00:00
Michael Anthony Knyszek
34b87b4a1a 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>
2021-04-02 19:27:06 +00:00
David Chase
254948a50e 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>
2021-04-02 17:58:59 +00:00
Michael Anthony Knyszek
28c5fed557 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>
2021-04-02 16:53:18 +00:00
Cherry Zhang
6996bae5d1 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>
2021-04-02 16:31:47 +00:00
Cherry Zhang
759116b3ac 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>
2021-04-02 16:30:18 +00:00