62918 Commits

Author SHA1 Message Date
Alan Donovan
8433412b74 go/types: document that Defs[id] may be missing in ill-typed code
Updates #70968

Change-Id: Id0a4acd6bad917ba8a5c439625bca14469b6eb7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/663895
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2025-04-08 13:26:21 -07:00
Mark Freeman
559b5d814f go/types, types2: fix failing error message test for s390x
Fixes #73206.

Change-Id: If27ce5fe7aa71415b6e2d525c78b1f04b88a308b
Reviewed-on: https://go-review.googlesource.com/c/go/+/663635
TryBot-Result: Gopher Robot <gobot@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2025-04-08 08:25:47 -07:00
qmuntal
3a4f077710 syscall: fix dangling pointers in Windows' process attributes
Windows' _PROC_THREAD_ATTRIBUTE_LIST can contain pointers to memory
owned by Go, but the GC is not aware of this. This can lead to the
memory being freed while the _PROC_THREAD_ATTRIBUTE_LIST is still in
use.

This CL uses the same approach as in x/sys/windows to ensure that the
attributes are not collected by the GC.

Fixes #73170.
Updates #73199.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest
Change-Id: I7dca8d386aed4c02fdcd4a631d0fa4dc5747a96f
Reviewed-on: https://go-review.googlesource.com/c/go/+/663715
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@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-08 07:56:17 -07:00
Mateusz Poliwczak
58b6891108 go/ast: don't MergeLine in SortImports when last import on the same line as RParen
Fixes #69183

Change-Id: I8b78dadaa8ba91e74ea2bfc21abd6abe72b7e38b
GitHub-Last-Rev: 1a41f9e8e3bef9926993813568902d1a77c991c1
GitHub-Pull-Request: golang/go#69187
Reviewed-on: https://go-review.googlesource.com/c/go/+/610035
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-08 07:56:01 -07:00
apocelipes
38a2a3c7ce runtime: use internal/byteorder
To simplify the code.

Change-Id: Ib1af5009cc25bb29fd26fdb7b29ff4579f0150aa
GitHub-Last-Rev: f698a8a771ac8c6ecb745ea4c27a7c677c1789d1
GitHub-Pull-Request: golang/go#73255
Reviewed-on: https://go-review.googlesource.com/c/go/+/663735
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-08 07:47:16 -07:00
Mateusz Poliwczak
14b15a2bea internal/runtime/maps: pass proper func PC to race.WritePC/race.ReadPC
Fixes #73191

Change-Id: I0f8a5a19faa745943a98476c7caf4c97ccdce184
Reviewed-on: https://go-review.googlesource.com/c/go/+/663175
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-08 06:12:47 -07:00
Keith Randall
af278bfb1f cmd/compile: add additional flag constant folding rules
Fixes #73200

Change-Id: I77518d37acd838acf79ed113194bac5e2c30897f
Reviewed-on: https://go-review.googlesource.com/c/go/+/663535
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@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2025-04-07 22:48:32 -07:00
Brad Fitzpatrick
92309ff771 doc/next: fix link
It was rendering incorrectly at https://tip.golang.org/doc/go1.25

Change-Id: I2f66c95414ac5d71b9b02b91bcdc0d0a87b3f605
Reviewed-on: https://go-review.googlesource.com/c/go/+/662436
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-07 13:59:43 -07:00
zhi.wang
8054d2da5b strconv: use switch for '+'/'-' prefix handling
Follow the approach used in strconv's readFloat, decimal.set, and Atoi,
where leading '+' and '-' are handled using a switch for clarity and
consistency.

Change-Id: I41eff34ce90b5ac43fcdbc0bb88910d6d5fb4d39
GitHub-Last-Rev: 0c9d2efb5a828515fa00afdba8c436aa31fb0e53
GitHub-Pull-Request: golang/go#73185
Reviewed-on: https://go-review.googlesource.com/c/go/+/663257
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-07 13:36:46 -07:00
abemotion
b2819d13db net/http: add link to types
Some types are not linked.
This change adds a link to each type.

