]> Cypherpunks repositories - gostls13.git/log
gostls13.git
4 years agoreflect: fix typo in result-in-registers case
David Chase [Wed, 7 Apr 2021 21:03:46 +0000 (17:03 -0400)]
reflect: fix typo in result-in-registers case

t is the type of the function that was called
tv is the type of the result

This fixes the failures for
GOEXPERIMENT=regabi,regabiargs go test go test text/template
GOEXPERIMENT=regabi,regabiargs go test go test html/template

Updates #40724.

Change-Id: Ic9b02d72d18ff48c9de1209987cc39da619c2241
Reviewed-on: https://go-review.googlesource.com/c/go/+/308189
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agosync: update misleading comment in map.go about entry type
panchenglong01 [Thu, 8 Apr 2021 09:21:05 +0000 (09:21 +0000)]
sync: update misleading comment in map.go about entry type

As discussed in: https://github.com/golang/go/issues/45429,  about entry
type comments, it is possible for p == nil when m.dirty != nil, so
update the commemt about it.

Fixes #45429

Change-Id: I7ef96ee5b6948df9ac736481d177a59ab66d7d4d
GitHub-Last-Rev: 202c598a0ab98f4634cb56fe2486e8e82f9d991f
GitHub-Pull-Request: golang/go#45443
Reviewed-on: https://go-review.googlesource.com/c/go/+/308292
Reviewed-by: Changkun Ou <euryugasaki@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Trust: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime: replace os.MkdirTemp with T.TempDir
ianwoolf [Wed, 7 Apr 2021 12:16:58 +0000 (20:16 +0800)]
runtime: replace os.MkdirTemp with T.TempDir

Updates #45402

Change-Id: I3aa82fc2486b4de49b45388bbab24f5ffe558f91
Reviewed-on: https://go-review.googlesource.com/c/go/+/307989
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>

4 years agoRevert "cmd/compile/internal/noder: limit the number of goroutine"
Matthew Dempsky [Thu, 8 Apr 2021 05:48:34 +0000 (05:48 +0000)]
Revert "cmd/compile/internal/noder: limit the number of goroutine"

This reverts commit c274a7c03be7b69d54d3307b954f6a0eb298c860.

Reason for revert: this can cause a compiler deadlock, and there's
no demonstrable benefit to making the change.

Change-Id: I42325ddea68d37db16fd0061c5baaee112b755b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/308369
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/internal/objabi: clarify initialization of Experiments
Austin Clements [Tue, 6 Apr 2021 20:31:40 +0000 (16:31 -0400)]
cmd/internal/objabi: clarify initialization of Experiments

