]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
16 months agomisc: update go.mod to 1.21
David Chase [Tue, 24 Jan 2023 21:28:04 +0000 (16:28 -0500)]
misc: update go.mod to 1.21

Doing this allows updates to swig so it can access slices
and strings in a somewhat less-unsafe way.

Change-Id: If2af8f8cf58d2287569dcd7c7ce09728e20b5ff0
Reviewed-on: https://go-review.googlesource.com/c/go/+/463396
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

16 months agoRevert "runtime: use explicit NOFRAME on darwin/amd64"
Quim Muntal [Thu, 26 Jan 2023 07:48:04 +0000 (07:48 +0000)]
Revert "runtime: use explicit NOFRAME on darwin/amd64"

This reverts CL 460235.

Reason for revert: This breaks darwin 10 and 11

Change-Id: I3c663ebe3b77eba45a006a3ebec5cabe667faa9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/463635
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 months agocrypto/rand, internal/syscall/unix: add support for getrandom on NetBSD ≥ 10.0
Tobias Klauser [Wed, 25 Jan 2023 15:19:26 +0000 (16:19 +0100)]
crypto/rand, internal/syscall/unix: add support for getrandom on NetBSD ≥ 10.0

The getrandom syscall was added to NetBSD in version 10.0, see
https://man.netbsd.org/NetBSD-10.0-STABLE/getrandom.2

Change-Id: I2714c1040791f7f4728be8d869058a38cbd93d4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/463123
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
16 months agoruntime: use explicit NOFRAME on darwin/amd64
qmuntal [Mon, 2 Jan 2023 14:54:44 +0000 (15:54 +0100)]
runtime: use explicit NOFRAME on darwin/amd64

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

Change-Id: I797f3909bcf7f7aad304e4ede820c884231e54f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/460235
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
16 months agocmd/go/internal/vcs: fix outdated comment
Cameron Bedard [Thu, 26 Jan 2023 01:05:20 +0000 (01:05 +0000)]
cmd/go/internal/vcs: fix outdated comment

Function was was replaced in https://go.dev/cl/12143.

Fixes #57718

Change-Id: I56ff9390af9ae31803805fa27d2c08b5e1d842e1
GitHub-Last-Rev: b8c9dbccbc0b412fd7833d4df9d347953798b17b
GitHub-Pull-Request: golang/go#57767
Reviewed-on: https://go-review.googlesource.com/c/go/+/461610
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
16 months agonet/http: keep sensitive headers on redirects to the same host
Gustavo Falco [Sun, 11 Dec 2022 02:39:20 +0000 (02:39 +0000)]
net/http: keep sensitive headers on redirects to the same host

Preserve sensitive headers on a redirect to a different port of the same host.

Fixes #35104

Change-Id: I5ab57c414ce92a70e688ee684b9ff02fb062b3c6
GitHub-Last-Rev: 8d53e71e2243c141d70d27a503d0f7e6dee64c3c
GitHub-Pull-Request: golang/go#54539
Reviewed-on: https://go-review.googlesource.com/c/go/+/424935
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>

16 months agocmd/compile: change some unreachable code paths into Fatalf
Matthew Dempsky [Fri, 2 Dec 2022 00:33:59 +0000 (16:33 -0800)]
cmd/compile: change some unreachable code paths into Fatalf

Now that GOEXPERIMENT=nounified is removed, we can assume InlineCall
and HaveInlineBody will always be overridden with the unified
frontend's implementations. Similarly, we can assume expandDecl will
never be called.

This CL changes the code paths into Fatalfs, so subsequent CLs can
remove all the unreachable code.

Updates #57410.

Change-Id: I2a0c3edb32916c30dd63c4dce4f1bd6f18e07468
Reviewed-on: https://go-review.googlesource.com/c/go/+/458618
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
16 months agocmd/compile: remove -d=typecheckinl flag
Matthew Dempsky [Fri, 2 Dec 2022 00:43:05 +0000 (16:43 -0800)]
cmd/compile: remove -d=typecheckinl flag

This flag forced the compiler to eagerly type check all available
inline function bodies, which presumably was useful in the early days
of implementing inlining support. However, it shouldn't have any
significance with the unified frontend, since the same code paths are
used for constructing normal function bodies as for inlining.

Updates #57410.

Change-Id: I6842cf86bcd0fbf22ac336f2fc0b7b8fe14bccca
Reviewed-on: https://go-review.googlesource.com/c/go/+/458617
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

16 months agocmd/compile/internal/pkginit: remove dependency on typecheck.Resolve
Matthew Dempsky [Tue, 20 Dec 2022 20:00:36 +0000 (12:00 -0800)]
cmd/compile/internal/pkginit: remove dependency on typecheck.Resolve

The use of typecheck.Resolve was previously necessary to interoperate
with the non-unified frontend, because it hooked into iimport. It's no
longer necessary with unified IR, where we can just lookup the
".inittask" symbol and access Def directly.

Updates #57410.

Change-Id: I73bdfd53f65988ececd2b777743cd8b591a6db48
Reviewed-on: https://go-review.googlesource.com/c/go/+/458616
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
16 months agocmd/compile: improve register overwrite decision for resultInArg0 ops
Keith Randall [Thu, 5 Jan 2023 21:02:44 +0000 (13:02 -0800)]
cmd/compile: improve register overwrite decision for resultInArg0 ops

When we're compiling a resultInArg0 op, we need to clobber the
register containing the input value. So we first make a register copy
of the input value. We can then clobber either of the two registers
the value is in and still have the original input value in a register
for future uses.

Before this CL, we always clobbered the original, not the copy.
But that's not always the right decision - if the original is already
in a specific register that it needs to be in later (typically, a
return value register), clobber the copy instead.

This optimization can remove a mov instruction. It saves 1376 bytes
of instructions in cmd/go.

Redo of CL 460656, reverted at CL 463475, with a fix for s390x.

The new code just ensures that the copied value is in a register
which is a valid input register for the instruction.

Change-Id: Id570b8a60a6d2da9090de80a90b6bb0266e9e38a
Reviewed-on: https://go-review.googlesource.com/c/go/+/463221
Auto-Submit: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 months agoruntime: delete unused cbctxts variable on windows assembly
qmuntal [Wed, 25 Jan 2023 07:56:17 +0000 (08:56 +0100)]
runtime: delete unused cbctxts variable on windows assembly

runtime·cbctxts has been unused since CL 258938, but it was left over.

Change-Id: I374ad26e668a36994e41f5d17593b33090bdc644
Reviewed-on: https://go-review.googlesource.com/c/go/+/463119
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 months agocmd: remove GOEXPERIMENT=nounified knob
Matthew Dempsky [Fri, 2 Dec 2022 00:14:11 +0000 (16:14 -0800)]
cmd: remove GOEXPERIMENT=nounified knob

This CL removes the GOEXPERIMENT=nounified knob, and any conditional
statements that depend on that knob. Further CLs to remove unreachable
code follow this one.

Updates #57410.

Change-Id: I39c147e1a83601c73f8316a001705778fee64a91
Reviewed-on: https://go-review.googlesource.com/c/go/+/458615
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 months agocontext: eliminate arbitrary timeouts in examples
Bryan C. Mills [Tue, 10 Jan 2023 16:49:37 +0000 (11:49 -0500)]
context: eliminate arbitrary timeouts in examples

ExampleWithDeadline and ExampleWithTimeout used an arbitrary 1-second
timeout for a “blocked” select case, which could fail if the test
goroutine happens to be descheduled for over a second, or perhaps if
an NTP synchronization happens to jump by a second at just the right
time.

Either case is plausible, especially on a heavily-loaded or slow
machine (as is often the case for builders for unusual ports).

Instead of an arbitrary timeout, use a “ready” channel that is never
actually ready.

Fixes #57594.

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

16 months agoos: eliminate arbitrary timeout in testClosewithBlockingRead
Bryan C. Mills [Wed, 25 Jan 2023 16:53:03 +0000 (11:53 -0500)]
os: eliminate arbitrary timeout in testClosewithBlockingRead

