]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
15 months agonet/http: support full-duplex HTTP/1 responses
Damien Neil [Wed, 1 Mar 2023 23:17:35 +0000 (15:17 -0800)]
net/http: support full-duplex HTTP/1 responses

Add support for concurrently reading from an HTTP/1 request body
while writing the response.

Normally, the HTTP/1 server automatically consumes any remaining
request body before starting to write a response, to avoid deadlocking
clients which attempt to write a complete request before reading the
response.

Add a ResponseController.EnableFullDuplex method which disables this
behavior.

For #15527
For #57786

Change-Id: Ie7ee8267d8333e9b32b82b9b84d4ad28ab8edf01
Reviewed-on: https://go-review.googlesource.com/c/go/+/472636
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
15 months agocmd/go: simplify cgo and buildmode checks in tests
Bryan C. Mills [Tue, 7 Mar 2023 20:56:20 +0000 (15:56 -0500)]
cmd/go: simplify cgo and buildmode checks in tests

Change-Id: I0d6e49226a8708cc5f6ed3bea7658bec202a7ae7
Reviewed-on: https://go-review.googlesource.com/c/go/+/474138
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agocmd/go: avoid running slow tests on non-longtest builders
Bryan C. Mills [Tue, 7 Mar 2023 20:12:29 +0000 (15:12 -0500)]
cmd/go: avoid running slow tests on non-longtest builders

Also annotate calls to tooSlow with specific reasons.