Change-Id: Id46fb64a74efb851ed76e4136f15e8fd9e445bb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/663075
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-07 13:35:49 -07:00
Mateusz Poliwczak
ffe47d9789 go/ast: move sortimports test directly to go/ast
For some reason i have created a separate package instead
of using _test package. Let's move this test where it belongs.

Change-Id: Ib569ca433de1ef4e161b9d334125648e00b7d3c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/663555
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-04-07 13:34:20 -07:00
cuishuang
465097b2b5 all: use built-in max/min to simplify the code
Change-Id: I309d93d6ebf0feb462217a344d5f02c190220752
Reviewed-on: https://go-review.googlesource.com/c/go/+/661737
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-07 12:59:28 -07:00
Sam Thanawalla
d584d2b3dd cmd/go: fix version stamping for v2 modules and subdirectories
We were not passing the module path to newCodeRepo which caused it to
incorrectly parse the major version. This allowed v0 and v1 modules to
work because an empty major version is allowed in that case.

Additionally we need to pass the root module path to derive the correct tag
for subdirectories.

Fixes: #72877
Fixes: #71738
Change-Id: Id792923f426858513972e713623270edbc76c545
Reviewed-on: https://go-review.googlesource.com/c/go/+/661875
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2025-04-07 11:29:57 -07:00
Carlos Amedee
a08d2db6d1 doc/go1.25: document macOS requirements
For #69839.
For #71661.

Change-Id: Ic13f4b7fb81461d55216b260384ee10037b86054
Reviewed-on: https://go-review.googlesource.com/c/go/+/663515
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-07 11:04:56 -07:00
Richard Miller
adb29670fc runtime: protect plan9 time_now function with !faketime build tag
The introduction of monotonic time support for Plan 9 in CL 656755
causes a build error with multiple declaration of time_now when
built with tag faketime. Correct this by moving function time_now
into its own source file with !faketime build tag.

Fixes #73169

Change-Id: Id7a9a1c77e286511e25546089681f2f88a9538bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/662856
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-07 09:53:44 -07:00
Xin Hao
20a924fe87 log/slog: make examples playable
Fixes #69246

Change-Id: I8e59132980404ee58ba2ca8718dd9f68404fdf8d
GitHub-Last-Rev: f59d3fad2002cda69a24789f2fdd4e9753cede9c
GitHub-Pull-Request: golang/go#69249
Reviewed-on: https://go-review.googlesource.com/c/go/+/610535
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2025-04-07 09:34:01 -07:00
Nicola Murino
3046b49991 crypto/tls: add offered cipher suites to the handshake error
This change makes debugging easier if the server handshake fails because
the client only offers unsupported algorithms.

Change-Id: I7daac173a16af2e073aec3d9b59709560f540c6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/631555
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Nicola Murino <nicola.murino@gmail.com>
2025-04-07 09:32:45 -07:00
Dimitri John Ledkov
a6e7445457 cmd/go/internal/load: join incompatible and dirty build specifiers with .
Change "+incompatible+dirty" version to be "+incompatible.dirty" such
that it is SemVer spec compatible.

Fixes #71971

Change-Id: I714ffb3f1ad88c793656c3652367db34739a2144
Reviewed-on: https://go-review.googlesource.com/c/go/+/652955
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Michael Matloob <matloob@golang.org>
2025-04-07 07:58:05 -07:00
Sam Thanawalla
e8adc39332 cmd/go: fix GOAUTH parsing for trailing slash
We were treating a url with a trailing slash differently than one
without. This CL treats them the same.

Additionally this fixes a bug in the way we iteratively try different
prefixes. We were only trying the host url but this change now tries all
different prefixes.

Fixes: #71889
Change-Id: I5d5f43000ae0e18ea8682050037253aff75ec142
Reviewed-on: https://go-review.googlesource.com/c/go/+/662435
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>
2025-04-07 07:33:33 -07:00
Keith Randall
16dbd2be39 cmd/compile: be more conservative about arm64 insns that can take zero register
It's really only needed for stores and store-like instructions
(atomic exchange, compare-and-swap, ...).

Fixes #73180