The 1-second timeout on execution of this test is empirically too
short on some platforms. Rather than trying to tune the timeout, allow
the test to time out on its own (and dump goroutines) if it deadlocks.

Fixes #57993.
Fixes #57994.

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

16 months agocmd/link: don't export all symbols for ELF external linking
Ian Lance Taylor [Mon, 27 Jun 2022 21:58:58 +0000 (14:58 -0700)]
cmd/link: don't export all symbols for ELF external linking

Since this may add a large number of --export-dynamic-symbol options,
use a response file if the command line gets large.

Fixes #53579

Change-Id: Ic226bf372bf1e177a3dae886d1c48f4ce3569c0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/414654
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

16 months agoRevert "cmd/compile: improve register overwrite decision for resultInArg0 ops"
Keith Randall [Wed, 25 Jan 2023 19:08:14 +0000 (19:08 +0000)]
Revert "cmd/compile: improve register overwrite decision for resultInArg0 ops"

This reverts CL 460656
Reason for revert: This breaks s390x.

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

16 months agocmd/compile: improve register overwrite decision for resultInArg0 ops
Keith Randall [Thu, 5 Jan 2023 21:02:44 +0000 (13:02 -0800)]
cmd/compile: improve register overwrite decision for resultInArg0 ops

When we're compiling a resultInArg0 op, we need to clobber the
register containing the input value. So we first make a register copy
of the input value. We can then clobber either of the two registers
the value is in and still have the original input value in a register
for future uses.

Before this CL, we always clobbered the original, not the copy.
But that's not always the right decision - if the original is already
in a specific register that it needs to be in later (typically, a
return value register), clobber the copy instead.

This optimization can remove a mov instruction. It saves 1376 bytes
of instructions in cmd/go.

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

16 months agointernal/testpty: fix error handling
Heschi Kreinick [Wed, 25 Jan 2023 17:48:54 +0000 (12:48 -0500)]
internal/testpty: fix error handling

When calling a c library function, you discover that an error has
occurred, typically by looking at the return value of the function. Only
after that can you use errno to figure out the cause of the error.

Nothing about cgo changes that story -- you still have to look at the
result before checking the error that represents errno. If not you can
get false errors if the function happens to leak a non-zero errno.

Fix testpty to check errors correctly.

Change-Id: Idb95f8dd6a8ed63f653190c2e722e742cf50542b
Reviewed-on: https://go-review.googlesource.com/c/go/+/463397
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

16 months agocmd/compile: revert package typecheck part of CL 422914
Matthew Dempsky [Fri, 2 Dec 2022 01:32:47 +0000 (17:32 -0800)]
cmd/compile: revert package typecheck part of CL 422914

This code path is unreachable anyway, and it adds new uses of
Type.Pkg, which shouldn't be used anymore.

Mark Type.Pkg as deprecated while here.

Updates #57410.

Change-Id: I1eec1c8ed99207d58d0ba0c44822bbad29dc64f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/458575
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 months agocmd/go/internal/str: fix PathPrefix functions for root directories
Bryan C. Mills [Fri, 20 Jan 2023 19:40:09 +0000 (14:40 -0500)]
cmd/go/internal/str: fix PathPrefix functions for root directories

For #51506.
For #50807.

Change-Id: I4c0ae85a2103ac4f07351a4f01ce24fa02f03104
Reviewed-on: https://go-review.googlesource.com/c/go/+/463176
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
16 months agoos: make Lstat for symlinks on Windows consistent with POSIX
Bryan C. Mills [Tue, 24 Jan 2023 14:05:36 +0000 (09:05 -0500)]
os: make Lstat for symlinks on Windows consistent with POSIX

This also makes path/filepath.Walk more consistent between
Windows and POSIX platforms.

According to
https://pubs.opengroup.org/onlinepubs/9699919799.2013edition/basedefs/V1_chap04.html#tag_04_12
symlinks in a path that includes a trailing slash must be resolved
before a function acts on that path.

POSIX defines an lstat function, whereas the Win32 API does not, so
Go's os.Lstat should follow the (defined) POSIX semantics instead of
doing something arbitrarily different.

CL 134195 added a test for the correct POSIX behavior when os.Lstat is
called on a symlink. However, the test turned out to be broken on Windows,
and when it was fixed (in CL 143578) it was fixed with different Lstat
behavior on Windows than on all other platforms that support symlinks.

In #50807 we are attempting to provide consistent symlink behavior for
cmd/go. This unnecessary platform difference, if left uncorrected,
will make that fix much more difficult.

CL 460595 reworked the implementation of Stat and Lstat on Windows,
and with the new implementation this fix is straightforward.

For #50807.
Updates #27225.

Change-Id: Ia28821aa4aab6cefa021da2d9b803506cdb2621b
Reviewed-on: https://go-review.googlesource.com/c/go/+/463177
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>

16 months agoruntime: mark amd64 runtime·rt0_go as NOFRAME
qmuntal [Wed, 25 Jan 2023 08:21:06 +0000 (09:21 +0100)]
runtime: mark amd64 runtime·rt0_go as NOFRAME

This CL adds the NOFRAME flag to runtime·rt0_go, which should
had been added in CL 459395 but didn't and broke fix windows-amd64-2008.

Change-Id: I4583f2034bf114e1f7aaddef9ba505f53536c3eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/463120
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 months agoruntime/race: update race_windows_amd64.syso
Than McIntosh [Thu, 28 Jul 2022 09:07:02 +0000 (05:07 -0400)]
runtime/race: update race_windows_amd64.syso

Update race_windows_amd64.syso to latest tsan (V3) runtime.

This version of the runtime depends on libsynchronization.a, so to
use this syso, you need to also be using a sufficiently up to date
version of GCC (notably GCC 5.1, installed on the Go windows builders
right now, does not include this library).

Updates #48231.
Updates #35006.
Fixes #49761.

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

16 months agoos: have RemoveAll loop on EINTR
Nigel Tao [Mon, 23 Jan 2023 22:49:36 +0000 (09:49 +1100)]
os: have RemoveAll loop on EINTR

Fixes #57966

Change-Id: Ia732d499ff9bd6e70030daab8fac42d1e204be37
Reviewed-on: https://go-review.googlesource.com/c/go/+/463076
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Nigel Tao (INACTIVE; USE @golang.org INSTEAD) <nigeltao@google.com>
16 months agosyscall: clean up variable declarations in forkAndExecInChild
Bryan C. Mills [Fri, 9 Dec 2022 17:30:24 +0000 (12:30 -0500)]
syscall: clean up variable declarations in forkAndExecInChild

The various forkAndExecInChild implementations have comments
explaining that they pre-declare variables to force allocations
to occur before forking, but then later use ":=" declarations
for additional variables.

To make it clearer that those ":=" declarations do not allocate,
we move their declarations up to the predeclared blocks.

For #57208.

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

16 months agosyscall: export X__ifi_pad and X_f on s390x and riscv64
Bryan C. Mills [Wed, 14 Dec 2022 19:36:46 +0000 (14:36 -0500)]
syscall: export X__ifi_pad and X_f on s390x and riscv64

This brings the exported field names on these GOARCHes
in line with the other supported linux platforms.

Fixes #57313.

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

16 months agotest/codegen: accept ppc64x as alias for ppc64le and ppc64 arches
Paul E. Murphy [Wed, 18 Jan 2023 21:20:15 +0000 (15:20 -0600)]
test/codegen: accept ppc64x as alias for ppc64le and ppc64 arches

This helps simplify the noise when adding ppc codegen tests. ppc64x
is used in other places to indicate something which runs on either
endian.

This helps cleanup existing codegen tests which are mostly
identical between endian variants.

condmove tests are converted as an example.

Change-Id: I2b2d98a9a1859015f62db38d62d9d5d7593435b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/462895
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>