This will somewhat reduce test coverage on the 'darwin' builders until
we have darwin 'longtest' builders (#35678,#49055), but still seems
worthwhile to avoid alert fatigue from tests that really shouldn't be
running in the short configurations.

Fixes #58918.
Fixes #58919.

Change-Id: I0000f0084b262beeec3eca3e9b8a45d61fab4313
Reviewed-on: https://go-review.googlesource.com/c/go/+/474137
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agonet: document the Close blocking with SO_LINGER on some OS's
Andy Pan [Tue, 7 Mar 2023 11:34:17 +0000 (19:34 +0800)]
net: document the Close blocking with SO_LINGER on some OS's

Fixes #58882

Change-Id: I65842a4aa3f808533e28128078e7e94a9b121404
Reviewed-on: https://go-review.googlesource.com/c/go/+/473915
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

15 months agocmd/internal/objabi: regenerate RelocType stringer file
qmuntal [Tue, 7 Mar 2023 07:37:31 +0000 (08:37 +0100)]
cmd/internal/objabi: regenerate RelocType stringer file

reloctype_strings.go is out-of-date since CL 462035, regenerate it.

Found while working on CL 461737.

Change-Id: I5cf910ab14c3618d6653c87861a4d53d3c91feff
Reviewed-on: https://go-review.googlesource.com/c/go/+/473875
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
15 months agoruntime: fix comment mismatch for currentConsMark
Revolution [Tue, 7 Mar 2023 08:32:32 +0000 (08:32 +0000)]
runtime: fix comment mismatch for currentConsMark

Change-Id: Ie0ed83e17be180100f144ce61bbd2c72a64d857b
GitHub-Last-Rev: 9db7a90a951c0fa9d18697fa93ae14267ab9b385
GitHub-Pull-Request: golang/go#58910
Reviewed-on: https://go-review.googlesource.com/c/go/+/473820
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
15 months agoruntime: allow for 5 more threads in TestWindowsStackMemory*
Alex Brainman [Sat, 4 Mar 2023 03:35:35 +0000 (14:35 +1100)]
runtime: allow for 5 more threads in TestWindowsStackMemory*

Original version of TestWindowsStackMemory did not consider sysmon and
other threads running during the test. Allow for 5 extra threads in this
test - this should cover any new threads in the future.

Fixes #58570

Change-Id: I215790f9b94ff40a32ddd7aa54af715d1dc391c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/473415
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agocmd/compile: enable address folding for globals on ARM64, just not -dynlink mode
Cherry Mui [Tue, 7 Mar 2023 20:32:30 +0000 (15:32 -0500)]
cmd/compile: enable address folding for globals on ARM64, just not -dynlink mode

On ARM64, in -dynlink mode (building a shared library or a plugin),
accessing global variable is made using the GOT. Currently, the
GOT accessing instruction sequence our assembler generates doesn't
handle large offset well, so we don't fold the offset into loads
and stores in the compiler. Currently, the rewrite rules are
guarded with the -shared flag. However, the GOT access
instructions are only generated in the -dynlink mode (which
implies -shared, but not the other direction).

CL 445535 attempted to remove the guard althgether. But that
causes build failure for -dynlink mode for the reason above. This
CL changes it to guard specifically on -dynlink mode, allowing
the optimization in more cases (-shared but not -dynlink build
modes).

Updates #58826.

Change-Id: I1391db6a33e8d0455a304e7cae7fcfdeb49bfdab
Reviewed-on: https://go-review.googlesource.com/c/go/+/473999
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoRevert "cmd/compile: enable address folding for global symbols of shared library"
Cherry Mui [Tue, 7 Mar 2023 18:23:40 +0000 (18:23 +0000)]
Revert "cmd/compile: enable address folding for global symbols of shared library"

This reverts CL 445535.

Reason for revert: see issue #58826. It doesn't handle large offset well.

Fixes #58826.

Change-Id: Ic4a33f4c510c88628ea7e16207a60977a04cf798
Reviewed-on: https://go-review.googlesource.com/c/go/+/474175
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
15 months agogo/types, types2: fine-tune inference tracing output (debugging support)
Robert Griesemer [Tue, 7 Mar 2023 17:59:35 +0000 (09:59 -0800)]
go/types, types2: fine-tune inference tracing output (debugging support)

No changes to non-tracing related code.

Change-Id: I3d004528281111a4479a02543a3e5443485182cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/474135
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agodebug/elf: retrieve values for dynamic section tags
Florin Papa [Mon, 21 Nov 2022 20:54:11 +0000 (12:54 -0800)]
debug/elf: retrieve values for dynamic section tags

Add functionality to retrieve values for .dynamic entries that don't
correspond to entries in the string table.

Fixes #56892

Change-Id: I6edabc8ca331c819e442d06e19b7f4df8343372b
Reviewed-on: https://go-review.googlesource.com/c/go/+/452617
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd: fix mismatched symbols
cui fliter [Tue, 7 Mar 2023 15:04:26 +0000 (23:04 +0800)]
cmd: fix mismatched symbols

Change-Id: Ib2c4ddec9740f7c21c180c9f0980394dceeedfaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/473975
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
15 months agocrypto/ed25519: improve Ed25519ctx error for oversized contexts
Tom Thorogood [Mon, 6 Mar 2023 07:43:45 +0000 (18:13 +1030)]
crypto/ed25519: improve Ed25519ctx error for oversized contexts

Previously if PrivateKey.Sign was called for Ed25519ctx with a context
longer than 255 bytes, the error message would mention Ed25519ph.

For Ed25519ph, the order of message length vs context length errors now
matches VerifyWithOptions. A message length error will be surfaced in
preference to a context length error. It also preferences hash errors
ahead of context length errors which also matches the behaviour of
VerifyWithOptions.

Change-Id: Iae380b3d879e0a9877ea057806fcd1e0ef7f7376
Reviewed-on: https://go-review.googlesource.com/c/go/+/473595
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
15 months agogo/types, types2: better error when method is missing due to ambiguity
Robert Griesemer [Mon, 6 Mar 2023 21:05:29 +0000 (13:05 -0800)]
go/types, types2: better error when method is missing due to ambiguity

If a type doesn't implement an interface due to an ambiguous method,
say so in the error message instead of just reporting a missing method.

Fixes #57352.

Change-Id: I5608f893c485de578b7f86362ca6f66033653695
Reviewed-on: https://go-review.googlesource.com/c/go/+/473658
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

15 months agogo/types, types2: avoid 2nd lookup when looking for method on ptr recv
Robert Griesemer [Mon, 6 Mar 2023 03:44:34 +0000 (19:44 -0800)]
go/types, types2: avoid 2nd lookup when looking for method on ptr recv

If a method is not found on a type V, for better error messages we
report if the method is on *V. There's no need to do a 2nd lookup
for that because the relevant information is readily returned by
lookupFieldOrMethod already.

Simplifies code and removes a long-standing TODO.

Change-Id: Ibdb2269b04c0db61bfe4641404ab1df330397b2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/473655
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agoRevert "cmd/go: extend path shortening to all paths in messages"
David Chase [Mon, 6 Mar 2023 20:38:31 +0000 (20:38 +0000)]
Revert "cmd/go: extend path shortening to all paths in messages"

This reverts CL 465805 (commit 3eedba50b10ca9086646f12d7917912cff7d4d0a).

Reason for revert: The longtest on Windows was typoed, silently ignored, and it turns out it fails there.

Change-Id: I362e9a22a7ec569314a0da932730ba137a98ecda
Reviewed-on: https://go-review.googlesource.com/c/go/+/473795
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agodebug/buildinfo: use saferio in ReadData methods
Ian Lance Taylor [Mon, 6 Mar 2023 19:39:22 +0000 (11:39 -0800)]
debug/buildinfo: use saferio in ReadData methods

This avoids a very large memory allocation if corrupt data says that
we need to read a very long string.

No test case because the problem can only happen for invalid data. Let
the fuzzer find cases like this.

For #47653
Fixes #58886

Change-Id: I4e80ba62a6416d010c8804e4f49ae81bdafaadb8
Reviewed-on: https://go-review.googlesource.com/c/go/+/473657
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/go: distinguish packages built for different main packages in printing
Cherry Mui [Fri, 3 Mar 2023 00:16:34 +0000 (19:16 -0500)]
cmd/go: distinguish packages built for different main packages in printing

In -pgo=auto mode, a package may be built multiple times. E.g. for

go build -pgo=auto cmd/a cmd/b

and both cmd/a and cmd/b imports package p, p may be built twice,
one using a's profile, one using b's. If we need to print p, e.g.
in "go list -deps" or when there is a build failure, p will be
printed twice, and currently we don't distinguish them.

We have a precedence for a similar case: for testing, there is the
original package, and the (internal) test version of the package
(which includes _test.go files). Packages that import the package
under testing may also have two versions (one imports the original,
one imports the testing version). In printing, the go command
distinguishes them by adding a "[p.test]" suffix for the latter,
as they are specifically built for the p.test binary.

We do the similar. When a package needs to be compiled multiple
times for different main packages, we attach the main package's
import path, like "p [cmd/a]" for package p built specifically
for cmd/a.

For #58099.

Change-Id: I4a040cf17e1dceb5ca1810c217f16e734c858ab6
Reviewed-on: https://go-review.googlesource.com/c/go/+/473275
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agocmd/go: support multiple main packages with -pgo=auto
Cherry Mui [Tue, 28 Feb 2023 23:43:14 +0000 (18:43 -0500)]
cmd/go: support multiple main packages with -pgo=auto

In -pgo=auto mode, the go command finds a profile named
default.pgo in the main package's directly, and if found, use it
as the profile for the build. Currently we only support a single
main package when -pgo=auto is used.

When multiple main packages are included in a build, they may
have different default profiles (or some have profiles whereas
some don't), so a common dependent package would need to be built
multiple times, with different profiles (or lack of). This CL
handles this. To do so, we need to split (unshare) the dependency
graph so they can attach different profiles.

Fixes #58099.

Change-Id: I1ad21361967aafbf5089d8d5e89229f95fe31276
Reviewed-on: https://go-review.googlesource.com/c/go/+/472358
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agocmd/go: make PGO profile path per package
Cherry Mui [Mon, 27 Feb 2023 20:37:32 +0000 (15:37 -0500)]
cmd/go: make PGO profile path per package

Currently, the PGO profile path is global for a single go command
invocation, as it applies to all packages being built (or none).
With -pgo=auto mode with multiple main packages, packages from a
single go command invocation could have different profiles. So it
is necessary that the PGO profile path is per package, which is
this CL does.

For #58099.

Change-Id: I148a15970ec907272db85b4b27ad6b08c41d6c0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/472357
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agocmd/go: extend path shortening to all paths in messages
David Chase [Mon, 6 Feb 2023 22:10:10 +0000 (17:10 -0500)]
cmd/go: extend path shortening to all paths in messages

The previous code only shortened the directory name for files
in the directory being compiled (and $WORK and runtime/std).

This extends the shortening to all file names.

Change-Id: I6abef6141d57036d893420b82e01ed0fbb637788
Reviewed-on: https://go-review.googlesource.com/c/go/+/465805
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>

15 months agocmd/compile: add flag to FOR/RANGE to preserve loop semantics across inlines
David Chase [Wed, 25 Jan 2023 22:08:16 +0000 (17:08 -0500)]
cmd/compile: add flag to FOR/RANGE to preserve loop semantics across inlines

This modifies the loopvar change to be tied to the
package if it is specified that way, and preserves
the change across inlining.

Down the road, this will be triggered (and flow correctly)
if the changed semantics are tied to Go version specified
in go.mod (or rather, for the compiler, by the specified
version for compilation).

Includes tests.

Change-Id: If54e8b6dd23273b86be5ba47838c90d38af9bd1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/463595
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
15 months agocmd/compile: experimental loop iterator capture semantics change
David Chase [Sun, 12 Jun 2022 19:33:57 +0000 (15:33 -0400)]
cmd/compile: experimental loop iterator capture semantics change

Adds:
GOEXPERIMENT=loopvar (expected way of invoking)
-d=loopvar={-1,0,1,2,11,12} (for per-package control and/or logging)
-d=loopvarhash=... (for hash debugging)

loopvar=11,12 are for testing, benchmarking, and debugging.

If enabled,for loops of the form `for x,y := range thing`, if x and/or
y are addressed or captured by a closure, are transformed by renaming
x/y to a temporary and prepending an assignment to the body of the
loop x := tmp_x.  This changes the loop semantics by making each
iteration's instance of x be distinct from the others (currently they
are all aliased, and when this matters, it is almost always a bug).

3-range with captured iteration variables are also transformed,
though it is a more complex transformation.

"Optimized" to do a simpler transformation for
3-clause for where the increment is empty.

(Prior optimization of address-taking under Return disabled, because
it was incorrect; returns can have loops for children.  Restored in
a later CL.)

Includes support for -d=loopvarhash=<binary string> intended for use
with hash search and GOCOMPILEDEBUG=loopvarhash=<binary string>
(use `gossahash -e loopvarhash command-that-fails`).

Minor feature upgrades to hash-triggered features; clients can specify
that file-position hashes use only the most-inline position, and/or that
they use only the basenames of source files (not the full directory path).
Most-inlined is the right choice for debugging loop-iteration change
once the semantics are linked to the package across inlining; basename-only
makes it tractable to write tests (which, otherwise, depend on the full
pathname of the source file and thus vary).

Updates #57969.

Change-Id: I180a51a3f8d4173f6210c861f10de23de8a1b1db
Reviewed-on: https://go-review.googlesource.com/c/go/+/411904
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agogo/types, types2: use "undefined type" rather than "<T>" in have/want error messages
Robert Griesemer [Fri, 3 Mar 2023 18:43:02 +0000 (10:43 -0800)]
go/types, types2: use "undefined type" rather than "<T>" in have/want error messages

In assignments and return statements, if we have the wrong number
of LHS or return values, we report the pattern that we have and
the pattern that we want. For untyped constants we use "number"
(to be not overly specific). For unknown types (due to earlier
errors), now use "unknown type" rather than the (cryptic) "<T>".

Fixes #58742.

Change-Id: I69c84ee29fb64badb0121e26a96f003b381024aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/473255
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
15 months agocmd/go: trim spaces in pkg-config ldflags output
qmuntal [Mon, 6 Mar 2023 11:36:31 +0000 (12:36 +0100)]
cmd/go: trim spaces in pkg-config ldflags output

Fixes #58889
Updates #35262

Change-Id: I1d51aa03f445faaf4f4e9cc412d5499cad526663
Reviewed-on: https://go-review.googlesource.com/c/go/+/473616
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agocmd/compile/internal/ir: explicit Pos for New{Bool,Int,String}
Matthew Dempsky [Tue, 28 Feb 2023 21:27:51 +0000 (13:27 -0800)]
cmd/compile/internal/ir: explicit Pos for New{Bool,Int,String}

Stop depending on base.Pos for these.

Change-Id: I58dea44f8141eb37b59a6e9f7db0c6baa516ad93
Reviewed-on: https://go-review.googlesource.com/c/go/+/472296
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/link: establish dependable package initialization order
Keith Randall [Fri, 13 Jan 2023 04:25:39 +0000 (20:25 -0800)]
cmd/link: establish dependable package initialization order

As described here:

https://github.com/golang/go/issues/31636#issuecomment-493271830

"Find the lexically earliest package that is not initialized yet,
but has had all its dependencies initialized, initialize that package,
 and repeat."

Simplify the runtime a bit, by just computing the ordering required
in the linker and giving a list to the runtime.

Update #31636
Fixes #57411

RELNOTE=yes

Change-Id: I1e4d3878ebe6e8953527aedb730824971d722cac
Reviewed-on: https://go-review.googlesource.com/c/go/+/462035
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agogo/types, types2: added clarifying comments, removed TODO in lookup.go
Robert Griesemer [Fri, 3 Mar 2023 01:24:32 +0000 (17:24 -0800)]
go/types, types2: added clarifying comments, removed TODO in lookup.go

Also, renamed lookupFieldOrMethod to lookupFieldOrMethodImpl to make
a clearer distinction between this function and the exported version
LookupFieldOrMethod.

Except for the rename, all changes are to comments only.

Change-Id: If7d1465c9cf659ea86bbbbcba8b95f16d2170fcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/473075
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/compile: ensure FuncForPC works on closures that start with NOPs
Keith Randall [Tue, 14 Feb 2023 07:27:51 +0000 (23:27 -0800)]
cmd/compile: ensure FuncForPC works on closures that start with NOPs

A 0-sized no-op shouldn't prevent us from detecting that the first
instruction is from an inlined callee.

Update #58300

Change-Id: Ic5f6ed108c54a32c05e9b2264b516f2cc17e4619
Reviewed-on: https://go-review.googlesource.com/c/go/+/467977
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoruntime: skip TestGdbPanic on Windows
qmuntal [Fri, 3 Mar 2023 15:04:56 +0000 (16:04 +0100)]
runtime: skip TestGdbPanic on Windows

TestGdbPanic expects crash() to raise a SIGABRT signal interceptable
by gdb, but Windows doesn't have signals.

Windows builders haven't caught this failing test because they still
don't have gdb installed (tracked in #22021).

Change-Id: I7c7f2523a54d61aea0a9821c4db7c79e58a7217c
Reviewed-on: https://go-review.googlesource.com/c/go/+/473116
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>

15 months agocmd/compile: optimize multiplication on loong64
Wayne Zuo [Thu, 2 Mar 2023 05:33:21 +0000 (13:33 +0800)]
cmd/compile: optimize multiplication on loong64

Previously, multiplication on loong64 architecture was performed using
MULV and MULHVU instructions to calculate the low 64-bit and high
64-bit of a multiplication respectively. However, in most cases, only
the low 64-bits are needed. This commit enalbes only computating the low
64-bit result with the MULV instruction.

Reduce the binary size slightly.

file      before    after     Δ       %
addr2line 2833777   2833849   +72     +0.003%
asm       5267499   5266963   -536    -0.010%
buildid   2579706   2579402   -304    -0.012%
cgo       4798260   4797444   -816    -0.017%
compile   25247419  25175030  -72389  -0.287%
cover     4973091   4972027   -1064   -0.021%
dist      3631013   3565653   -65360  -1.800%
doc       4076036   4074004   -2032   -0.050%
fix       3496378   3496066   -312    -0.009%
link      6984102   6983214   -888    -0.013%
nm        2743820   2743516   -304    -0.011%
objdump   4277171   4277035   -136    -0.003%
pack      2379248   2378872   -376    -0.016%
pprof     14419090  14419874  +784    +0.005%
test2json 2684386   2684018   -368    -0.014%
trace     13640018  13631034  -8984   -0.066%
vet       7748918   7752630   +3712   +0.048%
go        15643850  15638098  -5752   -0.037%
total     127423782 127268729 -155053 -0.122%

Change-Id: Ifce4a9a3ed1d03c170681e39cb6f3541db9882dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/472775
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: David Chase <drchase@google.com>
15 months agoarchive/zip: make receiver names consistent
Oleksandr Redko [Sun, 12 Feb 2023 12:21:26 +0000 (12:21 +0000)]
archive/zip: make receiver names consistent

Fixes revive linter receiver-naming warnings:

- receiver name f should be consistent with previous receiver name e for fileListEntry
- receiver name r should be consistent with previous receiver name z for Reader
- receiver name f should be consistent with previous receiver name h for FileHeader

Change-Id: Ibfa14b97f6ca7adc86e3a1df919c5bb5de9716dc
GitHub-Last-Rev: dd7315b09d224bb2953b82cc6bd97d81c9eaca0a
GitHub-Pull-Request: golang/go#58477
Reviewed-on: https://go-review.googlesource.com/c/go/+/467519
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>

15 months agoall: move //go: function directives directly above functions
Michael Pratt [Thu, 2 Mar 2023 22:09:22 +0000 (17:09 -0500)]
all: move //go: function directives directly above functions

These directives affect the next declaration, so the existing form is
valid, but can be confusing because it is easy to miss. Move then
directly above the declaration for improved readability.

CL 69120 previously moved the Gosched nosplit away to hide it from
documentation. Since CL 224737, directives are automatically excluded
from documentation.

Change-Id: I8ebf2d47fbb5e77c6f40ed8afdf79eaa4f4e335e
Reviewed-on: https://go-review.googlesource.com/c/go/+/472957
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
15 months agonet: re-enable TestVariousDeadlines on Plan 9
miller [Wed, 1 Mar 2023 09:46:14 +0000 (09:46 +0000)]
net: re-enable TestVariousDeadlines on Plan 9

After CL 470215 it should be safe to run this test on Plan 9.

Fixes #26945

Change-Id: I17880b696d2e91e6c4862fac05e6372f44e69b22
Reviewed-on: https://go-review.googlesource.com/c/go/+/472436
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

15 months agogo/types, types2: simplify missingMethod some more (cleanup)
Robert Griesemer [Thu, 2 Mar 2023 20:19:53 +0000 (12:19 -0800)]
go/types, types2: simplify missingMethod some more (cleanup)

Remove unnecessary assignments by using the same two variables
for methods consistently throughout.

Change-Id: I8b9bc8dbc8022b2472724d2a170f2635de3306e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/472915
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

15 months agogo/types, types2: disentangle convoluted logic for missing method cause
Robert Griesemer [Thu, 2 Mar 2023 01:08:15 +0000 (17:08 -0800)]
go/types, types2: disentangle convoluted logic for missing method cause

Use a state to exactly track lookup results. In case of lookup failure,
use the state to directly report the cause instead of trying to guess
from the missing and alternative method.

Addresses a TODO (incorrect error message).

Change-Id: I50902752deab741f8199a09fd1ed29286cf5be42
Reviewed-on: https://go-review.googlesource.com/c/go/+/472637
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
15 months agocmd/link/internal/ld: move more of mustLinkExternal into internal/platform
Bryan C. Mills [Wed, 1 Mar 2023 16:11:07 +0000 (16:11 +0000)]
cmd/link/internal/ld: move more of mustLinkExternal into internal/platform

internal/platform.MustLinkExternal is used in various places to
determine whether external linking is required. It should always
match what the linker actually requires, but today does not match
because the linker imposes additional constraints.

Updates #31544.

Change-Id: I0cc6ad587e95c607329dea5d60d29a5fb2a9e722
Reviewed-on: https://go-review.googlesource.com/c/go/+/472515
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agocmd/asm: don't panic on bad GATHER x86 instructions
Keith Randall [Thu, 2 Mar 2023 06:32:46 +0000 (22:32 -0800)]
cmd/asm: don't panic on bad GATHER x86 instructions

Fixes #58822

Change-Id: I9c44c57dac72884ec3209d87ddb25e7e1675a737
Reviewed-on: https://go-review.googlesource.com/c/go/+/472795
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
15 months agogo/types, types2: combine missingMethodCause with missingMethod
Robert Griesemer [Wed, 1 Mar 2023 21:53:48 +0000 (13:53 -0800)]
go/types, types2: combine missingMethodCause with missingMethod

For now this is simply a mechanical combination without any
relevant logic changes. This will make it easier to review
subsequent changes.

Change-Id: Ic2e2ae32b031d2dda0f69a08a5cc2349748bd25d
Reviewed-on: https://go-review.googlesource.com/c/go/+/472675
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agointernal/poll: remove redundant atomics from poll.FD on plan9
miller [Wed, 1 Mar 2023 09:33:27 +0000 (09:33 +0000)]
internal/poll: remove redundant atomics from poll.FD on plan9

After CL 235820 all references to FD.rtimedout and FD.wtimedout
are guarded by mutexes. Therefore they can safely be changed
from type atomic.Bool to bool.

Change-Id: I7ab921d1ad5c7ccc147feb2b0fba58a66b031261
Reviewed-on: https://go-review.googlesource.com/c/go/+/472435
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

15 months agoall: implement wasmimport directive
Evan Phoenix [Sun, 22 Jan 2023 23:30:59 +0000 (15:30 -0800)]
all: implement wasmimport directive

Go programs can now use the //go:wasmimport module_name function_name
directive to import functions from the WebAssembly runtime.

For now, the directive is restricted to the runtime and syscall/js
packages.

* Derived from CL 350737
* Original work modified to work with changes to the IR conversion code.
* Modification of CL 350737 changes to fully exist in Unified IR path (emp)
* Original work modified to work with changes to the ABI configuration code.
* Fixes #38248

Co-authored-by: Vedant Roy <vroy101@gmail.com>
Co-authored-by: Richard Musiol <mail@richard-musiol.de>
Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Change-Id: I740719735d91c306ac718a435a78e1ee9686bc16
Reviewed-on: https://go-review.googlesource.com/c/go/+/463018
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
15 months agoruntime: fix function name in comments
cui fliter [Wed, 1 Mar 2023 14:43:22 +0000 (22:43 +0800)]
runtime: fix function name in comments

Change-Id: I18bb87bfdea8b6d7994091ced5134aa2549f221e
Reviewed-on: https://go-review.googlesource.com/c/go/+/472476
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agogo/types, types2: change missingMethod to match MissingMethod signature
Robert Griesemer [Wed, 1 Mar 2023 16:06:42 +0000 (08:06 -0800)]
go/types, types2: change missingMethod to match MissingMethod signature

This simplifies the use of missingMethod and also opens the door to
further missingMethod-internal simplifications.

Change-Id: I74d9694b6fca67c4103aea04d08916a69ad0e3c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/472495
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agogo/types, types2: add cause parameter to missingMethod, (new)assertableTo
Robert Griesemer [Wed, 1 Mar 2023 04:35:23 +0000 (20:35 -0800)]
go/types, types2: add cause parameter to missingMethod, (new)assertableTo

This CL allows missingMethod (and with it the assertableTo methods)
to provide an error cause without an extra external (and messy) call
of missingMethodCause. This latter function is now only called by
missingMethod and can be eliminated eventually in favor of more
precise error causes generated directly by missingMethod.

The change requires that missingMethod (and the assertableTo methods)
accept general types for both relevant argument types (rather than a
Type and a *Interface) so that error causes can report the appropriate
(possibly defined) type rather than the underlying interface type.

Change-Id: Ic31508073fa138dd5fa27285b06cf232ee638685
Reviewed-on: https://go-review.googlesource.com/c/go/+/472395
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
15 months agogo/types, types2: consider methods when unifying type parameters and constraints
Robert Griesemer [Tue, 28 Feb 2023 20:56:06 +0000 (12:56 -0800)]
go/types, types2: consider methods when unifying type parameters and constraints

An inferred type argument must implement its type parameter's constraint's
methods whether or not a core type exists. This allows us to infer type
parameters used in method signatures.

Fixes #51593.

Change-Id: I1fddb05a71d442641b4311d8e30a13ea9bdb4db5
Reviewed-on: https://go-review.googlesource.com/c/go/+/472298
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
15 months agogo/types, types2: add predicate to missingMethod signature
Robert Griesemer [Tue, 28 Feb 2023 23:04:35 +0000 (15:04 -0800)]
go/types, types2: add predicate to missingMethod signature

This allows us to use missingMethod with different type comparers,
such as the global Identical predicate, or a unifier.

Preparation for the next CL.

Change-Id: I237fd9dd7feb3708847ae6d9a112bcdd0aa1ecb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/472297
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agogo/types, types2: handle unbound type parameters in switch (cleanup)
Robert Griesemer [Tue, 28 Feb 2023 17:43:36 +0000 (09:43 -0800)]
go/types, types2: handle unbound type parameters in switch (cleanup)

This simply moves the special handling for unbound type parameters
into the switch (which already looks for type parameters).

Change-Id: I2d6d22f3fdffc443065c3681a442288cd1d375ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/472115
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
15 months agogo/types, types2: better internal comment, added suitable test case
Robert Griesemer [Fri, 24 Feb 2023 05:26:46 +0000 (21:26 -0800)]
go/types, types2: better internal comment, added suitable test case

Change-Id: If55cd001ab3d274cd9c61c06f73bb98162aa12a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/471019
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
15 months agogo/types, types2: simplify unification when x == y (pointer identity)
Robert Griesemer [Fri, 24 Feb 2023 04:47:17 +0000 (20:47 -0800)]
go/types, types2: simplify unification when x == y (pointer identity)

Because we rename type parameters to avoid problems with self-recursive
function calls, there's no need anymore for special (and hard to follow)
logic for pointer-identical types. If they are identical, we have a
match. Simplify the code accordingly.

Change-Id: I2e1838a43e90fa4abfae3ab9e4f7da6463508966
Reviewed-on: https://go-review.googlesource.com/c/go/+/471018
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agogo/types, types2: simplify unification with constraints
Robert Griesemer [Fri, 24 Feb 2023 02:55:11 +0000 (18:55 -0800)]
go/types, types2: simplify unification with constraints

Change-Id: I399f0ac12e65713f3018a89da55ecd3cdb855c50
Reviewed-on: https://go-review.googlesource.com/c/go/+/471017
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agogo/types, types2: move Checker.infer into infer.go; delete infer2.go
Robert Griesemer [Fri, 24 Feb 2023 02:27:11 +0000 (18:27 -0800)]
go/types, types2: move Checker.infer into infer.go; delete infer2.go

Adjust imports but no other code changes otherwise.

Change-Id: Iffbd7f9b1786676a42b68d91ee6cc7df07d776bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/471015
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agogo/types, types2: remove code for infer1
Robert Griesemer [Fri, 24 Feb 2023 02:04:54 +0000 (18:04 -0800)]
go/types, types2: remove code for infer1

Fixes #58283.

Change-Id: I4a82083cddfed1b1be7776464f926a4c69a35e10
Reviewed-on: https://go-review.googlesource.com/c/go/+/470995
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

15 months agogo/types, types2: use new type inference algorithm exclusively
Robert Griesemer [Thu, 23 Feb 2023 22:54:47 +0000 (14:54 -0800)]
go/types, types2: use new type inference algorithm exclusively

The primary change is that type inference now always reports
an error if a unification step fails (rather than ignoring that
case, see infer2.go). This brings the implementation closely to
the description in #58650; but the implementation is more direct
by always maintaining a simple (type parameter => type) mapping.

To make this work, there are two small but subtle changes in the
unifier:

1) When deciding whether to proceed with the underlying type of
   a defined type, we also use the underlying type if the other
   type is a basic type (switch from !hasName(x) to isTypeLit(x)
   in unifier.go). This makes the case in issue #53650 work out.
   See the comment in the code for a detailed explanation of this
   change.