Change-Id: I8ecd833a301355adf0fa4bff43250091640c6226
Reviewed-on: https://go-review.googlesource.com/c/go/+/663155
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-06 19:11:43 -07:00
cuishuang
6fd9ee3da9 all: use slices.Equal to simplify code
Change-Id: Ib3be7cee6ca6dce899805aac176ca789eb2fd0f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/661738
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-04-06 09:36:41 -07:00
Keith Randall
1647896aa2 cmd/compile: on 32-bit, bump up align for values that may contain 64-bit fields
On 32-bit systems, these need to be aligned to 8 bytes, even though the
typechecker doesn't tell us that.

The 64-bit allocations might be the target of atomic operations
that require 64-bit alignment.

Fixes 386 longtest builder.

Fixes #73173

Change-Id: I68f6a4f40c7051d29c57ecd560c8d920876a56a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/663015
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-04 23:25:15 -07:00
khr@golang.org
e373771490 cmd/compile: use zero register instead of specialized *zero instructions
This lets us get rid of lots of specialized opcodes for storing zero.
Instead, use regular store opcodes that just happen to use the zero
register as one of their inputs.

Change-Id: I2902a6f9b0831cb598df45189ca6bb57221bef72
Reviewed-on: https://go-review.googlesource.com/c/go/+/633075
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-04 15:26:24 -07:00
Keith Randall
2d050e91a3 cmd/compile: allow pointer-containing elements in stack allocations
For variable-sized allocations.

Turns out that we already implement the correct escape semantics
for this case. Even when the result of the "make" does not escape,
everything assigned into it does.

Change-Id: Ia123c538d39f2f1e1581c24e4135a65af3821c5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/657937
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-04-04 15:04:34 -07:00
qmuntal
7e60bdd7aa os: support overlapped IO with NewFile
The runtime/poll package has just gained support for overlapped IO,
see CL 660595 and CL 661955. The only remaining piece was making it
visible to user code via os.NewFile.

Some of the poll.FD.Init responsibility has been moved to os.NewFile
to avoid unnecessary syscalls for the common case of using os.Open,
os.Create, os.OpenFile, and os.Pipe, where we know that the file
is not opened for overlapped IO.

Some internal/poll tests have been moved to the os package to exercise
public APIs rather than internal ones.

The os.NewFile function definition has been moved into an OS-agnostic
file to avoid having duplicated documentation and ensure that the
caller is aware of its behavior across all platforms.

Closes #19098.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-amd64-race,gotip-windows-arm64
Change-Id: If043f8b34d588cd4b481777203107ed92d660fd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/662236
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
2025-04-04 14:00:21 -07:00
Keith Randall
5fc596ebe7 cmd/compile: aggregate scalar allocations for heap escapes
If multiple small scalars escape to the heap, allocate them together
with a single allocation. They are going to be aggregated together
in the tiny allocator anyway, might as well do just one runtime call.

Change-Id: I4317e29235af63de378a26436a18d7fb0c39e41f
Reviewed-on: https://go-review.googlesource.com/c/go/+/648536
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-04 10:53:05 -07:00
qmuntal
6839e71d82 internal/syscall/windows: use unsafe.Pointer instead of uintptr
Some functions accept a uintptr when they should accept an
unsafe.Pointer, else the compiler won't know that the pointer should
be kept alive across the call, potentially causing undefined behavior.

Fixes #73156 (potentially)

Change-Id: I29c847eb8ffbb785fabf217e9f3718d10cfb5047
Reviewed-on: https://go-review.googlesource.com/c/go/+/662855
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-04-04 10:40:19 -07:00
Keith Randall
7a427143b6 cmd/compile: stack allocate variable-sized makeslice
Instead of always allocating variable-sized "make" calls on the heap,
allocate a small, constant-sized array on the stack and use that array
as the backing store if it is big enough.

Requires the result of the "make" doesn't escape.

  if cap <= K {
      var arr [K]E
      slice = arr[:len:cap]
  } else {
      slice = makeslice(E, len, cap)
  }

Pretty conservatively for now, K = 32/sizeof(E). The slice header is
already 24 bytes, so wasting 32 bytes of stack if the requested size
is too big isn't that bad. Larger would waste more stack space but
maybe avoid more allocations.