16 months agoruntime/cgo: use //go:build lines in C and assembly files
Tobias Klauser [Tue, 24 Jan 2023 09:16:42 +0000 (10:16 +0100)]
runtime/cgo: use //go:build lines in C and assembly files

Replace deprecated // +build lines by their respective //go:build line
counterpart. Also remove build constraints implied by file name or type.

Change-Id: I8d18cd40071ca28d7654da8f0d22841f43729ca6
Reviewed-on: https://go-review.googlesource.com/c/go/+/460538
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
16 months agobytes, strings: add ContainsFunc
hopehook [Tue, 3 Jan 2023 08:23:16 +0000 (16:23 +0800)]
bytes, strings: add ContainsFunc

Fixes #54386.

Change-Id: I78747da337ed6129e4f7426dd0483a644bed82e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/460216
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: hopehook <hopehook@golangcn.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

16 months agoencoding/gob: slightly simplify init code
Daniel Martí [Fri, 20 Jan 2023 21:53:34 +0000 (21:53 +0000)]
encoding/gob: slightly simplify init code

https://go.dev/cl/460543 stopped using the "expect" parameter in
bootstrapType, but we forgot to actually remove it.

While here, staticcheck correctly points out that we can use the copy
builtin to fill builtinIdToTypeSlice, now that it and idToType are an
array and slice respectively.

Change-Id: I48078415ab9bdd5633cf41f33ab4dc78eb30b48a
Reviewed-on: https://go-review.googlesource.com/c/go/+/462301
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
16 months agotest: remove TODO in issue20250.go
Matthew Dempsky [Tue, 10 Jan 2023 23:22:11 +0000 (15:22 -0800)]
test: remove TODO in issue20250.go

This has been investigated and explained on the issue tracker.

Fixes #54402.

Change-Id: I4d8b971faa810591983ad028b7db16411f3b3b4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/461456
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
16 months agoruntime: use explicit NOFRAME on windows/amd64
qmuntal [Fri, 23 Dec 2022 12:22:00 +0000 (13:22 +0100)]
runtime: use explicit NOFRAME on windows/amd64

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

Updates #57302
Updates #40044

Change-Id: Ia4d26f8420dcf2b54528969ffbf40a73f1315d61
Reviewed-on: https://go-review.googlesource.com/c/go/+/459395
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
16 months agocmd/link: support R_ADDRPOWER_GOT_PCREL34 on ppc64le
Paul E. Murphy [Fri, 20 Jan 2023 23:20:07 +0000 (17:20 -0600)]
cmd/link: support R_ADDRPOWER_GOT_PCREL34 on ppc64le

This will be generated by go code built for dynamic linking when
built with GOPPC64=power10 in a future change.

Change-Id: I9bd7ca6b2a65c360465e35ef12b10d3fa6d75745
Reviewed-on: https://go-review.googlesource.com/c/go/+/463015
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
16 months agoruntime: switch AMD64's publicationBarrier to ABIInternal
Jakub Ciolek [Wed, 18 Jan 2023 09:54:17 +0000 (10:54 +0100)]
runtime: switch AMD64's publicationBarrier to ABIInternal

Shrinks a few runtime functions:

runtime
runtime.mallocgc 2127 -> 2117  (-0.47%)
runtime.(*mheap).initSpan 652 -> 639  (-1.99%)
runtime.(*mspan).userArenaNextFree 825 -> 808  (-2.06%)

file      before   after    Δ       %
runtime.s 512473   512414   -59     -0.012%
total     20843331 20843272 -59     -0.000%

Change-Id: Ifaca7abb6db3467b73945fac71496dd7527e6863
Reviewed-on: https://go-review.googlesource.com/c/go/+/462296
Auto-Submit: Keith Randall <khr@golang.org>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
16 months agomath: handle int64 overflows for odd integer exponents in Pow(-0, y)
Dmitry Panov [Wed, 28 Dec 2022 23:05:26 +0000 (23:05 +0000)]
math: handle int64 overflows for odd integer exponents in Pow(-0, y)

The existing implementation does a float64 to int64 conversion in order to check whether the number is odd, however it does not check for overflows. If an overflow occurs, the result is implementation-defined and while it happens to work on amd64 and i386, it produces an incorrect result on arm64 and possibly other architectures.

This change fixes that and also avoids calling isOddInt altogether if the base is +0, because it's unnecessary.

