]> Cypherpunks repositories - gostls13.git/log
gostls13.git
3 weeks agocmd/compile: simplify logX implementations
Cuong Manh Le [Tue, 29 Jul 2025 16:39:08 +0000 (23:39 +0700)]
cmd/compile: simplify logX implementations

By calling logXu instead of duplicating the same ones.

Change-Id: Ide7a3ce072a6abafe1979f0158000457d90645c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/691475
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/compile: use unsigned power-of-two detector for unsigned mod
Cuong Manh Le [Wed, 23 Jul 2025 16:51:16 +0000 (23:51 +0700)]
cmd/compile: use unsigned power-of-two detector for unsigned mod

Same as CL 689815, but for modulus instead of division.

Updates #74485

Change-Id: I73000231c886a987a1093669ff207fd9117a8160
Reviewed-on: https://go-review.googlesource.com/c/go/+/689895
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 weeks agocmd/compile: add unsigned power-of-two detector
Cuong Manh Le [Wed, 23 Jul 2025 11:48:18 +0000 (18:48 +0700)]
cmd/compile: add unsigned power-of-two detector

Fixes #74485

Change-Id: Ia22a58ac43bdc36c8414d555672a3a3eafc749ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/689815
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

3 weeks agointernal/abi: move direct/indirect flag from Kind to TFlag
Keith Randall [Sun, 15 Jun 2025 00:06:20 +0000 (17:06 -0700)]
internal/abi: move direct/indirect flag from Kind to TFlag

This info makes more sense in the flags instead of as a high
bit of the kind. This makes kind access simpler because we now
don't need to mask anything.

Cleaned up most direct field accesses to use methods instead.
(reflect making new types is the only remaining direct accessor.)

IfaceIndir -> !IsDirectIface everywhere.

gocore has been updated to handle the new location. So has delve.
TODO: any other tools need updating?

Change-Id: I123f97a4d4bdd0bff1641ee7e276d1cc0bd7e8eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/681936
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agoos/exec: fix incorrect expansion of "", "." and ".." in LookPath
Olivier Mengué [Mon, 30 Jun 2025 14:58:59 +0000 (16:58 +0200)]
os/exec: fix incorrect expansion of "", "." and ".." in LookPath

Fix incorrect expansion of "" and "." when $PATH contains an executable
file or, on Windows, a parent directory of a %PATH% element contains an
file with the same name as the %PATH% element but with one of the
%PATHEXT% extension (ex: C:\utils\bin is in PATH, and C:\utils\bin.exe
exists).

Fix incorrect expansion of ".." when $PATH contains an element which is
an the concatenation of the path to an executable file (or on Windows
a path that can be expanded to an executable by appending a %PATHEXT%
extension), a path separator and a name.

"", "." and ".." are now rejected early with ErrNotFound.

Fixes CVE-2025-47906
Fixes #74466

Change-Id: Ie50cc0a660fce8fbdc952a7f2e05c36062dcb50e
Reviewed-on: https://go-review.googlesource.com/c/go/+/685755
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
3 weeks agointernal/goexperiment: delete RangeFunc goexperiment
Cherry Mui [Mon, 30 Jun 2025 21:34:01 +0000 (17:34 -0400)]
internal/goexperiment: delete RangeFunc goexperiment

It is now always enabeld. The GOEXPERIMENT doesn't control
anything. Remove.

Change-Id: I50eb09f4537f90ec28152eb59a5a689127843fce
Reviewed-on: https://go-review.googlesource.com/c/go/+/684838
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agointernal/goexperiment: delete CacheProg goexperiment
Cherry Mui [Mon, 30 Jun 2025 21:18:43 +0000 (17:18 -0400)]
internal/goexperiment: delete CacheProg goexperiment

It is now always enabeld. The GOEXPERIMENT doesn't control
anything. Remove.

Change-Id: I24ecf0cd7be5d5dd20f4c558871a3ea97792055e
Reviewed-on: https://go-review.googlesource.com/c/go/+/684837
Reviewed-by: qiu laidongfeng <2645477756@qq.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agosync: remove synchashtriemap GOEXPERIMENT
Michael Anthony Knyszek [Wed, 23 Jul 2025 02:33:03 +0000 (02:33 +0000)]
sync: remove synchashtriemap GOEXPERIMENT

It's been true by default for a full release. It's time to remove the
old map.

Change-Id: I65507f07725e0084aabd389f37d73ade0b7dc35b
Reviewed-on: https://go-review.googlesource.com/c/go/+/690395
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 weeks agocmd/compile: move arm32 over to new bounds check strategy
Keith Randall [Wed, 18 Jun 2025 22:15:29 +0000 (15:15 -0700)]
cmd/compile: move arm32 over to new bounds check strategy

Change-Id: I529edd805875a4833cabcf4692f0c6d4163b07d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/682398
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agoruntime: only deduct assist credit for arenas during GC
wingrez [Tue, 22 Jul 2025 16:39:00 +0000 (16:39 +0000)]
runtime: only deduct assist credit for arenas during GC

CL 617876 has changed the original behavior. This modification will restore it.

Change-Id: I72cce82ebed362f99da7548035435397c835c99b
GitHub-Last-Rev: 980ef25b43cbae064f9c9cff0b589b2adbc72f1f
GitHub-Pull-Request: golang/go#74705
Reviewed-on: https://go-review.googlesource.com/c/go/+/689436
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 weeks agocmd/go/internal/telemetrystats: count goexperiments
qmuntal [Tue, 15 Jul 2025 13:24:25 +0000 (15:24 +0200)]
cmd/go/internal/telemetrystats: count goexperiments

Knowing which goexperiments are enabled by the users is
useful information to have in the local telemetry database.

It also opens the door for uploading them in the future if
desired.

Change-Id: I12c8eaa3997dec0ed26703885f1c216676f5590d
Reviewed-on: https://go-review.googlesource.com/c/go/+/688135
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
3 weeks agoimage: fix formatting of godoc link
Olivier Mengué [Tue, 10 Jun 2025 14:56:45 +0000 (16:56 +0200)]
image: fix formatting of godoc link

Change-Id: I8fa8741e0db174f0c32af0a393ee1b037d5b7e51
Reviewed-on: https://go-review.googlesource.com/c/go/+/680455
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
3 weeks agocrypto/elliptic: change a variable name that have the same name as keywords
mohanson [Thu, 24 Jul 2025 07:20:54 +0000 (07:20 +0000)]
crypto/elliptic: change a variable name that have the same name as keywords

Change the variable name from byte to b, and use range over int to
simplify the loop.

Change-Id: I8855053c26ce798311f12505cd5edf21d7caf1f5
GitHub-Last-Rev: 70c80545df29c897ea81f115334fcc64503c0eb1
GitHub-Pull-Request: golang/go#74736
Reviewed-on: https://go-review.googlesource.com/c/go/+/690135
Reviewed-by: qiu laidongfeng <2645477756@qq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 weeks agocmd/compile: simplify zerorange on amd64
Keith Randall [Tue, 3 Jun 2025 19:36:35 +0000 (12:36 -0700)]
cmd/compile: simplify zerorange on amd64

Get rid of duffzero and large zeroing cases. We only use this code
for small things now.

Change-Id: Idcf330d0ac6433448efa8e32be7eb7f988e10122
Reviewed-on: https://go-review.googlesource.com/c/go/+/678619
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
3 weeks agoos/user: fix tests to pass on non-english Windows
Olivier Mengué [Fri, 18 Jul 2025 10:36:00 +0000 (12:36 +0200)]
os/user: fix tests to pass on non-english Windows

Tests on Windows are dependent on the english names of system accounts
and groups.

But on a french install of Windows the system accounts are:
- AUTORITE NT\Système
- AUTORITE NT\SERVICE LOCAL
- AUTORITE NT\SERVICE RÉSEAU

To allow the tests to pass on non-english Windows we only log
differences in user/group names if GetSystemDefaultLCID() reports
a non-english LCID, instead of failing.

Change-Id: Ib81acc2896c45675fa3faf5dc390b57ec5159689
Reviewed-on: https://go-review.googlesource.com/c/go/+/688715
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
3 weeks agointernal/poll: remove msg field from Windows' poll.operation
qmuntal [Wed, 2 Jul 2025 12:55:04 +0000 (14:55 +0200)]
internal/poll: remove msg field from Windows' poll.operation

There is no need to keep the msg field in the poll.operation struct.

This skims down the size of os.File by 112 bytes.

Change-Id: I5c7b1f3989f9bb5f1748df2cba8128d9c479b35d
Reviewed-on: https://go-review.googlesource.com/c/go/+/685418
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
3 weeks agointernal/poll: remove rsan field from Windows' poll.operation
qmuntal [Wed, 2 Jul 2025 10:51:42 +0000 (12:51 +0200)]
internal/poll: remove rsan field from Windows' poll.operation

There is no need to keep the rsan field in the poll.operation struct.

This skims down the size of os.File by 16 bytes.

Change-Id: I5e99e0e87178b63a19f0b9883b7b3d25abfd9ec3
Reviewed-on: https://go-review.googlesource.com/c/go/+/685417
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
3 weeks agointernal/poll: remove sa field from Windows' poll.operation
qmuntal [Wed, 2 Jul 2025 10:40:29 +0000 (12:40 +0200)]
internal/poll: remove sa field from Windows' poll.operation

There is no need to keep the sa field in the poll.operation struct.

This skims down the size of os.File by 32 bytes.

Change-Id: I6b021a76f582ead5dccb29b001e7a5b068a2c2ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/685416
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <mark@golang.org>
3 weeks agointernal/poll: remove qty and flags fields from Windows' poll.operation
qmuntal [Wed, 2 Jul 2025 10:33:13 +0000 (12:33 +0200)]
internal/poll: remove qty and flags fields from Windows' poll.operation

There is no need to keep the qty and flags fields in the poll.operation
struct.

This skims down the size of os.File by 16 bytes and makes poll.operation
harder to misuse.

Change-Id: I8943d88f29ed3c7eefbb83114b0d31052abbe646
Reviewed-on: https://go-review.googlesource.com/c/go/+/685436
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agointernal/runtime/maps: fix spelling errors in comments
Ruihua Wen [Thu, 24 Jul 2025 02:36:26 +0000 (02:36 +0000)]
internal/runtime/maps: fix spelling errors in comments