2) When we unify against an unbound type parameter, we always
   proceed with its core type (if any).
   Again, see the comment in the code for a detailed explanation
   of this change.

The remaining changes are comment and test adjustments. Because
the new logic now results in failing type inference where it
succeeded before or vice versa, and then instatiation or parameter
passing failed, a handful of error messages changed.
As desired, we still have the same number of errors for the same
programs.

Also, because type inference now produces different results, we
cannot easily compare against infer1 anymore (also infer1 won't
work correctly anymore due to the changes in the unifier). This
comparison (together with infer1) is now disabled.

Because some errors and their positions have changed, we need a
slightly larger error position tolerance for types2 (which produces
less accurate error positions than go/types). Hence the change in
types2/check_test.go.

Finally, because type inference is now slightly more relaxed,
issue #51139 doesn't produce a type unification failure anymore
for a (previously correctly) inferred type argument.

Fixes #51139.

Change-Id: Id796eea42f1b706a248843ad855d9d429d077bd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/470916
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agocmd/compile: relax overly strict assertion
Matthew Dempsky [Tue, 21 Feb 2023 21:16:22 +0000 (13:16 -0800)]
cmd/compile: relax overly strict assertion

The assertion here was to make sure the newly constructed and
typechecked expression selected the same receiver-qualified method,
but in the case of anonymous receiver types we can actually end up
with separate types.Field instances corresponding to each types.Type
instance. In that case, the assertion spuriously failed.

