]> Cypherpunks repositories - gostls13.git/log
gostls13.git
2 years agoruntime: consolidate function descriptor definitions on PPC64
Paul E. Murphy [Thu, 23 Mar 2023 15:41:31 +0000 (10:41 -0500)]
runtime: consolidate function descriptor definitions on PPC64

This is a cleanup to allow a consistent definitions of a function
descriptor on code shared between AIX and Linux. They need to be
declared in slightly different ways, but we can hide that in one
macro.

And, update all usage.

Change-Id: I10f3580473db555b4fb4d2597b856f3a67d01a53
Reviewed-on: https://go-review.googlesource.com/c/go/+/478917
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>

2 years agonet: don't assume that NOFILE rlimit fits in an int
Ian Lance Taylor [Sun, 26 Mar 2023 03:05:38 +0000 (20:05 -0700)]
net: don't assume that NOFILE rlimit fits in an int

No test because a test requires a system on which we can set RLIMIT_NOFILE
to RLIM_INFINITY, which we normally can't.

Fixes #59242

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

2 years agocmd/internal/obj/loong64: clean up code for short conditional branches
WANG Xuerui [Wed, 22 Mar 2023 05:28:08 +0000 (13:28 +0800)]
cmd/internal/obj/loong64: clean up code for short conditional branches

Untangle the logic so the preparation of operands and actual assembling
(branch range checking included) are properly separated, making future
changes easier to review and maintain. No functional change intended.

Change-Id: I1f73282f9d92ff23d84846453d3597ba66d207d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/478376
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agointernal/syscall/unix: fix PosixFallocate on 32-bit freebsd
Tobias Klauser [Mon, 27 Mar 2023 20:24:28 +0000 (22:24 +0200)]
internal/syscall/unix: fix PosixFallocate on 32-bit freebsd

Follow-up for CL 478035 which broke the freebsd/396 builders:

https://build.golang.org/log/e6e442cd353024c4fdb64111ad0bcbf5b25b8ecd

64-bit syscall arguments need to be passed as two 32-bit arguments on
32-bit freebsd.

Change-Id: Idf4fdf4ab7d112bc2cf95b075a5a29f221bffcb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/479715
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>

2 years agocmd/compile: start using reflect.Value.IsZero
Daniel Martí [Sat, 25 Mar 2023 11:30:26 +0000 (11:30 +0000)]
cmd/compile: start using reflect.Value.IsZero

We now require Go 1.17.13 to bootstrap via make.bash,
and since reflect.Value.IsZero was added in Go 1.13,
we can now use it directly to save a bit of copy pasting.

Change-Id: I77eef782cbbf86c72a4505c8b4866c9658914a24
Reviewed-on: https://go-review.googlesource.com/c/go/+/479395
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>

2 years agoruntime: skip TestGdbCoreSignalBacktrace on arches other than 386/amd64
Michael Pratt [Mon, 27 Mar 2023 19:20:58 +0000 (19:20 +0000)]
runtime: skip TestGdbCoreSignalBacktrace on arches other than 386/amd64

For #25218.

Change-Id: I4024a2064e0f56755fe40eb7489ba28eb4358c60
Reviewed-on: https://go-review.googlesource.com/c/go/+/479518
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>

2 years agocmd/link/internal/ld, internal/syscall/unix: use posix_fallocate on freebsd
Tobias Klauser [Mon, 27 Mar 2023 18:52:43 +0000 (20:52 +0200)]
cmd/link/internal/ld, internal/syscall/unix: use posix_fallocate on freebsd

The posix_fallocate system call is available since FreeBSD 9.0, see
https://man.freebsd.org/cgi/man.cgi?query=posix_fallocate

Change-Id: Ie65e0a44341909707617d3b0d9a4f1710c45b935
Reviewed-on: https://go-review.googlesource.com/c/go/+/478035
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years agogo/types, types2: better error message for some invalid integer array lengths
Robert Griesemer [Thu, 23 Mar 2023 20:57:47 +0000 (13:57 -0700)]
go/types, types2: better error message for some invalid integer array lengths

Don't say "array length must be integer" if it is in fact an integer.

Fixes #59209

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

2 years agosrc/log/slog: disallow == on Values
Jonathan Amsterdam [Mon, 27 Mar 2023 14:21:10 +0000 (10:21 -0400)]
src/log/slog: disallow == on Values

Comparing two Values with == is sensitive to the internal
representation of Values, and may not correspond to
equality on the Go values they represent. For example,

    StringValue("X") != StringValue(strings.ToUpper("x"))

because Go ends up doing a pointer comparison on the data
stored in the Values.

So make Values non-comparable by adding a non-comparable field.

Updates #56345.

Change-Id: Ieedbf454e631cda10bc6fcf470b57d3f1d2182cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/479516
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agolog/slog: fix string representation of Group values
Jonathan Amsterdam [Mon, 27 Mar 2023 13:42:22 +0000 (09:42 -0400)]
log/slog: fix string representation of Group values

Format Group values like a []Attr, rather than a *Attr.

Also, use fmt.Append in Value.append.

Updates #56345.

Change-Id: I9db1a8ec47f8e99c1ac3225d78e152013116bff3
Reviewed-on: https://go-review.googlesource.com/c/go/+/479515
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: don't panic if unsafe.Sizeof/Offsetof is used with oversize types
Robert Griesemer [Thu, 23 Mar 2023 17:43:56 +0000 (10:43 -0700)]
cmd/compile: don't panic if unsafe.Sizeof/Offsetof is used with oversize types

In the Sizes API, recognize an overflow (to a negative value) as a
consequence of an oversize value, and specify as such in the API.

Adjust the various size computations to take overflow into account.

Recognize a negative size or offset as an error and report it rather
than panicking.

Use the same protocol for results provided by the default (StdSizes)
and external Sizes implementations.

Add a new error code TypeTooLarge for the new errors.

Fixes #59190.
Fixes #59207.

Change-Id: I8c33a9e69932760275100112dde627289ac7695b
Reviewed-on: https://go-review.googlesource.com/c/go/+/478919
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2 years agoruntime: don't inject a sigpanic if not on user G stack
Cherry Mui [Wed, 18 Jan 2023 00:15:39 +0000 (19:15 -0500)]
runtime: don't inject a sigpanic if not on user G stack

If a panicking signal (e.g. SIGSEGV) happens on a g0 stack, we're
either in the runtime or running C code. Either way we cannot
recover and sigpanic will immediately throw. Further, injecting a
sigpanic could make the C stack unwinder and the debugger fail to
unwind the stack. So don't inject a sigpanic.

If we have cgo traceback and symbolizer attached, if it panics in
a C function ("CF" for the example below), previously it shows
something like

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x45f1ef]

runtime stack:
runtime.throw({0x485460?, 0x0?})
.../runtime/panic.go:1076 +0x5c fp=0x7ffd77f60f58 sp=0x7ffd77f60f28 pc=0x42e39c
runtime.sigpanic()
.../runtime/signal_unix.go:821 +0x3e9 fp=0x7ffd77f60fb8 sp=0x7ffd77f60f58 pc=0x442229

goroutine 1 [syscall]:
CF
/tmp/pp/c.c:6 pc=0x45f1ef
runtime.asmcgocall
.../runtime/asm_amd64.s:869 pc=0x458007
runtime.cgocall(0x45f1d0, 0xc000053f70)
.../runtime/cgocall.go:158 +0x51 fp=0xc000053f48 sp=0xc000053f10 pc=0x404551
main._Cfunc_CF()
_cgo_gotypes.go:39 +0x3f fp=0xc000053f70 sp=0xc000053f48 pc=0x45f0bf

Now it shows

SIGSEGV: segmentation violation
PC=0x45f1ef m=0 sigcode=1
signal arrived during cgo execution

goroutine 1 [syscall]:
CF
/tmp/pp/c.c:6 pc=0x45f1ef
runtime.asmcgocall
.../runtime/asm_amd64.s:869 pc=0x458007
runtime.cgocall(0x45f1d0, 0xc00004ef70)
.../runtime/cgocall.go:158 +0x51 fp=0xc00004ef48 sp=0xc00004ef10 pc=0x404551
main._Cfunc_CF()
_cgo_gotypes.go:39 +0x3f fp=0xc00004ef70 sp=0xc00004ef48 pc=0x45f0bf

I think the new one is reasonable.

For #57698.

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

2 years agolog/slog/internal/benchmarks: slog benchmarks
Jonathan Amsterdam [Wed, 22 Mar 2023 00:39:45 +0000 (20:39 -0400)]
log/slog/internal/benchmarks: slog benchmarks

Add a suite of benchmarks for the LogAttrs method, which is intended
to be fast.

Updates #56345.

Change-Id: If43f9f250bd588247c539bed87f81be7f5428c6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/478200
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2 years agoall: add a few links in package godocs
Daniel Martí [Thu, 23 Mar 2023 08:12:30 +0000 (08:12 +0000)]
all: add a few links in package godocs

I noticed the one in path/filepath while reading the docs,
and the other ones were found via some quick grepping.

Change-Id: I386f2f74ef816a6d18aa2f58ee6b64dbd0147c9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/478795
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agonet: call getSystemDNSConfig inside lookupWithFake to avoid nil dereference panic...
Mateusz Poliwczak [Thu, 17 Nov 2022 08:54:48 +0000 (08:54 +0000)]
net: call getSystemDNSConfig inside lookupWithFake to avoid nil dereference panic when running tests alone

It happens with tests that only call lookupWithFake, and before them no-one calls resolverConf.tryUpdate. running alone one of these: TestIssue8434, TestIssueNoSuchHostExists cause a nil dereference panic.

Change-Id: I3fccd96dff5b3c77b5420a7f73742acbafa80142
GitHub-Last-Rev: 7456fd16a7ff4845b4ca305d4107d29f1d6f7b3e
GitHub-Pull-Request: golang/go#56759
Reviewed-on: https://go-review.googlesource.com/c/go/+/450856
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2 years agolog/slog: clarify the limits of TextHandler output parseability
Jonathan Amsterdam [Tue, 21 Mar 2023 23:27:30 +0000 (19:27 -0400)]
log/slog: clarify the limits of TextHandler output parseability

Give an example illustrating the problem with dots inside groups
or keys. Clarify that to fix it in general, you need to do more
than escape the keys, since that won't distinguish the group "a.b"
from the two groups "a" and "b".

Updates #56345.

Change-Id: Ide301899c548d50b0a1f18e93e93d6e11ad485cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/478199
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agonet/mail: fix EOF error while reading header-only message
0xc0d [Tue, 22 Nov 2022 00:14:11 +0000 (00:14 +0000)]
net/mail: fix EOF error while reading header-only message

Check if any header found in case of EOF to recognize header-only
messages and if so, return a Message with the found headers
and a body from the reader which is already empty.

Fixes #33823.

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

2 years agoencoding/gob: update decgen to generate current dec_helpers
Ian Lance Taylor [Fri, 24 Mar 2023 00:38:05 +0000 (17:38 -0700)]
encoding/gob: update decgen to generate current dec_helpers

I edited dec_helpers.go without realizing that it is a generated file.
Fix the generator to generate the current version (which generates
a small comment change).

Change-Id: I70e3bc78eb0728d23c08972611218f288dc1d29c
Reviewed-on: https://go-review.googlesource.com/c/go/+/479117
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Andrew Ekstedt <andrew.ekstedt@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2 years agogo/types, types2: adjust Checker.recordCommaOkTypes signature
Robert Griesemer [Wed, 22 Mar 2023 00:21:17 +0000 (17:21 -0700)]
go/types, types2: adjust Checker.recordCommaOkTypes signature

By changing the signature to accept a slice rather than an
array, we can avoid creating the array in the first place.

Functionally, we now also record comma-ok types if the
corresponding assignment was incorrect. But this change
provides more (not less) information through the API and
only so if the program is incorrect in the first place.

Change-Id: I0d629441f2f890a37912171fb26ef0e75827ce23
Reviewed-on: https://go-review.googlesource.com/c/go/+/478218
Auto-Submit: Robert Griesemer <gri@google.com>
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>

2 years agoruntime: add "sigaction" to sigreturn symbol name
Michael Pratt [Thu, 23 Mar 2023 19:28:42 +0000 (15:28 -0400)]
runtime: add "sigaction" to sigreturn symbol name

In order to identify the sigreturn function, gdb looks for
"__restore_rt". However because that symbol is sometimes missing from
the symbol table, it also performs the same instruction matching as
libgcc, but only in symbols containing "sigaction" (it expects sigaction
to preceed __restore_rt).

To match this heuristic, we add __sigaction to the sigreturn symbol
name.

Fixes #25218.

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

2 years agoruntime: add GODEBUG=dontfreezetheworld=1
Michael Pratt [Thu, 23 Mar 2023 17:52:36 +0000 (13:52 -0400)]
runtime: add GODEBUG=dontfreezetheworld=1

This GODEBUG flag disables the freezetheworld call during fatal panic.
freezetheworld asks the scheduler to stop running goroutines on all Ms.
This is normally useful, as it ensures we can collect a traceback from
every goroutine. However, it can be frustrating when debugging the
scheduler itself, as it significantly changes the scheduler state from
when the panic started.