Change-Id: I289d26f75bb556b46699159f06ce7eb03d34656d
GitHub-Last-Rev: 10ce76df1d4951e021d460808c9d477cfbcf7c5c
GitHub-Pull-Request: golang/go#74733
Reviewed-on: https://go-review.googlesource.com/c/go/+/690095
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 weeks agoruntime: remove openbsd/mips64 related code
Joel Sing [Sat, 15 Feb 2025 08:34:08 +0000 (19:34 +1100)]
runtime: remove openbsd/mips64 related code

The openbsd/mips64 port has been broken for many years and it has not
been possible to land the changes needed to unbreak it. As such, this
port is considered dead and can be decommissioned in order to remove
technical debt and allow other changes to be completed.

Updates #61546

Change-Id: I9680eab9fb3aa85b83de47c66e9ebaf8c388a3bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/649659
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 weeks agoerrors: omit redundant nil check in type assertion for Join
Jes Cok [Sat, 26 Jul 2025 02:49:42 +0000 (02:49 +0000)]
errors: omit redundant nil check in type assertion for Join

When ok is true, err can't be nil.

Make it behave more like the Unwrap function.

Change-Id: Ieba5de57d60f5ff4d6a3468d703e6f72be02a97d
GitHub-Last-Rev: 6df9365a1d586bba64df57be11f9ca7b772cc773
GitHub-Pull-Request: golang/go#74764
Reviewed-on: https://go-review.googlesource.com/c/go/+/689920
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
3 weeks agoall: omit unnecessary type conversions
Jes Cok [Mon, 28 Jul 2025 11:36:17 +0000 (11:36 +0000)]
all: omit unnecessary type conversions

Found by github.com/mdempsky/unconvert

Change-Id: Ib78cceb718146509d96dbb6da87b27dbaeba1306
GitHub-Last-Rev: dedf354811701ce8920c305b6f7aa78914a4171c
GitHub-Pull-Request: golang/go#74771
Reviewed-on: https://go-review.googlesource.com/c/go/+/690735
Reviewed-by: Mark Freeman <mark@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 weeks agocmd/compile: cleanup SelectN rules by indexing into args
Jorropo [Sat, 26 Jul 2025 02:04:05 +0000 (04:04 +0200)]
cmd/compile: cleanup SelectN rules by indexing into args

Change-Id: I7b8e8cd88c4d6d562aa25df91593d35d331ef63c
Reviewed-on: https://go-review.googlesource.com/c/go/+/690595
Reviewed-by: Mark Freeman <mark@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/compile: rewrite cmov(x, x, cond) into x
Jorropo [Sat, 26 Jul 2025 01:36:15 +0000 (03:36 +0200)]
cmd/compile: rewrite cmov(x, x, cond) into x

I don't think branchelim will intentionally generate theses.
But at the time where branchelim is generating them they might different,
and through opt process they become the same value.

Change-Id: I4a19f1db14c08057b7e782a098f4c18ca36ab7fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/690519
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Mark Freeman <mark@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 weeks agonet/http: add proper panic message
yazdan [Wed, 16 Jul 2025 08:12:54 +0000 (11:42 +0330)]
net/http: add proper panic message

Change-Id: Ibfb330eaf24e004ddec60a5ca08cdc780235ad8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/688315
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agotest/codegen: fix failing condmove wasm tests
Michael Munday [Sat, 26 Jul 2025 23:17:49 +0000 (00:17 +0100)]
test/codegen: fix failing condmove wasm tests

These recently added tests failed when using the -all_codgen flag.

Fixes #74770

Change-Id: Idea1ea02af2bd9f45c7d0a28d633c7442328e6df
Reviewed-on: https://go-review.googlesource.com/c/go/+/690715
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Run-TryBot: Michael Munday <mikemndy@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>

3 weeks agoruntime,syscall: move SyscallX implementations from runtime to syscall
qmuntal [Fri, 25 Jul 2025 13:25:37 +0000 (15:25 +0200)]
runtime,syscall: move SyscallX implementations from runtime to syscall

There is no need for syscall.Syscall{3,6,9,12,15,18} to be implemented
in the runtime and linknamed from syscall. All of them can be
implemented using the single runtime.syscall_syscalln function.

While here, improve the documentation of syscall.SyscallN.

Change-Id: I0e09d42e855d6baf900354c9b7992a4329c4ffc7
Reviewed-on: https://go-review.googlesource.com/c/go/+/690515
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 weeks agointernal/runtime/syscall/windows: factor out code from runtime
qmuntal [Mon, 21 Jul 2025 12:39:04 +0000 (14:39 +0200)]
internal/runtime/syscall/windows: factor out code from runtime

Factor out the code related to doing calls using the Windows stdcall
calling convention into a separate package. This will allow us to
reuse it in other low-level packages that can't depend on syscall.

Updates #51087.

Cq-Include-Trybots: luci.golang.try:gotip-windows-arm64,gotip-windows-amd64-longtest,gotip-solaris-amd64
Change-Id: I68640b07091183b50da6bef17406c10a397896e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/689156
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 weeks agohash/crc32: fix incorrect checksums with avx512+race
Klaus Post [Mon, 28 Jul 2025 15:26:52 +0000 (15:26 +0000)]
hash/crc32: fix incorrect checksums with avx512+race

CRC value loaded from incorrect register, which happened
to line up with actual register on default compile.
Therefore failures would only show up with -race.

Add regression test with longer payloads.

Fix regression from CL 689435.

Fixes #74767.

Change-Id: Ib63ddade998a5630297b285f3d566361f36f28e5
GitHub-Last-Rev: 5074012d2cbc8fdb78c1fb2ada72e3bd98c985c2
GitHub-Pull-Request: golang/go#74775
Reviewed-on: https://go-review.googlesource.com/c/go/+/690855
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/compile: remove no-longer-necessary call to calculateDepths
Keith Randall [Fri, 25 Jul 2025 21:15:50 +0000 (14:15 -0700)]
cmd/compile: remove no-longer-necessary call to calculateDepths

We now calculate depths by default, no need to ask.
All calls were removed in CL 680775 when that CL was written, but an
additional call appeared between then and submitting the CL. Oops.

Another case for which a presubmit check would help.

Fixes #74762

Change-Id: I1b70ed7f91b56e4939b4a3d0ad7a5f31fe396b4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/690036
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: t hepudds <thepudds1460@gmail.com>
3 weeks agocmd/compile: fix containsUnavoidableCall computation
Keith Randall [Tue, 10 Jun 2025 21:37:47 +0000 (14:37 -0700)]
cmd/compile: fix containsUnavoidableCall computation

The previous algorithm was incorrect, as it reused the dominatedByCall
slice without resetting it. It also used the depth fields even though
they were not yet calculated.

Also, clean up a lot of the loop detector code that we never use.

Always compute depths. It is cheap.

Update #71868

Not really sure how to test this. As it is just an advisory bit,
nothing goes really wrong when the result is incorrect.

Change-Id: Ic0ae87a4d3576554831252d88b05b058ca68af41
Reviewed-on: https://go-review.googlesource.com/c/go/+/680775
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
3 weeks agogo/types, types2: use nil to represent incomplete explicit aliases
Mark Freeman [Tue, 24 Jun 2025 21:16:24 +0000 (17:16 -0400)]
go/types, types2: use nil to represent incomplete explicit aliases

Using Invalid to represent an incomplete alias is problematic since
it implies that an error has been reported somewhere. This causes
confusion for observers of invalid aliases trying not to emit
follow-on errors.

This change uses nil instead to represent an incomplete alias. This
has a mild benefit of making alias memoization more convenient. We
additionally can now memoize Invalid aliases.

This necessitates a minor change to our cycle error reporting for
aliases. Care is taken to separate logic according to gotypesalias.
Otherwise, a cycle as simple as "type T = T" panics.

A test is also added which uses go/types to inspect for Invalid
types. Currently, the problematic Invalid does not cause an error
in type checking, but rather a panic in noding. Thus, we cannot use
the familiar test facilities relying on error reporting.

Fixes #74181

Change-Id: Iea5ebce567a2805f5647de0fb7ded4a96f6c5f8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/683796
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/compile/internal/types2: add loaded state between loader calls and constraint...
Mark Freeman [Fri, 13 Jun 2025 15:47:57 +0000 (11:47 -0400)]
cmd/compile/internal/types2: add loaded state between loader calls and constraint expansion

There is a deadlock issue when calling SetConstraint from a lazy loader
because the loader is called from resolve(), which is holding a lock on
the loaded type.

If the loaded type has a generic constraint which refers back to the
loaded type (such as an argument or result), then we will loop back to
the loaded type and deadlock.

This change postpones calls to SetConstraint and passes them back to
resolve(). At that point, the loaded type is mostly constructed, but
its constraints might be unexpanded.

Similar to how we handle resolved instances, we advance the state for
the loaded type to a, appropriately named, loaded state. When we expand
the constraint, we don't try to acquire the lock on the loaded type.
Thus, no deadlock.

Fixes #63285

Change-Id: Ie0204b58a5b433f6d839ce8fd8a99542246367b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/681875
Commit-Queue: Mark Freeman <mark@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agoos/user: user random name for the test user account
qmuntal [Thu, 24 Jul 2025 13:38:35 +0000 (15:38 +0200)]
os/user: user random name for the test user account

TestImpersonated and TestGroupIdsTestUser are flaky due to sporadic
failures when creating the test user account when running the tests
from different processes at the same time.

This flakiness can be fixed by using a random name for the test user
account.

Fixes #73523
Fixes #74727
Fixes #74728
Fixes #74729
Fixes #74745
Fixes #74751

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest
Change-Id: Ib2283a888437420502b1c11d876c975f5af4bc03
Reviewed-on: https://go-review.googlesource.com/c/go/+/690175
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>

3 weeks agoruntime: rename scanobject to scanObject
Michael Anthony Knyszek [Fri, 25 Jul 2025 18:08:35 +0000 (18:08 +0000)]
runtime: rename scanobject to scanObject

This is long overdue.

Change-Id: I891b114cb581e82b903c20d1c455bbbdad548fe8
Reviewed-on: https://go-review.googlesource.com/c/go/+/690535
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