The fix here is to relax and assertion and just compare the method's
name and type (including receiver type).

Fixes #58563.

Change-Id: I67d51ddb020e6ed52671473c93fc08f283a40886
Reviewed-on: https://go-review.googlesource.com/c/go/+/471676
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocrypto/x509: make TestIssue51759 builder only
Roland Shoemaker [Wed, 1 Mar 2023 19:50:10 +0000 (11:50 -0800)]
crypto/x509: make TestIssue51759 builder only

Since we can't gate tests on the macOS version on normal machines,
restrict TestIssue51759 to only run on builders, where we have a way to
do this.

Change-Id: I70fc83c587689b499b6a38864973a77bb3e52596
Reviewed-on: https://go-review.googlesource.com/c/go/+/472619
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
15 months agocmd/link: update -T flag's documentation
Cherry Mui [Wed, 1 Mar 2023 00:10:44 +0000 (19:10 -0500)]
cmd/link: update -T flag's documentation

The -T flag actually means the start address of text symbols, not
the text sections, which may differ by the header size. It has
been behaving like this since at least 2009. Make it clear in the
documentation.

Also remove the -D flag from the doc. The flag doesn't actually
exist in the implementation.

Fixes #58727.

Change-Id: Ic5b7e93adca3f1ff9f0de33dbb6089f46cdf4738
Reviewed-on: https://go-review.googlesource.com/c/go/+/472356
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
15 months agocrypto/x509: fix broken tests
Roland Shoemaker [Wed, 1 Mar 2023 16:39:04 +0000 (08:39 -0800)]
crypto/x509: fix broken tests

