]> Cypherpunks repositories - gostls13.git/log
gostls13.git
4 months agocmd/compile/internal/abi: fix ComputePadding
Derek Parker [Fri, 21 Mar 2025 19:43:32 +0000 (19:43 +0000)]
cmd/compile/internal/abi: fix ComputePadding

Fixes the ComputePadding calculation to take into account the padding
added for the current offset. This fixes an issue where padding can be
added incorrectly for certain structs.

Related: https://github.com/go-delve/delve/issues/3923

Same as https://go-review.googlesource.com/c/go/+/656736 just without
the brittle test.

Fixes #72053

Change-Id: I67f157a42f5fc5d3a54d0e9be03488aa44752bcb
GitHub-Last-Rev: fabed69a31258fa8c1806f88d1cbcc745c881148
GitHub-Pull-Request: golang/go#72997
Reviewed-on: https://go-review.googlesource.com/c/go/+/659698
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: 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>

4 months agocmd/link/internal/ld: change pe64 from int to bool
qmuntal [Wed, 19 Mar 2025 08:57:36 +0000 (09:57 +0100)]
cmd/link/internal/ld: change pe64 from int to bool

pe64 should be a bool, not a int. Probable a leftover from the
previous C implementation.

While here, us pe64 in more places.

Change-Id: Ie9871b39b64a7b9d317cb0700cb77a19ee23838d
Reviewed-on: https://go-review.googlesource.com/c/go/+/659115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
4 months agoruntime: deduplicate context call injection on Windows
qmuntal [Fri, 14 Mar 2025 10:56:20 +0000 (11:56 +0100)]
runtime: deduplicate context call injection on Windows

Injecting a call to a thread context is complex enough to warrant
a dedicated function so that we don't repeat the same code in multiple
places. Note that the unix sigctxt struct also follows the
same approach.

The behavior is unchanged, but the implementation semantics are now
clearer by using goarch.StackAlign instead of a mix of goarch.PtrSize,
goarch.StackAlign and hardcoded values.

While here, fix #68552.

Cq-Include-Trybots: luci.golang.try:gotip-windows-arm64
Change-Id: Ic29cd2bf322b520127fecccafd61577076945758
Reviewed-on: https://go-review.googlesource.com/c/go/+/657815
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
4 months agointernal/syscall/unix: add missing cgo_import_dynamics for AIX
Damien Neil [Thu, 20 Mar 2025 23:02:58 +0000 (16:02 -0700)]
internal/syscall/unix: add missing cgo_import_dynamics for AIX

Change-Id: Ief4c6dd8340e07556692d2bde2284a3b7afb2444
Reviewed-on: https://go-review.googlesource.com/c/go/+/659756
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agointernal/syscall/windows: set SYNCHRONIZE flag in Deleteat
Damien Neil [Thu, 20 Mar 2025 19:50:21 +0000 (12:50 -0700)]
internal/syscall/windows: set SYNCHRONIZE flag in Deleteat

Change-Id: Ice23659cf089b4f837d73b2db5b6eccd7562164e
Reviewed-on: https://go-review.googlesource.com/c/go/+/659616
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
4 months agoruntime: fix interactions between synctest, race detector, and timers
Damien Neil [Mon, 17 Mar 2025 20:48:50 +0000 (13:48 -0700)]
runtime: fix interactions between synctest, race detector, and timers

When an AfterFunc executes in a synctest bubble, there is a series of
happens-before relationships:

  1. The AfterFunc is created.
  2. The AfterFunc goroutine executes.
  3. The AfterFunc goroutine returns.
  4. A subsequent synctest.Wait call returns.

We were failing to correctly establish the happens-before relationship
between the AfterFunc goroutine and the AfterFunc itself being created.
When an AfterFunc executes, the G running the timer temporarily switches
to the timer heap's racectx. It then calls time.goFunc, which starts a
new goroutine to execute the timer. time.goFunc relies on the new goroutine
inheriting the racectx of the G running the timer.

Normal, non-synctest timers, execute with m.curg == nil, which causes
new goroutines to inherit the g0 racectx. We were running synctest
timers with m.curg set (to the G executing synctest.Run), so the new
AfterFunc goroutine was created using m.curg's racectx. This resulted
in us not properly establishing the happens-before relationship between
AfterFunc being called and the AfterFunc goroutine starting.

Fix this by setting m.curg to nil while executing timers.

As one additional fix, when waking a blocked bubble, wake the root
goroutine rather than a goroutine blocked in Wait if there is a
timer that can fire.

Fixes #72750

Change-Id: I2b2d6b0f17f64649409adc93c2603f720494af89
Reviewed-on: https://go-review.googlesource.com/c/go/+/658595
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 months agoRevert "cmd/compile/internal/abi: fix ComputePadding"
Cherry Mui [Fri, 21 Mar 2025 15:46:14 +0000 (08:46 -0700)]
Revert "cmd/compile/internal/abi: fix ComputePadding"

This reverts CL 656736.

Reason for revert: breaks many builders (all flavors of
linux-amd64 builders).

Change-Id: Ie7190d4078fada227391804c5cf10b9ce9cc9115
Reviewed-on: https://go-review.googlesource.com/c/go/+/659955
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
4 months agocmd/internal/obj/riscv: fix the encoding for REV8 and ORCB
Mark Ryan [Wed, 11 Dec 2024 17:09:32 +0000 (18:09 +0100)]
cmd/internal/obj/riscv: fix the encoding for REV8 and ORCB

The instructions are currently encoded and validated using an
iIIEncoding which is incorrect as these instructions do not
take an immediate operand.  Encode them instead using an
rIIEncoding as is done for the other two register argument bitmanip
instructions.

Change-Id: Ia4d9c6f6ebd2dfc381935ebc11afa8fc3664232b
Reviewed-on: https://go-review.googlesource.com/c/go/+/637317
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
4 months agoruntime/race: fix reversed conditional in test for fatal map access
Damien Neil [Thu, 20 Mar 2025 22:03:43 +0000 (15:03 -0700)]
runtime/race: fix reversed conditional in test for fatal map access

Change-Id: Icc4d90355d8af07fdec852b2adf720f7cfd1edd6
Reviewed-on: https://go-review.googlesource.com/c/go/+/659735
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agocmd/compile/internal/abi: fix ComputePadding
Derek Parker [Wed, 19 Mar 2025 01:54:41 +0000 (01:54 +0000)]
cmd/compile/internal/abi: fix ComputePadding

Fixes the ComputePadding calculation to take into account
the padding added for the current offset. This fixes an issue
where padding can be added incorrectly for certain structs.

Related: https://github.com/go-delve/delve/issues/3923

Fixes #72053

Change-Id: I277629799168c6b44bc9ed03df4345e0318064ce
GitHub-Last-Rev: 9478b29a137e20421ad348bb93a54406b1977008
GitHub-Pull-Request: golang/go#72805
Reviewed-on: https://go-review.googlesource.com/c/go/+/656736
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
4 months agoos: add Root.Rename
Damien Neil [Wed, 19 Mar 2025 18:15:06 +0000 (11:15 -0700)]
os: add Root.Rename

For #67002

Change-Id: Ifb1042bc5ceaeea64296763319b24634bbcb0bf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/659416
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>

4 months agoruntime/race: don't complain about unrun tests when fatal map access happens
Damien Neil [Thu, 20 Mar 2025 20:33:49 +0000 (13:33 -0700)]
runtime/race: don't complain about unrun tests when fatal map access happens

Fixes #72964

Change-Id: I42c6994fec3b21774bddd1d4d65dc832d9149446
Reviewed-on: https://go-review.googlesource.com/c/go/+/659697
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agostrings: don't assert on Replace's allocs for ASAN
Julien Cretel [Thu, 20 Mar 2025 20:33:46 +0000 (20:33 +0000)]
strings: don't assert on Replace's allocs for ASAN

CL 657935 caused failures on the ASAN builder.

Under ASAN, do not assert on the number of allocations incurred by Replace.

Fixes #72973

Change-Id: I61536be6def6f2489d2a026c943c6e232865b723
GitHub-Last-Rev: 4aee3c2560c9a6fa6ba7c1950acc2172a7cfffe4
GitHub-Pull-Request: golang/go#72975
Reviewed-on: https://go-review.googlesource.com/c/go/+/659696
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>

4 months agotesting: allow manual timer control in testing.B.Loop
Junyang Shao [Tue, 18 Mar 2025 21:13:23 +0000 (21:13 +0000)]
testing: allow manual timer control in testing.B.Loop

Fixes #72922

Change-Id: I56610d2d11d151a8f95b6434bbedbfcd5c11c317
Reviewed-on: https://go-review.googlesource.com/c/go/+/658975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 months agoos: skip atime checks in TestRootChtimes on plan9
Damien Neil [Thu, 20 Mar 2025 16:30:19 +0000 (09:30 -0700)]
os: skip atime checks in TestRootChtimes on plan9

Plan 9 doesn't permit setting arbitrary atimes.

Fixes #72957

Change-Id: Ia4e14c75ed7dcdefd4669c0c21884d5ead9ab2fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/659615
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agocmd/compile/internal/ssa: remove linkedBlocks and its uses
Mateusz Poliwczak [Thu, 20 Mar 2025 13:49:56 +0000 (14:49 +0100)]
cmd/compile/internal/ssa: remove linkedBlocks and its uses