Currently objabi.Experiments is set via side-effect from an init
function, which makes their initialization process somewhat unclear
(indeed, I've messed this up before) and opens the possibility of
accessing them from another init function before it's initialized.

Originally, this init function set several variables, but at this
point it sets only objabi.Experiments, so switch to just using a
variable initializer to make the initialization process clear.

Change-Id: Id0d2ac76ae463824bbf37a9305e8643a275f1365
Reviewed-on: https://go-review.googlesource.com/c/go/+/307821
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agoruntime,cmd/link: include GOEXPERIMENTs in runtime.Version(), "go version X"
Austin Clements [Tue, 6 Apr 2021 21:04:52 +0000 (17:04 -0400)]
runtime,cmd/link: include GOEXPERIMENTs in runtime.Version(), "go version X"

This adds the set of GOEXPERIMENTs to the build version if it differs
from the default set of experiments. This exposes the experiment
settings via runtime.Version() and "go version <binary>".

Change-Id: I143dbbc50f66a4cf175469199974e18848075af6
Reviewed-on: https://go-review.googlesource.com/c/go/+/307820
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/internal/objabi: make GOEXPERIMENT be a diff from default experiments
Austin Clements [Tue, 6 Apr 2021 20:11:17 +0000 (16:11 -0400)]
cmd/internal/objabi: make GOEXPERIMENT be a diff from default experiments

Right now the rules around handling default-on experiments are
complicated and a bit inconsistent. Notably, objabi.GOEXPERIMENT is
set to a comma-separated list of enabled experiments, but this may not
be the string a user should set the GOEXPERIMENT environment variable
to get that list of experiments: if an experiment is enabled by
default but gets turned off by GOEXPERIMENT, then the string we report
needs to include "no"+experiment to capture that default override.

This complication also seeps into the version string we print for "go
tool compile -V", etc. This logic is further complicated by the fact
that it only wants to include an experiment string if the set of
experiments varies from the default.

This CL rethinks how we handle default-on experiments. Now that
experiment state is all captured in a struct, we can simplify a lot of
this logic. objabi.GOEXPERIMENT will be set based on the delta from
the default set of experiments, which reflects what a user would
actually need to pass on the command line. Likewise, we include this
delta in the "-V" output, which simplifies this logic because if
there's nothing to show in the version string, the delta will be
empty.

Change-Id: I7ed307329541fc2c9f90edd463fbaf8e0cc9e8ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/307819
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile,cmd/internal/objabi: abstract out object header string
Austin Clements [Wed, 7 Apr 2021 13:27:11 +0000 (09:27 -0400)]
cmd/compile,cmd/internal/objabi: abstract out object header string

Change-Id: Idbbb4cb7127b93afa34a8aa18bbdaad1f206ab6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/308090
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agointernal/goexperiment: consolidate experiment-enabled constants
Austin Clements [Tue, 6 Apr 2021 17:35:48 +0000 (13:35 -0400)]
internal/goexperiment: consolidate experiment-enabled constants

Currently, we have boolean and integral constants for GOEXPERIMENTs in
various places. Consolidate these into automatically generated
constants in the internal/goexperiment package.

Change-Id: I42a49aba2a3b4c722fedea23a613162cd8a67bee
Reviewed-on: https://go-review.googlesource.com/c/go/+/307818
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: Matthew Dempsky <mdempsky@google.com>
4 years agointernal/goexperiment,cmd: consolidate GOEXPERIMENTs into a new package
Austin Clements [Tue, 6 Apr 2021 12:25:01 +0000 (08:25 -0400)]
internal/goexperiment,cmd: consolidate GOEXPERIMENTs into a new package

Currently there's knowledge about the list of GOEXPERIMENTs in a few
different places. This CL introduces a new package and consolidates
the list into one place: the internal/goexperiment.Flags struct type.

This package gives us a central place to document the experiments as
well as the GOEXPERIMENT environment variable itself. It will also
give us a place to put built-time constants derived from the enabled
experiments.

Now the objabi package constructs experiment names by reflecting over
this struct type rather than having a separate list of these names
(this is similar to how the compiler handles command-line flags and
debug options). We also expose a better-typed API to the toolchain for
propagating enabled experiments.

Change-Id: I06e026712b59fe2bd7cd11a869aedb48ffe5a4b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/307817
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/asm,runtime: reduce spellings of GOEXPERIMENTs
Austin Clements [Tue, 6 Apr 2021 14:17:28 +0000 (10:17 -0400)]
cmd/asm,runtime: reduce spellings of GOEXPERIMENTs

Currently, the objabi.Experiment fields use Go-standard CamelCase, the
GOEXPERIMENT environment variable flags and build tags use all
lowercase, and the asm macros use upper-case with underscores.

This CL makes asm use the lowercase names for macros so there is one
less spelling, e.g., GOEXPERIMENT_regabiargs. This also makes them
consistent with the GOOS_* and GOARCH_* macros, which also use lower
case.

Change-Id: I305cd89af5e8cd1a89cc148746c034bcfd76db3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/307816
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agoruntime: drop haveexperiment, sys.GOEXPERIMENT
Austin Clements [Tue, 6 Apr 2021 12:28:17 +0000 (08:28 -0400)]
runtime: drop haveexperiment, sys.GOEXPERIMENT

We have ways to statically access experiments now, so we don't need a
relatively clunky string-parsing dynamic way to do it.

Change-Id: I5d75480916eef4bde2c30d5fe30593180da77ff2
Reviewed-on: https://go-review.googlesource.com/c/go/+/307815
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: Matthew Dempsky <mdempsky@google.com>
4 years agosyscall: replace os.MkdirTemp with T.TempDir
ianwoolf [Wed, 7 Apr 2021 14:32:56 +0000 (22:32 +0800)]
syscall: replace os.MkdirTemp with T.TempDir

Updates #45402

Change-Id: I573133d6b987e8ac23e3e2018652612af684c755
Reviewed-on: https://go-review.googlesource.com/c/go/+/307990
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
4 years agocmd/internal/obj: remove ppc64 msr support from MOV* insns
Paul E. Murphy [Tue, 9 Mar 2021 22:55:09 +0000 (16:55 -0600)]
cmd/internal/obj: remove ppc64 msr support from MOV* insns

These are privileged instructions, and thus will never work with
usermode code. I don't think there is a case where this isn't
true.  The motivation is to simplify handling of MOV* opcodes.

Assembler support for recognizing the MSR as a register is
retained.

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

4 years agoruntime/map: update comment for gc/reflect
Makdon [Wed, 7 Apr 2021 15:24:46 +0000 (15:24 +0000)]
runtime/map: update comment for gc/reflect

update comment cause gc/reflect.go has been moved to reflectdata/reflect.go

In the commit (attach below), gc/reflect.go is moved to reflectdata/reflect.go
So the  comment referring gc/reflect.go should be updated to reflectdata/reflect.go

There maybe other places that refers gc/reflect.go that should be updated.
I would work around it soon.

commit:
https://github.com/golang/go/commit/de65151e507e7b3c8e46d74f223d7c562177bedc
https://github.com/golang/go/commit/e4895ab4c0eb44de6ddc5dc8d860a827b20d2781

Change-Id: Ieed5c48049ffe6889c08e164972fc7825653ac05
GitHub-Last-Rev: eec9c2328d0be40842c3994f26f26f03fa650a91
GitHub-Pull-Request: golang/go#45421
Reviewed-on: https://go-review.googlesource.com/c/go/+/307930
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agocmd/compile/internal/types2: combine two loops (cleanup of TODO)
Robert Griesemer [Wed, 7 Apr 2021 05:46:57 +0000 (22:46 -0700)]
cmd/compile/internal/types2: combine two loops (cleanup of TODO)

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

Change-Id: I71b451382b6780101a0c94174ebe579e8a0684c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/307949
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/pack: use testing.T.TempDir in tests
Tobias Klauser [Wed, 7 Apr 2021 09:48:53 +0000 (11:48 +0200)]
cmd/pack: use testing.T.TempDir in tests

Change-Id: I7371259cf5d64f04698ae1477c3de1255664178d
Reviewed-on: https://go-review.googlesource.com/c/go/+/307969
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Than McIntosh <thanm@google.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: correct argument area size for typedmemmove/typedmemclr
Cherry Zhang [Wed, 7 Apr 2021 04:06:06 +0000 (00:06 -0400)]
cmd/compile: correct argument area size for typedmemmove/typedmemclr

When the write barrier pass emits typedmemmove/typedmemclr calls,
even the arguments are in registers, we still need to leave space
for the spill slots. Count that space. Otherwise when the callee
spills arguments it may clobber locals on the caller's frame.

Change-Id: I5326943427feaf66cab7658a5bef55b3baf5d345
Reviewed-on: https://go-review.googlesource.com/c/go/+/307824
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 agoembed, testing/fstest: small optimization for ReadDir
徐志伟 [Tue, 6 Apr 2021 04:56:32 +0000 (04:56 +0000)]
embed, testing/fstest: small optimization for ReadDir

Change-Id: If8dc6d917b55119b5662ce5b0b87328d220d684d
GitHub-Last-Rev: cc9a1d5a7e2599ee7f98c61d35b2450b9b6a92c3
GitHub-Pull-Request: golang/go#45388
Reviewed-on: https://go-review.googlesource.com/c/go/+/307250
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>

4 years agonet/http: replace os.MkdirTemp with T.TempDir
ianwoolf [Wed, 7 Apr 2021 05:42:22 +0000 (13:42 +0800)]
net/http: replace os.MkdirTemp with T.TempDir

Updates: #45402
Change-Id: Ia61f422d058bf57fc3688abc25597d6cc1692c51
Reviewed-on: https://go-review.googlesource.com/c/go/+/307653
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
4 years agocmd/compile/internal/syntax: add "~" operator
Robert Griesemer [Mon, 5 Apr 2021 23:52:25 +0000 (16:52 -0700)]
cmd/compile/internal/syntax: add "~" operator

Change-Id: I7991103d97b97260d9615b7f5baf7ec75ad87d1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/307370
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile/internal/types2: process errors in src order during testing
Robert Griesemer [Mon, 5 Apr 2021 23:06:18 +0000 (16:06 -0700)]
cmd/compile/internal/types2: process errors in src order during testing

Follow-up on https://golang.org/cl/305573.
As a consequence, re-enable test case that caused problems with that CL.

Change-Id: Ibffee3f016f4885a55b8e527a5680dd437322209
Reviewed-on: https://go-review.googlesource.com/c/go/+/307216
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile/internal/syntax, types2: move cmpPos to pos.Cmp
Robert Griesemer [Mon, 5 Apr 2021 22:48:32 +0000 (15:48 -0700)]
cmd/compile/internal/syntax, types2: move cmpPos to pos.Cmp

Make position comparison generally available.

Change-Id: I94b6f658fa19a15b30574dbb2181879115c131a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/307215
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile/internal/types2: remove Config.AcceptMethodTypeParams flag
Robert Griesemer [Mon, 5 Apr 2021 21:30:03 +0000 (14:30 -0700)]
cmd/compile/internal/types2: remove Config.AcceptMethodTypeParams flag

Type parameters for methods are not part of the accepted language,
but maintaining the code for type-checking them ensures regularity
of the type checker implementation. For now, keep the flag internally,
disabled by default. The flag is set when running tests.

Change-Id: Ic99934bd00bd2608dc1178e4131f46dd1507f0f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/307214
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile/internal/types2: remove Config.InferFromConstraints flag
Robert Griesemer [Fri, 2 Apr 2021 01:39:39 +0000 (18:39 -0700)]
cmd/compile/internal/types2: remove Config.InferFromConstraints flag

Constraint type inference is part of the proposed language.
Use an internal flag to control the feayure for debugging.

Change-Id: I7a9eaee92b5ffc23c25d9e68a729acc0d705e879
Reviewed-on: https://go-review.googlesource.com/c/go/+/306770
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile/internal/types2: combine all type inference in a single function
Robert Griesemer [Wed, 31 Mar 2021 00:16:53 +0000 (17:16 -0700)]
cmd/compile/internal/types2: combine all type inference in a single function

Rather than splitting up type inference into function argument
and constraint type inference, provide a single Checker.infer
that accepts type parameters, type arguments, value parameters,
and value arguments, if any. Checker.infer returns the completed
list of type arguments, or nil.

Updated (and simplified) call sites.

Change-Id: I9200a44b9c4ab7f2d21eed824abfffaab68ff766
Reviewed-on: https://go-review.googlesource.com/c/go/+/306170
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile: pre-spill pointers in aggregate-typed register args
David Chase [Tue, 6 Apr 2021 22:39:15 +0000 (18:39 -0400)]
cmd/compile: pre-spill pointers in aggregate-typed register args

There's a problem in liveness, where liveness of any
part of an aggregate keeps the whole aggregate alive,
but the not-live parts don't get spilled.  The GC
can observe those live-but-not-spilled slots, which
can contain junk.

A better fix is to change liveness to work
pointer-by-pointer, but that is also a riskier,
trickier fix.

To avoid this, in the case of

(1) an aggregate input parameter
(2) containing pointers
(3) passed in registers

pre-spill the pointers.

Updates #40724.

Change-Id: I6beb8e0a353b1ae3c68c16072f56698061922c04
Reviewed-on: https://go-review.googlesource.com/c/go/+/307909
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: fix bug of conditional instructions on arm64
eric fang [Tue, 6 Apr 2021 07:23:38 +0000 (07:23 +0000)]
cmd/compile: fix bug of conditional instructions on arm64

CL 302231 added some optimization rules with instructions CSETM, CSINC,
CSINV, and CSNEG, but did not deal with the situation where flag is
constant, resulting in some cases that could be more optimized cannot
be optimized, and the FlagConstant value is passed to codegen pass. This
CL adds these missing rules.

Fixes #45359

Change-Id: I700608cfb9a6a768a18d1fd5d374d7e92aa6f838
Reviewed-on: https://go-review.googlesource.com/c/go/+/307650
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: eric fang <eric.fang@arm.com>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

4 years agoruntime/cgo: add Handle for managing (c)go pointers
Changkun Ou [Tue, 23 Feb 2021 08:58:14 +0000 (09:58 +0100)]
runtime/cgo: add Handle for managing (c)go pointers

A non-trivial Cgo program may need to use callbacks and interact with
go objects per goroutine. Because of the rules for passing pointers
between Go and C, such a program needs to store handles to associated
Go values. This often causes much extra effort to figure out a way to
correctly deal with: 1) map collision; 2) identifying leaks and 3)
concurrency.