Setting this flag has some disadvantages. Most notably, running
goroutines will not traceback in the standard output (though they may be
included in the final SIGQUIT loop). Additionally, we may missing
concurrently created goroutines when looping over allgs (CL 270861 made
this safe, but still racy). The final state of all goroutines will also
be further removed from the time of panic, as they continued to run for
a while.

One unfortunate part of this flag is the final SIGQUIT loop in the
runtime leaves every thread in the signal handler at exit. This is a bit
frustrating in gdb, which doesn't understand how to step beyond
sigtramp. The data is still there, but you must manually walk.

Change-Id: Ie6bd3ac521fcababea668196b60cf225a0be1a00
Reviewed-on: https://go-review.googlesource.com/c/go/+/478975
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

2 years agoruntime: fix ARM assembly code in cgocallback
Cherry Mui [Fri, 24 Mar 2023 17:15:31 +0000 (13:15 -0400)]
runtime: fix ARM assembly code in cgocallback

A comparison instruction was missing in CL 392854.

Should fix ARM builders.

For #51676.

Change-Id: Ica27a99be10e595bab4fad35e2e6c00a1c68a662
Reviewed-on: https://go-review.googlesource.com/c/go/+/479255
TryBot-Bypass: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

2 years agocmd/internal/obj/ppc64: fix incorrect base reg causing segv
Lynn Boger [Thu, 23 Mar 2023 18:19:02 +0000 (13:19 -0500)]
cmd/internal/obj/ppc64: fix incorrect base reg causing segv

This fixes a segv that was reported due to building minio. The
problem occurred because of an incorrect selection of the
base register, which was introduced by CL 306369.

Fixes #59196

Change-Id: Ieb77b2afa8fb4e6f3943df5ce138679f6750d376
Reviewed-on: https://go-review.googlesource.com/c/go/+/478920
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agonet: add initial MPTCP support
Matthieu Baerts [Fri, 24 Feb 2023 16:51:57 +0000 (17:51 +0100)]
net: add initial MPTCP support

This currently defines an internal function supportsMultipathTCP which
reports whether MPTCP[1] is supported on the current platform.

Only Linux is supported here.

The check on Linux is performed once by attemting to create an MPTCP
socket and look at the returned error:

- If the protocol is not supported, EINVAL (kernel < 5.6) or
  EPROTONOSUPPORT (kernel >= 5.6) is returned and there is no point to
  try again.

- Other errors can be returned:
  - ENOPROTOOPT: the sysctl knob net.mptcp.enabled is set to 0
  - Unpredictable ones: if MPTCP is blocked using SELinux, eBPF, etc.

These other errors are due to modifications that can be reverted during
the session: MPTCP can be available again later. In this case, it is
fine to always try to create an MPTCP socket and fallback to TCP in case
of error.

This work has been co-developped by Gregory Detal
<gregory.detal@tessares.net>.

[1] https://www.rfc-editor.org/rfc/rfc8684.html

Updates #56539

Change-Id: Ic84fe85aad887a2be4556a898e649bf6b6f12f03
Reviewed-on: https://go-review.googlesource.com/c/go/+/471135
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agolog/slog: use Infinity instead of Inf
Joe Tsai [Thu, 23 Mar 2023 07:29:08 +0000 (00:29 -0700)]
log/slog: use Infinity instead of Inf

JSON is derived from Javascript, so we should use Javascript-inspired
literals instead of ones more common to Go.

In Javascript, infinity is declared as Infinity rather than Inf.

Change-Id: I6c81353d0c677640f3f11961a37d792408ac03fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/478758
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime/cgo: store M for C-created thread in pthread key
doujiang24 [Fri, 24 Mar 2023 01:30:46 +0000 (01:30 +0000)]
runtime/cgo: store M for C-created thread in pthread key

In a C thread, it's necessary to acquire an extra M by using needm while invoking a Go function from C. But, needm and dropm are heavy costs due to the signal-related syscalls.
So, we change to not dropm while returning back to C, which means binding the extra M to the C thread until it exits, to avoid needm and dropm on each C to Go call.
Instead, we only dropm while the C thread exits, so the extra M won't leak.

When invoking a Go function from C:
Allocate a pthread variable using pthread_key_create, only once per shared object, and register a thread-exit-time destructor.
And store the g0 of the current m into the thread-specified value of the pthread key,  only once per C thread, so that the destructor will put the extra M back onto the extra M list while the C thread exits.

When returning back to C:
Skip dropm in cgocallback, when the pthread variable has been created, so that the extra M will be reused the next time invoke a Go function from C.

This is purely a performance optimization. The old version, in which needm & dropm happen on each cgo call, is still correct too, and we have to keep the old version on systems with cgo but without pthreads, like Windows.

This optimization is significant, and the specific value depends on the OS system and CPU, but in general, it can be considered as 10x faster, for a simple Go function call from a C thread.

For the newly added BenchmarkCGoInCThread, some benchmark results:
1. it's 28x faster, from 3395 ns/op to 121 ns/op, in darwin OS & Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
2. it's 6.5x faster, from 1495 ns/op to 230 ns/op, in Linux OS & Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz

Fixes #51676

Change-Id: I380702fe2f9b6b401b2d6f04b0aba990f4b9ee6c
GitHub-Last-Rev: 93dc64ad98e5583372e41f65ee4b7ab78b5aff51
GitHub-Pull-Request: golang/go#51679
Reviewed-on: https://go-review.googlesource.com/c/go/+/392854
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: thepudds <thepudds1460@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agocmd/link: add padding after runtime.etext
Cherry Mui [Thu, 23 Mar 2023 20:10:05 +0000 (16:10 -0400)]
cmd/link: add padding after runtime.etext