This CL also requires the element type be pointer-free.  Maybe we
could relax that at some point, but it is hard. If the element type
has pointers we can get heap->stack pointers (in the case where the
requested size is too big and the slice is heap allocated).

Note that this only handles the case of makeslice called directly from
compiler-generated code. It does not handle slices built in the
runtime on behalf of the program (e.g. in growslice). Some of those
are currently handled by passing in a tmpBuf (e.g. concatstrings),
but we could probably do more.

Change-Id: I8378efad527cd00d25948a80b82a68d88fbd93a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/653856
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-04-04 10:36:58 -07:00
Alexander Musman
16a6b71f18 cmd/compile: improve store-to-load forwarding with compatible types
Improve the compiler's store-to-load forwarding optimization by relaxing the
type comparison condition. Instead of requiring exact type equality (CMPeq),
we now use copyCompatibleType which allows forwarding between compatible
types where safe.

Fix several size comparison bugs in the nested store patterns. Previously,
we were comparing the size of the outer store with the load type,
rather than comparing with the size of the actual store being forwarded
from.

Skip OpConvert in dead store elimination to help get rid of dead stores such
as zeroing slices. OpConvert, like OpInlMark, doesn't really use the memory.

This optimization is particularly beneficial for code that creates slices with
computed pointers, such as the runtime's heapBitsSlice function, where
intermediate calculations were previously causing the compiler to miss
store-to-load forwarding opportunities.

Local sweet run result on an x86_64 laptop:

                       │  Orig.res   │              Hopt.res              │
                       │   sec/op    │   sec/op     vs base               │
BiogoIgor-8               5.303 ± 1%    5.322 ± 1%       ~ (p=0.190 n=10)
BiogoKrishna-8            7.894 ± 1%    7.828 ± 2%       ~ (p=0.190 n=10)
BleveIndexBatch100-8      2.257 ± 1%    2.248 ± 2%       ~ (p=0.529 n=10)
EtcdPut-8                30.12m ± 1%   30.03m ± 1%       ~ (p=0.796 n=10)
EtcdSTM-8                127.1m ± 1%   126.2m ± 0%  -0.74% (p=0.023 n=10)
GoBuildKubelet-8          52.21 ± 0%    52.05 ± 1%       ~ (p=0.063 n=10)
GoBuildKubeletLink-8      4.342 ± 1%    4.305 ± 0%  -0.85% (p=0.000 n=10)
GoBuildIstioctl-8         43.33 ± 0%    43.24 ± 0%  -0.22% (p=0.015 n=10)
GoBuildIstioctlLink-8     4.604 ± 1%    4.598 ± 0%       ~ (p=0.063 n=10)
GoBuildFrontend-8         15.33 ± 0%    15.29 ± 0%       ~ (p=0.143 n=10)
GoBuildFrontendLink-8    740.0m ± 1%   737.7m ± 1%       ~ (p=0.912 n=10)
GopherLuaKNucleotide-8    9.590 ± 1%    9.656 ± 1%       ~ (p=0.165 n=10)
MarkdownRenderXHTML-8    96.97m ± 1%   97.26m ± 2%       ~ (p=0.105 n=10)
Tile38QueryLoad-8        335.9µ ± 1%   335.6µ ± 1%       ~ (p=0.481 n=10)
geomean                   1.336         1.333       -0.22%

Change-Id: I031552623e6d5a3b1b5be8325e6314706e45534f
Reviewed-on: https://go-review.googlesource.com/c/go/+/662075
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-04-04 08:25:47 -07:00
qiulaidongfeng
822031dffc sync: add WaitGroup.Go
Fixes #63796

Change-Id: I2a941275dd64ef858cbf02d31a759fdc5c082ceb
Reviewed-on: https://go-review.googlesource.com/c/go/+/662635
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-04 08:19:32 -07:00
qmuntal
d164776615 internal/poll: simplify execIO
execIO has multiple return paths and multiple places where error is
mangled. This CL simplifies the function by just having one return
path.

Some more tests have been added to ensure that the error handling
is done correctly.

Updates #19098.