This CL implements a Handle representation in runtime/cgo package, and
related methods such as Value, Delete, etc. which allows Go users can
use a standard way to handle the above difficulties.

In addition, the CL allows a Go value to have multiple handles, and the
NewHandle always returns a different handle compare to the previously
returned handles. In comparison, CL 294670 implements a different
behavior of NewHandle that returns a unique handle when the Go value is
referring to the same object.

Benchmark:
name                      time/op
Handle/non-concurrent-16  487ns ± 1%
Handle/concurrent-16      674ns ± 1%

Fixes #37033

Change-Id: I0eadb9d44332fffef8fb567c745246a49dd6d4c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/295369
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 agoreflect: refactor funcLayout tests
Michael Anthony Knyszek [Tue, 6 Apr 2021 21:55:19 +0000 (21:55 +0000)]
reflect: refactor funcLayout tests

This change refactors the existing funcLayout tests and sets them up to
support the new register ABI by explicitly setting the register counts
to zero. This allows the test to pass if GOEXPERIMENT=regabiargs is set.

A follow-up change will add tests for a non-zero register count.

For #40724.

Change-Id: Ibbe061b4ed4fd70566eb38b9e6182dca32b81127
Reviewed-on: https://go-review.googlesource.com/c/go/+/307869
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: use register ABI for race detector functions
Cherry Zhang [Tue, 6 Apr 2021 00:26:11 +0000 (20:26 -0400)]
runtime: use register ABI for race detector functions