3 weeks agoruntime: duplicate scanobject in greentea and non-greentea files
Michael Anthony Knyszek [Tue, 22 Jul 2025 23:31:51 +0000 (23:31 +0000)]
runtime: duplicate scanobject in greentea and non-greentea files

This change exists to help differentiate profile samples spent on
Green Tea and non-Green-Tea GC time in mixed contexts.

Change-Id: I8dea340d2d11ba4c410ae939fb5f37020d0b55d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/689477
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/compile: remove unused arg from gorecover
Keith Randall [Wed, 2 Jul 2025 17:00:42 +0000 (10:00 -0700)]
cmd/compile: remove unused arg from gorecover

We don't need this argument anymore to match up
a recover with its corresponding panic.

Change-Id: I5d3646cdd766259ee9d3d995a2f215f02e17abc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/685555
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
3 weeks agoruntime: iterate through inlinings when processing recover()
Keith Randall [Tue, 1 Jul 2025 22:29:12 +0000 (15:29 -0700)]
runtime: iterate through inlinings when processing recover()

We care about the wrapper-ness of logical frames, not physical frames.

Fixes #73916
Fixes #73917
Fixex #73920

Change-Id: Ia17c8390e71e6c0e13e23dcbb7bc7273ef25da90
Reviewed-on: https://go-review.googlesource.com/c/go/+/685375
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 weeks agoencoding/json: fix truncated Token error regression in goexperiment.jsonv2
Joe Tsai [Fri, 25 Jul 2025 00:10:54 +0000 (17:10 -0700)]
encoding/json: fix truncated Token error regression in goexperiment.jsonv2

The jsontext.Decoder.ReadToken method reports a non-EOF error,
if the token stream is truncated and does not form a valid JSON value.
In contrast, the v1 json.Decoder.Token method would report EOF
so long as the input was a prefix of some valid JSON value.
Modify json.Decoder.Token to preserve historical behavior.

This only modifies code that is compiled in under goexperiment.jsonv2.

Updates #69449
Fixes #74750

Change-Id: Ifd281c46f118f0e748076013fefc7659f77c56ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/689516
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 weeks agoencoding/json/jsontext: preserve buffer capacity in Encoder.Reset
Joe Tsai [Wed, 25 Jun 2025 01:56:26 +0000 (18:56 -0700)]
encoding/json/jsontext: preserve buffer capacity in Encoder.Reset

This does the equivalent of CL 681177 for the Encoder.
It preserves the internal buffer between resets.

Change-Id: I5e9353b6d7755e067d4f9a4d1ea3d8f056253027
Reviewed-on: https://go-review.googlesource.com/c/go/+/690375
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 weeks agoreflect: avoid a bounds check in stack-constrained code
Keith Randall [Thu, 24 Jul 2025 23:41:23 +0000 (16:41 -0700)]
reflect: avoid a bounds check in stack-constrained code

Since CL 682496 we need more stack space to handle bounds checks.
The code modified here normally has no bounds checks, but in -N
builds it still does and thus uses too much stack.

Use unsafe arithmetic to avoid the bounds check.

This will hopefully fix some of the arm64 linux builders.

Change-Id: I5b3096a14b4fb9553e635b7f340e60b8ffba8755
Reviewed-on: https://go-review.googlesource.com/c/go/+/690415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
3 weeks agoencoding/json: fix extra data regression under goexperiment.jsonv2
Joe Tsai [Thu, 24 Jul 2025 19:16:35 +0000 (12:16 -0700)]
encoding/json: fix extra data regression under goexperiment.jsonv2

When operating under v1 semantics in the v2 implementation,
a extra data error should take precedence over any semantic error
that could theoretically occur within the value itself.

This change only affects code compiled under goexperiment.jsonv2.

Fixes #74614

Change-Id: I055a606b053fa66b0c766ae205487b8290109285
Reviewed-on: https://go-review.googlesource.com/c/go/+/689919
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agoencoding/json: reduce error text regressions under goexperiment.jsonv2
Joe Tsai [Thu, 24 Jul 2025 18:34:18 +0000 (11:34 -0700)]
encoding/json: reduce error text regressions under goexperiment.jsonv2

There were minor and unnecessary error text changes
when v1 was implemented using v2.
Reduce divergences if possible.

Of the cases reported in #74713, there are no more differences for:

v1: json: cannot unmarshal number into Go value of type chan int
v2: json: cannot unmarshal number into Go value of type chan int

and

v1: json: cannot unmarshal number into Go value of type error
v2: json: cannot unmarshal number into Go value of type error

However, there is a difference between:

v1: json: cannot unmarshal string into Go struct field .F.V of type int
v2: json: cannot unmarshal string into Go struct field S.F.V of type int

For reasons unclear, the v1 logic was always inconsistent about
whether it could properly record the root struct type,
while the v1 emulation layer under v2 is always able to.

This only modifies code that is compiled in under goexperiment.jsonv2.

Fixes #74713

Change-Id: I9e87323b1810130cb929288fdd86aff4be82d5f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/689918
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 weeks agotime: remove redundant uint32 conversion in split
cxbdasheng [Thu, 24 Jul 2025 06:23:23 +0000 (06:23 +0000)]
time: remove redundant uint32 conversion in split

cd is a uint32 converted again.

Change-Id: Ia41e247e0644c17cd9e0593d79457db77512fc3e
GitHub-Last-Rev: 1ba8596e2761be75cc35f79e8245a96d6bb81096
GitHub-Pull-Request: golang/go#74679
Reviewed-on: https://go-review.googlesource.com/c/go/+/689055
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agointernal/buildcfg: add ability to get GORISCV64 variable in GOGOARCH
Julian Zhu [Tue, 15 Apr 2025 13:34:42 +0000 (21:34 +0800)]
internal/buildcfg: add ability to get GORISCV64 variable in GOGOARCH

For #61476

Change-Id: I29f4c1c3c3303e70ec2d7f380112eb2d00754018
Reviewed-on: https://go-review.googlesource.com/c/go/+/665655
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
3 weeks agocmd/internal/obj: rip out argp adjustment for wrapper frames
Keith Randall [Tue, 1 Jul 2025 22:00:13 +0000 (15:00 -0700)]
cmd/internal/obj: rip out argp adjustment for wrapper frames

The previous CL made this adjustment unnecessary. The argp field
is no longer used by the runtime.

Change-Id: I3491eeef4103c6653ec345d604c0acd290af9e8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/685356
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
3 weeks agoruntime: detect successful recovers differently
Keith Randall [Tue, 1 Jul 2025 21:45:45 +0000 (14:45 -0700)]
runtime: detect successful recovers differently

Use stack unwinding instead of keeping incremental track of the argp
of defers that are allowed to recover.

It's much simpler, and it lets us get rid of the incremental tracking
by wrapper code. (Ripped out in a subsequent CL.)

We only need to stack unwind a few frames to get the right answer, and
only when recover()ing in a panic situation. It will be more expensive
in that case, but cheaper in all others.

Change-Id: Id095807db6864b7ac1e1baf09285b77a07c46d19
Reviewed-on: https://go-review.googlesource.com/c/go/+/685355
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
3 weeks agounicode/utf8: skip ahead during ascii runs in Valid/ValidString
Keith Randall [Sun, 22 Jun 2025 18:48:57 +0000 (11:48 -0700)]
unicode/utf8: skip ahead during ascii runs in Valid/ValidString

When we see an ASCII character, we will probably see many.
Grab & check increasingly large chunks of the string for ASCII-only-ness.

Also redo some of the non-ASCII code to make it more optimizer friendly.

goos: linux
goarch: amd64
pkg: unicode/utf8
cpu: 12th Gen Intel(R) Core(TM) i7-12700
                               │     base     │                 exp                 │
                               │    sec/op    │   sec/op     vs base                │
ValidTenASCIIChars-20             3.596n ± 3%   2.522n ± 1%  -29.86% (p=0.000 n=10)
Valid100KASCIIChars-20            6.094µ ± 2%   2.115µ ± 1%  -65.29% (p=0.000 n=10)
ValidTenJapaneseChars-20          21.02n ± 0%   18.61n ± 2%  -11.44% (p=0.000 n=10)
ValidLongMostlyASCII-20          51.774µ ± 0%   3.836µ ± 1%  -92.59% (p=0.000 n=10)
ValidLongJapanese-20             102.40µ ± 1%   50.95µ ± 1%  -50.24% (p=0.000 n=10)
ValidStringTenASCIIChars-20       2.640n ± 3%   2.526n ± 1%   -4.34% (p=0.000 n=10)
ValidString100KASCIIChars-20      5.585µ ± 7%   2.118µ ± 1%  -62.07% (p=0.000 n=10)
ValidStringTenJapaneseChars-20    21.29n ± 2%   18.67n ± 1%  -12.31% (p=0.000 n=10)
ValidStringLongMostlyASCII-20    52.431µ ± 1%   3.841µ ± 0%  -92.67% (p=0.000 n=10)
ValidStringLongJapanese-20       102.66µ ± 1%   50.90µ ± 1%  -50.42% (p=0.000 n=10)
geomean                           1.152µ        454.8n       -60.53%

This is an attempt to see if we can get enough performance that we don't
need to consider assembly like that in CL 681695.

Change-Id: I8250feb797a6b4e7d335c23929f6e3acc8b24840
Reviewed-on: https://go-review.googlesource.com/c/go/+/682778
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/compile: move amd64 and 386 over to new bounds check strategy
Keith Randall [Wed, 18 Jun 2025 22:14:00 +0000 (15:14 -0700)]
cmd/compile: move amd64 and 386 over to new bounds check strategy

Change-Id: I13f54f04ccb8452e625dba4249e0d56bafd1fad8
Reviewed-on: https://go-review.googlesource.com/c/go/+/682397
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
3 weeks agocmd/compile: add missing StringLen rule in prove
Keith Randall [Sun, 22 Jun 2025 23:50:16 +0000 (16:50 -0700)]
cmd/compile: add missing StringLen rule in prove

(StringLen (StringMake _ x)) == x, just like the rules we
currently have for slices.

This helps propagate string length knowledge to places which need it.