The runtime.etext symbol is a marker symbol that marks the end of
(Go's) text section. Currently it has 0 size on some platforms.
Especially in external linking mode, this may cause the next
symbol (e.g. a C function) to have the same address as
runtime.etext, which may confuse some symbolizer. Add some padding
bytes to avoid address collision.

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

2 years agonet: add mptcpStatus type
Matthieu Baerts [Mon, 20 Mar 2023 09:35:51 +0000 (10:35 +0100)]
net: add mptcpStatus type

This new type will be used in the following commits.

The goal is to have a tristate, an enum with three values:

- system default (0)
- enabled
- disabled

The system default value is linked to defaultMPTCPEnabled: disabled by
default for the moment. Users will be able to force enabling/disabling
MPTCP or use the default behaviour.

This work has been co-developped by Gregory Detal
<gregory.detal@tessares.net>.

Updates #56539

Change-Id: I8fa0cad7a18ca967508799fc828ef060b27683d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/477735
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocrypto/x509: remove unnecessary !Empty() check
Mateusz Poliwczak [Thu, 23 Mar 2023 10:57:36 +0000 (10:57 +0000)]
crypto/x509: remove unnecessary !Empty() check

This check is already done by PeekASN1Tag.

Change-Id: Ieba0e35548f7f99bce689d29adaea6b8e471cc70
GitHub-Last-Rev: b4ef3dcc2307839cb7575cf29c3e6445b6a7520e
GitHub-Pull-Request: golang/go#59197
Reviewed-on: https://go-review.googlesource.com/c/go/+/478835
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agocrypto/x509: remove letters from the end of basic constraints parsing errors
Mateusz Poliwczak [Thu, 23 Mar 2023 10:57:26 +0000 (10:57 +0000)]
crypto/x509: remove letters from the end of basic constraints parsing errors

Change-Id: I84533d2df1a20f6337c43b1ca00d8022909a0018
GitHub-Last-Rev: 7dcc4e7296054df7fcbaebfdbd2a9895750f56ea
GitHub-Pull-Request: golang/go#59195
Reviewed-on: https://go-review.googlesource.com/c/go/+/478816
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
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: Ian Lance Taylor <iant@google.com>
2 years agocmd/compile: optimize cmp to cmn under conditions < and >= on arm64
erifan01 [Tue, 14 Mar 2023 01:25:07 +0000 (09:25 +0800)]
cmd/compile: optimize cmp to cmn under conditions < and >= on arm64

Under the right conditions we can optimize cmp comparisons to cmn
comparisons, such as:
func foo(a, b int) int {
  var c int
  if a + b < 0 {
   c = 1
  }
  return c
}

Previously it's compiled as:
  ADD     R1, R0, R1
  CMP     $0, R1
  CSET    LT, R0
With this CL it's compiled as:
  CMN     R1, R0
  CSET    MI, R0
Here we need to pay attention to the overflow situation of a+b, the MI
flag means N==1, which doesn't honor the overflow flag V, its value
depends only on the sign of the result. So it has the same semantic of
the Go code, so it's correct.

Similarly, this CL also optimizes the case of >= comparison
using the PL conditional flag.

Change-Id: I47179faba5b30cca84ea69bafa2ad5241bf6dfba
Reviewed-on: https://go-review.googlesource.com/c/go/+/476116
Run-TryBot: Eric Fang <eric.fang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: combine similar optimization rules on arm64
erifan01 [Tue, 7 Mar 2023 00:49:11 +0000 (08:49 +0800)]
cmd/compile: combine similar optimization rules on arm64

This CL combines some rules with the same structure.
In order to avoid extremely long rules, this CL does not merge some
rules. In addition, this CL aligned the components of some rules for
better reading.

Change-Id: I4ba1493251ace00b10591e3c8eef4b6277a4b226
Reviewed-on: https://go-review.googlesource.com/c/go/+/476115
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agonet/http: continue using referer header if it's present
Paschalis Tsilias [Mon, 15 Feb 2021 13:55:28 +0000 (15:55 +0200)]
net/http: continue using referer header if it's present

Currently, net/http replaces the Referer header with the URL of the
previous request, regardless of its status. This CL changes this
behavior, respecting the Referer header for secure connections, if it is
set.

Fixes #44160

Change-Id: I2d7fe37dd681549136329e832188294691584870
Reviewed-on: https://go-review.googlesource.com/c/go/+/291636
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nick Craig-Wood <nickcw@gmail.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agonet/http: fix typo
Michał Matczuk [Thu, 23 Mar 2023 13:52:59 +0000 (13:52 +0000)]
net/http: fix typo

Change-Id: I6e39f14df65685451d3d98c6def1e0665da20590
GitHub-Last-Rev: d9de237bd24ab3deebdbdf1f75a1835169670c1d
GitHub-Pull-Request: golang/go#59200
Reviewed-on: https://go-review.googlesource.com/c/go/+/478855
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoRevert "os/user: lookup Linux users and groups via systemd userdb"
Heschi Kreinick [Thu, 23 Mar 2023 21:50:21 +0000 (21:50 +0000)]
Revert "os/user: lookup Linux users and groups via systemd userdb"

This reverts CL 459455.

Reason for revert: breaks tests on various platforms, see https://go-review.googlesource.com/c/go/+/459455/74#message-3d9462b24872f6e0b12b4abf5ea3983e1588f91a

Change-Id: I4c79b28f750c2369909688f86616d76d7eaf0ab4
Reviewed-on: https://go-review.googlesource.com/c/go/+/479135
Run-TryBot: Heschi Kreinick <heschi@google.com>
Auto-Submit: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoall: replace leading spaces with tabs in assembly
Michael Pratt [Thu, 23 Mar 2023 18:18:19 +0000 (14:18 -0400)]
all: replace leading spaces with tabs in assembly

Most of these are one-off mistakes. Only one file was all spaces.

Change-Id: I277c3ce4a4811aa4248c90676f66bc775ae8d062
Reviewed-on: https://go-review.googlesource.com/c/go/+/478976
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agotesting: quote -test.v=test2json output when logging it
Bryan C. Mills [Thu, 23 Mar 2023 19:17:50 +0000 (15:17 -0400)]
testing: quote -test.v=test2json output when logging it

The -test.v=test2json flag causes the testing package to inject extra
control characters in the output to allow the JSON parser to more
gracefully handle extraneous writes to os.Stdout and/or os.Stderr in
the package under test (see CL 443596). However, it doesn't filter out
those control characters because almost no real-world tests will
output them.

It turns out that testing.TestFlag is one of the rare tests that does
output those control characters, because it tests the
-test.v=test2json flag itself.

Fixes #59181.

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

2 years agoencoding/gob: extend partially allocated string slices
Johan Abildskov [Wed, 22 Mar 2023 06:31:25 +0000 (06:31 +0000)]
encoding/gob: extend partially allocated string slices

Fixes #59172

Change-Id: I54d5e724f10117a40ec5dd58c810f6bbb2475933
GitHub-Last-Rev: d1a986698c820415b2e0be12141091a3cbf6fde3
GitHub-Pull-Request: golang/go#59173
Reviewed-on: https://go-review.googlesource.com/c/go/+/478215
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2 years agoos/user: lookup Linux users and groups via systemd userdb
Ananth Bhaskararaman [Wed, 22 Mar 2023 05:37:43 +0000 (05:37 +0000)]
os/user: lookup Linux users and groups via systemd userdb

Fetch usernames and groups via systemd userdb if available.
Otherwise fall back to parsing /etc/passwd, etc.

Fixes #38810

Co-authored-by: Michael Stapelberg <stapelberg@google.com>
Change-Id: Iff6ffc54feec6b6cec241b89e362c2285c8c0454
GitHub-Last-Rev: 1a627cc9a18063f5d274bb96113947cd4d952e5a
GitHub-Pull-Request: golang/go#57458
Reviewed-on: https://go-review.googlesource.com/c/go/+/459455
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: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agocmd/go: enable -pgo=auto by default
Cherry Mui [Tue, 7 Mar 2023 22:49:34 +0000 (17:49 -0500)]
cmd/go: enable -pgo=auto by default

Updates #58099.
Updates #55022.

Change-Id: I32eacdf9f008d16566e0b30230ecc25d110a9811
Reviewed-on: https://go-review.googlesource.com/c/go/+/474236
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agocmd/go: permit "go list" error in some tests
Cherry Mui [Mon, 20 Mar 2023 20:19:30 +0000 (16:19 -0400)]
cmd/go: permit "go list" error in some tests

The vendor_import test lists packages that are known bad (e.g.
bad.go, invalid.go). Pass -e to permit error.

The mod_vendor_auto test includes a package that imports a main
package, which should be an error. Pass -e to permit error.

Updates #59186.

Change-Id: I3b63025c3935f55feda1a95151d4c688d0394644
Reviewed-on: https://go-review.googlesource.com/c/go/+/477838
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agocmd/go: make get_dash_t test more specific
Cherry Mui [Mon, 20 Mar 2023 20:13:02 +0000 (16:13 -0400)]
cmd/go: make get_dash_t test more specific

Currently it uses "go list ...", which includes all packages in
the known universe, and may include unresolved dependencies. The
test for issue #8181 is specifically for that the test dependency
of package b is downloaded. Test that specifically.

Change-Id: Icfbd7e197698b10ae4bc7c8aa3b0f2c477ca6b8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/477837
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

2 years agonet/http: improve logging in TestServerSetKeepAlivesEnabledClosesConns
Bryan C. Mills [Wed, 22 Mar 2023 16:19:23 +0000 (12:19 -0400)]
net/http: improve logging in TestServerSetKeepAlivesEnabledClosesConns

- Log the actual addresses reported, in case that information is relevant.

- Keep going after the first error, so that we report more information
  about the idle connections after they have been used. (Was the first
  connection dropped completely, or did it later show up as idle?)

- Remove the third request at the end of the test. It had been
  assuming that the address for a new connection would always be
  different from the address for the just-closed connection; however,
  that assumption does not hold in general.

Removing the third request addresses one of the two failure modes seen
in #55195. It may help in investigating the other failure mode, but I
do not expect it to fix the failures entirely. (I suspect that the
other failure mode is a synchronization bug in returning the idle
connection from the first request.)

For #55195.

Change-Id: If9604ea68db0697268288ce9812dd57633e83fbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/478515
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>

2 years agonet/http: simplify Conn lifetimes in TestClientTimeoutKillsConn tests
Bryan C. Mills [Tue, 21 Mar 2023 20:14:53 +0000 (16:14 -0400)]
net/http: simplify Conn lifetimes in TestClientTimeoutKillsConn tests

This is intended to fix the failure mode observed in
https://build.golang.org/log/f153e06ed547517fb2cddb0fa817fea40a6146f7,
but I haven't been able to reproduce that failure mode locally so I'm
not sure whether it actually does.

Change-Id: Ib14378f1299a76b54013419bdc715a9dbdd94667
Reviewed-on: https://go-review.googlesource.com/c/go/+/478235
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agonet/http: in the IdleConnStrsForTesting_h2 helper, omit conns that cannot be reused
Bryan C. Mills [Mon, 20 Mar 2023 20:19:45 +0000 (16:19 -0400)]
net/http: in the IdleConnStrsForTesting_h2 helper, omit conns that cannot be reused

In #59155, we observed that the IdleConnStrsForTesting_h2 helper
function sometimes reported extra connections after a
"client conn not usable" failure and retry. It turns out that that
state corresponds exactly to the
http2clientConnIdleState.canTakeNewRequest field, so (with a bit of
extra nethttpomithttp2 plumbing) we can use that field in the helper
to filter out the unusable connections.

Fixes #59155.

Change-Id: Ief6283c9c8c5ec47dd9f378beb0ddf720832484e
Reviewed-on: https://go-review.googlesource.com/c/go/+/477856
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

2 years agocmd/go: use --ffile-prefix-map instead of --debug-prefix-map
Michael Matloob [Tue, 21 Mar 2023 20:00:18 +0000 (16:00 -0400)]
cmd/go: use --ffile-prefix-map instead of --debug-prefix-map

Also add code to replace the vendor directory in the prefix-map in
vendored modules.  We weren't doing that before because in vendored
modules, the module's Dir field was set to empty, so nothing was being
replaced. Instead when Dir is not set, so we are in vendor mode,
replace the entire vendor directory's path.

Change-Id: I910499c74237699fd36d18049909a72e2b6705d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/478455
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 years agoruntime: save and restore fcc registers in async preempt on loong64
Huang Qiqi [Mon, 13 Mar 2023 10:52:43 +0000 (18:52 +0800)]
runtime: save and restore fcc registers in async preempt on loong64

During the context switch of goroutine scheduling, the value of the
fcc0 register needs to be saved on the stack.

Fixs #59000.

Change-Id: Ie80dbae738f60df6c11a3fe31fc57de817d76afc
Reviewed-on: https://go-review.googlesource.com/c/go/+/475577
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
2 years agotest: add test that caused gofrontend crash
Ian Lance Taylor [Wed, 22 Mar 2023 00:28:36 +0000 (17:28 -0700)]
test: add test that caused gofrontend crash

For #59169

Change-Id: Id72ad9fe8b6e1d7cf64f972520ae8858f70c025a
Reviewed-on: https://go-review.googlesource.com/c/go/+/478217
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

2 years agosync: fix TestCondSignalStealing flake
Collin Wright [Mon, 20 Mar 2023 23:27:04 +0000 (23:27 +0000)]
sync: fix TestCondSignalStealing flake

Fixes: #59043
Change-Id: I8215948a772566641dab1079a9837128450deb1b
GitHub-Last-Rev: 0fa6f08a70658e1272da0c82812de752350d394d
GitHub-Pull-Request: golang/go#59160
Reviewed-on: https://go-review.googlesource.com/c/go/+/477955
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>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

2 years agocmd/internal/obj/loong64: realize all unconditional jumps with B/BL
WANG Xuerui [Tue, 21 Mar 2023 10:23:44 +0000 (18:23 +0800)]
cmd/internal/obj/loong64: realize all unconditional jumps with B/BL

The current practice of using the "PC-relative" `BEQ ZERO, ZERO` for
short jumps is inherited from the MIPS port, where the pre-R6 long
jumps are PC-regional instead of PC-relative. This quirk is not
present in LoongArch from the very beginning so there is no reason to
keep the behavior any more.

While at it, simplify the code to not place anything in the jump offset
field if a relocation is to take place. (It may be relic of a previous
REL-era treatment where the addend is to be stored in the instruction
word, but again, loong64 is exclusively RELA from day 1 so no point in
doing so either.)

Benchmark shows very slight improvement on a 3A5000 box, indicating the
LA464 micro-architecture presumably *not* seeing the always-true BEQs as
equivalent to B:

goos: linux
goarch: loong64
pkg: test/bench/go1
                      │  2ef70d9d0f  │                this CL                │
                      │    sec/op    │    sec/op     vs base                 │
BinaryTree17             14.57 ±  4%    14.54 ±  1%       ~ (p=0.353 n=10)
Fannkuch11               3.570 ±  0%    3.570 ±  0%       ~ (p=0.529 n=10)
FmtFprintfEmpty         92.84n ±  0%   92.84n ±  0%       ~ (p=0.970 n=10)
FmtFprintfString        150.0n ±  0%   149.9n ±  0%       ~ (p=0.350 n=10)
FmtFprintfInt           153.3n ±  0%   153.3n ±  0%       ~ (p=1.000 n=10) ¹
FmtFprintfIntInt        235.8n ±  0%   235.8n ±  0%       ~ (p=0.963 n=10)
FmtFprintfPrefixedInt   318.5n ±  0%   318.5n ±  0%       ~ (p=0.474 n=10)
FmtFprintfFloat         410.4n ±  0%   410.4n ±  0%       ~ (p=0.628 n=10)
FmtManyArgs             944.9n ±  0%   945.0n ±  0%       ~ (p=0.240 n=10)
GobDecode               13.97m ± 12%   12.83m ± 21%       ~ (p=0.165 n=10)
GobEncode               17.84m ±  5%   18.60m ±  4%       ~ (p=0.123 n=10)
Gzip                    421.0m ±  0%   421.0m ±  0%       ~ (p=0.579 n=10)
Gunzip                  89.80m ±  0%   89.77m ±  0%       ~ (p=0.529 n=10)
HTTPClientServer        86.54µ ±  1%   86.25µ ±  0%  -0.33% (p=0.003 n=10)
JSONEncode              18.57m ±  0%   18.57m ±  0%       ~ (p=0.353 n=10)
JSONDecode              77.48m ±  0%   77.30m ±  0%  -0.23% (p=0.035 n=10)
Mandelbrot200           7.217m ±  0%   7.217m ±  0%       ~ (p=0.436 n=10)
GoParse                 7.599m ±  2%   7.632m ±  1%       ~ (p=0.353 n=10)
RegexpMatchEasy0_32     140.1n ±  0%   140.1n ±  0%       ~ (p=0.582 n=10)
RegexpMatchEasy0_1K     1.538µ ±  0%   1.538µ ±  0%       ~ (p=1.000 n=10) ¹
RegexpMatchEasy1_32     161.7n ±  0%   161.7n ±  0%       ~ (p=1.000 n=10) ¹
RegexpMatchEasy1_1K     1.632µ ±  0%   1.632µ ±  0%       ~ (p=1.000 n=10) ¹
RegexpMatchMedium_32    1.369µ ±  0%   1.369µ ±  0%       ~ (p=1.000 n=10)
RegexpMatchMedium_1K    39.96µ ±  0%   39.96µ ±  0%  +0.01% (p=0.010 n=10)
RegexpMatchHard_32      2.099µ ±  0%   2.099µ ±  0%       ~ (p=1.000 n=10) ¹
RegexpMatchHard_1K      62.50µ ±  0%   62.50µ ±  0%       ~ (p=0.099 n=10)
Revcomp                  1.349 ±  0%    1.347 ±  0%  -0.14% (p=0.001 n=10)
Template                118.4m ±  0%   118.0m ±  0%  -0.36% (p=0.023 n=10)
TimeParse               407.8n ±  0%   407.9n ±  0%  +0.02% (p=0.000 n=10)
TimeFormat              508.0n ±  0%   507.9n ±  0%       ~ (p=0.421 n=10)
geomean                 103.5µ         103.3µ        -0.17%
¹ all samples are equal

                     │  2ef70d9d0f   │                this CL                 │
                     │      B/s      │      B/s       vs base                 │
GobDecode              52.67Mi ± 11%   57.04Mi ± 17%       ~ (p=0.149 n=10)
GobEncode              41.03Mi ±  4%   39.35Mi ±  4%       ~ (p=0.118 n=10)
Gzip                   43.95Mi ±  0%   43.95Mi ±  0%       ~ (p=0.428 n=10)
Gunzip                 206.1Mi ±  0%   206.1Mi ±  0%       ~ (p=0.399 n=10)
JSONEncode             99.64Mi ±  0%   99.66Mi ±  0%       ~ (p=0.304 n=10)
JSONDecode             23.88Mi ±  0%   23.94Mi ±  0%  +0.22% (p=0.030 n=10)
GoParse                7.267Mi ±  2%   7.238Mi ±  1%       ~ (p=0.360 n=10)
RegexpMatchEasy0_32    217.8Mi ±  0%   217.8Mi ±  0%  -0.00% (p=0.006 n=10)
RegexpMatchEasy0_1K    635.0Mi ±  0%   635.0Mi ±  0%       ~ (p=0.194 n=10)
RegexpMatchEasy1_32    188.7Mi ±  0%   188.7Mi ±  0%       ~ (p=0.338 n=10)
RegexpMatchEasy1_1K    598.5Mi ±  0%   598.5Mi ±  0%  -0.00% (p=0.000 n=10)
RegexpMatchMedium_32   22.30Mi ±  0%   22.30Mi ±  0%       ~ (p=0.211 n=10)
RegexpMatchMedium_1K   24.43Mi ±  0%   24.43Mi ±  0%       ~ (p=1.000 n=10)
RegexpMatchHard_32     14.54Mi ±  0%   14.54Mi ±  0%       ~ (p=0.474 n=10)
RegexpMatchHard_1K     15.62Mi ±  0%   15.62Mi ±  0%       ~ (p=1.000 n=10) ¹
Revcomp                179.7Mi ±  0%   180.0Mi ±  0%  +0.14% (p=0.001 n=10)
Template               15.63Mi ±  0%   15.68Mi ±  0%  +0.34% (p=0.022 n=10)
geomean                60.29Mi         60.44Mi        +0.24%
¹ all samples are equal

Change-Id: I112dd663c49567386ea75dd4966a9f8127ffb90e
Reviewed-on: https://go-review.googlesource.com/c/go/+/478075
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/internal/obj/ppc64: add VC[LT]ZLSBB instructions
Paul E. Murphy [Tue, 7 Mar 2023 23:19:04 +0000 (17:19 -0600)]
cmd/internal/obj/ppc64: add VC[LT]ZLSBB instructions

These are ISA 3.0 power9 instructions which are helpful when reducing
a vector compare result into a GPR.

They are used in a future patch to improve the bytes.IndexByte asm
routine.

Change-Id: I424e2628e577167b9b7c0fcbd82099daf568ea35
Reviewed-on: https://go-review.googlesource.com/c/go/+/478115
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agocmd/compile: mark negative size memclr non-inlineable
Cuong Manh Le [Wed, 22 Mar 2023 10:45:07 +0000 (17:45 +0700)]
cmd/compile: mark negative size memclr non-inlineable

Fixes #59174

Change-Id: I72b2b068830b90d42a0186addd004fb3175b9126
Reviewed-on: https://go-review.googlesource.com/c/go/+/478375
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoreflect: add test for interface type NumMethod
Cuong Manh Le [Wed, 22 Mar 2023 04:44:04 +0000 (11:44 +0700)]
reflect: add test for interface type NumMethod

While at it, also use concrete type for non-interface type test.

Change-Id: Ie468c30ee31ba99ef8f9a810d3be851fd37b9b43
Reviewed-on: https://go-review.googlesource.com/c/go/+/478356
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2 years agoruntime: improve memmove on ppc64x/power10
Archana R [Wed, 22 Feb 2023 11:52:15 +0000 (05:52 -0600)]
runtime: improve memmove on ppc64x/power10

Rewrite memmove asm function to use the new power10 instructions
lxvl and stxvl or the load and store vector with length which can
specify the number of bytes to be loaded/stored in a register,
thereby avoiding multiple instructions to process 8bytes, 4bytes,
2bytes and a single byte while storing the tail end bytes. On power9
and power8 the code remains unchanged.
The performance for all sizes<=16 improve on power10 with this change.

name                          old time/op    new time/op    delta
Memmove/1                2.87ns ±  0%    2.64ns ±  1%    -8.11%
Memmove/2                2.85ns ±  0%    2.62ns ±  1%    -8.12%
Memmove/3                2.78ns ±  0%    2.63ns ±  1%    -5.33%
Memmove/4                2.83ns ±  0%    2.63ns ±  2%    -7.33%
Memmove/5                2.78ns ±  0%    2.63ns ±  1%    -5.40%
Memmove/6                2.61ns ±  3%    2.61ns ±  1%      ~
Memmove/7                2.82ns ±  0%    2.61ns ±  1%    -7.48%
Memmove/8                2.82ns ±  0%    2.65ns ±  1%    -6.11%
Memmove/9                6.41ns ±  0%    2.62ns ±  1%   -59.17%
Memmove/10               5.09ns ±  1%    2.60ns ±  1%   -48.90%
Memmove/11               4.68ns ±  7%    2.59ns ±  1%   -44.56%
Memmove/12               6.25ns ±  2%    2.60ns ±  1%   -58.46%
Memmove/13               4.15ns ± 25%    2.59ns ±  1%   -37.66%
Memmove/14               3.76ns ± 11%    2.59ns ±  1%   -30.94%
Memmove/15               3.82ns ±  1%    2.60ns ±  1%   -31.93%
Memmove/16               2.96ns ±  1%    2.59ns ±  1%   -12.63%
MemmoveUnalignedDst/1    3.07ns ±  0%    2.77ns ±  0%    -9.75%
MemmoveUnalignedDst/2    2.82ns ±  0%    2.77ns ±  0%    -1.73%
MemmoveUnalignedDst/3    3.03ns ±  0%    2.77ns ±  0%    -8.75%
MemmoveUnalignedDst/4    2.85ns ±  1%    2.77ns ±  0%    -2.90%
MemmoveUnalignedDst/5    3.03ns ±  0%    2.77ns ±  0%    -8.75%
MemmoveUnalignedDst/6    2.88ns ±  0%    2.77ns ±  0%    -4.04%
MemmoveUnalignedDst/7    3.11ns ±  0%    2.77ns ±  0%   -11.10%
MemmoveUnalignedDst/8    4.18ns ±  2%    2.77ns ±  0%   -33.90%
MemmoveUnalignedDst/9    6.36ns ±  1%    2.77ns ±  0%   -56.53%
MemmoveUnalignedDst/10   5.77ns ±  1%    2.77ns ±  0%   -52.09%
MemmoveUnalignedDst/11   4.68ns ±  1%    2.77ns ±  0%   -40.86%
MemmoveUnalignedDst/12   4.54ns ±  2%    2.77ns ±  0%   -39.05%
MemmoveUnalignedDst/13   6.16ns ±  5%    2.77ns ±  0%   -55.14%
MemmoveUnalignedDst/14   4.03ns ±  2%    2.77ns ±  0%   -31.41%
MemmoveUnalignedDst/15   4.11ns ±  0%    2.77ns ±  0%   -32.74%
MemmoveUnalignedDst/16   3.49ns ±  4%    2.79ns ±  1%   -20.04%
MemmoveUnalignedSrc/1    3.06ns ±  0%    2.77ns ±  0%    -9.68%
MemmoveUnalignedSrc/2    2.82ns ±  1%    2.77ns ±  0%    -1.93%
MemmoveUnalignedSrc/3    3.04ns ±  0%    2.77ns ±  0%    -8.95%
MemmoveUnalignedSrc/4    2.85ns ±  0%    2.77ns ±  0%    -2.86%
MemmoveUnalignedSrc/5    3.04ns ±  0%    2.77ns ±  0%    -8.97%
MemmoveUnalignedSrc/6    2.93ns ±  0%    2.77ns ±  0%    -5.43%
MemmoveUnalignedSrc/7    3.13ns ±  0%    2.77ns ±  0%   -11.56%
MemmoveUnalignedSrc/8    3.71ns ±  2%    2.77ns ±  0%   -25.46%
MemmoveUnalignedSrc/9    6.04ns ±  0%    2.77ns ±  0%   -54.16%
MemmoveUnalignedSrc/10   6.86ns ±  5%    2.77ns ±  0%   -59.69%
MemmoveUnalignedSrc/11   4.18ns ±  3%    2.77ns ±  0%   -33.81%
MemmoveUnalignedSrc/12   4.75ns ±  2%    2.77ns ±  0%   -41.81%
MemmoveUnalignedSrc/13   4.78ns ±  3%    2.77ns ±  0%   -42.15%
MemmoveUnalignedSrc/14   3.89ns ±  5%    2.77ns ±  0%   -28.80%
MemmoveUnalignedSrc/15   4.09ns ±  0%    2.77ns ±  0%   -32.30%
MemmoveUnalignedSrc/16   3.15ns ±  1%    2.77ns ±  0%   -12.05%
Change-Id: Ia3c09d968dada71a794e5ccab3300ea9c46d8374
Reviewed-on: https://go-review.googlesource.com/c/go/+/470135
Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoslog: eliminate needsQuotingSet
Jonathan Amsterdam [Tue, 21 Mar 2023 22:33:46 +0000 (18:33 -0400)]
slog: eliminate needsQuotingSet

Delete the set of bytes that need quoting in TextHandler, because it
is almost identical to the set for JSON. Use JSONHandler's safeSet
with a few exceptions.

Updates #56345.

Change-Id: Iff6d309c067affef2e5ecfcebd6e1bb8f00f95b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/478198
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agolog/slog: fix window race builder
Cuong Manh Le [Wed, 22 Mar 2023 04:13:23 +0000 (11:13 +0700)]
log/slog: fix window race builder

Bench log file is created non-portably, only works on system where
"/tmp" existed and "/" is path separator.

Fixing this by using portable methods from std lib.

Updates #56345

Change-Id: I1f6b6b97b913ca56a6053beca7025652618ecbf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/478355
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: fix incorrect truncating when converting CMP to TST on arm64
erifan01 [Tue, 7 Mar 2023 00:44:08 +0000 (08:44 +0800)]
cmd/compile: fix incorrect truncating when converting CMP to TST on arm64

CL 420434 optimized CMP into TST in some situations, but it has a bug,
these four rules are not correct:
(LessThan (CMPWconst [0] x:(ANDconst [c] y))) && x.Uses == 1 => (LessThan (TSTconst [c] y))
(LessEqual (CMPWconst [0] x:(ANDconst [c] y))) && x.Uses == 1 => (LessEqual (TSTconst [c] y))
(GreaterThan (CMPWconst [0] x:(ANDconst [c] y))) && x.Uses == 1 => (GreaterThan (TSTconst [c] y))
(GreaterEqual (CMPWconst [0] x:(ANDconst [c] y))) && x.Uses == 1 => (GreaterEqual (TSTconst [c] y))

But due to the existence of this rule
(LessThan (CMPWconst [0] x:(ANDconst [c] y))) && x.Uses == 1 =>
(LessThan (TSTWconst [int32(c)] y)), the above rules have never been
fired. This CL corrects them as:
(LessThan (CMPconst [0] x:(ANDconst [c] y))) && x.Uses == 1 => (LessThan (TSTconst [c] y))
(LessEqual (CMPconst [0] x:(ANDconst [c] y))) && x.Uses == 1 => (LessEqual (TSTconst [c] y))
(GreaterThan (CMPconst [0] x:(ANDconst [c] y))) && x.Uses == 1 => (GreaterThan (TSTconst [c] y))
(GreaterEqual (CMPconst [0] x:(ANDconst [c] y))) && x.Uses == 1 => (GreaterEqual (TSTconst [c] y))

Change-Id: I7d60bcc9a266ee58388baeaab9f493b57cf1ad55
Reviewed-on: https://go-review.googlesource.com/c/go/+/473617
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>

2 years agoos: avoid creating a new file in Truncate on Windows
Nont Thanonchai [Wed, 22 Mar 2023 01:04:45 +0000 (01:04 +0000)]
os: avoid creating a new file in Truncate on Windows

Truncate() a non existent file on Windows currently creates a new blank
file. This behavior is not consistent with other OSes where a file not
found error would instead be returned. This change makes Truncate on
Windows return a file-not-found error when the specified file doesn't
exist, bringing the behavior consistent.

New test cases have been added to prevent a regression.

Fixes #58977

Change-Id: Iaf7b41fc4ea86a2b2ccc59f8be81be42ed211b5c
GitHub-Last-Rev: 636b6c37c1685096281ad506f3cfe35fd5810cb2
GitHub-Pull-Request: golang/go#59085
Reviewed-on: https://go-review.googlesource.com/c/go/+/477215
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: 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>
2 years agocmd/compile: re-compile instantiated generic methods in linkshared mode
Cuong Manh Le [Fri, 17 Mar 2023 17:53:07 +0000 (00:53 +0700)]
cmd/compile: re-compile instantiated generic methods in linkshared mode

For G[T] that was seen and compiled in imported package, it is not added
to typecheck.Target.Decls, prevent wasting compile time re-creating
DUPOKS symbols. However, the linker do not support a type symbol
referencing a method symbol across DSO boundary. That causes unreachable
sym error when building under -linkshared mode.

To fix it, always re-compile generic methods in linkshared mode.

Fixes #58966

Change-Id: I894b417cfe8234ae1fe809cc975889345df22cef
Reviewed-on: https://go-review.googlesource.com/c/go/+/477375
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agolog/slog: rename and remove files
Jonathan Amsterdam [Tue, 21 Mar 2023 13:12:30 +0000 (09:12 -0400)]
log/slog: rename and remove files

- Remove the norace_test.go files, moving their contents elsewhere.

- Rename the internal/testutil package to internal/slogtest.

- Remove value_unsafe.go, moving its contents to value.go.

Updates golang/go#56345.

Change-Id: I2a24ace5aea47f7a3067cd671f606c4fb279d744
Reviewed-on: https://go-review.googlesource.com/c/go/+/478197
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/compile/internal/types2: avoid unpacking single-value LHS
Robert Griesemer [Mon, 20 Mar 2023 21:29:05 +0000 (14:29 -0700)]
cmd/compile/internal/types2: avoid unpacking single-value LHS

For ++/-- statements, we know that syntax.AssignStmt.Lhs is a
single expression. Avoid unpacking (and allocating a slice) in
that case. Minor optimization.

Change-Id: I6615fd12277b1cd7d4f8b86e0b9d39f27708c13e
Reviewed-on: https://go-review.googlesource.com/c/go/+/477915
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>

2 years agogo/types: remove Checker.useLHS - not needed
Robert Griesemer [Mon, 20 Mar 2023 20:32:04 +0000 (13:32 -0700)]
go/types: remove Checker.useLHS - not needed

We can just use Checker.use, as long as we take care of blank (_)
identifiers that may appear of the LHS of assignments. It's ok to
"use" non-blank variables in case of an error, even on the LHS.

This makes this code match the types2 implementation.

Change-Id: Ied9b9802ecb63912631bbde1dc6993ae855a691b
Reviewed-on: https://go-review.googlesource.com/c/go/+/477895
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>

2 years agogo.types, types2: factor out checking of LHS in variable assignment
Robert Griesemer [Mon, 20 Mar 2023 18:47:28 +0000 (11:47 -0700)]
go.types, types2: factor out checking of LHS in variable assignment

Step towards disentangling assignment checking functionality.
In preparation for reverse inference of function type arguments,
but independently helpful in better separating concerns in the code.

Change-Id: I9bac9d8005090c00d9ae6c5cfa13765aacce6b12
Reviewed-on: https://go-review.googlesource.com/c/go/+/477855
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2 years agogo/types, types2: refactor multiExpr and exprList
Robert Griesemer [Tue, 21 Mar 2023 04:04:14 +0000 (21:04 -0700)]
go/types, types2: refactor multiExpr and exprList

Preparation for simpler exprList use.

Change-Id: I2d62bbaba006aa3a378ec743564d46c5edcb8b47
Reviewed-on: https://go-review.googlesource.com/c/go/+/478016
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>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile/internal/types2: respect commaerr in Checker.exprList
Robert Griesemer [Tue, 21 Mar 2023 20:59:24 +0000 (13:59 -0700)]
cmd/compile/internal/types2: respect commaerr in Checker.exprList

The changes to exprList (in call.go), made in CL 282193, didn't
get faithfully ported to types2: in the case of operand mode
commaerr, unpacking didn't correctly set the type of the 2nd
value to error. This shouldn't matter for the compiler, but
the code differs from the go/types version. Make them the same.

Change-Id: I6f69575f9ad4f43169b851dffeed85c19588a261
Reviewed-on: https://go-review.googlesource.com/c/go/+/478255
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>

2 years agocmd/go: add a -debug-runtime-trace flag
Robert Findley [Mon, 20 Mar 2023 21:30:49 +0000 (17:30 -0400)]
cmd/go: add a -debug-runtime-trace flag

The runtime/trace package proved useful for investigating go command
performance, and it makes sense (to me) to make this available for
development behind an undocumented flag, at the cost of ~25KB of binary
size. We could of course futher hide this functionality behind an
experiment or build tag, if necessary.

Updates #59157

Change-Id: I612320920ca935f1ee10bb6a803b7952f36c939b
Reviewed-on: https://go-review.googlesource.com/c/go/+/477896
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>

2 years agocmd/go: extend the linker -o workaround for plugins to all platforms
Cherry Mui [Tue, 21 Mar 2023 20:27:14 +0000 (16:27 -0400)]
cmd/go: extend the linker -o workaround for plugins to all platforms

On Linux, for a shared object, at least with the Gold linker, the
output file path is recorded in the .gnu.version_d section. When
the output file path is in a temporary directory, it causes
nondeterministic build.

This is similar to #58557, but for Linux with the Gold linker.
Apply the same workaround as in CL 477296.

Should fix the linux-arm64-longtest builder.

Change-Id: Ic703bff32c1bcc40054b89be696e04280855e876
Reviewed-on: https://go-review.googlesource.com/c/go/+/478196
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agolog/slog: clarify Logger.WithGroup doc
Jonathan Amsterdam [Tue, 21 Mar 2023 12:57:43 +0000 (08:57 -0400)]
log/slog: clarify Logger.WithGroup doc

Make it clear that "qualified by the given name" doesn't imply
any particular implementation, but depends on how the Handler
treats groups.

Updates golang/go#56345.

Change-Id: Idf52553108bc1a7d2091a06cc4fc4cc0fc52cc14
Reviewed-on: https://go-review.googlesource.com/c/go/+/478056
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>

2 years agolog/slog: use unsafe.StringData, SliceData
Jonathan Amsterdam [Tue, 21 Mar 2023 12:23:20 +0000 (08:23 -0400)]
log/slog: use unsafe.StringData, SliceData

Use the new functions in 1.20 (unsafe.StringData, etc.) instead
of StringHeader and StructHeader from the reflect package.

Updates golang/go#56345.

Change-Id: I84d0db7b203aeffe45ce8b06beb7b4ee17e19949
Reviewed-on: https://go-review.googlesource.com/c/go/+/478055
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agolog/slog: initial commit
Jonathan Amsterdam [Fri, 17 Mar 2023 14:20:01 +0000 (10:20 -0400)]
log/slog: initial commit

The slog structured logging package.

This code was copied from the slog directory of the x/exp repo
at commit 642cacee5cc05231f45555a333d07f1005ffc287, with the
following changes:

- Change import paths.
- Delete unused files list.go, list_test.go.
- Rename example_depth_test.go to example_wrap_test.go and
  adjust example output.
- Change the tag safe_values to safe_slog_values.
- Make captureHandler goroutine-safe to fix a race condition
  in benchmarks.
- Other small changes as suggested in review comments.

Also, add dependencies to go/build/deps_test.go.

Also, add new API for the API checker.

Updates golang/go#56345.

Change-Id: Id8d720967571ced5c5f32c84a8dd9584943cd7df
Reviewed-on: https://go-review.googlesource.com/c/go/+/477295
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2 years agoruntime: bias the pacer's cons/mark smoothing against noise
Michael Anthony Knyszek [Mon, 13 Feb 2023 21:45:38 +0000 (21:45 +0000)]
runtime: bias the pacer's cons/mark smoothing against noise

Currently the pacer is designed to pace against the edge. Specifically,
it tries to find the sweet spot at which there are zero assists, but
simultaneously finishes each GC perfectly on time.

This pretty much works, despite the noisiness of the measurement of the
cons/mark ratio, which is central to the pacer's function. (And this
noise is basically a given; the cons/mark ratio is used as a prediction
under a steady-state assumption.) Typically, this means that the GC
might assist a little bit more because it started the GC late, or it
might execute more GC cycles because it started early. In many cases the
magnitude of this variation is small.