Change-Id: Ida0b1e85d4d123914054306e5bef8da94408b91c
Reviewed-on: https://go-review.googlesource.com/c/go/+/662215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-04 08:09:07 -07:00
Michael Pratt
8969771cc3 runtime: add thread exit plus vgetrandom stress test
Add a regression test similar to the reproducer from #73141 to try to
help catch future issues with vgetrandom and thread exit. Though the
test isn't very precise, it just hammers thread exit.

When the test reproduces #73141, it simply crashes with a SIGSEGV and no
output or stack trace, which would be very unfortunate on a builder.
https://go.dev/issue/49165 tracks collecting core dumps from builders,
which would make this more tractable to debug.

For #73141.

Change-Id: I6a6a636c7d7b41e2729ff6ceb30fd7f979aa9978
Reviewed-on: https://go-review.googlesource.com/c/go/+/662636
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-04-04 06:37:49 -07:00
Mark Freeman
5eaeb7b455 go/types, types2: better error messages for invalid qualified identifiers
This change borrows code from CL 631356 by Emmanuel Odeke (thanks!).

Fixes #70549.

Change-Id: Id6f794ea2a95b4297999456f22c6e02890fce13b
Reviewed-on: https://go-review.googlesource.com/c/go/+/662775
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
2025-04-03 15:36:36 -07:00
thepudds
ab2926291b testing: clarify how B.Loop avoids optimizing away all the useful work
As discussed in #73137, we want to clarify the description of how
B.Loop avoids surprising optimizations, while also hinting that
the exact approach might change in the future.

Updates #73137

Change-Id: I8536540cd5d79804a47fba8cd6eec3821864309d
Reviewed-on: https://go-review.googlesource.com/c/go/+/662356
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-04-03 12:24:34 -07:00
qmuntal
ce94e916fe internal/syscall/windows: define NtQueryInformationFile buffer as unsafe.Pointer
The unsafe.Pointer -> uintptr conversion must happen when calling
syscall.Syscall, not when calling the auto-generated wrapper function,
else the Go compiler doesn't know that it has to keep the pointer alive.

This can cause undefined behavior and stack corruption.

Fixes #73135.
Fixes #73112 (potentially).
Fixes #73128 (potentially).

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race
Change-Id: Ib3ad8b99618d8997bfd0742c0e44aeda696856c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/662575
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Carlos Amedee <carlos@golang.org>
2025-04-03 12:20:27 -07:00
Aleksey Markin
9302a57134 cmd/link/internal/ld: introduce -funcalign=N option
This patch adds linker option -funcalign=N that allows to set alignment
for function entries.

This CL is based on vasiliy.leonenko@gmail.com's cl/615736.

For #72130

Change-Id: I57e5c9c4c71a989533643fda63a9a79c5c897dea
Reviewed-on: https://go-review.googlesource.com/c/go/+/660996
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-04-03 12:02:03 -07:00
Vasily Leonenko
5b36f61356 internal/bytealg: optimize Index/IndexString/IndexByte/IndexByteString on arm64
Introduce ABIInternal support for Index/IndexString/IndexByte/IndexByteString

goos: linux
goarch: arm64
pkg: bytes
                              │   base.txt    │                new.txt                │
                              │      B/s      │      B/s       vs base                │