runtime.raceread/racewrite/racewriterange are functions that are
called from compiler instrumented code, follwoing ABIInternal.
They are assembly functions defined as ABIInternal in the runtime,
in order to avoid wrappers because they need to get the caller's
PC. This CL makes them to use the actual internal ABI.

Change-Id: Id91d73cf257f7b11a858958d85c38c4aa904d9c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/307812
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agopath/filepath: replace os.MkdirTemp with T.TempDir
ianwoolf [Tue, 6 Apr 2021 14:05:45 +0000 (22:05 +0800)]
path/filepath: replace os.MkdirTemp with T.TempDir

Change-Id: I6d78e0e742cb0e7f5ea3f430e9cec0f5d1ee03e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/307652
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
4 years agocmd/go/internal/modload: track conflicts in versionLimiter
Bryan C. Mills [Fri, 26 Mar 2021 04:44:30 +0000 (00:44 -0400)]
cmd/go/internal/modload: track conflicts in versionLimiter

This significantly simplifies the implementation of editRequirements
in preparation for making it lazy. It should have no effect on which
version combinations are rejected by 'go get', nor on which solutions
are found if downgrades are needed.

This change results in a small but observable change in error logging.
Before, we were reporting an error line for each argument that would
have exceeded its specified version, attributing it to one arbitrary
cause. Now, we are reporting an error line for each argument that
would cause any other argument to exceed its specified version. As a
result, if one argument would cause two others to exceed their
versions, we will now report one line instead of two; if two arguments
would independently cause one other to exceed its version, we will now
report two lines instead of one.