However, we can't possibly control for all sources of noise, especially
since some noise can come from the underlying system. Furthermore, there
are inputs to the measurement that have effectively no restrictions on
how they vary, and the pacer needs to assume that they're essentially
static when they might not be in some applications (i.e. goroutine
stacks).

The result of high noise is that the variation in when a GC starts is
much higher, leading to a significant amount of assists in some GC
cycles. While the GC cycle frequency basically averages out in the
steady-state in the face of this variation, starting a GC late has the
significant drawback of reducing application latencies.

This CL thus biases the pacer toward avoiding assists by picking a
cons/mark smoothing function that takes the maximum measured cons/mark
over 5 cycles total. I picked 5 cycles because empirically this was the
best trade-off between window size and smoothness for a uniformly
distributed jitter in the cons/mark signal. The cost here is that if
there's a significant phase change in the application that makes it less
active with the GC, then we'll be using a stale cons/mark measurement
for 5 cycles. I suspect this is fine precisely because this only happens
when the application becomes less active, i.e. when latency matters
less.

Another good reason for this particular bias is that even though the GC
might start earlier and end earlier on average, resulting in more
frequent GC cycles and potentially worse throughput, it also means that
it uses less memory used on average. As a result, there's a reasonable
workaround in just turning GOGC up slightly to reduce GC cycle
frequency and bringing memory (and hopefully throughput) levels back to
the same baseline. Meanwhile, there should still be fewer assists than
before which is just a clear improvement to latency.