Change-Id: Ifdcf6d1f2d430c1c4bbac32e0ea74c188eae998e
Reviewed-on: https://go-review.googlesource.com/c/go/+/682777
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
3 weeks agocmd/compile: move arm64 over to new bounds check strategy
Keith Randall [Wed, 18 Jun 2025 22:06:55 +0000 (15:06 -0700)]
cmd/compile: move arm64 over to new bounds check strategy

For all the static bounds checks in cmd/go, we have:

    6877    just a single instruction (the call itself)
    139     needs an additional reg-reg move
    602     needs an additional constant load
    25      needs some other instruction

that's ~90% implemented using just a single instruction.

Reduces the text size of cmd/go by ~0.8%.
Total binary size is just barely smaller, ~0.2%. (The difference
is the new pcdata table.)

Change-Id: I416e9c196f5d8d0e8f08e191e6df3045e11dccbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/682496
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 weeks agocmd/compile,runtime: remember idx+len for bounds check failure with less code
Keith Randall [Wed, 18 Jun 2025 21:50:23 +0000 (14:50 -0700)]
cmd/compile,runtime: remember idx+len for bounds check failure with less code

Currently we must put the index and length into specific registers so
we can call into the runtime to report a bounds check failure.

So a typical bounds check call is something like:

MOVD  R3, R0
MOVD  R7, R1
CALL  runtime.panicIndex

or, if for instance the index is constant,

MOVD  $7, R0
MOVD  R9, R1
CALL  runtime.panicIndex

Sometimes the MOVD can be avoided, if the value happens to be in the
right register already. But that's not terribly common, and doesn't
work at all for constants.

Let's get rid of those MOVD instructions. They pollute the instruction
cache and are almost never executed.

Instead, we'll encode in a PCDATA table where the runtime should find
the index and length. The table encodes, for each index and length,
whether it is a constant or in a register, and which register or
constant it is.

That way, we can avoid all those useless MOVDs. Instead, we can figure
out the index and length at runtime. This makes the bounds panic path
slower, but that's a good tradeoff.

We can encode registers 0-15 and constants 0-31. Anything outside that
range still needs to use an explicit instruction.

This CL is the foundation, followon CLs will move each architecture
to the new strategy.

Change-Id: I705c511e546e6aac59fed922a8eaed4585e96820
Reviewed-on: https://go-review.googlesource.com/c/go/+/682396
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agoruntime: move bounds check constants to internal/abi
Keith Randall [Tue, 17 Jun 2025 21:44:56 +0000 (14:44 -0700)]
runtime: move bounds check constants to internal/abi

For future use by the compiler.

Change-Id: Id3da62006b283ac38008261c0ef88aaf71ef5896
Reviewed-on: https://go-review.googlesource.com/c/go/+/682456
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 weeks agocmd/compile: rewrite condselects into doublings and halvings
Jorropo [Thu, 3 Jul 2025 00:57:25 +0000 (02:57 +0200)]
cmd/compile: rewrite condselects into doublings and halvings

For performance see CL 685676.

This allows something like:
  if y { x *= 2 }

To be compiled to:
  SHLXQ BX, AX, AX

Instead of:
  MOVQ    AX, CX
  SHLQ    $1, CX
  MOVBLZX BL, DX
  TESTQ   DX, DX
  CMOVQNE CX, AX

While ./make.bash uniqued per LOC, there is 2 doublings and 4 halvings.

Change-Id: Ic0727cbf429528a2dbf17cbfc3b0121db8387444
Reviewed-on: https://go-review.googlesource.com/c/go/+/685695
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 weeks agocmd/compile: add opt branchelim to rewrite some CondSelect into math
Jorropo [Wed, 2 Jul 2025 23:35:51 +0000 (01:35 +0200)]
cmd/compile: add opt branchelim to rewrite some CondSelect into math

This allows something like:
  if y { x++ }

To be compiled to:
  MOVBLZX BX, CX
  ADDQ CX, AX

Instead of:
  LEAQ    1(AX), CX
  MOVBLZX BL, DX
  TESTQ   DX, DX
  CMOVQNE CX, AX

While ./make.bash uniqued per LOC, there is 100 additions and 75 substractions.

See benchmark here: https://go.dev/play/p/DJf5COjwhd_s

Either it's a performance no-op or it is faster:

  goos: linux
  goarch: amd64
  cpu: AMD Ryzen 5 3600 6-Core Processor
                                          │ /tmp/old.logs │            /tmp/new.logs             │
                                          │    sec/op     │    sec/op     vs base                │
  CmovInlineConditionAddLatency-12           0.5443n ± 5%   0.5339n ± 3%   -1.90% (p=0.004 n=10)
  CmovInlineConditionAddThroughputBy6-12      1.492n ± 1%    1.494n ± 1%        ~ (p=0.955 n=10)
  CmovInlineConditionSubLatency-12           0.5419n ± 3%   0.5282n ± 3%   -2.52% (p=0.019 n=10)
  CmovInlineConditionSubThroughputBy6-12      1.587n ± 1%    1.584n ± 2%        ~ (p=0.492 n=10)
  CmovOutlineConditionAddLatency-12          0.5223n ± 1%   0.2639n ± 4%  -49.47% (p=0.000 n=10)
  CmovOutlineConditionAddThroughputBy6-12     1.159n ± 1%    1.097n ± 2%   -5.35% (p=0.000 n=10)
  CmovOutlineConditionSubLatency-12          0.5271n ± 3%   0.2654n ± 2%  -49.66% (p=0.000 n=10)
  CmovOutlineConditionSubThroughputBy6-12     1.053n ± 1%    1.050n ± 1%        ~ (p=1.000 n=10)
  geomean

There are other benefits not tested by this benchmark:
- the math form is usually a couple bytes shorter (ICACHE)
- the math form is usually 0~2 uops shorter (UCACHE)
- the math form has usually less register pressure*
- the math form can sometimes be optimized further

*regalloc rarely find how it can use less registers

As far as pass ordering goes there are many possible options,
I've decided to reorder branchelim before late opt since:
- unlike running exclusively the CondSelect rules after branchelim,
  some extra optimizations might trigger on the adds or subs.
- I don't want to maintain a second generic.rules file of only the stuff,
  that can trigger after branchelim.
- rerunning all of opt a third time increase compilation time for little gains.

By elimination moving branchelim seems fine.

Change-Id: I869adf57e4d109948ee157cfc47144445146bafd
Reviewed-on: https://go-review.googlesource.com/c/go/+/685676
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 weeks agocmd/compile: learn transitive proofs for safe unsigned subs
Jorropo [Fri, 4 Jul 2025 07:26:38 +0000 (09:26 +0200)]
cmd/compile: learn transitive proofs for safe unsigned subs

I've split this into it's own CL to make git bisect more effective.

Change-Id: I436ff21a3e2362b3924de25a458534eb9947e013
Reviewed-on: https://go-review.googlesource.com/c/go/+/685821
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

3 weeks agocmd/compile: learn transitive proofs for safe negative signed adds
Jorropo [Fri, 4 Jul 2025 07:25:23 +0000 (09:25 +0200)]
cmd/compile: learn transitive proofs for safe negative signed adds

I've split this into it's own CL to make git bisect more effective.

Change-Id: Ib2c6dbc82fb04f50f2d17fbe6626c9fc322fb478
Reviewed-on: https://go-review.googlesource.com/c/go/+/685820
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 weeks agocmd/compile: learn transitive proofs for safe positive signed adds
Jorropo [Fri, 4 Jul 2025 07:23:21 +0000 (09:23 +0200)]
cmd/compile: learn transitive proofs for safe positive signed adds

I've split this into it's own CL to make git bisect more effective.

Change-Id: I3fbb42ec7d29169a29f7f55ef2c188317512f532
Reviewed-on: https://go-review.googlesource.com/c/go/+/685819
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/compile: learn transitive proofs for safe unsigned adds
Jorropo [Fri, 4 Jul 2025 07:21:03 +0000 (09:21 +0200)]
cmd/compile: learn transitive proofs for safe unsigned adds

I've split this into it's own CL to make git bisect more effective.

Change-Id: Iaab5f0bd2ad51e86ced8c6b8fbd371eb75eeef14
Reviewed-on: https://go-review.googlesource.com/c/go/+/685815
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
3 weeks agocmd/compile: fold shift through AND for slice operations
Alexander Musman [Sat, 7 Jun 2025 09:00:11 +0000 (12:00 +0300)]
cmd/compile: fold shift through AND for slice operations

Fold a shift through AND when the AND gets a zero-or-one operand (e.g.
from arithmetic shift by 63 of a 64-bit value) for a common case with
slice operations:

    ASR     $63, R2, R2
    AND     R3<<3, R2, R2
    ADD     R2, R0, R2

As the operands are 64-bit, we can transform it to:

    AND     R2->63, R3, R2
    ADD     R2<<3, R0, R2

Code size improvement:
compile: .text:     9088004 ->  9086292 (-0.02%)
etcd:    .text:    10500276 -> 10498964 (-0.01%)

Change-Id: Ibcd5e67173da39b77ceff77ca67812fb8be5a7b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/679895
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Mark Freeman <mark@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 weeks agointernal/runtime/syscall: rename to internal/runtime/syscall/linux
qmuntal [Mon, 21 Jul 2025 08:39:28 +0000 (10:39 +0200)]
internal/runtime/syscall: rename to internal/runtime/syscall/linux

All code in internal/runtime/syscall is Linux-specific, so better
move it to a new linux sub-directory. This way it will be easier
to factor out runtime syscall code from other platforms, e.g.
Windows.

Updates #51087.

Change-Id: Idd2a52444b33bf3ad576b47fd232e990cdc8ae75
Reviewed-on: https://go-review.googlesource.com/c/go/+/689155
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/compile: improve loopRotate to handle nested loops
Alexander Musman [Tue, 13 May 2025 06:44:17 +0000 (09:44 +0300)]
cmd/compile: improve loopRotate to handle nested loops

Enhance loop rotation of nested loops. Currently, loops are processed independently,
resulting in unnecessary jumps between outer and inner loops. By processing inner
loops before their parent loop, we ensure nested loop blocks are
properly placed within their parent loop's block sequence.

There is some code size improvement (as measured on amd64) due to jumps
to/from inner loop are removed by the updated loopRotate block order:

Executable            Old .text  New .text     Change
-------------------------------------------------------
asm                     2147569    2146481     -0.05%
cgo                     1977457    1975761     -0.09%
compile                10447345   10441905     -0.05%
cover                   2110097    2108977     -0.05%
link                    2930289    2929041     -0.04%
preprofile               927345     926769     -0.06%
vet                     3279057    3277009     -0.06%

Change-Id: I4b9e993c2be07fad735e6bcf32d062d099d9cfb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/684335
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/compile: optimize slice bounds checking with SUB/SUBconst comparisons
Alexander Musman [Sat, 7 Jun 2025 10:18:58 +0000 (13:18 +0300)]
cmd/compile: optimize slice bounds checking with SUB/SUBconst comparisons

Optimize ARM64 code generation for slice bounds checking by recognizing
patterns where comparisons to zero involve SUB or SUBconst operations.
This change adds SSA opt rules to simplify:
 (CMPconst [0] (SUB x y)) => (CMP x y)

The optimizations apply to EQ, NE, ULE, and UGT comparisons, enabling
more efficient bounds checking for slice operations.

Code size improvement:
compile: .text:    9088004  ->  9065988 (-0.24%)
etcd:    .text:    10500276 -> 10497092 (-0.03%)
Change-Id: I467cb27674351652bcacc52b87e1f19677bd46a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/679915
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Keith Randall <khr@golang.org>

3 weeks agointernal/poll: remove handle field from Windows' poll.operation
qmuntal [Wed, 2 Jul 2025 09:12:28 +0000 (11:12 +0200)]
internal/poll: remove handle field from Windows' poll.operation

The handle field can be accessed directly wherever needed, there is
no need to store it in the operation struct.

This skims down the size of os.File by 16 bytes.

Change-Id: I87c94cb773437891127b6c36dc7f8883622ffed3
Reviewed-on: https://go-review.googlesource.com/c/go/+/685435
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
3 weeks agointernal/poll: remove fd field from Windows' poll.operation
qmuntal [Wed, 2 Jul 2025 09:05:47 +0000 (11:05 +0200)]
internal/poll: remove fd field from Windows' poll.operation

There is no need to keep the fd in the poll.operation struct,
given that all usages of this field have direct access to the fd struct.

This skims down the size of os.File by 16 bytes.

Change-Id: I837e345250387f62e294cc1772d752865a04ef6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/685415
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

3 weeks agoruntime: add benchmark for small-size memmory operation
Julian Zhu [Wed, 18 Jun 2025 09:26:26 +0000 (17:26 +0800)]
runtime: add benchmark for small-size memmory operation

On RISC-V and MIPS andarchitectures, misaligned load/store is not mandatory for implementations. Therefore, it's important to handle memory operations involving small sizes or data with a remainder when divided by 8 or 4.
This CL add some benchmark for small-size memmory operation, to ensure that SSA rules do not generate unaligned access traps on such architectures.

Change-Id: I6fcdfdb76e9552d5b10df140fa92568ac9468386
Reviewed-on: https://go-review.googlesource.com/c/go/+/682575
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 weeks agohash/crc32: add AVX512 IEEE CRC32 calculation
Klaus Post [Wed, 23 Jul 2025 11:23:52 +0000 (11:23 +0000)]
hash/crc32: add AVX512 IEEE CRC32 calculation

Benchmark:

goos: windows
goarch: amd64
pkg: hash/crc32
cpu: AMD Ryzen 9 9950X 16-Core Processor

benchmark                                               old MB/s     new MB/s     speedup
BenchmarkCRC32/poly=IEEE/size=15/align=0-32             1081.48      1089.42      1.01x
BenchmarkCRC32/poly=IEEE/size=15/align=1-32             1085.87      1082.61      1.00x
BenchmarkCRC32/poly=IEEE/size=40/align=0-32             2756.33      2752.37      1.00x
BenchmarkCRC32/poly=IEEE/size=40/align=1-32             2758.27      2756.99      1.00x
BenchmarkCRC32/poly=IEEE/size=512/align=0-32            18133.44     18076.52     1.00x
BenchmarkCRC32/poly=IEEE/size=512/align=1-32            18151.05     18055.41     0.99x
BenchmarkCRC32/poly=IEEE/size=1kB/align=0-32            19902.93     48581.07     2.44x
BenchmarkCRC32/poly=IEEE/size=1kB/align=1-32            19966.99     48393.25     2.42x
BenchmarkCRC32/poly=IEEE/size=4kB/align=0-32            21690.33     51679.25     2.38x
BenchmarkCRC32/poly=IEEE/size=4kB/align=1-32            21655.30     51731.22     2.39x
BenchmarkCRC32/poly=IEEE/size=32kB/align=0-32           22046.57     46406.90     2.10x
BenchmarkCRC32/poly=IEEE/size=32kB/align=1-32           21986.22     46250.66     2.10x

AVX512 are enabled above 1KB input size.

This rather high limit is due to AVX512 may be slower to ramp up
than the regular SSE4 implementation for smaller inputs.

This is not reflected in the benchmarks,
since consecutive calls means the CPU is "hot".

The 'HasAVX512VPCLMULQDQ' name mirrors the one in golang.org/x/sys/cpu

Change-Id: Id23685d8e3cc412b6d397a7d70056844bdb79271

Change-Id: Id23685d8e3cc412b6d397a7d70056844bdb79271
GitHub-Last-Rev: 6639f07b9febc7c96a7f3b402a2fd60f7be5e154
GitHub-Pull-Request: golang/go#74701
Reviewed-on: https://go-review.googlesource.com/c/go/+/689435
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 weeks agocmd/compile: prefer base.Fatalf to panic in dwarfgen
Derek Parker [Mon, 14 Jul 2025 22:28:59 +0000 (22:28 +0000)]
cmd/compile: prefer base.Fatalf to panic in dwarfgen

Updates a few spots which call `panic` to instead call `base.Fatalf`.

Change-Id: I30b73c7994caa647245b0e253f20e0b88185e644
GitHub-Last-Rev: b3839bbe424294f92a1f9448e5e0ac074e722e4d
GitHub-Pull-Request: golang/go#74616
Reviewed-on: https://go-review.googlesource.com/c/go/+/688035
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/internal/obj/s390x: add MVCLE instruction
kmvijay [Fri, 30 May 2025 10:10:20 +0000 (10:10 +0000)]
cmd/internal/obj/s390x: add MVCLE instruction

MVCLE (Move Long Extended) instruction is used to move large data storage-to-storage.
This change will add MVCLE into the Go asm for s390x architecture.
Upcoming PR of runtime/memmove_s390x.s will use this instruction for performance improvement.

Change-Id: I3bbb6668c736a36849917887398c74cebb1c3a99
Reviewed-on: https://go-review.googlesource.com/c/go/+/677455
Reviewed-by: Srinivas Pokala <Pokala.Srinivas@ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Munday <mikemndy@gmail.com>
Reviewed-by: Vishwanatha HD <vishwanatha.hd@ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 weeks agoruntime: optimize memclr on mips64x
Julian Zhu [Tue, 17 Jun 2025 03:37:07 +0000 (11:37 +0800)]
runtime: optimize memclr on mips64x