This change may result in a small performance improvement. Because we
are now scanning and rejecting incompatible requirements earlier, we
may waste less time computing upgrades and downgrades that ultimately
won't matter due to conflicting constraints.

For #36460

Change-Id: I125aa09b4be749dc5bacef23a859333991960e85
Reviewed-on: https://go-review.googlesource.com/c/go/+/305009
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd/compile: check for unused OpArg* and mark invalid (again)
David Chase [Tue, 6 Apr 2021 02:20:41 +0000 (22:20 -0400)]
cmd/compile: check for unused OpArg* and mark invalid (again)

This caused a problem with

GOEXPERIMENT=regabi,regabiargs go test -c  crypto/x509

Updates #40724.

Change-Id: Ia3cdbe9968816c77836cb3e3ba89642aafd1b18d
Reviewed-on: https://go-review.googlesource.com/c/go/+/307529
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: load results into registers on open defer return path
Cherry Zhang [Sun, 4 Apr 2021 00:09:15 +0000 (20:09 -0400)]
cmd/compile: load results into registers on open defer return path

When a function panics then recovers, it needs to return to the
caller with named results having the correct values. For
in-register results, we need to load them into registers at the
defer return path.

For non-open-coded defers, we already generate correct code, as
the defer return path is part of the SSA CFG and contains the
instructions that are the same as an ordinary return statement,
including putting the results to the right places.