The use of predFn/succFn is not needed since CL 22401.

Change-Id: Icc39190bb7b0e85541c75da2d564093d551751d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/659555
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
4 months agoall: use exec.Command.String in test logs
qmuntal [Thu, 20 Mar 2025 09:02:31 +0000 (10:02 +0100)]
all: use exec.Command.String in test logs

There is no need to manually construct a human-friendly string for
a exec.Command. The String method does that for us.

Change-Id: Iff1033478000bade9cbdc079f6143a7690374258
Reviewed-on: https://go-review.googlesource.com/c/go/+/659475
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agocmd/cgo/internal/testshared: log stdout when go command fails
qmuntal [Thu, 20 Mar 2025 08:41:28 +0000 (09:41 +0100)]
cmd/cgo/internal/testshared: log stdout when go command fails

Understanding a failure in the goCmd call is difficult because the
important information might be in the stdout instead of stderr.

Change-Id: Icf42974679103c69016129fe2ebb15d5a0a3b51a
Reviewed-on: https://go-review.googlesource.com/c/go/+/659456
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
4 months agocmd/go: fail go clean command when failed to find go cache directory
Max Neverov [Tue, 18 Mar 2025 20:02:03 +0000 (20:02 +0000)]
cmd/go: fail go clean command when failed to find go cache directory

Currently, if computing of the go cache directory fails it does not expose the error. Commands like go clean, exec, modindex that use go cache directory continue execution producing incorrect or no result. This patch adds an error to the return values such that it can be validated on call sites. It also introduces such validation in go clean -cache command to fail execution in case when error occurred.

Fixes #69997

Change-Id: I53fd1ec67f0a6bd8a367e785dcb145a673c084dc
GitHub-Last-Rev: e2063d10db7bb969bcbc8993761e3b38bb420938
GitHub-Pull-Request: golang/go#70392
Reviewed-on: https://go-review.googlesource.com/c/go/+/628596
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Matloob <matloob@golang.org>

4 months agonet/http/httputil: document ReverseProxy removal of response headers
Sean Liao [Mon, 17 Mar 2025 18:39:31 +0000 (18:39 +0000)]
net/http/httputil: document ReverseProxy removal of response headers

Fixes #30359

Change-Id: I5dfb2cd63c737959fd2f6a0dbf50ff8de18bb15d
Reviewed-on: https://go-review.googlesource.com/c/go/+/658535
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
4 months agostrings: speed up Replace
Julien Cretel [Wed, 19 Mar 2025 20:07:38 +0000 (20:07 +0000)]
strings: speed up Replace

Add benchmarks for Replace.

The length of parameter old does not change. Move the corresponding length
check outside the loop. Use range-over-int loops where possible.

Some benchmark results (no changes to allocations):

goos: darwin
goarch: amd64
pkg: strings
cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
                                 │     old      │                new                 │
                                 │    sec/op    │   sec/op     vs base               │
Replace/"hello"_"l"_"L"_0-8         6.102n ± 6%   6.139n ± 5%       ~ (p=0.644 n=20)
Replace/"hello"_"l"_"L"_-1-8        62.81n ± 1%   63.30n ± 1%       ~ (p=0.098 n=20)
Replace/"hello"_"x"_"X"_-1-8        12.19n ± 0%   12.49n ± 0%  +2.50% (p=0.000 n=20)
Replace/""_"x"_"X"_-1-8             12.20n ± 0%   12.51n ± 0%  +2.58% (p=0.000 n=20)
Replace/"radar"_"r"_"<r>"_-1-8      69.65n ± 0%   66.57n ± 0%  -4.43% (p=0.000 n=20)
Replace/""_""_"<>"_-1-8             39.54n ± 1%   35.84n ± 1%  -9.34% (p=0.000 n=20)
Replace/"banana"_"a"_"<>"_-1-8      79.95n ± 0%   79.21n ± 0%  -0.93% (p=0.000 n=20)
Replace/"banana"_"a"_"<>"_1-8       48.67n ± 1%   49.45n ± 0%  +1.60% (p=0.000 n=20)
Replace/"banana"_"a"_"<>"_1000-8    80.28n ± 1%   79.52n ± 0%  -0.95% (p=0.000 n=20)
Replace/"banana"_"an"_"<>"_-1-8     82.89n ± 1%   84.62n ± 1%  +2.09% (p=0.000 n=20)
Replace/"banana"_"ana"_"<>"_-1-8    56.45n ± 1%   57.41n ± 1%  +1.69% (p=0.000 n=20)
Replace/"banana"_""_"<>"_-1-8       114.5n ± 1%   104.8n ± 0%  -8.52% (p=0.000 n=20)
Replace/"banana"_""_"<>"_10-8       114.5n ± 0%   104.8n ± 0%  -8.43% (p=0.000 n=20)
Replace/"banana"_""_"<>"_6-8       104.00n ± 0%   95.43n ± 0%  -8.24% (p=0.000 n=20)
Replace/"banana"_""_"<>"_5-8        91.85n ± 1%   83.68n ± 1%  -8.89% (p=0.000 n=20)
Replace/"banana"_""_"<>"_1-8        43.73n ± 1%   40.17n ± 0%  -8.13% (p=0.000 n=20)
Replace/"banana"_"a"_"a"_-1-8       4.410n ± 0%   4.443n ± 0%  +0.76% (p=0.000 n=20)
Replace/"banana"_"a"_"a"_1-8        4.395n ± 0%   4.423n ± 1%  +0.64% (p=0.022 n=20)
Replace/"☺☻☹"_""_"<>"_-1-8          98.58n ± 0%   91.66n ± 0%  -7.02% (p=0.000 n=20)
geomean                             39.72n        38.59n       -2.83%

Change-Id: Ia0c7798b24d95d7c98b488a6d4ce7e78de76db9d
GitHub-Last-Rev: 644fe36dcbe46b6a22febea5fe2cd566572b879c
GitHub-Pull-Request: golang/go#72868
Reviewed-on: https://go-review.googlesource.com/c/go/+/657935
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agogo/parser: add *ast.BlockStmt depth test
Mateusz Poliwczak [Thu, 20 Mar 2025 08:12:17 +0000 (09:12 +0100)]
go/parser: add *ast.BlockStmt depth test

At first glance i have thought that we do not handle such case properly,
because parseBlockStmt and parseStmtList do not call call the
incNestLev. Fortunately parseStmt does, so it is detected properly.

As we don't have a test case directly for blockstmts only, i think it is
worth adding one.

Change-Id: If149b86fd90a7ee4a33c861070d1bafdd40e98ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/659455
Reviewed-by: Roland Shoemaker <roland@golang.org>
Commit-Queue: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

4 months agodoc: go 1.26 remove support for windows/arm
qiulaidongfeng [Sun, 16 Mar 2025 06:40:40 +0000 (14:40 +0800)]
doc: go 1.26 remove support for windows/arm

For #71671

Change-Id: I690aa24c0d9dd62749244c92d26a5a353f0d5c47
Reviewed-on: https://go-review.googlesource.com/c/go/+/658275
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
4 months agoos: don't wrap os.Getgroups error in tests
Kir Kolyshkin [Tue, 18 Mar 2025 23:33:22 +0000 (16:33 -0700)]
os: don't wrap os.Getgroups error in tests

The error returned is an os.PathError which already provides enough
context.

Change-Id: Ib9391c00afc56bca673b8086d5dc19cf9b99b285
Reviewed-on: https://go-review.googlesource.com/c/go/+/658957
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agocmd/compile/internal/ssagen: use an alias for math/bits.OnesCount
Joel Sing [Wed, 19 Mar 2025 13:09:52 +0000 (00:09 +1100)]
cmd/compile/internal/ssagen: use an alias for math/bits.OnesCount

Currently, only amd64 has an intrinsic for math/bits.OnesCount, which
generates the same code as math/bits.OnesCount64. Replace this with
an alias that maps math/bits.OnesCount to math/bits.OnesCount64 on
64 bit platforms.

Change-Id: Ifa12a2173a201aacd52c3c22b9a948be6e314405
Reviewed-on: https://go-review.googlesource.com/c/go/+/659215
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
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>

4 months agoos: fix typos in comments
Kir Kolyshkin [Tue, 18 Mar 2025 23:28:31 +0000 (16:28 -0700)]
os: fix typos in comments

 * peformed -> performed
 * reprots -> reports

Found when reviewing

Change-Id: I9474074199f6a610f40b4bcf798c6d77948f3d3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/658956
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

4 months agocrypto/tls: add missing RUnlock in ticketKeys
Edoardo Spadolini [Fri, 26 Jul 2024 14:06:55 +0000 (14:06 +0000)]
crypto/tls: add missing RUnlock in ticketKeys

If GetConfigForClient returns a tls.Config that has
SessionTicketsDisabled set, the TLS server handshake currently leaves
the Config's internal RWMutex read locked after calculating the
ticketKeys to use for the handshake.