(I was considering avoiding the extra check if runtime.GOARCH is "amd64" or "i386", but I can't see this pattern being used anywhere outside the tests. And having separate files with build tags just for isOddInt() seems like an overkill)

Fixes #57465

Change-Id: Ieb243796194412aa6b98fac05fd19766ca2413ef
GitHub-Last-Rev: 3bfbd85c4cd6c5dc3d15239e180c99764a19ca88
GitHub-Pull-Request: golang/go#57494
Reviewed-on: https://go-review.googlesource.com/c/go/+/459815
Auto-Submit: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Bypass: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
16 months agoall: fix some comments
cui fliter [Tue, 24 Jan 2023 01:20:13 +0000 (09:20 +0800)]
all: fix some comments

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

16 months agoRevert "cmd/compile: teach prove about bitwise OR operation"
Keith Randall [Tue, 24 Jan 2023 16:11:06 +0000 (16:11 +0000)]
Revert "cmd/compile: teach prove about bitwise OR operation"

This reverts commit 3680b5e9c4f42fcf9155aa42b3b344d1fbe19571.

Reason for revert: causes long compile times on certain functions. See issue #57959

Change-Id: Ie9e881ca8abbc79a46de2bfeaed0b9d6c416ed42
Reviewed-on: https://go-review.googlesource.com/c/go/+/463295
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
16 months agogo/types, types2: refuse pointer to array as argument to "clear" builtin
Cuong Manh Le [Sat, 21 Jan 2023 07:53:47 +0000 (14:53 +0700)]
go/types, types2: refuse pointer to array as argument to "clear" builtin

The accepted proposal only permits map and slice types.

Updates #56351

Change-Id: I95cf4c856a5ecfcdf564601b6215eda3cb6ba86b
Reviewed-on: https://go-review.googlesource.com/c/go/+/463075
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

16 months agocmd/link: remove importcycles function
Jeremy Quirke [Mon, 26 Dec 2022 04:07:03 +0000 (04:07 +0000)]
cmd/link: remove importcycles function

The importcycles method has not been useful since April 2016 when a large code deletion was performed.

The compiler itself provides some protection against import cycles, and the linker does import cycle detection in linksetup -> postorder.

For #57400

Change-Id: I3095bdb3f16a82ba25681bf4a20ceaa3c9613921
GitHub-Last-Rev: 87a46153b136db67675874ffe46e5881b9c756ce
GitHub-Pull-Request: golang/go#57462
Reviewed-on: https://go-review.googlesource.com/c/go/+/459475
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

16 months agocmd/compile: flag 'large' functions when -m=2+ in effect
Than McIntosh [Tue, 3 Jan 2023 18:11:10 +0000 (13:11 -0500)]
cmd/compile: flag 'large' functions when -m=2+ in effect

When -m=N (where N > 1) is in effect, include a note in the trace
output if a given function is considered "big" during inlining
analysis, since this causes the inliner to be less aggressive. If a
small change to a large function happens to nudge it over the large
function threshold, it can be confusing for developers, thus it's
probably worth including this info in the remark output.

Change-Id: Id31a1b76371ab1ef9265ba28a377f97b0247d0a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/460317
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Keith Randall <khr@google.com>
16 months agoos: use handle based APIs to read directories on windows
qmuntal [Tue, 22 Nov 2022 17:46:35 +0000 (18:46 +0100)]
os: use handle based APIs to read directories on windows

This CL updates File.readdir() on windows so it uses
GetFileInformationByHandleEx with FILE_ID_BOTH_DIR_INFO
instead of Find* APIs. The former is more performant because
it allows us to buffer IO calls and reduces the number of system calls,
passing from 1 per file to 1 every ~100 files
(depending on the size of the file name and the size of the buffer).

This change improve performance of File.ReadDir by 20-30%.

name        old time/op    new time/op    delta
ReadDir-12     562µs ±14%     385µs ± 9%  -31.60%  (p=0.000 n=9+9)

name        old alloc/op   new alloc/op   delta
ReadDir-12    29.7kB ± 0%    29.5kB ± 0%   -0.88%  (p=0.000 n=8+10)

name        old allocs/op  new allocs/op  delta
ReadDir-12       399 ± 0%       397 ± 0%   -0.50%  (p=0.000 n=10+10)

This change also speeds up calls to os.SameFile when using FileStats
returned from File.readdir(), as their file ID can be inferred while
reading the directory.

Change-Id: Id56a338ee66c39656b564105cac131099218fb5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/452995
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
16 months agoruntime: remove unused badsignal2 on windows
qmuntal [Mon, 23 Jan 2023 11:59:29 +0000 (12:59 +0100)]
runtime: remove unused badsignal2 on windows

This CL removes badsignal2 function, as it is unused on Windows.

badsignal2 was originally intended to abort the process when
an exception was raised on a non-Go thread, following the same approach
as Linux and others.

Since it was added, back on https://golang.org/cl/5797068, it has caused
several issues on Windows, see #8224 and #50877. That's because we can't
know wether the signal is bad or not, as our trap might not be at the
end of the exception handler chain.

To fix those issues, https://golang.org/cl/104200046 and CL 442896
stopped calling badsignal2, and CL 458135 removed one last incorrect
call on amd64 and 386.

Change-Id: I5bd31ee2672118ae0f1a2c8b46a1bb0f4893a011
Reviewed-on: https://go-review.googlesource.com/c/go/+/463116
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

16 months agoruntime: factor out windows sigtramp
qmuntal [Fri, 16 Dec 2022 15:54:03 +0000 (16:54 +0100)]
runtime: factor out windows sigtramp

This CL factors out part of the Windows sigtramp implementation, which
was duplicated in all four architectures. The new common code is
implemented in Go rather than in assembly, which will make Windows
error handling easier to reason and maintain.

While here, implement the control flow guard workaround on
windows/386, which almost comes for free.

Change-Id: I0bf38c28c54793225126e161bd95527a62de05e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/458135
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
16 months agoruntime: run TestVectoredHandlerDontCrashOnLibrary on 386 and arm64
qmuntal [Mon, 23 Jan 2023 14:13:20 +0000 (15:13 +0100)]
runtime: run TestVectoredHandlerDontCrashOnLibrary on 386 and arm64

This CL updates TestVectoredHandlerDontCrashOnLibrary so it can run on
windows/386 and windows/arm64. It still can't run on windows/arm as
it does not support c-shared buildmode (see #43800).

Change-Id: Id1577687e165e77d27633c632634ecf86e6e9d6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/463117
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 months agopath/filepath: remove extra Clean call in EvalSymlinks on Windows
qmuntal [Thu, 1 Dec 2022 20:59:00 +0000 (21:59 +0100)]
path/filepath: remove extra Clean call in EvalSymlinks on Windows

EvalSymlinks calls Clean twice, one in walkSymlinks and another in
toNorm. The later is not necessary, as toNorm is only called by
EvalSymlinks and just after walkSymlinks cleans the path without any
path manipulation in between.

Change-Id: Ibdb782c7eed59468f0ebb913e98d2a7db0df010d
Reviewed-on: https://go-review.googlesource.com/c/go/+/454615
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>

16 months agoarchive: error check when parse archive
James Yang [Fri, 6 Jan 2023 08:44:28 +0000 (08:44 +0000)]
archive: error check when parse archive

Add error check when call `r.parseObject` in `parseArchive`.

Change-Id: Ib1739f25941262593cf63837e272b6ee896d8613
GitHub-Last-Rev: 5a17f9aa2c7406e191a518fdac6cb519a425fd09
GitHub-Pull-Request: golang/go#57624
Reviewed-on: https://go-review.googlesource.com/c/go/+/460755
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

16 months agocmd/compile/internal/pgo: gofmt and simplify
Koichi Shiraishi [Mon, 31 Oct 2022 23:19:34 +0000 (08:19 +0900)]
cmd/compile/internal/pgo: gofmt and simplify

Change-Id: I29621cb6a3845917e7558be28579fe0e1b2d5afa
Reviewed-on: https://go-review.googlesource.com/c/go/+/446776
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>

16 months agoos: treat non-symlink reparse points as irregular files
Bryan C. Mills [Wed, 4 Jan 2023 22:23:46 +0000 (17:23 -0500)]
os: treat non-symlink reparse points as irregular files

Prior to this change (as of CL 143578), our stat function attempted to
resolve all reparse points as if they were symlinks.

This results in an additional call to CreateFile when statting a
symlink file: we use CreateFile once to obtain the reparse tag and
check whether the file is actually a symlink, and if it is we call
CreateFile again without FILE_FLAG_OPEN_REPARSE_POINT to stat the link
target. Fortunately, since symlinks are rare on Windows that overhead
shouldn't be a big deal in practice.

Fixes #42919.

Change-Id: If453930c6e98040cd6525ac4aea60a84498c9579
Reviewed-on: https://go-review.googlesource.com/c/go/+/460595
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

16 months agoutf16: reduce utf16.Decode allocations
qmuntal [Fri, 25 Nov 2022 13:22:36 +0000 (14:22 +0100)]
utf16: reduce utf16.Decode allocations

This CL avoids allocating in utf16.Decode for code point sequences
with less than 64 elements. It does so by splitting the function in two,
one that can be inlined that preallocates a buffer and the other that
does the heavy-lifting.

The mid-stack inliner will allocate the buffer in the caller stack,
and in many cases this will be enough to avoid the allocation.

unicode/utf16 benchmarks:

name                         old time/op    new time/op    delta
DecodeValidASCII-12            60.1ns ± 3%    16.0ns ±20%   -73.40%  (p=0.000 n=8+10)
DecodeValidJapaneseChars-12    61.3ns ±10%    14.9ns ±39%   -75.71%  (p=0.000 n=10+10)

name                         old alloc/op   new alloc/op   delta
DecodeValidASCII-12             48.0B ± 0%      0.0B       -100.00%  (p=0.000 n=10+10)
DecodeValidJapaneseChars-12     48.0B ± 0%      0.0B       -100.00%  (p=0.000 n=10+10)

name                         old allocs/op  new allocs/op  delta
DecodeValidASCII-12              1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
DecodeValidJapaneseChars-12      1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)

I've also benchmarked os.File.ReadDir with this change applied
to demonstrate that it does make a difference in the caller site, in this
case via syscall.UTF16ToString:

name        old time/op    new time/op    delta
ReadDir-12     592µs ± 8%     620µs ±16%     ~     (p=0.280 n=10+10)

name        old alloc/op   new alloc/op   delta
ReadDir-12    30.4kB ± 0%    22.4kB ± 0%  -26.10%  (p=0.000 n=8+10)

name        old allocs/op  new allocs/op  delta
ReadDir-12       402 ± 0%       272 ± 0%  -32.34%  (p=0.000 n=10+10)

Change-Id: I65cf5caa3fd3b3a466c0ed837a50a96e975bbe6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/453415
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>

16 months agointernal/abi: repair broken self-bootstrap
David Chase [Mon, 23 Jan 2023 18:29:32 +0000 (13:29 -0500)]
internal/abi: repair broken self-bootstrap

Fixes bug caused by https://go.dev/cl/462115

Change-Id: Id91a139db827f2962be837b8fd218e7b895ce8b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/463175
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

16 months agoruntime: enable sha512 optimizations on arm64 via hwcaps.
Matt Horsnell [Fri, 13 Jan 2023 10:54:28 +0000 (10:54 +0000)]
runtime: enable sha512 optimizations on arm64 via hwcaps.

Change-Id: I9d88c8eb91106de412a9abc6601cdda06537d818
Reviewed-on: https://go-review.googlesource.com/c/go/+/461747
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>

16 months agocmd/compile: teach prove about unsigned division, modulus and rsh
Jorropo [Sun, 4 Dec 2022 20:41:47 +0000 (21:41 +0100)]
cmd/compile: teach prove about unsigned division, modulus and rsh

Fixes: #57077
Change-Id: Icffcac42e28622eadecdba26e3cd7ceca6c4aacc
Reviewed-on: https://go-review.googlesource.com/c/go/+/455095
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
16 months agomath/big: validate result of Float.GobDecode
Alexander Yastrebov [Mon, 23 Jan 2023 16:52:33 +0000 (16:52 +0000)]
math/big: validate result of Float.GobDecode

Fixes #57946

Change-Id: Ia499ebfd8801432122f89fdf6bda4d1e7b6dd832
GitHub-Last-Rev: 29e099388680bc5b7075e0fa63499b39697579ca
GitHub-Pull-Request: golang/go#57951
Reviewed-on: https://go-review.googlesource.com/c/go/+/463017
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
16 months agoruntime,cmd/internal/obj/x86: use TEB TLS slots on windows/i386
qmuntal [Fri, 2 Dec 2022 08:25:26 +0000 (09:25 +0100)]
runtime,cmd/internal/obj/x86: use TEB TLS slots on windows/i386

This CL redesign how we get the TLS pointer on windows/i386.
It applies the same changes as done in CL 431775 for windows/amd64.

We were previously reading it from the [TEB] arbitrary data slot,
located at 0x14(FS), which can only hold 1 TLS pointer.

With this CL, we will read the TLS pointer from the TEB TLS slot array,
located at 0xE10(GS). The TLS slot array can hold multiple
TLS pointers, up to 64, so multiple Go runtimes running on the
same thread can coexists with different TLS.

Each new TLS slot has to be allocated via [TlsAlloc],
which returns the slot index. This index can then be used to get the
slot offset from GS with the following formula: 0xE10 + index*4.

The slot index is fixed per Go runtime, so we can store it
in runtime.tls_g and use it latter on to read/update the TLS pointer.

Loading the TLS pointer requires the following asm instructions:

  MOVQ runtime.tls_g, AX
  MOVQ AX(FS), AX

Notice that this approach will now be implemented in all the supported
windows arches.

[TEB]: https://en.wikipedia.org/wiki/Win32_Thread_Information_Block
[TlsAlloc]: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-tlsalloc

Change-Id: If4550b0d44694ee6480d4093b851f4991a088b32
Reviewed-on: https://go-review.googlesource.com/c/go/+/454675
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

16 months agocmd/compile: make loopbce handle 8, 16 and 32 bit induction variables
Jakub Ciolek [Mon, 3 Oct 2022 16:08:29 +0000 (18:08 +0200)]
cmd/compile: make loopbce handle 8, 16 and 32 bit induction variables

Compute limits and increment values for all integer widths.
Resolves 2 TODO's in loopbce.go

compilecmp linux/amd64:

compress/flate
compress/flate.(*huffmanEncoder).bitCounts 1235 -> 1207  (-2.27%)

cmd/internal/obj/wasm
cmd/internal/obj/wasm.assemble 7443 -> 7303  (-1.88%)
cmd/internal/obj/wasm.assemble.func1 165 -> 138  (-16.36%)

cmd/link/internal/ld
cmd/link/internal/ld.(*Link).findfunctab.func1 1646 -> 1627  (-1.15%)

Change-Id: I2d79b7376eb67d6bcc8fdaf0c197c11e631562d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/435258
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
16 months agoruntime: remove duplicate check of work.full in gcMark.
j2gg0s [Wed, 18 Jan 2023 15:08:29 +0000 (15:08 +0000)]
runtime: remove duplicate check of work.full in gcMark.

Change-Id: I659669d7259e7cf73f730232cda11d8525a4aabc
GitHub-Last-Rev: 5d183e81285aba64f1f76e5bddbe2f0ae012b138
GitHub-Pull-Request: golang/go#57901
Reviewed-on: https://go-review.googlesource.com/c/go/+/462281
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
16 months agointernal/abi,runtime: refactor map constants into one place
David Chase [Fri, 13 Jan 2023 21:12:47 +0000 (16:12 -0500)]
internal/abi,runtime: refactor map constants into one place

Previously TryBot-tested with bucket bits = 4.
Also tested locally with bucket bits = 5.
This makes it much easier to change the size of map
buckets, and hopefully provides pointers to all the
code that in some way depends on details of map layout.

Change-Id: I9f6669d1eadd02f182d0bc3f959dc5f385fa1683
Reviewed-on: https://go-review.googlesource.com/c/go/+/462115
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Austin Clements <austin@google.com>
16 months agoruntime: use copy as spotted by staticcheck
Daniel Martí [Sat, 21 Jan 2023 22:41:49 +0000 (22:41 +0000)]
runtime: use copy as spotted by staticcheck

Change-Id: Ibffe46bad7d30df9380ba18d49eeb6782406a1aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/463115
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
16 months agotest: test that we schedule OpArgIntReg early
Keith Randall [Fri, 20 Jan 2023 21:54:36 +0000 (13:54 -0800)]
test: test that we schedule OpArgIntReg early

If OpArgIntReg is incorrectly scheduled, that causes it to be spilled
incorrectly, which causes the argument to not be considered live
at the start of the function.

This is the test for CL 462858

Add a brief mention of why CL 462858 is needed in the scheduling code.

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

16 months agocmd/compile: sort liveness variable reports
Keith Randall [Fri, 20 Jan 2023 21:36:51 +0000 (13:36 -0800)]
cmd/compile: sort liveness variable reports

Sort variables before display so that when there are multiple variables
to report, they are in a consistent order.

Otherwise they are ordered in the order they appear in the fn.Dcl list,
which can vary. Particularly, they vary depending on regabi.

Change-Id: I0db380f7cbe6911e87177503a4c3b39851ff1b5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/462898
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 months agonet: add testing.Short Skip to test affected by local network configuration
David Chase [Mon, 9 Jan 2023 18:36:36 +0000 (13:36 -0500)]
net: add testing.Short Skip to test affected by local network configuration

If the local network mangles invalid DNS queries, that is not a Go problem.

Change-Id: I54db392532eed988bca81b70a98cd6d11766af89
Reviewed-on: https://go-review.googlesource.com/c/go/+/461275
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

16 months agobytes,strings: add some examples
fangguizhen [Fri, 20 Jan 2023 09:43:40 +0000 (09:43 +0000)]
bytes,strings: add some examples

Change-Id: Ic93ad59119f3549c0f13c4f366f71e9d01b88c47
GitHub-Last-Rev: afb518047288976f440d3fe0d65923c1905a9b26
GitHub-Pull-Request: golang/go#57907
Reviewed-on: https://go-review.googlesource.com/c/go/+/462283
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

16 months agopath/filepath: fix evaluation of symlinks to paths under /tmp on macOS
matsuyoshi30 [Wed, 18 Jan 2023 15:45:18 +0000 (00:45 +0900)]
path/filepath: fix evaluation of symlinks to paths under /tmp on macOS

For symlinks created from symlinks under the root directory created
as the relative path (e.g., symbolic links under /tmp), we update vol and volLen.

Fixes #57905

Change-Id: I45affd1db3b93109de51bf19b181f3cdba061109
Reviewed-on: https://go-review.googlesource.com/c/go/+/461761
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
16 months agoerrors: move example functions into example_test file
fangguizhen [Thu, 19 Jan 2023 23:21:59 +0000 (23:21 +0000)]
errors: move example functions into example_test file

Change-Id: Ide70476698d82a51881802dd6bf05dd7abcd60e8
GitHub-Last-Rev: ddb251ded669d3dbbb96a05f4df7151c8d7c16d2
GitHub-Pull-Request: golang/go#57931
Reviewed-on: https://go-review.googlesource.com/c/go/+/462292
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

16 months agointernal/coverage/decodemeta: fix coding error in func literal handling
Than McIntosh [Fri, 20 Jan 2023 19:03:43 +0000 (14:03 -0500)]
internal/coverage/decodemeta: fix coding error in func literal handling

Fix a coding error in coverage meta-data decoding in the method
decodemeta.CoverageMetaDataDecoder.ReadFunc. The code was not
unconditionally assigning the "function literal" field of the
coverage.FuncDesc object passed in, resulting in bad values depending
on what the state of the field happened to be in the object.

Fixes #57942.

Change-Id: I6dfd7d7f7af6004f05c622f9a7116e9f6018cf4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/462955
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 months agoruntime/coverage: avoid non-test coverage profiles in test report helper
Than McIntosh [Thu, 19 Jan 2023 15:16:07 +0000 (10:16 -0500)]
runtime/coverage: avoid non-test coverage profiles in test report helper

When walking through the set of coverage data files generated from a
"go test -cover" run, it's possible to encounter pods (clumps of data
files) that were generated by a run from an instrumented Go tool (for
example, cmd/compile). Add a guard to the test reporting code to
ensure that it only processes files created by the currently running
test.