Lastly, this CL updates the GC pacer tests to capture this bias against
assists and toward GC cycles starting earlier in the face of noise.

Sweet benchmarks didn't show any meaningful difference, but real
production applications showed a reduction in tail latencies of up
to 45%.

Updates #56966.

Change-Id: I8f03d793f9a1c6e7ef3524d18294dbc0d7de6122
Reviewed-on: https://go-review.googlesource.com/c/go/+/467875
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

2 years agoruntime: for deep stacks, print both the top 50 and bottom 50 frames
Austin Clements [Mon, 13 Mar 2023 18:02:16 +0000 (14:02 -0400)]
runtime: for deep stacks, print both the top 50 and bottom 50 frames

This is relatively easy using the new traceback iterator.

Ancestor tracebacks are now limited to 50 frames. We could keep that
at 100, but the fact that it used 100 before seemed arbitrary and
unnecessary.

Fixes #7181
Updates #54466

Change-Id: If693045881d84848f17e568df275a5105b6f1cb0
Reviewed-on: https://go-review.googlesource.com/c/go/+/475960
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agoruntime: let (*sigctxt).r9 return the correct register value on netbsd
Tobias Klauser [Tue, 21 Mar 2023 16:44:29 +0000 (17:44 +0100)]
runtime: let (*sigctxt).r9 return the correct register value on netbsd

Fixes #59152

Change-Id: I7f89e2b48db9ff120d7cd094b72ded865874e961
Reviewed-on: https://go-review.googlesource.com/c/go/+/478135
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2 years agocmd/link: improve error message and debugging
Cherry Mui [Wed, 15 Mar 2023 21:38:35 +0000 (17:38 -0400)]
cmd/link: improve error message and debugging

Correct an error message to missing section, not unreachable
symbol.

Also, under -v >= 2, dump symbol info on error for debugging.

Updates #58966.

Change-Id: I0f832c517d64f4b672b313a8b9be2d028744f945
Reviewed-on: https://go-review.googlesource.com/c/go/+/476735
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years agointernal/bytealg: rewrite PPC64 Compare
Paul E. Murphy [Mon, 27 Feb 2023 22:04:50 +0000 (16:04 -0600)]
internal/bytealg: rewrite PPC64 Compare

Merge the P8 and P9 paths into one. This removes the need for
a runtime CPU check and maintaining two separate code paths.

This takes advantage of overlapping checks, and the P9 SETB
(emulated with little overhead on P8) to speed up comparisons
of small strings.

Similarly, the SETB instruction can be used on GOPPC64=power9
which provides a small speedup over using a couple ISELs. This
only accounts for a few percent on very small strings, thus
results of running P8 codegen on P9 are left out.

For the baseline on a power8 machine:

BytesCompare/1     7.76ns ± 0%  6.38ns ± 0%  -17.71%
BytesCompare/2     7.77ns ± 0%  6.36ns ± 0%  -18.12%
BytesCompare/3     7.56ns ± 0%  6.36ns ± 0%  -15.79%
BytesCompare/4     7.76ns ± 0%  5.74ns ± 0%  -25.99%
BytesCompare/5     7.48ns ± 0%  5.74ns ± 0%  -23.29%
BytesCompare/6     7.56ns ± 0%  5.74ns ± 0%  -24.06%
BytesCompare/7     7.14ns ± 0%  5.74ns ± 0%  -19.63%
BytesCompare/8     5.58ns ± 0%  5.19ns ± 0%   -7.03%
BytesCompare/9     7.85ns ± 0%  5.19ns ± 0%  -33.86%
BytesCompare/10    7.87ns ± 0%  5.19ns ± 0%  -34.06%
BytesCompare/11    7.59ns ± 0%  5.19ns ± 0%  -31.59%
BytesCompare/12    7.87ns ± 0%  5.19ns ± 0%  -34.02%
BytesCompare/13    7.55ns ± 0%  5.19ns ± 0%  -31.24%
BytesCompare/14    7.47ns ± 0%  5.19ns ± 0%  -30.53%
BytesCompare/15    7.88ns ± 0%  5.19ns ± 0%  -34.09%
BytesCompare/16    6.07ns ± 0%  5.58ns ± 0%   -8.08%
BytesCompare/17    9.05ns ± 0%  5.62ns ± 0%  -37.94%
BytesCompare/18    8.95ns ± 0%  5.62ns ± 0%  -37.24%
BytesCompare/19    8.49ns ± 0%  5.62ns ± 0%  -33.81%
BytesCompare/20    9.07ns ± 0%  5.62ns ± 0%  -38.05%
BytesCompare/21    8.69ns ± 0%  5.62ns ± 0%  -35.37%
BytesCompare/22    8.57ns ± 0%  5.62ns ± 0%  -34.43%
BytesCompare/23    8.31ns ± 0%  5.62ns ± 0%  -32.38%
BytesCompare/24    8.42ns ± 0%  5.62ns ± 0%  -33.23%
BytesCompare/25    9.70ns ± 0%  5.56ns ± 0%  -42.69%
BytesCompare/26    9.53ns ± 0%  5.56ns ± 0%  -41.66%
BytesCompare/27    9.29ns ± 0%  5.56ns ± 0%  -40.15%
BytesCompare/28    9.53ns ± 0%  5.56ns ± 0%  -41.65%
BytesCompare/29    9.37ns ± 0%  5.56ns ± 0%  -40.63%
BytesCompare/30    9.17ns ± 0%  5.56ns ± 0%  -39.36%
BytesCompare/31    9.07ns ± 0%  5.56ns ± 0%  -38.71%
BytesCompare/32    5.81ns ± 0%  5.49ns ± 0%   -5.49%
BytesCompare/33    9.36ns ± 0%  5.32ns ± 0%  -43.17%
BytesCompare/34    9.44ns ± 0%  5.32ns ± 0%  -43.68%
BytesCompare/35    8.91ns ± 0%  5.32ns ± 0%  -40.29%
BytesCompare/36    9.45ns ± 0%  5.32ns ± 0%  -43.71%
BytesCompare/37    8.94ns ± 0%  5.32ns ± 0%  -40.53%
BytesCompare/38    9.08ns ± 0%  5.32ns ± 0%  -41.44%
BytesCompare/39    8.62ns ± 0%  5.32ns ± 0%  -38.33%
BytesCompare/40    7.93ns ± 0%  5.32ns ± 0%  -32.93%
BytesCompare/41    10.1ns ± 0%   5.3ns ± 0%  -47.08%
BytesCompare/42    10.1ns ± 0%   5.3ns ± 0%  -47.43%
BytesCompare/43    9.80ns ± 0%  5.32ns ± 0%  -45.66%
BytesCompare/44    10.3ns ± 0%   5.3ns ± 0%  -48.26%
BytesCompare/45    9.88ns ± 0%  5.33ns ± 0%  -46.08%
BytesCompare/46    9.82ns ± 0%  5.32ns ± 0%  -45.81%
BytesCompare/47    9.73ns ± 0%  5.33ns ± 0%  -45.25%
BytesCompare/48    8.31ns ± 0%  5.22ns ± 0%  -37.19%
BytesCompare/49    11.2ns ± 0%   5.2ns ± 0%  -53.28%
BytesCompare/50    11.1ns ± 0%   5.2ns ± 0%  -52.86%
BytesCompare/51    10.8ns ± 0%   5.2ns ± 0%  -51.37%
BytesCompare/52    11.1ns ± 0%   5.2ns ± 0%  -52.94%
BytesCompare/53    10.8ns ± 0%   5.2ns ± 0%  -51.50%
BytesCompare/54    10.7ns ± 0%   5.2ns ± 0%  -51.09%
BytesCompare/55    10.3ns ± 0%   5.2ns ± 0%  -49.49%
BytesCompare/56    10.9ns ± 0%   5.2ns ± 0%  -51.73%
BytesCompare/57    12.2ns ± 0%   5.3ns ± 0%  -56.92%
BytesCompare/58    12.2ns ± 0%   5.3ns ± 0%  -56.81%
BytesCompare/59    11.5ns ± 0%   5.3ns ± 0%  -54.45%
BytesCompare/60    12.1ns ± 0%   5.3ns ± 0%  -56.67%
BytesCompare/61    11.7ns ± 0%   5.3ns ± 0%  -54.96%
BytesCompare/62    11.9ns ± 0%   5.3ns ± 0%  -55.76%
BytesCompare/63    11.4ns ± 0%   5.3ns ± 0%  -53.73%
BytesCompare/64    6.08ns ± 0%  5.47ns ± 0%   -9.96%
BytesCompare/65    9.87ns ± 0%  5.96ns ± 0%  -39.57%
BytesCompare/66    9.81ns ± 0%  5.96ns ± 0%  -39.25%
BytesCompare/67    9.49ns ± 0%  5.96ns ± 0%  -37.18%
BytesCompare/68    9.81ns ± 0%  5.96ns ± 0%  -39.26%
BytesCompare/69    9.44ns ± 0%  5.96ns ± 0%  -36.84%
BytesCompare/70    9.58ns ± 0%  5.96ns ± 0%  -37.75%
BytesCompare/71    9.24ns ± 0%  5.96ns ± 0%  -35.50%
BytesCompare/72    8.26ns ± 0%  5.94ns ± 0%  -28.09%
BytesCompare/73    10.6ns ± 0%   5.9ns ± 0%  -43.70%
BytesCompare/74    10.6ns ± 0%   5.9ns ± 0%  -43.87%
BytesCompare/75    10.2ns ± 0%   5.9ns ± 0%  -41.83%
BytesCompare/76    10.7ns ± 0%   5.9ns ± 0%  -44.55%
BytesCompare/77    10.3ns ± 0%   5.9ns ± 0%  -42.51%
BytesCompare/78    10.3ns ± 0%   5.9ns ± 0%  -42.29%
BytesCompare/79    10.2ns ± 0%   5.9ns ± 0%  -41.95%
BytesCompare/80    8.74ns ± 0%  5.93ns ± 0%  -32.23%
BytesCompare/81    11.7ns ± 0%   6.8ns ± 0%  -41.87%
BytesCompare/82    11.7ns ± 0%   6.8ns ± 0%  -41.54%
BytesCompare/83    11.1ns ± 0%   6.8ns ± 0%  -38.32%
BytesCompare/84    11.7ns ± 0%   6.8ns ± 0%  -41.59%
BytesCompare/85    11.2ns ± 0%   6.8ns ± 0%  -38.93%
BytesCompare/86    11.2ns ± 0%   6.8ns ± 0%  -38.87%
BytesCompare/87    10.8ns ± 0%   6.8ns ± 0%  -37.07%
BytesCompare/88    11.3ns ± 0%   6.7ns ± 0%  -40.57%
BytesCompare/89    12.6ns ± 0%   6.7ns ± 0%  -46.57%
BytesCompare/90    12.6ns ± 0%   6.7ns ± 0%  -46.44%
BytesCompare/91    11.9ns ± 0%   6.7ns ± 0%  -43.66%
BytesCompare/92    12.5ns ± 0%   6.7ns ± 0%  -46.09%
BytesCompare/93    12.2ns ± 0%   6.7ns ± 0%  -44.90%
BytesCompare/94    12.4ns ± 0%   6.7ns ± 0%  -45.62%
BytesCompare/95    11.8ns ± 0%   6.7ns ± 0%  -43.00%
BytesCompare/96    7.25ns ± 0%  6.62ns ± 0%   -8.70%
BytesCompare/97    11.1ns ± 0%   7.2ns ± 0%  -34.98%
BytesCompare/98    10.9ns ± 0%   7.2ns ± 0%  -34.03%
BytesCompare/99    10.4ns ± 0%   7.2ns ± 0%  -31.19%
BytesCompare/100   10.9ns ± 0%   7.2ns ± 0%  -33.97%
BytesCompare/101   10.4ns ± 0%   7.2ns ± 0%  -31.19%
BytesCompare/102   10.7ns ± 0%   7.2ns ± 0%  -32.72%
BytesCompare/103   10.2ns ± 0%   7.2ns ± 0%  -29.28%
BytesCompare/104   9.38ns ± 0%  7.19ns ± 0%  -23.33%
BytesCompare/105   11.7ns ± 0%   7.2ns ± 0%  -38.60%
BytesCompare/106   11.7ns ± 0%   7.2ns ± 0%  -38.28%
BytesCompare/107   11.3ns ± 0%   7.2ns ± 0%  -36.48%
BytesCompare/108   11.7ns ± 0%   7.2ns ± 0%  -38.49%
BytesCompare/109   11.4ns ± 0%   7.2ns ± 0%  -36.76%
BytesCompare/110   11.3ns ± 0%   7.2ns ± 0%  -36.37%
BytesCompare/111   11.1ns ± 0%   7.2ns ± 0%  -35.05%
BytesCompare/112   9.95ns ± 0%  7.19ns ± 0%  -27.71%
BytesCompare/113   12.7ns ± 0%   7.0ns ± 0%  -44.71%
BytesCompare/114   12.6ns ± 0%   7.0ns ± 0%  -44.23%
BytesCompare/115   12.3ns ± 0%   7.0ns ± 0%  -42.83%
BytesCompare/116   12.7ns ± 0%   7.0ns ± 0%  -44.67%
BytesCompare/117   12.2ns ± 0%   7.0ns ± 0%  -42.41%
BytesCompare/118   12.2ns ± 0%   7.0ns ± 0%  -42.50%
BytesCompare/119   11.9ns ± 0%   7.0ns ± 0%  -40.76%
BytesCompare/120   12.3ns ± 0%   7.0ns ± 0%  -43.01%
BytesCompare/121   13.7ns ± 0%   7.0ns ± 0%  -48.55%
BytesCompare/122   13.6ns ± 0%   7.0ns ± 0%  -48.06%
BytesCompare/123   12.9ns ± 0%   7.0ns ± 0%  -45.44%
BytesCompare/124   13.5ns ± 0%   7.0ns ± 0%  -47.91%
BytesCompare/125   13.0ns ± 0%   7.0ns ± 0%  -46.03%
BytesCompare/126   13.2ns ± 0%   7.0ns ± 0%  -46.72%
BytesCompare/127   12.9ns ± 0%   7.0ns ± 0%  -45.36%
BytesCompare/128   7.53ns ± 0%  6.78ns ± 0%   -9.95%
BytesCompare/256   10.1ns ± 0%   9.6ns ± 0%   -4.35%
BytesCompare/512   23.0ns ± 0%  15.3ns ± 0%  -33.30%
BytesCompare/1024  36.4ns ± 0%  32.8ns ± 0%   -9.83%
BytesCompare/2048  62.0ns ± 0%  56.0ns ± 0%   -9.77%

For GOPPC64=power9 on power9:

BytesCompare/1     5.95ns ± 0%  4.83ns ± 0%  -18.89%
BytesCompare/2     6.37ns ± 0%  4.69ns ± 0%  -26.39%
BytesCompare/3     6.87ns ± 0%  4.68ns ± 0%  -31.79%
BytesCompare/4     5.86ns ± 0%  4.63ns ± 0%  -20.98%
BytesCompare/5     5.84ns ± 0%  4.63ns ± 0%  -20.67%
BytesCompare/6     5.84ns ± 0%  4.63ns ± 0%  -20.70%
BytesCompare/7     5.82ns ± 0%  4.63ns ± 0%  -20.40%
BytesCompare/8     5.81ns ± 0%  4.64ns ± 0%  -20.23%
BytesCompare/9     5.83ns ± 0%  4.71ns ± 0%  -19.19%
BytesCompare/10    6.22ns ± 0%  4.71ns ± 0%  -24.32%
BytesCompare/11    6.94ns ± 0%  4.71ns ± 0%  -32.16%
BytesCompare/12    5.77ns ± 0%  4.71ns ± 0%  -18.34%
BytesCompare/13    5.77ns ± 0%  4.71ns ± 0%  -18.44%
BytesCompare/14    5.77ns ± 0%  4.71ns ± 0%  -18.31%
BytesCompare/15    6.31ns ± 0%  4.71ns ± 0%  -25.32%
BytesCompare/16    4.99ns ± 0%  5.03ns ± 0%   +0.72%
BytesCompare/17    5.07ns ± 0%  5.03ns ± 0%   -0.87%
BytesCompare/18    5.07ns ± 0%  5.03ns ± 0%   -0.81%
BytesCompare/19    5.07ns ± 0%  5.03ns ± 0%   -0.85%
BytesCompare/20    5.07ns ± 0%  5.03ns ± 0%   -0.73%
BytesCompare/21    5.07ns ± 0%  5.03ns ± 0%   -0.81%
BytesCompare/22    5.07ns ± 0%  5.03ns ± 0%   -0.77%
BytesCompare/23    5.07ns ± 0%  5.03ns ± 0%   -0.75%
BytesCompare/24    5.08ns ± 0%  5.07ns ± 0%   -0.12%
BytesCompare/25    5.03ns ± 0%  5.00ns ± 0%   -0.60%
BytesCompare/26    5.02ns ± 0%  5.00ns ± 0%   -0.56%
BytesCompare/27    5.03ns ± 0%  5.00ns ± 0%   -0.60%
BytesCompare/28    5.03ns ± 0%  5.00ns ± 0%   -0.72%
BytesCompare/29    5.03ns ± 0%  5.00ns ± 0%   -0.68%
BytesCompare/30    5.03ns ± 0%  5.00ns ± 0%   -0.76%
BytesCompare/31    5.03ns ± 0%  5.00ns ± 0%   -0.60%
BytesCompare/32    5.02ns ± 0%  5.05ns ± 0%   +0.56%
BytesCompare/33    6.78ns ± 0%  5.16ns ± 0%  -23.84%
BytesCompare/34    7.26ns ± 0%  5.16ns ± 0%  -28.93%
BytesCompare/35    7.78ns ± 0%  5.16ns ± 0%  -33.65%
BytesCompare/36    6.72ns ± 0%  5.16ns ± 0%  -23.24%
BytesCompare/37    7.32ns ± 0%  5.16ns ± 0%  -29.55%
BytesCompare/38    7.26ns ± 0%  5.16ns ± 0%  -28.95%
BytesCompare/39    7.99ns ± 0%  5.16ns ± 0%  -35.40%
BytesCompare/40    6.67ns ± 0%  5.11ns ± 0%  -23.41%
BytesCompare/41    7.25ns ± 0%  5.14ns ± 0%  -29.05%
BytesCompare/42    7.47ns ± 0%  5.14ns ± 0%  -31.11%
BytesCompare/43    7.97ns ± 0%  5.14ns ± 0%  -35.42%
BytesCompare/44    7.29ns ± 0%  5.14ns ± 0%  -29.38%
BytesCompare/45    8.06ns ± 0%  5.14ns ± 0%  -36.20%
BytesCompare/46    7.89ns ± 0%  5.14ns ± 0%  -34.77%
BytesCompare/47    8.59ns ± 0%  5.14ns ± 0%  -40.13%
BytesCompare/48    5.57ns ± 0%  5.12ns ± 0%   -8.18%
BytesCompare/49    6.05ns ± 0%  5.17ns ± 0%  -14.48%
BytesCompare/50    6.05ns ± 0%  5.17ns ± 0%  -14.51%
BytesCompare/51    6.06ns ± 0%  5.17ns ± 0%  -14.61%
BytesCompare/52    6.05ns ± 0%  5.17ns ± 0%  -14.54%
BytesCompare/53    6.06ns ± 0%  5.17ns ± 0%  -14.56%
BytesCompare/54    6.05ns ± 0%  5.17ns ± 0%  -14.54%
BytesCompare/55    6.05ns ± 0%  5.17ns ± 0%  -14.54%
BytesCompare/56    6.02ns ± 0%  5.11ns ± 0%  -15.13%
BytesCompare/57    6.01ns ± 0%  5.14ns ± 0%  -14.56%
BytesCompare/58    6.02ns ± 0%  5.14ns ± 0%  -14.59%
BytesCompare/59    6.02ns ± 0%  5.14ns ± 0%  -14.65%
BytesCompare/60    6.03ns ± 0%  5.14ns ± 0%  -14.71%
BytesCompare/61    6.02ns ± 0%  5.14ns ± 0%  -14.69%
BytesCompare/62    6.01ns ± 0%  5.14ns ± 0%  -14.55%
BytesCompare/63    6.02ns ± 0%  5.14ns ± 0%  -14.65%
BytesCompare/64    6.09ns ± 0%  5.15ns ± 0%  -15.34%
BytesCompare/65    7.83ns ± 0%  5.93ns ± 0%  -24.17%
BytesCompare/66    7.86ns ± 0%  5.93ns ± 0%  -24.52%
BytesCompare/67    8.56ns ± 0%  5.93ns ± 0%  -30.68%
BytesCompare/68    7.90ns ± 0%  5.93ns ± 0%  -24.88%
BytesCompare/69    8.58ns ± 0%  5.93ns ± 0%  -30.84%
BytesCompare/70    8.54ns ± 0%  5.93ns ± 0%  -30.48%
BytesCompare/71    9.18ns ± 0%  5.94ns ± 0%  -35.34%
BytesCompare/72    7.89ns ± 0%  5.86ns ± 0%  -25.76%
BytesCompare/73    8.59ns ± 0%  5.82ns ± 0%  -32.25%
BytesCompare/74    8.52ns ± 0%  5.82ns ± 0%  -31.61%
BytesCompare/75    9.17ns ± 0%  5.82ns ± 0%  -36.50%
BytesCompare/76    8.54ns ± 0%  5.82ns ± 0%  -31.85%
BytesCompare/77    9.25ns ± 0%  5.82ns ± 0%  -37.07%
BytesCompare/78    9.17ns ± 0%  5.82ns ± 0%  -36.48%
BytesCompare/79    10.0ns ± 0%   5.8ns ± 0%  -41.66%
BytesCompare/80    6.76ns ± 0%  5.69ns ± 0%  -15.90%
BytesCompare/81    7.63ns ± 0%  6.70ns ± 0%  -12.23%
BytesCompare/82    7.63ns ± 0%  6.70ns ± 0%  -12.23%
BytesCompare/83    7.63ns ± 0%  6.70ns ± 0%  -12.24%
BytesCompare/84    7.63ns ± 0%  6.70ns ± 0%  -12.24%
BytesCompare/85    7.63ns ± 0%  6.70ns ± 0%  -12.23%
BytesCompare/86    7.63ns ± 0%  6.70ns ± 0%  -12.24%
BytesCompare/87    7.63ns ± 0%  6.70ns ± 0%  -12.24%
BytesCompare/88    7.53ns ± 0%  6.56ns ± 0%  -12.90%
BytesCompare/89    7.53ns ± 0%  6.55ns ± 0%  -12.93%
BytesCompare/90    7.53ns ± 0%  6.55ns ± 0%  -12.93%
BytesCompare/91    7.53ns ± 0%  6.55ns ± 0%  -12.93%
BytesCompare/92    7.53ns ± 0%  6.55ns ± 0%  -12.93%
BytesCompare/93    7.53ns ± 0%  6.55ns ± 0%  -12.93%
BytesCompare/94    7.53ns ± 0%  6.55ns ± 0%  -12.93%
BytesCompare/95    7.53ns ± 0%  6.55ns ± 0%  -12.94%
BytesCompare/96    7.02ns ± 0%  6.45ns ± 0%   -8.09%
BytesCompare/97    8.73ns ± 0%  7.39ns ± 0%  -15.35%
BytesCompare/98    8.71ns ± 0%  7.39ns ± 0%  -15.15%
BytesCompare/99    9.42ns ± 0%  7.39ns ± 0%  -21.57%
BytesCompare/100   8.73ns ± 0%  7.39ns ± 0%  -15.36%
BytesCompare/101   9.43ns ± 0%  7.39ns ± 0%  -21.70%
BytesCompare/102   9.42ns ± 0%  7.39ns ± 0%  -21.59%
BytesCompare/103   10.2ns ± 0%   7.4ns ± 0%  -27.58%
BytesCompare/104   8.74ns ± 0%  7.35ns ± 0%  -15.95%
BytesCompare/105   9.44ns ± 0%  7.30ns ± 0%  -22.67%
BytesCompare/106   9.44ns ± 0%  7.30ns ± 0%  -22.69%
BytesCompare/107   10.2ns ± 0%   7.3ns ± 0%  -28.53%
BytesCompare/108   9.48ns ± 0%  7.30ns ± 0%  -23.04%
BytesCompare/109   10.2ns ± 0%   7.3ns ± 0%  -28.81%
BytesCompare/110   10.2ns ± 0%   7.3ns ± 0%  -28.39%
BytesCompare/111   10.9ns ± 0%   7.3ns ± 0%  -33.18%
BytesCompare/112   7.75ns ± 0%  7.16ns ± 0%   -7.60%
BytesCompare/113   8.57ns ± 0%  7.83ns ± 0%   -8.60%
BytesCompare/114   8.57ns ± 0%  7.83ns ± 0%   -8.63%
BytesCompare/115   8.57ns ± 0%  7.83ns ± 0%   -8.56%
BytesCompare/116   8.57ns ± 0%  7.83ns ± 0%   -8.57%
BytesCompare/117   8.57ns ± 0%  7.83ns ± 0%   -8.56%
BytesCompare/118   8.57ns ± 0%  7.83ns ± 0%   -8.56%
BytesCompare/119   8.57ns ± 0%  7.83ns ± 0%   -8.61%
BytesCompare/120   8.46ns ± 0%  7.71ns ± 0%   -8.80%
BytesCompare/121   8.46ns ± 0%  7.72ns ± 0%   -8.77%
BytesCompare/122   8.46ns ± 0%  7.72ns ± 0%   -8.78%
BytesCompare/123   8.46ns ± 0%  7.72ns ± 0%   -8.76%
BytesCompare/124   8.46ns ± 0%  7.72ns ± 0%   -8.70%
BytesCompare/125   8.46ns ± 0%  7.72ns ± 0%   -8.70%
BytesCompare/126   8.46ns ± 0%  7.72ns ± 0%   -8.70%
BytesCompare/127   8.46ns ± 0%  7.72ns ± 0%   -8.71%
BytesCompare/128   8.19ns ± 0%  7.35ns ± 0%  -10.29%
BytesCompare/256   12.8ns ± 0%  11.4ns ± 0%  -11.23%
BytesCompare/512   22.2ns ± 0%  20.7ns ± 0%   -6.80%
BytesCompare/1024  41.1ns ± 0%  39.8ns ± 0%   -3.12%
BytesCompare/2048  86.5ns ± 0%  81.1ns ± 0%   -6.31%

Change-Id: I7c7fb1f7b891c23c6cade580e7b9928ca1a6efc3
Reviewed-on: https://go-review.googlesource.com/c/go/+/474496
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agocmd/internal/obj/loong64: add support for movgr2cf and movcf2gr instructions
Huang Qiqi [Mon, 13 Mar 2023 10:50:49 +0000 (18:50 +0800)]
cmd/internal/obj/loong64: add support for movgr2cf and movcf2gr instructions

Change-Id: I7ff3c8df24ed7990fe104bc2530354c0bd5fe018
Reviewed-on: https://go-review.googlesource.com/c/go/+/475576
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
2 years agocmd/asm, runtime: remove the RSB register from loong64
WANG Xuerui [Mon, 13 Mar 2023 08:20:50 +0000 (16:20 +0800)]
cmd/asm, runtime: remove the RSB register from loong64

It was carryover from the mips64 port (where it represented the platform
GP register) but LoongArch platform ABI doesn't have the GP concept.

Change-Id: Iea326ae13676e95b040b52aaadc08d311b507bd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/475815
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years agoruntime: reuse freed memory blocks on wasm
Achille Roussel [Mon, 20 Mar 2023 22:16:21 +0000 (22:16 +0000)]
runtime: reuse freed memory blocks on wasm

When compiling Go programs to WebAssembly, the memory allocation
strategy was neither releasing memory to the OS nor reusing blocks freed
by calls to runtime.sysFreeOS.

This CL unifies the plan9 and wasm memory management strategy
since both platforms use a linear memory space and do not have a
mechanism for returning memory blocks to the OS.

Fixes #59061

Change-Id: I282ba93c0fe1a0961a31c0825b2a7e0478b8713d
GitHub-Last-Rev: 1c485be4fb798679fde7db148392de558a6fa97c
GitHub-Pull-Request: golang/go#59065
Reviewed-on: https://go-review.googlesource.com/c/go/+/476717
Reviewed-by: Julien Fabre <ju.pryz@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Evan Phoenix <evan@phx.io>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agocmd/go: use platform.MustLinkExternal in externalLinkingForced
Ian Lance Taylor [Mon, 20 Mar 2023 21:39:05 +0000 (14:39 -0700)]
cmd/go: use platform.MustLinkExternal in externalLinkingForced

This is a roll-forward of CL 477395 which was rolled back in CL 477736.
The earlier CL failed because we didn't account for the fact that
on some targets PIE is the default. That is now fixed.

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

2 years agocmd/go: rewrite externalLinkingForced slightly for clarity
Ian Lance Taylor [Mon, 20 Mar 2023 21:30:09 +0000 (14:30 -0700)]
cmd/go: rewrite externalLinkingForced slightly for clarity

Change-Id: I8f8d38c48d4ffe70d15330ea0d4794f264c88f25
Reviewed-on: https://go-review.googlesource.com/c/go/+/477918
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: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agocmd/go: use DefaultPIE to see if external linking is forced
Ian Lance Taylor [Mon, 20 Mar 2023 21:20:22 +0000 (14:20 -0700)]
cmd/go: use DefaultPIE to see if external linking is forced

Before this CL, the code checked whether external linking was
required for -buildmode=pie. This CL changes it to also consider
whether external linking is required if PIE is the default build mode.

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

2 years agointernal/platform: pass race mode to DefaultPIE
Ian Lance Taylor [Mon, 20 Mar 2023 21:08:59 +0000 (14:08 -0700)]
internal/platform: pass race mode to DefaultPIE

On Windows we default to PIE, except in race mode.
Pass isRace to platform.DefaultPIE to centralize that decision.
This is in preparation for adding another call to DefaultPIE.

Change-Id: I91b75d307e7d4d260246a934f98734ddcbca372a
Reviewed-on: https://go-review.googlesource.com/c/go/+/477916
TryBot-Result: Gopher Robot <gobot@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>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

2 years agoall: gofmt
Damien Neil [Mon, 20 Mar 2023 20:01:14 +0000 (13:01 -0700)]
all: gofmt

Change-Id: I926388ee5aeeff11f765cbd4558b66645d1bbc08
Reviewed-on: https://go-review.googlesource.com/c/go/+/477836
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/go: import runtime/cgo when externally linking
Ian Lance Taylor [Mon, 20 Mar 2023 19:53:22 +0000 (12:53 -0700)]
cmd/go: import runtime/cgo when externally linking

Restore CL 477195, which was reverted in CL 477795.
This version includes CL 477397, which fixes the test problems
with CL 477195. CL 477397 was not submitted because it had an
unrelated failure on darwin-amd64. That failure is fixed by CL 477736.

Fixes #31544

Change-Id: I3a2258cd0ca295cede3511ab212e56fd0114f94a
Reviewed-on: https://go-review.googlesource.com/c/go/+/477839
Reviewed-by: Bryan Mills <bcmills@google.com>
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>