Convert TestUnknownAuthorityError to use subtests, avoiding continuing
the test after an unrecoverable failure.

Skip TestIssue51759 on pre-macOS 11 builders, which don't enforce the
behavior we were testing for.

Updates #58791
Fixes #58812

Change-Id: I4e3e5bc371aa139d38052184c8232f8cb564138f
Reviewed-on: https://go-review.googlesource.com/c/go/+/472496
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
15 months agoruntime/coverage: restrict use of all counter-related APIs to atomic mode
Than McIntosh [Thu, 26 Jan 2023 16:46:45 +0000 (11:46 -0500)]
runtime/coverage: restrict use of all counter-related APIs to atomic mode

The existing runtime/coverage API set includes a "ClearCounters()"
function that zeros out the counter values in a running process so as
enable capturing of a coverage profile from a specific execution time
segment. Calling this function is only permitted if the program is
built with "-covermode=atomic", due (in part) to concerns about
processors with relaxed memory models in which normal stores can be
reordered.

In the bug in question, a test that stresses a different set of
counter-related APIs was hitting an invalid counter segment when
running on a machine (ppc64) which does indeed have a relaxed memory
consistency model.

From a post-mortem examination of the counter array for the harness
from the ppc64 test run, it was clear that the thread reading values
from the counter array was seeing the sort of inconsistency that could
result from stores being reordered (specifically the prolog
"packageID" and "number-of-counters" stores).

To preclude the possibility of future similar problems, this patch
extends the "atomic mode only" restriction from ClearCounters to the
other APIs that deal with counters (WriteCounters, WriteCountersDir).

Fixes #56197.

Change-Id: Idb85d67a84d69ead508e0902ab46ab4dc82af466
Reviewed-on: https://go-review.googlesource.com/c/go/+/463695
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoruntime: remove implicit NOFRAME heuristic support
qmuntal [Wed, 8 Feb 2023 15:51:34 +0000 (16:51 +0100)]
runtime: remove implicit NOFRAME heuristic support

All amd64 OSes already make use of the NOFRAME flag wherever is
required, so we can remove the frameless nosplit functions heuristic
code path.

Updates #58378

Change-Id: I966970693ba07f8c66da0aca83c23caad7cbbfe5
Reviewed-on: https://go-review.googlesource.com/c/go/+/466458
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
15 months agointernal/testenv: use 'go env CGO_ENABLED' instead of a build constraint
Bryan C. Mills [Tue, 28 Feb 2023 19:16:54 +0000 (19:16 +0000)]
internal/testenv: use 'go env CGO_ENABLED' instead of a build constraint

A build constraint reports whether the test binary was compiled with
cgo enabled, but that doesn't necessarily imply that cgo can be used
in the environment in which the test binary is run.

In particular, cross-compiled builders (such as Android) may compile
the test binaries on the host with CGO enabled but not provide a C
toolchain on the device that runs the test.

For #58775.

Change-Id: Ibf2f44c9e956cd3fa898c3de67af4449e8ef2dd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/472215
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

15 months agoruntime: use explicit NOFRAME on plan9/amd64
qmuntal [Wed, 8 Feb 2023 15:47:16 +0000 (16:47 +0100)]
runtime: use explicit NOFRAME on plan9/amd64

This CL marks some plan9 assembly functions as NOFRAME to avoid
relying on the implicit amd64 NOFRAME heuristic, where NOSPLIT functions
without stack were also marked as NOFRAME.

Updates #58378

Change-Id: Ic8c9ab5c1a0897bebc6c1419ddc903a7492a1b0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/466457
TryBot-Bypass: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agocmd/compile/internal/pgo: drop unused 'recursive' argument
Michael Pratt [Tue, 28 Feb 2023 21:21:27 +0000 (16:21 -0500)]
cmd/compile/internal/pgo: drop unused 'recursive' argument

Change-Id: I7ccde4c6d1506cbd8e14d284a921f06b29b5f495
Reviewed-on: https://go-review.googlesource.com/c/go/+/472258
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoruntime: remove unnecessary NOFRAME flags on windows
qmuntal [Thu, 9 Feb 2023 13:14:07 +0000 (14:14 +0100)]
runtime: remove unnecessary NOFRAME flags on windows

This CL removes some NOFRAME flags on Windows assembly files
for several reasons:

- windows/386 does not use a frame pointer
- Leaf frameless functions already skip the frame pointer
- Some non-leaf functions do not contain enough dragons to justify
not using the frame pointer

Updates #58378

Change-Id: I31e71bf7f769e1957a4adba91778da5af66ce1e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/466835
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocrypto/x509: fix system root tests + darwin intermediate handling
Roland Shoemaker [Tue, 28 Feb 2023 21:23:43 +0000 (13:23 -0800)]
crypto/x509: fix system root tests + darwin intermediate handling

On Windows, replace tests which rely on a root that expired last year.
On Darwin fix an test which wasn't testing the expected behavior, and
fix the behavior which was broken.

Fixes #58791

Change-Id: I771175b9e123b8bb0e4efdf58cc2bb93aa94fbae
Reviewed-on: https://go-review.googlesource.com/c/go/+/472295
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>

15 months agocmd/compile: don't mark uintptr->unsafe.Pointer conversion unsafe points
Cherry Mui [Wed, 11 Jan 2023 23:56:31 +0000 (18:56 -0500)]
cmd/compile: don't mark uintptr->unsafe.Pointer conversion unsafe points