Fixes #57924.

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

16 months agocontext: add APIs for setting a cancelation cause when deadline or timer expires
Sameer Ajmani [Thu, 10 Nov 2022 14:38:50 +0000 (09:38 -0500)]
context: add APIs for setting a cancelation cause when deadline or timer expires

Fixes #56661

Change-Id: I1c23ebc52e6b7ae6ee956614e1a0a45d6ecbd5b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/449318
Run-TryBot: Sameer Ajmani <sameer@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

16 months agogo/types: add a test that generated files match types2
Robert Findley [Wed, 18 Jan 2023 18:08:49 +0000 (13:08 -0500)]
go/types: add a test that generated files match types2

Adjust the go/types file generation to run in a test, so that we can
easily reuse the existing logic to verify that the current content of
go/types matches the expected result of generating from types2.

This test will enforce that we don't forget to regenerate go/types when
making changes to types2.

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

16 months agocmd/link: fix incorrect DOS header on Windows binaries
Kevin Parsons [Tue, 17 Jan 2023 08:02:17 +0000 (08:02 +0000)]
cmd/link: fix incorrect DOS header on Windows binaries

The previous DOS header placed on Windows binaries was incorrect, as it had e_crlc (number of relocations) set to 4, instead of e_cparhdr (size of header in 16-bit words) set to 4. This resulted in execution starting at the beginning of the file, instead of where the DOS stub code actually exists.

