1
0
mirror of https://github.com/golang/go synced 2024-11-17 08:54:41 -07:00
Commit Graph

47569 Commits

Author SHA1 Message Date
Michael Anthony Knyszek
31d2556273 runtime: set up read-only dummy TLS space for needm on Windows
On Windows, TLS is uninitialized for C threads calling into Go code.
In this path, before calling into user Go code, we call into needm which
runs without an m, but whose purpose is to pick one up. While in Go
code, we may occasionally restore the G register from TLS for a number
of reasons. Rather than try to flag all these cases, given that needm
(and its callees) are already somewhat special, just set up a dummy TLS
space for it that's read-only. If it ever actually tries to write to
this space (it shouldn't), it will fail loudly. Otherwise, code that
restores the G register will simply load a zero value, but that's OK
since needm is careful never to require the G at any point, because it
doesn't yet have a valid G. Furthermore, by the time needm returns, it
will have set up TLS properly for a Windows C thread, so there's no need
to do anything extra afterwards.

For #40724.

Change-Id: I34e8095059817e4ee663505e89cda8785b634b98
Reviewed-on: https://go-review.googlesource.com/c/go/+/307872
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-08 16:37:24 +00:00
David Chase
283b02063b cmd/compile: sanitize before/after expansion OpSelectN references
In expand_calls, OpSelectN occurs both before and after the rewriting.
Attempting to rewrite a post-expansion OpSelectN is bad.
(The only ones rewritten in place are the ones returning mem;
others are synthesized to replace other selection chains with
register references.)

Updates #40724.
Updates #44816#issuecomment-815258897.

Change-Id: I7b6022cfb47f808d3ce6cc796c067245f36047f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/308309
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-08 15:03:31 +00:00
Austin Clements
1be8be4acc cmd/go: fix TestNewReleaseRebuildsStalePackagesInGOPATH
CL 307818 added a package that the runtime depends on, but didn't
update the list of runtime dependencies in this test.

This should fix the longtest builder failures.

Change-Id: I5f3be31b069652e05ac3db9b1ce84dd5dfe0f66f
Reviewed-on: https://go-review.googlesource.com/c/go/+/308469
Trust: Austin Clements <austin@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-08 15:02:51 +00:00
David Chase
912c4e29d3 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>
2021-04-08 14:23:47 +00:00
panchenglong01
1749f3915e 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: 202c598a0a
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>
2021-04-08 14:08:29 +00:00
ianwoolf
a7e16abb22 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>
2021-04-08 07:33:58 +00:00
Matthew Dempsky
2123dfba65 Revert "cmd/compile/internal/noder: limit the number of goroutine"
This reverts commit c274a7c03b.

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>
2021-04-08 06:08:49 +00:00
Austin Clements
8752454ece 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>
2021-04-08 02:17:23 +00:00
Austin Clements
5159c83641 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>
2021-04-08 02:17:22 +00:00
Austin Clements
a8e55538af 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>
2021-04-08 02:17:20 +00:00
Austin Clements
89ca1ce9a8 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>
2021-04-08 02:17:19 +00:00
Austin Clements
b675e52e95 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>
2021-04-08 02:17:18 +00:00
Austin Clements
6304b401e4 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>
2021-04-08 02:17:16 +00:00
Austin Clements
0c4a08cb74 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>
2021-04-08 02:17:15 +00:00
Austin Clements
aeaa4519b5 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>
2021-04-08 02:17:13 +00:00
ianwoolf
f60aa7a18c 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>
2021-04-07 23:00:58 +00:00
Paul E. Murphy
fca51ba24a 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>
2021-04-07 20:23:47 +00:00
Makdon
e306d06063 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:
de65151e50
e4895ab4c0

Change-Id: Ieed5c48049ffe6889c08e164972fc7825653ac05
GitHub-Last-Rev: eec9c2328d
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>
2021-04-07 18:44:30 +00:00
Robert Griesemer
b3064b66d0 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>
2021-04-07 16:57:40 +00:00
Tobias Klauser
4520da486b 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>
2021-04-07 13:24:10 +00:00
Cherry Zhang
b55d900529 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>
2021-04-07 13:14:57 +00:00
徐志伟
d6aa162f30 embed, testing/fstest: small optimization for ReadDir
Change-Id: If8dc6d917b55119b5662ce5b0b87328d220d684d
GitHub-Last-Rev: cc9a1d5a7e
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>
2021-04-07 09:59:58 +00:00
ianwoolf
5d5f779db4 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>
2021-04-07 06:53:34 +00:00
Robert Griesemer
4bbe046aad 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>
2021-04-07 05:19:41 +00:00
Robert Griesemer
836356bdaa 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>
2021-04-07 05:19:36 +00:00
Robert Griesemer
8f1099b585 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>
2021-04-07 05:19:29 +00:00
Robert Griesemer
1395432f23 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>
2021-04-07 05:19:22 +00:00
Robert Griesemer
7d5c54eee4 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>
2021-04-07 05:19:15 +00:00
Robert Griesemer
bce85b7011 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>
2021-04-07 05:19:08 +00:00
David Chase
8462169b5a 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>
2021-04-07 03:42:11 +00:00
eric fang
8d77e45064 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>
2021-04-07 02:05:55 +00:00
Changkun Ou
972e883925 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>
2021-04-06 23:39:42 +00:00
Michael Anthony Knyszek
b084073b53 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>
2021-04-06 22:55:58 +00:00
Cherry Zhang
0a510478b0 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>
2021-04-06 21:43:19 +00:00
ianwoolf
7da8490cbb 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>
2021-04-06 21:42:50 +00:00
Bryan C. Mills
0bc4605ead 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>
2021-04-06 21:25:55 +00:00
David Chase
b56177a303 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>
2021-04-06 20:28:21 +00:00
Cherry Zhang
f5efa5a313 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>
2021-04-06 20:22:15 +00:00
Austin Clements
bcc4422ee1 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>
2021-04-06 19:55:44 +00:00
Ahmet Aktürk
1271e9a9cc 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>
2021-04-06 19:18:47 +00:00
Bryan C. Mills
2e6f39beb0 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>
2021-04-06 19:13:44 +00:00
Robert Griesemer
d6a90d06d2 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>
2021-04-06 19:00:26 +00:00
Robert Griesemer
3a30381b21 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>
2021-04-06 18:59:08 +00:00
Robert Griesemer
93466cc1b6 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>
2021-04-06 18:57:04 +00:00
Robert Griesemer
d57189e92b 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>
2021-04-06 18:55:39 +00:00
Cherry Zhang
55bac87bd6 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>
2021-04-06 18:01:39 +00:00
Cherry Zhang
b345a306a0 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>
2021-04-06 14:15:29 +00:00
Paul E. Murphy
939b561a6e 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>
2021-04-06 13:13:28 +00:00
Dan Scales
5cd8a34495 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>
2021-04-06 13:01:37 +00:00
cui
84162b8832 cmd/compile/internal/typecheck: call tcConv directly
Change-Id: I9f71acfa93c47cff620b006918872ecd90bbebe9
GitHub-Last-Rev: 2fed2e2305
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>
2021-04-06 09:22:20 +00:00