For open-coded defers, we have a special code generation that
emits a disconnected block that currently contains only the
deferreturn call and a RET instruction. It leaves the result
registers unset. This CL adds instructions that load the result
registers on that path.

Updates #40724.

Change-Id: I1f60514da644fd5fb4b4871a1153c62f42927282
Reviewed-on: https://go-review.googlesource.com/c/go/+/307231
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agoruntime: deflake TestGCTestIsReachable
Austin Clements [Tue, 6 Apr 2021 18:55:46 +0000 (14:55 -0400)]
runtime: deflake TestGCTestIsReachable

This is a simple workaround for a bug where runtime.GC() can return
before finishing a full sweep, causing gcTestIsReachable to throw. The
right thing is to fix runtime.GC(), but this should get this test
passing reliably in the meantime.

Updates #45315.

Change-Id: Iae141e6dbb26a9c2649497c1feedd4aaeaf540c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/307809
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 agotime: properly quote strings containing quotes and backslashes
Ahmet Aktürk [Mon, 5 Apr 2021 19:05:05 +0000 (22:05 +0300)]
time: properly quote strings containing quotes and backslashes

Fixes #45391

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

4 years agocmd/go/internal/modload: factor out a method to update loader requirements
Bryan C. Mills [Thu, 25 Mar 2021 03:31:32 +0000 (23:31 -0400)]
cmd/go/internal/modload: factor out a method to update loader requirements

For #36460

Change-Id: Idb0b333a28d2470bc9482fe1829ccb6ddf8abd34
Reviewed-on: https://go-review.googlesource.com/c/go/+/304909
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd/compile/internal/types2: simplify Checker.Call
Robert Griesemer [Wed, 31 Mar 2021 06:12:48 +0000 (23:12 -0700)]
cmd/compile/internal/types2: simplify Checker.Call

Now that we use square brackets for instantiations, we
can tell type arguments from ordinary arguments without
"guessing" which permits a simpler implementation.

Specifically, replace use of Checker.exprOrTypeList with
Checker.exprList, and delete Checker.exprOrTypeList and
Checker.multiExprOrType.

Disable a test for an (esoteric) failure due to an
unrelated problem with error matching when running
the test.

Change-Id: I17f18fffc32f03fa90d93a68ebf56e5f2fcc9dab
Reviewed-on: https://go-review.googlesource.com/c/go/+/306171
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile/internal/types2: simplify Checker.funcInst
Robert Griesemer [Wed, 31 Mar 2021 05:07:26 +0000 (22:07 -0700)]
cmd/compile/internal/types2: simplify Checker.funcInst

Now that we use square brackets for instantiations, we
can tell type arguments from ordinary arguments without
"guessing" which permits a simpler implementation.

While at it, also fix a minor position error for type
instantiations (now matching the code for function
instantiations).