Memclr/5-4                          49.94n ±  5%         50.51n ±  1%        ~ (p=0.331 n=6)
Memclr/16-4                         22.71n ±  0%         21.01n ±  2%   -7.47% (p=0.002 n=6)
Memclr/64-4                         49.70n ±  1%         26.09n ±  1%  -47.51% (p=0.002 n=6)
Memclr/256-4                        84.23n ±  3%         44.32n ±  2%  -47.38% (p=0.002 n=6)
Memclr/4096-4                       805.6n ±  1%         220.9n ±  2%  -72.57% (p=0.002 n=6)
Memclr/65536-4                     12.734µ ±  1%         3.287µ ±  1%  -74.19% (p=0.002 n=6)
Memclr/1M-4                         209.1µ ±  0%         105.9µ ±  5%  -49.34% (p=0.002 n=6)
Memclr/4M-4                         838.9µ ±  6%         418.2µ ±  0%  -50.15% (p=0.002 n=6)
Memclr/8M-4                         1.708m ±  4%         1.108m ±  4%  -35.15% (p=0.002 n=6)
Memclr/16M-4                        3.458m ±  1%         2.840m ±  3%  -17.88% (p=0.002 n=6)
Memclr/64M-4                        14.05m ±  0%         11.40m ±  2%  -18.87% (p=0.002 n=6)
MemclrUnaligned/0_5-4               50.57n ±  2%         51.00n ±  0%        ~ (p=0.063 n=6)
MemclrUnaligned/0_16-4              48.82n ±  8%         22.39n ±  1%  -54.14% (p=0.002 n=6)
MemclrUnaligned/0_64-4              52.73n ±  3%         25.29n ±  0%  -52.05% (p=0.002 n=6)
MemclrUnaligned/0_256-4             88.41n ±  1%         50.04n ±  7%  -43.41% (p=0.002 n=6)
MemclrUnaligned/0_4096-4            802.2n ±  1%         220.4n ±  1%  -72.53% (p=0.002 n=6)
MemclrUnaligned/0_65536-4          12.729µ ±  0%         3.341µ ±  6%  -73.76% (p=0.002 n=6)
MemclrUnaligned/1_5-4               50.52n ±  0%         50.99n ±  6%   +0.93% (p=0.002 n=6)
MemclrUnaligned/1_16-4              71.23n ±  1%         71.78n ±  1%   +0.77% (p=0.041 n=6)
MemclrUnaligned/1_64-4              85.11n ±  0%         76.30n ±  1%  -10.36% (p=0.002 n=6)
MemclrUnaligned/1_256-4            133.50n ±  2%         91.91n ±  1%  -31.15% (p=0.002 n=6)
MemclrUnaligned/1_4096-4            849.7n ±  0%         291.3n ±  2%  -65.72% (p=0.002 n=6)
MemclrUnaligned/1_65536-4          12.776µ ±  1%         3.399µ ±  1%  -73.40% (p=0.002 n=6)
MemclrUnaligned/4_5-4               44.34n ±  0%         44.52n ±  7%   +0.41% (p=0.022 n=6)
MemclrUnaligned/4_16-4              70.68n ±  0%         71.24n ±  4%        ~ (p=0.132 n=6)
MemclrUnaligned/4_64-4              81.83n ±  4%         77.98n ±  2%   -4.71% (p=0.002 n=6)
MemclrUnaligned/4_256-4            121.15n ±  3%         87.58n ±  0%  -27.71% (p=0.002 n=6)
MemclrUnaligned/4_4096-4            837.0n ±  2%         278.8n ±  3%  -66.69% (p=0.002 n=6)
MemclrUnaligned/4_65536-4          12.793µ ±  6%         3.373µ ±  3%  -73.64% (p=0.002 n=6)
MemclrUnaligned/7_5-4               43.89n ±  2%         43.10n ±  0%   -1.80% (p=0.002 n=6)
MemclrUnaligned/7_16-4              73.59n ±  2%         72.95n ±  1%   -0.86% (p=0.006 n=6)
MemclrUnaligned/7_64-4              88.67n ±  0%         78.89n ±  1%  -11.03% (p=0.002 n=6)
MemclrUnaligned/7_256-4            123.90n ±  1%         85.41n ±  2%  -31.07% (p=0.002 n=6)
MemclrUnaligned/7_4096-4            842.8n ±  2%         268.0n ±  0%  -68.20% (p=0.002 n=6)
MemclrUnaligned/7_65536-4          12.877µ ± 11%         3.348µ ±  0%  -74.00% (p=0.002 n=6)
MemclrUnaligned/0_1M-4              208.4µ ±  5%         104.6µ ±  1%  -49.80% (p=0.002 n=6)
MemclrUnaligned/0_4M-4              836.1µ ±  7%         419.3µ ±  2%  -49.85% (p=0.002 n=6)
MemclrUnaligned/0_8M-4              1.701m ±  9%         1.136m ± 12%  -33.21% (p=0.002 n=6)
MemclrUnaligned/0_16M-4             3.467m ± 16%         2.832m ±  4%  -18.30% (p=0.002 n=6)
MemclrUnaligned/0_64M-4             14.05m ±  2%         11.33m ±  2%  -19.38% (p=0.002 n=6)
MemclrUnaligned/1_1M-4              208.8µ ±  4%         104.7µ ±  1%  -49.85% (p=0.002 n=6)
MemclrUnaligned/1_4M-4              838.0µ ±  0%         418.3µ ±  2%  -50.09% (p=0.002 n=6)
MemclrUnaligned/1_8M-4              1.692m ±  1%         1.108m ±  3%  -34.53% (p=0.002 n=6)
MemclrUnaligned/1_16M-4             3.463m ± 20%         2.833m ±  6%  -18.21% (p=0.002 n=6)
MemclrUnaligned/1_64M-4             14.05m ±  4%         11.35m ±  2%  -19.28% (p=0.002 n=6)
MemclrUnaligned/4_1M-4              209.2µ ±  1%         104.7µ ±  7%  -49.94% (p=0.002 n=6)
MemclrUnaligned/4_4M-4              836.2µ ±  6%         418.8µ ± 15%  -49.91% (p=0.002 n=6)
MemclrUnaligned/4_8M-4              1.702m ±  0%         1.123m ±  4%  -34.01% (p=0.002 n=6)
MemclrUnaligned/4_16M-4             3.476m ±  8%         2.804m ±  2%  -19.34% (p=0.002 n=6)
MemclrUnaligned/4_64M-4             14.13m ± 25%         11.40m ±  0%  -19.33% (p=0.002 n=6)
MemclrUnaligned/7_1M-4              208.9µ ±  8%         104.9µ ±  6%  -49.81% (p=0.002 n=6)
MemclrUnaligned/7_4M-4              845.6µ ± 12%         418.2µ ±  7%  -50.54% (p=0.002 n=6)
MemclrUnaligned/7_8M-4              1.706m ± 10%         1.101m ±  3%  -35.48% (p=0.002 n=6)
MemclrUnaligned/7_16M-4             3.466m ±  3%         2.812m ±  2%  -18.86% (p=0.002 n=6)
MemclrUnaligned/7_64M-4             14.08m ±  5%         11.35m ± 18%  -19.37% (p=0.002 n=6)
GoMemclr/5-4                        49.79n ±  2%         50.34n ±  0%        ~ (p=0.394 n=6)
GoMemclr/16-4                       21.64n ±  0%         22.04n ±  7%   +1.85% (p=0.002 n=6)
GoMemclr/64-4                       47.93n ±  4%         23.77n ±  4%  -50.41% (p=0.002 n=6)
GoMemclr/256-4                      82.77n ±  2%         43.90n ±  0%  -46.96% (p=0.002 n=6)

Change-Id: I272967d001809ac4948e4118df6cdd0e0661ab96
Reviewed-on: https://go-review.googlesource.com/c/go/+/682195
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

3 weeks agoruntime: improvement in memclr for s390x
kmvijay [Wed, 18 Jun 2025 10:57:46 +0000 (10:57 +0000)]
runtime: improvement in memclr for s390x

The unrolled loop for sizes >= 4KB is further optimized.
Offsets are computed and included in the XC instruction directly.
This reduces code size and instructions, improves performance.

goos: linux
goarch: s390x
pkg: runtime
                        | Orig_Memclr_for_benchstat_2.log | MM_Memclr_for_benchstat_No_VSTL_3.log  |
                        |             sec/op              |    sec/op     vs base                  |
Memclr/5                                     1.925n ±  0%   1.925n ±  0%        ~ (p=0.211 n=10)
Memclr/16                                    2.604n ± 13%   2.633n ± 11%        ~ (p=0.912 n=10)
Memclr/64                                    3.598n ±  2%   3.520n ±  5%        ~ (p=0.190 n=10)
Memclr/256                                   3.571n ± 12%   3.538n ± 11%        ~ (p=0.739 n=10)
Memclr/4096                                  15.15n ±  0%   15.14n ±  0%        ~ (p=0.204 n=10)
Memclr/65536                                 226.3n ±  0%   224.9n ±  0%   -0.62% (p=0.000 n=10)
Memclr/1M                                    12.77µ ±  0%   12.60µ ±  0%   -1.35% (p=0.000 n=10)
Memclr/4M                                    51.07µ ±  0%   50.37µ ±  0%   -1.38% (p=0.000 n=10)
Memclr/8M                                    102.1µ ±  0%   100.7µ ±  0%   -1.36% (p=0.000 n=10)
Memclr/16M                                   204.4µ ±  0%   201.6µ ±  0%   -1.35% (p=0.000 n=10)
Memclr/64M                                   965.4µ ±  0%   935.3µ ±  0%   -3.12% (p=0.000 n=10)
MemclrUnaligned/0_5                          2.671n ±  6%   2.618n ±  0%        ~ (p=0.194 n=10)
MemclrUnaligned/0_16                         3.143n ±  6%   2.955n ±  8%        ~ (p=0.089 n=10)
MemclrUnaligned/0_64                         3.622n ±  3%   3.571n ±  2%        ~ (p=0.304 n=10)
MemclrUnaligned/0_256                        3.712n ±  8%   3.653n ±  5%        ~ (p=0.754 n=10)
MemclrUnaligned/0_4096                       15.14n ±  0%   15.14n ±  0%        ~ (p=1.000 n=10) ¹
MemclrUnaligned/0_65536                      231.9n ±  0%   225.2n ±  0%   -2.91% (p=0.000 n=10)
MemclrUnaligned/1_5                          2.620n ±  8%   2.620n ±  0%        ~ (p=0.866 n=10)
MemclrUnaligned/1_16                         3.103n ±  7%   2.933n ±  9%        ~ (p=0.052 n=10)
MemclrUnaligned/1_64                         3.576n ±  3%   3.568n ±  3%        ~ (p=0.748 n=10)
MemclrUnaligned/1_256                        3.744n ±  9%   3.709n ± 10%        ~ (p=0.853 n=10)
MemclrUnaligned/1_4096                       26.23n ±  0%   26.23n ±  0%        ~ (p=1.000 n=10) ¹
MemclrUnaligned/1_65536                      401.1n ±  0%   399.5n ±  0%   -0.40% (p=0.000 n=10)
MemclrUnaligned/4_5                          2.620n ±  6%   2.623n ±  0%        ~ (p=0.985 n=10)
MemclrUnaligned/4_16                         3.095n ±  7%   3.005n ±  9%        ~ (p=0.247 n=10)
MemclrUnaligned/4_64                         3.586n ±  1%   3.578n ±  3%        ~ (p=1.000 n=10)
MemclrUnaligned/4_256                        3.843n ±  5%   3.742n ± 10%        ~ (p=0.971 n=10)
MemclrUnaligned/4_4096                       26.23n ±  0%   26.23n ±  0%        ~ (p=1.000 n=10)
MemclrUnaligned/4_65536                      401.1n ±  0%   399.5n ±  0%   -0.41% (p=0.000 n=10)
MemclrUnaligned/7_5                          2.634n ±  6%   2.644n ±  4%        ~ (p=0.896 n=10)
MemclrUnaligned/7_16                         3.119n ±  7%   3.044n ±  9%        ~ (p=0.529 n=10)
MemclrUnaligned/7_64                         3.568n ±  1%   3.585n ±  3%        ~ (p=0.499 n=10)
MemclrUnaligned/7_256                        3.741n ±  9%   3.629n ±  6%        ~ (p=0.853 n=10)
MemclrUnaligned/7_4096                       26.23n ±  0%   26.23n ±  0%        ~ (p=1.000 n=10) ¹
MemclrUnaligned/7_65536                      401.1n ±  0%   399.4n ±  0%   -0.42% (p=0.000 n=10)
MemclrUnaligned/0_1M                         12.82µ ±  0%   12.60µ ±  0%   -1.70% (p=0.000 n=10)
MemclrUnaligned/0_4M                         51.28µ ±  0%   50.37µ ±  0%   -1.77% (p=0.000 n=10)
MemclrUnaligned/0_8M                         102.5µ ±  0%   100.8µ ±  0%   -1.75% (p=0.000 n=10)
MemclrUnaligned/0_16M                        205.1µ ±  0%   201.7µ ±  0%   -1.62% (p=0.000 n=10)
MemclrUnaligned/0_64M                        965.2µ ±  0%   934.7µ ±  0%   -3.16% (p=0.000 n=10)
MemclrUnaligned/1_1M                         16.02µ ±  0%   15.81µ ±  0%   -1.34% (p=0.000 n=10)
MemclrUnaligned/1_4M                         64.03µ ±  0%   63.20µ ±  0%   -1.29% (p=0.000 n=10)
MemclrUnaligned/1_8M                         128.0µ ±  0%   126.4µ ±  0%   -1.27% (p=0.000 n=10)
MemclrUnaligned/1_16M                        256.3µ ±  0%   253.2µ ±  0%   -1.21% (p=0.000 n=10)
MemclrUnaligned/1_64M                        1.210m ±  0%   1.187m ±  0%   -1.88% (p=0.000 n=10)
MemclrUnaligned/4_1M                         16.03µ ±  0%   15.81µ ±  0%   -1.37% (p=0.000 n=10)
MemclrUnaligned/4_4M                         64.04µ ±  0%   63.20µ ±  0%   -1.31% (p=0.000 n=10)
MemclrUnaligned/4_8M                         128.0µ ±  0%   126.4µ ±  0%   -1.27% (p=0.000 n=10)
MemclrUnaligned/4_16M                        256.1µ ±  0%   253.0µ ±  0%   -1.20% (p=0.000 n=10)
MemclrUnaligned/4_64M                        1.210m ±  0%   1.188m ±  0%   -1.81% (p=0.000 n=10)
MemclrUnaligned/7_1M                         16.02µ ±  0%   15.81µ ±  0%   -1.32% (p=0.000 n=10)
MemclrUnaligned/7_4M                         64.06µ ±  0%   63.21µ ±  0%   -1.34% (p=0.000 n=10)
MemclrUnaligned/7_8M                         128.1µ ±  0%   126.4µ ±  0%   -1.29% (p=0.000 n=10)
MemclrUnaligned/7_16M                        256.2µ ±  0%   253.2µ ±  0%   -1.18% (p=0.000 n=10)
MemclrUnaligned/7_64M                        1.210m ±  0%   1.188m ±  0%   -1.82% (p=0.000 n=10)
MemclrRange/1K_2K                            841.1n ±  1%   879.0n ±  3%   +4.51% (p=0.002 n=10)
MemclrRange/2K_8K                            1.435µ ±  2%   1.415µ ±  0%   -1.39% (p=0.000 n=10)
MemclrRange/4K_16K                           1.241µ ±  0%   1.209µ ±  0%   -2.58% (p=0.000 n=10)
MemclrRange/160K_228K                        19.83µ ±  0%   19.59µ ±  0%   -1.22% (p=0.000 n=10)
MemclrKnownSize1                             1.732n ±  0%   1.732n ±  0%        ~ (p=0.474 n=10)
MemclrKnownSize2                             1.925n ±  3%   1.925n ±  1%        ~ (p=0.929 n=10)
MemclrKnownSize4                             1.732n ±  0%   1.732n ±  0%        ~ (p=1.000 n=10) ¹
MemclrKnownSize8                             1.732n ±  0%   1.732n ±  0%        ~ (p=1.000 n=10)
MemclrKnownSize16                            2.413n ±  9%   2.681n ± 14%  +11.10% (p=0.004 n=10)
MemclrKnownSize32                            3.284n ±  4%   3.328n ±  2%        ~ (p=0.671 n=10)
MemclrKnownSize64                            4.893n ±  1%   4.882n ±  1%        ~ (p=0.591 n=10)
MemclrKnownSize112                           5.623n ±  2%   5.596n ±  2%   -0.48% (p=0.027 n=10)
MemclrKnownSize128                           5.612n ±  1%   5.599n ±  0%        ~ (p=0.066 n=10)
MemclrKnownSize192                           7.128n ±  1%   7.337n ±  2%   +2.93% (p=0.000 n=10)
MemclrKnownSize248                           6.740n ±  1%   6.829n ±  3%   +1.33% (p=0.005 n=10)
MemclrKnownSize256                           3.657n ±  8%   3.512n ± 14%        ~ (p=0.436 n=10)
MemclrKnownSize512                           3.624n ±  3%   3.982n ±  9%   +9.88% (p=0.017 n=10)
MemclrKnownSize1024                          4.662n ±  0%   4.680n ±  0%   +0.39% (p=0.000 n=10)
MemclrKnownSize4096                          15.14n ±  0%   15.15n ±  0%   +0.07% (p=0.000 n=10)
MemclrKnownSize512KiB                        6.388µ ±  0%   6.309µ ±  0%   -1.24% (p=0.000 n=10)
geomean                                      268.9n         266.9n         -0.75%
¹ all samples are equal