In the past, we planned to implement asynchronous preemption using
precise register pointer maps. In this strategy, conversions between
unsafe.Pointer and uintptr would need to be marked as unsafe points,
as if a pointer value is temporarily converted to uintptr (and not
live otherwise), the GC would not be able to see it when scanning
the stack (and registers).

But now we actually implemented asynchronous preemption with inner
frame conservative scan. So even if a pointer value lives as an
integer the GC can still see it. There is no need to mark the
conversion as unsafe points. This allows more places to be
preempted, as well as for debugger to inject a call.

Fixes #57719.

Change-Id: I375ab820d8d74d122b565cf72ecc7cdb225dbc01
Reviewed-on: https://go-review.googlesource.com/c/go/+/461696
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>

15 months agoruntime: use os.TempDir instead of hard-coding /tmp
Bryan C. Mills [Tue, 28 Feb 2023 21:12:13 +0000 (21:12 +0000)]
runtime: use os.TempDir instead of hard-coding /tmp

On Android, /tmp does not exist.

Change-Id: Ib1797d79d89704a7a9466ad94efd57d2848b3b57
Reviewed-on: https://go-review.googlesource.com/c/go/+/472255
TryBot-Bypass: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

15 months agocrypto/x509: fix ParsePKCS8PrivateKey comment
Roland Shoemaker [Tue, 28 Feb 2023 18:11:51 +0000 (10:11 -0800)]
crypto/x509: fix ParsePKCS8PrivateKey comment

Fixes #58789

Change-Id: I91cdd20c6d4f05baaacd6a38717aa7bed6682573
Reviewed-on: https://go-review.googlesource.com/c/go/+/472155
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
15 months agonet: use /dev/null for TestSplice of big file to fix the test flakes on linux-riscv64...
Andy Pan [Tue, 28 Feb 2023 11:31:23 +0000 (19:31 +0800)]
net: use /dev/null for TestSplice of big file to fix the test flakes on linux-riscv64-jsing

Fixes #58787

Change-Id: Ia6e9ee0d8dd505f64bfe9ffd23a868b8165f550f
Reviewed-on: https://go-review.googlesource.com/c/go/+/471995
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

15 months agocmd/compile: preserve full inlined location for ir.Name locals
David Chase [Tue, 31 Jan 2023 04:54:13 +0000 (23:54 -0500)]
cmd/compile: preserve full inlined location for ir.Name locals

This was noticed while testing hash-search debugging
of the loopvar experiment.

The change is incomplete -- it only addresses local
variables, not parameters.  The code to log/search
changes in loop variable semantics depends on this,
so that will be the test.

Change-Id: I0f84ab7696c6cab43486242cacaba6a0bfc45475
Reviewed-on: https://go-review.googlesource.com/c/go/+/464315
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>

15 months agocmd/compile: update documentation for ONAME node with nil Func
Cuong Manh Le [Thu, 16 Feb 2023 14:30:36 +0000 (21:30 +0700)]
cmd/compile: update documentation for ONAME node with nil Func

After CL 436435 chain, the only case left where we create an ONAME node
with nil Func is interface method from imported package.

Change-Id: I9d9144916d01712283f2b116973f88965715fea3
Reviewed-on: https://go-review.googlesource.com/c/go/+/468816
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

15 months agocmd/go: set GOWORK=off explicitly in script tests that cd to GOROOT
Bryan C. Mills [Mon, 27 Feb 2023 22:24:15 +0000 (22:24 +0000)]
cmd/go: set GOWORK=off explicitly in script tests that cd to GOROOT

Some folks working on the Go project may have a go.work file in
GOROOT/src in order to test changes in x repos. 'go test cmd/go'
should not fail if that is the case.

For #58767.

Change-Id: I0e57b15fb1d3e4abc4903c177434626c9f125cae
Reviewed-on: https://go-review.googlesource.com/c/go/+/471601
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
15 months agocmd/go: disable workspace mode in GOPATH mode
Bryan C. Mills [Mon, 27 Feb 2023 22:13:16 +0000 (22:13 +0000)]
cmd/go: disable workspace mode in GOPATH mode

Workspace mode is specifically for working with modules;
it doesn't make sense in GOPATH mode.

This also fixes a panic in (*modload.MainModuleSet).GoVersion
when go.work is present in GOPATH mode.

For #58767.

Change-Id: Ic6924352afb486fecc18e009e6b517f078e81094
Reviewed-on: https://go-review.googlesource.com/c/go/+/471600
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
15 months agocmd/compile/internal/walk: remove unused eqFor
Cuong Manh Le [Thu, 16 Feb 2023 14:19:42 +0000 (21:19 +0700)]
cmd/compile/internal/walk: remove unused eqFor

CL 436436 replaced eqFor with reflectdata.EqFor, but forgot removing it.

Change-Id: I3f2bf02da2e161a27718226b970b81815e9f0a46
Reviewed-on: https://go-review.googlesource.com/c/go/+/468815
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
15 months agosyscall: use unsafe.Slice in (*RawSockaddrAny).Sockaddr on windows
Tobias Klauser [Tue, 28 Feb 2023 12:58:42 +0000 (13:58 +0100)]
syscall: use unsafe.Slice in (*RawSockaddrAny).Sockaddr on windows

Follow CL 471436.

Change-Id: I415b126f58dbd381b8d45457e7bd79f025a2a03c
Reviewed-on: https://go-review.googlesource.com/c/go/+/472035
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
15 months agointernal/xcoff: use saferio to allocate slices
Ian Lance Taylor [Mon, 27 Feb 2023 23:30:42 +0000 (15:30 -0800)]
internal/xcoff: use saferio to allocate slices

No test case because the problem can only happen for invalid data. Let
the fuzzer find cases like this.

For #47653
Fixes #58754

Change-Id: Ic3ef58b204b946f8bff80310d4c8dfcbb2939a1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/471678
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

15 months agomime/multipart: fix Reader.ReadForm(math.MaxInt64) overflow
hopehook [Sun, 12 Feb 2023 14:27:35 +0000 (22:27 +0800)]
mime/multipart: fix Reader.ReadForm(math.MaxInt64) overflow

Because "CopyN" will read one more byte, which will cause us
to overflow when calling "Reader.ReadForm(math.MaxInt64)".

So we should check if the parameter exceeds "math.MaxInt64"
to avoid returning no data.

Fixes #58384.

Change-Id: I30088ce6468176b21e4a9a0b8b6080f2986dda23
Reviewed-on: https://go-review.googlesource.com/c/go/+/467557
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: hopehook <hopehook@golangcn.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agocmd/compile: use ONAME node directly from generated hash func
Cuong Manh Le [Fri, 17 Feb 2023 04:57:30 +0000 (11:57 +0700)]
cmd/compile: use ONAME node directly from generated hash func

This reverts CL 468879

CL 469017 marked type eq/hash functions as non-inlineable, so this
change won't cause ICE anymore.

Updates #58572

Change-Id: I3e6ec9ba2217102693acd1848a0eba0886dc9fda
Reviewed-on: https://go-review.googlesource.com/c/go/+/469018
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/compile: mark type eq/hash functions non-inlineable
Cuong Manh Le [Fri, 17 Feb 2023 04:19:32 +0000 (11:19 +0700)]
cmd/compile: mark type eq/hash functions non-inlineable

The compiler used to generate ONAME node with nil Func for them, so the
inliner can still analyze, but could not generate inline call for them
anyway.

CL 436961 attempts to create ONAME node with non-nil Func, causing the
inliner complains about missing body reader.

This CL makes inliner recognize type eq/hash functions, and mark them as
non-inlineable. Longer term, if we do want to inline these functions, we
need to integrate the code generation into Unified IR frontend.

Updates #58572

Change-Id: Icdd4dda03711929faa3d48fe2d9886568471f0bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/469017
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
15 months agohash/maphash: add purego implementation
Cuong Manh Le [Thu, 16 Feb 2023 07:35:25 +0000 (14:35 +0700)]
hash/maphash: add purego implementation

Fixes #47342