Change-Id: I20eca51c5b06259703767b5906e89197d6cd595a
Reviewed-on: https://go-review.googlesource.com/c/go/+/306169
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile/internal/types2: review of pos.go and move into syntax package
Robert Griesemer [Mon, 29 Mar 2021 22:15:56 +0000 (15:15 -0700)]
cmd/compile/internal/types2: review of pos.go and move into syntax package

This moves the two helper functions startPos and endPos into
the syntax package where they belong. Export the functions and
adjust dependent code.

Change-Id: I8170faeadd7cfa8f53009f81fcffd50ec0fc6a98
Reviewed-on: https://go-review.googlesource.com/c/go/+/305578
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agotest/syntax: remove interface.go
Robert Griesemer [Tue, 6 Apr 2021 18:36:36 +0000 (11:36 -0700)]
test/syntax: remove interface.go

The exact same test case covered by this file is also in
fixedbugs/bug121.go. No need for duplication.

Also, the actual syntax error tested (multiple method names
with a single signature) is an unlikely syntax error, and
only here for historical reasons (in the very beginning, this
was actually possible to write). Now, virtually nobody is making
this mistake.

Change-Id: I9d68e0aee2a63025f44e6338647f8250ecc3077a
Reviewed-on: https://go-review.googlesource.com/c/go/+/307789
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoruntime/pprof: deflake TestMorestack
Cherry Zhang [Tue, 6 Apr 2021 14:23:48 +0000 (10:23 -0400)]
runtime/pprof: deflake TestMorestack