Change-Id: I2911866fb82777311ec4219600fb48c85f7bf862
Reviewed-on: https://go-review.googlesource.com/c/go/+/682595
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 weeks agointernal/runtime/exithook: fix a typo
Jes Cok [Thu, 24 Jul 2025 13:58:50 +0000 (13:58 +0000)]
internal/runtime/exithook: fix a typo

That is the say -> That is to say

Change-Id: I4a19d4c500103e16e6ae55f41a9fbdddd4bb84a8
GitHub-Last-Rev: 571d49ab8e6d81ac9db8b47d89118fb74bd3f2f6
GitHub-Pull-Request: golang/go#74741
Reviewed-on: https://go-review.googlesource.com/c/go/+/690195
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

3 weeks agocmd/internal/goobj: make error output clear
wingrez [Tue, 22 Jul 2025 15:12:58 +0000 (15:12 +0000)]
cmd/internal/goobj: make error output clear

Change-Id: Ic8510037e5d745f3c9f1b9c203439d3fe2e2d5a5
GitHub-Last-Rev: 4101a1595bd542bec8c20e4332c884125ee57aff
GitHub-Pull-Request: golang/go#74703
Reviewed-on: https://go-review.googlesource.com/c/go/+/689515
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/go/internal/doc: clean up after merge with cmd/internal/doc
Michael Matloob [Wed, 23 Jul 2025 15:45:01 +0000 (11:45 -0400)]
cmd/go/internal/doc: clean up after merge with cmd/internal/doc

This is done in a separate CL to reduce the diffs from the previous CL.
Merge the main.go and doc.go files, and isolate the bootstrap-tagged
code to one file.

For #74667

Change-Id: I11bf0aa18beeb898937135f49f473c1ba1b7e756
Reviewed-on: https://go-review.googlesource.com/c/go/+/689875
Reviewed-by: Michael Matloob <matloob@google.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 weeks agocmd/internal/doc: merge with cmd/go/internal/doc
Michael Matloob [Wed, 23 Jul 2025 15:25:14 +0000 (11:25 -0400)]
cmd/internal/doc: merge with cmd/go/internal/doc

Now that cmd/doc has been removed, cmd/go/internal/doc is the only user
of the cmd/internal/doc code. Merge cmd/internal/doc into
cmd/go/internal/doc.

For #74667

Change-Id: I16bbe7b1f418b54ee411c8d6e6609c0973e40b3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/689836
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/doc: delete
Michael Matloob [Wed, 23 Jul 2025 15:25:14 +0000 (11:25 -0400)]
cmd/doc: delete

Users should not invoke "go tool doc" directly, but should instead run
"go doc". Remove "cmd/doc" because it no longer invokes the "doc" tool
but incorporates its logic directly.

Fixes #74667

Change-Id: I357a3d7e0ca075f028df66e34951a41354c08941
Reviewed-on: https://go-review.googlesource.com/c/go/+/689835
Reviewed-by: Michael Matloob <matloob@google.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agoruntime: randomize heap base address
Roland Shoemaker [Wed, 21 May 2025 02:03:44 +0000 (02:03 +0000)]
runtime: randomize heap base address

During initialization, allow randomizing the heap base address by
generating a random uint64 and using its bits to randomize various
portions of the heap base address.

We use the following method to randomize the base address:

* We first generate a random heapArenaBytes aligned address that we use
  for generating the hints.
* On the first call to mheap.grow, we then generate a random
  PallocChunkBytes aligned offset into the mmap'd heap region, which we
  use as the base for the heap region.
* We then mark a random number of pages within the page allocator as
  allocated.

Our final randomized "heap base address" becomes the first byte of
the first available page returned by the page allocator. This results
in an address with at least heapAddrBits-gc.PageShift-1 bits of
entropy.

Fixes #27583

Change-Id: Ideb4450a5ff747a132f702d563d2a516dec91a88
Reviewed-on: https://go-review.googlesource.com/c/go/+/674835
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/compile: use better fatal message for staticValue1
Cuong Manh Le [Thu, 22 May 2025 13:57:33 +0000 (20:57 +0700)]
cmd/compile: use better fatal message for staticValue1

So the position of the wrong assignment statement will be reported,
instead of using incorrect base.Pos one.

Notice while fixing issue #73823.

Change-Id: I53f240bf99d11b5f5082ee4ca0903d9f099881b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/675495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
3 weeks agocmd/cgo: compare malloc return value to NULL instead of literal 0
Tobias Klauser [Wed, 28 May 2025 09:26:17 +0000 (11:26 +0200)]
cmd/cgo: compare malloc return value to NULL instead of literal 0

Follow the pattern used in the other _cgoPREFIX_Cfunc* functions. This
also avoids a -Wzero-as-null-pointer-constant warning when compiling
with g++.

Change-Id: I95ac8842df048105f4c738f3603136d9cfa2dfdc
Reviewed-on: https://go-review.googlesource.com/c/go/+/664916
Auto-Submit: Keith Randall <khr@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 weeks agogo/types, types2: better error messages for certain type mismatches
Robert Griesemer [Wed, 18 Jun 2025 00:09:27 +0000 (17:09 -0700)]
go/types, types2: better error messages for certain type mismatches

When an untyped operand of a (typically binary) operation does not
match the type of the operand and an implicit conversion is not
possible, the error message should report a "type mismatch".

The type-checkers mostly did so, but not for untyped numeric types
to other types (e.g. an untyped int vs a function); in those cases
it reported that the (impossible) conversion failed.

Fix this for numeric types.
This also improves the position and messages for some incorrect
min/max built-in calls.

Fixes #73428.

Change-Id: I8af071918b73fcc72f16cc61858d7baca57fc259
Reviewed-on: https://go-review.googlesource.com/c/go/+/682495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