Change-Id: I07e450a0d2edda9e80f51fc2c20af633aa271684
GitHub-Last-Rev: 693d7acf952e9478708fe4cd69788f3115e6fe23
GitHub-Pull-Request: golang/go#68607
Reviewed-on: https://go-review.googlesource.com/c/go/+/601335
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Roland Shoemaker <roland@golang.org>
4 months agonet/smtp: make test certificate FIPS 140-3 compliant
Filippo Valsorda [Tue, 18 Mar 2025 19:28:34 +0000 (20:28 +0100)]
net/smtp: make test certificate FIPS 140-3 compliant

The key was too small and was getting rejected by crypto/tls if running
tests in FIPS 140-3 mode.

Change-Id: I6a6a4656374b942aeeca55d5c0464c965db0f6de
Reviewed-on: https://go-review.googlesource.com/c/go/+/658935
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Auto-Submit: Filippo Valsorda <filippo@golang.org>

4 months agomisc/linkcheck: remove unused tool
Sean Liao [Wed, 19 Mar 2025 16:34:43 +0000 (16:34 +0000)]
misc/linkcheck: remove unused tool

Fixes #72953

Change-Id: I8a0c8da3f8309841147412a078bc82095a93c5b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/659275
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 months agoos: skip Root.Chtimes atime check on netbsd, truncate a/mtime on plan9
Damien Neil [Wed, 19 Mar 2025 23:37:16 +0000 (16:37 -0700)]
os: skip Root.Chtimes atime check on netbsd, truncate a/mtime on plan9

The NetBSD builder has noatime set on its filesystem.
Skip testing the atime on this builder.

Plan9 has second precision on its atime and mtimes.
Truncate the values passed to Chtimes.

For #72957

Change-Id: I963e2dd34075a9ba025e80641f0b675d5d912188
Reviewed-on: https://go-review.googlesource.com/c/go/+/659356
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
4 months agointernal/syscall/unix: fix number of params for unlinkat
Kir Kolyshkin [Wed, 19 Mar 2025 23:56:21 +0000 (16:56 -0700)]
internal/syscall/unix: fix number of params for unlinkat

This reverts the change to Unlinkat done in CL 659415, as it appears
to be wrong.

While at it, let's unify argument formatting for better readability
(and also so those parameters are easier to count).

Change-Id: I092105f85de107e0495afed3cd66c039343250f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/659357
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

4 months agointernal/syscall/unix: use correct number of params in unlinkat, fchownat
Damien Neil [Wed, 19 Mar 2025 20:13:51 +0000 (13:13 -0700)]
internal/syscall/unix: use correct number of params in unlinkat, fchownat

We were calling syscall6 with an incorrect parameter count, omitting
the flags parameter.

Change-Id: Ife606bd57c1e4b899c0340767e9197bbe0aa81a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/659415
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agoos: add Root.Readlink
Damien Neil [Tue, 18 Mar 2025 22:12:31 +0000 (15:12 -0700)]
os: add Root.Readlink

For #67002

Change-Id: I532a5ffc02c7457796540db54fa2f5ddad86e4b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/658995
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agoos: add Root.Lchown
Damien Neil [Fri, 14 Feb 2025 00:38:08 +0000 (16:38 -0800)]
os: add Root.Lchown

For #67002

Change-Id: I1bbf18838a1dd2281a2b6e56fc8a58ef70007adc
Reviewed-on: https://go-review.googlesource.com/c/go/+/649536
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agoruntime/race: detect when TestRace fails to run all tests, skip failures
Damien Neil [Tue, 18 Mar 2025 17:22:04 +0000 (10:22 -0700)]
runtime/race: detect when TestRace fails to run all tests, skip failures

TestRace runs a collection of tests, some of which are expected
to fail with data races. Make TestRace more robust at detecting
when the test run is cut short, such as when a test causes
an unhandled panic.

Skip TestRaceRangeFuncIterator, which contains an unhandled panic.
This test was causing all subsequent tests to not run.

Skip TestNoRaceRangeFuncIterator, which contains an unexpected data race.
This test was not running due to the above failure.

For #72925

Change-Id: Id662375cc498ea25ae308619709768588bf6a2f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/658875
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>

5 months agogo/types, types2: fix silly logic error in commonUnder
Robert Griesemer [Wed, 19 Mar 2025 16:38:51 +0000 (09:38 -0700)]
go/types, types2: fix silly logic error in commonUnder

Fixes #72936.

Change-Id: I79ed8d559c8565fa960b974f8c1207ee442f4c26
Reviewed-on: https://go-review.googlesource.com/c/go/+/659256
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: Robert Findley <rfindley@google.com>
5 months agonet/http/httputil: don't call WriteHeader after Hijack
Damien Neil [Wed, 19 Mar 2025 16:26:31 +0000 (09:26 -0700)]
net/http/httputil: don't call WriteHeader after Hijack

CL 637939 changed ReverseProxy to report errors encountered when
copying data on an hijacked connection. This is generally not useful,
and when using the default error handler results in WriteHeader
being called on a hijacked connection.

While this is harmless with standard net/http ResponseWriter
implementations, it can confuse middleware layers.

Fixes #72954

Change-Id: I21f3d3d515e114dc5c298d7dbc3796c505d3c82f
Reviewed-on: https://go-review.googlesource.com/c/go/+/659255
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agocmd/compile: remove implicit deref from len(p) where p is ptr-to-array
Keith Randall [Fri, 14 Mar 2025 20:19:18 +0000 (13:19 -0700)]
cmd/compile: remove implicit deref from len(p) where p is ptr-to-array

func f() *[4]int { return nil }
_ = len(f())

should not panic. We evaluate f, but there isn't a dereference
according to the spec (just "arg is evaluated").

Update #72844

Change-Id: Ia32cefc1b7aa091cd1c13016e015842b4d12d5b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/658096
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Keith Randall <khr@google.com>
5 months agoruntime: in asan mode unregister root regions on free
Florian Zenker [Wed, 19 Mar 2025 10:55:55 +0000 (10:55 +0000)]
runtime: in asan mode unregister root regions on free

CL 651755 introduced registration of root regions when allocating
memory. We also need to unregister that memory to avoid the leak
sanitizer accessing unmapped memory.

Issue #67833

Change-Id: I5d403d66e65a8a003492f4d79dad22d416fd8574
Reviewed-on: https://go-review.googlesource.com/c/go/+/659135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agocmd/internal/obj/riscv: prevent panics on bad branches
Mark Ryan [Wed, 11 Dec 2024 13:03:17 +0000 (14:03 +0100)]
cmd/internal/obj/riscv: prevent panics on bad branches

Syntactically incorrect branches, such as

BEQ X5, X6, $1
BEQ X5, X6, 31(X10)

cause the assembler to panic, which they shouldn't really do.  It's
better for the user to see a normal error, as reported for other
syntax errors in riscv64 assembly.  The panics also prevent us
from writing negative tests for these sorts of errors.

Here we fix the issue by ensuring we generate a normal error instead
of panicking when the user provides an invalid branch target.  We
also add a couple of negative tests.

Change-Id: I1da568999a75097484b61a01d418f5d4be3e04fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/637316
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
5 months agocmd/internal/obj/riscv: prevent duplicate error reports
Mark Ryan [Tue, 10 Dec 2024 16:02:26 +0000 (17:02 +0100)]
cmd/internal/obj/riscv: prevent duplicate error reports

The riscv64 Go assembler can output certain errors, ones produced by
instructionsForProg, multiple times.  These errors are guaranteed to
be output at least twice and can appear three or more times if a
rescan is needed to recompute branch addresses.  For example, the
syntactically incorrect instruction

MOV (X10), $1

will generate at least two identical errors

asm: 86076 (asm.s:21524) MOV (X10), $1: unsupported MOV
asm: 86076 (asm.s:21524) MOV (X10), $1: unsupported MOV
asm: assembly failed

In addition to confusing the user, these duplicate errors make it
difficult to write negative tests for certain types of instructions,
e.g., branches, whose duplicate errors are not always identical,
and so not ignored by endtoend_test.go.

We fix the issue by returning from preprocess if any errors have been
generated by the time we reach the end of the rescan loop. One
implication of this change is that validation errors will no longer
be reported if an error is generated earlier in the preprocess stage.
Negative test cases for validation errors are therefore moved to
their own file as the existing riscv64error.s file contains errors
generated by instructionsForProg that will now suppress the
validation errors.

Change-Id: Iffacdbefce28f44970dd5dda44990b822b8a23d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/637315
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
5 months agointernal/godebugs: fix changed version for winsymlink and winreadlinkvolume to 1.23
Jordan Liggitt [Wed, 19 Mar 2025 00:27:07 +0000 (20:27 -0400)]
internal/godebugs: fix changed version for winsymlink and winreadlinkvolume to 1.23

https://go.dev/doc/godebug#go-123 documents changes to winsymlink and
winreadlinkvolume in Go 1.23.

This fixes the registered "changed" minor version to Go 1.23,
so that defaults when building a Go 1.22 module are correct.

Fixes #72935

Change-Id: I5d5bf31ca04f9e95208fb0fdaad2232f9db653ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/659035
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

5 months agoos: add Root.Chtimes
Damien Neil [Tue, 11 Feb 2025 18:47:20 +0000 (10:47 -0800)]
os: add Root.Chtimes