Fixes #57834

Change-Id: I8c5966b65c72b2474b771b85aaadb61cad9f5be6
GitHub-Last-Rev: c715ad290a01218a1320834e519125e7a5f94384
GitHub-Pull-Request: golang/go#57835
Reviewed-on: https://go-review.googlesource.com/c/go/+/462054
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
16 months agocmd/compile: ensure register args come before on-stack args in schedule
Keith Randall [Fri, 20 Jan 2023 18:36:19 +0000 (10:36 -0800)]
cmd/compile: ensure register args come before on-stack args in schedule

The register allocator doesn't like OpArg coming in between other
OpIntArg operations, as it doesn't put the spills in the right place
in that situation.

This is just a bug in the new scheduler, I didn't copy over the
proper score from the old scheduler correctly.

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

16 months agosync: document memory model for Swap/CompareAnd{Swap,Delete} in Map
Changkun Ou [Wed, 28 Dec 2022 14:04:58 +0000 (15:04 +0100)]
sync: document memory model for Swap/CompareAnd{Swap,Delete} in Map

CL 381316 documented the memory model of Map's APIs. However, the newly
introduced Swap, CompareAndSwap, and CompareAndDelete are missing from
this documentation as CL 399094 did not add this info.

This CL specifies the defined read/write operations of the new Map APIs.

For #51972

Change-Id: I519a04040a0b429a3f978823a183cd62e42c90ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/459715
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Changkun Ou <mail@changkun.de>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
16 months agogo/types, types2: use go.dev/issue/nnnnn when referring to an issue (cleanup)
Robert Griesemer [Thu, 19 Jan 2023 23:53:54 +0000 (15:53 -0800)]
go/types, types2: use go.dev/issue/nnnnn when referring to an issue (cleanup)

Apply the following regex substitutions, in order:

golang/go#(\d+)  =>  go.dev/issue/$1
issue #?(\d+)    =>  go.dev/issue/$1

Providing a link uniformly makes it easier to find the respective issue.

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

16 months agotypes2: add *Config to typecheck functions for tests, factor more code
Robert Griesemer [Wed, 18 Jan 2023 23:55:01 +0000 (15:55 -0800)]
types2: add *Config to typecheck functions for tests, factor more code

Some tests in go/types can still not use the typecheck helper functions
because they need a specific fileset for position information.

(We could use a single global file set for all tests to make this work.)

Change-Id: I73552b08a00f08d809c319d3d2328acee9532619
Reviewed-on: https://go-review.googlesource.com/c/go/+/461694
Auto-Submit: Robert Griesemer <gri@google.com>
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>
16 months agogo/types: generate instantiate.go
Robert Griesemer [Wed, 18 Jan 2023 22:59:04 +0000 (14:59 -0800)]
go/types: generate instantiate.go

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

16 months agogo/types: provision for generating initorder.go, but disabled for now
Robert Griesemer [Wed, 18 Jan 2023 22:39:20 +0000 (14:39 -0800)]
go/types: provision for generating initorder.go, but disabled for now

Add the code to generate initorder.go but do not enable the generation
of that file for now because the generated  use uses error_ which has
implications for gopls use (error_ produces a single error instead of
pultiple \t-indented follow-on errors).

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

16 months agocmd/dist: mark linux/sparc64 as a broken port, remove incomplete map
Dmitri Shuralyov [Mon, 19 Dec 2022 22:39:09 +0000 (17:39 -0500)]
cmd/dist: mark linux/sparc64 as a broken port, remove incomplete map

The linux/sparc64 port is incomplete—it doesn't work, and it doesn't
have a builder. Now that dist supports broken ports, mark it as such.

The incomplete map was created to hide ports that aren't functional
from dist list output. Now that we have the broken port concept, it
seems largely redundant, so remove it for now.

For #56679.
Updates #28944.

Change-Id: I34bd23e913ed6d786a4d0aa8d2852f2b926fe4b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/458516
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
16 months agocmd/dist: add map of broken ports and -force flag
Dmitri Shuralyov [Mon, 19 Dec 2022 21:50:24 +0000 (16:50 -0500)]
cmd/dist: add map of broken ports and -force flag

It's empty so far. The next CL adds linux/sparc64.

Also add -force flag to the bootstrap.bash script
so that it's possible to use it with broken ports.

For #56679.

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

16 months agocmd/dist: remove GOTESTONLY environment variable
Dmitri Shuralyov [Fri, 2 Dec 2022 18:33:04 +0000 (13:33 -0500)]
cmd/dist: remove GOTESTONLY environment variable

This hook was added for the Go build system (x/build) to be able to set
the run flag value, but it's no longer used anywhere. Remove it for now.

Updates #46054.

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

16 months agocmd/dist: remove hardcoded timeout scale for arm and mips{,le,64,64le}
Dmitri Shuralyov [Fri, 2 Dec 2022 18:40:49 +0000 (13:40 -0500)]
cmd/dist: remove hardcoded timeout scale for arm and mips{,le,64,64le}

Fixes #57117.

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

16 months agocrypto/tls: improve client auth failure alerts
Anit Gandhi [Mon, 21 Nov 2022 17:17:44 +0000 (17:17 +0000)]
crypto/tls: improve client auth failure alerts