IndexByte/10                     1.090Gi ± 0%    1.313Gi ± 0%  +20.51% (p=0.000 n=10)
IndexByte/32                     3.714Gi ± 0%    4.289Gi ± 0%  +15.47% (p=0.000 n=10)
IndexByte/4K                     22.92Gi ± 0%    23.01Gi ± 0%   +0.37% (p=0.000 n=10)
IndexByte/4M                     20.23Gi ± 0%    20.35Gi ± 0%   +0.60% (p=0.000 n=10)
IndexByte/64M                    23.82Gi ± 0%    23.81Gi ± 0%   -0.01% (p=0.002 n=10)
IndexBytePortable/10             788.5Mi ± 0%    788.5Mi ± 0%        ~ (p=0.722 n=10)
IndexBytePortable/32            1002.3Mi ± 0%   1002.3Mi ± 0%        ~ (p=0.137 n=10)
IndexBytePortable/4K             1.111Gi ± 0%    1.111Gi ± 0%        ~ (p=0.692 n=10)
IndexBytePortable/4M             1.116Gi ± 0%    1.116Gi ± 0%        ~ (p=0.158 n=10)
IndexBytePortable/64M            1.116Gi ± 0%    1.116Gi ± 0%   -0.01% (p=0.000 n=10)
IndexRune/10                     352.1Mi ± 0%    445.0Mi ± 0%  +26.38% (p=0.000 n=10)
IndexRune/32                     1.101Gi ± 0%    1.391Gi ± 0%  +26.43% (p=0.000 n=10)
IndexRune/4K                     21.07Gi ± 0%    21.25Gi ± 0%   +0.82% (p=0.000 n=10)
IndexRune/4M                     23.81Gi ± 0%    23.81Gi ± 0%        ~ (p=0.218 n=10)
IndexRune/64M                    23.81Gi ± 0%    23.81Gi ± 0%        ~ (p=0.271 n=10)
IndexRuneASCII/10                1.038Gi ± 0%    1.190Gi ± 1%  +14.63% (p=0.000 n=10)
IndexRuneASCII/32                3.643Gi ± 2%    4.203Gi ± 0%  +15.38% (p=0.000 n=10)
IndexRuneASCII/4K                22.90Gi ± 0%    22.98Gi ± 0%   +0.34% (p=0.000 n=10)
IndexRuneASCII/4M                23.81Gi ± 0%    23.81Gi ± 0%        ~ (p=0.108 n=10)
IndexRuneASCII/64M               23.82Gi ± 0%    23.81Gi ± 0%        ~ (p=0.105 n=10)
IndexRuneUnicode/Latin/10        404.4Mi ± 0%    493.7Mi ± 0%  +22.10% (p=0.000 n=10)
IndexRuneUnicode/Latin/32        1.261Gi ± 0%    1.543Gi ± 0%  +22.31% (p=0.000 n=10)
IndexRuneUnicode/Latin/4K        6.966Gi ± 0%    8.115Gi ± 0%  +16.50% (p=0.000 n=10)
IndexRuneUnicode/Latin/4M        6.599Gi ± 0%    7.576Gi ± 0%  +14.80% (p=0.000 n=10)
IndexRuneUnicode/Latin/64M       6.297Gi ± 0%    7.070Gi ± 2%  +12.28% (p=0.000 n=10)
IndexRuneUnicode/Cyrillic/10     385.9Mi ± 0%    440.1Mi ± 0%  +14.03% (p=0.000 n=10)
IndexRuneUnicode/Cyrillic/32     1.206Gi ± 0%    1.375Gi ± 0%  +14.05% (p=0.000 n=10)
IndexRuneUnicode/Cyrillic/4K     2.468Gi ± 0%    2.921Gi ± 0%  +18.37% (p=0.000 n=10)
IndexRuneUnicode/Cyrillic/4M     2.386Gi ± 0%    2.845Gi ± 0%  +19.23% (p=0.000 n=10)
IndexRuneUnicode/Cyrillic/64M    2.280Gi ± 0%    2.717Gi ± 0%  +19.14% (p=0.000 n=10)
IndexRuneUnicode/Han/10          307.1Mi ± 0%    331.5Mi ± 0%   +7.94% (p=0.000 n=10)
IndexRuneUnicode/Han/32          982.2Mi ± 0%   1060.2Mi ± 0%   +7.94% (p=0.000 n=10)
IndexRuneUnicode/Han/4K          4.986Gi ± 0%    5.957Gi ± 0%  +19.48% (p=0.000 n=10)
IndexRuneUnicode/Han/4M          3.822Gi ± 0%    4.198Gi ± 0%   +9.83% (p=0.000 n=10)
IndexRuneUnicode/Han/64M         3.765Gi ± 0%    4.140Gi ± 0%   +9.96% (p=0.000 n=10)
Index/10                         634.6Mi ± 0%    635.2Mi ± 0%   +0.09% (p=0.000 n=10)
Index/32                         375.3Mi ± 0%    385.1Mi ± 0%   +2.63% (p=0.000 n=10)
Index/4K                         754.8Mi ± 0%    755.2Mi ± 0%   +0.04% (p=0.001 n=10)
Index/4M                         746.5Mi ± 0%    746.3Mi ± 0%   -0.03% (p=0.000 n=10)
Index/64M                        746.5Mi ± 0%    746.3Mi ± 0%   -0.03% (p=0.000 n=10)
IndexEasy/10                     714.6Mi ± 0%    714.6Mi ± 0%   +0.00% (p=0.001 n=10)
IndexEasy/32                     1.221Gi ± 0%    1.524Gi ± 0%  +24.81% (p=0.000 n=10)
IndexEasy/4K                     21.06Gi ± 0%    21.47Gi ± 0%   +1.91% (p=0.000 n=10)
IndexEasy/4M                     20.23Gi ± 0%    20.24Gi ± 0%        ~ (p=0.684 n=10)
IndexEasy/64M                    13.07Gi ± 0%    12.58Gi ± 4%   -3.75% (p=0.000 n=10)
IndexHard1                       1.114Gi ± 0%    1.114Gi ± 0%        ~ (p=0.193 n=10)
IndexHard2                       1.111Gi ± 0%    1.112Gi ± 0%   +0.04% (p=0.001 n=10)
IndexHard3                       1.086Gi ± 0%    1.081Gi ± 0%   -0.37% (p=0.000 n=10)
IndexHard4                       607.9Mi ± 0%    607.9Mi ± 0%        ~ (p=0.136 n=10)
geomean                          2.536Gi         2.720Gi        +7.26%