For #67002

Change-Id: I9b10ac30f852052c85d6d21eb1752a9de5474346
Reviewed-on: https://go-review.googlesource.com/c/go/+/649515
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agodoc: document change in nil-ptr checking behavior
Keith Randall [Tue, 18 Mar 2025 21:04:26 +0000 (14:04 -0700)]
doc: document change in nil-ptr checking behavior

This could bite people during the 1.25 release, so make sure it
has good documentation in the release notes.

Update #72860

Change-Id: Ie9aaa219025a631e81ebc48461555c5fb898f43f
Reviewed-on: https://go-review.googlesource.com/c/go/+/658955
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
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>

5 months agobytes,strings: document Fields trimming of leading and trailing characters
Sean Liao [Mon, 17 Mar 2025 15:21:39 +0000 (15:21 +0000)]
bytes,strings: document Fields trimming of leading and trailing characters

Fixes #72841

Change-Id: I46875c61e3147c69da759bf4bf4f0539cbd4f437
Reviewed-on: https://go-review.googlesource.com/c/go/+/658218
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agocmd/compile/internal/amd64: disable FIPS 140-3 mode for TestGoAMD64v1
Filippo Valsorda [Tue, 18 Mar 2025 19:21:51 +0000 (20:21 +0100)]
cmd/compile/internal/amd64: disable FIPS 140-3 mode for TestGoAMD64v1

TestGoAMD64v1 modifies the binary, which will make the FIPS 140-3
integrity self-check fail. Disable FIPS 140-3 mode when running the
modified binary.

Change-Id: I6a6a46566a38f8c44f996f6e1155dac5f67c56e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/658915
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
5 months agonet/http/httputil: document ProxyRequest.SetURL limitations
Sean Liao [Mon, 17 Mar 2025 19:20:32 +0000 (19:20 +0000)]
net/http/httputil: document ProxyRequest.SetURL limitations

Fixes #50337

Change-Id: I898ff6352f46f0f9b540b053049c5116e2165827
Reviewed-on: https://go-review.googlesource.com/c/go/+/658536
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
5 months agocmd/go/internal/clean: add logging to help debug openbsd flakes
Michael Matloob [Tue, 18 Mar 2025 17:00:42 +0000 (13:00 -0400)]
cmd/go/internal/clean: add logging to help debug openbsd flakes

This change adds extra logging in the case where there's an error
removing all the files in the gomodcache using modfetch.RemoveAll.
It logs the names of the files found in GOMODCACHE as well as their
modes. The modes are included because they should all be writable by the
time we call robustio.RemoveAll.

For #68087

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

5 months agonet/http: add onClose hook to fake net listener
Damien Neil [Mon, 17 Mar 2025 22:43:47 +0000 (15:43 -0700)]
net/http: add onClose hook to fake net listener

Avoids a race condition: If we set an onClose hook on a conn
created by a listener, then setting the hook can race with
the connection closing.

Change-Id: Ibadead3abbe4335d41f1e2cf84f4696fe98166b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/658655
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Damien Neil <dneil@google.com>

5 months agoruntime, time: don't use monotonic clock inside synctest bubbles
Damien Neil [Wed, 12 Mar 2025 23:00:26 +0000 (16:00 -0700)]
runtime, time: don't use monotonic clock inside synctest bubbles

Don't include a monotonic time in time.Times created inside
a bubble, to avoid the confusion of different Times using
different monotonic clock epochs.

For #67434

goos: darwin
goarch: arm64
pkg: time
cpu: Apple M1 Pro
         │ /tmp/bench.0 │            /tmp/bench.1            │
         │    sec/op    │   sec/op     vs base               │
Since-10    18.42n ± 2%   18.68n ± 1%       ~ (p=0.101 n=10)
Until-10    18.28n ± 2%   18.46n ± 2%  +0.98% (p=0.009 n=10)
geomean     18.35n        18.57n       +1.20%

Change-Id: Iaf1b80d0a4df52139c5b80d4bde4410ef8a49f2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/657415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
5 months agoruntime: add function runtime.cgoSigtramp support on loong64 and enable cgo-traceback...
limeidan [Thu, 6 Mar 2025 02:25:01 +0000 (10:25 +0800)]
runtime: add function runtime.cgoSigtramp support on loong64 and enable cgo-traceback testcases

Change-Id: I82f6ebd5636bfa112ad3e25dd9b77d7778469a1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/604176
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
5 months agoruntime, runtime/cgo: use libc for sigaction syscalls when cgo is enabled on loong64
limeidan [Wed, 5 Mar 2025 07:07:07 +0000 (15:07 +0800)]
runtime, runtime/cgo: use libc for sigaction syscalls when cgo is enabled on loong64

This ensures that runtime's signal handlers pass through the TSAN and
MSAN libc interceptors and subsequent calls to the intercepted
sigaction function from C will correctly see them.

Change-Id: I243a70d9dcb6d95a65c8494d5f9f9f09a316c693
Reviewed-on: https://go-review.googlesource.com/c/go/+/654995
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agocrypto/tls: fix ECH compatibility
古大羊 [Mon, 10 Feb 2025 04:49:15 +0000 (12:49 +0800)]
crypto/tls: fix ECH compatibility

Previously, the code only checked supportedVersions[0] for TLS 1.3
However, Chromium-based
browsers may list TLS 1.3 at different positions, causing ECH failures.
This fix:
    Iterates through supportedVersions to accept connections as long as TLS 1.3 is present.
    Improves ECH compatibility, ensuring Chrome, Edge, and other browsers work properly.

Fixes #71642

Change-Id: I32f4219fb6654d5cc22c7f33497c6142c0acb4f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/648015
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
5 months agolog/slog: document Logger ignores Handler.Handle errors
Sean Liao [Mon, 17 Mar 2025 18:18:48 +0000 (18:18 +0000)]
log/slog: document Logger ignores Handler.Handle errors

Fixes #66579

Change-Id: Ie75378b087763c3e88303df3b3f8d7565003a92f
Reviewed-on: https://go-review.googlesource.com/c/go/+/658515
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
5 months agocrypto/internal/hpke: propagate hkdf error value
qmuntal [Mon, 17 Mar 2025 15:16:53 +0000 (16:16 +0100)]
crypto/internal/hpke: propagate hkdf error value

The hkdf operations done in hpke are not expected to fail given that
we control the inputs. However, propagating the error instead of
doesn't hurt and makes the code more robust to future changes.

Change-Id: I168854593a40f67e2cc275e0dedc3b24b8f1480e
Reviewed-on: https://go-review.googlesource.com/c/go/+/658475
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
5 months agocrypto/internal/hpke: use crypto/hkdf
qmuntal [Mon, 17 Mar 2025 10:43:32 +0000 (11:43 +0100)]
crypto/internal/hpke: use crypto/hkdf

The hpke package uses public-facing crypto packages except for hkdf,
which uses crypto/internal/hkdf. We already have a public hkdf package,
crypto/hkdf, so use it instead for consistency.

Change-Id: Icf6afde791234dfe24dbfba715c0891f32005ca2
Reviewed-on: https://go-review.googlesource.com/c/go/+/657556
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agocmd/go: point tidy errors to correct URL
Mohammed Al Sahaf [Fri, 6 Dec 2024 17:22:56 +0000 (20:22 +0300)]
cmd/go: point tidy errors to correct URL

The `go mod tidy` errors have been pointing to an older URL. This CL
fixes the URL by pointing to the correct URL: https://go.dev/ref/mod.

Fixes #49394

Change-Id: I707dda407ba032db8a55083998002a5ab72033e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/633421
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agointernal/buildcfg: expand spinbitmutex platforms
Rhys Hiltner [Fri, 14 Mar 2025 19:04:51 +0000 (12:04 -0700)]
internal/buildcfg: expand spinbitmutex platforms

Go 1.24 included the spinbitmutex GOEXPERIMENT for several popular
architectures, based on their native support an atomic primitive (8-bit
exchange) that aided its efficient implementation.

Move towards making the new mutex implementation permanent, so it fully
replaces the two previous (sema- and futex-based "tristate")
implementations.

For #68578

Change-Id: I888a73959df42eb0ec53875309c446675af8f09d
Reviewed-on: https://go-review.googlesource.com/c/go/+/658455
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
5 months agoreflect: document Method(ByName) w.r.t dead code elimination
Ilya Priven [Sat, 15 Mar 2025 22:58:18 +0000 (22:58 +0000)]
reflect: document Method(ByName) w.r.t dead code elimination

The behavior is described in src/cmd/link/internal/ld/deadcode.go
but is not otherwise documented. Since the usage of those functions
could have significant caveats (longer builds, larger binaries),
we are informing the user.

Change-Id: I87571dd14aa16d7aac59fe45dfc52cb7c5b956c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/658255
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agodoc/next: add release note for work package pattern
Michael Matloob [Mon, 17 Mar 2025 15:53:22 +0000 (11:53 -0400)]
doc/next: add release note for work package pattern

For #71294
Fixes #50745

Change-Id: Iff05e98ac860a1764d4c59572f9abc3ae8d9c5fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/658495
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
5 months agohtml/template: document comment stripping
Sean Liao [Sat, 15 Mar 2025 00:14:14 +0000 (00:14 +0000)]
html/template: document comment stripping