This change makes it easier for clients to debug mutual TLS connection failures. Currently, there are a few situations where invalid client auth leads to a generic "bad certificate" alert. 3 specific situations have a more appropriate TLS alert code, based on the alert descriptions in the appendix of both RFC5246 and RFC8446.
  1. The server is configured to require client auth, but no client cert was provided; the appropriate alert is "certificate required". This applies only to TLS 1.3, which first defined the certificate_required alert code.
  2. The client provided a cert that was signed by an authority that is not in the server's trusted set of CAs; the appropriate alert is "unknown certificate authority".
  3. The client provided an expired (or not yet valid) cert; the appropriate alert is "expired certificate".
Otherwise, we still fall back to "bad certificate".

Fixes #52113

Change-Id: I7d5860fe911cad8a1615f16bfe488a37e936dc36
GitHub-Last-Rev: 34eeab587b38549b2ba4a778f7f9894e9b715b43
GitHub-Pull-Request: golang/go#53251
Reviewed-on: https://go-review.googlesource.com/c/go/+/410496
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
16 months agocmd/go: update test for change in panic(nil) behavior
Ian Lance Taylor [Fri, 20 Jan 2023 03:18:20 +0000 (19:18 -0800)]
cmd/go: update test for change in panic(nil) behavior

panic(nil) now panics with runtime.PanicNilError.

For #25448

Change-Id: I58994aa80d4d11f0c5fcd988714f7b4b45c6b5ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/462293
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
16 months agogo/types: use internal/lazyregexp for goVersionRx
Daniel Martí [Sun, 8 Jan 2023 22:56:40 +0000 (22:56 +0000)]
go/types: use internal/lazyregexp for goVersionRx

With benchinit, we see a noticeable improvement in init times:

name     old time/op    new time/op    delta
GoTypes    83.4µs ± 0%    43.7µs ± 1%  -47.57%  (p=0.029 n=4+4)

name     old alloc/op   new alloc/op   delta
GoTypes    26.5kB ± 0%    18.8kB ± 0%  -29.15%  (p=0.029 n=4+4)

name     old allocs/op  new allocs/op  delta
GoTypes       238 ± 0%       154 ± 0%  -35.29%  (p=0.029 n=4+4)

Port the same change to cmd/compile/internal/types and types2.

Updates #26775.

Change-Id: Ia1f7c4a4ce9a22d66e2aa9c9b9c341036993adca
Reviewed-on: https://go-review.googlesource.com/c/go/+/460544
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
16 months agoencoding/gob: shave off some init time cost
Daniel Martí [Sun, 8 Jan 2023 20:03:33 +0000 (20:03 +0000)]
encoding/gob: shave off some init time cost

Avoid unnecessary allocations when calling reflect.TypeOf;
we can use nil pointers, which fit into an interface without allocating.
This saves about 1% of CPU time.

The builtin types are limited to typeIds between 0 and firstUserId,
and since firstUserId is 64, builtinIdToType does not need to be a map.
We can simply use an array of length firstUserId, which is simpler.
This saves about 1% of CPU time.

idToType is similar to firstUserId in that it is a map keyed by typeIds.
The difference is that it can grow with the user's types.
However, each added type gets the next available typeId,
meaning that we can use a growing slice, similar to the case above.
nextId then becomes the current length of the slice.
This saves about 1% of CPU time.

typeInfoMap is stored globally as an atomic.Value,
where each modification loads the map, makes a whole copy,
adds the new element, and stores the modified copy.
This is perfectly fine when the user registers types,
as that can happen concurrently and at any point in the future.

However, during init time, we sequentially register many types,
and the overhead of copying maps adds up noticeably.
During init time, use a regular global map instead,
which gets replaced by the atomic.Value when our init work is done.
This saves about 2% of CPU time.

Finally, avoid calling checkId in bootstrapType;
we have just called setTypeId, whose logic for getting nextId is simple,
so the extra check doesn't gain us much.
This saves about 1% of CPU time.

Using benchinit, which transforms GODEBUG=inittrace=1 data into Go
benchmark compatible output, results in a nice improvement:

name         old time/op    new time/op    delta
EncodingGob     175µs ± 0%     162µs ± 0%  -7.45%  (p=0.016 n=5+4)

name         old alloc/op   new alloc/op   delta
EncodingGob    39.0kB ± 0%    36.1kB ± 0%  -7.35%  (p=0.016 n=5+4)

name         old allocs/op  new allocs/op  delta
EncodingGob       588 ± 0%       558 ± 0%  -5.10%  (p=0.000 n=5+4)

Updates #26775.

Change-Id: I28618e8b96ef440480e666ef2cd5c4a9a332ef21
Reviewed-on: https://go-review.googlesource.com/c/go/+/460543
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

16 months agointernal/profile: use internal/lazyregexp for the legacy parser
Daniel Martí [Sun, 8 Jan 2023 23:07:43 +0000 (23:07 +0000)]
internal/profile: use internal/lazyregexp for the legacy parser

Per benchinit, this makes a big difference to init times:

name             old time/op    new time/op    delta
InternalProfile     185µs ± 1%       6µs ± 1%  -96.51%  (p=0.008 n=5+5)

name             old alloc/op   new alloc/op   delta
InternalProfile     101kB ± 0%       4kB ± 0%  -95.72%  (p=0.008 n=5+5)

name             old allocs/op  new allocs/op  delta
InternalProfile       758 ± 0%        25 ± 0%  -96.70%  (p=0.008 n=5+5)

The fixed 0.2ms init cost is saved for any importer of net/http/pprof,
but also for cmd/compile, as it supports PGO now.
A Go program parsing profiles might not even need to compile these
regular expressions at all, if it doesn't encounter any legacy files.
I suspect this will be the case with most invocations of cmd/compile.

Updates #26775.

Change-Id: I8374dc64459f0b6bb09bbdf9d0b6c55d7ae1646e
Reviewed-on: https://go-review.googlesource.com/c/go/+/460545
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

16 months agocmd/link: use strings.LastIndexByte to fix a TODO
Daniel Martí [Mon, 9 Jan 2023 12:46:20 +0000 (12:46 +0000)]
cmd/link: use strings.LastIndexByte to fix a TODO

Go 1.20 will require Go 1.17 to bootstrap, so we can stop worrying about
older Go bootstrap versions. https://go.dev/issues/44505 fixed most of
those TODOs, but this one was presumably forgotten about.

Change-Id: I0c19ec4eec65cd807e7db9a57c5969845d915c07
Reviewed-on: https://go-review.googlesource.com/c/go/+/461155
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 months agocmd/compile: use a boolean as a avoid clobbering flags mov marker
Jakub Ciolek [Tue, 10 Jan 2023 07:36:00 +0000 (08:36 +0100)]
cmd/compile: use a boolean as a avoid clobbering flags mov marker

The Value type implements Aux interface because it is being used as a
"avoid clobbering flags" marker by amd64, x86 and s390x SSA parts.

Create a boolean that implements the Aux interface. Use it as the marker
instead. We no longer need Value to implement Aux.

Resolves a TODO.

See CL 275756 for more info.

Change-Id: I8a1eddf7e738b8aa31e82f3c4c590bafd2cdc56b
Reviewed-on: https://go-review.googlesource.com/c/go/+/461156
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 months agocmd/internal/obj/s390x, runtime: fix breakpoint in s390x
Srinivas Pokala [Wed, 14 Dec 2022 05:31:50 +0000 (06:31 +0100)]
cmd/internal/obj/s390x, runtime: fix breakpoint in s390x

Currently runtime.Breakpoint generates SIGSEGV in s390x.
The solution to this is add new asm instruction BRRK of
type FORMAT_E for the breakpoint exception.

Fixes #52103

Change-Id: I8358a56e428849a5d28d5ade141e1d7310bee084
Reviewed-on: https://go-review.googlesource.com/c/go/+/457456
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
16 months agocmd/compile: AMD64v3 remove unnecessary TEST comparision in isPowerOfTwo
Jorropo [Sun, 6 Nov 2022 05:37:13 +0000 (06:37 +0100)]
cmd/compile: AMD64v3 remove unnecessary TEST comparision in isPowerOfTwo