2 years agoRevert "cmd/go: use platform.MustLinkExternal in externalLinkingForced"
Ian Lance Taylor [Mon, 20 Mar 2023 17:54:31 +0000 (10:54 -0700)]
Revert "cmd/go: use platform.MustLinkExternal in externalLinkingForced"

This reverts CL 477395.

Failing on darwin-amd64 builders:
https://build.golang.org/log/b07ec5e40a896f5d099e4c85f4094321ecc84f21

loadinternal: cannot find runtime/cgo
signal: trace/BPT trap
FAIL crypto/x509 0.024s
FAIL
2023/03/20 12:16:35 Failed: exit status 1

Change-Id: Ib9923f9ff7e24c3b5f8690ba1d6b5d0b6693d49c
Reviewed-on: https://go-review.googlesource.com/c/go/+/477736
TryBot-Result: Gopher Robot <gobot@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>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

2 years agocmd/link/internal/ld: emit better complex types for COFF symbols
qmuntal [Mon, 13 Mar 2023 14:10:59 +0000 (15:10 +0100)]
cmd/link/internal/ld: emit better complex types for COFF symbols

The Go linker has always used IMAGE_SYM_TYPE_NULL as COFF symbol
type [1] when external linking and array of structs
(IMAGE_SYM_DTYPE_ARRAY<<4+IMAGE_SYM_TYPE_STRUCT) when internal linking.
This behavior seems idiosyncratic, and looking at the git history it
seems that it has probably been cargo culted from earlier toolchains.

This CL updates the Go linker to use IMAGE_SYM_DTYPE_FUNCTION<<4 for
those symbols representing functions, and IMAGE_SYM_TYPE_NULL otherwise.

This new behavior better represents the symbol types, and can help
other tools interpreting the intent of each symbol, e.g. debuggers or
tools extracting debug info from Go binaries. It also mimics what other
toolchains do, i.e. MSVC, LLVM, and GCC.

[1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#type-representation

Change-Id: I6b39b2048e95f0324b2eb90c85802ce42db455d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/475856
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>

2 years agocmd/compile: add rewrite rules for arithmetic operations
Yi Yang [Sun, 19 Mar 2023 07:24:04 +0000 (07:24 +0000)]
cmd/compile: add rewrite rules for arithmetic operations

Add the following common local transformations

(t + x) - (t + y) == x - y
(t + x) - (y + t) == x - y
(x + t) - (y + t) == x - y
(x + t) - (t + y) == x - y
(x - t) + (t + y) == x + y
(x - t) + (y + t) == x + y

The compiler itself matches such patterns many times. This also aligns with other popular compilers.

Fixes #59111

Change-Id: Ibdfdb414782f8fcaa20b84ac5d43d0d9ae2c7b60
GitHub-Last-Rev: 1aad82e62e61e89789932c2070851a023f130dd8
GitHub-Pull-Request: golang/go#59119
Reviewed-on: https://go-review.googlesource.com/c/go/+/477555
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Heschi Kreinick <heschi@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>

2 years agoRevert "cmd/go: import runtime/cgo when externally linking"
Bryan Mills [Mon, 20 Mar 2023 14:31:59 +0000 (14:31 +0000)]
Revert "cmd/go: import runtime/cgo when externally linking"

This reverts CL 477195.

Reason for revert: test fails on darwin and solaris builders.

Change-Id: I68085f06bc84b0b8649804b8968626ed0e788931
Reviewed-on: https://go-review.googlesource.com/c/go/+/477795
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Bypass: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agodebug/dwarf: return ErrUnknownPC rather than nil on unknown PC
Joel Sing [Thu, 2 Mar 2023 14:24:06 +0000 (01:24 +1100)]
debug/dwarf: return ErrUnknownPC rather than nil on unknown PC

Currently, on e == nil or e.Tag == 0, SeekPC returns with a nil error.
Instead, indicate that the PC is unknown.

Change-Id: I9594296034e2df872e399bd800b00cb565c413c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/473695
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

2 years agoruntime: provide and use a GO_PPC64X_HAS_FUNCDESC define
Joel Sing [Tue, 14 Mar 2023 09:50:38 +0000 (20:50 +1100)]
runtime: provide and use a GO_PPC64X_HAS_FUNCDESC define

Rather than implying that all ppc64 GOARCHs use function descriptors,
provide a define for platforms that make use of function descriptors.
Condition on GO_PPC64X_HAS_FUNCDESC when choosing whether or not
to load the entry address from the first slot of the function
descriptor.

Updates #56001.

Change-Id: I9cdc788f2de70a1262c17d8485b555383d1374b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/476117
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agointernal/cpu: add default osinit for ppc64/ppc64le
Joel Sing [Thu, 2 Mar 2023 14:23:52 +0000 (01:23 +1100)]
internal/cpu: add default osinit for ppc64/ppc64le

This will be used for operating systems other than AIX and Linux (both of
which provide a more specific version).

Updates #56001

Change-Id: Ia1de994866b66f03c83696faa92d0531a0b75273
Reviewed-on: https://go-review.googlesource.com/c/go/+/473698
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/dist: add openbsd/ppc64 as a known GOOS/GOARCH
Joel Sing [Sat, 11 Mar 2023 15:08:45 +0000 (02:08 +1100)]
cmd/dist: add openbsd/ppc64 as a known GOOS/GOARCH

Also map uname output containing powerpc64 to ppc64 on openbsd.

Updates #56001

Change-Id: I6a4470cb0e5d6c6940d5268a6a06d23430c7859a
Reviewed-on: https://go-review.googlesource.com/c/go/+/475635
Reviewed-by: Eric Grosse <grosse@gmail.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoerrors: clarify Join documentation
David Bendory [Fri, 17 Mar 2023 14:04:01 +0000 (14:04 +0000)]
errors: clarify Join documentation

The previous documentation used a double-negative in describing Join behavior; this use of language could be confusing.

This update removes the double-negative.

Change-Id: If13e88682e865314a556e7d381143a97fa5486d9
GitHub-Last-Rev: 92b3f88a5d49229e71adafcfa7b1d01dcb7646f3
GitHub-Pull-Request: golang/go#59082
Reviewed-on: https://go-review.googlesource.com/c/go/+/477095
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

2 years agocmd/go: make sure linker -o for plugin doesn't include tempdir path
Michael Matloob [Fri, 17 Mar 2023 15:40:25 +0000 (11:40 -0400)]
cmd/go: make sure linker -o for plugin doesn't include tempdir path

There is already a case that when buildmode=shared passes only the
basename of the -o argument to the link command to the linker (and
runs in the directory of that argument) to avoid having that
(temporary) directory of the file be included in the LC_ID_DYLIB load
command. Extend the case to buildmode=plugin, because the same thing
can happen there.

This can only happen on darwin: the -o command can be embedded into
Mach-O and PE binaries, but plugin isn't supported on Windows.

For #58557

Change-Id: I7a4a5627148e77c6906ac4583af3d9f053d5b249
Reviewed-on: https://go-review.googlesource.com/c/go/+/477296
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 years agocmd/go: use platform.MustLinkExternal in externalLinkingForced
Ian Lance Taylor [Fri, 17 Mar 2023 19:40:25 +0000 (12:40 -0700)]
cmd/go: use platform.MustLinkExternal in externalLinkingForced

Change-Id: If5613ae73d03c196f26340fd6293e37c78c29bd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/477395
TryBot-Result: Gopher Robot <gobot@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>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agocmd/go: import runtime/cgo when externally linking
Ian Lance Taylor [Fri, 17 Mar 2023 00:45:02 +0000 (17:45 -0700)]
cmd/go: import runtime/cgo when externally linking

Fixes #31544

Change-Id: Ic99875ad227876eb741e93653589310327c9c0ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/477195
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/compile/internal/ssa: drop overwritten regalloc basic block input requirements
Michael Pratt [Tue, 21 Feb 2023 18:20:49 +0000 (13:20 -0500)]
cmd/compile/internal/ssa: drop overwritten regalloc basic block input requirements

For the following description, consider the following basic block graph:

      b1 ───┐┌──── b2
            ││
            ││
            ▼▼
            b3

For register allocator transitions between basic blocks, there are two
key passes (significant paraphrasing):

First, each basic block is visited in some predetermined visit order.
This is the core visitOrder range loop in regAllocState.regalloc. The
specific ordering heuristics aren't important here, except that the
order guarantees that when visiting a basic block at least one of its
predecessors has already been visited.

Upon visiting a basic block, that block sets its expected starting
register state (regAllocState.startRegs) based on the ending register
state (regAlloc.State.endRegs) of one of its predecessors. (How it
chooses which predecessor to use is not important here.)

From that starting state, registers are assigned for all values in the
block, ultimately resulting in some ending register state.

After all blocks have been visited, the shuffle pass
(regAllocState.shuffle) ensures that for each edge, endRegs of the
predecessor == startRegs of the successor. That is, it makes sure that
the startRegs assumptions actually hold true for each edge. It does this
by adding moves to the end of the predecessor block to place values in
the expected register for the successor block. These may be moves from
other registers, or from memory if the value is spilled.

Now on to the actual problem:

Assume that b1 places some value v1 into register R10, and thus ends
with endRegs containing R10 = v1.

When b3 is visited, it selects b1 as its model predecessor and sets
startRegs with R10 = v1.

b2 does not have v1 in R10, so later in the shuffle pass, we will add a
move of v1 into R10 to the end of b2 to ensure it is available for b3.

This is all perfectly fine and exactly how things should work.

Now suppose that b3 does not use v1. It does need to use some other
value v2, which is not currently in a register. When assigning v2 to a
register, it finds all registers are already in use and it needs to dump
a value. Ultimately, it decides to dump v1 from R10 and replace it with
v2.

This is fine, but it has downstream effects on shuffle in b2. b3's
startRegs still state that R10 = v1, so b2 will add a move to R10 even
though b3 will unconditionally overwrite it. i.e., the move at the end
of b2 is completely useless and can result in code like:

// end of b2
MOV n(SP), R10 // R10 = v1 <-- useless
// start of b3
MOV m(SP), R10 // R10 = v2

This is precisely what happened in #58298.

This CL addresses this problem by dropping registers from startRegs if
they are never used in the basic block prior to getting dumped. This
allows the shuffle pass to avoid placing those useless values into the
register.

There is a significant limitation to this CL, which is that it only
impacts the immediate predecessors of an overwriting block. We can
discuss this by zooming out a bit on the previous graph:

b4 ───┐┌──── b5
      ││
      ││
      ▼▼
      b1 ───┐┌──── b2
            ││
            ││
            ▼▼
            b3

Here we have the same graph, except we can see the two predecessors of
b1.

Now suppose that rather than b1 assigning R10 = v1 as above, the
assignment is done in b4. b1 has startRegs R10 = v1, doesn't use the
value at all, and simply passes it through to endRegs R10 = v1.

Now the shuffle pass will require both b2 and b5 to add a move to
assigned R10 = v1, because that is specified in their successor
startRegs.

With this CL, b3 drops R10 = v1 from startRegs, but there is no
backwards propagation, so b1 still has R10 = v1 in startRegs, and b5
still needs to add a useless move.

Extending this CL with such propagation may significantly increase the
number of useless moves we can remove, though it will add complexity to
maintenance and could potentially impact build performance depending on
how efficiently we could implement the propagation (something I haven't
considered carefully).

As-is, this optimization does not impact much code. In bent .text size
geomean is -0.02%. In the container/heap test binary, 18 of ~2500
functions are impacted by this CL. Bent and sweet do not show a
noticeable performance impact one way or another, however #58298 does
show a case where this can have impact if the useless instructions end
up in the hot path of a tight loop.

For #58298.

Change-Id: I2fcef37c955159d068fa0725f995a1848add8a5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/471158
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
2 years agonet/http: eliminate more arbitrary timeouts in tests
Bryan C. Mills [Fri, 17 Mar 2023 16:42:02 +0000 (12:42 -0400)]
net/http: eliminate more arbitrary timeouts in tests

Change-Id: I5b3158ecd0eb20dc433a53a2b03eb4551cbb3f7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/477196
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2 years agonet/http/httputil: use response controller in reverse proxy
Shang Ding [Thu, 16 Feb 2023 03:04:33 +0000 (21:04 -0600)]
net/http/httputil: use response controller in reverse proxy

Previously, the reverse proxy is unable to detect
the support for hijack or flush if those things
are residing in the response writer in a wrapped
manner.

The reverse proxy now makes use of the new http
response controller as the means to discover
the underlying flusher and hijacker associated
with the response writer, allowing wrapped flusher
and hijacker become discoverable.

Change-Id: I53acbb12315c3897be068e8c00598ef42fc74649
Reviewed-on: https://go-review.googlesource.com/c/go/+/468755
Run-TryBot: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agoruntime: remove arm64 non-register ABI fallback code
Joel Sing [Sat, 11 Mar 2023 16:12:40 +0000 (03:12 +1100)]
runtime: remove arm64 non-register ABI fallback code

This presumably got missed in CL 393875.

Change-Id: I4f2de00ebd6ec405d5e289a7f8c2fc781607260b
Reviewed-on: https://go-review.googlesource.com/c/go/+/475617
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>