Fixes #28628

Change-Id: I8b68f55f25e62f747d7cc48a490fec7f426f53d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/658115
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agoruntime: skip TestCgoCallbackPprof on platforms with broken profiling
Michael Pratt [Mon, 17 Mar 2025 12:11:42 +0000 (12:11 +0000)]
runtime: skip TestCgoCallbackPprof on platforms with broken profiling

CL 658035 added TestCgoCallbackPprof, which is consistently failing on
solaris. runtime/pprof maintains a list of platforms where CPU profiling
does not work properly. Since this test requires CPU profiling, skip the
this test on those platforms.

For #72870.
Fixes #72876.

Change-Id: I6a6a636cbf6b16abcbba8771178fe1d001be9d9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/658415
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>
5 months agocmd/internal/obj/loong64: add {V,XV}NEG{B/H/W/V} instructions support
Xiaolin Zhao [Fri, 13 Dec 2024 09:20:38 +0000 (17:20 +0800)]
cmd/internal/obj/loong64: add {V,XV}NEG{B/H/W/V} instructions support

Go asm syntax:
 VNEG{B/H/W/V} VJ, VD
XVNEG{B/H/W/V} XJ, XD

Equivalent platform assembler syntax:
 vneg.{b/h/w/d} vd, vj
xvneg.{b/h/w/d} xd, xj

Change-Id: Ie0a82a434b0ffbcb77425a65b96eff56e030028c
Reviewed-on: https://go-review.googlesource.com/c/go/+/635935
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
5 months agodoc/go_mem: fix grammar issue
Julien Cretel [Sun, 16 Mar 2025 13:55:23 +0000 (13:55 +0000)]
doc/go_mem: fix grammar issue

In the passage about buffered channels, remove redundant words and match
the wording of the earlier passage about unbuffered channels.

Change-Id: I35d8a3bf4f176c3f69cf5e6a64595e5d1c23e3a1
GitHub-Last-Rev: 1c4c9390a174d1a66797a025e2fdb0bf56239f48
GitHub-Pull-Request: golang/go#72891
Reviewed-on: https://go-review.googlesource.com/c/go/+/657778
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>

5 months agocmd/compile: intrinsify math/bits.TrailingZeros on riscv64
Joel Sing [Sun, 23 Feb 2025 11:17:53 +0000 (22:17 +1100)]
cmd/compile: intrinsify math/bits.TrailingZeros on riscv64

For riscv64/rva22u64 and above, we can intrinsify math/bits.TrailingZeros
using the CTZ/CTZW machine instructions.

On a StarFive VisionFive 2 with GORISCV64=rva22u64:

                  │   ctz.b.1    │               ctz.b.2               │
                  │    sec/op    │   sec/op     vs base                │
TrailingZeros-4     25.500n ± 0%   8.052n ± 0%  -68.42% (p=0.000 n=10)
TrailingZeros8-4     14.76n ± 0%   10.74n ± 0%  -27.24% (p=0.000 n=10)
TrailingZeros16-4    26.84n ± 0%   10.74n ± 0%  -59.99% (p=0.000 n=10)
TrailingZeros32-4   25.500n ± 0%   8.052n ± 0%  -68.42% (p=0.000 n=10)
TrailingZeros64-4   25.500n ± 0%   8.052n ± 0%  -68.42% (p=0.000 n=10)
geomean              23.09n        9.035n       -60.88%

Change-Id: I71edf2b988acb7a68e797afda4ee66d7a57d587e
Reviewed-on: https://go-review.googlesource.com/c/go/+/652320
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
5 months agostrings: add FuzzReplace test
Jorropo [Fri, 14 Mar 2025 20:29:08 +0000 (21:29 +0100)]
strings: add FuzzReplace test

While reviewing CL 657935 I've notied there a
couple tricky reslices that depends on multiple
things being correct.

Might as well fuzz it.

Change-Id: Id78921bcb252e73a8a06e6deb4c920445a87d525
Reviewed-on: https://go-review.googlesource.com/c/go/+/658075
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agohtml/template: replace end-of-life link
cui fliter [Mon, 15 Jan 2024 06:52:10 +0000 (14:52 +0800)]
html/template: replace end-of-life link

Fix #65044

Change-Id: I5bf9c1cf2e9d3ae1e4bbb8f2653512c710db370b
Reviewed-on: https://go-review.googlesource.com/c/go/+/555815
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agoos: use slices.Clone
Tobias Klauser [Fri, 14 Mar 2025 13:07:45 +0000 (14:07 +0100)]
os: use slices.Clone

Change-Id: I5a3de1b2fe2ebbb6437df5e7cc55e0d8d69c9cd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/657915
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
5 months agoruntime: log profile when mutex profile test fails
Rhys Hiltner [Fri, 14 Mar 2025 20:47:54 +0000 (13:47 -0700)]
runtime: log profile when mutex profile test fails

For #70602

Change-Id: I3f723ebc17ef690d5be7f4f948c9dd1f890196fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/658095
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
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>
5 months agocmd/compile: combine negation and word sign extension on riscv64
Joel Sing [Wed, 12 Oct 2022 06:37:23 +0000 (17:37 +1100)]
cmd/compile: combine negation and word sign extension on riscv64

Use NEGW to produce a negated and sign extended word, rather than doing
the same via two instructions:

   neg     t0, t0
   sext.w  a0, t0

Becomes:

   negw    t0, t0

Change-Id: I824ab25001bd3304bdbd435e7b244fcc036ef212
Reviewed-on: https://go-review.googlesource.com/c/go/+/652319
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
5 months agocmd/compile/internal/ssa: remove double negation with addition on riscv64
Joel Sing [Sun, 23 Feb 2025 13:37:45 +0000 (00:37 +1100)]
cmd/compile/internal/ssa: remove double negation with addition on riscv64

On riscv64, subtraction from a constant is typically implemented as an
ADDI with the negative constant, followed by a negation. However this can
lead to multiple NEG/ADDI/NEG sequences that can be optimised out.

For example, runtime.(*_panic).nextDefer currently contains:

   lbu     t0, 0(t0)
   addi    t0, t0, -8
   neg     t0, t0
   addi    t0, t0, -7
   neg     t0, t0

Which is now optimised to:

   lbu     t0, 0(t0)
   addi    t0, t0, -1

Change-Id: Idf5815e6db2e3705cc4a4811ca9130a064ae3d80
Reviewed-on: https://go-review.googlesource.com/c/go/+/652318
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: David Chase <drchase@google.com>
5 months agotest/codegen: add a test for negation and conversion to int32
Joel Sing [Mon, 24 Feb 2025 12:24:42 +0000 (23:24 +1100)]
test/codegen: add a test for negation and conversion to int32

Codify the current code generation used on riscv64 in this case.

Change-Id: If4152e3652fc19d0aa28b79dba08abee2486d5ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/652317
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agotest/codegen: add riscv64 codegen for arithmetic tests
Joel Sing [Mon, 24 Feb 2025 12:08:46 +0000 (23:08 +1100)]
test/codegen: add riscv64 codegen for arithmetic tests

Codify the current riscv64 code generation for various subtract from
constant and addition/subtraction tests.

Change-Id: I54ad923280a0578a338bc4431fa5bdc0644c4729
Reviewed-on: https://go-review.googlesource.com/c/go/+/652316
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: David Chase <drchase@google.com>
5 months agotest/codegen: add riscv64/rva23u64 specifiers to existing tests
Joel Sing [Sun, 23 Feb 2025 11:31:35 +0000 (22:31 +1100)]
test/codegen: add riscv64/rva23u64 specifiers to existing tests

Tests that exist for riscv64/rva22u64 should also be applied to
riscv64/rva23u64.

Change-Id: Ia529fdf0ac55b8bcb3dcd24fa80efef2351f3842
Reviewed-on: https://go-review.googlesource.com/c/go/+/652315
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
5 months agointernal/runtime/atomic: add Xchg8 for s390x and wasm
Rhys Hiltner [Fri, 14 Mar 2025 16:36:06 +0000 (09:36 -0700)]
internal/runtime/atomic: add Xchg8 for s390x and wasm

This makes the single-byte atomic.Xchg8 operation available on all
GOARCHes, including those without direct / single-instruction support.

Fixes #69735

Change-Id: Icb6aff8f907257db81ea440dc4d29f96b3cff6c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/657936
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: 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>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

5 months agocmd/go: enable fuzz testing on OpenBSD
Maciej Żok [Tue, 30 May 2023 18:29:05 +0000 (18:29 +0000)]
cmd/go: enable fuzz testing on OpenBSD

This change provides support for -fuzz flag on OpenBSD. According to #46554 the flag was unsupported on some OSes due to lack of proper testing.

Fixes: #60491
Change-Id: I49835131d3ee23f6482583b518b9c5c224fc4efe
GitHub-Last-Rev: f697a3c0f2dc36cc3c96c0336281c5e2440f7a1a
GitHub-Pull-Request: golang/go#60520
Reviewed-on: https://go-review.googlesource.com/c/go/+/499335
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