Change-Id: I9c3b36de3e7c85d3e7aff2f84abc78a1b382008c
Reviewed-on: https://go-review.googlesource.com/c/go/+/468795
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agoio/ioutil: add doc links for deprecated function
Shengyu Zhang [Tue, 28 Feb 2023 16:58:07 +0000 (16:58 +0000)]
io/ioutil: add doc links for deprecated function

Go 1.19 introduced doc links (https://go.dev/doc/comment#doclinks).
It will be convenient when we can directly jump to the suggested
function when the original function is deprecated.

Change-Id: I6172a5265f3b47aefec53179bca60f9904606b3f
GitHub-Last-Rev: b2aa85bf1bb67a39b5b26a047ba90a4b6a61dba4
GitHub-Pull-Request: golang/go#58779
Reviewed-on: https://go-review.googlesource.com/c/go/+/471915
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
15 months agocmd/go: skip TestDocsUpToDate if 'go build' is not supported
Bryan C. Mills [Tue, 28 Feb 2023 15:16:30 +0000 (15:16 +0000)]
cmd/go: skip TestDocsUpToDate if 'go build' is not supported

testGo is currently only configured if testenv.HasGoBuild returns
true, which implies that a complete toolchain is present.
Since setting up testGo now only uses the test binary itself, it does
not actually require 'go build', but fixing that will be a bit more
involved. For now, just skip the test when it isn't set up.

Fixes #58775.

Change-Id: I6487b47b44c87aa139ae11cfa44ce6f0f5f84bd4
Reviewed-on: https://go-review.googlesource.com/c/go/+/472095
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

15 months agocmd/internal/obj: use prefix insn in MOV* opcodes for GOPPC64=power10
Paul E. Murphy [Tue, 9 Mar 2021 22:55:22 +0000 (16:55 -0600)]
cmd/internal/obj: use prefix insn in MOV* opcodes for GOPPC64=power10

As background, Power10 adds prefixed load, store, and add immediate
instructions which encode 34b signed displacements. Likewise, they
also give the option to compute addresses against the PC. This enables
using simpler PC relative (PC-rel) relocations instead of maintaining a
dedicated pointer (the TOC) to the code/data blob on PPC64/linux.

Similary, there are several Go opcodes where it can be advantageous to
use prefixed instructions instead of composite sequences like oris/ori/add
to implement "MOVD <big const>, Rx" or "ADD <big const>, Rx, Ry", or
large offset load/stores like "MOVD <big constant>(Rx), Ry" using the same
framework which dynamically configures optab.

When selecting prefixed instruction forms, the assembler must also use
new relocations. These new relocations are always PC-rel by design, thus
code assembled as such has no implicit requirement to maintain a TOC
pointer when assembling shared objects. Thus, we can safely avoid
situations where some Go objects use a TOC pointer, and some do not. This
greatly simplifies linking Go objects. For more details about the
challenges of linking TOC and PC-rel compiled code, see the PPC64 ELFv2
ABI.

The TOC pointer in R2 is still maintained in those build configurations
which previously required it (e.x buildmode=pie). However, Go code built
with PC-rel relocations does not require the TOC pointer. A future
change could remove the overhead of maintaining a TOC pointer in those
build configurations.

This is enabled only for power10/ppc64le/linux.

A final noteworthy difference between the prefixed and regular load/store
instruction forms is the removal of the DS/DQ form restrictions. That
is, the immediate operand does not need to be aligned.

Updates #44549

Change-Id: If59c216d203c3eed963bfa08855e21771e6ed669
Reviewed-on: https://go-review.googlesource.com/c/go/+/355150
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>

15 months agodebug/macho: use saferio to read dynamic indirect symbols
Ian Lance Taylor [Mon, 27 Feb 2023 23:52:52 +0000 (15:52 -0800)]
debug/macho: use saferio to read dynamic indirect symbols

No test case because the problem can only happen for invalid data. Let
the fuzzer find cases like this.

For #47653
Fixes #58755

Change-Id: I5b95a21f47ec306ad90cd6221f0566c6f8b6c3ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/471835
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

15 months agocmd/asm: remove the incorrect check of LDADDx-like instructions
fanzha02 [Fri, 13 Jan 2023 06:22:34 +0000 (06:22 +0000)]
cmd/asm: remove the incorrect check of LDADDx-like instructions

According to the ARM Architecture Reference Manual, LDADDx-like
instructions can take rt as zr when the encode A bit is 0. They
are used by the alias STADDx-like instructions. The current
assembler adds incorrect constraints for them, which is rt can't
be zr when field.enc A is 0. This patch removes it.

Add test cases.

Reported by Matt Horsnell <matt.horsnell@arm.com>

The reference:
https://developer.arm.com/documentation/ddi0602/2022-12/Base-Instructions

Change-Id: Ia2487a5e3900e32994fc14edaf03deeb245e70c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/462295
Reviewed-by: Matt Horsnell <matthew.horsnell@gmail.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agonet,os: set the theoretical unlimited remaining bytes to max int64
Andy Pan [Mon, 27 Feb 2023 04:07:57 +0000 (12:07 +0800)]
net,os: set the theoretical unlimited remaining bytes to max int64

Based on https://go-review.googlesource.com/c/go/+/466015/comment/073a63fa_7a9e485f

Change-Id: I3e1b035de6b8217c5fa5695e436f164b3058e33c
Reviewed-on: https://go-review.googlesource.com/c/go/+/471439
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agoall: fix typos
pgxiaolianzi [Mon, 27 Feb 2023 06:51:55 +0000 (06:51 +0000)]
all: fix typos

Change-Id: Ica8d5e5799a4de532764ae86cdb623508d3a8e18
GitHub-Last-Rev: 3e97cca9de3885f2fe0d7deb776e59cc1c73146d
GitHub-Pull-Request: golang/go#58689
Reviewed-on: https://go-review.googlesource.com/c/go/+/471021
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

15 months agocmd/compile: omit redundant sign/unsign extension on arm64
ruinan [Thu, 18 Aug 2022 01:31:57 +0000 (01:31 +0000)]
cmd/compile: omit redundant sign/unsign extension on arm64

On Arm64, all 32-bit instructions will ignore the upper 32 bits and
clear them to zero for the result. No need to do an unsign extend before
a 32 bit op.

This CL removes the redundant unsign extension only for the existing
32-bit opcodes, and also omits the sign extension when the upper bit of
the result can be predicted.

Fixes #42162

Change-Id: I61e6670bfb8982572430e67a4fa61134a3ea240a
CustomizedGitHooks: yes
Reviewed-on: https://go-review.googlesource.com/c/go/+/427454
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Eric Fang <eric.fang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Eric Fang <eric.fang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agointernal/testdir: simplify and clean up
Dmitri Shuralyov [Mon, 6 Feb 2023 22:10:22 +0000 (17:10 -0500)]
internal/testdir: simplify and clean up

Now that the bare minimum change to make the run.go test runner into
a normal go test is done, there remain many opportunities to simplify,
modernize and generally clean up the test code.

Of all the opportunities available, this change tries to fit somewhere
between doing "not enough" and "way too much". This ends up including:

• replace verbose flag with testing.Verbose()
• replace custom temporary directory creation, removal, -keep flag
  with testing.T.TempDir
• replace custom code to find the go command with testenv.GoToolPath
• replace many instances of "t.err = err; return" with "return err",
  or with t.Fatal when it's clearly a test infrastructure error
• replace reliance on changing working directory to GOROOT/test to
  computing and using absolute paths
• replace uses of log.Fatal with t.Fatal
• replace uses of deprecated ioutil package with their replacements
• add some missing error checks, use more idiomatic identifier names

For #56844.

Change-Id: I5b301bb83a8e5b64cf211d7f2f4b14d38d48fea0
Reviewed-on: https://go-review.googlesource.com/c/go/+/466155
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

15 months agocmd/dist, test: convert test/run.go runner to a cmd/go test
Dmitri Shuralyov [Wed, 8 Feb 2023 16:40:06 +0000 (11:40 -0500)]
cmd/dist, test: convert test/run.go runner to a cmd/go test

As motivated on the issue, we want to move the functionality of the
run.go program to happen via a normal go test. Each .go test case in
the GOROOT/test directory gets a subtest, and cmd/go's support for
parallel test execution replaces run.go's own implementation thereof.

The goal of this change is to have fairly minimal and readable diff
while making an atomic changeover. The working directory is modified
during the test execution to be GOROOT/test as it was with run.go,
and most of the test struct and its run method are kept unchanged.
The next CL in the stack applies further simplifications and cleanups
that become viable.

There's no noticeable difference in test execution time: it takes around
60-80 seconds both before and after on my machine. Test caching, which
the previous runner lacked, can shorten the time significantly.

For #37486.
Fixes #56844.

Change-Id: I209619dc9d90e7529624e49c01efeadfbeb5c9ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/463276
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agomisc/cgo/{life,stdio}: remove reliance on test/run.go
Dmitri Shuralyov [Mon, 6 Feb 2023 18:44:32 +0000 (13:44 -0500)]
misc/cgo/{life,stdio}: remove reliance on test/run.go

The misc/cgo/life and misc/cgo/stdio tests started out as fairly simple
test cases when they were added, but the machinery to execute them has
grown in complexity over the years.

They currently reuse the test/run.go runner and its "run" action without
needing much of the additional flexibility that said runner implements.
Given that runner isn't well documented, it makes it harder to see that
ultimately these tests just do 'go run' on a few test programs and check
that the output matches a golden file.

Maybe these test cases should move out of misc to be near similar tests,
or the machinery to execute them can made available in a package that is
easier and safer to reuse. I'd rather not block the refactor of the test
directory runner on that, so for now rewrite these to be self-contained.

Also delete misc/cgo/stdio/testdata/run.out which has no effect on the
test. It was seemingly accidentally kept behind during the refactor in
CL 6220049.

For #56844.

Change-Id: I5e2f542824925092cdddb03b44b6295a4136ccb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/465755
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

15 months agocmd/compile/internal/noder: correct positions for synthetic closures
Matthew Dempsky [Tue, 14 Feb 2023 23:13:50 +0000 (15:13 -0800)]
cmd/compile/internal/noder: correct positions for synthetic closures

When inlining functions that contain function literals, we need to be
careful about position information. The OCLOSURE node should use the
inline-adjusted position, but the ODCLFUNC and its body should use the
original positions.

However, the same problem can arise with certain generic constructs,
which require the compiler to synthesize function literals to insert
dictionary arguments.

go.dev/cl/425395 fixed the issue with user-written function literals
in a somewhat kludgy way; this CL extends the same solution to
synthetic function literals.

This is all quite subtle and the solutions aren't terribly robust, so
longer term it's probably desirable to revisit how we track inlining
context for positions. But for now, this seems to be the least bad
solution, esp. for backporting to 1.20.

Updates #54625.
Fixes #58513.

Change-Id: Icc43a70dbb11a0e665cbc9e6a64ef274ad8253d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/468415
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

15 months agoos: don't try to put directory into non-blocking mode
Ian Lance Taylor [Fri, 18 Nov 2022 23:20:06 +0000 (15:20 -0800)]
os: don't try to put directory into non-blocking mode

Fixes #56843

Change-Id: I3cb3e8397499cd8c57a3edddd45f38c510519b36
Reviewed-on: https://go-review.googlesource.com/c/go/+/451997
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agonet/http: reduce calls to append in hexEscapeNonASCII to gain a slight performance...
Andy Pan [Wed, 24 Aug 2022 15:02:16 +0000 (23:02 +0800)]
net/http: reduce calls to append in hexEscapeNonASCII to gain a slight performance boost

goos: linux
goarch: amd64
pkg: net/http
cpu: DO-Premium-Intel
                    │     old      │                 new                 │
                    │    sec/op    │   sec/op     vs base                │
HexEscapeNonASCII-4   469.6n ± 20%   371.1n ± 9%  -20.98% (p=0.000 n=10)

                    │    old     │              new               │
                    │    B/op    │    B/op     vs base            │
HexEscapeNonASCII-4   192.0 ± 0%   192.0 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

                    │    old     │              new               │
                    │ allocs/op  │ allocs/op   vs base            │
HexEscapeNonASCII-4   2.000 ± 0%   2.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

Change-Id: Ic8d2b3ddcf2cf724dec3f51a2aba205f2c6e4fe6
Reviewed-on: https://go-review.googlesource.com/c/go/+/425786
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
15 months agoos: skip zero-copy attempts with copy_file_range(2)/splice(2) for target files with...
Andy Pan [Mon, 27 Feb 2023 04:47:39 +0000 (12:47 +0800)]
os: skip zero-copy attempts with copy_file_range(2)/splice(2) for target files with O_APPEND flag

Change-Id: I6cccac9295ab4a9bf7f7a33382a34f31b1c4a000
Reviewed-on: https://go-review.googlesource.com/c/go/+/471496
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>

15 months agocmd/go: convert mkalldocs.sh to a Go program
Bryan C. Mills [Wed, 15 Feb 2023 21:45:14 +0000 (16:45 -0500)]
cmd/go: convert mkalldocs.sh to a Go program

mkalldocs.sh required a Unix shell, making it less accessible for
contributors on Windows. It also used a substantially different
codepath to regenerate the file than the one used to check the file
for staleness, making failures in TestDocsUpToDate more complex to
diagnose.

We can solve both of those problems by using the same technique as in
checkScriptReadme: use the test itself as the generator to update the
file. The test is already written in Go, the test binary already knows
how to mimic the 'go' command, and this approach brings the difference
between the test and the generator down to a single flag check.

Updates #26735.

Change-Id: I7c6f65cb0e0c29e334e38a45412e0a73c4d31d42
Reviewed-on: https://go-review.googlesource.com/c/go/+/468636
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

15 months agocmd/compile: use zero constants in comparisons where possible
Michael Munday [Mon, 20 Sep 2021 20:39:39 +0000 (21:39 +0100)]
cmd/compile: use zero constants in comparisons where possible

Some integer comparisons with 1 and -1 can be rewritten as comparisons
with 0. For example, x < 1 is equivalent to x <= 0. This is an
advantageous transformation on riscv64 because comparisons with zero
do not require a constant to be loaded into a register. Other
architectures will likely benefit too and the transformation is
relatively benign on architectures that do not benefit.

Change-Id: I2ce9821dd7605a660eb71d76e83a61f9bae1bf25
Reviewed-on: https://go-review.googlesource.com/c/go/+/350831
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/go: reject list when -find and -export are used together
RenKanai [Sun, 27 Mar 2022 13:06:22 +0000 (22:06 +0900)]
cmd/go: reject list when -find and -export are used together

Fixes #51952.

Change-Id: If2cfc41d65373ca38cfb7b0396be8988d444eb5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/396074
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
15 months agocmd/compile: improve logical shift with MASKEQZ on loong64
Wayne Zuo [Thu, 1 Sep 2022 04:26:43 +0000 (12:26 +0800)]
cmd/compile: improve logical shift with MASKEQZ on loong64

Using MASKEQZ instruction can save one instruction in calculation of
shift operations.

Reference: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Change-Id: Ic5349c6f5ebd7af608c7d75a9b3a862305758275
Reviewed-on: https://go-review.googlesource.com/c/go/+/427396
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>

15 months agocmd/asm: preserve 3rd arg when GOT-rewriting assembly instructions
Keith Randall [Mon, 27 Feb 2023 16:53:34 +0000 (08:53 -0800)]
cmd/asm: preserve 3rd arg when GOT-rewriting assembly instructions

Fixes #58735

Change-Id: I7cc1c34ed8454553328d44b2ea72e4c0255b6ec1
Reviewed-on: https://go-review.googlesource.com/c/go/+/471675
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoruntime: set procid on Windows
qmuntal [Thu, 23 Feb 2023 13:15:28 +0000 (14:15 +0100)]
runtime: set procid on Windows

The runtime-gdb.py script needs procid to be set in order to
map a goroutine ID with an OS thread. The Go runtime is not currently
setting that variable on Windows, so TestGdbPython (and friends) can't
succeed.

This CL initializes procid and unskips gdb tests on Windows.

Fixes #22687
Updates #21380
Updates #22021

Change-Id: Icd1d9fc1764669ed1bf04f53d17fadfd24ac3f30
Reviewed-on: https://go-review.googlesource.com/c/go/+/470596
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>