Change-Id: I1fc246783ebb215882d7144d05dbe2433dc66751
Reviewed-on: https://go-review.googlesource.com/c/go/+/662415
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
2025-04-03 11:25:06 -07:00
Vasily Leonenko
f2e9076764 internal/bytealg: optimize Count/CountString on arm64
Introduce ABIInternal support for Count/CountString
Move <32 size block from function end to beginning as fastpath

goos: linux
goarch: arm64
pkg: strings
                   │   base.txt   │               new.txt                │
                   │     B/s      │     B/s       vs base                │
CountByte/10         672.5Mi ± 0%   692.9Mi ± 0%   +3.04% (p=0.000 n=10)
CountByte/32         3.592Gi ± 0%   3.970Gi ± 0%  +10.53% (p=0.000 n=10)
CountByte/4096       16.63Gi ± 0%   16.73Gi ± 0%   +0.64% (p=0.000 n=10)
CountByte/4194304    14.97Gi ± 2%   15.02Gi ± 1%        ~ (p=0.190 n=10)
CountByte/67108864   12.50Gi ± 0%   12.50Gi ± 0%        ~ (p=0.853 n=10)
geomean              5.931Gi        6.099Gi        +2.83%

Change-Id: I5af1be2b117d9fb8d570739637499923de62251c
Reviewed-on: https://go-review.googlesource.com/c/go/+/662395
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>
Commit-Queue: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-04-03 09:21:11 -07:00
0x2b3bfa0
9326d9d012 make.bat: fix GOROOT_BOOTSTRAP detection
Due to a flaw in the %GOROOT_BOOTSTRAP% detection logic, the last Go
executable found by `where go` was taking precedence over the first one.

In batch scripts, environment variable expansion happens when each line
of the script is read, not when it is executed. Thus, the check in the
loop for GOROOT_BOOTSTRAP being unset would always be true, even when
the variable had been set in a previous loop iteration.

See SET /? for more information.

Change-Id: I15ddcbe771a902acb47a1f07ba7f4cb8a311e0dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/653535
Auto-Submit: Carlos Amedee <carlos@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-03 08:45:30 -07:00
Alan Donovan
fd8f6cec21 api: move go1.25 to next/70250
My CL 645115 added the new entries in the wrong place,
prematurely creating the go1.25 file.

Also, add the missing release note.

Change-Id: Ib5b5ccfb42757a9ea9dc93e33b3e3ed8e8bd7d3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/662615
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2025-04-03 08:07:11 -07:00
Joel Sing
06f82af183 cmd/internal/obj/arm64: return a bit shift from movcon
Return the shift in bits from movcon, rather than returning an index.
This allows a number of multiplications to be removed, making the code
more readable. Scale down to an index only when encoding.