5 months agodebug/elf: add riscv attributes definitions
Meng Zhuo [Thu, 13 Mar 2025 08:29:16 +0000 (16:29 +0800)]
debug/elf: add riscv attributes definitions

This CL adds `riscv.attributes` related ELF section header
type and program header type according to
[RISC-V ELF Specification](https://github.com/riscv-non-isa/riscv-elf-psabi-doc/releases/download/v1.0/riscv-abi.pdf)

Also an riscv64/linux testcase binary built from:

```
gcc -march=rv64g -no-pie -o gcc-riscv64-linux-exec hello.c
strip gcc-riscv64-linux-exec
```

Fixes #72843

Change-Id: I7710a0516f69141c0efaba71dd997f05b4c88421
Reviewed-on: https://go-review.googlesource.com/c/go/+/657515
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agotime: optimize quote using byte(c) for ASCII
1911860538 [Thu, 13 Mar 2025 11:57:51 +0000 (11:57 +0000)]
time: optimize quote using byte(c) for ASCII

Since c < runeSelf && c >= ' ' (i.e., 32 <= c < 128), using buf = append(buf, byte(c)) instead of buf = append(buf, string(c)...) is a better choice, as it provides better performance.

Change-Id: Ic0ab25c71634a1814267f4d85be2ebd8a3d44676
GitHub-Last-Rev: 5445b547712bbfc77a5c17d76194291c22eb4a05
GitHub-Pull-Request: golang/go#72820
Reviewed-on: https://go-review.googlesource.com/c/go/+/657055
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

5 months agotest/codegen: tighten the TrailingZeros64 test on 386
Joel Sing [Wed, 26 Feb 2025 10:03:15 +0000 (21:03 +1100)]
test/codegen: tighten the TrailingZeros64 test on 386

Make the TrailingZeros64 code generation check more specific for 386.
Just checking for BSFL will match both the generic 64 bit decomposition
and the custom 386 lowering.

Change-Id: I62076f1889af0ef1f29704cba01ab419cae0c6e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/656996
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>
Reviewed-by: Keith Randall <khr@golang.org>
5 months agoruntime: only set isExtraInC if there are no Go frames left
Michael Pratt [Fri, 14 Mar 2025 14:50:25 +0000 (10:50 -0400)]
runtime: only set isExtraInC if there are no Go frames left

mp.isExtraInC is intended to indicate that this M has no Go frames at
all; it is entirely executing in C.

If there was a cgocallback to Go and then a cgocall to C, such that the
leaf frames are C, that is fine. e.g., traceback can handle this fine
with SetCgoTraceback (or by simply skipping the C frames).

However, we currently mismanage isExtraInC, unconditionally setting it
on return from cgocallback. This means that if there are two levels of
cgocallback, we end up running Go code with isExtraInC set.

1. C-created thread calls into Go function 1 (via cgocallback).
2. Go function 1 calls into C function 1 (via cgocall).
3. C function 1 calls into Go function 2 (via cgocallback).
4. Go function 2 returns back to C function 1 (returning via the remainder of cgocallback).
5. C function 1 returns back to Go function 1 (returning via the remainder of cgocall).
6. Go function 1 is now running with mp.isExtraInC == true.

The fix is simple; only set isExtraInC on return from cgocallback if
there are no more Go frames. There can't be more Go frames unless there
is an active cgocall out of the Go frames.

Fixes #72870.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Change-Id: I6a6a636c4e7ba75a29639d7036c5af3738033467
Reviewed-on: https://go-review.googlesource.com/c/go/+/658035
Reviewed-by: Cherry Mui <cherryyz@google.com>
Commit-Queue: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agoencoding/asn1: make sure implicit fields roundtrip
Roland Shoemaker [Mon, 3 Mar 2025 17:04:35 +0000 (09:04 -0800)]
encoding/asn1: make sure implicit fields roundtrip

Make sure Marshal and Unmarshal support the same field tags for implicit
encoding choices. In particular this adds support for Unmarshalling
implicitly tagged GeneralizedTime fields. Also add tests and update the
docs.

Fixes #72078

Change-Id: I21465ee4bcd73a7db0d0c36b2df53cabfc480185
Reviewed-on: https://go-review.googlesource.com/c/go/+/654275
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agocmd/compile: don't move nilCheck operations during tighten
Keith Randall [Thu, 13 Mar 2025 23:15:15 +0000 (16:15 -0700)]
cmd/compile: don't move nilCheck operations during tighten

Nil checks need to stay in their original blocks. They cannot
be moved to a following conditionally-executed block.

Fixes #72860

Change-Id: Ic2d66cdf030357d91f8a716a004152ba4c016f77
Reviewed-on: https://go-review.googlesource.com/c/go/+/657715
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: 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>
5 months agocmd/internal/obj/loong64: add {V,XV}{FSQRT/FRECIP/FRSQRT}.{S/D} instructions support
Xiaolin Zhao [Mon, 16 Dec 2024 02:53:00 +0000 (10:53 +0800)]
cmd/internal/obj/loong64: add {V,XV}{FSQRT/FRECIP/FRSQRT}.{S/D} instructions support

Go asm syntax:
 V{FSQRT/FRECIP/FRSQRT}{F/D} VJ, VD
XV{FSQRT/FRECIP/FRSQRT}{F/D} XJ, XD

Equivalent platform assembler syntax:
 v{fsqrt/frecip/frsqrt}.{s/d} vd, vj
xv{fsqrt/frecip/frsqrt}.{s/d} xd, xj

Change-Id: I3fdbe3193659d7532164451b087ccf725053172f
Reviewed-on: https://go-review.googlesource.com/c/go/+/636395
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
5 months agocrypto/x509: change how we retrieve chains on darwin
Roland Shoemaker [Tue, 4 Mar 2025 00:27:36 +0000 (16:27 -0800)]
crypto/x509: change how we retrieve chains on darwin

Instead of using the deprecated SecTrustGetCertificateAtIndex and
SecTrustGetCertificateCount method, use the SecTrustCopyCertificateChain
method.

This method require macOS 12+, which will be the minimum supported
version in 1.25.

Change-Id: I9a5ef75431cdb84f1cbe4eee47e6e9e2da4dea03
Reviewed-on: https://go-review.googlesource.com/c/go/+/654376
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
5 months agocrypto/x509,ecoding/asn1: better handling of weird encodings
Roland Shoemaker [Fri, 21 Feb 2025 01:05:04 +0000 (17:05 -0800)]
crypto/x509,ecoding/asn1: better handling of weird encodings

For various cursed reasons we need to support the BMPString and
T61String ASN.1 string encodings. These types use the defunct UCS-2 and
T.61 character encodings respectively.

This change rejects some characters when decoding BMPStrings which are
not valid in UCS-2, and properly parses T61Strings instead of treating
them as plain UTF-8.

While still not perfect, this matches the behavior of most other
implementations, particularly BoringSSL. Ideally we'd just remove
support for these ASN.1 types (particularly in crypto/x509, where we
don't actually expose any API), but doing so is likely to break some
deploy certificates which unfortunately still use these types in DNs,
despite them being deprecated since 1999/2002.

Fixes #71862

Change-Id: Ib8f392656a35171e48eaf71a200be6d7605b2f02
Reviewed-on: https://go-review.googlesource.com/c/go/+/651275
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
5 months agocrypto/tls/internal/fips140tls: use crypto/fips140
qmuntal [Fri, 10 Jan 2025 12:38:35 +0000 (13:38 +0100)]
crypto/tls/internal/fips140tls: use crypto/fips140

There is no need for fips140tls to depend on an internal package, it
can use crypto/fips140 directly.

Both approaches are equivalent, but using crypto/fips140 makes us
exercise a public API and sets precedence.

Change-Id: I668e80ee62b711bc60821cee3a54232a33295ee1
Reviewed-on: https://go-review.googlesource.com/c/go/+/642035
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
5 months agocrypto/tls: relax native FIPS 140-3 mode
Filippo Valsorda [Wed, 19 Feb 2025 11:29:31 +0000 (12:29 +0100)]
crypto/tls: relax native FIPS 140-3 mode

We are going to stick to BoringSSL's policy for Go+BoringCrypto, but
when using the native FIPS 140-3 module we can allow Ed25519, ML-KEM,
and P-521.

NIST SP 800-52r2 is stricter, but it only applies to some entities, so
they can restrict the profile with Config.

Fixes #71757

Change-Id: I6a6a4656eb02e56d079f0a22f98212275a40a679
Reviewed-on: https://go-review.googlesource.com/c/go/+/650576
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: David Chase <drchase@google.com>
5 months agocrypto/tls: clean up supported/default/allowed parameters
Filippo Valsorda [Wed, 19 Feb 2025 11:29:31 +0000 (12:29 +0100)]
crypto/tls: clean up supported/default/allowed parameters

Cleaned up a lot of the plumbing to make it consistently follow this
logic: clone the preference order; filter by user preference; filter by
FIPS policy. There should be no behavior changes.

Updates #71757

Change-Id: I6a6a4656eb02e56d079f0a22f98212275a400000
Reviewed-on: https://go-review.googlesource.com/c/go/+/657096
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
5 months agocmd/go: permit additional cflags when compiling
Holger Hans Peter Freyther [Sun, 9 Jul 2023 14:24:12 +0000 (22:24 +0800)]
cmd/go: permit additional cflags when compiling

In CL 475375 the Go command started to generate the "preferlinkext"
token file for "strange/dangerous" compiler flags. This serves as a hint
to the Go linker whether to call the external linker or not.

Permit compiler flag used by the hermetic_cc_toolchain bzlmod.

As a side effect, it also allows these flags to appear
in #cgo directives in source code. We don't know of any cases
where that is actually useful, but it appears to be harmless
and simplifies the implementation of the internal linking change.

Fixes #72842

Change-Id: Ic6de29b535a4e2c0720f383567ea6b3c7ca4f541
Reviewed-on: https://go-review.googlesource.com/c/go/+/657575
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
5 months agocrypto/tls: add ConnectionState.CurveID
Filippo Valsorda [Thu, 27 Feb 2025 13:01:13 +0000 (14:01 +0100)]
crypto/tls: add ConnectionState.CurveID

This required adding a new field to SessionState for TLS 1.0–1.2, since
the key exchange is not repeated on resumption. The additional field is
unfortunately not backwards compatible because current Go versions check
that the encoding has no extra data at the end, but will cause
cross-version tickets to be ignored. Relaxed that so we can add fields
in a backwards compatible way the next time.

For the cipher suite, we check that the session's is still acceptable
per the Config. That would arguably make sense here, too: if a Config
for example requires PQ, we should reject resumptions of connections
that didn't use PQ. However, that only applies to pre-TLS 1.3
connections, since in TLS 1.3 we always do a fresh key exchange on
resumption. Since PQ is the only main differentiator between key
exchanges (aside from off-by-default non-PFS RSA, which are controlled
by the cipher suite in TLS 1.0–1.2) and it's PQ-only, we can skip that
check.

Fixes #67516

Change-Id: I6a6a465681a6292edf66c7b8df8f4aba4171a76b
Reviewed-on: https://go-review.googlesource.com/c/go/+/653315
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
5 months agocrypto/tls: allow P-521 in FIPS 140-3 mode and Go+BoringCrypto
Filippo Valsorda [Wed, 12 Mar 2025 15:36:08 +0000 (16:36 +0100)]
crypto/tls: allow P-521 in FIPS 140-3 mode and Go+BoringCrypto

Partially reverts CL 587296, restoring the Go+BoringCrypto 1.23 behavior
in terms of supported curves.

Updates #71757

Change-Id: I6a6a465651a8407056fd0fae091d10a945b37997
Reviewed-on: https://go-review.googlesource.com/c/go/+/657095
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>

5 months agodoc/next: add release note for new toolchain line behavior
Michael Matloob [Wed, 12 Mar 2025 19:14:44 +0000 (15:14 -0400)]
doc/next: add release note for new toolchain line behavior

The go command will now no longer update the toolchain line implicitly
to the local toolchain version when updating the go line. Document that
in a release note.

For #65847

Change-Id: I4e970d881a43c22292fe9fa65a9835d0214ef7bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/657178
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agocmd/go/internal/load,cmd/link/internal/ld: use objabi.LookupPkgSpecial(pkg).Runtime
Jes Cok [Wed, 12 Mar 2025 15:46:37 +0000 (15:46 +0000)]
cmd/go/internal/load,cmd/link/internal/ld: use objabi.LookupPkgSpecial(pkg).Runtime

As suggested by Michael in CL 655515.

Change-Id: Idf0b879287bd777d03443aebc7351fcb0d724885
GitHub-Last-Rev: 58eda020f5310f873674f56903facec4f212d6c0
GitHub-Pull-Request: golang/go#72806
Reviewed-on: https://go-review.googlesource.com/c/go/+/656856
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

5 months agosyscall: use testing.T.Context
Tobias Klauser [Wed, 12 Mar 2025 09:59:10 +0000 (10:59 +0100)]
syscall: use testing.T.Context

Change-Id: I62763878d51598bf1ae0a4e75441e1d3a4b86aa3
Reviewed-on: https://go-review.googlesource.com/c/go/+/656955
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agotest/codegen: remove plan9/amd64 specific array zeroing/copying tests
Joel Sing [Wed, 12 Mar 2025 12:11:30 +0000 (23:11 +1100)]
test/codegen: remove plan9/amd64 specific array zeroing/copying tests

The compiler previously avoided the use of MOVUPS on plan9/amd64. This
was changed in CL 655875, however the codegen tests were not updated
and now fail (seemingly the full codegen tests do not run anywhere,
not even on the longtest builders).

Change-Id: I388b60e7b0911048d4949c5029347f9801c018a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/656997
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@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Keith Randall <khr@google.com>

5 months agocmd/internal/dwarf: always use AT_ranges for scopes with DWARF 5
Than McIntosh [Wed, 12 Mar 2025 18:08:21 +0000 (14:08 -0400)]
cmd/internal/dwarf: always use AT_ranges for scopes with DWARF 5

This patch extends the change in CL 657175 to apply the same abbrev
selection strategy to single-range lexical scopes that we're now using
for inlined routine bodies, when DWARF 5 is in effect. Ranges are more
compact and use fewer relocation than explicit hi/lo PC values, so we
might as well always use them.

Updates #26379.

Change-Id: Ieeaddf50e82acc4866010e29af32bcd1fb3b4f02
Reviewed-on: https://go-review.googlesource.com/c/go/+/657177
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
5 months agodoc/next: add tentative DWARF 5 release note fragment
Than McIntosh [Wed, 12 Mar 2025 17:27:25 +0000 (13:27 -0400)]
doc/next: add tentative DWARF 5 release note fragment

Add a small fragment describing the move to DWARF 5 for this release,
along with the name of the GOEXPERIMENT.

Updates #26379.

Change-Id: I3a30a71436133e2e0a5edf1ba0db84b9cc17cc5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/657176
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
5 months agocmd/link: only check PIE size difference when the linkmode is the same
Joel Sing [Wed, 12 Mar 2025 13:39:27 +0000 (00:39 +1100)]
cmd/link: only check PIE size difference when the linkmode is the same

Currently we check the size difference between non-PIE and PIE binaries
without specifying a linkmode (and that is presumed to be internal).
However, on some platforms (like openbsd/arm64), the use of
-buildmode=pie results in external linking. Ensure that we only test
internally linked non-PIE against internally linked PIE and externally
linked non-PIE against externally linked PIE, avoiding unexpected
differences.

Fixes #72818

Change-Id: I7e1da0976a4b5de387a59d0d6c04f58498a8eca0
Reviewed-on: https://go-review.googlesource.com/c/go/+/657035
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@golang.org>
5 months agocmd/compile: simplify bounded shift on loong64
Xiaolin Zhao [Sat, 16 Nov 2024 08:27:20 +0000 (16:27 +0800)]
cmd/compile: simplify bounded shift on loong64

Use the shiftIsBounded function to generate more efficient shift instructions.
This change also optimize shift ops when the shift value is v&63 and v&31.

goos: linux
goarch: loong64
pkg: math/bits
cpu: Loongson-3A6000-HV @ 2500.00MHz
                |  CL 627855   |               this CL                |
                |    sec/op    |    sec/op     vs base                |
LeadingZeros      1.1005n ± 0%   0.8425n ± 1%  -23.44% (p=0.000 n=10)
LeadingZeros8      1.502n ± 0%    1.501n ± 0%   -0.07% (p=0.001 n=10)
LeadingZeros16     1.502n ± 0%    1.501n ± 0%   -0.07% (p=0.000 n=10)
LeadingZeros32    0.9511n ± 0%   0.8050n ± 0%  -15.36% (p=0.000 n=10)
LeadingZeros64    1.1195n ± 0%   0.8423n ± 0%  -24.76% (p=0.000 n=10)
TrailingZeros     0.8086n ± 0%   0.8005n ± 0%   -1.00% (p=0.000 n=10)
TrailingZeros8     1.031n ± 1%    1.035n ± 1%        ~ (p=0.136 n=10)
TrailingZeros16   0.8114n ± 0%   0.8254n ± 1%   +1.73% (p=0.000 n=10)
TrailingZeros32   0.8090n ± 0%   0.8005n ± 0%   -1.05% (p=0.000 n=10)
TrailingZeros64   0.8089n ± 1%   0.8005n ± 0%   -1.04% (p=0.000 n=10)
OnesCount         0.8677n ± 0%   1.2010n ± 0%  +38.41% (p=0.000 n=10)
OnesCount8        0.8009n ± 0%   0.8004n ± 0%   -0.06% (p=0.000 n=10)
OnesCount16       0.9344n ± 0%   1.2010n ± 0%  +28.53% (p=0.000 n=10)
OnesCount32       0.8677n ± 0%   1.2010n ± 0%  +38.41% (p=0.000 n=10)
OnesCount64       1.2010n ± 0%   0.8671n ± 0%  -27.80% (p=0.000 n=10)
RotateLeft        0.8009n ± 0%   0.6671n ± 0%  -16.71% (p=0.000 n=10)
RotateLeft8        1.202n ± 0%    1.327n ± 0%  +10.40% (p=0.000 n=10)
RotateLeft16      0.8036n ± 0%   0.8218n ± 0%   +2.26% (p=0.000 n=10)
RotateLeft32      0.6674n ± 0%   0.8004n ± 0%  +19.94% (p=0.000 n=10)
RotateLeft64      0.6674n ± 0%   0.8004n ± 0%  +19.94% (p=0.000 n=10)
Reverse           0.4067n ± 1%   0.4122n ± 1%   +1.38% (p=0.001 n=10)
Reverse8          0.8009n ± 0%   0.8004n ± 0%   -0.06% (p=0.000 n=10)
Reverse16         0.8009n ± 0%   0.8005n ± 0%   -0.05% (p=0.000 n=10)
Reverse32         0.8009n ± 0%   0.8004n ± 0%   -0.06% (p=0.001 n=10)
Reverse64         0.8009n ± 0%   0.8004n ± 0%   -0.06% (p=0.008 n=10)
ReverseBytes      0.4057n ± 1%   0.4133n ± 1%   +1.90% (p=0.000 n=10)
ReverseBytes16    0.8009n ± 0%   0.8004n ± 0%   -0.07% (p=0.000 n=10)
ReverseBytes32    0.8009n ± 0%   0.8005n ± 0%   -0.05% (p=0.000 n=10)
ReverseBytes64    0.8009n ± 0%   0.8004n ± 0%   -0.06% (p=0.000 n=10)
Add                1.201n ± 0%    1.201n ± 0%        ~ (p=1.000 n=10)
Add32              1.201n ± 0%    1.201n ± 0%        ~ (p=0.474 n=10)
Add64              1.201n ± 0%    1.201n ± 0%        ~ (p=1.000 n=10)
Add64multiple      1.832n ± 0%    1.828n ± 0%   -0.22% (p=0.001 n=10)
Sub                1.201n ± 0%    1.201n ± 0%        ~ (p=1.000 n=10)
Sub32              1.602n ± 0%    1.601n ± 0%   -0.06% (p=0.000 n=10)
Sub64              1.201n ± 0%    1.201n ± 0%        ~ (p=0.474 n=10)
Sub64multiple      2.402n ± 0%    2.400n ± 0%   -0.10% (p=0.000 n=10)
Mul               0.8009n ± 0%   0.8004n ± 0%   -0.06% (p=0.000 n=10)
Mul32             0.8009n ± 0%   0.8004n ± 0%   -0.06% (p=0.000 n=10)
Mul64             0.8008n ± 0%   0.8004n ± 0%   -0.05% (p=0.000 n=10)
Div                9.083n ± 0%    7.638n ± 0%  -15.91% (p=0.000 n=10)
Div32              4.011n ± 0%    4.009n ± 0%   -0.05% (p=0.000 n=10)
Div64              9.711n ± 0%    8.204n ± 0%  -15.51% (p=0.000 n=10)
geomean            1.083n         1.078n        -0.40%

goos: linux
goarch: loong64
pkg: math/bits
cpu: Loongson-3A5000 @ 2500.00MHz
                |  CL 627855   |               this CL                |
                |    sec/op    |    sec/op     vs base                |
LeadingZeros       1.341n ± 4%    1.331n ± 2%   -0.71% (p=0.008 n=10)
LeadingZeros8      1.781n ± 0%    1.766n ± 1%   -0.84% (p=0.011 n=10)
LeadingZeros16     1.782n ± 0%    1.767n ± 0%   -0.79% (p=0.001 n=10)
LeadingZeros32     1.341n ± 1%    1.333n ± 0%   -0.52% (p=0.001 n=10)
LeadingZeros64     1.338n ± 0%    1.333n ± 0%   -0.37% (p=0.008 n=10)
TrailingZeros     0.9025n ± 0%   0.8077n ± 0%  -10.50% (p=0.000 n=10)
TrailingZeros8     1.056n ± 0%    1.089n ± 1%   +3.17% (p=0.001 n=10)
TrailingZeros16    1.101n ± 0%    1.102n ± 0%   +0.09% (p=0.011 n=10)
TrailingZeros32   0.9024n ± 1%   0.8083n ± 0%  -10.43% (p=0.000 n=10)
TrailingZeros64   0.9028n ± 1%   0.8087n ± 0%  -10.43% (p=0.000 n=10)
OnesCount          1.482n ± 1%    1.302n ± 0%  -12.15% (p=0.000 n=10)
OnesCount8         1.206n ± 0%    1.207n ± 2%   +0.12% (p=0.000 n=10)
OnesCount16        1.534n ± 0%    1.402n ± 0%   -8.58% (p=0.000 n=10)
OnesCount32        1.531n ± 1%    1.302n ± 0%  -14.99% (p=0.000 n=10)
OnesCount64        1.302n ± 0%    1.538n ± 1%  +18.16% (p=0.000 n=10)
RotateLeft        0.8083n ± 0%   0.8087n ± 1%        ~ (p=0.579 n=10)
RotateLeft8        1.310n ± 0%    1.323n ± 0%   +0.95% (p=0.001 n=10)
RotateLeft16       1.149n ± 0%    1.165n ± 1%   +1.35% (p=0.001 n=10)
RotateLeft32      0.8093n ± 0%   0.8105n ± 0%        ~ (p=0.393 n=10)
RotateLeft64      0.8088n ± 0%   0.8090n ± 0%        ~ (p=0.739 n=10)
Reverse           0.5109n ± 0%   0.5172n ± 1%   +1.25% (p=0.000 n=10)
Reverse8          0.8010n ± 0%   0.8011n ± 0%   +0.01% (p=0.000 n=10)
Reverse16         0.8010n ± 0%   0.8011n ± 0%   +0.01% (p=0.002 n=10)
Reverse32         0.8010n ± 0%   0.8011n ± 0%   +0.01% (p=0.000 n=10)
Reverse64         0.8010n ± 0%   0.8011n ± 0%   +0.01% (p=0.005 n=10)
ReverseBytes      0.5122n ± 2%   0.5182n ± 1%        ~ (p=0.060 n=10)
ReverseBytes16    0.8010n ± 0%   0.8011n ± 0%   +0.01% (p=0.005 n=10)
ReverseBytes32    0.8010n ± 0%   0.8011n ± 0%   +0.01% (p=0.005 n=10)
ReverseBytes64    0.8010n ± 0%   0.8011n ± 0%   +0.01% (p=0.001 n=10)
Add                1.201n ± 4%    1.202n ± 0%   +0.08% (p=0.028 n=10)
Add32              1.201n ± 0%    1.202n ± 2%   +0.08% (p=0.014 n=10)
Add64              1.201n ± 1%    1.202n ± 0%   +0.08% (p=0.025 n=10)
Add64multiple      1.902n ± 0%    1.913n ± 0%   +0.55% (p=0.004 n=10)
Sub                1.201n ± 0%    1.202n ± 3%   +0.08% (p=0.001 n=10)
Sub32              1.654n ± 0%    1.656n ± 1%        ~ (p=0.117 n=10)
Sub64              1.201n ± 0%    1.202n ± 0%   +0.08% (p=0.001 n=10)
Sub64multiple      2.180n ± 4%    2.159n ± 1%   -0.96% (p=0.006 n=10)
Mul               0.9345n ± 0%   0.9346n ± 0%   +0.01% (p=0.000 n=10)
Mul32              1.030n ± 0%    1.050n ± 1%   +1.94% (p=0.000 n=10)
Mul64             0.9345n ± 0%   0.9346n ± 1%   +0.01% (p=0.000 n=10)
Div                11.57n ± 1%    11.12n ± 0%   -3.85% (p=0.000 n=10)
Div32              4.337n ± 1%    4.341n ± 1%        ~ (p=0.286 n=10)
Div64              12.76n ± 0%    12.02n ± 3%   -5.80% (p=0.000 n=10)
geomean            1.252n         1.235n        -1.32%

Change-Id: Iec4cfd2b83bb0f946068c1d657369ff081d95b04
Reviewed-on: https://go-review.googlesource.com/c/go/+/628575
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: David Chase <drchase@google.com>
5 months agocmd/internal/obj/loong64: add {V,XV}DIV{B/H/W/V}[U] and {V,XV}MOD{B/H/W/V}[U] instruc...
Xiaolin Zhao [Mon, 16 Dec 2024 02:24:17 +0000 (10:24 +0800)]
cmd/internal/obj/loong64: add {V,XV}DIV{B/H/W/V}[U] and {V,XV}MOD{B/H/W/V}[U] instructions support

Go asm syntax:
 VDIV{B/H/W/V}[U] VK, VJ, VD
XVDIV{B/H/W/V}[U] XK, XJ, XD
 VMOD{B/H/W/V}[U] VK, VJ, VD
XVMOD{B/H/W/V}[U] XK, XJ, XD

Equivalent platform assembler syntax:
 vdiv.{b/h/w/d}[u] vd, vj, vk
xvdiv.{b/h/w/d}[u] xd, xj, xk
 vmod.{b/h/w/d}[u] vd, vj, vk
xvmod.{b/h/w/d}[u] xd, xj, xk

Change-Id: I3676721c3c415de0f2ebbd480ecd1b2400a28dba
Reviewed-on: https://go-review.googlesource.com/c/go/+/636376
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>