3 weeks agocmd/compile: use ,ok return idiom for sparsemap.get
Keith Randall [Fri, 13 Jun 2025 18:08:53 +0000 (11:08 -0700)]
cmd/compile: use ,ok return idiom for sparsemap.get

Change-Id: I89719b94de74a32402d02309515dffc4989484db
Reviewed-on: https://go-review.googlesource.com/c/go/+/681575
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>

3 weeks agocmd/compile: use generics for sparse map
Keith Randall [Thu, 12 Jun 2025 00:14:59 +0000 (17:14 -0700)]
cmd/compile: use generics for sparse map

So it is easier to reuse this code with different key/value types.

Change-Id: I5a9e669769cf359b32f2fe784594868acdee4d02
Reviewed-on: https://go-review.googlesource.com/c/go/+/681175
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 weeks agocmd/api: rerun updategolden
Keith Randall [Thu, 22 May 2025 17:25:49 +0000 (10:25 -0700)]
cmd/api: rerun updategolden

Not sure why, but

    go test cmd/api --updategolden

makes changes to the golden files. The changes are just moving things
around, no actual semantic changes. But this is confusing for new
contributors when updating api files.

Change-Id: If27b039f47b94953b7891f8f6b6999ed79953198
Reviewed-on: https://go-review.googlesource.com/c/go/+/675616
Auto-Submit: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
3 weeks agoruntime: drop NetBSD kernel bug sysmon workaround fixed in NetBSD 9.2
Tobias Klauser [Fri, 11 Jul 2025 20:59:10 +0000 (22:59 +0200)]
runtime: drop NetBSD kernel bug sysmon workaround fixed in NetBSD 9.2

The NetBSD releases supported by the NetBSD project as off today are 9.4
and 10.1. The Go project's NetBSD builders are on 9.3. Thus, it is fine
to drop the workaround which was only needed for NetBSD before 9.2.

Fixes #46495

Cq-Include-Trybots: luci.golang.try:gotip-netbsd-arm64
Change-Id: I3c2ec42fb0f08f7dafdfb7f1dbd97853afc16386
Reviewed-on: https://go-review.googlesource.com/c/go/+/687735
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/go: clean should respect workspaces
Adi Aloni [Mon, 23 Jun 2025 10:39:20 +0000 (13:39 +0300)]
cmd/go: clean should respect workspaces

The existing implementation doesn't invoke modload.InitWorkfile during
runClean which in turn causes go clean to ignore workspaces and
consequentially workspace vendoring.

Fixes #74337

Change-Id: I295a1fcc5e81d096971c8cee9c9baa840c7725e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/682856
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
3 weeks agoencoding/json/jsontext: preserve buffer capacity in Decoder.Reset
Filip Petkovski [Mon, 23 Jun 2025 11:47:21 +0000 (11:47 +0000)]
encoding/json/jsontext: preserve buffer capacity in Decoder.Reset

The Decoder.Reset method is not preserving the internal buffer between
resets, causing buffer capacity to be lost and resulting in unnecessary
allocations when reusing decoders. This is particularly problematic when
decoding many small messages.

This commit fixes the Reset method to preserve the internal buffer. It
makes sure aliasing is removed if the buffer currently points to an
internal byte slice of a bytes.Buffer. It adds a TestDecoderReset test
structured into subtests to better validate the different scenarios.

Change-Id: Ia685bff47034598224489173bb7f2ffd48e89da5
GitHub-Last-Rev: 462ddc936409ee3da6d75def7d9de59eb3c65f8d
GitHub-Pull-Request: golang/go#74120
Reviewed-on: https://go-review.googlesource.com/c/go/+/681177
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>

3 weeks agocmd/go: always return the cached path from go tool -n
Michael Matloob [Fri, 18 Jul 2025 18:14:16 +0000 (14:14 -0400)]
cmd/go: always return the cached path from go tool -n

If we're running go tool -n always return the cached path of the tool.
We can't always use the cached path when running the tool because if we
copied the tool to the cached location in the same process and then try
to run it we'll run into #22315, producing spurious ETXTBSYs.

Fixes #72824

Change-Id: I81f23773b9028f955ccc97453627ae4f2573814b
Reviewed-on: https://go-review.googlesource.com/c/go/+/688895
Auto-Submit: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agoruntime: check TestUsingVDSO ExitError type assertion
Michael Pratt [Wed, 23 Jul 2025 20:56:50 +0000 (16:56 -0400)]
runtime: check TestUsingVDSO ExitError type assertion

Currently this test panics if the error is not an ExitError. We aren't
expecting other errors, but we want to continue to the t.Fatal so the
error contents actually get logged.

For #74672.

Change-Id: I6a6a636cee5ddac500ed7ec549340b02944101ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/689956
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>

3 weeks agodoc/next: initialize
Michael Anthony Knyszek [Wed, 23 Jul 2025 17:50:06 +0000 (17:50 +0000)]
doc/next: initialize

Initialize the doc/next directory for the next release by copying the
contents of doc/initial into it.

For #73829.

Change-Id: Ia473d0430043920fc5135844ec6c117eb1b00217
Reviewed-on: https://go-review.googlesource.com/c/go/+/689878
Reviewed-by: Mark Freeman <mark@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agointernal/goversion: update Version to 1.26
Michael Anthony Knyszek [Wed, 23 Jul 2025 17:47:03 +0000 (17:47 +0000)]
internal/goversion: update Version to 1.26

Go 1.26 is in the process of being opened for development (to be
eventually released). This change marks the very beginning of its
development cycle, updating the Version value accordingly.

For #40705.
For #73829.

Change-Id: Ie4ce2d38160dd6283c08e10ecbd7d3a43ed92b48
Reviewed-on: https://go-review.googlesource.com/c/go/+/689877
Reviewed-by: Mark Freeman <mark@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

3 weeks agocmd/link: scope test to linux & net.sendFile
Derek Parker [Wed, 23 Jul 2025 17:52:35 +0000 (17:52 +0000)]
cmd/link: scope test to linux & net.sendFile

Limits the scope of new test added in 71c2bf551303930faa32886446910fa5bd0a701a.

Discussion: https://go-review.googlesource.com/c/go/+/684377.

Change-Id: I0e8f513eb564aae277ba8a80ebdad469eb1e6e6a
GitHub-Last-Rev: add2b2e2096e5221ac3d54376c1afa1bec10482c
GitHub-Pull-Request: golang/go#74720
Reviewed-on: https://go-review.googlesource.com/c/go/+/689916
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
4 weeks agocmd/compile: fix loclist for heap return vars without optimizations
Derek Parker [Tue, 22 Jul 2025 22:05:06 +0000 (22:05 +0000)]
cmd/compile: fix loclist for heap return vars without optimizations

When compiling without optimizations certain variables such as
return params end up missing location lists.

Fixes #65405

Change-Id: Id4ec6b1ab6681fd77b8fefb47a4ec05060c128ef
GitHub-Last-Rev: 5ab6a5398162119dd0cd5325f4239b4559b030bd
GitHub-Pull-Request: golang/go#74398
Reviewed-on: https://go-review.googlesource.com/c/go/+/684377
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
4 weeks agonet: correct comment for ListenConfig.ListenPacket
Lyle Dean [Sun, 20 Jul 2025 23:20:11 +0000 (00:20 +0100)]
net: correct comment for ListenConfig.ListenPacket

Fixes #74634

Change-Id: I21196c4aef1b717bfda0b54e61b35e83cfa9dc1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/689075
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 weeks agoall: go fmt
Michael Pratt [Tue, 22 Jul 2025 15:17:06 +0000 (11:17 -0400)]
all: go fmt

Change-Id: I6a6a636c341d4ba3518be7f6806093bbdff11c88
Reviewed-on: https://go-review.googlesource.com/c/go/+/689535
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 weeks agocmd/internal/objabi: remove redundant word in comment
cuishuang [Mon, 9 Jun 2025 07:47:15 +0000 (15:47 +0800)]
cmd/internal/objabi: remove redundant word in comment

Change-Id: I9bbce94a2f36d5de28b946c94652876f01907fe6
Reviewed-on: https://go-review.googlesource.com/c/go/+/680115
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>

4 weeks agoruntime: relax TestMemoryLimitNoGCPercent a bit
Keith Randall [Mon, 21 Jul 2025 20:37:27 +0000 (13:37 -0700)]
runtime: relax TestMemoryLimitNoGCPercent a bit

It seems to be pretty flaky. I've seen:

retained=289438024
   limit=268435456
   bound=285212672

Which is ~4MB over the bound.

Not sure why this tends to be darwin-specific, but we'll fix
just darwin for now.
(It isn't quite darwin-only, as it appeared in #66893.
But it is certainly worse on darwin.)

Fixes #73136
Update #66893

Change-Id: If609e909bc6c65c2663dd46b7a9bad4fd291c3da
Reviewed-on: https://go-review.googlesource.com/c/go/+/689315
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 weeks agocmd/compile: for arm64 epilog, do SP increment with a single instruction
Keith Randall [Mon, 21 Jul 2025 17:09:35 +0000 (10:09 -0700)]
cmd/compile: for arm64 epilog, do SP increment with a single instruction

That way, the frame is atomically popped. Previously, for big frames
the SP was unwound in two steps (because arm64 can only add constants
up to 1<<12 in a single instruction).

Fixes #73259

Change-Id: I382c249194ad7bc9fc19607c27487c58d90d49e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/689235
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
4 weeks agoruntime: fix asan wrapper for riscv64
Keith Randall [Sat, 19 Jul 2025 16:34:04 +0000 (09:34 -0700)]
runtime: fix asan wrapper for riscv64

Make sure we keep the M in X21. The instruction at line 87
needs to be loading from the M, not from the gsignal.

Fixes #73979, maybe?

Change-Id: I3aba1c35454636138b305bca26e20dbc8e6b1d6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/688975
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 weeks agocmd/go: check subcommand properties
Ian Alexander [Fri, 30 May 2025 21:59:34 +0000 (17:59 -0400)]
cmd/go: check subcommand properties

This change corrects the properties checked by Lookup.  We were
inspecting the properties of the Command receiver; now we are
inspecting the properties of the subcommand.

Fixes #73864.

Change-Id: Ieb462e489fc4f8f0568aa3a2d404b322d627166c
Reviewed-on: https://go-review.googlesource.com/c/go/+/678655
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>