With GOAMD64=V3 the canonical isPowerOfTwo function:
  func isPowerOfTwo(x uintptr) bool {
    return x&(x-1) == 0
  }

Used to compile to:
  temp := BLSR(x) // x&(x-1)
  flags = TEST(temp, temp)
  return flags.zf

However the blsr instruction already set ZF according to the result.
So we can remove the TEST instruction if we are just checking ZF.
Such as in multiple pieces of code around memory allocations.

This make the code smaller and faster.

Change-Id: Ia12d5a73aa3cb49188c0b647b1eff7b56c5a7b58
Reviewed-on: https://go-review.googlesource.com/c/go/+/448255
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 months agocmd/compile: rewrite empty makeslice to zerobase pointer
Jorropo [Wed, 30 Nov 2022 08:45:29 +0000 (09:45 +0100)]
cmd/compile: rewrite empty makeslice to zerobase pointer

make\(\[\][a-zA-Z0-9]+, 0\) is seen 52 times in the go source.
And at least 391 times on internet:
https://grep.app/search?q=make%5C%28%5C%5B%5C%5D%5Ba-zA-Z0-9%5D%2B%2C%200%5C%29&regexp=true
This used to compile to calling runtime.makeslice.
However we can copy what we do for []T{}, just use a zerobase pointer.

On my machine this is 10x faster (from 3ns to 0.3ns).
Note that an empty loop also runs in 0.3ns,
so this really is free when you count superscallar execution.

Change-Id: I1cfe7e69f5a7a4dabbc71912ce6a4f8a2d4a7f3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/454036
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>

16 months agoruntime: remove 104 byte stack guard
liu-xuewen [Sat, 5 Nov 2022 07:40:49 +0000 (07:40 +0000)]
runtime: remove 104 byte stack guard

The number 104 appears to date back to the
first implementation of split stacks in
https://go.googlesource.com/go/+/b987f7a757f53f460973622a36eebb696f9b5060.
That change introduces a 104 byte stack guard.
it doesn't makes any sense today.

Change-Id: I73069f6d1a827653af63e616f0119fbac809882e
GitHub-Last-Rev: bcf900059047548c1709c6d4cf4649a96ad85e57
GitHub-Pull-Request: golang/go#56594
Reviewed-on: https://go-review.googlesource.com/c/go/+/448036
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
16 months agocmd/compile: improve scheduling pass
Keith Randall [Tue, 17 Nov 2020 23:32:45 +0000 (15:32 -0800)]
cmd/compile: improve scheduling pass

Convert the scheduling pass from scheduling backwards to scheduling forwards.

Forward scheduling makes it easier to prioritize scheduling values as
soon as they are ready, which is important for things like nil checks,
select ops, etc.

Forward scheduling is also quite a bit clearer. It was originally
backwards because computing uses is tricky, but I found a way to do it
simply and with n lg n complexity. The new scheme also makes it easy
to add new scheduling edges if needed.

Fixes #42673
Update #56568

Change-Id: Ibbb38c52d191f50ce7a94f8c1cbd3cd9b614ea8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/270940
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
16 months agoall: fix typos in go file comments
Marcel Meyer [Thu, 19 Jan 2023 22:26:15 +0000 (22:26 +0000)]
all: fix typos in go file comments

This is the second round to look for spelling mistakes. This time the
manual sifting of the result list was made easier by filtering out
capitalized and camelcase words.

grep -r --include '*.go' -E '^// .*$' . | aspell list | grep -E -x '[A-Za-z]{1}[a-z]*' | sort | uniq

This PR will be imported into Gerrit with the title and first
comment (this text) used to generate the subject and body of
the Gerrit change.

Change-Id: Ie8a2092aaa7e1f051aa90f03dbaf2b9aaf5664a9
GitHub-Last-Rev: fc2bd6e0c51652f13a7588980f1408af8e6080f5
GitHub-Pull-Request: golang/go#57737
Reviewed-on: https://go-review.googlesource.com/c/go/+/461595
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
16 months agogo/types: generate infer.go
Robert Griesemer [Wed, 18 Jan 2023 21:34:48 +0000 (13:34 -0800)]
go/types: generate infer.go

Also, remove pos parameter from inferB (was unused).

Change-Id: I050f64d9fe916628499a55ca46f15c1f58ed4d1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/461691
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
16 months agocmd/compile/internal/types2: remove useConstraintTypeInference flg (cleanup)
Robert Griesemer [Wed, 18 Jan 2023 21:39:58 +0000 (13:39 -0800)]
cmd/compile/internal/types2: remove useConstraintTypeInference flg (cleanup)

This useConstraintTypeInference flag was debugging purposes only and
is not needed anymore. It's already gone in go/types.

Also, adjust/fix some comments.

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

16 months agobytes, strings: rename field in CutSuffix tests
fangguizhen [Thu, 19 Jan 2023 03:12:12 +0000 (03:12 +0000)]
bytes, strings: rename field in CutSuffix tests

Change-Id: I63181f6540fc1bfcfc988a16bf9fafbd3575cfdf
GitHub-Last-Rev: d90528730a92a087866c1bfc227a0a0bf1cdffbe
GitHub-Pull-Request: golang/go#57909
Reviewed-on: https://go-review.googlesource.com/c/go/+/462284
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 months agomisc/cgo/testsanitizers: use fmt.Printf instead fmt.Println
Alice [Mon, 16 Jan 2023 11:54:01 +0000 (11:54 +0000)]
misc/cgo/testsanitizers: use fmt.Printf instead fmt.Println

Change-Id: Ie46bc3cbfb2622b5eb70618557ff5398866f5607
GitHub-Last-Rev: a665ef84dd9c11c6c274ad7f1cb51733d8253f6d
GitHub-Pull-Request: golang/go#57813
Reviewed-on: https://go-review.googlesource.com/c/go/+/462044
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

16 months agotime: no need to wrap error with errors.New
fangguizhen [Mon, 16 Jan 2023 17:46:20 +0000 (17:46 +0000)]
time: no need to wrap error with errors.New

Change-Id: Ibd519ed6419f8f21c89a111a0326d0788aca9d19
GitHub-Last-Rev: 45e3224f9afef57f49eebf3cbdf6b1d01cfd7346
GitHub-Pull-Request: golang/go#57819
Reviewed-on: https://go-review.googlesource.com/c/go/+/462046
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

16 months agonet/http: close Request.Body when pconn write loop exits early
Damien Neil [Wed, 11 Jan 2023 21:47:38 +0000 (13:47 -0800)]
net/http: close Request.Body when pconn write loop exits early

The pconn write loop closes a request's body after sending the
request, but in the case where the write loop exits with an
unsent request in writech the body is never closed.

Close the request body in this case.

Fixes #49621

Change-Id: Id94a92937bbfc0beb1396446f4dee32fd2059c7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/461675
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
16 months agoarchive/zip: use base offset 0 if it has a valid entry
Ian Lance Taylor [Wed, 11 Jan 2023 20:17:20 +0000 (12:17 -0800)]
archive/zip: use base offset 0 if it has a valid entry

In CL 408734 we introduced a fall back to base offset 0 if reading a
directory entry at the computed base offset failed. We have now found
a file in the wild for which the computed base offset is incorrect,
but happens to refer to a valid directory entry. In this CL, we change
the fallback such that if the first directory header relative to base
offset 0 is valid, we just use base offset 0.

Change-Id: Ia9ace20c1065d1f651035f16f7d91d741ab1dbf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/461598
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

16 months agocmd/internal/obj/riscv: add check for invalid shift amount input
Wayne Zuo [Thu, 12 Jan 2023 11:37:18 +0000 (19:37 +0800)]
cmd/internal/obj/riscv: add check for invalid shift amount input

Current RISCV64 assembler do not check the invalid shift amount. This CL
adds the check to avoid generating invalid instructions.

Fixes #57755

Change-Id: If33877605e161baefd98c50db1f71641ca057507
Reviewed-on: https://go-review.googlesource.com/c/go/+/461755
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>