In TestMorestack, on macOS, for some reason it got most of the
samples in synchronization (e.g. pthread_cond_signal and
pthread_cond_wait) and sometimes in other "syscalls" (usleep,
nanotime1), and very few samples in stack copying, sometimes 0,
which causes the test to fail. Maybe synchronization is slower on
macOS? (It doesn't seem so to me.) Or it is the OS's accounting
problem, where it is more likely to trigger a profiling signal
at a syscall (or certain kinds of syscalls)?

As the test is really about whether it can connect stack copying
with the function that grows the stack, this CL makes it spend
more time in copying stack than synchronization. Now it's getting
~100 samples for stack copying on a 5 second interval on my
machine, and the test passes reliably.

Fixes #44418.

Change-Id: I3a462c8c39766f2d67d697598f8641bbe64f16ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/307730
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 years agocmd/compile: when GOSSAFUNC is set, dump the current pass on crash
Cherry Zhang [Tue, 6 Apr 2021 00:41:56 +0000 (20:41 -0400)]
cmd/compile: when GOSSAFUNC is set, dump the current pass on crash

When an SSA pass ICEs, it calls f.Fatalf, which terminates the
compiler. When GOSSAFUNC is set, the current pass is not written
to ssa.html. This CL makes it write ssa.html when it calls Fatalf,
for the ease of debugging.

Change-Id: I5d55e4258f0693d89c48c0a84984f2f893b0811d
Reviewed-on: https://go-review.googlesource.com/c/go/+/307509
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 agocmd/internal/obj: reorg ppc64 MOV* optab entries and remove unused classes
Paul E. Murphy [Tue, 9 Mar 2021 22:55:08 +0000 (16:55 -0600)]
cmd/internal/obj: reorg ppc64 MOV* optab entries and remove unused classes

C_LECON and C_SECON classifications are not generated on ppc64, however
there are many optab entries which match against them. Remove them to
resolve their related TODOs.

Likewise, reorder the optab entries for better readability.

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

4 years agocmd/compile: fix gcSizes.Sizeof for a zero-sized struct
Dan Scales [Tue, 6 Apr 2021 03:03:02 +0000 (20:03 -0700)]
cmd/compile: fix gcSizes.Sizeof for a zero-sized struct

(*gcSizes).Sizeof was requiring the last field of a zero-sized struct to
be at least one byte. But that rule (fix for #9401, see logic in
calcStructOffset) only applies to a struct that has some non-zero sized
fields. Fix (*gcSizes).Sizeof to have the logic like calcStructOffset.

Fixes running the gotests with -G=3 enabled.

Fixes #45390

Change-Id: I011f40e3de3a327392bbbb791b9422be75336313
Reviewed-on: https://go-review.googlesource.com/c/go/+/307549
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>

4 years agocmd/compile/internal/typecheck: call tcConv directly
cui [Tue, 6 Apr 2021 03:26:35 +0000 (03:26 +0000)]
cmd/compile/internal/typecheck: call tcConv directly

Change-Id: I9f71acfa93c47cff620b006918872ecd90bbebe9
GitHub-Last-Rev: 2fed2e23054d75f7a743f9c5a6e5574a545e3080
GitHub-Pull-Request: golang/go#45366
Reviewed-on: https://go-review.googlesource.com/c/go/+/307109
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agoos: implement fs.StatFS for os.DirFS
Charlie Moog [Thu, 25 Mar 2021 00:17:03 +0000 (19:17 -0500)]
os: implement fs.StatFS for os.DirFS

Change-Id: I1d7382bf522aeda7148431b348f6ab9a162be097
Reviewed-on: https://go-review.googlesource.com/c/go/+/304531
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Robert Griesemer <gri@golang.org>

4 years agoruntime: make reflectcall ABI0 on amd64
Michael Anthony Knyszek [Fri, 2 Apr 2021 20:46:35 +0000 (20:46 +0000)]
runtime: make reflectcall ABI0 on amd64

reflectcall expects the ABI0 calling convention, but it's marked as
ABIInternal. When it gets called this way, naturally it doesn't work
very well.

For #40724.

Change-Id: Ic76237420cd8c72f5df1c1ac7972ad6f989f8402
Reviewed-on: https://go-review.googlesource.com/c/go/+/306931
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 agoruntime: use funcID to identify abort in isAbortPC
Michael Anthony Knyszek [Mon, 5 Apr 2021 19:13:34 +0000 (19:13 +0000)]
runtime: use funcID to identify abort in isAbortPC

This change eliminates the use of funcPC to determine if an PC is in
abort. Using funcPC for this purpose is problematic when using plugins
because symbols no longer have unique PCs. funcPC also grabs the wrapper
for runtime.abort which isn't what we want for the new register ABI, so
rather than mark runtime.abort as ABIInternal, use funcID.

For #40724.

Change-Id: I2730e99fe6f326d22d64a10384828b94f04d101a
Reviewed-on: https://go-review.googlesource.com/c/go/+/307391
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>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/compile: fix for zerorange on plan9-amd64
Than McIntosh [Mon, 5 Apr 2021 20:50:38 +0000 (16:50 -0400)]
cmd/compile: fix for zerorange on plan9-amd64

In CL 305829 a problematic change was made to the compiler's
amd64-specific "zerorange" function. In zerorange the compiler uses
different sets of strategies depending on the size of the stack frame
it needs to zero; turns out that only on plan9-amd64 was it hitting
the final fallback strategy, which is a REPSTOSQ instruction. REPSTOSQ
takes RAX as an input, hence the changes made in CL 305829 (switching
to R13) were incorrect.

This patch restores the zerorange REPSTOSQ sequence (back to use RAX).
This is going to be an interim solution, since long term we need to
avoid touching RAX in the function prolog (since if the new register
ABI is in effect, it will hold a live value).

Fixes #45372.

Change-Id: Ic89a6a2a76d6e03b9fbda99275101e96b70fdf5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/307469
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoreflect: call ABI0 callReflect/callMethod
Cherry Zhang [Sun, 4 Apr 2021 16:10:32 +0000 (12:10 -0400)]
reflect: call ABI0 callReflect/callMethod

Currently the assembly code marshals arguments in ABI0 layout.
Call the ABI0 functions. We may want to move to ABIInternal at
some point (maybe when register args is always enabled).

Updates #40724.

Change-Id: I23bb3073f3f6420a8d0c119b65ae3e577578aadb
Reviewed-on: https://go-review.googlesource.com/c/go/+/307237
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/compile: enable panic+recover adjustment for some ABI wrappers
Cherry Zhang [Sun, 4 Apr 2021 16:59:49 +0000 (12:59 -0400)]
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>
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>