Change-Id: I1be91eb526ad95d389e2f8ce97212311551790df
Reviewed-on: https://go-review.googlesource.com/c/go/+/650939
Auto-Submit: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-03 06:00:28 -07:00
Joel Sing
4464a7d94f cmd/internal/obj/arm64: deduplicate con32class
Teach conclass how to handle 32 bit values and deduplicate the code
between con32class and conclass.

Change-Id: I9c5eea31d443fd4c2ce700c6ea21e1d0bef665b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/650938
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Joel Sing <joel@sing.id.au>
2025-04-03 05:20:09 -07:00
Joel Sing
c524db9ca8 cmd/internal/obj/arm64: simplify conclass
Reduce repetition by pulling some common conversions into variables.

Change-Id: I8c1cc806236b5ecdadf90f4507923718fa5de9b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/650937
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-03 04:37:34 -07:00
Michael Pratt
0b31e6d4cc runtime: cleanup M vgetrandom state before dropping P
When an M is destroyed, we put its vgetrandom state back on the shared
list for another M to reuse. This list is simply a slice, so appending
to the slice may allocate. Currently this operation is performed in
mdestroy, after the P is released, meaning allocation is not allowed.

More the cleanup earlier in mdestroy when allocation is still OK.

Also add //go:nowritebarrierrec to mdestroy since it runs without a P,
which would have caught this bug.

Fixes #73141.

Change-Id: I6a6a636c3fbf5c6eec09d07a260e39dbb4d2db12
Reviewed-on: https://go-review.googlesource.com/c/go/+/662455
Reviewed-by: Jason Donenfeld <Jason@zx2c4.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>
2025-04-03 01:25:08 -07:00
Julia Lapenko
13b1261175 cmd/compile/internal/devirtualize: do not select a zero-weight edge as the hottest one
When both a direct call and an interface call appear on the same line,
PGO devirtualization may make a suboptimal decision. In some cases,
the directly called function becomes a candidate for devirtualization
if no other relevant outgoing edges with non-zero weight exist for the
caller's IRNode in the WeightedCG. The edge to this candidate is
considered the hottest. Despite having zero weight, this edge still
causes the interface call to be devirtualized.

This CL prevents devirtualization when the weight of the hottest edge
is 0.

Fixes #72092

Change-Id: I06c0c5e080398d86f832e09244aceaa4aeb98721
Reviewed-on: https://go-review.googlesource.com/c/go/+/655475
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-02 16:39:13 -07:00
Sergey Slukin
116b82354c cmd/compile: changed variable name due to shadowing of package name min
Change-Id: I52e5de04d137238d6f6779edcc662f5c7433c61e
Reviewed-on: https://go-review.googlesource.com/c/go/+/660195
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-02 11:25:15 -07:00
khr@golang.org
144d4e5d5f runtime: simplify needzero logic
We always need to zero allocations with pointers in them. So we don't
need some of the mallocs to take a needzero argument.

Change-Id: Ideaa7b738873ba6a93addb5169791b42e2baad7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/660455
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-02 10:52:28 -07:00
qmuntal
83bbf47863 crypto/tls: use crypto/hkdf
For consistency, prefer crypto/hkdf over crypto/internal/fips140/hkdf.
Both should have the same behavior given the constrained use of HKDF
in TLS.

Change-Id: Ia982b9f7a6ea66537d748eb5ecae1ac1eade68a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/658217
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-04-02 08:50:53 -07:00
Alexander Musman
3033ef0016 cmd/compile: Remove unused 'NoInline' field from CallExpr stucture
Remove the 'NoInline' field from CallExpr stucture, as it's no longer
used after enabling of tail call inlining.

Change-Id: Ief3ada9938589e7a2f181582ef2758ebc4d03aad
Reviewed-on: https://go-review.googlesource.com/c/go/+/655816
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-04-02 05:55:35 -07:00
Alan Donovan
dceb77a336 cmd/vet: add waitgroup analyzer
+ relnote

Fixes #18022

Change-Id: I92d1939e9d9f16824655c6c909a5f58ed9500014
Reviewed-on: https://go-review.googlesource.com/c/go/+/661519
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Alan Donovan <adonovan@google.com>
2025-04-01 15:09:39 -07:00