Compare commits

...

849 Commits

Author SHA1 Message Date
Mateusz Poliwczak
93e3d5dc5f go/parser: use non-adjusted position while parsing CommentGroups
Line directives should not affect the way Comments get grouped
into CommentGroups.

Change-Id: I9aa4b558cb1333b32be692e8720291d0e6961cae
GitHub-Last-Rev: de867b27bff28983716ba9126329d75f456a2b5a
GitHub-Pull-Request: golang/go#69133
Reviewed-on: https://go-review.googlesource.com/c/go/+/609515
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-05 08:29:32 -07:00
qmuntal
6953ef86cd net,os: support converting between *os.File and net.Conn on Windows
The runtime poller and os.NewFile recently gained support for
disassociating the handle from the runtime poller IOCP (see CL 664455).
This was the main blocker for allowing the conversion between *os.File
and net.Conn.

Implementing the conversion is now trivial. The only remaining work,
implemented in this CL, is improving os.NewFile to also support
socket handles and updating some build tags so that Windows can share
almost the same net's File implementation as Unix.

There is one important limitation, though: the duplicated socket handle
returned by the various File methods in the net package is not
usable on other process. If someone needs to pass a socket handle to
another process, they should manually call the WSADuplicateSocket
Windows API passing the process ID of the target process.

Fixes #9503.
Fixes #10350.
Updates #19098.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race,gotip-windows-amd64-longtest,gotip-windows-arm64
Change-Id: Ic43cadaac2662b925d57a9d362ddc7ae21d1b56e
Reviewed-on: https://go-review.googlesource.com/c/go/+/668195
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-05-05 04:05:18 -07:00
Russ Cox
8ec555931d go/types: fix typo in Info.Types doc comment
Change-Id: Ib95b77ab3dc6e48158e25e70fabb2579f3706b5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/669755
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-05-04 15:04:38 -07:00
Michael Pratt
93fb2c9074 runtime: clear frame pointer in morestack
Corollary to CL 669615.

morestack uses the frame pointer from g0.sched.bp. This doesn't really
make any sense. morestack wasn't called by whatever used g0 last, so at
best unwinding will get misleading results.

For #63630.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-arm64-longtest
Change-Id: I6a6a636c3a2994eb88f890c506c96fd899e993a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/669616
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nick Ripley <nick.ripley@datadoghq.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-05-02 13:30:27 -07:00
Michael Pratt
739fb752e3 runtime: don't restore from g0.sched in systemstack on arm64
On arm64, systemstack restores the frame pointer from g0.sched to R29
prior to calling the callback. That doesn't really make any sense. The
frame pointer value in g0.sched is some arbitrary BP from a prior
context save, but that is not the caller of systemstack.

amd64 does not do this. In fact, it leaves BP completely unmodified so
frame pointer unwinders like gdb can walk through the systemstack frame
and continue traceback on the caller's stack. Unlike mcall, systemstack
always returns to the original goroutine, so that is safe.

We should do the same on arm64.

For #63630.

Cq-Include-Trybots: luci.golang.try:gotip-linux-arm64-longtest
Change-Id: I6a6a636c35d321dd5d7dc1c4d09e29b55b1ab621
Reviewed-on: https://go-review.googlesource.com/c/go/+/669236
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Nick Ripley <nick.ripley@datadoghq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-02 13:30:24 -07:00
Michael Pratt
9c1d19a183 runtime: clear frame pointer in mcall
On amd64, mcall leaves BP untouched, so the callback will push BP,
connecting the g0 stack to the calling g stack. This seems OK (frame
pointer unwinders like Linux perf can see what user code called into the
scheduler), but the "scheduler" part is problematic.

mcall is used when calling into the scheduler to deschedule the current
goroutine (e.g., in goyield). Once the goroutine is descheduled, it may
be picked up by another M and continue execution. The other thread is
mutating the goroutine stack, but our M still has a frame pointer
pointing to the goroutine stack.

A frame pointer unwinder like Linux perf could get bogus values off of
the mutating stack. Note that though the execution tracer uses
framepointer unwinding, it never unwinds a g0, so it isn't affected.

Clear the frame pointer in mcall so that unwinding always stops at
mcall.

On arm64, mcall stores the frame pointer from g0.sched.bp. This doesn't
really make any sense. mcall wasn't called by whatever used g0 last, so
at best unwinding will get misleading results (e.g., it might look like
cgocallback calls mcall?).

Also clear the frame pointer on arm64.

Other architectures don't use frame pointers.

For #63630.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-arm64-longtest
Change-Id: I6a6a636cb6404f3c95ecabdb969c9b8184615cee
Reviewed-on: https://go-review.googlesource.com/c/go/+/669615
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nick Ripley <nick.ripley@datadoghq.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-05-02 13:11:15 -07:00
Stefan Schlosser
21908c3dec cmd/go/internal/vcs: include Subversion VCS build information
The existing implementation lacks the Status function for retrieving VCS build
information for Subversion. As a consequence, binaries aren't stamped with the
Revision, CommitTime and Uncommitted information from SVN repositories.

This change provides the svnStatus function and retrieves the information by
running svn info and svn status commands.

Fixes #73444

Change-Id: Ie6d95ffbb3a3c580cc42128ad1f8d82a869c91f2
GitHub-Last-Rev: 3472222865638a13b122c8995561166cfe228fa8
GitHub-Pull-Request: golang/go#73446
Reviewed-on: https://go-review.googlesource.com/c/go/+/666875
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
2025-05-02 13:11:07 -07:00
Michael Anthony Knyszek
1b40dbce1a runtime: mark and scan small objects in whole spans [green tea]
Our current parallel mark algorithm suffers from frequent stalls on
memory since its access pattern is essentially random. Small objects
are the worst offenders, since each one forces pulling in at least one
full cache line to access even when the amount to be scanned is far
smaller than that. Each object also requires an independent access to
per-object metadata.

The purpose of this change is to improve garbage collector performance
by scanning small objects in batches to obtain better cache locality
than our current approach. The core idea behind this change is to defer
marking and scanning small objects, and then scan them in batches
localized to a span.

This change adds scanned bits to each small object (<=512 bytes) span in
addition to mark bits. The scanned bits indicate that the object has
been scanned. (One way to think of them is "grey" bits and "black" bits
in the tri-color mark-sweep abstraction.) Each of these spans is always
8 KiB and if they contain pointers, the pointer/scalar data is already
packed together at the end of the span, allowing us to further optimize
the mark algorithm for this specific case.

When the GC encounters a pointer, it first checks if it points into a
small object span. If so, it is first marked in the mark bits, and then
the object is queued on a work-stealing P-local queue. This object
represents the whole span, and we ensure that a span can only appear at
most once in any queue by maintaining an atomic ownership bit for each
span. Later, when the pointer is dequeued, we scan every object with a
set mark that doesn't have a corresponding scanned bit. If it turns out
that was the only object in the mark bits since the last time we scanned
the span, we scan just that object directly, essentially falling back to
the existing algorithm. noscan objects have no scan work, so they are
never queued.

Each span's mark and scanned bits are co-located together at the end of
the span. Since the span is always 8 KiB in size, it can be found with
simple pointer arithmetic. Next to the marks and scans we also store the
size class, eliminating the need to access the span's mspan altogether.

The work-stealing P-local queue is a new source of GC work. If this
queue gets full, half of it is dumped to a global linked list of spans
to scan. The regular scan queues are always prioritized over this queue
to allow time for darts to accumulate. Stealing work from other Ps is a
last resort.

This change also adds a new debug mode under GODEBUG=gctrace=2 that
dumps whole-span scanning statistics by size class on every GC cycle.

A future extension to this CL is to use SIMD-accelerated scanning
kernels for scanning spans with high mark bit density.

For #19112. (Deadlock averted in GOEXPERIMENT.)
For #73581.

Change-Id: I4bbb4e36f376950a53e61aaaae157ce842c341bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/658036
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-02 10:28:07 -07:00
Dmitri Shuralyov
f760e1fe49 cmd/api: skip 3 non-TestCheck tests in -check mode
TestIssue64958 takes a while, so it's not worth running both without
and with -check flag. The others are fast, but there's still no good
reason to run anything but TestCheck when the -check flag is on.

Change-Id: I13ebb90e3c863006f21441909b05364e1b316ed6
Reviewed-on: https://go-review.googlesource.com/c/go/+/668656
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2025-05-02 10:06:27 -07:00
Joel Sing
1cc624fd62 cmd/internal/obj/riscv: add support for vector permutation instructions
Add support for vector permutation instructions to the RISC-V assembler.
This includes integer scalar move, floating point scalar move, slide up
and slide down, register gather, compression and whole vector register
move instructions.

Change-Id: I1da9f393091504fd81714006355725b8b9ecadea
Reviewed-on: https://go-review.googlesource.com/c/go/+/646780
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
2025-05-02 04:24:52 -07:00
Joel Sing
936ecc3e24 cmd/internal/obj/riscv: add support for vector mask instructions
Add support for vector mask instructions to the RISC-V assembler.
These allow manipulation of vector masks and include mask register
logical instructions, population count and find-first bit set
instructions.

Change-Id: I3ab3aa0f918338aee9b37ac5a2b2fdc407875072
Reviewed-on: https://go-review.googlesource.com/c/go/+/646779
Reviewed-by: Carlos Amedee <carlos@golang.org>
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: Junyang Shao <shaojunyang@google.com>
2025-05-02 04:24:40 -07:00
Joel Sing
2e60916f6e cmd/internal/obj/riscv: add support for vector reduction instructions
Add support for vector reduction instructions to the RISC-V assembler,
including single-width integer reduction, widening integer reduction,
single-width floating-point reduction and widening floating-point
reduction.

Change-Id: I8f17bef11389f3a017e0430275023fc5d75936e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/646778
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-05-02 04:24:27 -07:00
Josh Rickmar
7785528c50 os: fix Root.Mkdir permission bits on OpenBSD
Pass missing mode bits in the mkdirat() syscall wrapper.

Fixes #73559

Change-Id: I54b1985bd77b1fe5d1a48acab9f2597f8c931854
GitHub-Last-Rev: 669c17361d86bc9065bb6b47a2d60aa86bcfa12d
GitHub-Pull-Request: golang/go#73565
Reviewed-on: https://go-review.googlesource.com/c/go/+/669375
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2025-05-01 16:36:58 -07:00
Alan Donovan
9921537a96 sync: WaitGroup.Go: document that f must not panic
Fixes #63796

Change-Id: Ib11d32574011e13aab3a0ad504f0d10009627503
Reviewed-on: https://go-review.googlesource.com/c/go/+/667695
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2025-05-01 12:34:03 -07:00
Keith Randall
12110c3f7e cmd/compile: improve multiplication strength reduction
Use an automatic algorithm to generate strength reduction code.
You give it all the linear combination (a*x+b*y) instructions in your
architecture, it figures out the rest.

Just amd64 and arm64 for now.

Fixes #67575

Change-Id: I35c69382bebb1d2abf4bb4e7c43fd8548c6c59a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/626998
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-01 09:33:31 -07:00
Joel Sing
4d10d4ad84 cmd/compile,internal/cpu,runtime: intrinsify math/bits.OnesCount on riscv64
For riscv64/rva22u64 and above, we can intrinsify math/bits.OnesCount
using the CPOP/CPOPW machine instructions. Since the native Go
implementation of OnesCount is relatively expensive, it is also
worth emitting a check for Zbb support when compiled for rva20u64.

On a Banana Pi F3, with GORISCV64=rva22u64:

              │     oc.1     │                oc.2                 │
              │    sec/op    │   sec/op     vs base                │
OnesCount-8     16.930n ± 0%   4.389n ± 0%  -74.08% (p=0.000 n=10)
OnesCount8-8     5.642n ± 0%   5.016n ± 0%  -11.10% (p=0.000 n=10)
OnesCount16-8    9.404n ± 0%   5.015n ± 0%  -46.67% (p=0.000 n=10)
OnesCount32-8   13.165n ± 0%   4.388n ± 0%  -66.67% (p=0.000 n=10)
OnesCount64-8   16.300n ± 0%   4.388n ± 0%  -73.08% (p=0.000 n=10)
geomean          11.40n        4.629n       -59.40%

On a Banana Pi F3, compiled with GORISCV64=rva20u64 and with Zbb
detection enabled:

              │     oc.3     │                oc.4                 │
              │    sec/op    │   sec/op     vs base                │
OnesCount-8     16.930n ± 0%   5.643n ± 0%  -66.67% (p=0.000 n=10)
OnesCount8-8     5.642n ± 0%   5.642n ± 0%        ~ (p=0.447 n=10)
OnesCount16-8   10.030n ± 0%   6.896n ± 0%  -31.25% (p=0.000 n=10)
OnesCount32-8   13.170n ± 0%   5.642n ± 0%  -57.16% (p=0.000 n=10)
OnesCount64-8   16.300n ± 0%   5.642n ± 0%  -65.39% (p=0.000 n=10)
geomean          11.55n        5.873n       -49.16%

On a Banana Pi F3, compiled with GORISCV64=rva20u64 but with Zbb
detection disabled:

              │    oc.3     │                oc.5                 │
              │   sec/op    │   sec/op     vs base                │
OnesCount-8     16.93n ± 0%   29.47n ± 0%  +74.07% (p=0.000 n=10)
OnesCount8-8    5.642n ± 0%   5.643n ± 0%        ~ (p=0.191 n=10)
OnesCount16-8   10.03n ± 0%   15.05n ± 0%  +50.05% (p=0.000 n=10)
OnesCount32-8   13.17n ± 0%   18.18n ± 0%  +38.04% (p=0.000 n=10)
OnesCount64-8   16.30n ± 0%   21.94n ± 0%  +34.60% (p=0.000 n=10)
geomean         11.55n        15.84n       +37.16%

For hardware without Zbb, this adds ~5ns overhead, while for hardware
with Zbb we achieve a performance gain up of up to 11ns. It is worth
noting that OnesCount8 is cheap enough that it is preferable to stick
with the generic version in this case.

Change-Id: Id657e40e0dd1b1ab8cc0fe0f8a68df4c9f2d7da5
Reviewed-on: https://go-review.googlesource.com/c/go/+/660856
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-01 05:57:41 -07:00
Joel Sing
90e8b8cdae cmd/compile: intrinsify math/bits.Bswap on riscv64
For riscv64/rva22u64 and above, we can intrinsify math/bits.Bswap
using the REV8 machine instruction.

On a StarFive VisionFive 2 with GORISCV64=rva22u64:

                 │     rb.1     │                rb.2                 │
                 │    sec/op    │   sec/op     vs base                │
ReverseBytes-4     18.790n ± 0%   4.026n ± 0%  -78.57% (p=0.000 n=10)
ReverseBytes16-4    6.710n ± 0%   5.368n ± 0%  -20.00% (p=0.000 n=10)
ReverseBytes32-4   13.420n ± 0%   5.368n ± 0%  -60.00% (p=0.000 n=10)
ReverseBytes64-4   17.450n ± 0%   4.026n ± 0%  -76.93% (p=0.000 n=10)
geomean             13.11n        4.649n       -64.54%

Change-Id: I26eee34270b1721f7304bb1cddb0fda129b20ece
Reviewed-on: https://go-review.googlesource.com/c/go/+/660855
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-05-01 05:57:13 -07:00
Joel Sing
6fc1e34100 internal/bytealg: deduplicate code between Count/CountString for riscv64
Change-Id: I22eb4e7444e5fe5f6767cc960895f3c6e2fa13cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/661615
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Carlos Amedee <carlos@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-05-01 05:56:26 -07:00
Joel Sing
5a342266e6 cmd/internal/obj/riscv: add support for vector floating-point instructions
Add support for vector floating-point instructions to the RISC-V
assembler. This includes single-width and widening addition and
subtraction, multiplication and division, fused multiply-addition,
comparison, min/max, sign-injection, classification and type
conversion instructions.

Change-Id: I8bceb1c5d7eead0561ba5407ace00805a6144f51
Reviewed-on: https://go-review.googlesource.com/c/go/+/646777
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
2025-05-01 05:55:31 -07:00
Julian Zhu
6109185cf9 math/big: fix incorrect register allocation for mipsx/mips64x
According to the MIPS ABI, R26/R27 are reserved for OS kernel, and may be clobbered by it. They must not be used by user mode.

See Figure 3-18 of MIPS ELF ABI specification: https://refspecs.linuxfoundation.org/elf/mipsabi.pdf

Fixes #73472

Change-Id: Ifda692a803176bfaab2c70d6623636c5d135f42e
Reviewed-on: https://go-review.googlesource.com/c/go/+/667816
Reviewed-by: 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>
Reviewed-by: Keith Randall <khr@google.com>
2025-05-01 05:04:39 -07:00
Dmitri Shuralyov
b48e52b428 cmd/dist: move "devel" substring in git-inferred development version
Keep the property that the "devel" substring is always present in these
development versions of Go, but also gain the property that it's viable
to use functions in the go/version package such as Lang, Compare, and
get the expected results without needing to trim the "devel " prefix.

For #73369.
For #41116.
Fixes #73372.

Change-Id: Ieea4692e8c6cf0135e010f49f85300f6b038d6b1
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/668015
Reviewed-by: Funda Secgin <fundasecgin30@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-04-30 12:54:52 -07:00
Mark Ryan
12e5efd710 cmd/link: fix cgo on riscv64 when building with gcc-15
It's not currently possible to build cgo programs that are partially
compiled with gcc-15 on riscv64 using the internal linker. There are
two reasons for this.

1. When gcc-15 compiles _cgo_export.c, which contains no actual code,
   for a riscv64 target, it emits a label in the .text section called
   .Letext0. This label is referred to by another section, .debug_line,
   and an entry is generated in the symbol table for it. The Go linker
   panics when processing the .Letext0 symbol in _cgo_export.o, as it
   occurs in an empty section.
2. GCC-15 is generating additional debug symbols with the .LVUS
   prefix, e.g., .LVUS33, that need to be ignored.

We fix the issue by removing the check in
cmd/link/internal/loader/loader.go that panics if we encounter a
symbol in an empty section (the comments preceding this check suggest
it's safe to remove it) and by adding .LVUS to the list of symbol
prefixes to ignore.

Fixes #72840

Change-Id: I00658b6bdd01606dde1581b5bc2f42edfc37de82
Reviewed-on: https://go-review.googlesource.com/c/go/+/668276
Auto-Submit: 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: Joel Sing <joel@sing.id.au>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
2025-04-30 11:40:17 -07:00
Dmitri Shuralyov
214b208e24 cmd/go, cmd/internal/objabi: detect "devel" version by substring
These were the remaining instances in the main Go repo I found where a
Go version like "devel go1.25-9ce47e66e8 Wed Mar 26 03:48:50 2025 -0700"
is considered to be a development version rather than a release version,
but the version "go1.25-devel_9ce47e66e8 Wed Mar 26 03:48:50 2025 -0700"
is not.

Update this in preparation of the move of "devel" from front to middle.

For #73372.
For #73369.

Change-Id: If5442ecb0751c08b3a1b4d1148193e501700b956
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/668355
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-30 11:07:24 -07:00
qmuntal
3cebfb678b os: test overlapped pipes deadlines on Windows
NewFile recently added support for overlapped I/O on Windows,
which allows us to set deadlines on them, but the test coverage for
this new feature is not exhaustive.

Modify the existing pipe deadline tests to also exercise named
overlapped pipes.

Updates #19098.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race,gotip-windows-amd64-longtest,gotip-windows-arm64
Change-Id: I86d284d9fb054c24959045a922cf84feeda5b5f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/668095
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-04-30 08:49:12 -07:00
Jake Bailey
06751c455d syscall: cache Errno.Error() on Windows
Windows is unlike the other OSs and depends on a syscall for most
errors. This can be costly; cache the returned string for later reuse.

This helps test caching, since errors are written out as string to the
test ID, which are often PathErrors wrapping Errnos.

For now, only cache ERROR_FILE_NOT_FOUND and ERROR_PATH_NOT_FOUND.

goos: windows
goarch: amd64
pkg: syscall
cpu: Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
               │    old.txt    │               new.txt               │
               │    sec/op     │   sec/op     vs base                │
ErrnoString-20   1788.00n ± 1%   11.08n ± 1%  -99.38% (p=0.000 n=10)

               │  old.txt   │              new.txt               │
               │    B/op    │   B/op     vs base                 │
ErrnoString-20   48.00 ± 0%   0.00 ± 0%  -100.00% (p=0.000 n=10)

               │  old.txt   │               new.txt               │
               │ allocs/op  │ allocs/op   vs base                 │
ErrnoString-20   1.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=10)

For #72992

Change-Id: I9a0910fa6538772ffc64ef7670b44059a2c7d18c
Reviewed-on: https://go-review.googlesource.com/c/go/+/667495
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>
2025-04-30 08:41:56 -07:00
qmuntal
c966f1c0c0 net: support IPv6 addresses in ListenMulticastUDP on Windows
Fixes #63529.

Change-Id: Id9246af1a72beef3149af571f0891437bba2f4e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/668216
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2025-04-30 08:34:01 -07:00
Sean Liao
8270b858ee testing: use more doc links
Change-Id: Ide372735165b7510fd8d7588451a37fa743e59c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/668915
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-30 08:21:07 -07:00
Jakub Ciolek
1e756dc5f7 cmd/compile: relax tighten register-pressure heuristic slightly
Sometimes a value has multiple args, but they are the same
dependency. Relax the regalloc heuristic for those.

No measurable compile-time regression according to compilebench,
maybe even a small improvement.

name    old time/op  new time/op  delta
StdCmd   14.4s ± 1%   14.4s ± 1%  -0.39%  (p=0.101 n=11+11)

compilecmp:

linux/amd64:

strconv
strconv.formatBits 1199 -> 1189  (-0.83%)
strconv.formatDecimal 637 -> 631  (-0.94%)

strconv [cmd/compile]
strconv.formatBits 1199 -> 1189  (-0.83%)
strconv.formatDecimal 637 -> 631  (-0.94%)

image
image.NewGray16 286 -> 275  (-3.85%)
image.NewAlpha16 286 -> 275  (-3.85%)

regexp/syntax
regexp/syntax.ranges.Less 150 -> 147  (-2.00%)
regexp/syntax.(*compiler).rune 774 -> 773  (-0.13%)
regexp/syntax.(*ranges).Swap 197 -> 180  (-8.63%)
regexp/syntax.ranges.Swap 146 -> 134  (-8.22%)
regexp/syntax.(*compiler).cap 440 -> 425  (-3.41%)
regexp/syntax.(*compiler).nop 310 -> 297  (-4.19%)
regexp/syntax.(*compiler).compile 5815 -> 5733  (-1.41%)
regexp/syntax.(*ranges).Less 211 -> 197  (-6.64%)

regexp/syntax [cmd/compile]
regexp/syntax.(*compiler).compile 5815 -> 5733  (-1.41%)
regexp/syntax.(*compiler).rune 774 -> 773  (-0.13%)
regexp/syntax.(*compiler).cap 440 -> 425  (-3.41%)
regexp/syntax.(*ranges).Less 211 -> 197  (-6.64%)
regexp/syntax.ranges.Swap 146 -> 134  (-8.22%)
regexp/syntax.(*ranges).Swap 197 -> 180  (-8.63%)
regexp/syntax.(*compiler).nop 310 -> 297  (-4.19%)
regexp/syntax.ranges.Less 150 -> 147  (-2.00%)

crypto/elliptic
crypto/elliptic.(*nistCurve[go.shape.*uint8]).pointFromAffine 1272 -> 1240  (-2.52%)

image/gif
image/gif.(*decoder).readColorTable 652 -> 646  (-0.92%)
image/gif.(*encoder).colorTablesMatch 350 -> 349  (-0.29%)

crypto/internal/cryptotest
crypto/internal/cryptotest.testCipher.func3 1289 -> 1286  (-0.23%)

internal/trace/internal/tracev1
internal/trace/internal/tracev1.(*parser).collectBatchesAndCPUSamples 1352 -> 1338  (-1.04%)

internal/fuzz
internal/fuzz.byteSliceDuplicateBytes 741 -> 718  (-3.10%)

cmd/compile/internal/types
cmd/compile/internal/types.CalcSize 3663 -> 3633  (-0.82%)

cmd/compile/internal/rttype
cmd/compile/internal/rttype.Init 2149 -> 2124  (-1.16%)

cmd/link/internal/loadmacho
cmd/link/internal/loadmacho.macholoadsym 1213 -> 1212  (-0.08%)

cmd/compile/internal/rangefunc
cmd/compile/internal/rangefunc.(*rewriter).checks 5207 -> 5175  (-0.61%)

net/http
net/http.(*http2SettingsFrame).Setting 155 -> 147  (-5.16%)

cmd/compile/internal/rttype [cmd/compile]
cmd/compile/internal/rttype.Init 2149 -> 2124  (-1.16%)

cmd/compile/internal/rangefunc [cmd/compile]
cmd/compile/internal/rangefunc.(*rewriter).checks 5207 -> 5175  (-0.61%)

cmd/link/internal/ld
cmd/link/internal/ld.pefips 3119 -> 3109  (-0.32%)

cmd/vendor/rsc.io/markdown
cmd/vendor/rsc.io/markdown.parseDash 593 -> 587  (-1.01%)

cmd/compile/internal/ssa
cmd/compile/internal/ssa.(*poset).setOrder 3442 -> 3416  (-0.76%)
cmd/compile/internal/ssa.rewriteValuegeneric_OpMul16 2054 -> 2022  (-1.56%)
cmd/compile/internal/ssa.rewriteValuegeneric_OpMul8 2054 -> 2022  (-1.56%)
inserted cmd/compile/internal/ssa.tighten.deferwrap5

cmd/compile/internal/ssa [cmd/compile]
cmd/compile/internal/ssa.rewriteValuegeneric_OpMul8 2054 -> 2022  (-1.56%)
cmd/compile/internal/ssa.rewriteValuegeneric_OpMul16 2054 -> 2022  (-1.56%)
cmd/compile/internal/ssa.tighten.deferwrap4 76 -> 67  (-11.84%)
cmd/compile/internal/ssa.tighten 6746 -> 5082  (-24.67%)
inserted cmd/compile/internal/ssa.tighten.deferwrap5

file                                             before   after    Δ       %
strconv.s                                        49029    49020    -9      -0.018%
strconv [cmd/compile].s                          49029    49020    -9      -0.018%
image.s                                          34963    34941    -22     -0.063%
regexp/syntax.s                                  83017    82860    -157    -0.189%
regexp/syntax [cmd/compile].s                    83017    82860    -157    -0.189%
crypto/elliptic.s                                26848    26816    -32     -0.119%
image/gif.s                                      22840    22833    -7      -0.031%
crypto/internal/cryptotest.s                     63834    63832    -2      -0.003%
internal/trace/internal/tracev1.s                52995    52981    -14     -0.026%
internal/trace.s                                 181396   181412   +16     +0.009%
internal/fuzz.s                                  85526    85503    -23     -0.027%
cmd/internal/obj/s390x.s                         121651   121683   +32     +0.026%
cmd/internal/obj/ppc64.s                         139867   139871   +4      +0.003%
cmd/compile/internal/types.s                     71425    71395    -30     -0.042%
cmd/internal/obj/ppc64 [cmd/compile].s           139952   139956   +4      +0.003%
cmd/internal/obj/s390x [cmd/compile].s           121753   121785   +32     +0.026%
cmd/compile/internal/rttype.s                    10418    10393    -25     -0.240%
cmd/link/internal/loadmacho.s                    23270    23272    +2      +0.009%
cmd/compile/internal/rangefunc.s                 35050    35018    -32     -0.091%
cmd/vendor/github.com/google/pprof/profile.s     148264   148273   +9      +0.006%
net/http.s                                       612895   612910   +15     +0.002%
cmd/compile/internal/rttype [cmd/compile].s      10397    10372    -25     -0.240%
cmd/compile/internal/rangefunc [cmd/compile].s   35681    35649    -32     -0.090%
net/http/cookiejar.s                             28758    28761    +3      +0.010%
cmd/compile/internal/reflectdata.s               86639    86644    +5      +0.006%
cmd/compile/internal/reflectdata [cmd/compile].s 89725    89730    +5      +0.006%
cmd/link/internal/ld.s                           649596   649633   +37     +0.006%
cmd/vendor/rsc.io/markdown.s                     116731   116757   +26     +0.022%
cmd/compile/internal/ssa.s                       3574185  3574642  +457    +0.013%
cmd/compile/internal/ssa [cmd/compile].s         3725364  3723715  -1649   -0.044%
cmd/compile/internal/ssagen.s                    415135   415155   +20     +0.005%
total                                            36475376 36473818 -1558   -0.004%

linux/arm64:

go/printer
go/printer.(*printer).expr1 7152 -> 7168  (+0.22%)

fmt [cmd/compile]
fmt.(*ss).advance 1712 -> 1696  (-0.93%)

crypto/x509
crypto/x509.marshalCertificatePolicies.func1.2.(*Builder).AddASN1ObjectIdentifier.1 changed

internal/fuzz
internal/fuzz.minimizeBytes changed

cmd/internal/obj/arm64
cmd/internal/obj/arm64.bitconEncode changed

math/big [cmd/compile]
math/big.(*Float).Int64 512 -> 528  (+3.12%)
math/big.NewInt changed
math/big.fmtE 720 -> 736  (+2.22%)
math/big.basicSqr changed

cmd/asm/internal/asm
cmd/asm/internal/asm.(*Parser).asmText 1424 -> 1440  (+1.12%)

go/constant [cmd/compile]
go/constant.UnaryOp changed
go/constant.BinaryOp changed

crypto/tls
crypto/tls.prf10 576 -> 560  (-2.78%)

cmd/internal/obj/arm64 [cmd/compile]
cmd/internal/obj/arm64.bitconEncode changed

cmd/vendor/golang.org/x/term
cmd/vendor/golang.org/x/term.(*Terminal).addKeyToLine changed

cmd/compile/internal/ir
cmd/compile/internal/ir.ConstOverflow changed

cmd/vendor/github.com/google/pprof/internal/graph
cmd/vendor/github.com/google/pprof/internal/graph.(*builder).addEdge changed

cmd/compile/internal/ir [cmd/compile]
cmd/compile/internal/ir.ConstOverflow changed

cmd/compile/internal/rttype
cmd/compile/internal/rttype.Init changed

cmd/compile/internal/rttype [cmd/compile]
cmd/compile/internal/rttype.Init changed

cmd/compile/internal/abi [cmd/compile]
cmd/compile/internal/abi.(*ABIParamAssignment).RegisterTypesAndOffsets 1344 -> 1328  (-1.19%)

cmd/vendor/golang.org/x/tools/go/types/typeutil
cmd/vendor/golang.org/x/tools/go/types/typeutil.hasher.hash changed

cmd/vendor/github.com/ianlancetaylor/demangle
cmd/vendor/github.com/ianlancetaylor/demangle.(*rustState).expandPunycode changed

net/http/cookiejar
net/http/cookiejar.adapt changed
net/http/cookiejar.encode changed

cmd/compile/internal/reflectdata
cmd/compile/internal/reflectdata.OldMapType changed

cmd/compile/internal/reflectdata [cmd/compile]
cmd/compile/internal/reflectdata.OldMapType changed

cmd/vendor/github.com/google/pprof/internal/report
cmd/vendor/github.com/google/pprof/internal/report.(*Report).newTrimmedGraph 2336 -> 2368  (+1.37%)

cmd/link/internal/ld
cmd/link/internal/ld.(*relocSymState).relocsym changed

cmd/vendor/rsc.io/markdown
cmd/vendor/rsc.io/markdown.parseDash changed
cmd/vendor/rsc.io/markdown.parseLinkRefDef changed

cmd/trace
main.(*stackMap).profile 912 -> 880  (-3.51%)

cmd/vendor/golang.org/x/tools/go/analysis/passes/tests
cmd/vendor/golang.org/x/tools/go/analysis/passes/tests.checkExampleOutput 832 -> 816  (-1.92%)

cmd/compile/internal/ssa
cmd/compile/internal/ssa.shouldElimIfElse changed
cmd/compile/internal/ssa.storeOrder changed
cmd/compile/internal/ssa.elimIfElse changed
cmd/compile/internal/ssa.tighten 3408 -> 3456  (+1.41%)

cmd/compile/internal/ssa [cmd/compile]
cmd/compile/internal/ssa.storeOrder changed
cmd/compile/internal/ssa.elimIfElse changed
cmd/compile/internal/ssa.shouldElimIfElse changed
cmd/compile/internal/ssa.tighten 4960 -> 4976  (+0.32%)
cmd/compile/internal/ssa.branchelim changed

file                                                     before   after    Δ       %
runtime.s                                                624064   624032   -32     -0.005%
runtime [cmd/compile].s                                  679456   679424   -32     -0.005%
strconv.s                                                48528    48560    +32     +0.066%
strconv [cmd/compile].s                                  48528    48560    +32     +0.066%
index/suffixarray.s                                      41808    41856    +48     +0.115%
fmt.s                                                    72272    72256    -16     -0.022%
math/big.s                                               152992   153024   +32     +0.021%
go/printer.s                                             77680    77696    +16     +0.021%
fmt [cmd/compile].s                                      81760    81744    -16     -0.020%
math/big [cmd/compile].s                                 153040   153072   +32     +0.021%
cmd/asm/internal/asm.s                                   57360    57376    +16     +0.028%
crypto/tls.s                                             354304   354288   -16     -0.005%
cmd/compile/internal/abi [cmd/compile].s                 22752    22736    -16     -0.070%
cmd/vendor/github.com/google/pprof/internal/report.s     67008    67040    +32     +0.048%
cmd/trace.s                                              215040   215008   -32     -0.015%
cmd/vendor/golang.org/x/tools/go/analysis/passes/tests.s 12544    12528    -16     -0.128%
cmd/compile/internal/ssa.s                               3209248  3209296  +48     +0.001%
cmd/compile/internal/ssa [cmd/compile].s                 3319152  3319168  +16     +0.000%
total                                                    33366288 33366416 +128    +0.000%

Change-Id: I8111792c9dd4f927b49a6d5dd90a3fdc3ec26277
Reviewed-on: https://go-review.googlesource.com/c/go/+/666836
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@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-29 07:38:24 -07:00
John Bampton
29595ffeca doc: fix grammar and spelling
Minor typo fixes in the docs

Change-Id: I56b5d0318936aecc7775fb5bc70534456707da49
GitHub-Last-Rev: b4d042f8a997aa0d3824d8f9350dd24090b21073
GitHub-Pull-Request: golang/go#73531
Reviewed-on: https://go-review.googlesource.com/c/go/+/668815
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-29 07:37:04 -07:00
Guoqi Chen
b386b62852 cmd/internal/obj/loong64: fix the error parameters when calling UnspillRegisterArgs
This bug was introduced in CL 648518.

Fixes #73518.

Change-Id: I4988dd0b636c6a6a48d2aa2e2ae868e43f69995a
Reviewed-on: https://go-review.googlesource.com/c/go/+/668475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-28 18:54:08 -07:00
John Bampton
760f22848d crypto/internal/hpke: rename Receipient to Recipient
receipient -> recipient

Change-Id: I9ed5937acf0f3808283e35221f8b4f41408eee7c
GitHub-Last-Rev: 0ed5ff7a46808d5311af3620b6577734a1e557f4
GitHub-Pull-Request: golang/go#73131
Reviewed-on: https://go-review.googlesource.com/c/go/+/662175
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
2025-04-28 18:49:45 -07:00
goto1134
c8b589e266 cmd/list: fix -retracted flag description
Change-Id: Ia1ab220485af2f38c3ddcd4c5d5bca1b195a33ed
GitHub-Last-Rev: fb9933427d852518c93efbc4f2c2e4d4ee9b9197
GitHub-Pull-Request: golang/go#59847
Reviewed-on: https://go-review.googlesource.com/c/go/+/489175
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-28 16:51:08 -07:00
Julien Cretel
f9ce1dddc2 mime: speed up ParseMediaType
Add benchmarks for ParseMediaType.

Eschew UTF-8 decoding and strings.IndexFunc where possible, and rely
on 128-bit bitmaps instead. Eliminate some bounds checks.

Some benchmark results (no changes to allocations):

goos: darwin
goarch: amd64
pkg: mime
cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
                      │     old     │                 new                 │
                      │   sec/op    │   sec/op     vs base                │
ParseMediaType-8        71.75µ ± 0%   55.53µ ± 0%  -22.60% (p=0.000 n=20)
ParseMediaTypeBogus-8   5.330µ ± 0%   3.603µ ± 0%  -32.41% (p=0.000 n=20)
geomean                 19.56µ        14.14µ       -27.67%

Change-Id: I324c9990fe43581484916ecff61ca6c708467a89
GitHub-Last-Rev: e2293d64b3852722bef920169eaa44e7ded3111c
GitHub-Pull-Request: golang/go#73436
Reviewed-on: https://go-review.googlesource.com/c/go/+/666655
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: 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>
Auto-Submit: Sean Liao <sean@liao.dev>
2025-04-26 08:01:54 -07:00
Austin Clements
7a2689b152 sync: tidy WaitGroup documentation, add WaitGroup.Go example
This reframes the WaitGroup documentation with Go at its center and
Add/Done as more "advanced" features.

Updates #63796

Change-Id: I8101972626fdb00c6f7fb185b685227823d10db1
Reviewed-on: https://go-review.googlesource.com/c/go/+/662975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-25 15:40:11 -07:00
David du Colombier
9f55e7bc21 runtime: don't read /dev/random on Plan 9
In CL 656755, the readRandom function was modified
to read an integer from /dev/random.

However, on Plan 9, /dev/random can only return
a few hundred bits a second.

The issue is that readRandom is called by randinit,
which is called at the creation of Go processes.

Consequently, it lead the Go programs to be very
slow on Plan 9.

This change reverts the change done in CL 656755
to make the readRandom function always returning 0
on Plan 9.

Change-Id: Ibe1bf7e4c8cbc82998e4f5e1331f5e29a047c4fc
Cq-Include-Trybots: luci.golang.try:gotip-plan9-arm

Reviewed-on: https://go-review.googlesource.com/c/go/+/663195
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Richard Miller <millerresearch@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-25 14:43:43 -07:00
Dmitri Shuralyov
eb55b985a1 cmd/dist: add "devel" substring check to isRelease computation
Non-release versions that are built from source without a VERSION file
specifying any particular version end up with a development version like
"devel go1.25-67e0681aef Thu Apr 24 12:17:27 2025 -0700". Right now
those versions are correctly determined to be non-release because they
don't have a "go" prefix, instead they have a "devel " prefix.

In preparation of being able to move the "devel" substring, add a check
that said substring isn't present anywhere, since it is certain not to
be included in any released Go version we publish at https://go.dev/dl/.

For #73372.

Change-Id: Ia3e0d03b5723d4034d6270c3a2224f8dfae380e9
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/667955
Auto-Submit: 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: Michael Pratt <mpratt@google.com>
2025-04-25 14:30:13 -07:00
Keith Randall
3f3782feed cmd/compile: allow all of the preamble to be preemptible
We currently make some parts of the preamble unpreemptible because
it confuses morestack. See comments in the code.

Instead, have morestack handle those weird cases so we can
remove unpreemptible marks from most places.

This CL makes user functions preemptible everywhere if they have no
write barriers (at least, on x86). In cmd/go the fraction of functions
that need preemptible markings drops from 82% to 36%. Makes the cmd/go
binary 0.3% smaller.

Update #35470

Change-Id: Ic83d5eabfd0f6d239a92e65684bcce7e67ff30bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/648518
Auto-Submit: Keith Randall <khr@google.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>
2025-04-25 12:21:48 -07:00
limeidan
dc1e255104 runtime, internal/fuzz: add comparison tracing for libFuzzer on loong64
Change-Id: I212330962453139fa353db29928786b64c9ff063
Reviewed-on: https://go-review.googlesource.com/c/go/+/667455
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-24 23:16:24 -07:00
Guoqi Chen
fb2c88147d cmd/internal/obj: add new assembly format for BFPT and BFPF on loong64
On loong64, BFPT and BFPF are mapped to the platform assembly as follows:

   Go asm syntax:
        BFPT   FCCx, offs21
        BFPF   FCCx, offs21
   Equivalent platform assembler syntax:
        bcnez  cj, offs21
        bceqz  cj, offs21

If the condition register is not specified, it defaults to FCC0.

Change-Id: I2cc3df62a9c55d4b5eb124789358983c6737319c
Reviewed-on: https://go-review.googlesource.com/c/go/+/667456
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
2025-04-24 18:28:42 -07:00
Julian Zhu
06f96a598e crypto/sha256: improve performance of riscv64 assembly
Simplified the implementation of Ch and Maj by reducing instructions, based on CL 605495 which made the same change for SHA-512.

goos: linux
goarch: riscv64
pkg: crypto/sha256
cpu: Spacemit(R) X60
                    │  oldsha256  │              newsha256              │
                    │   sec/op    │   sec/op     vs base                │
Hash8Bytes/New-8      2.303µ ± 0%   2.098µ ± 0%   -8.90% (p=0.000 n=10)
Hash8Bytes/Sum224-8   2.535µ ± 0%   2.329µ ± 0%   -8.13% (p=0.000 n=10)
Hash8Bytes/Sum256-8   2.558µ ± 0%   2.352µ ± 0%   -8.04% (p=0.000 n=10)
Hash1K/New-8          28.67µ ± 0%   25.21µ ± 0%  -12.06% (p=0.000 n=10)
Hash1K/Sum224-8       28.89µ ± 0%   25.43µ ± 0%  -11.99% (p=0.000 n=10)
Hash1K/Sum256-8       28.91µ ± 0%   25.43µ ± 0%  -12.04% (p=0.000 n=10)
Hash8K/New-8          218.0µ ± 1%   192.7µ ± 2%  -11.58% (p=0.000 n=10)
Hash8K/Sum224-8       218.0µ ± 1%   193.6µ ± 1%  -11.20% (p=0.000 n=10)
Hash8K/Sum256-8       219.1µ ± 1%   193.4µ ± 1%  -11.74% (p=0.000 n=10)
geomean               24.93µ        22.28µ       -10.65%

                    │  oldsha256   │              newsha256               │
                    │     B/s      │     B/s       vs base                │
Hash8Bytes/New-8      3.309Mi ± 0%   3.633Mi ± 0%   +9.80% (p=0.000 n=10)
Hash8Bytes/Sum224-8   3.009Mi ± 0%   3.271Mi ± 0%   +8.72% (p=0.000 n=10)
Hash8Bytes/Sum256-8   2.985Mi ± 0%   3.242Mi ± 0%   +8.63% (p=0.000 n=10)
Hash1K/New-8          34.06Mi ± 0%   38.73Mi ± 0%  +13.72% (p=0.000 n=10)
Hash1K/Sum224-8       33.80Mi ± 0%   38.40Mi ± 0%  +13.63% (p=0.000 n=10)
Hash1K/Sum256-8       33.78Mi ± 0%   38.40Mi ± 0%  +13.69% (p=0.000 n=10)
Hash8K/New-8          35.84Mi ± 1%   40.54Mi ± 2%  +13.10% (p=0.000 n=10)
Hash8K/Sum224-8       35.83Mi ± 1%   40.35Mi ± 1%  +12.61% (p=0.000 n=10)
Hash8K/Sum256-8       35.66Mi ± 1%   40.40Mi ± 1%  +13.29% (p=0.000 n=10)
geomean               15.54Mi        17.39Mi       +11.89%

Change-Id: I9aa692fcfd70634dc6c308db9b5d06bd82ac2302
Reviewed-on: https://go-review.googlesource.com/c/go/+/639495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
2025-04-24 17:55:31 -07:00
Mateusz Poliwczak
42d3cdc909 sync/atomic: document that atomic types should not be copied
Change-Id: I3c557d02cd676a389b5c5ea70ed92c8959041e3b
GitHub-Last-Rev: 8732da19a64853834ca155cafc1d7b2967290c31
GitHub-Pull-Request: golang/go#63256
Reviewed-on: https://go-review.googlesource.com/c/go/+/531375
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>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Sean Liao <sean@liao.dev>
2025-04-24 16:10:59 -07:00
changwang ma
da64b60c7e runtime: fix typo in comment
Change-Id: I85f518e36c18f4f0eda8b167750b43cd8c48ecff
Reviewed-on: https://go-review.googlesource.com/c/go/+/622675
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-24 15:19:23 -07:00
Keith Randall
67e0681aef cmd/compile: put constant value on node inside parentheses
That's where the unified IR writer expects it.

Fixes #73476

Change-Id: Ic22bd8dee5be5991e6d126ae3f6eccb2acdc0b19
Reviewed-on: https://go-review.googlesource.com/c/go/+/667415
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-24 12:17:27 -07:00
Felix Geisendörfer
3672a09a48 runtime/debug: update SetCrashOutput example to not pass parent env vars
Fixes #73490

Change-Id: I500fa73f4215c7f490779f53c1c2c0d775f51a95
Reviewed-on: https://go-review.googlesource.com/c/go/+/667775
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-04-24 12:01:27 -07:00
Keith Randall
3452d80da3 cmd/compile: add cast in range loop final value computation
When replacing a loop where the iteration variable has a named type,
we need to compute the last iteration value as i = T(len(a)-1), not
just i = len(a)-1.

Fixes #73491

Change-Id: Ic1cc3bdf8571a40c10060f929a9db8a888de2b70
Reviewed-on: https://go-review.googlesource.com/c/go/+/667815
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-24 11:02:26 -07:00
Keith Randall
3009566a46 runtime: fix tag pointers on aix
Clean up tagged pointers a bit. I got the shifts wrong
for the weird aix case.

Change-Id: I21449fd5973f4651fd1103d3b8be9c2b9b93a490
Reviewed-on: https://go-review.googlesource.com/c/go/+/667715
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-24 10:09:19 -07:00
qmuntal
8a8f506516 os,internal/poll: disassociate handle from IOCP in File.Fd
Go 1.25 will gain support for overlapped IO on handles passed to
os.NewFile thanks to CL 662236. It was previously not possible to add
an overlapped handle to the Go runtime's IO completion port (IOCP),
and now happens on the first call the an IO method.

This means that there is code that relies on the fact that File.Fd
returns a handle that can always be associated with a custom IOCP.
That wouldn't be the case anymore, as a handle can only be associated
with one IOCP at a time and it must be explicitly disassociated.

To fix this breaking change, File.Fd will disassociate the handle
from the Go runtime IOCP before returning it. It is then not necessary
to defer the association until the first IO method is called, which
was recently added in CL 661955 to support this same use case, but
in a more complex and unreliable way.

Updates #19098.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race,gotip-windows-amd64-longtest,gotip-windows-arm64
Change-Id: Id8a7e04d35057047c61d1733bad5bf45494b2c28
Reviewed-on: https://go-review.googlesource.com/c/go/+/664455
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-24 06:51:09 -07:00
Keith Randall
c1fc209c41 runtime: use precise bounds of Go data/bss for race detector
We only want to call into the race detector for Go global variables.
By rounding up the region bounds, we can include some C globals.
Even worse, we can include only *part* of a C global, leading to
race{read,write}range calls which straddle the end of shadow memory.
That causes the race detector to barf.

Fix some off-by-one errors in the assembly comparisons. We want to
skip calling the race detector when addr == racedataend.

Fixes #73483

Change-Id: I436b0f588d6165b61f30cb7653016ba9b7cbf585
Reviewed-on: https://go-review.googlesource.com/c/go/+/667655
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2025-04-23 23:22:12 -07:00
Keith Randall
9d0320de25 runtime: align taggable pointers more so we can use low bits for tag
Currently we assume alignment to 8 bytes, so we can steal the low 3 bits.
This CL assumes alignment to 512 bytes, so we can steal the low 9 bits.

That's 6 extra bits!

Aligning to 512 bytes wastes a bit of space but it is not egregious.
Most of the objects that we make tagged pointers to are pretty big.

Update #49405

Change-Id: I66fc7784ac1be5f12f285de1d7851d5a6871fb75
Reviewed-on: https://go-review.googlesource.com/c/go/+/665815
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-23 21:44:50 -07:00
Alan Donovan
702f164ed1 cmd/vet: add hostport analyzer
+ test, release note

Fixes #28308

Change-Id: I190e2fe513eeb6b90b0398841f67bf52510b5f59
Reviewed-on: https://go-review.googlesource.com/c/go/+/667596
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-23 19:09:44 -07:00
Alan Donovan
fca5832607 cmd/vendor: update x/tools and x/text
This CL updates x/tools to 68e94bd and x/text to v0.24.0,
updates the vendor tree, and re-runs the bundle step for net/http.

Updates golang/go#28308

Change-Id: I4184f77547f535270ddc8e2ce6542377e3046ffd
Reviewed-on: https://go-review.googlesource.com/c/go/+/667597
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2025-04-23 15:34:39 -07:00
Nevkontakte
71d9505998 crypto/tls: skip part of the test based on GOOS instead of GOARCH
This allows to skip the last part of the test under GopherJS as well as
WebAssembly, since GopherJS shares GOOS=js with wasm.

Change-Id: I41adad788043c1863b23eb2a6da9bc9aa2833092
GitHub-Last-Rev: d8d42a3b7ccb2bee6479306b6ac1a319443702ec
GitHub-Pull-Request: golang/go#51827
Reviewed-on: https://go-review.googlesource.com/c/go/+/394114
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-23 10:22:11 -07:00
Michael Anthony Knyszek
f1ebad19bd internal/goexperiment: add Green Tea GC goexperiment
Change-Id: Ia3ea5290842d8eddfafad4882f5874a2aff03e94
Reviewed-on: https://go-review.googlesource.com/c/go/+/645935
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-04-23 08:07:17 -07:00
Michael Anthony Knyszek
e90ba1d208 runtime: move some malloc constants to internal/runtime/gc
These constants are needed by some future generator programs.

Change-Id: I5dccd009cbb3b2f321523bc0d8eaeb4c82e5df81
Reviewed-on: https://go-review.googlesource.com/c/go/+/655276
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-23 08:06:33 -07:00
Michael Anthony Knyszek
528bafa049 runtime: move sizeclass defs to new package internal/runtime/gc
We will want to reference these definitions from new generator programs,
and this is a good opportunity to cleanup all these old C-style names.

Change-Id: Ifb06f0afc381e2697e7877f038eca786610c96de
Reviewed-on: https://go-review.googlesource.com/c/go/+/655275
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-04-23 08:00:33 -07:00
limeidan
ecdd429a3b runtime: optimize the function memequal using SIMD on loong64
goos: linux
goarch: loong64
pkg: bytes
cpu: Loongson-3A6000-HV @ 2500.00MHz
                              │      old      │                 new                  │
                              │    sec/op     │    sec/op     vs base                │
Equal/0                          0.4012n ± 0%   0.4003n ± 0%   -0.21% (p=0.000 n=10)
Equal/same/1                      2.555n ± 1%    2.419n ± 0%   -5.32% (p=0.000 n=10)
Equal/same/6                      2.574n ± 1%    2.425n ± 1%   -5.79% (p=0.000 n=10)
Equal/same/9                      2.578n ± 0%    2.419n ± 1%   -6.19% (p=0.000 n=10)
Equal/same/15                     2.565n ± 1%    2.417n ± 0%   -5.73% (p=0.000 n=10)
Equal/same/16                     2.576n ± 1%    2.414n ± 0%   -6.31% (p=0.000 n=10)
Equal/same/20                     2.573n ± 1%    2.416n ± 0%   -6.10% (p=0.000 n=10)
Equal/same/32                     2.559n ± 0%    2.411n ± 0%   -5.80% (p=0.000 n=10)
Equal/same/4K                     2.579n ± 1%    2.410n ± 0%   -6.53% (p=0.000 n=10)
Equal/same/4M                     2.571n ± 0%    2.411n ± 0%   -6.22% (p=0.000 n=10)
Equal/same/64M                    2.568n ± 1%    2.413n ± 0%   -6.05% (p=0.000 n=10)
Equal/1                           5.215n ± 0%    6.404n ± 0%  +22.80% (p=0.000 n=10)
Equal/6                          11.630n ± 0%    6.404n ± 0%  -44.94% (p=0.000 n=10)
Equal/9                          15.240n ± 0%    6.404n ± 0%  -57.98% (p=0.000 n=10)
Equal/15                         22.925n ± 0%    6.404n ± 0%  -72.07% (p=0.000 n=10)
Equal/16                         24.070n ± 0%    5.203n ± 0%  -78.38% (p=0.000 n=10)
Equal/20                         28.880n ± 0%    6.404n ± 0%  -77.83% (p=0.000 n=10)
Equal/32                         43.320n ± 0%    6.404n ± 0%  -85.22% (p=0.000 n=10)
Equal/4K                        4938.50n ± 0%    55.43n ± 0%  -98.88% (p=0.000 n=10)
Equal/4M                         5048.8µ ± 0%    202.0µ ± 0%  -96.00% (p=0.000 n=10)
Equal/64M                        80.819m ± 0%    4.539m ± 0%  -94.38% (p=0.000 n=10)
EqualBothUnaligned/64_0          79.830n ± 0%    4.803n ± 0%  -93.98% (p=0.000 n=10)
EqualBothUnaligned/64_1          79.830n ± 0%    4.803n ± 0%  -93.98% (p=0.000 n=10)
EqualBothUnaligned/64_4          79.830n ± 0%    4.803n ± 0%  -93.98% (p=0.000 n=10)
EqualBothUnaligned/64_7          79.830n ± 0%    4.803n ± 0%  -93.98% (p=0.000 n=10)
EqualBothUnaligned/4096_0       4937.00n ± 0%    65.64n ± 0%  -98.67% (p=0.000 n=10)
EqualBothUnaligned/4096_1       4937.00n ± 0%    78.85n ± 0%  -98.40% (p=0.000 n=10)
EqualBothUnaligned/4096_4       4937.00n ± 0%    78.87n ± 0%  -98.40% (p=0.000 n=10)
EqualBothUnaligned/4096_7       4937.00n ± 0%    78.87n ± 0%  -98.40% (p=0.000 n=10)
EqualBothUnaligned/4194304_0     5049.2µ ± 0%    204.2µ ± 0%  -95.96% (p=0.000 n=10)
EqualBothUnaligned/4194304_1     5049.2µ ± 0%    205.1µ ± 0%  -95.94% (p=0.000 n=10)
EqualBothUnaligned/4194304_4     5049.4µ ± 0%    205.1µ ± 0%  -95.94% (p=0.000 n=10)
EqualBothUnaligned/4194304_7     5049.2µ ± 0%    205.1µ ± 0%  -95.94% (p=0.000 n=10)
EqualBothUnaligned/67108864_0    80.796m ± 0%    3.863m ± 0%  -95.22% (p=0.000 n=10)
EqualBothUnaligned/67108864_1    80.801m ± 0%    3.706m ± 0%  -95.41% (p=0.000 n=10)
EqualBothUnaligned/67108864_4    80.799m ± 0%    3.706m ± 0%  -95.41% (p=0.000 n=10)
EqualBothUnaligned/67108864_7    80.781m ± 0%    3.706m ± 0%  -95.41% (p=0.000 n=10)
geomean                           1.040µ         149.6n       -85.63%

Change-Id: Id4c2bc0ca758337dd9759df83750c761814be488
Reviewed-on: https://go-review.googlesource.com/c/go/+/667255
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-04-23 01:29:52 -07:00
Xiaolin Zhao
93e4e26d5b runtime: fix typos in comments
Change-Id: Id169b68cc93bb6eb4cdca384efaaf971fcfa32b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/666316
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-04-22 18:37:58 -07:00
Carlos Amedee
489917fc40 Revert "runtime: only poll network from one P at a time in findRunnable"
This reverts commit 352dd2d932c1c1c6dbc3e112fcdfface07d4fffb.

Reason for revert: cockroachdb benchmark failing. Likely due to CL 564197.

For #73474

Change-Id: Id5d83cd8bb8fe9ee7fddb8dc01f1a01f2d40154e
Reviewed-on: https://go-review.googlesource.com/c/go/+/667336
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>
2025-04-22 15:49:52 -07:00
1911860538
83b53527fa net/http: replace map lookup with switch for scheme port
Improve scheme port lookup by replacing map with switch, reducing overhead and improving performance.

Change-Id: I45c790da15e237d5f32c50d342b3713b98fd2ffa
GitHub-Last-Rev: 4c02e4cabf181b365fbf2b722e3051625a289527
GitHub-Pull-Request: golang/go#73422
Reviewed-on: https://go-review.googlesource.com/c/go/+/666356
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2025-04-22 13:10:32 -07:00
Mateusz Poliwczak
8a85a2e70a runtime, internal/runtime/maps: speed-up empty/zero map lookups
This lets the inliner do a better job optimizing the mapKeyError call.

goos: linux
goarch: amd64
pkg: runtime
cpu: AMD Ryzen 5 4600G with Radeon Graphics
                                 │ /tmp/before2 │             /tmp/after3             │
                                 │    sec/op    │   sec/op     vs base                │
MapAccessZero/Key=int64-12          1.875n ± 0%   1.875n ± 0%        ~ (p=0.506 n=25)
MapAccessZero/Key=int32-12          1.875n ± 0%   1.875n ± 0%        ~ (p=0.082 n=25)
MapAccessZero/Key=string-12         1.902n ± 1%   1.902n ± 1%        ~ (p=0.256 n=25)
MapAccessZero/Key=mediumType-12     2.816n ± 0%   1.958n ± 0%  -30.47% (p=0.000 n=25)
MapAccessZero/Key=bigType-12        2.815n ± 0%   1.935n ± 0%  -31.26% (p=0.000 n=25)
MapAccessEmpty/Key=int64-12         1.942n ± 0%   2.109n ± 0%   +8.60% (p=0.000 n=25)
MapAccessEmpty/Key=int32-12         2.110n ± 0%   1.940n ± 0%   -8.06% (p=0.000 n=25)
MapAccessEmpty/Key=string-12        2.024n ± 0%   2.109n ± 0%   +4.20% (p=0.000 n=25)
MapAccessEmpty/Key=mediumType-12    3.157n ± 0%   2.344n ± 0%  -25.75% (p=0.000 n=25)
MapAccessEmpty/Key=bigType-12       3.054n ± 0%   2.115n ± 0%  -30.75% (p=0.000 n=25)
geomean                             2.305n        2.011n       -12.75%

Change-Id: Iee83930884dc4c8a791a711aa189a1c93b68d536
Reviewed-on: https://go-review.googlesource.com/c/go/+/663495
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-04-22 11:01:05 -07:00
Keith Randall
7d0cb2a2ad cmd/compile: constant fold 128-bit multiplies
The full 64x64->128 multiply comes up when using bits.Mul64.
The 64x64->64+overflow multiply comes up in unsafe.Slice when using
a constant length.

Change-Id: I298515162ca07d804b2d699d03bc957ca30a4ebc
Reviewed-on: https://go-review.googlesource.com/c/go/+/667175
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-22 10:24:18 -07:00
Rhys Hiltner
7a177114df runtime: commit to spinbitmutex GOEXPERIMENT
Use the "spinbit" mutex implementation always (including on platforms
that need to emulate atomic.Xchg8), and delete the prior "tristate"
implementations.

The exception is GOARCH=wasm, where the Go runtime does not use multiple
threads.

For #68578

Change-Id: Ifc29bbfa05071d776c23a19ae185891a03a82417
Reviewed-on: https://go-review.googlesource.com/c/go/+/658456
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-22 10:00:26 -07:00
Rhys Hiltner
7ce45a014c runtime: fix test of when a mutex is contended
This is used only in tests that verify reports of runtime-internal mutex
contention.

For #66999
For #70602

Change-Id: I72cb1302d8ea0524f1182ec892f5c9a1923cddba
Reviewed-on: https://go-review.googlesource.com/c/go/+/667095
Reviewed-by: Michael Knyszek <mknyszek@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: Junyang Shao <shaojunyang@google.com>
2025-04-22 09:58:32 -07:00
Prabhav Dogra
95611c0eb4 sync: use atomic.Bool for Once.done
Updated the use of atomic.Uint32 to atomic.Bool for sync package.

Change-Id: Ib8da66fea86ef06e1427ac5118016b96fbcda6b1
GitHub-Last-Rev: d36e0f431fcde988f90badf86bbf04a18a411947
GitHub-Pull-Request: golang/go#73447
Reviewed-on: https://go-review.googlesource.com/c/go/+/666895
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2025-04-22 08:28:13 -07:00
Ian Lance Taylor
352dd2d932 runtime: only poll network from one P at a time in findRunnable
For #65064

Change-Id: Ifecd7e332d2cf251750752743befeda4ed396f33
Reviewed-on: https://go-review.googlesource.com/c/go/+/564197
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Artur M. Wolff <artur.m.wolff@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-04-22 02:49:42 -07:00
Keith Randall
336626bac4 cmd/compile: ensure we evaluate side effects of len() arg
For any len() which requires the evaluation of its arg (according to the spec).

Update #72844

Change-Id: Id2b0bcc78073a6d5051abd000131dafdf65e7f26
Reviewed-on: https://go-review.googlesource.com/c/go/+/658097
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-21 15:50:54 -07:00
Keith Randall
8af32240c6 cmd/compile: don't evaluate side effects of range over array
If the thing we're ranging over is an array or ptr to array, and
it doesn't have a function call or channel receive in it, then we
shouldn't evaluate it.

Typecheck the ranged-over value as a constant in that case.
That makes the unified exporter replace the range expression
with a constant int.

Change-Id: I0d4ea081de70d20cf6d1fa8d25ef6cb021975554
Reviewed-on: https://go-review.googlesource.com/c/go/+/659317
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-04-21 15:50:43 -07:00
thepudds
04a9b16f3d cmd/compile/internal/escape: avoid reading ir.Node during inner loop of walkOne
Broadly speaking, escape analysis has two main phases. First, it
traverses the AST while building a data-flow graph of locations and
edges. Second, during "solve", it repeatedly walks the data-flow graph
while carefully propagating information about each location, including
whether a location's address reaches the heap.

Once escape analysis is in the solve phase and repeatedly walking the
data-flow graph, almost all the information it needs is within the
location graph, with a notable exception being the ir.Class of an
ir.Name, which currently must be checked by following a pointer from
the location to its ir.Node.

For typical graphs, that does not matter much, but if the graph becomes
large enough, cache misses in the inner solve loop start to matter more,
and the class is checked many times in the inner loop.

We therefore store the class information on the location in the graph
to reduce how much memory we need to load in the inner loop.

The package github.com/microsoft/typescript-go/internal/checker
has many locations, and compilation currently spends most of its time
in escape analysis.

This CL gives roughly a 30% speedup for wall clock compilation time
for the checker package:

  go1.24.0:      91.79s
  this CL:       64.98s

Linux perf shows a healthy reduction for example in l2_request.miss and
dTLB-load-misses on an amd64 test VM.

We could tweak things a bit more, though initial review feedback
has suggested it would be good to get this in as it stands.

Subsequent CLs in this stack give larger improvements.

Updates #72815

Change-Id: I3117430dff684c99e6da1e0d7763869873379238
Reviewed-on: https://go-review.googlesource.com/c/go/+/657295
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Jake Bailey <jacob.b.bailey@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
2025-04-21 15:44:05 -07:00
Julian Zhu
c0245b31fb crypto/sha512: remove unnecessary move op, replace with direct add
goos: linux
goarch: riscv64
pkg: crypto/sha512
                    │      o      │                 n                  │
                    │   sec/op    │   sec/op     vs base               │
Hash8Bytes/New-4      3.499µ ± 0%   3.444µ ± 0%  -1.56% (p=0.000 n=10)
Hash8Bytes/Sum384-4   4.012µ ± 0%   3.957µ ± 0%  -1.37% (p=0.000 n=10)
Hash8Bytes/Sum512-4   4.218µ ± 0%   4.162µ ± 0%  -1.32% (p=0.000 n=10)
Hash1K/New-4          17.07µ ± 0%   16.57µ ± 0%  -2.97% (p=0.000 n=10)
Hash1K/Sum384-4       17.59µ ± 0%   17.11µ ± 0%  -2.76% (p=0.000 n=10)
Hash1K/Sum512-4       17.78µ ± 0%   17.30µ ± 0%  -2.72% (p=0.000 n=10)
Hash8K/New-4          112.2µ ± 0%   108.7µ ± 0%  -3.08% (p=0.000 n=10)
Hash8K/Sum384-4       112.7µ ± 0%   109.2µ ± 0%  -3.09% (p=0.000 n=10)
Hash8K/Sum512-4       112.9µ ± 0%   109.4µ ± 0%  -3.07% (p=0.000 n=10)
geomean               19.72µ        19.24µ       -2.44%

                    │      o       │                  n                  │
                    │     B/s      │     B/s       vs base               │
Hash8Bytes/New-4      2.184Mi ± 0%   2.213Mi ± 0%  +1.31% (p=0.000 n=10)
Hash8Bytes/Sum384-4   1.898Mi ± 1%   1.926Mi ± 0%  +1.51% (p=0.000 n=10)
Hash8Bytes/Sum512-4   1.812Mi ± 1%   1.831Mi ± 0%  +1.05% (p=0.000 n=10)
Hash1K/New-4          57.20Mi ± 0%   58.95Mi ± 0%  +3.06% (p=0.000 n=10)
Hash1K/Sum384-4       55.51Mi ± 0%   57.09Mi ± 0%  +2.84% (p=0.000 n=10)
Hash1K/Sum512-4       54.91Mi ± 0%   56.44Mi ± 0%  +2.79% (p=0.000 n=10)
Hash8K/New-4          69.63Mi ± 0%   71.84Mi ± 0%  +3.17% (p=0.000 n=10)
Hash8K/Sum384-4       69.30Mi ± 0%   71.52Mi ± 0%  +3.20% (p=0.000 n=10)
Hash8K/Sum512-4       69.19Mi ± 0%   71.39Mi ± 0%  +3.18% (p=0.000 n=10)
geomean               19.65Mi        20.13Mi       +2.45%

Change-Id: Ib68b934276ec08246d4ae60ef9870c233f0eac69
Reviewed-on: https://go-review.googlesource.com/c/go/+/665595
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-04-20 21:03:00 -07:00
Joel Sing
c893e1cf82 crypto/internal/fips140/aes: actually use the VTBL instruction on arm64
Support for the VTBL instruction was added in CL 110015 - use it
directly, rather than using WORD encodings. Note that one of the
WORD encodings does not actually match the instruction in the
comment - use the instruction that matches the existing encoding
instead.

Change-Id: I1933162f8144a6b86b38e8b550d36907131b1dd4
Reviewed-on: https://go-review.googlesource.com/c/go/+/666795
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-20 02:15:23 -07:00
1911860538
a204ed53d9 net: simplify readProtocols via sync.OnceFunc
In this case, using sync.OnceFunc is a better choice.

Change-Id: I52d27b9741265c90300a04a03537020e1aaaaaa7
GitHub-Last-Rev: a281daea255f1508a9042e8c8c7eb7ca1cef2430
GitHub-Pull-Request: golang/go#73434
Reviewed-on: https://go-review.googlesource.com/c/go/+/666635
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2025-04-19 16:11:06 -07:00
Matthew Burton
ad0434200c fs: clarify documentation for ReadDir method
The fs.ReadDir method behaves the same way as
os.ReadDir, in that when n <= 0, ReadDir returns
all DirEntry values remaining in the dictionary.

Update the comment to reflect that only remaining
DirEntry values are returned (not all entries),
for subsequent calls.

Fixes #69301

Change-Id: I41ef7ef1c8e3fe7d64586f5297512697dc60dd40
Reviewed-on: https://go-review.googlesource.com/c/go/+/663215
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-19 16:07:50 -07:00
Russ Cox
a4d0269a4f math/big: use clearer loop bounds check elimination
Checking that the lengths are equal and panicking teaches the compiler
that it can assume “i in range for z” implies “i in range for x”, letting us
simplify the actual loops a bit.

It also turns up a few places in math/big that were playing maybe a little
too fast and loose with slice lengths. Update those to explicitly set all the
input slices to the same length.

These speedups are basically irrelevant, since they only happen
in real code if people are compiling with -tags math_big_pure_go.
But at least the code is clearer.

benchmark \ system                   c3h88    c2s16       s7      386   s7-386   c4as16      mac      arm  loong64  ppc64le  riscv64    s390x
AddVV/words=1/impl=go                    ~  +11.20%   +5.11%   -7.67%   -7.77%   +1.90%  +10.76%  -33.22%        ~  +10.98%        ~   +6.60%
AddVV/words=10/impl=go             -22.12%  -13.48%  -10.37%  -17.95%  -18.07%  -24.58%  -22.04%  -29.95%  -14.22%        ~   -6.33%   +3.66%
AddVV/words=16/impl=go              -9.75%  -13.73%        ~  -21.90%  -18.66%  -30.03%  -20.45%  -28.09%  -17.33%   -7.15%   -8.96%  +12.55%
AddVV/words=100/impl=go             -5.91%   -1.02%        ~  -29.23%  -22.18%  -25.62%   -6.49%  -23.59%  -22.31%   -1.88%  -14.13%   +9.23%
AddVV/words=1000/impl=go            -0.52%   -0.19%   -3.58%  -33.89%  -23.46%  -22.46%        ~  -24.00%  -24.73%   +0.93%  -15.79%  +12.32%
AddVV/words=10000/impl=go                ~        ~        ~  -33.79%  -23.72%  -23.79%   -5.98%  -23.92%        ~   +0.78%  -15.45%   +8.59%
AddVV/words=100000/impl=go               ~        ~        ~  -33.90%  -24.25%  -22.82%   -4.09%  -24.63%        ~   +1.00%  -13.56%        ~
SubVV/words=1/impl=go                    ~  +11.64%  +14.05%        ~   -4.07%        ~  +10.79%  -33.69%        ~        ~   +3.89%  +12.33%
SubVV/words=10/impl=go             -10.31%  -14.09%   -7.38%  +13.76%  -13.25%  -18.05%  -20.08%  -24.97%  -14.15%  +10.13%   -0.97%   -2.51%
SubVV/words=16/impl=go              -8.06%  -13.73%   -5.70%  +17.00%  -12.83%  -23.76%  -17.52%  -25.25%  -17.30%   -2.80%   -4.96%  -18.25%
SubVV/words=100/impl=go             -9.22%   -1.30%   -2.76%  +20.88%  -14.35%  -15.29%   -8.49%  -19.64%  -22.31%   -0.68%  -14.30%   -9.04%
SubVV/words=1000/impl=go            -0.60%        ~   -3.43%  +23.08%  -16.14%  -11.96%        ~  -28.52%  -24.73%        ~  -15.95%   -9.91%
SubVV/words=10000/impl=go                ~        ~        ~  +26.01%  -15.24%  -11.92%        ~  -28.26%   +4.25%        ~  -15.42%   -5.95%
SubVV/words=100000/impl=go               ~        ~        ~  +25.71%  -15.83%  -12.13%        ~  -27.88%   -1.27%        ~  -13.57%   -6.72%
LshVU/words=1/impl=go               +0.56%   +0.36%        ~        ~        ~        ~        ~        ~        ~        ~        ~        ~
LshVU/words=10/impl=go             +13.37%   +4.63%        ~        ~        ~        ~        ~   -2.90%        ~        ~        ~        ~
LshVU/words=16/impl=go             +22.83%   +6.47%        ~        ~        ~        ~        ~        ~   +0.80%        ~        ~   +5.88%
LshVU/words=100/impl=go             +7.56%  +13.95%        ~        ~        ~        ~        ~        ~   +0.33%   -2.50%        ~        ~
LshVU/words=1000/impl=go            +0.64%  +17.92%        ~        ~        ~        ~        ~   -6.52%        ~   -2.58%        ~        ~
LshVU/words=10000/impl=go                ~  +17.60%        ~        ~        ~        ~        ~   -6.64%   -6.22%   -1.40%        ~        ~
LshVU/words=100000/impl=go               ~  +14.57%        ~        ~        ~        ~        ~        ~   -5.47%        ~        ~        ~
RshVU/words=1/impl=go                    ~        ~        ~        ~        ~        ~        ~        ~        ~        ~        ~   +2.72%
RshVU/words=10/impl=go                   ~        ~        ~        ~        ~        ~        ~   +2.50%        ~        ~        ~        ~
RshVU/words=16/impl=go                   ~   +0.53%        ~        ~        ~        ~        ~   +3.82%        ~        ~        ~        ~
RshVU/words=100/impl=go                  ~        ~        ~        ~        ~        ~        ~   +6.18%        ~        ~        ~        ~
RshVU/words=1000/impl=go                 ~        ~        ~        ~        ~        ~        ~   +7.00%        ~        ~        ~        ~
RshVU/words=10000/impl=go                ~        ~        ~        ~        ~        ~        ~        ~        ~        ~        ~        ~
RshVU/words=100000/impl=go               ~        ~        ~        ~        ~        ~        ~   +7.05%        ~        ~        ~        ~
MulAddVWW/words=1/impl=go          -10.34%   +4.43%  +10.62%   -1.62%   -4.74%   -2.86%  +11.75%        ~   -8.00%   +8.89%   +3.87%        ~
MulAddVWW/words=10/impl=go          -1.61%   -5.87%        ~   -8.30%   -4.55%   +0.87%        ~   -5.28%  -20.82%        ~        ~   -2.32%
MulAddVWW/words=16/impl=go          -2.96%   -5.28%        ~   -9.22%   -5.28%        ~        ~   -3.74%  -19.52%   -1.48%   -2.53%   -9.52%
MulAddVWW/words=100/impl=go         -3.89%   -7.53%   +1.93%  -10.49%   -4.87%   -8.27%        ~        ~   -0.65%   -0.61%   -7.59%  -20.61%
MulAddVWW/words=1000/impl=go        -0.45%   -3.91%   +4.54%  -11.46%   -4.69%   -8.53%        ~        ~   -0.05%        ~   -8.88%  -19.77%
MulAddVWW/words=10000/impl=go            ~   -3.30%   +4.10%  -11.34%   -4.10%   -9.43%        ~   -0.61%        ~   -0.55%   -8.21%  -18.48%
MulAddVWW/words=100000/impl=go      -0.30%   -3.03%   +4.31%  -11.55%   -4.41%   -9.74%        ~   -0.75%   +0.63%        ~   -7.80%  -19.82%
AddMulVVWW/words=1/impl=go               ~  +13.09%  +12.50%   -7.05%  -10.41%   +2.53%  +13.32%   -3.49%        ~  +15.56%   +3.62%        ~
AddMulVVWW/words=10/impl=go        -15.96%   -9.06%   -5.06%  -14.56%  -11.83%   -5.44%  -26.30%  -14.23%  -11.44%   -1.79%   -5.93%   -6.60%
AddMulVVWW/words=16/impl=go        -19.05%  -12.43%   -6.19%  -14.24%  -12.67%   -8.65%  -18.64%  -16.56%  -10.64%   -3.00%   -7.61%  -12.80%
AddMulVVWW/words=100/impl=go       -22.13%  -16.59%  -13.04%  -13.79%  -11.46%  -12.01%   -6.46%  -21.80%   -5.08%   -3.13%  -13.60%  -22.53%
AddMulVVWW/words=1000/impl=go      -17.07%  -17.05%  -14.08%  -13.59%  -12.13%  -11.21%        ~  -22.81%   -4.27%   -1.27%  -16.35%  -23.47%
AddMulVVWW/words=10000/impl=go     -15.03%  -16.78%  -14.23%  -13.86%  -11.84%  -11.69%        ~  -22.75%  -13.39%   -1.10%  -14.37%  -22.01%
AddMulVVWW/words=100000/impl=go    -13.70%  -14.90%  -14.26%  -13.55%  -12.04%  -11.63%        ~  -22.61%        ~   -2.53%  -10.42%  -23.16%

Change-Id: Ic6f64344484a762b818c7090d1396afceb638607
Reviewed-on: https://go-review.googlesource.com/c/go/+/665155
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-04-19 08:19:27 -07:00
Russ Cox
7f516a31b0 math/big: replace assembly with mini-compiler output
Step 4 of the mini-compiler: switch to the new generated assembly.
No systematic performance regressions, and many many improvements.

In the benchmarks, the systems are:

	c3h88     GOARCH=amd64     c3h88 perf gomote (newer Intel, Google Cloud)
	c2s16     GOARCH=amd64     c2s16 perf gomote (Intel, Google Cloud)
	s7        GOARCH=amd64     rsc basement server (AMD Ryzen 9 7950X)
	386       GOARCH=386       gotip-linux-386 gomote (Intel, Google Cloud)
	s7-386    GOARCH=386       rsc basement server (AMD Ryzen 9 7950X)
	c4as16    GOARCH=arm64     c4as16 perf gomote (Google Cloud)
	mac       GOARCH=arm64     Apple M3 Pro in MacBook Pro
	arm       GOARCH=arm       gotip-linux-arm gomote
	loong64   GOARCH=loong64   gotip-linux-loong64 gomote
	ppc64le   GOARCH=ppc64le   gotip-linux-ppc64le gomote
	riscv64   GOARCH=riscv64   gotip-linux-riscv64 gomote
	s390x     GOARCH=s390x     linux-s390x-ibm old gomote

benchmark \ system           c3h88    c2s16       s7      386   s7-386   c4as16      mac      arm  loong64  ppc64le  riscv64    s390x
AddVV/words=1               -4.03%   +5.21%   -4.04%   +4.94%        ~        ~        ~        ~  -19.51%        ~        ~        ~
AddVV/words=10             -10.20%   +0.34%   -3.46%  -11.50%   -7.46%   +7.66%   +5.97%        ~  -17.90%        ~        ~        ~
AddVV/words=16             -10.91%   -6.45%   -8.45%  -21.86%  -17.90%   +2.73%   -1.61%        ~  -22.47%   -3.54%        ~        ~
AddVV/words=100             -3.77%   -4.30%   -3.17%  -47.27%  -45.34%   -0.78%        ~   -8.74%  -27.19%        ~        ~        ~
AddVV/words=1000            -0.08%   -0.71%        ~  -49.21%  -48.07%        ~        ~  -16.80%  -24.74%        ~        ~        ~
AddVV/words=10000                ~        ~        ~  -48.73%  -48.56%   -0.06%        ~  -17.08%        ~        ~   -4.81%        ~
AddVV/words=100000               ~        ~        ~  -47.80%  -48.38%        ~        ~  -15.10%  -25.06%        ~   -5.34%        ~
SubVV/words=1               -0.84%   +3.43%   -3.62%   +1.34%        ~   -0.76%        ~        ~  -18.18%   +5.58%        ~        ~
SubVV/words=10              -9.99%   +0.34%        ~  -11.23%   -8.24%   +7.53%   +6.15%        ~  -17.55%   +2.77%   -2.08%        ~
SubVV/words=16             -11.94%   -6.45%   -6.81%  -21.82%  -18.11%   +1.58%   -1.21%        ~  -20.36%        ~        ~        ~
SubVV/words=100             -3.38%   -4.32%   -1.80%  -46.14%  -46.43%   +0.41%        ~   -7.20%  -26.17%        ~   -0.42%        ~
SubVV/words=1000            -0.38%   -0.80%        ~  -49.22%  -48.90%        ~        ~  -15.86%  -24.73%        ~        ~        ~
SubVV/words=10000                ~        ~        ~  -49.57%  -49.64%   -0.03%        ~  -15.85%  -26.52%        ~   -5.05%        ~
SubVV/words=100000               ~        ~        ~  -46.88%  -49.66%        ~        ~  -15.45%  -16.11%        ~   -4.99%        ~
LshVU/words=1                    ~   +5.78%        ~        ~   -2.48%   +1.61%   +2.18%   +2.70%  -18.16%  -34.16%  -21.29%        ~
LshVU/words=10             -18.34%   -3.78%   +2.21%        ~        ~   -2.81%  -12.54%        ~  -25.02%  -24.78%  -38.11%  -66.98%
LshVU/words=16             -23.15%   +1.03%   +7.74%   +0.73%        ~   +8.88%   +1.56%        ~  -25.37%  -28.46%  -41.27%        ~
LshVU/words=100            -32.85%   -8.86%   -2.58%        ~   +2.69%   +1.24%        ~  -20.63%  -44.14%  -42.68%  -53.09%        ~
LshVU/words=1000           -37.30%   -0.20%   +5.67%        ~        ~   +1.44%        ~  -27.83%  -45.01%  -37.07%  -57.02%  -46.57%
LshVU/words=10000          -36.84%   -2.30%   +3.82%        ~   +1.86%   +1.57%  -66.81%  -28.00%  -13.15%  -35.40%  -41.97%        ~
LshVU/words=100000         -40.30%        ~   +3.96%        ~        ~        ~        ~  -24.91%  -19.06%  -36.14%  -40.99%  -66.03%
RshVU/words=1               -3.17%   +4.76%   -4.06%   +4.31%   +4.55%        ~        ~        ~  -20.61%        ~  -26.20%  -51.33%
RshVU/words=10             -22.08%   -4.41%  -17.99%   +3.64%  -11.87%        ~  -16.30%        ~  -30.01%        ~  -40.37%  -63.05%
RshVU/words=16             -26.03%   -8.50%  -18.09%        ~  -17.52%   +6.50%        ~   -2.85%  -30.24%        ~  -42.93%  -63.13%
RshVU/words=100            -20.87%  -28.83%  -29.45%        ~  -26.25%   +1.46%   -1.14%  -16.20%  -45.65%  -16.20%  -53.66%  -77.27%
RshVU/words=1000           -24.03%  -21.37%  -26.71%        ~  -28.95%   +0.98%        ~  -18.82%  -45.21%  -23.55%  -57.09%  -71.18%
RshVU/words=10000          -24.56%  -22.44%  -27.01%        ~  -28.88%   +0.78%   -5.35%  -17.47%  -16.87%  -20.67%  -41.97%        ~
RshVU/words=100000         -23.36%  -15.65%  -27.54%        ~  -29.26%   +1.73%   -6.67%  -13.68%  -21.40%  -23.02%  -40.37%  -66.31%
MulAddVWW/words=1           +2.37%   +8.14%        ~   +4.10%   +3.71%        ~        ~        ~  -21.62%        ~   +1.12%        ~
MulAddVWW/words=10               ~   -2.72%  -15.15%   +8.04%        ~        ~        ~   -2.52%  -19.48%        ~   -6.18%        ~
MulAddVWW/words=16               ~   +1.49%        ~   +4.49%   +6.58%   -8.70%   -7.16%  -12.08%  -21.43%   -6.59%   -9.05%        ~
MulAddVWW/words=100         +0.37%   +1.11%   -4.51%  -13.59%        ~  -11.10%   -3.63%  -21.40%  -22.27%   -2.92%  -14.41%        ~
MulAddVWW/words=1000             ~   +0.90%   -7.13%  -18.94%        ~  -14.02%   -9.97%  -28.31%  -18.72%   -2.32%  -15.80%        ~
MulAddVWW/words=10000            ~   +1.08%   -6.75%  -19.10%        ~  -14.61%   -9.04%  -28.48%  -14.29%   -2.25%   -9.40%        ~
MulAddVWW/words=100000           ~        ~   -6.93%  -18.09%        ~  -14.33%   -9.66%  -28.92%  -16.63%   -2.43%   -8.23%        ~
AddMulVVWW/words=1          +2.30%   +4.83%  -11.37%   +4.58%        ~   -3.14%        ~        ~  -10.58%  +30.35%        ~        ~
AddMulVVWW/words=10         -3.27%        ~   +8.96%   +5.74%        ~   +2.67%   -1.44%   -7.64%  -13.41%        ~        ~        ~
AddMulVVWW/words=16         -6.12%        ~        ~        ~   +1.91%   -7.90%  -16.22%  -14.07%  -14.26%   -4.15%   -7.30%        ~
AddMulVVWW/words=100        -5.48%   -2.14%        ~   -9.40%   +9.98%   -1.43%  -12.35%  -18.56%  -21.94%        ~   -9.84%        ~
AddMulVVWW/words=1000      -11.35%   -3.40%   -3.64%  -11.04%  +12.82%   -1.33%  -15.63%  -20.50%  -20.95%        ~  -11.06%  -51.97%
AddMulVVWW/words=10000     -10.31%   -1.61%   -8.41%  -12.15%  +13.10%   -1.03%  -16.34%  -22.46%   -1.00%        ~  -10.33%  -49.80%
AddMulVVWW/words=100000    -13.71%        ~   -8.31%  -12.18%  +12.98%   -1.35%  -15.20%  -21.89%        ~        ~   -9.38%  -48.30%

Change-Id: I0a33c33602c0d053c84d9946e662500cfa048e2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/664938
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-19 08:19:23 -07:00
Russ Cox
39070da4f8 math/big: add shift and mul to mini-compiler
Step 3 of the mini-compiler: add the generators for the shift and mul routines.

Change-Id: I981d5b7086262c740036f5db768d3e63083984e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/664937
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-19 08:19:20 -07:00
Russ Cox
2a88106617 math/big: add all architectures to mini-compiler
Step 2 of the mini-compiler: add all the remaining architectures.

Change-Id: I8c5283aa8baa497785a5c15f2248528fa9ae886e
Reviewed-on: https://go-review.googlesource.com/c/go/+/664936
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2025-04-19 08:19:17 -07:00
Russ Cox
8cc98a04ef math/big: new mini-compiler for arith assembly
The arith assembly is big enough, and the details that you have to keep
in mind are complex enough and varied enough, that it is worth using
a Go program to generate the assembly. That way, all the architectures
can use the same algorithms, and porting to new architectures will be
easier.

This is the first of a sequence of CLs to introduce a new mini-compiler
for generating the arith assembly, in math/big/internal/asmgen.
This CL has the basics of the compiler as well as a couple simple
architectures and the generator for addVV/subVV. It does not check
in the generated assembly yet. That will happen in a followup CL after
the other architectures and generators have been added.

Change-Id: Ib704c60fd972fc5690ac04d8fae3712ee2c1a80a
Reviewed-on: https://go-review.googlesource.com/c/go/+/664935
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2025-04-19 08:19:14 -07:00
Russ Cox
a11643df8f math/big: replace addVW/subVW assembly with fast pure Go
The vast majority of the time, carry propagation is limited and
addVW/subVW only need to consider a single word for carry propagation.
As Josh Bleecher-Snyder pointed out in 2019 (CL 164968), once carrying
is done, the remaining words can be handled faster with copy (memmove).
In the benchmarks below, this is the data=random case.

Even more important, if the source and destination are the same,
the copy can be optimized away entirely, making a small in-place
addition to a big.Int O(1) instead of O(N). To date, only a few
systems (amd64, arm64, and pure Go, meaning wasm) make use of this
asymptotic improvement. This is the data=shortcut case.

This CL deletes the addVW/subVW assembly and replaces it with
an optimized pure Go version. Using Go makes it easy to call
the real copy builtin, which will use optimized memmove code,
instead of recreating a worse memmove in assembly (as arm64 does)
or omitting the copy optimization entirely (as most others do).

The worst case for the Go version versus assembly is the case
of incrementing 2^N-1 by 1, which has to propagate a carry
the entire length of the array. This is the data=carry case.
On balance, we believe this case is rare enough to be worth
taking a hit in that case, in exchange for significant wins
in the other cases and the deletion of significant amounts of
assembly of varying quality. (Remember that half the assembly has
the copy optimization and shortcut, while half does not.)

In the benchmarks, the systems are:

	c2s16     GOARCH=amd64     c2s16 perf gomote (Intel, Google Cloud)
	c3h88     GOARCH=amd64     c3h88 perf gomote (newer Intel, Google Cloud)
	s7        GOARCH=amd64     rsc basement server (AMD Ryzen 9 7950X)
	c4as16    GOARCH=arm64     c4as16 perf gomote (Google Cloud)
	mac       GOARCH=arm64     Apple M3 Pro in MacBook Pro
	386       GOARCH=386       gotip-linux-386 gomote
	arm       GOARCH=arm       gotip-linux-arm gomote
	loong64   GOARCH=loong64   gotip-linux-loong64 gomote
	ppc64le   GOARCH=ppc64le   gotip-linux-ppc64le gomote
	riscv64   GOARCH=riscv64   gotip-linux-riscv64 gomote

benchmark \ system                    c2s16     c3h88       s7    c4as16       mac       386      arm  loong64   ppc64le  riscv64

AddVW/words=1/data=random            -1.15%    -1.74%   -5.89%    -9.80%   -11.54%   +23.71%  -12.74%  -14.25%   +14.67%  +10.27%
AddVW/words=2/data=random            -2.59%         ~   -4.38%   -19.31%   -15.41%   +24.80%        ~  -19.99%   +13.73%  +19.71%
AddVW/words=3/data=random            -3.75%   -19.10%   -3.79%   -23.15%   -17.04%   +20.04%  -10.07%  -23.20%         ~  +15.39%
AddVW/words=4/data=random            -2.84%    +7.05%   -8.77%   -22.64%   -15.77%   +16.01%   -7.36%  -28.22%         ~  +23.00%
AddVW/words=5/data=random           -10.97%    +2.16%  -12.09%   -20.89%   -17.14%    +9.42%   -4.69%  -32.60%         ~  +10.07%
AddVW/words=6/data=random            -9.87%         ~   -7.54%   -19.08%    -6.46%         ~   -3.44%  -34.61%         ~  +12.19%
AddVW/words=7/data=random           -14.36%         ~  -10.09%   -19.10%   -10.47%    -6.20%   -5.06%  -38.14%   -11.54%   +6.79%
AddVW/words=8/data=random           -17.50%         ~  -11.06%   -25.14%   -12.88%    -8.35%   -5.11%  -41.39%   -14.04%  +11.87%
AddVW/words=9/data=random           -19.76%    -4.05%  -15.47%   -24.08%   -16.50%   -12.34%  -21.56%  -44.25%   -14.82%        ~
AddVW/words=10/data=random          -13.89%         ~   -9.69%   -23.06%    -8.04%   -12.58%  -19.25%  -32.80%   -11.68%        ~
AddVW/words=16/data=random          -29.36%   -15.35%  -21.86%   -25.04%   -19.89%   -32.26%  -16.29%  -42.66%   -25.92%   -3.01%
AddVW/words=32/data=random          -39.02%   -28.76%  -39.87%   -11.22%    -2.85%   -55.40%  -31.17%  -55.37%   -37.92%  -16.28%
AddVW/words=64/data=random          -25.94%   -19.09%  -20.60%    -6.90%    +8.91%   -51.00%  -43.72%  -62.27%   -44.11%  -28.74%
AddVW/words=100/data=random         -22.79%   -18.13%  -18.25%         ~   +33.89%   -67.40%  -51.77%  -63.54%   -53.75%  -30.97%
AddVW/words=1000/data=random         -8.98%    -3.84%        ~    -3.15%         ~   -93.35%  -63.92%  -65.66%   -68.67%  -42.30%
AddVW/words=10000/data=random        -1.38%    -0.38%        ~         ~         ~   -89.16%  -65.18%  -44.65%   -70.35%  -20.08%
AddVW/words=100000/data=random            ~         ~        ~         ~         ~   -87.03%  -64.51%  -36.08%   -61.40%  -16.53%

SubVW/words=1/data=random            -3.67%         ~   -8.38%   -10.26%    -3.07%   +45.78%   -6.06%  -11.17%         ~        ~
SubVW/words=2/data=random            -3.48%   -10.07%   -5.76%   -20.14%    -8.45%   +44.28%        ~  -19.09%         ~  +16.98%
SubVW/words=3/data=random            -7.11%   -26.64%   -4.48%   -22.07%    -9.21%   +35.61%        ~  -23.93%   -18.20%        ~
SubVW/words=4/data=random            -4.23%    +7.19%   -8.95%   -22.62%   -13.89%   +33.20%   -8.96%  -29.96%         ~  +22.23%
SubVW/words=5/data=random           -11.49%    +1.92%  -10.86%   -22.27%   -17.53%   +24.48%   -2.88%  -35.19%   -19.55%        ~
SubVW/words=6/data=random            -7.67%         ~   -7.72%   -18.44%    -6.24%   +12.03%   -2.00%  -39.68%   -10.73%        ~
SubVW/words=7/data=random           -13.69%   -18.32%  -11.82%   -18.92%   -11.57%    +6.63%        ~  -43.54%   -30.81%        ~
SubVW/words=8/data=random           -16.02%         ~  -11.07%   -24.50%   -11.92%    +4.32%   -3.01%  -46.95%   -24.14%        ~
SubVW/words=9/data=random           -18.76%    -3.34%  -14.84%   -23.79%   -17.50%         ~  -21.80%  -49.98%   -29.62%        ~
SubVW/words=10/data=random          -13.23%         ~   -9.25%   -21.26%   -11.63%         ~  -18.58%  -39.19%   -20.09%        ~
SubVW/words=16/data=random          -28.25%   -13.24%  -22.66%   -27.18%   -19.13%   -23.38%  -20.24%  -51.01%   -28.06%   -3.05%
SubVW/words=32/data=random          -38.41%   -28.88%  -40.12%   -11.20%    -2.80%   -49.17%  -34.67%  -63.29%   -39.25%  -15.20%
SubVW/words=64/data=random          -25.51%   -19.24%  -22.20%    -6.57%    +9.98%   -48.52%  -48.14%  -69.50%   -49.44%  -27.92%
SubVW/words=100/data=random         -21.69%   -18.51%        ~    +1.92%   +34.42%   -65.88%  -54.67%  -71.24%   -58.88%  -30.71%
SubVW/words=1000/data=random         -9.81%    -4.05%   -2.14%    -3.06%         ~   -93.37%  -67.33%  -74.12%   -68.36%  -42.17%
SubVW/words=10000/data=random             ~    -0.52%        ~         ~         ~   -88.87%  -68.54%  -44.94%   -70.63%  -19.95%
SubVW/words=100000/data=random            ~         ~        ~         ~         ~   -86.69%  -68.09%  -48.36%   -62.42%  -19.32%

AddVW/words=1/data=shortcut         -29.38%   -25.38%  -27.37%   -23.15%   -25.41%    +3.01%  -33.60%  -36.12%   -15.76%        ~
AddVW/words=2/data=shortcut         -32.79%   -34.72%  -31.47%   -24.47%   -28.21%    -3.75%  -34.66%  -43.89%   -23.65%  -21.56%
AddVW/words=3/data=shortcut         -38.50%   -46.83%  -35.67%   -26.38%   -30.29%   -10.41%  -44.89%  -47.68%   -30.93%  -26.85%
AddVW/words=4/data=shortcut         -40.40%   -28.85%  -34.19%   -29.83%   -32.95%   -16.09%  -42.86%  -51.02%   -34.19%  -26.69%
AddVW/words=5/data=shortcut         -43.87%   -35.42%  -36.46%   -32.59%   -37.72%   -20.82%  -45.14%  -54.01%   -35.49%  -30.48%
AddVW/words=6/data=shortcut         -46.98%   -39.34%  -42.22%   -35.43%   -38.18%   -27.46%  -46.72%  -56.61%   -40.21%  -34.07%
AddVW/words=7/data=shortcut         -49.63%   -47.97%  -46.61%   -35.28%   -41.93%   -31.14%  -49.29%  -58.89%   -41.10%  -37.01%
AddVW/words=8/data=shortcut         -50.48%   -42.33%  -45.40%   -40.24%   -41.74%   -32.92%  -50.62%  -60.98%   -44.85%  -38.10%
AddVW/words=9/data=shortcut         -54.27%   -43.52%  -49.06%   -42.16%   -45.22%   -37.57%  -51.84%  -62.91%   -46.04%  -40.82%
AddVW/words=10/data=shortcut        -56.01%   -45.40%  -51.42%   -43.29%   -46.14%   -38.65%  -53.65%  -64.62%   -47.05%  -43.21%
AddVW/words=16/data=shortcut        -62.73%   -55.66%  -59.31%   -56.38%   -54.31%   -53.16%  -61.03%  -72.29%   -58.24%  -52.57%
AddVW/words=32/data=shortcut        -74.00%   -69.42%  -71.75%   -33.65%   -37.35%   -71.73%  -72.59%  -82.44%   -70.87%  -67.69%
AddVW/words=64/data=shortcut        -56.69%   -52.72%  -52.09%   -35.48%   -36.87%   -84.24%  -83.10%  -90.37%   -82.56%  -80.81%
AddVW/words=100/data=shortcut       -56.68%   -53.18%  -51.49%   -33.49%   -37.72%   -89.95%  -88.21%  -93.37%   -88.47%  -86.52%
AddVW/words=1000/data=shortcut      -56.68%   -52.45%  -51.66%   -35.31%   -36.65%   -98.88%  -98.62%  -99.24%   -98.78%  -98.41%
AddVW/words=10000/data=shortcut     -56.70%   -52.40%  -51.92%   -33.49%   -36.98%   -99.89%  -99.86%  -99.92%   -99.87%  -99.91%
AddVW/words=100000/data=shortcut    -56.67%   -52.46%  -52.38%   -35.31%   -37.20%   -99.99%  -99.99%  -99.99%   -99.99%  -99.99%

SubVW/words=1/data=shortcut         -29.80%   -20.71%  -26.94%   -23.24%   -25.33%   +26.97%  -32.02%  -37.85%   -40.20%  -12.67%
SubVW/words=2/data=shortcut         -35.47%   -36.38%  -31.93%   -25.43%   -30.18%   +18.96%  -33.48%  -46.48%   -39.38%  -18.65%
SubVW/words=3/data=shortcut         -39.22%   -49.96%  -36.90%   -25.82%   -30.96%   +12.53%  -40.67%  -51.07%   -43.71%  -23.78%
SubVW/words=4/data=shortcut         -40.46%   -24.90%  -34.66%   -29.87%   -33.97%    +4.60%  -42.32%  -54.92%   -42.83%  -22.45%
SubVW/words=5/data=shortcut         -43.84%   -34.17%  -38.00%   -32.55%   -37.27%    -2.46%  -43.09%  -58.18%   -45.70%  -26.45%
SubVW/words=6/data=shortcut         -47.69%   -37.49%  -42.73%   -35.90%   -37.73%    -8.52%  -46.55%  -61.01%   -44.00%  -30.14%
SubVW/words=7/data=shortcut         -49.45%   -50.66%  -46.88%   -34.77%   -41.64%   -14.46%  -48.92%  -63.46%   -50.47%  -33.39%
SubVW/words=8/data=shortcut         -50.45%   -39.31%  -47.14%   -40.47%   -41.70%   -15.77%  -50.21%  -65.64%   -47.71%  -34.01%
SubVW/words=9/data=shortcut         -54.28%   -43.07%  -49.42%   -41.34%   -44.99%   -19.39%  -51.55%  -67.61%   -56.92%  -36.82%
SubVW/words=10/data=shortcut        -56.85%   -47.88%  -50.92%   -42.76%   -45.67%   -23.60%  -53.04%  -69.34%   -60.18%  -39.43%
SubVW/words=16/data=shortcut        -62.36%   -54.83%  -58.80%   -55.83%   -53.74%   -41.04%  -60.16%  -76.75%   -60.56%  -48.63%
SubVW/words=32/data=shortcut        -73.68%   -68.64%  -71.57%   -33.52%   -37.34%   -64.73%  -72.67%  -85.89%   -71.87%  -64.56%
SubVW/words=64/data=shortcut        -56.68%   -51.66%  -52.56%   -34.75%   -37.54%   -80.30%  -83.58%  -92.39%   -83.41%  -78.70%
SubVW/words=100/data=shortcut       -56.68%   -50.97%  -51.57%   -33.68%   -36.78%   -87.42%  -88.53%  -94.84%   -88.87%  -84.96%
SubVW/words=1000/data=shortcut      -56.68%   -50.89%  -52.10%   -34.94%   -37.77%   -98.59%  -98.71%  -99.43%   -98.80%  -98.20%
SubVW/words=10000/data=shortcut     -56.68%   -51.00%  -52.44%   -33.65%   -37.27%   -99.86%  -99.87%  -99.94%   -99.88%  -99.90%
SubVW/words=100000/data=shortcut    -56.68%   -50.80%  -52.20%   -34.79%   -37.46%   -99.99%  -99.99%  -99.99%   -99.99%  -99.99%

AddVW/words=1/data=carry             -0.51%    -5.29%  -24.03%   -26.48%         ~         ~  -33.14%  -30.23%         ~  -20.74%
AddVW/words=2/data=carry             -6.36%         ~  -21.05%   -39.40%         ~   +10.72%  -29.12%  -31.34%         ~  -17.29%
AddVW/words=3/data=carry                  ~         ~  -17.46%   -19.53%   +17.58%         ~  -26.23%  -23.61%    +7.80%  -14.34%
AddVW/words=4/data=carry            +19.02%   +16.80%        ~         ~   +28.25%         ~  -27.90%  -20.31%   +19.16%        ~
AddVW/words=5/data=carry             +3.97%   +53.02%        ~         ~   +11.31%         ~  -19.05%  -17.47%   +16.81%        ~
AddVW/words=6/data=carry             +2.98%   +19.83%        ~         ~   +14.84%         ~  -18.48%  -14.92%   +18.25%        ~
AddVW/words=7/data=carry                  ~         ~        ~         ~   +27.17%         ~  -15.50%  -12.74%   +13.00%        ~
AddVW/words=8/data=carry             +0.58%   +22.32%        ~    +6.10%   +29.63%         ~  -13.04%        ~   +28.46%   +2.95%
AddVW/words=9/data=carry                  ~   +31.53%        ~         ~   +14.42%         ~  -11.32%        ~   +18.37%   +3.28%
AddVW/words=10/data=carry            +3.94%   +22.36%        ~    +6.29%   +19.22%         ~  -11.27%        ~   +20.10%   +3.91%
AddVW/words=16/data=carry            +2.82%   +14.23%        ~   +10.06%   +25.91%   -16.12%        ~        ~   +52.28%  +10.40%
AddVW/words=32/data=carry                 ~   +25.35%  +13.66%         ~   +34.89%   -34.39%   +6.51%  -18.71%   +41.06%  +19.42%
AddVW/words=64/data=carry           -42.03%         ~  -39.70%    +6.65%   +32.29%   -39.94%  +14.34%        ~   +19.68%  +20.86%
AddVW/words=100/data=carry          -33.95%   -34.28%  -39.65%         ~   +27.72%   -26.80%  +17.40%        ~   +26.39%  +23.32%
AddVW/words=1000/data=carry         -42.49%   -47.87%  -47.44%    +1.25%    +4.25%   -41.76%  +23.40%        ~   +25.48%  +27.99%
AddVW/words=10000/data=carry        -41.85%   -48.49%  -49.43%         ~         ~   -42.09%  +24.61%  -10.32%   +40.55%  +18.35%
AddVW/words=100000/data=carry       -28.18%   -48.13%  -48.24%    +1.35%         ~   -42.90%  +24.73%   -9.79%   +22.55%  +17.16%

SubVW/words=1/data=carry            -10.32%   -17.16%  -24.14%   -26.24%         ~   +18.43%  -34.10%  -29.54%    -9.57%        ~
SubVW/words=2/data=carry            -19.45%   -23.31%  -20.74%   -39.73%         ~   +15.74%  -28.13%  -30.21%         ~  -18.74%
SubVW/words=3/data=carry                  ~   -16.18%  -15.34%   -19.54%   +17.62%   +12.39%  -27.64%  -27.09%         ~  -14.97%
SubVW/words=4/data=carry            +11.67%   +24.42%        ~         ~   +25.11%   +14.07%  -28.08%  -26.18%         ~        ~
SubVW/words=5/data=carry             +8.08%   +25.64%        ~         ~   +10.35%    +8.12%  -21.75%  -25.50%         ~   -4.86%
SubVW/words=6/data=carry                  ~   +13.82%        ~         ~   +12.92%    +6.79%  -20.25%  -24.70%         ~   -2.74%
SubVW/words=7/data=carry                  ~         ~   +8.29%    +4.51%   +26.59%    +4.62%  -18.01%  -24.09%         ~   -1.26%
SubVW/words=8/data=carry                  ~   +23.16%  +16.19%    +6.16%   +25.46%    +6.74%  -15.57%  -22.74%         ~   +1.44%
SubVW/words=9/data=carry                  ~   +30.71%  +20.81%         ~   +12.36%         ~  -12.99%        ~         ~   +3.13%
SubVW/words=10/data=carry            +5.03%   +19.53%  +14.84%   +14.16%   +16.12%         ~  -11.64%  -16.00%   +15.45%   +3.29%
SubVW/words=16/data=carry           +14.42%   +15.58%  +33.07%   +11.43%   +24.65%         ~        ~  -21.90%   +25.59%   +9.40%
SubVW/words=32/data=carry                 ~   +27.57%  +46.58%         ~   +35.35%    -8.49%        ~  -24.04%   +11.86%  +18.40%
SubVW/words=64/data=carry           -24.34%   -27.83%  -20.90%   +13.34%   +37.17%   -14.90%        ~   -8.81%   +12.88%  +18.92%
SubVW/words=100/data=carry          -25.19%   -34.70%  -27.45%   +12.86%   +28.42%   -14.48%        ~        ~   +25.71%  +21.93%
SubVW/words=1000/data=carry         -24.93%   -47.86%  -47.26%    +2.66%         ~   -23.88%        ~        ~   +25.99%  +27.81%
SubVW/words=10000/data=carry        -24.17%   -36.48%  -49.41%    +1.06%         ~   -25.06%        ~  -26.50%   +27.94%  +18.36%
SubVW/words=100000/data=carry       -22.51%   -35.86%  -49.46%    +3.96%         ~   -25.18%        ~  -22.15%   +26.86%  +15.44%

Change-Id: I8f252073040e674780ac6ec9912082fb205329dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/664898
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-18 15:07:59 -07:00
Russ Cox
b44b360dd4 math/big: add more complete tests and benchmarks of assembly
Also fix a few real but currently harmless bugs from CL 664895.
There were a few places that were still wrong if z != x or if a != 0.

Change-Id: Id8971e2505523bc4708780c82bf998a546f4f081
Reviewed-on: https://go-review.googlesource.com/c/go/+/664897
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-04-18 14:14:06 -07:00
Russ Cox
930cf59ba8 regexp/syntax: recognize category aliases like \p{Letter}
The Unicode specification defines aliases for some of the general
category names. For example the category "L" has alias "Letter".

The regexp package supports \p{L} but not \p{Letter}, because there
was nothing in the Unicode tables that lets regexp know about Letter.
Now that package unicode provides CategoryAliases (see #70780),
we can use it to provide \p{Letter} as well.

This is the only feature missing from making package regexp suitable
for use in a JSON-API Schema implementation. (The official test suite
includes usage of aliases like \p{Letter} instead of \p{L}.)

For better conformity with Unicode TR18, also accept case-insensitive
matches for names and ignore underscores, hyphens, and spaces;
and add Any, ASCII, and Assigned.

Fixes #70781.

Change-Id: I50ff024d99255338fa8d92663881acb47f1e92a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/641377
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-04-18 14:13:38 -07:00
Russ Cox
28fd9fa8a6 unicode: add CategoryAliases, Cn, LC
CategoryAliases is for regexp to use, for things like \p{Letter} as an alias for \p{L}.
Cn and LC are special-case categories that were never implemented
but should have been.

These changes were generated by the updated generator in CL 641395.

Fixes #70780.

Change-Id: Ibba20ff76191c8ae9631ac5ba19965790fe0cc81
Reviewed-on: https://go-review.googlesource.com/c/go/+/641376
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-04-18 14:13:31 -07:00
Michael Pratt
252c939445 internal/runtime/maps: move tombstone test to swiss file
This test fails on GOEXPERIMENT=noswissmap as it is testing behavior
specific to swissmaps. Move it to map_swiss_test.go to skip it on
noswissmap.

We could also switch the test to use NewTestMap, which provides a
swissmap even in GOEXPERIMENT=noswissmap, but that is tedious to use and
noswissmap is going away soon anyway.

For #70886.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-noswissmap
Change-Id: I6a6a636c5ec72217d936cd01e9da36ae127ea2c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/666437
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-18 08:30:30 -07:00
Damien Neil
0e17905793 encoding/json: add json/v2 with GOEXPERIMENT=jsonv2 guard
This imports the proposed new v2 JSON API implemented in
github.com/go-json-experiment/json as of commit
d3c622f1b874954c355e60c8e6b6baa5f60d2fed.

When GOEXPERIMENT=jsonv2 is set, the encoding/json/v2 and
encoding/jsontext packages are visible, the encoding/json
package is implemented in terms of encoding/json/v2, and
the encoding/json package include various additional APIs.
(See #71497 for details.)

When GOEXPERIMENT=jsonv2 is not set, the new API is not
present and the encoding/json package is unchanged.

The experimental API is not bound by the Go compatibility
promise and is expected to evolve as updates are made to
the json/v2 proposal.

The contents of encoding/json/internal/jsontest/testdata
are compressed with zstd v1.5.7 with the -19 option.

Fixes #71845
For #71497

Change-Id: Ib8c94e5f0586b6aaa22833190b41cf6ef59f4f01
Reviewed-on: https://go-review.googlesource.com/c/go/+/665796
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>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-18 08:24:07 -07:00
apocelipes
c889004615 internal,runtime: use the builtin clear
To simplify the code.

Change-Id: I023de705504c0b580718eec3c7c563b6cf2c8184
GitHub-Last-Rev: 026b32c799b13d0c7ded54f2e61429e6c5ed0aa8
GitHub-Pull-Request: golang/go#73412
Reviewed-on: https://go-review.googlesource.com/c/go/+/666118
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>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-04-18 04:21:17 -07:00
apocelipes
8a8efafa88 cmd/compile: use the builtin clear
To simplify the code a bit.

Change-Id: Ia72f576de59ff161ec389a4992bb635f89783540
GitHub-Last-Rev: eaec8216be964418a085649fcca53a042f28ce1a
GitHub-Pull-Request: golang/go#73411
Reviewed-on: https://go-review.googlesource.com/c/go/+/666117
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-04-18 04:21:12 -07:00
qmuntal
b89988c5ca internal/poll: remove outdated tests
TestFileFdsAreInitialised and TestSerialFdsAreInitialised were added
to ensure handles passed to os.NewFile were not added to the runtime
poller. This used to be problematic because the poller could crash
if an external I/O event was received (see #21172).

This is not an issue anymore since CL 482495 and #19098.

Change-Id: I292ceae27724fefe6f438a398ebfe351dd5231d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/665315
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-04-17 22:15:25 -07:00
Keith Randall
05ed8a00e0 internal/runtime/maps: prune tombstones in maps before growing
Before growing, if there are lots of tombstones try to remove them.
If we can remove enough, we can continue at the given size for a
while longer.

Fixes #70886

Change-Id: I71e0d873ae118bb35798314ec25e78eaa5340d73
Reviewed-on: https://go-review.googlesource.com/c/go/+/640955
Reviewed-by: Michael Pratt <mpratt@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>
2025-04-17 09:45:34 -07:00
Philip Roberts
7b263895f7 database/sql: wake cleaner if maxIdleTime set to less than maxLifetime
The existing implementation wouldn't wake the connection cleaner if
maxIdleTime was set to a value less than maxLifetime while an existing
connection was open - resulting in idle connections not being discarded
until after the first maxLifetime had passed.

Fixes #45993

Change-Id: I074ed7ba9803354c8b3a41f2625ae0d8a7d5059b
GitHub-Last-Rev: 0d149d8d38bc9c2ad42a2a20dcfc73994d54fe23
GitHub-Pull-Request: golang/go#58490
Reviewed-on: https://go-review.googlesource.com/c/go/+/467655
Auto-Submit: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-04-16 22:57:52 -07:00
Sean Liao
3cefe69c5a crypto/rand: add and update examples
Change-Id: I77406c22b82c9f8bc57323c783f63c4897486e7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/665096
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-04-16 16:10:00 -07:00
zxc111
ae5a5132eb net/http: add test for proxyAuth
Change-Id: Ib4edae749ce8da433e992e08a90c9cf3d4357081
GitHub-Last-Rev: 19d87d12ab6b299b37e8907429f4dff52ab53745
GitHub-Pull-Request: golang/go#46102
Reviewed-on: https://go-review.googlesource.com/c/go/+/318690
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-16 15:01:40 -07:00
1911860538
548dcfea1a net/url: clarify why @ is allowed in userinfo
Add comment to clarify why '@' is allowed in validUserinfo func.

Change-Id: Ia9845bc40fea6c34093434d57bb1be4ddbc70b84
GitHub-Last-Rev: ce65168ab03afd879ad028de295f6adb7ee1c97d
GitHub-Pull-Request: golang/go#73195
Reviewed-on: https://go-review.googlesource.com/c/go/+/663455
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2025-04-16 15:01:23 -07:00
Eric Young
5ab9d96604 crypto/tls: fix a testing deadlock that occurs on a TLS protocol error
A Go routine was, on an error, returning without sending a message on its
signaling channel, so the main program was blocking forever waiting for
a message that was never sent. Found while breaking crypto/tls.

Change-Id: Id0b3c070a27cabd852f74e86bb9eff5c66b86d28
GitHub-Last-Rev: 4d84fb8b556589ec98eba6142a553fbd45683b96
GitHub-Pull-Request: golang/go#53216
Reviewed-on: https://go-review.googlesource.com/c/go/+/410274
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: 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-16 14:07:41 -07:00
Marcel Meyer
5715d73559 all: use strings.ReplaceAll where applicable
```
find . \
-not -path './.git/*' \
-not -path './test/*' \
-not -path './src/cmd/vendor/*' \
-not -wholename './src/strings/example_test.go' \
-type f \
-exec \
sed -i -E 's/strings\.Replace\((.+), -1\)/strings\.ReplaceAll\(\1\)/g' {} \;
```

Change-Id: I59e2e91b3654c41a32f17dd91ec56f250198f0d6
GitHub-Last-Rev: 0868b1eccc945ca62a5ed0e56a4054994d4bd659
GitHub-Pull-Request: golang/go#73370
Reviewed-on: https://go-review.googlesource.com/c/go/+/665395
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>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-04-16 12:26:29 -07:00
najeira
2cb9e7f68f crypto/cipher: use AEAD.NonceSize to make nonce in the example
The existing example uses hard-coded constant to make nonce buffer.
Using AEAD.NonceSize makes it a more portable and appropriate example.

Fixes: #48372

Change-Id: I7c7a38ed48aff46ca11ef4f5654c778eac13dde6
GitHub-Last-Rev: 03ccbb16df4ca9cbd4a014836aee0f54b2ff3002
GitHub-Pull-Request: golang/go#48373
Reviewed-on: https://go-review.googlesource.com/c/go/+/349603
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-04-16 08:45:29 -07:00
Weidi Deng
5413abc440 net/http: set Request.TLS when net.Conn implements ConnectionState
Fixes #56104

Change-Id: I8fbbb00379e51323e2782144070cbcad650eb6f1
GitHub-Last-Rev: 62d7a8064e4f2173f0d8e02ed91a7e8de7f13fca
GitHub-Pull-Request: golang/go#56110
Reviewed-on: https://go-review.googlesource.com/c/go/+/440795
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-16 07:05:57 -07:00
Keith Randall
786e62bcd3 runtime: don't use cgo_unsafe_args for syscall9 wrapper
It uses less stack space this way.

Similar to CL 386719
Update #71302

Change-Id: I585bde5f681a90a6900cbd326994ab8a122fd148
Reviewed-on: https://go-review.googlesource.com/c/go/+/665695
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>
2025-04-15 23:25:16 -07:00
Keith Randall
9d7de04838 runtime: fix 9-arg syscall on darwin/amd64
The last 3 arguments need to be passed on the stack, not registers.

Fixes #71302

Change-Id: Ib1155ad1a805957fad3d9594c93981a558755591
Reviewed-on: https://go-review.googlesource.com/c/go/+/665435
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-15 23:25:01 -07:00
thepudds
2c9689ab0e cmd/compile/internal/escape: add hash for bisecting stack allocation of variable-sized makeslice
CL 653856 enabled stack allocation of variable-sized makeslice results.

This CL adds debug hashing of that change, plus a debug flag
to control the byte threshold used.

The debug hashing machinery means we also now have a way to disable just
the CL 653856 optimization by doing -gcflags='all=-d=variablemakehash=n'
or similar, though the stderr output will then typically have many
lines of debug hash output.

Using this CL plus the bisect command, I was able to retroactively
find one of the lines of code responsible for #73199:

  $ bisect -compile=variablemake go test -skip TestListWireGuardDrivers
  [...]
  bisect: FOUND failing change set
  --- change set #1 (enabling changes causes failure)
  ./security_windows.go:1321:38 (variablemake)
  ./security_windows.go:1321:38 (variablemake)
  ---

Previously, I had tracked down those lines by diffing '-gcflags=-m=1'
output and brief code inspection, but seeing the bisect was very nice.

This CL also adds a compiler debug flag to control the threshold for
stack allocation of variably sized make results. This can help
us identify more code that is relying on certain stack allocations.
This might be a temporary flag that we delete prior to Go 1.25
(given we would not want people to rely on it), or maybe it
might make sense to keep it for some period of time beyond the release
of Go 1.25 to help the ecosystem shake out other bugs.

Using these two flags together (and picking a threshold of 64 rather
than the default of 32), it looks for example like this
x/sys/windows code might be relying on stack allocation of
a byte slice:

  $ bisect -compile=variablemake go test -gcflags=-d=variablemakethreshold=64 -skip TestListWireGuardDrivers
  [...]
  bisect: FOUND failing change set
  --- change set #1 (enabling changes causes failure)
  ./syscall_windows_test.go:1178:16 (variablemake)

Updates #73199
Fixes #73253

Change-Id: I160179a0e3c148c3ea86be5c9b6cea8a52c3e5b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/663795
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
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>
2025-04-15 20:19:42 -07:00
Constantin Konstantinidis
30aca0674e strings: duplicate alignment test from bytes package
Fixes #26129

Change-Id: If98f85b458990dbff7ecfeaea6c81699dafa66ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/665275
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
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-15 19:24:07 -07:00
Keith Randall
f4803ddc2c math/big: fix loong64 assembly for vet
Vet is failing on this code because some arguments of mulAddVWW
got renamed in the go decl (CL 664895) but not the assembly accessors.

Looks like the assembly got written before that CL but checked in
after that CL.

Change-Id: I270e8db5f8327aa2029c21a126fab1231a3506a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/665717
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2025-04-15 19:23:32 -07:00
Damien Neil
2869d55366 net/http: test intended behavior in TestClientInsecureTransport
This test wasn't testing the HTTP/2 case, because it didn't
set NextProtos in the tls.Config.

Set "Connection: close" on requests to make sure each request
gets a new connection.

Change-Id: I1ef470e7433a602ce88da7bd7eeec502687ea857
Reviewed-on: https://go-review.googlesource.com/c/go/+/655676
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-04-15 15:55:28 -07:00
Damien Neil
64371adcf4 cmd/go/internal/imports: remove test dependency on json internals
TestScan loads encoding/json and verifies that various imports
match expectations. The new v2 encoding/json violates these
expectations. Since this test is testing the ScanDir function,
not encoding/json, change it to use a test package with defined
imports instead.

Change-Id: I68a0813ccf37daadbd6ea52872a8ac132141e82a
Reviewed-on: https://go-review.googlesource.com/c/go/+/665795
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Bypass: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2025-04-15 15:43:46 -07:00
Lin Lin
fcd73b0ac3 cmd/compile/internal/importer: correct a matching error
Change-Id: I2499d6ef1df0cc6bf0be8903ce64c03e1f296d19
GitHub-Last-Rev: 1f759d89be7b40c7fe72b920fc004de3fed8d057
GitHub-Pull-Request: golang/go#73064
Reviewed-on: https://go-review.googlesource.com/c/go/+/660978
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-15 13:05:15 -07:00
Damien Neil
79b809afb3 os: handle trailing slashes in os.RemoveDir on Windows
CL 661575 inadvertently caused os.RemoveDir on Windows to
fail when given a path with a trailing / or \, due to the
splitPath function not correctly stripping trailing
separators.

Fixes #73317

Change-Id: I21977b94bb08ff1e563de6f5f16a4bdf5024a15e
Reviewed-on: https://go-review.googlesource.com/c/go/+/664715
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-04-15 11:17:39 -07:00
Huang Qiqi
396a48bea6 math/big: optimize subVV function for loong64
Benchmark results on Loongson 3C5000 (which is an LA464 implementation):

goos: linux
goarch: loong64
pkg: math/big
cpu: Loongson-3C5000 @ 2200.00MHz
             │ test/old_3c5000_subvv.log │      test/new_3c5000_subvv.log      │
             │          sec/op           │   sec/op     vs base                │
SubVV/1                     10.920n ± 0%   7.657n ± 0%  -29.88% (p=0.000 n=20)
SubVV/2                     14.100n ± 0%   8.841n ± 0%  -37.30% (p=0.000 n=20)
SubVV/3                      16.38n ± 0%   11.06n ± 0%  -32.48% (p=0.000 n=20)
SubVV/4                      18.65n ± 0%   12.85n ± 0%  -31.10% (p=0.000 n=20)
SubVV/5                      20.93n ± 0%   14.79n ± 0%  -29.34% (p=0.000 n=20)
SubVV/10                     32.30n ± 0%   22.29n ± 0%  -30.99% (p=0.000 n=20)
SubVV/100                    244.3n ± 0%   149.2n ± 0%  -38.93% (p=0.000 n=20)
SubVV/1000                   2.292µ ± 0%   1.378µ ± 0%  -39.88% (p=0.000 n=20)
SubVV/10000                  26.26µ ± 0%   25.64µ ± 0%   -2.33% (p=0.000 n=20)
SubVV/100000                 341.3µ ± 0%   238.0µ ± 0%  -30.26% (p=0.000 n=20)
geomean                      209.1n        144.5n       -30.86%

Change-Id: I3863c2c6728f1b0f8fecbf77de13254299c5b1cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/659877
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-15 04:56:52 -07:00
Huang Qiqi
72fa8adbdc math/big: optimize mulAddVWW function for loong64
Benchmark results on Loongson 3A5000 (which is an LA464 implementation):

goos: linux
goarch: loong64
pkg: math/big
cpu: Loongson-3A5000-HV @ 2500.00MHz
                 │ test/old_3a5000_muladdvww.log │    test/new_3a5000_muladdvww.log    │
                 │            sec/op             │   sec/op     vs base                │
MulAddVWW/1                          7.606n ± 0%   6.987n ± 0%   -8.14% (p=0.000 n=20)
MulAddVWW/2                          9.207n ± 0%   8.567n ± 0%   -6.95% (p=0.000 n=20)
MulAddVWW/3                         10.810n ± 0%   9.223n ± 0%  -14.68% (p=0.000 n=20)
MulAddVWW/4                          13.01n ± 0%   12.41n ± 0%   -4.61% (p=0.000 n=20)
MulAddVWW/5                          15.79n ± 0%   12.99n ± 0%  -17.73% (p=0.000 n=20)
MulAddVWW/10                         25.62n ± 0%   20.02n ± 0%  -21.86% (p=0.000 n=20)
MulAddVWW/100                        217.0n ± 0%   170.9n ± 0%  -21.24% (p=0.000 n=20)
MulAddVWW/1000                       2.064µ ± 0%   1.612µ ± 0%  -21.90% (p=0.000 n=20)
MulAddVWW/10000                      24.50µ ± 0%   16.74µ ± 0%  -31.66% (p=0.000 n=20)
MulAddVWW/100000                     239.1µ ± 0%   171.1µ ± 0%  -28.45% (p=0.000 n=20)
geomean                              159.2n        130.3n       -18.18%

Change-Id: I063434bc382f4f1234f879172ab671a3d6f2eb80
Reviewed-on: https://go-review.googlesource.com/c/go/+/659881
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-15 04:56:20 -07:00
Huang Qiqi
24daaeea09 math/big: optimize subVW function for loong64
Benchmark results on Loongson 3C5000 (which is an LA464 implementation):

goos: linux
goarch: loong64
pkg: math/big
cpu: Loongson-3C5000 @ 2200.00MHz
                │ test/old_3c5000_subvw.log │      test/new_3c5000_subvw.log      │
                │          sec/op           │   sec/op     vs base                │
SubVW/1                         8.564n ± 0%   5.915n ± 0%  -30.93% (p=0.000 n=20)
SubVW/2                        11.675n ± 0%   6.825n ± 0%  -41.54% (p=0.000 n=20)
SubVW/3                        13.410n ± 0%   7.969n ± 0%  -40.57% (p=0.000 n=20)
SubVW/4                        15.300n ± 0%   9.740n ± 0%  -36.34% (p=0.000 n=20)
SubVW/5                         17.34n ± 1%   10.66n ± 0%  -38.55% (p=0.000 n=20)
SubVW/10                        26.55n ± 0%   15.21n ± 0%  -42.70% (p=0.000 n=20)
SubVW/100                       199.2n ± 0%   102.5n ± 0%  -48.52% (p=0.000 n=20)
SubVW/1000                     1866.5n ± 1%   924.6n ± 0%  -50.46% (p=0.000 n=20)
SubVW/10000                     17.67µ ± 2%   12.04µ ± 2%  -31.83% (p=0.000 n=20)
SubVW/100000                    186.4µ ± 0%   132.0µ ± 0%  -29.17% (p=0.000 n=20)
SubVWext/1                      8.616n ± 0%   5.949n ± 0%  -30.95% (p=0.000 n=20)
SubVWext/2                     11.410n ± 0%   7.008n ± 1%  -38.58% (p=0.000 n=20)
SubVWext/3                     13.255n ± 1%   8.073n ± 0%  -39.09% (p=0.000 n=20)
SubVWext/4                     15.095n ± 0%   9.893n ± 0%  -34.47% (p=0.000 n=20)
SubVWext/5                      16.87n ± 0%   10.86n ± 0%  -35.63% (p=0.000 n=20)
SubVWext/10                     26.00n ± 0%   15.54n ± 0%  -40.22% (p=0.000 n=20)
SubVWext/100                    196.0n ± 0%   104.3n ± 1%  -46.76% (p=0.000 n=20)
SubVWext/1000                  1847.0n ± 0%   923.7n ± 0%  -49.99% (p=0.000 n=20)
SubVWext/10000                  17.30µ ± 1%   11.71µ ± 1%  -32.31% (p=0.000 n=20)
SubVWext/100000                 187.5µ ± 0%   131.6µ ± 0%  -29.82% (p=0.000 n=20)
geomean                         159.7n        97.79n       -38.79%

Change-Id: I21a6903e79b02cb22282e80c9bfe2ae9f1a87589
Reviewed-on: https://go-review.googlesource.com/c/go/+/659878
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
2025-04-15 04:56:10 -07:00
Huang Qiqi
2fe0330cd7 math/big: optimize addVW function for loong64
Benchmark results on Loongson 3C5000 (which is an LA464 implementation):

goos: linux
goarch: loong64
pkg: math/big
cpu: Loongson-3C5000 @ 2200.00MHz
                │ test/old_3c5000_addvw.log │      test/new_3c5000_addvw.log      │
                │          sec/op           │   sec/op     vs base                │
AddVW/1                         9.555n ± 0%   5.915n ± 0%  -38.09% (p=0.000 n=20)
AddVW/2                        11.370n ± 0%   6.825n ± 0%  -39.97% (p=0.000 n=20)
AddVW/3                        12.485n ± 0%   7.970n ± 0%  -36.16% (p=0.000 n=20)
AddVW/4                        14.980n ± 0%   9.718n ± 0%  -35.13% (p=0.000 n=20)
AddVW/5                         16.73n ± 0%   10.63n ± 0%  -36.46% (p=0.000 n=20)
AddVW/10                        24.57n ± 0%   15.18n ± 0%  -38.23% (p=0.000 n=20)
AddVW/100                       184.9n ± 0%   102.4n ± 0%  -44.62% (p=0.000 n=20)
AddVW/1000                     1721.0n ± 0%   921.4n ± 0%  -46.46% (p=0.000 n=20)
AddVW/10000                     16.83µ ± 0%   11.68µ ± 0%  -30.58% (p=0.000 n=20)
AddVW/100000                    184.7µ ± 0%   131.3µ ± 0%  -28.93% (p=0.000 n=20)
AddVWext/1                      9.554n ± 0%   5.915n ± 0%  -38.09% (p=0.000 n=20)
AddVWext/2                     11.370n ± 0%   6.825n ± 0%  -39.97% (p=0.000 n=20)
AddVWext/3                     12.505n ± 0%   7.969n ± 0%  -36.27% (p=0.000 n=20)
AddVWext/4                     14.980n ± 0%   9.718n ± 0%  -35.13% (p=0.000 n=20)
AddVWext/5                      16.70n ± 0%   10.63n ± 0%  -36.33% (p=0.000 n=20)
AddVWext/10                     24.54n ± 0%   15.18n ± 0%  -38.13% (p=0.000 n=20)
AddVWext/100                    185.0n ± 0%   102.4n ± 0%  -44.65% (p=0.000 n=20)
AddVWext/1000                  1721.0n ± 0%   921.4n ± 0%  -46.46% (p=0.000 n=20)
AddVWext/10000                  16.83µ ± 0%   11.68µ ± 0%  -30.60% (p=0.000 n=20)
AddVWext/100000                 184.9µ ± 0%   130.4µ ± 0%  -29.51% (p=0.000 n=20)
geomean                         155.5n        96.87n       -37.70%

Change-Id: I824a90cb365e09d7d0d4a2c53ff4b30cf057a75e
Reviewed-on: https://go-review.googlesource.com/c/go/+/659876
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-15 04:55:58 -07:00
Xiaolin Zhao
b8ed752d6f internal/chacha8rand: implement func block in assembly
Benchmark result on Loongson-3A6000:
goos: linux
goarch: loong64
pkg: math/rand/v2 + internal/chacha8rand
cpu: Loongson-3A6000-HV @ 2500.00MHz
                         |  bench.old   |              bench.new              |
                         |    sec/op    |   sec/op     vs base                |
ChaCha8MarshalBinary        67.39n ± 0%   65.96n ± 0%   -2.12% (p=0.000 n=10)
ChaCha8MarshalBinaryRead    80.93n ± 0%   78.31n ± 0%   -3.23% (p=0.000 n=10)
ChaCha8                    10.610n ± 0%   5.129n ± 0%  -51.66% (p=0.000 n=10)
ChaCha8Read                 51.30n ± 0%   28.05n ± 0%  -45.31% (p=0.000 n=10)
Block                      218.50n ± 0%   45.48n ± 0%  -79.19% (p=0.000 n=10)
geomean                     57.86n        32.05n       -44.62%

Benchmark result on Loongson-3A5000:
goos: linux
goarch: loong64
pkg: math/rand/v2 + internal/chacha8rand
cpu: Loongson-3A5000 @ 2500.00MHz
                         |  bench.old   |              bench.new              |
                         |    sec/op    |   sec/op     vs base                |
ChaCha8MarshalBinary        116.3n ± 0%   116.6n ± 0%   +0.26% (p=0.015 n=10)
ChaCha8MarshalBinaryRead    142.6n ± 0%   142.0n ± 0%   -0.39% (p=0.000 n=10)
ChaCha8                    16.270n ± 0%   6.848n ± 0%  -57.91% (p=0.000 n=10)
ChaCha8Read                 78.65n ± 0%   47.39n ± 1%  -39.74% (p=0.000 n=10)
Block                      301.50n ± 0%   91.85n ± 0%  -69.53% (p=0.000 n=10)
geomean                     91.45n        54.79n       -40.09%

Change-Id: I64d80c81d2df288fecff80ae23ef89f0fb54cdfa
Reviewed-on: https://go-review.googlesource.com/c/go/+/664035
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-15 04:54:59 -07:00
limeidan
005d7f29d1 cmd/internal/obj/loong64: add support for {V,XV}SET{EQ,NE}Z.V series instructions
Change-Id: If3794dfde3ff461662c8a493ff51d0c779e81bca
Reviewed-on: https://go-review.googlesource.com/c/go/+/664795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-15 04:54:50 -07:00
Alex S
57508059e8 encoding/json: correct method comment to reflect actual argument
Change-Id: I0e9040ee5b84463f0391e8e4ae1b64a036867913
GitHub-Last-Rev: 859c82a254f49fa4b5376c0e8fff6f62f5131f62
GitHub-Pull-Request: golang/go#73123
Reviewed-on: https://go-review.googlesource.com/c/go/+/662015
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
2025-04-15 04:38:58 -07:00
Dmitrii Martynov
e0dba45c62 runtime: size field for gQueue and gList
Before CL, all instances of gQueue and gList stored the size of
structures in a separate variable. The size changed manually and passed
as a separate argument to different functions. This CL added an
additional field to gQueue and gList structures to store the size. Also,
the calculation of size was moved into the implementation of API for
these structures. This allows to reduce possible errors by eliminating
manual calculation of the size and simplifying functions' signatures.

Change-Id: I087da2dfaec4925e4254ad40fce5ccb4c175ec41
Reviewed-on: https://go-review.googlesource.com/c/go/+/664777
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
2025-04-15 02:33:12 -07:00
Achille Roussel
ba7b8ca336 iter: reduce memory footprint of iter.Pull functions
The implementation of iter.Pull and iter.Pull2 functions is based on
closures and sharing local state, which results in one heap allocation
for each captured variable.

The number of heap allocations can be reduced by grouping the state
shared between closures in a struct, allowing the compiler to allocate
all local variables in a single heap region instead of creating
individual heap objects for each variable.

This approach can sometimes have downsides when it couples unrelated
objects in a single memory region, preventing the garbage collector from
reclaiming unused memory. While technically only a subset of the local
state is shared between the next and stop functions, it seems unlikely
that retaining the rest of the state until stop is reclaimed would be
problematic in practice, since the two closures would often have very
similar lifetimes.

The change also reduces the total memory footprint due to alignment
rules, the two booleans can be packed in memory and sometimes can even
exist within the padding space of the v value. There is also less
metadata needed for the garbage collector to track each individual heap
allocation.

goos: darwin
goarch: arm64
pkg: iter
cpu: Apple M2 Pro
         │ /tmp/bench.old │           /tmp/bench.new            │
         │     sec/op     │   sec/op     vs base                │
Pull-12       218.6n ± 7%   146.1n ± 0%  -33.19% (p=0.000 n=10)
Pull2-12      239.8n ± 5%   155.0n ± 5%  -35.36% (p=0.000 n=10)
geomean       229.0n        150.5n       -34.28%

         │ /tmp/bench.old │           /tmp/bench.new           │
         │      B/op      │    B/op     vs base                │
Pull-12        288.0 ± 0%   176.0 ± 0%  -38.89% (p=0.000 n=10)
Pull2-12       312.0 ± 0%   176.0 ± 0%  -43.59% (p=0.000 n=10)
geomean        299.8        176.0       -41.29%

         │ /tmp/bench.old │           /tmp/bench.new           │
         │   allocs/op    │ allocs/op   vs base                │
Pull-12       11.000 ± 0%   5.000 ± 0%  -54.55% (p=0.000 n=10)
Pull2-12      12.000 ± 0%   5.000 ± 0%  -58.33% (p=0.000 n=10)
geomean        11.49        5.000       -56.48%

Change-Id: Iccbe233e8ae11066087ffa4781b66489d0d410a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/552375
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-14 15:10:49 -07:00
fanzha02
adf21a9b56 internal/cpu: add a detection for Neoverse(N3, V3, V3ae) cores
The memmove implementation relies on the variable
runtime.arm64UseAlignedLoads to select fastest code
path. Considering Neoverse N3, V3 and V3ae cores
prefer aligned loads, this patch adds code to detect
them for memmove performance.

Change-Id: I7266fc35d8b2c15ff516c592b987bafacb82b620
Reviewed-on: https://go-review.googlesource.com/c/go/+/664038
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-14 09:26:16 -07:00
Keith Randall
e278a789b6 path: add Join benchmark
This is a case where CL 653856 saves an allocation.

        │     old     │                 new                 │
        │   sec/op    │   sec/op     vs base                │
Join-24   73.57n ± 1%   60.27n ± 1%  -18.07% (p=0.000 n=10)

        │    old     │                new                 │
        │    B/op    │    B/op     vs base                │
Join-24   48.00 ± 0%   24.00 ± 0%  -50.00% (p=0.000 n=10)

        │    old     │                new                 │
        │ allocs/op  │ allocs/op   vs base                │
Join-24   2.000 ± 0%   1.000 ± 0%  -50.00% (p=0.000 n=10)

Change-Id: I56308262ca73a7ab9698b54fd8681f5b44626995
Reviewed-on: https://go-review.googlesource.com/c/go/+/665075
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>
2025-04-14 08:06:30 -07:00
dmathieu
80bff42fdd errors: optimize errors.Join for single unwrappable errors
Change-Id: I10bbb782ca7234cda8c82353f2255eec5be588c9
GitHub-Last-Rev: e5ad8fdb802e56bb36c41b4982ed27c1e0809af8
GitHub-Pull-Request: golang/go#70770
Reviewed-on: https://go-review.googlesource.com/c/go/+/635115
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: 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>
2025-04-14 06:49:08 -07:00
James Tucker
0c0d257241 internal/poll: disable SIO_UDP_NETRESET on Windows
Disable the reception of NET_UNREACHABLE (TTL expired) message reporting
on UDP sockets to match the default behavior of sockets on other
plaforms.

See https://learn.microsoft.com/en-us/windows/win32/winsock/winsock-ioctls#sio_udp_netreset

This is similar to, but a different case from the prior change 3114bd6 /
https://golang.org/issue/5834 that disabled one of the two flags
influencing behavior in response to the reception of related ICMP.

Updates #5834
Updates #68614

Change-Id: I39bc77ab68f5edfc14514d78870ff4a24c0f645e
GitHub-Last-Rev: 78f073bac226aeca438b64acc2c66f76c25f29f8
GitHub-Pull-Request: golang/go#68615
Reviewed-on: https://go-review.googlesource.com/c/go/+/601397
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>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2025-04-14 05:51:58 -07:00
qmuntal
f414dfe4f5 os,internal/poll: support I/O on overlapped files not added to the poller
This fixes the support for I/O on overlapped files that are not added to
the poller. Note that CL 661795 already added support for that, but it
really only worked for pipes, not for plain files.

Additionally, this CL also makes this kind of I/O operations to not
notify the external poller to avoid confusing it.

Updates #15388.

Change-Id: I15c6ea74f3a87960aef0986598077b6eab9b9c99
Reviewed-on: https://go-review.googlesource.com/c/go/+/664415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2025-04-14 05:40:53 -07:00
Guoqi Chen
13b7c7d8d2 runtime: optimize the function memmove using SIMD on loong64
goos: linux
goarch: loong64
pkg: runtime
cpu: Loongson-3A6000 @ 2500.00MHz
                                 |  bench.old   |            bench.new                |
                                 |    sec/op    |   sec/op     vs base                |
Memmove/256                        10.215n ± 0%   6.407n ± 0%  -37.28% (p=0.000 n=10)
Memmove/512                        16.940n ± 0%   8.694n ± 0%  -48.68% (p=0.000 n=10)
Memmove/1024                        29.64n ± 0%   15.22n ± 0%  -48.65% (p=0.000 n=10)
Memmove/2048                        55.42n ± 0%   28.03n ± 0%  -49.43% (p=0.000 n=10)
Memmove/4096                       106.55n ± 0%   53.65n ± 0%  -49.65% (p=0.000 n=10)
MemmoveOverlap/256                  11.01n ± 0%   10.84n ± 0%   -1.54% (p=0.000 n=10)
MemmoveOverlap/512                  17.41n ± 0%   15.09n ± 0%  -13.35% (p=0.000 n=10)
MemmoveOverlap/1024                 30.23n ± 0%   28.70n ± 0%   -5.08% (p=0.000 n=10)
MemmoveOverlap/2048                 55.87n ± 0%   42.84n ± 0%  -23.32% (p=0.000 n=10)
MemmoveOverlap/4096                107.10n ± 0%   87.90n ± 0%  -17.93% (p=0.000 n=10)
MemmoveUnalignedDst/256            16.665n ± 1%   9.611n ± 0%  -42.33% (p=0.000 n=10)
MemmoveUnalignedDst/512             24.75n ± 0%   11.81n ± 0%  -52.29% (p=0.000 n=10)
MemmoveUnalignedDst/1024            43.25n ± 0%   20.46n ± 1%  -52.68% (p=0.000 n=10)
MemmoveUnalignedDst/2048            75.68n ± 0%   39.64n ± 0%  -47.61% (p=0.000 n=10)
MemmoveUnalignedDst/4096           152.75n ± 0%   80.08n ± 0%  -47.57% (p=0.000 n=10)
MemmoveUnalignedDstOverlap/256      11.88n ± 1%   10.95n ± 0%   -7.83% (p=0.000 n=10)
MemmoveUnalignedDstOverlap/512      19.71n ± 0%   16.20n ± 0%  -17.83% (p=0.000 n=10)
MemmoveUnalignedDstOverlap/1024     39.84n ± 0%   28.74n ± 0%  -27.86% (p=0.000 n=10)
MemmoveUnalignedDstOverlap/2048     81.12n ± 0%   40.11n ± 0%  -50.56% (p=0.000 n=10)
MemmoveUnalignedDstOverlap/4096    166.20n ± 0%   85.11n ± 0%  -48.79% (p=0.000 n=10)
MemmoveUnalignedSrc/256            10.945n ± 1%   6.807n ± 0%  -37.81% (p=0.000 n=10)
MemmoveUnalignedSrc/512             19.33n ± 4%   11.01n ± 1%  -43.02% (p=0.000 n=10)
MemmoveUnalignedSrc/1024            34.74n ± 0%   19.69n ± 0%  -43.32% (p=0.000 n=10)
MemmoveUnalignedSrc/2048            65.98n ± 0%   39.79n ± 0%  -39.69% (p=0.000 n=10)
MemmoveUnalignedSrc/4096           126.00n ± 0%   81.31n ± 0%  -35.47% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_256_0     13.610n ± 0%   7.608n ± 0%  -44.10% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_256_0      12.81n ± 0%   10.94n ± 0%  -14.60% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_256_1      17.17n ± 0%   10.01n ± 0%  -41.70% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_256_1      17.62n ± 0%   11.21n ± 0%  -36.38% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_256_4      16.22n ± 0%   10.01n ± 0%  -38.29% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_256_4      16.42n ± 0%   11.21n ± 0%  -31.73% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_256_7      14.09n ± 0%   10.79n ± 0%  -23.39% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_256_7      14.82n ± 0%   11.21n ± 0%  -24.36% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_4096_0    109.80n ± 0%   75.07n ± 0%  -31.63% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_4096_0    108.90n ± 0%   78.48n ± 0%  -27.93% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_4096_1    113.60n ± 0%   78.88n ± 0%  -30.56% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_4096_1    113.80n ± 0%   80.56n ± 0%  -29.20% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_4096_4    112.30n ± 0%   80.35n ± 0%  -28.45% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_4096_4    113.80n ± 1%   80.58n ± 0%  -29.19% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_4096_7    110.70n ± 0%   79.68n ± 0%  -28.02% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_4096_7    111.10n ± 0%   80.58n ± 0%  -27.47% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_65536_0    4.669µ ± 0%   2.680µ ± 0%  -42.60% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_65536_0    5.083µ ± 0%   2.672µ ± 0%  -47.43% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_65536_1    4.716µ ± 0%   2.677µ ± 0%  -43.24% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_65536_1    4.611µ ± 0%   2.672µ ± 0%  -42.05% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_65536_4    4.718µ ± 0%   2.678µ ± 0%  -43.24% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_65536_4    4.610µ ± 0%   2.673µ ± 0%  -42.01% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_65536_7    4.724µ ± 0%   2.678µ ± 0%  -43.31% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_65536_7    4.611µ ± 0%   2.673µ ± 0%  -42.03% (p=0.000 n=10)
MemmoveUnalignedSrcOverlap/256      13.62n ± 0%   11.97n ± 0%  -12.11% (p=0.000 n=10)
MemmoveUnalignedSrcOverlap/512      23.96n ± 0%   16.20n ± 0%  -32.39% (p=0.000 n=10)
MemmoveUnalignedSrcOverlap/1024     43.95n ± 0%   30.25n ± 0%  -31.18% (p=0.000 n=10)
MemmoveUnalignedSrcOverlap/2048     84.29n ± 0%   42.27n ± 0%  -49.85% (p=0.000 n=10)
MemmoveUnalignedSrcOverlap/4096    170.50n ± 0%   85.47n ± 0%  -49.87% (p=0.000 n=10)

Change-Id: Id1c3fbfed049d9a665f05f7c1af84e9fbd45fddf
Reviewed-on: https://go-review.googlesource.com/c/go/+/663395
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
2025-04-13 20:20:58 -07:00
Than McIntosh
47ab9cbd82 cmd: fix DWARF gen bug with packages that use assembly
When the compiler builds a Go package with DWARF 5 generation enabled,
it emits relocations into various generated DWARF symbols (ex:
SDWARFFCN) that use the R_DWTXTADDR_* flavor of relocations. The
specific size of this relocation is selected based on the total number
of functions in the package -- if the package is tiny (just a couple
funcs) we can use R_DWTXTADDR_U1 relocs (which target just a byte); if
the package is larger we might need to use the 2-byte or 3-byte flavor
of this reloc.

Prior to this patch, the strategy used to pick the right relocation
size was flawed in that it didn't take into account packages with
assembly code. For example, if you have a package P with 200 funcs
written in Go source and 200 funcs written in assembly, you can't use
the R_DWTXTADDR_U1 reloc flavor for indirect text references since the
real function count for the package (asm + go) exceeds 255.

The new strategy (with this patch) is to have the compiler look at the
"symabis" file to determine the count of assembly functions. For the
assembler, rather than create additional plumbing to pass in the Go
source func count we just use an dummy (artificially high) function
count so as to select a relocation that will be large enough.

Fixes #72810.
Updates #26379.

Change-Id: I98d04f3c6aacca1dafe1f1610c99c77db290d1d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/663235
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2025-04-13 08:09:12 -07:00
Keith Randall
21acfdc4ef cmd/compile: turn off variable-sized make() stack allocation with -N
Give people a way to turn this optimization off.

(Currently the constant-sized make() stack allocation is not disabled
with -N. Kinda inconsistent, but oh well, probably worse to change it now.)

Update #73253

Change-Id: Idb9ffde444f34e70673147fd6a962368904a7a55
Reviewed-on: https://go-review.googlesource.com/c/go/+/664655
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: t hepudds <thepudds1460@gmail.com>
2025-04-11 17:18:12 -07:00
Marcel Meyer
03640f688b all: use built-in min, max functions
Change-Id: Ie76ebb556d635068342747f3f91dd7dc423df531
GitHub-Last-Rev: aea61fb3a054e6bd24f4684f90fb353d5682cd0b
GitHub-Pull-Request: golang/go#73340
Reviewed-on: https://go-review.googlesource.com/c/go/+/664677
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-11 16:00:30 -07:00
Marcel Meyer
56fad21c22 cmd/compile/internal/ssa: small cleanups
Change-Id: I0420fb3956577c56fa24a31929331d526d480556
GitHub-Last-Rev: d74b0d4d75d4e432aaf84d02964da4a2e12d0e1b
GitHub-Pull-Request: golang/go#73339
Reviewed-on: https://go-review.googlesource.com/c/go/+/664975
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
2025-04-11 15:58:07 -07:00
Tobias Klauser
f967078712 os: fix TestRootChtimes on illumos
TestRootChtimes currently fails on illumos [1] because the times
returned by os.Stat have only microsecond precision on that builder.
Truncate them to make the test pass again.

[1] https://build.golang.org/log/9780af24c3b3073dae1d827b2b9f9e3a48912c30

Change-Id: I8cf895d0b60c854c27cb4faf57c3b44bd40bfdd4
Reviewed-on: https://go-review.googlesource.com/c/go/+/664915
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Bypass: Damien Neil <dneil@google.com>
2025-04-11 13:20:16 -07:00
Russ Cox
3968a5bca4 runtime: handle m0 padding better
The SpinbitMutex experiment requires m structs other than m0
to be allocated in 2048-byte size class, by adding padding.
Do the calculation more explicitly, to avoid future CLs like CL 653335.

Change-Id: I83ae1e86ef3711ab65441f4e487f94b9e1429029
Reviewed-on: https://go-review.googlesource.com/c/go/+/654595
Reviewed-by: Rhys Hiltner <rhys.hiltner@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-04-11 12:24:59 -07:00
Marcel Meyer
c77ada1b78 cmd/compile/internal/ssa: simplify with built-in min, max functions
Change-Id: I08fa2940cd3565c578b1b323656a4fa12e0c65bb
GitHub-Last-Rev: 1f673b190ee62fe8158c9e70acf6b0882f6b3f6e
GitHub-Pull-Request: golang/go#73322
Reviewed-on: https://go-review.googlesource.com/c/go/+/664675
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-04-11 08:50:53 -07:00
Marcel Meyer
bbf4d57c22 cmd/compile/internal/ssa: use built-in min, max function
Change-Id: I6dd6e3f8a581931fcea3c3e0ac30ce450253e1d8
GitHub-Last-Rev: c476f8b9a3741a682340d3a37d6d5a9a44a56e5f
GitHub-Pull-Request: golang/go#73318
Reviewed-on: https://go-review.googlesource.com/c/go/+/664615
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-04-11 08:31:00 -07:00
Marcel Meyer
c3a0859720 runtime: use built-in min function
Change-Id: I625c392864c97cefc2ac8f23612e3f62f7fbba23
GitHub-Last-Rev: 779f756850e7bf0cf2059ed0b4d412638c872f7e
GitHub-Pull-Request: golang/go#73313
Reviewed-on: https://go-review.googlesource.com/c/go/+/664016
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-11 08:22:09 -07:00
1911860538
5c2c1cde9c time: remove redundant int conversion in tzruleTime
daysBefore returns int.

Change-Id: Ib30c9ea76b46178a4fc35e8198aaab913329ceba
GitHub-Last-Rev: 2999e99dad8bfd075fdc942def1de2593d920c79
GitHub-Pull-Request: golang/go#73182
Reviewed-on: https://go-review.googlesource.com/c/go/+/663275
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
2025-04-11 07:30:57 -07:00
Russ Cox
432fd9c60f math/big: remove copy responsibility from, rename shlVU, shrVU
It is annoying that non-x86 implementations of shlVU and shrVU
have to go out of their way to handle the trivial case shift==0
with their own copy loops. Instead, arrange to never call them
with shift==0, so that the code can be removed.

Unfortunately, there are linknames of shlVU, so we cannot
change that function. But we can rename the functions and
then leave behind a shlVU wrapper, so do that.

Since the big.Int API calls the operations Lsh and Rsh, rename
shlVU/shrVU to lshVU/rshVU. Also rename various other shl/shr
methods and functions to lsh/rsh.

Change-Id: Ieaf54e0110a298730aa3e4566ce5be57ba7fc121
Reviewed-on: https://go-review.googlesource.com/c/go/+/664896
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-11 06:03:38 -07:00
Russ Cox
4dffdd797b math/big: replace addMulVVW with addMulVVWW
addMulVVW is an unnecessarily special case.
All other assembly routines taking []Word (V as in vector) arguments
take separate source and destination. For example:

	addVV: z = x+y
	mulAddVWW: z = x*m+a

addMulVVW uses the z parameter as both destination and source:

	addMulVVW: z = z+x*m

Even looking at the signatures is confusing: all the VV routines take
two input vectors x and y, but addMulVVW takes only x: where is y?
(The answer is that the two inputs are z and x.)

It would be nice to fix this, both for understandability and regularity,
and to simplify a future assembly generator.

We cannot remove or redefine addMulVVW, because it has been used
in linknames. Instead, the CL adds a new final addend argument ‘a’
like in mulAddVWW, making the natural name addMulVVWW
(two input vectors, two input words):

	addMulVVWW: z = x+y*m+a

This CL updates all the assembly implementations to rename the
inputs z, x, y -> x, y, m, and then introduces a separate destination z.

Change-Id: Ib76c80b53f6d1f4a901f663566e9c4764bb20488
Reviewed-on: https://go-review.googlesource.com/c/go/+/664895
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-04-11 05:42:18 -07:00
Marcel Meyer
037112464b cmd/compile/internal/ssa: use built-in min function
Change-Id: Id4276adea58afdf98c6f9b547cca0546fc659ae1
GitHub-Last-Rev: 4c836241c86d51c69330153dea1c5679958c37f9
GitHub-Pull-Request: golang/go#73323
Reviewed-on: https://go-review.googlesource.com/c/go/+/664695
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2025-04-10 16:38:29 -07:00
Marcel Meyer
9d915d6870 cmd/compile/internal/ssa: remove unused round function
Change-Id: I15ee74ab0be0cd996a74e6233b39e0953da3f327
GitHub-Last-Rev: dc41b1027a2b07a227705303dc02a85433756eab
GitHub-Pull-Request: golang/go#73324
Reviewed-on: https://go-review.googlesource.com/c/go/+/664696
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-10 16:37:57 -07:00
Sam Thanawalla
835e36fc7f cmd/go: add subdirectory support to go-import meta tag
This CL adds ability to specify a subdirectory in the go-import meta tag.
A go-import meta tag now will support:
<meta name="go-import" content="root-path vcs repo-url subdir">

Fixes: #34055
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: Iedac520f97e0646254cc1bd2f97d5a9a5236829b
Reviewed-on: https://go-review.googlesource.com/c/go/+/625577
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-10 11:14:09 -07:00
qmuntal
2c35900fe4 net: deduplicate sendfile files
The sendfile implementation for platforms supporting it is now in
net/sendfile.go, rather than being duplicated in separate files for
each platform.

The only difference between the implementations was the poll.SendFile
parameters, which have been harmonized, and also linux strictly
asserting for os.File, which now have been relaxed to allow any
type implementing syscall.Conn.

Change-Id: Ia1a2d5ee7380710a36fc555dbf681f7e996ea2ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/664075
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2025-04-10 09:12:09 -07:00
qmuntal
9aad012a6e net: reenable sendfile on Windows
Windows sendfile optimization is skipped since CL 472475, which started
passing an os.fileWithoutWriteTo instead of an os.File to sendfile,
and that function was only implemented for os.File.

This CL fixes the issue by asserting against an interface rather than
a concrete type.

Some tests have been reenabled, triggering bugs in poll.SendFile which
have been fixed in this CL.

Fixes #67042.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest
Change-Id: Id6f7a0e1e0f34a72216fa9d00c5bf36f5a994219
Reviewed-on: https://go-review.googlesource.com/c/go/+/664055
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2025-04-10 07:36:41 -07:00
Zxilly
d60a684c87 cmd/internal/obj/wasm: use i64 for large return addr
Use i64 to avoid overflow when getting PC_F from the return addr.

Fixes #73246

Change-Id: I5683dccf7eada4b8536edf53e2e83116a2f6d943
GitHub-Last-Rev: 267d9a1a031868430d0af530de14229ee1ae8609
GitHub-Pull-Request: golang/go#73277
Reviewed-on: https://go-review.googlesource.com/c/go/+/663995
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-09 23:38:23 -07:00
1911860538
7a82b6a9e1 net/http: initialize Value with File length in cloneMultipartForm
Improve the initialization of the Value map in cloneMultipartForm by
utilizing the length of the File map to optimize memory allocation.

Change-Id: I97ba9e19b2718a75c270e6df21306f4c82656c71
GitHub-Last-Rev: a9683ba9a7cbb20213766fba8d9096b4f8591d86
GitHub-Pull-Request: golang/go#69943
Reviewed-on: https://go-review.googlesource.com/c/go/+/621235
Reviewed-by: Christian Ekrem <christianekrem@gmail.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
2025-04-09 17:04:40 -07:00
Dmitrii Martynov
a42e337ede runtime: explicitly exclude a potential deadlock in the scheduler
The following sequence in the scheduler may potentially lead to
deadlock:
- globrunqget() -> runqput() -> runqputslow() -> globrunqputbatch()
However, according to the current logic of the scheduler it is not
possible to face the deadlock.

The patch explicitly excludes the deadlock, even though it is impossible
situation at the moment.

Additionally, the "runq" and "globrunq" APIs were partially refactored,
which allowed to minimize the usage of these APIs by each other.
This will prevent situations described in the CL.

Change-Id: I7318f935d285b95522998e0903eaa6193af2ba48
Reviewed-on: https://go-review.googlesource.com/c/go/+/662216
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>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-09 16:12:45 -07:00
qiulaidongfeng
8898450841 cmd/go: only print GOCACHE value in env -changed if it's not the default
When other environment variables are set to default values,
we will not print it in go env -changed,
GOCACHE should do the same.

For #69994

Change-Id: I16661803cf1f56dd132b4db1c2d5cb4823fc0e58
Reviewed-on: https://go-review.googlesource.com/c/go/+/621997
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-09 13:56:45 -07:00
thepudds
4820816b0d cmd/go/internal/modcmd: remove documentation for auto-converting legacy formats
CL 518776 dropped the ability of 'go mod init' to convert
legacy pre-module dependency configuration files, such as automatically
transforming a Gopkg.lock to a go.mod file with similar requirements,
but some of the documentation remained.

In this CL, we remove it from the cmd/go documentation.
(CL 662675 is a companion change that removes it from the Modules
Reference page).

Updates #71537

Change-Id: Ieccc64c811c4c25a657c00e42f7362a32b5fd661
Reviewed-on: https://go-review.googlesource.com/c/go/+/662695
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
2025-04-09 13:53:22 -07:00
Jakob Ackermann
cfb78d63bd net/http: reduce memory usage when hijacking
Previously, Hijack allocated a new write buffer and the existing
connection write buffer used an extra 4KiB of memory until the handler
finished and the "conn" was garbage collected. Now, hijack re-uses the
existing write buffer and re-attaches it to the raw connection to avoid
referencing the net/http "conn" after returning.

After a handler that hijacked exited, the "conn" reference in
"connReader" will now be unset. This allows all of the "conn",
"response" and "Request" to get garbage collected.
Overall, this is reducing the memory usage by 43% or 6.7KiB per hijacked
connection (see BenchmarkServerHijackMemoryUsage in an earlier revision
of the CL).

CloseNotify will continue to work _before_ the handler has exited
(i.e. while the "conn" is still referenced in "connReader"). This aligns
with the documentation of CloseNotifier:
> After the Handler has returned, there is no guarantee that the channel
> receives a value.

goos: linux
goarch: amd64
pkg: net/http
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
               │   before    │             after              │
               │   sec/op    │    sec/op     vs base          │
ServerHijack-8   42.59µ ± 8%   39.47µ ± 16%  ~ (p=0.481 n=10)

               │    before    │                after                 │
               │     B/op     │     B/op      vs base                │
ServerHijack-8   16.12Ki ± 0%   12.06Ki ± 0%  -25.16% (p=0.000 n=10)

               │   before   │               after               │
               │ allocs/op  │ allocs/op   vs base               │
ServerHijack-8   51.00 ± 0%   49.00 ± 0%  -3.92% (p=0.000 n=10)

Change-Id: I20a37ee314ed0d47463a4657d712154e78e48138
GitHub-Last-Rev: 80f09dfa273035f53cdd72845e5c5fb129c3e230
GitHub-Pull-Request: golang/go#70756
Reviewed-on: https://go-review.googlesource.com/c/go/+/634855
Reviewed-by: 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: Damien Neil <dneil@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
2025-04-09 13:49:52 -07:00
qmuntal
cac276f81a internal/poll: fix race in Close
There is a potential race between a concurrent call to FD.initIO, which
calls FD.pd.init, and a call to FD.Close, which calls FD.pd.evict.

This is solved by calling FD.initIO in FD.Close, as that will block
until the concurrent FD.initIO has completed. Note that FD.initIO is
no-op if first called from here.

The race window is so small that it is not possible to write a test
that triggers it.

Change-Id: Ie2f2818e746b9d626fe3b9eb6b8ff967c81ef863
Reviewed-on: https://go-review.googlesource.com/c/go/+/663815
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-04-09 13:07:09 -07:00
qmuntal
7007dfcd0c os: clean-up NewFile tests
This CL removes some unnecessary code and duplicated NewFile tests
cases.

It also simplifies TestPipeCanceled by removing the need for using
SetReadDeadline. Using CancelIoEx instead of CancelIo makes the cancel
operations to finish almost instantly. The latter could take more than
20s to finish if called from a thread different from the one that
called ReadFile.

Change-Id: I9033cbcad277666bc2aec89b3e5a3ef529da2cd8
Reviewed-on: https://go-review.googlesource.com/c/go/+/663755
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-09 13:06:17 -07:00
limeidan
09d76e59d2 cmd/compile: set unalignedOK to make memcombine work properly on loong64
goos: linux
goarch: loong64
pkg: unicode/utf8
cpu: Loongson-3A6000-HV @ 2500.00MHz
                            │     old     │                 new                 │
                            │   sec/op    │   sec/op     vs base                │
ValidTenASCIIChars            7.604n ± 0%   6.805n ± 0%  -10.51% (p=0.000 n=10)
Valid100KASCIIChars           37.41µ ± 0%   16.58µ ± 0%  -55.67% (p=0.000 n=10)
ValidTenJapaneseChars         60.84n ± 0%   58.62n ± 0%   -3.64% (p=0.000 n=10)
ValidLongMostlyASCII          113.5µ ± 0%   113.5µ ± 0%        ~ (p=0.303 n=10)
ValidLongJapanese             204.6µ ± 0%   206.8µ ± 0%   +1.07% (p=0.000 n=10)
ValidStringTenASCIIChars      7.604n ± 0%   6.803n ± 0%  -10.53% (p=0.000 n=10)
ValidString100KASCIIChars     38.05µ ± 0%   17.14µ ± 0%  -54.97% (p=0.000 n=10)
ValidStringTenJapaneseChars   60.58n ± 0%   59.48n ± 0%   -1.82% (p=0.000 n=10)
ValidStringLongMostlyASCII    113.5µ ± 0%   113.4µ ± 0%   -0.10% (p=0.000 n=10)
ValidStringLongJapanese       205.9µ ± 0%   207.3µ ± 0%   +0.67% (p=0.000 n=10)
geomean                       3.324µ        2.756µ       -17.08%

Change-Id: Id43b6e2e41907bd4b92f421dacde31f048db47d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/662495
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>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-09 09:18:20 -07:00
David Chase
ecc06f0db7 cmd/compile: fix the test for ABI specification so it works right w/ generics
Change-Id: I09ef615bfe69a30fa8f7eef5f0a8ff94a244c920
Reviewed-on: https://go-review.googlesource.com/c/go/+/663776
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>
2025-04-09 00:32:10 -07:00
Keith Randall
0909bcd9e4 syscall: remove unused windows function
It's causing the dependency test to fail.

Fixes #73274

Change-Id: I7d80ea4872e360c16ac3b77acf15fa2660d117b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/663975
Auto-Submit: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2025-04-08 17:13:04 -07:00
Neal Patel
53badd4836 net/http: push roundTrip panic higher in the stack
If Transport is a non-nil interface pointing to a nil implementer,
then a panic inside of roundTrip further obsfucates the issue.

Change-Id: I47664b8e6185c5f56b5e529f49022484b5ea1d94
Reviewed-on: https://go-review.googlesource.com/c/go/+/661897
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Neal Patel <nealpatel@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-04-08 14:27:47 -07:00
Damien Neil
ec4a9fb321 context: don't return a nil Cause for a canceled custom context
Avoid a case where Cause(ctx) could return nil for a canceled context,
when ctx is a custom context implementation and descends from a
cancellable-but-not-canceled first-party Context.

Fixes #73258

Change-Id: Idbd81ccddea82ecabece4373d718baae6ca4b58e
Reviewed-on: https://go-review.googlesource.com/c/go/+/663936
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-08 14:04:56 -07:00
cuishuang
3acd440219 time: add examples for AppendBinary and AppendText
Change-Id: I61529b5162f8a77d3bbffcbbac98c834a7626e3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/661935
Reviewed-by: 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>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-08 13:59:46 -07:00
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
Alan Donovan
903d7b7862 cmd/vendor: update golang.org/x/tools to v0.31.1-0.20250328151535-a857356d5cc5
Also, sys@v0.31.1.

Updates #18022

Change-Id: I15a6d1979cc1e71d3065bc50f09dc8d3f6c6cdc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/661518
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>
Commit-Queue: Alan Donovan <adonovan@google.com>
2025-04-01 15:08:03 -07:00
qmuntal
75bf2a8c49 internal/poll: defer IOCP association until first IO operation
Defer the association of the IOCP to the handle until the first
I/O operation is performed.

A handle can only be associated with one IOCP at a time, so this allows
external code to associate the handle with their own IOCP and still be
able to use a FD (through os.NewFile) to pass the handle around
(e.g. to a child process standard input, output, and error) without
having to worry about the IOCP association.

This CL doesn't change any user-visible behavior, as os.NewFile still
initializes the FD as non-pollable.

For #19098.

Change-Id: Id22a49846d4fda3a66ffcc0bc1b48eb39b395dc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/661955
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-01 11:58:06 -07:00
喜欢
7177f24009 log/slog: log and logAttrs initialize ctx at top
In extreme cases (e.g., ctx = nil), it is recommended to initialize the
context only once at the entry point before using log and logAttrs.

Change-Id: Ib191963f52183406d7fcd5104b60fea1a9e1bc80
GitHub-Last-Rev: e1719b95390011a45a0a6652a13e675279bc76cd
GitHub-Pull-Request: golang/go#73066
Reviewed-on: https://go-review.googlesource.com/c/go/+/661255
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-01 06:38:57 -07:00
Joel Sing
4c1b8ca98c cmd/internal/obj/riscv: add support for vector fixed-point arithmetic instructions
Add support for vector fixed-point arithmetic instructions to the
RISC-V assembler. This includes single width saturating addition
and subtraction, averaging addition and subtraction and scaling
shift instructions.

Change-Id: I9aa27e9565ad016ba5bb2b479e1ba70db24e4ff5
Reviewed-on: https://go-review.googlesource.com/c/go/+/646776
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-01 05:31:22 -07:00
Russ Cox
4c32b1cc75 runtime: fix plan9 monotonic time, crypto randomness
Open /dev/bintime at process start on Plan 9,
marked close-on-exec, hold it open for the duration of the
process, and use it for obtaining time.

The change to using /dev/bintime also sets up for an upcoming
Plan 9 change to add monotonic time to that file. If the monotonic
field is available, then nanotime1 and time.now use that field.
Otherwise they fall back to using Unix nanoseconds as "monotonic",
as they always have.

Before this CL, monotonic time went backward any time
aux/timesync decided to adjust the system's time-of-day backward.

Also use /dev/random for randomness (once at startup).
Before this CL, there was no real randomness in the runtime
on Plan 9 (the crypto/rand package still had some). Now there will be.

Change-Id: I0c20ae79d3d96eff1a5f839a56cec5c4bc517e61
Reviewed-on: https://go-review.googlesource.com/c/go/+/656755
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-03-31 17:06:53 -07:00
Damien Neil
6d418096b2 os: avoid symlink races in RemoveAll on Windows
Make the openat-using version of RemoveAll use the appropriate
Windows equivalent, via new portable (but internal) functions
added for os.Root.

We could reimplement everything in terms of os.Root,
but this is a bit simpler and keeps the existing code structure.

Fixes #52745

Change-Id: I0eba0286398b351f2ee9abaa60e1675173988787
Reviewed-on: https://go-review.googlesource.com/c/go/+/661575
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-31 15:36:10 -07:00
Damien Neil
c6a1dc4729 cmd/link: close file in tempdir so Windows can delete it
Fixes #73098

Change-Id: I9f5570903071b15df9e4f8a1820414f305db9d35
Reviewed-on: https://go-review.googlesource.com/c/go/+/661915
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-03-31 15:30:17 -07:00
qmuntal
b9cbb65384 os,internal/poll: support I/O on overlapped handles not added to the poller
Calling syscall.ReadFile and syscall.WriteFile on overlapped handles
always need to be passed a valid *syscall.Overlapped structure, even if
the handle is not added to a IOCP (like the Go runtime poller). Else,
the syscall will fail with ERROR_INVALID_PARAMETER.

We also need to handle ERROR_IO_PENDING errors when the overlapped
handle is not added to the poller, in which case we need to block until
the operation completes.

Previous CLs already added support for overlapped handles to the poller,
mostly to keep track of the file offset independently of the file
pointer (which is not supported for overlapped handles).

Fixed #15388.
Updates #19098.

Change-Id: I2103ab892a37d0e326752ae8c2771a43c13ba42e
Reviewed-on: https://go-review.googlesource.com/c/go/+/661795
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2025-03-31 12:01:49 -07:00
Mateusz Poliwczak
eec3745bd7 cmd/compile/internal/ssa: replace uses of interface{} with Sym/Aux
Change-Id: I0a3ce2e823697eee5bb5e7d5ea0ef025132c0689
Reviewed-on: https://go-review.googlesource.com/c/go/+/661655
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2025-03-31 08:20:16 -07:00
thepudds
bfc209518e internal/runtime/maps: speed up small map lookups ~1.7x for unpredictable keys
On master, lookups on small Swiss Table maps (<= 8 elements) for
non-specialized key types are seemingly a performance regression
compared to the Go 1.23 map implementation (reported in #70849).
Currently, a linear scan is used for gets in these cases.

This CL changes (*Map).getWithKeySmall to instead use the SIMD or SWAR
match on the control bytes to then jump to candidate matching slots,
with sample results below for a 16-byte key. This especially helps the
hit case when the key is unpredictable, which previously had to scan an
unpredictable number of control bytes to find a candidate slot when the
key is unpredictable.

Separately, other CLs in this stack modify the main Swiss Table
benchmarks to randomize lookup key order (vs. previously most of the
benchmarks had a repeating lookup key ordering, which likely is
predictable until the map is too big). We have sample results for the
randomized key order benchmarks followed by results from the older
benchmarks.

The first table below is with randomized key order. For hits, the older
results get slower as there are more elements. With this CL, we see hits
for unpredictable key ordering (sizes 2-8) get a ~1.7x speedup from
~25ns to ~14ns, with a now consistent lookup time for the different
sizes. (The 1 element size map has a predictable key ordering because
there is only one key, and that reports a modest ~0.5ns or ~3%
performance penalty). Misses for unpredictable key order get a ~1.3x
speedup, from ~13ns to ~10ns, with similar results for the 1 element
size.

                                                   │ no-fix-new-bmarks  │ fix-with-new-bmarks   │
                                                   │     sec/op         │  sec/op       vs base │
MapSmallAccessHit/Key=smallType/Elem=int32/len=1-4        13.26n ±  0%   13.64n ±  0%   +2.90% (p=0.000 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=2-4        19.47n ±  0%   13.62n ±  0%  -30.05% (p=0.000 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=3-4        22.23n ±  0%   13.64n ±  0%  -38.68% (p=0.000 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=4-4        23.98n ±  0%   13.64n ±  0%  -43.11% (p=0.000 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=5-4        25.02n ±  0%   13.67n ±  0%  -45.35% (p=0.000 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=6-4        25.77n ±  1%   13.68n ±  2%  -46.89% (p=0.000 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=7-4        26.38n ±  0%   13.64n ±  0%  -48.28% (p=0.000 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=8-4        26.31n ±  0%   13.71n ± 21%  -47.90% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=1-4      13.055n ±  0%   9.815n ±  0%  -24.82% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=2-4      13.070n ±  0%   9.813n ±  0%  -24.92% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=3-4      13.060n ±  0%   9.819n ±  0%  -24.82% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=4-4      13.075n ±  0%   9.816n ±  0%  -24.92% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=5-4      13.060n ±  0%   9.826n ±  0%  -24.76% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=6-4      13.095n ± 19%   9.834n ± 31%  -24.90% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=7-4      13.075n ± 19%   9.822n ± 27%  -24.88% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=8-4       13.11n ± 16%   12.14n ± 19%   -7.43% (p=0.000 n=20)

The next table uses the original benchmarks from just before this CL
stack (i.e., without shuffling lookup keys).

With this CL, we see improvement that is directionally similar to the
above results but not as large, presumably because the branches in the
linear scan are fairly predictable with predictable keys. (The numbers
here also include the time from a mod in the benchmark code, which
seemed to take around ~1/3 of CPU time based on spot checking a couple
of examples, vs. the modified benchmarks shown above have removed that
mod).

                                                  │ master-8c3e391573 │   just-fix-with-old-bmarks       │
                                                  │      sec/op       │    sec/op     vs base            │
MapSmallAccessHit/Key=smallType/Elem=int32/len=1-4      20.85n ±  0%   21.69n ±  0%   +4.03% (p=0.000 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=2-4      21.22n ±  0%   21.70n ±  0%   +2.24% (p=0.000 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=3-4      21.73n ±  0%   21.71n ±  0%        ~ (p=0.158 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=4-4      22.06n ±  0%   21.71n ±  0%   -1.56% (p=0.000 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=5-4      22.41n ±  0%   21.73n ±  0%   -3.01% (p=0.000 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=6-4      22.71n ±  0%   21.72n ±  0%   -4.38% (p=0.000 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=7-4      22.98n ±  0%   21.71n ±  0%   -5.53% (p=0.000 n=20)
MapSmallAccessHit/Key=smallType/Elem=int32/len=8-4      23.20n ±  0%   21.72n ±  0%   -6.36% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=1-4     19.95n ±  0%   17.30n ±  0%  -13.28% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=2-4     19.96n ±  0%   17.31n ±  0%  -13.28% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=3-4     19.95n ±  0%   17.29n ±  0%  -13.33% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=4-4     19.95n ±  0%   17.30n ±  0%  -13.29% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=5-4     19.96n ± 25%   17.32n ±  0%  -13.22% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=6-4     19.99n ± 24%   17.29n ±  0%  -13.51% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=7-4     19.97n ± 20%   17.34n ± 16%  -13.14% (p=0.000 n=20)
MapSmallAccessMiss/Key=smallType/Elem=int32/len=8-4     20.02n ± 11%   17.33n ± 14%  -13.44% (p=0.000 n=20)
geomean                                                 21.02n         19.39n         -7.78%

See #70849 for additional benchmark results, including results for arm64
(which also means without SIMD support).

Updates #54766
Updates #70700
Fixes #70849

Change-Id: Ic2361bb6fc15b4436d1d1d5be7e4712e547f611b
Reviewed-on: https://go-review.googlesource.com/c/go/+/634396
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-30 21:39:07 -07:00
Joel Sing
391dde29a3 cmd/internal/obj/arm64: factor out constant classification code
This will allow for further improvements and deduplication.

Change-Id: I9374fc2d16168ced06f3fcc9e558a9c85e24fd01
Reviewed-on: https://go-review.googlesource.com/c/go/+/650936
Reviewed-by: Fannie Zhang <Fannie.Zhang@arm.com>
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>
2025-03-29 06:30:04 -07:00
Joel Sing
535e0daefd cmd/internal/obj/riscv: add support for vector integer arithmetic instructions
Add support for vector integer arithmetic instructions to the RISC-V
assembler. This includes vector addition, subtraction, integer
extension, add-with-carry, subtract-with-borrow, bitwise logical
operations, comparison, min/max, integer division and multiplication
instructions.

Change-Id: I8c191ef8e31291e13743732903e4f12356133a46
Reviewed-on: https://go-review.googlesource.com/c/go/+/646775
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
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>
2025-03-29 05:54:51 -07:00
Cherry Mui
5fb9e5dc19 cmd/link: handle Mach-O X86_64_RELOC_SUBTRACTOR in internal linking
With recent LLVM toolchain, on macOS/AMD64, the race detector syso
file built from it contains X86_64_RELOC_SUBTRACTOR relocations,
which the Go linker currently doesn't handle in internal linking
mode. To ensure internal linking mode continue to work with the
race detector syso, this CL adds support of X86_64_RELOC_SUBTRACTOR
relocations.

X86_64_RELOC_SUBTRACTOR is actually a pair of relocations that
resolves to the difference between two symbol addresses (each
relocation specifies a symbol). For the cases we care (the race
syso), the symbol being subtracted out is always in the current
section, so we can just convert it to a PC-relative relocation,
with the addend adjusted. If later we need the more general form,
we can introduce a new mechanism (say, objabi.R_DIFF) that works
as a pair of relocations like the Mach-O one.

As we expect the pair of relocations be consecutive, don't reorder
(sort) relocation records when loading Mach-O objects.

Change-Id: I757456b07270fb4b2a41fd0fef67a2b39dd6b238
Reviewed-on: https://go-review.googlesource.com/c/go/+/660715
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-28 14:35:41 -07:00
qmuntal
b9934d855c internal/poll: honor ERROR_OPERATION_ABORTED if pipe is not closed
FD.Read converts a syscall.ERROR_OPERATION_ABORTED error to
ErrFileClosing. It does that in case the pipe operation was aborted by
a CancelIoEx call in FD.Close.

It doesn't take into account that the operation might have been
aborted by a CancelIoEx call in external code. In that case, the
operation should return the error as is.

Change-Id: I75dcf0edaace8b57dc47b398ea591ca9f116112b
Reviewed-on: https://go-review.googlesource.com/c/go/+/661555
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-28 14:14:48 -07:00
Michael Anthony Knyszek
5ec76ae5aa weak: clarify Pointer equality semantics
The docs currently are imprecise about comparisons. This could lead
users to believe that objects of the same type, allocated at the same
address, could produce weak pointers that are equal to
previously-created weak pointers. This is not the case. Weak pointers
map to objects, not addresses.

Update the documentation to state precisely that if two pointers do not
compare equal, then two weak pointers created from those two pointers
are guaranteed not to compare equal. Since a future pointer pointing to
the same address is not comparable with a pointer produced *before* an
object at that address has been reclaimed, this is sufficient to explain
that weak pointers map 1:1 with object offsets, not addresses.

(An object slot cannot be reused unless that slot is unreachable, so
by construction, there's never an opportunity to compare an "old" and
"new" pointer unless one uses unsafe tricks that violate the
unsafe.Pointer rules.)

Fixes #71381.

Change-Id: I5509fd433cde013926d725694d480c697a8bc911
Reviewed-on: https://go-review.googlesource.com/c/go/+/643935
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2025-03-28 13:50:18 -07:00
Cherry Mui
8f6c083d7b cmd/link: choose one with larger size for duplicated BSS symbols
When two packages declare a variable with the same name (with
linkname at least on one side), the linker will choose one as the
actual definition of the symbol if one has content (i.e. a DATA
symbol) and the other does not (i.e. a BSS symbol). When both have
content, it is redefinition error. When neither has content,
currently the choice is sort of arbitrary (depending on symbol
loading order, etc. which are subject to change).

One use case for that is that one wants to reference a symbol
defined in another package, and the reference side just wants to
see some of the fields, so it may be declared with a smaller type.
In this case, we want to choose the one with the larger size as
the true definition. Otherwise the code accessing the larger
sized one may read/write out of bounds, corrupting the next
variable. This CL makes the linker do so.

Fixes #72032.

Change-Id: I160aa9e0234702066cb8f141c186eaa89d0fcfed
Reviewed-on: https://go-review.googlesource.com/c/go/+/660696
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@golang.org>
2025-03-28 12:00:23 -07:00
Damien Neil
26fdb07d4c os: add Root.Symlink
For #67002

Change-Id: Ia1637b61eae49e97e1d07f058ad2390e74cd3403
Reviewed-on: https://go-review.googlesource.com/c/go/+/660635
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Damien Neil <dneil@google.com>
2025-03-28 11:02:40 -07:00
qmuntal
656b5b3abe internal/poll: don't skip empty writes on Windows
Empty writes might be important for some protocols. Let Windows decide
what do with them rather than skipping them on our side. This is inline
with the behavior of other platforms.

While here, refactor the Read/Write/Pwrite methods to reduce one
indentation level and make the code easier to read.

Fixes #73084.

Change-Id: Ic5393358e237d53b8be6097cd7359ac0ff205309
Reviewed-on: https://go-review.googlesource.com/c/go/+/661435
Reviewed-by: 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-03-28 09:44:35 -07:00
Joel Sing
e6c2e12c63 cmd/compile/internal/ssa: optimise more branches with zero on riscv64
Optimise more branches with zero on riscv64. In particular, BLTU with
zero occurs with IsInBounds checks for index zero. This currently results
in two instructions and requires an additional register:

   li      t2, 0
   bltu    t2, t1, 0x174b4

This is equivalent to checking if the bounds is not equal to zero. With
this change:

   bnez    t1, 0x174c0

This removes more than 500 instructions from the Go binary on riscv64.

Change-Id: I6cd861d853e3ef270bd46dacecdfaa205b1c4644
Reviewed-on: https://go-review.googlesource.com/c/go/+/606715
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-28 01:27:22 -07:00
Damien Neil
cfc784a152 os: avoid panic in Root when symlink references the root
We would panic when opening a symlink ending in ..,
where the symlink references the root itself.

Fixes #73081

Change-Id: I7dc3f041ca79df7942feec58c197fde6881ecae5
Reviewed-on: https://go-review.googlesource.com/c/go/+/661416
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-27 22:25:37 -07:00
Junyang Shao
b17a99d6fc cmd/compile: update GOSSAFUNC doc for printing CFG
Updates #30074

Change-Id: I160124afb65849c624a225d384c35313723f9f30
Reviewed-on: https://go-review.googlesource.com/c/go/+/661415
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-03-27 15:39:38 -07:00
Keith Randall
a645bc5eb9 maps: implement faster clone
│     base     │             experiment              │
            │    sec/op    │   sec/op     vs base                │
MapClone-24   66.802m ± 7%   3.348m ± 2%  -94.99% (p=0.000 n=10)

Fixes #70836

Change-Id: I9e192b1ee82e18f5580ff18918307042a337fdcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/660175
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-03-27 14:21:20 -07:00
Mark Freeman
6722c008c1 cmd/compile: rename some test packages in codegen
All other files here use the codegen package.

Change-Id: I714162941b9fa9051dacc29643e905fe60b9304b
Reviewed-on: https://go-review.googlesource.com/c/go/+/661135
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>
Auto-Submit: Keith Randall <khr@golang.org>
2025-03-27 13:54:37 -07:00
Junyang Shao
4d6722a8fd cmd/compile: match more patterns for shortcircuit
This CL tries to generalize the pattern matching of certain
shortcircuit-able CFGs a bit more:
For a shortcircuit-able CFG:
p   q
 \ /
  b
 / \
t   u
Where the constant branch is t, and b has multiple phi values
other than the control phi.

For the non-constant branch target u, we try to match the
"diamond" shape CFG:
p   q
 \ /
  b
 / \
t   u
 \ /
  m

or

p   q
 \ /
  b
  |\
  | u
  |/
  m

Instead of matching u as a single block, we know try to
generalize it as a subgraph that satisfy condition:
it's a DAG that has a single entry point u, and has a
path to m.

compilebench stats:
                         │   old.txt   │              new.txt               │
                         │   sec/op    │   sec/op     vs base               │
Template                   109.4m ± 3%   109.8m ± 3%       ~ (p=0.796 n=10)
Unicode                    94.23m ± 1%   93.85m ± 1%       ~ (p=0.631 n=10)
GoTypes                    538.2m ± 1%   538.8m ± 1%       ~ (p=0.912 n=10)
Compiler                   90.21m ± 1%   90.02m ± 1%       ~ (p=0.436 n=10)
SSA                         3.318 ± 1%    3.323 ± 1%       ~ (p=1.000 n=10)
Flate                      69.38m ± 1%   69.57m ± 2%       ~ (p=0.529 n=10)
GoParser                   128.5m ± 1%   127.4m ± 1%       ~ (p=0.075 n=10)
Reflect                    267.4m ± 1%   267.2m ± 2%       ~ (p=0.739 n=10)
Tar                        127.7m ± 2%   126.4m ± 1%       ~ (p=0.353 n=10)
XML                        149.5m ± 1%   149.6m ± 2%       ~ (p=0.684 n=10)
LinkCompiler               390.0m ± 1%   388.4m ± 2%       ~ (p=0.353 n=10)
ExternalLinkCompiler        1.296 ± 0%    1.296 ± 1%       ~ (p=0.971 n=10)
LinkWithoutDebugCompiler   226.3m ± 1%   225.5m ± 1%       ~ (p=0.393 n=10)
StdCmd                      13.26 ± 0%    13.25 ± 1%       ~ (p=0.529 n=10)
geomean                    319.3m        318.8m       -0.17%

                         │   old.txt   │               new.txt               │
                         │ user-sec/op │ user-sec/op   vs base               │
Template                   293.1m ± 3%   291.4m ± 11%       ~ (p=0.436 n=10)
Unicode                    91.09m ± 5%   87.61m ±  7%       ~ (p=0.165 n=10)
GoTypes                     1.932 ± 3%    1.926 ±  3%       ~ (p=0.739 n=10)
Compiler                   125.8m ± 3%   121.5m ± 10%       ~ (p=0.481 n=10)
SSA                         18.93 ± 3%    18.89 ±  1%       ~ (p=0.684 n=10)
Flate                      158.5m ± 5%   160.0m ±  7%       ~ (p=0.971 n=10)
GoParser                   316.0m ± 9%   327.4m ±  7%       ~ (p=0.052 n=10)
Reflect                    845.6m ± 6%   861.6m ±  3%       ~ (p=0.579 n=10)
Tar                        358.1m ± 5%   348.5m ±  4%       ~ (p=0.089 n=10)
XML                        382.4m ± 4%   392.2m ±  3%       ~ (p=0.143 n=10)
LinkCompiler               609.1m ± 4%   627.9m ±  3%       ~ (p=0.123 n=10)
ExternalLinkCompiler        1.336 ± 2%    1.343 ±  4%       ~ (p=0.565 n=10)
LinkWithoutDebugCompiler   248.7m ± 3%   248.0m ±  1%       ~ (p=0.853 n=10)
geomean                    506.4m        506.8m        +0.08%

          │   old.txt    │               new.txt               │
          │  text-bytes  │  text-bytes   vs base               │
HelloSize   965.8Ki ± 0%   965.0Ki ± 0%  -0.08% (p=0.000 n=10)
CmdGoSize   12.30Mi ± 0%   12.29Mi ± 0%  -0.08% (p=0.000 n=10)
geomean     3.406Mi        3.403Mi       -0.08%

          │   old.txt    │                new.txt                │
          │  data-bytes  │  data-bytes   vs base                 │
HelloSize   15.08Ki ± 0%   15.08Ki ± 0%       ~ (p=1.000 n=10) ¹
CmdGoSize   408.5Ki ± 0%   408.5Ki ± 0%       ~ (p=1.000 n=10) ¹
geomean     78.49Ki        78.49Ki       +0.00%
¹ all samples are equal

          │   old.txt    │                new.txt                │
          │  bss-bytes   │  bss-bytes    vs base                 │
HelloSize   142.0Ki ± 0%   142.0Ki ± 0%       ~ (p=1.000 n=10) ¹
CmdGoSize   206.4Ki ± 0%   206.4Ki ± 0%       ~ (p=1.000 n=10) ¹
geomean     171.2Ki        171.2Ki       +0.00%
¹ all samples are equal

          │   old.txt    │               new.txt               │
          │  exe-bytes   │  exe-bytes    vs base               │
HelloSize   1.466Mi ± 0%   1.462Mi ± 0%  -0.27% (p=0.000 n=10)
CmdGoSize   18.19Mi ± 0%   18.17Mi ± 0%  -0.10% (p=0.000 n=10)
geomean     5.164Mi        5.154Mi       -0.18%

Fixes #72132

Change-Id: I3d1cb10b6a158c5750adc23c79709d63dbd771f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/656255
Auto-Submit: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2025-03-27 12:30:03 -07:00
Alan Donovan
b3aff930cf go/types: LookupSelection: returns LookupFieldOrMethod as a Selection
Also, rewrite some uses of LookupFieldOrMethod in terms of it.

+ doc, relnote

Fixes #70737

Change-Id: I58a6dd78ee78560d8b6ea2d821381960a72660ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/647196
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-03-27 12:29:28 -07:00
Mateusz Poliwczak
e9242ee812 cmd/compile: remove references to *gc.Node in docs
ssa.Sym is only implemented by *ir.Name or *obj.LSym.

Change-Id: Ia171db618abd8b438fcc2cf402f40f3fe3ec6833
Reviewed-on: https://go-review.googlesource.com/c/go/+/660995
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-27 11:25:27 -07:00
qmuntal
af53bd2c03 internal/syscall/windows: run go generate
CL 660595 manually edited zsyscall_windows.go, making it be out of sync
with its associated //sys directive. Longtest builders are failing
due to that.

Fixes #73069.

Change-Id: If7256ef4b831423e4925fb6e5656fe3f7ef77fea
Reviewed-on: https://go-review.googlesource.com/c/go/+/661275
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-27 08:58:05 -07:00
Joel Sing
d88f93f720 cmd/internal/obj/riscv,internal/bytealg: synthesize MIN/MAX/MINU/MAXU instructions
Provide a synthesized version of the MIN/MAX/MINU/MAXU instructions
if they're not natively available. This allows these instructions to
be used in assembly unconditionally.

Use MIN in internal/bytealg.compare.

Cq-Include-Trybots: luci.golang.try:gotip-linux-riscv64
Change-Id: I8a5a3a59f0a9205e136fc3d673b23eaf3ca469f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/653295
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-27 05:52:28 -07:00
Joel Sing
d37624881f cmd/internal/obj/riscv: improve constant construction
Attempt to construct large constants that have a consecutive sequence
of ones from a small negative constant, with a logical right and/or
left shift. This allows for a large range of mask like constants to be
constructed with only two or three instructions, avoiding the need to
load from memory.

Change-Id: I35a77fecdd2df0ed3f33b772d518f85119d4ff66
Reviewed-on: https://go-review.googlesource.com/c/go/+/652778
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>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
2025-03-27 04:26:47 -07:00
Guoqi Chen
1763ee199d runtime: optimizing memclrNoHeapPointers implementation using SIMD on loong64
goos: linux
goarch: loong64
pkg: runtime
cpu: Loongson-3A6000 @ 2500.00MHz
                        |  bench.old   |            bench.new.256             |
                        |    sec/op    |    sec/op     vs base                |
Memclr/5                   3.204n ± 0%    2.804n ± 0%  -12.48% (p=0.000 n=10)
Memclr/16                  3.204n ± 0%    3.204n ± 0%        ~ (p=0.465 n=10)
Memclr/64                  5.267n ± 0%    4.005n ± 0%  -23.96% (p=0.000 n=10)
Memclr/256                10.280n ± 0%    5.400n ± 0%  -47.47% (p=0.000 n=10)
Memclr/4096               107.00n ± 1%    30.24n ± 0%  -71.74% (p=0.000 n=10)
Memclr/65536              1675.0n ± 0%    431.1n ± 0%  -74.26% (p=0.000 n=10)
Memclr/1M                  52.61µ ± 0%    32.82µ ± 0%  -37.62% (p=0.000 n=10)
Memclr/4M                  210.3µ ± 0%    131.3µ ± 0%  -37.59% (p=0.000 n=10)
Memclr/8M                  420.3µ ± 0%    262.5µ ± 0%  -37.54% (p=0.000 n=10)
Memclr/16M                 857.4µ ± 1%    542.9µ ± 3%  -36.68% (p=0.000 n=10)
Memclr/64M                 3.658m ± 3%    2.173m ± 0%  -40.59% (p=0.000 n=10)
MemclrUnaligned/0_5        4.264n ± 1%    4.359n ± 0%   +2.23% (p=0.000 n=10)
MemclrUnaligned/0_16       4.595n ± 0%    4.599n ± 0%   +0.10% (p=0.020 n=10)
MemclrUnaligned/0_64       5.356n ± 0%    5.122n ± 0%   -4.37% (p=0.000 n=10)
MemclrUnaligned/0_256     10.370n ± 0%    5.907n ± 1%  -43.03% (p=0.000 n=10)
MemclrUnaligned/0_4096    107.10n ± 0%    37.35n ± 0%  -65.13% (p=0.000 n=10)
MemclrUnaligned/0_65536   1694.0n ± 0%    441.7n ± 0%  -73.93% (p=0.000 n=10)
MemclrUnaligned/1_5        4.272n ± 0%    4.348n ± 0%   +1.76% (p=0.000 n=10)
MemclrUnaligned/1_16       4.593n ± 0%    4.608n ± 0%   +0.33% (p=0.002 n=10)
MemclrUnaligned/1_64       7.610n ± 0%    5.293n ± 0%  -30.45% (p=0.000 n=10)
MemclrUnaligned/1_256     12.230n ± 0%    9.012n ± 0%  -26.31% (p=0.000 n=10)
MemclrUnaligned/1_4096    114.10n ± 0%    39.50n ± 0%  -65.38% (p=0.000 n=10)
MemclrUnaligned/1_65536   1705.0n ± 0%    468.8n ± 0%  -72.50% (p=0.000 n=10)
MemclrUnaligned/4_5        4.283n ± 1%    4.346n ± 0%   +1.48% (p=0.000 n=10)
MemclrUnaligned/4_16       4.599n ± 0%    4.605n ± 0%   +0.12% (p=0.000 n=10)
MemclrUnaligned/4_64       7.572n ± 1%    5.283n ± 0%  -30.24% (p=0.000 n=10)
MemclrUnaligned/4_256     12.215n ± 0%    9.212n ± 0%  -24.58% (p=0.000 n=10)
MemclrUnaligned/4_4096    114.35n ± 0%    39.48n ± 0%  -65.47% (p=0.000 n=10)
MemclrUnaligned/4_65536   1705.0n ± 0%    469.2n ± 0%  -72.48% (p=0.000 n=10)
MemclrUnaligned/7_5        4.296n ± 1%    4.349n ± 0%   +1.22% (p=0.000 n=10)
MemclrUnaligned/7_16       4.601n ± 0%    4.606n ± 0%   +0.11% (p=0.004 n=10)
MemclrUnaligned/7_64       7.609n ± 0%    5.296n ± 1%  -30.39% (p=0.000 n=10)
MemclrUnaligned/7_256     12.200n ± 0%    9.011n ± 0%  -26.14% (p=0.000 n=10)
MemclrUnaligned/7_4096    114.00n ± 0%    39.51n ± 0%  -65.34% (p=0.000 n=10)
MemclrUnaligned/7_65536   1704.0n ± 0%    469.5n ± 0%  -72.45% (p=0.000 n=10)
MemclrUnaligned/0_1M       52.57µ ± 0%    32.83µ ± 0%  -37.54% (p=0.000 n=10)
MemclrUnaligned/0_4M       210.1µ ± 0%    131.3µ ± 0%  -37.53% (p=0.000 n=10)
MemclrUnaligned/0_8M       420.8µ ± 0%    262.5µ ± 0%  -37.62% (p=0.000 n=10)
MemclrUnaligned/0_16M      846.2µ ± 0%    528.4µ ± 0%  -37.56% (p=0.000 n=10)
MemclrUnaligned/0_64M      3.425m ± 1%    2.187m ± 3%  -36.16% (p=0.000 n=10)
MemclrUnaligned/1_1M       52.56µ ± 0%    32.84µ ± 0%  -37.52% (p=0.000 n=10)
MemclrUnaligned/1_4M       210.5µ ± 0%    131.3µ ± 0%  -37.62% (p=0.000 n=10)
MemclrUnaligned/1_8M       420.5µ ± 0%    262.7µ ± 0%  -37.53% (p=0.000 n=10)
MemclrUnaligned/1_16M      845.2µ ± 0%    528.3µ ± 0%  -37.49% (p=0.000 n=10)
MemclrUnaligned/1_64M      3.381m ± 0%    2.243m ± 3%  -33.66% (p=0.000 n=10)
MemclrUnaligned/4_1M       52.56µ ± 0%    32.85µ ± 0%  -37.50% (p=0.000 n=10)
MemclrUnaligned/4_4M       210.1µ ± 0%    131.3µ ± 0%  -37.49% (p=0.000 n=10)
MemclrUnaligned/4_8M       420.0µ ± 0%    262.6µ ± 0%  -37.48% (p=0.000 n=10)
MemclrUnaligned/4_16M      844.8µ ± 0%    528.7µ ± 0%  -37.41% (p=0.000 n=10)
MemclrUnaligned/4_64M      3.382m ± 1%    2.211m ± 4%  -34.63% (p=0.000 n=10)
MemclrUnaligned/7_1M       52.59µ ± 0%    32.84µ ± 0%  -37.56% (p=0.000 n=10)
MemclrUnaligned/7_4M       210.2µ ± 0%    131.3µ ± 0%  -37.54% (p=0.000 n=10)
MemclrUnaligned/7_8M       420.1µ ± 0%    262.7µ ± 0%  -37.47% (p=0.000 n=10)
MemclrUnaligned/7_16M      845.1µ ± 0%    528.7µ ± 0%  -37.43% (p=0.000 n=10)
MemclrUnaligned/7_64M      3.369m ± 0%    2.313m ± 1%  -31.34% (p=0.000 n=10)
MemclrRange/1K_2K         2707.0n ± 0%    972.4n ± 0%  -64.08% (p=0.000 n=10)
MemclrRange/2K_8K          8.816µ ± 0%    2.519µ ± 0%  -71.43% (p=0.000 n=10)
MemclrRange/4K_16K         8.333µ ± 0%    2.240µ ± 0%  -73.12% (p=0.000 n=10)
MemclrRange/160K_228K      83.47µ ± 0%    31.27µ ± 0%  -62.54% (p=0.000 n=10)
MemclrKnownSize1          0.4003n ± 0%   0.4004n ± 0%        ~ (p=0.119 n=10)
MemclrKnownSize2          0.4003n ± 0%   0.4005n ± 0%        ~ (p=0.069 n=10)
MemclrKnownSize4          0.4003n ± 0%   0.4005n ± 0%        ~ (p=0.100 n=10)
MemclrKnownSize8          0.4003n ± 0%   0.4004n ± 0%   +0.04% (p=0.047 n=10)
MemclrKnownSize16         0.8011n ± 0%   0.8012n ± 0%        ~ (p=0.926 n=10)
MemclrKnownSize32          1.602n ± 0%    1.602n ± 0%        ~ (p=0.772 n=10)
MemclrKnownSize64          2.405n ± 0%    2.404n ± 0%        ~ (p=0.780 n=10)
MemclrKnownSize112         2.804n ± 0%    2.804n ± 0%        ~ (p=0.538 n=10)
MemclrKnownSize128         3.204n ± 0%    3.205n ± 0%        ~ (p=0.105 n=10)
MemclrKnownSize192         4.808n ± 0%    4.807n ± 0%        ~ (p=0.688 n=10)
MemclrKnownSize248         6.347n ± 0%    6.346n ± 0%        ~ (p=0.133 n=10)
MemclrKnownSize256         6.560n ± 0%    6.573n ± 0%   +0.19% (p=0.001 n=10)
MemclrKnownSize512        13.010n ± 0%    6.809n ± 0%  -47.66% (p=0.000 n=10)
MemclrKnownSize1024       25.830n ± 0%    8.412n ± 0%  -67.43% (p=0.000 n=10)
MemclrKnownSize4096       102.70n ± 0%    27.64n ± 0%  -73.09% (p=0.000 n=10)
MemclrKnownSize512KiB      26.30µ ± 0%    16.42µ ± 0%  -37.59% (p=0.000 n=10)
geomean                    629.8n         393.2n       -37.57%

Change-Id: I2b9fe834c31d786d2e30cc02c65a6f9c455c4e8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/657835
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>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
2025-03-26 17:58:32 -07:00
qmuntal
d69ab99f3f net: run unix socket stream tests on Windows
The net package supports Unix domain sockets on Windows, but most of
the tests related to them are skipped.

This CL unskip the SOCK_STREAM tests. SOCK_DGRAM probablye can also
make to work, but that will come in a follow-up CL.

Change-Id: If9506a8af57e9bfe58bd7b48a98fc39335627a61
Reviewed-on: https://go-review.googlesource.com/c/go/+/660915
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-26 13:22:29 -07:00
qmuntal
440a8f7024 internal/poll: support async file operations on Windows
This CL adds support for async file operations on Windows. The affected
functions are Read, Write, Pread, and Pwrite.

The code has been slightly refactored to avoid duplication. Both the
async and sync variants follow the same code path, with the exception of
the async variant passes an overlapped structure to the syscalls
and supports the use of a completion port.

This doesn't change any user-facing behavior, as the os package still
sets the pollable parameter to false when calling FD.Init.

For #19098.

Change-Id: Iead6e51fa8f57e83456eb5ccdce28c2ea3846cc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/660595
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-03-26 13:05:03 -07:00
Jonathan Amsterdam
b138f8e4d2 log/slog: Handler doc points to handler guide
There's a link in the package doc, but there should be one here too.

For #73057.

Change-Id: I8f8fe73f20bb6dd49cdf23b5f7634a92d4f7add9
Reviewed-on: https://go-review.googlesource.com/c/go/+/661015
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-26 11:06:06 -07:00
Joel Sing
9ce47e66e8 cmd/internal/obj/arm64: add support for BTI instruction
Add support for the `BTI' instruction to the arm64 assembler. This
instruction provides Branch Target Identification for targets of
indirect branches. A BTI can be marked with a target type of
'C' (call), 'J' (jump) or 'JC' (jump or call).

Updates #66054

Change-Id: I1cf31a0382207bb75b9b2deb49ac298a59c00d8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/646781
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Marvin Drees <marvin.drees@9elements.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-26 03:48:50 -07:00
junya koyama
99d97d7c4f testing/slogtest: test nested groups in empty record
Updates #62280

Change-Id: I1c80cb18bb174b47ff156974f72c37baf6b73635
GitHub-Last-Rev: d98b6cd57eb028af8513f583cbef3ce46505b590
GitHub-Pull-Request: golang/go#65597
Reviewed-on: https://go-review.googlesource.com/c/go/+/562635
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
2025-03-25 19:19:09 -07:00
Xiaolin Zhao
0095b5d098 cmd/internal/obj/loong64: add [X]VSHUF4I.{B/H/W/D} instructions support
Go asm syntax:
	 VSHUF4I{B/H/W/V}	$1, V1, V2
	XVSHUF4I{B/H/W/V}	$2, X1, X2

Equivalent platform assembler syntax:
	 vshuf4i.{b/h/w/d}	v2, v1, $1
	xvshuf4i.{b/h/w/d}	x2, x1, $2

Change-Id: I6a847ccbd2c93432d87bd1390b5cf1508da06496
Reviewed-on: https://go-review.googlesource.com/c/go/+/658376
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-25 18:02:50 -07:00
Michael Matloob
87d1833c66 cmd/go/internal/modload: improve ErrNoModRoot error text
Before this change, in several cases where HasModRoot() returned false,
we'd return ErrNoModRoot. ErrNoModRoot would say that there was no
go.mod file but would not mention workspaces. With this change,
ErrNoModRoot will return error text that's different if we're in a
workspace, saying that there are no modules in the workspace.

Fixes #54419

Change-Id: I77c94d0011947bf8e33c066416ab3762502fd2e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/660675
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-03-25 13:48:29 -07:00
Julien Cretel
44fef2aa4d bytes: speed up Replace
This CL is to package bytes what CL 657935 was to package strings.

Add fuzz test and 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: bytes
cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
                                 │     old      │                 new                 │
                                 │    sec/op    │   sec/op     vs base                │
Replace/"hello"_"l"_"L"_0-8         27.83n ± 2%   27.22n ± 1%   -2.17% (p=0.000 n=20)
Replace/"hello"_"l"_"L"_-1-8        60.64n ± 0%   57.97n ± 1%   -4.40% (p=0.000 n=20)
Replace/"hello"_"x"_"X"_-1-8        33.99n ± 0%   33.88n ± 0%        ~ (p=0.140 n=20)
Replace/""_"x"_"X"_-1-8             10.40n ± 1%   10.57n ± 0%   +1.64% (p=0.000 n=20)
Replace/"radar"_"r"_"<r>"_-1-8      62.63n ± 0%   61.39n ± 0%   -1.98% (p=0.000 n=20)
Replace/""_""_"<>"_-1-8             29.76n ± 1%   24.18n ± 1%  -18.75% (p=0.000 n=20)
Replace/"banana"_"a"_"<>"_-1-8      77.00n ± 0%   77.10n ± 1%        ~ (p=0.525 n=20)
Replace/"banana"_"a"_"<>"_1-8       44.24n ± 0%   43.57n ± 1%   -1.54% (p=0.000 n=20)
Replace/"banana"_"a"_"<>"_1000-8    78.23n ± 0%   77.16n ± 1%   -1.36% (p=0.000 n=20)
Replace/"banana"_"an"_"<>"_-1-8     72.78n ± 1%   69.97n ± 1%   -3.85% (p=0.000 n=20)
Replace/"banana"_"ana"_"<>"_-1-8    54.41n ± 0%   54.04n ± 1%   -0.67% (p=0.033 n=20)
Replace/"banana"_""_"<>"_-1-8       116.8n ± 1%   103.5n ± 1%  -11.42% (p=0.000 n=20)
Replace/"banana"_""_"<>"_10-8       117.2n ± 1%   103.6n ± 0%  -11.60% (p=0.000 n=20)
Replace/"banana"_""_"<>"_6-8       105.30n ± 0%   92.50n ± 0%  -12.16% (p=0.000 n=20)
Replace/"banana"_""_"<>"_5-8        91.81n ± 0%   79.87n ± 1%  -13.01% (p=0.000 n=20)
Replace/"banana"_""_"<>"_1-8        35.87n ± 1%   30.33n ± 1%  -15.43% (p=0.000 n=20)
Replace/"banana"_"a"_"a"_-1-8       70.84n ± 0%   68.83n ± 0%   -2.84% (p=0.000 n=20)
Replace/"banana"_"a"_"a"_1-8        44.27n ± 1%   43.47n ± 1%   -1.80% (p=0.000 n=20)
Replace/"☺☻☹"_""_"<>"_-1-8         104.25n ± 1%   93.33n ± 0%  -10.48% (p=0.000 n=20)
geomean                             56.31n        52.88n        -6.09%

Change-Id: I5daf44ccfd887da445d8c681415c32de7c2b85d1
GitHub-Last-Rev: d1caf1f0845a402a026764068a1db4dcf73e9017
GitHub-Pull-Request: golang/go#72967
Reviewed-on: https://go-review.googlesource.com/c/go/+/659515
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-25 13:02:53 -07:00
Sean Liao
2bf57a3534 testing: document exit codes
Fixes #25989

Change-Id: I2e2a2a17854034ff68e69b8973018b1b2e7d59f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/660076
Reviewed-by: Thanyalak Detkhong (Palm’my) <pmy4416@gmail.com>
Reviewed-by: 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-03-25 11:52:07 -07:00
qmuntal
936bb82ddb internal/poll,net: set SIO_UDP_CONNRESET in net
Setting the SIO_UDP_CONNRESET option in internal/poll.FD.Init
adds unnecessary complexity to the FD.Init signature and
implementation. Better to set it in the net package when initializing
the UDP connection, which is where conceptually it belongs.

While here, update an outdated comment in FD.Init that said the runtime
poller doesn't support I/O operations initialized by the user
outside the internal/poll package. It does support those operations
since CL 561895.

For #19098.
Updates #21172.

Change-Id: I9a70b0deafdb4619830abe2147e2d366b4c2b890
Reviewed-on: https://go-review.googlesource.com/c/go/+/660496
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-25 11:36:25 -07:00
qmuntal
35c9864897 internal/poll: always use SetFileCompletionNotificationModes on non-socket handles
SetFileCompletionNotificationModes can be unconditionally called on
non-socket handles.

The Windows poll.FD implementation still doesn't support non-socket
pollable handles yet, so this CL doesn't change any behavior.
Support for pollable non-socket handles will come in subsequent CLs.

For #19098.

Change-Id: I811a61497cfbb26acb566c20367d212335b9d551
Reviewed-on: https://go-review.googlesource.com/c/go/+/660495
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2025-03-25 11:33:49 -07:00
Joel Sing
6bf95d40bb test/codegen: add combined conversion and shift tests
This adds tests for type conversion and shifts, detailing various
poor bad code generation that currently exists for riscv64. This
will be addressed in future CLs.

Change-Id: Ie1d366dfe878832df691600f8500ef383da92848
Reviewed-on: https://go-review.googlesource.com/c/go/+/615678
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-03-25 06:53:49 -07:00
Joel Sing
fd0805b660 cmd/internal/obj/arm64: move register encoding into opldrr/opstrr
Rather than having register encoding knowledge in each caller of opldrr/opstrr
(and in a separate olsxrr function), pass the registers into opldrr/opstrr and
let them handle the encoding. This reduces duplication and improves readability.

Change-Id: I50a25263f305d01454f3ff95e8b6e7c76e760ab0
Reviewed-on: https://go-review.googlesource.com/c/go/+/471521
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-03-25 06:00:40 -07:00
Xiaolin Zhao
ac8474c0a2 cmd/internal/obj/loong64: add [X]VMULW{EV/OD} series instructions support
Go asm syntax:
	 VMULW{EV/OD}{HB/WH/VW/QV}[U]		VK, VJ, VD
	XVMULW{EV/OD}{HB/WH/VW/QV}[U]		XK, XJ, XD
	 VMULW{EV/OD}{HBUB/WHUH/VWUW/QVUV}	VK, VJ, VD
	XVMULW{EV/OD}{HBUB/WHUH/VWUW/QVUV}	XK, XJ, XD

Equivalent platform assembler syntax:
	 vmulw{ev/od}.{h.b/w.h/d.w/q.d}[u]		vd, vj, vk
	xvmulw{ev/od}.{h.b/w.h/d.w/q.d}[u]		xd, xj, xk
	 vmulw{ev/od}.{h.bu.b/w.hu.h/d.wu.w/q.du.d}	vd, vj, vk
	xvmulw{ev/od}.{h.bu.b/w.hu.h/d.wu.w/q.du.d}	xd, xj, xk

Change-Id: Ib1b5fb9605417a2b81841deae40e0e2beb90d03c
Reviewed-on: https://go-review.googlesource.com/c/go/+/658375
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
2025-03-25 05:49:58 -07:00
Joel Sing
4f5863c2ce cmd/internal/obj/arm64: provide and use an oprrrr function
Provide a four register version of oprrr, which takes an additional 'ra'
register. Use this instead of oprrr where appropriate.

Change-Id: I8882957a83c2b08e407f37a37c61864cd920bbc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/471519
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-03-25 04:12:09 -07:00
Joel Sing
f90f3cfcf7 cmd/internal/obj/arm64: move register encoding into oprrr
Rather than having register encoding knowledge in each caller of oprrr,
pass the registers into oprrr and let it handle the encoding. This reduces
duplication and improves readability.

Change-Id: Iab6c70f7796b7a8c071419654b8a5686aeee8c1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/471518
Reviewed-by: Fannie Zhang <Fannie.Zhang@arm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-03-25 04:08:38 -07:00
Joel Sing
dab10bca37 cmd/internal/obj/arm64: replace range checks with isaddcon2
isaddcon2 tests for the range 0 <= v <= 0xffffff - replace duplicated range
checks with calls to isaddcon2.

Change-Id: Ia6f331852ed3d77715b265cb4fcc500579eac711
Reviewed-on: https://go-review.googlesource.com/c/go/+/650935
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Fannie Zhang <Fannie.Zhang@arm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-25 04:03:02 -07:00
Michael Pratt
4f11f8ff7d runtime: rename runfinq to runFinalizersAndCleanups
Users see this frame in tracebacks and it serves as a hint that what is
running here is a finalizer or cleanup. But runfinq is a rather dense
name. We can give it a more obvious name to help users realize what it
is.

For #73011.

Change-Id: I6a6a636ce9a493fd00d4b4c60c23f2b1c96d3568
Reviewed-on: https://go-review.googlesource.com/c/go/+/660296
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-03-24 20:56:45 -07:00
Michael Pratt
9c88db5f1e runtime: always show runfinq in traceback
Today, runtime.runfinq is hidden whenever runtime frames are hidden.

However this frame serves as a hint that this goroutine is running
finalizers, which is otherwise unclear, but can be useful when debugging
issues with finalizers.

Fixes #73011.

Change-Id: I6a6a636cb63951fbe1fefc3554fe9cea5d0a0fb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/660295
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>
2025-03-24 17:15:19 -07:00
Austin Clements
aaf9b46800 testing: streamline logic in loopSlowPath
There's a fair amount of duplication of logic between various return
branches of loopSlowPath and stopOrScaleBLoop. Restructure these so
there's a single "keep going" path and a single "we're done" path.

Change-Id: I38e4c7a616f8bd7707f3ca886f38ff21dbd78b6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/659658
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-03-24 11:41:13 -07:00
Austin Clements
5918101d67 testing: detect a stopped timer in B.Loop
Currently, if the user stops the timer in a B.Loop benchmark loop, the
benchmark will run until it hits the timeout and fails.

Fix this by detecting that the timer is stopped and failing the
benchmark right away. We avoid making the fast path more expensive for
this check by "poisoning" the B.Loop iteration counter when the timer
is stopped so that it falls back to the slow path, which can check the
timer.

This causes b to escape from B.Loop, which is totally harmless because
it was already definitely heap-allocated. But it causes the
test/inline_testingbloop.go errorcheck test to fail. I don't think the
escape messages actually mattered to that test, they just had to be
matched. To fix this, we drop the debug level to -m=1, since -m=2
prints a lot of extra information for escaping parameters that we
don't want to deal with, and change one error check to allow b to
escape.

Fixes #72971.

Change-Id: I7d4abbb1ec1e096685514536f91ba0d581cca6b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/659657
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-24 11:41:09 -07:00
Austin Clements
b7f8c2a110 testing: detect early return from B.Loop
Currently, if a benchmark function returns prior to B.Loop() returning
false, we'll report a bogus result. While there was no way to detect
this with b.N-style benchmarks, one way b.Loop()-style benchmarks are
more robust is that we *can* detect it.

This CL adds a flag to B that tracks if B.Loop() has finished and
checks it after the benchmark completes. If there was an early exit
(not caused by another error), it reports a B.Error.

Fixes #72933.
Updates #72971.

Change-Id: I731c1350e6df938c0ffa08fcedc11dc147e78854
Reviewed-on: https://go-review.googlesource.com/c/go/+/659656
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-03-24 11:41:05 -07:00
Sean Liao
c72e274725 go/build: prioritize build constraints in docs
Now that modules is the primary way of building go code,
GOPATH shouldn't be the first topic.

Change-Id: Icaf6c651bdcfbe69068c5980845f8eb5e40ead99
Reviewed-on: https://go-review.googlesource.com/c/go/+/660135
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-24 10:22:30 -07:00
Jake Bailey
710476495a testing: remove redundant variable capture from subtest example
Loop variable capturing hasn't been needed like this since Go 1.21;
remove it from the example.

Change-Id: I231dcfdb57832e32d524f156a605ba36d1c9d6d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/660176
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: 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-03-24 10:16:54 -07:00
Michael Matloob
2d2bcdd2ad cmd/go: upgrade go install pkg@version's go using local mod, work
This CL changes the toolchain selection behavior for go install pkg@v
and go run pkg@v to also take into account the go and toolchain version
lines in the containing go.mod and go.work file.

Before this change, the go command would detect that go install
pkg@version or go run pkg@version was being run and skip the standard
behavior that would select the toolchain based on the go version in the
go.mod or go.work file. It would instead check the go line of the module
being downloaded and switch to that version if necessary.

With this change, the go command does not skip the standard behavior. It
proceeds to determine if an upgrade is required based on the containing
go.mod or go.work file's go and toolchain lines. Then, it checks the
module being installed to see if it would require a higher version than
the determined upgrade (or the local version if no upgrade was
determined). If it does require a higher version, then a switch happens
to that version, and if not the upgrade logic proceeds as usual doing
the upgrade if one was determined.

Fixes #66518

Change-Id: I00d96170e8713c451cc0fd2203be521585418842
Reviewed-on: https://go-review.googlesource.com/c/go/+/660035
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-24 09:57:26 -07:00
Sean Liao
7372b64425 net/url: document referenced RFCs
Fixes #30611

Change-Id: If933c2a7e63d89402d2034618057ad546cf9641b
Reviewed-on: https://go-review.googlesource.com/c/go/+/660077
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>
Reviewed-by: Damien Neil <dneil@google.com>
2025-03-24 08:34:32 -07:00
Damien Neil
d2d1fd68b6 os: add Root.Link
For #67002

Change-Id: I223f3f2dbc8b02726f4ce5a017c628c4a20f109a
Reviewed-on: https://go-review.googlesource.com/c/go/+/659757
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
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>
2025-03-24 07:53:38 -07:00
Vishwanatha HD
4ae6ab2bdf cmd/asm: add LCDBR instruction on s390x
This CL is to add LCDBR assembly instruction mnemonics, mainly used in math package.

The LCDBR instruction has the same effect as the FNEG pseudo-instructions, just that it sets the flag.

Change-Id: I3f00f1ed19148d074c3b6c5f64af0772289f2802
Reviewed-on: https://go-review.googlesource.com/c/go/+/648036
Reviewed-by: Srinivas Pokala <Pokala.Srinivas@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Munday <mike.munday@lowrisc.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2025-03-24 07:05:55 -07:00
Robert Griesemer
3ada42ffed go/types, types2: align trace output a bit better for easier debugging
Compute alignment padding rather than using a tab in trace output.
This aligns the ":" after the file position in typical cases (files
shorter than 1000 lines, lines shorter than 100 columns), resulting
in nicer trace output for easier debugging.

Before this CL (example trace):

x.go:8:2:  -- checking type A (white, objPath = )
x.go:8:11:  .  -- type B
x.go:9:2:  .  .  -- checking type B (white, objPath = A)
x.go:9:14:  .  .  .  -- type C[D]
x.go:9:13:  .  .  .  .  -- instantiating type C with [D]
x.go:9:13:  .  .  .  .  .  -- type C
x.go:10:2:  .  .  .  .  .  .  -- checking type C (white, objPath = A->B)
x.go:10:6:  .  .  .  .  .  .  .  -- type any
x.go:10:6:  .  .  .  .  .  .  .  => any (under = any) // *Alias
x.go:10:11:  .  .  .  .  .  .  .  -- type struct{}
x.go:10:11:  .  .  .  .  .  .  .  => struct{} // *Struct
x.go:10:2:  .  .  .  .  .  .  => type C[_ any] struct{} (black)

With this CL:

x.go:8:2   :  -- checking type A (white, objPath = )
x.go:8:11  :  .  -- type B
x.go:9:2   :  .  .  -- checking type B (white, objPath = A)
x.go:9:14  :  .  .  .  -- type C[D]
x.go:9:13  :  .  .  .  .  -- instantiating type C with [D]
x.go:9:13  :  .  .  .  .  .  -- type C
x.go:10:2  :  .  .  .  .  .  .  -- checking type C (white, objPath = A->B)
x.go:10:6  :  .  .  .  .  .  .  .  -- type any
x.go:10:6  :  .  .  .  .  .  .  .  => any (under = any) // *Alias
x.go:10:11 :  .  .  .  .  .  .  .  -- type struct{}
x.go:10:11 :  .  .  .  .  .  .  .  => struct{} // *Struct
x.go:10:2  :  .  .  .  .  .  .  => type C[_ any] struct{} (black)

Change-Id: Ibcf346737f57ec5351d1e1e65178e2c3c155d766
Reviewed-on: https://go-review.googlesource.com/c/go/+/659755
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-23 22:15:04 -07:00
Joel Sing
b70244ff7a cmd/compile: intrinsify math/bits.Len on riscv64
For riscv64/rva22u64 and above, we can intrinsify math/bits.Len using the
CLZ/CLZW machine instructions.

On a StarFive VisionFive 2 with GORISCV64=rva22u64:

                 │   clz.b.1   │               clz.b.2               │
                 │   sec/op    │   sec/op     vs base                │
LeadingZeros-4     28.89n ± 0%   12.08n ± 0%  -58.19% (p=0.000 n=10)
LeadingZeros8-4    18.79n ± 0%   14.76n ± 0%  -21.45% (p=0.000 n=10)
LeadingZeros16-4   25.27n ± 0%   14.76n ± 0%  -41.59% (p=0.000 n=10)
LeadingZeros32-4   25.12n ± 0%   12.08n ± 0%  -51.92% (p=0.000 n=10)
LeadingZeros64-4   25.89n ± 0%   12.08n ± 0%  -53.35% (p=0.000 n=10)
geomean            24.55n        13.09n       -46.70%

Change-Id: I0dda684713dbdf5336af393f5ccbdae861c4f694
Reviewed-on: https://go-review.googlesource.com/c/go/+/652321
Reviewed-by: David Chase <drchase@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: Cherry Mui <cherryyz@google.com>
2025-03-21 18:21:44 -07:00
Joel Sing
af133d86e4 cmd/internal/obj/riscv: factor out shift constant code
Move the code that tests to see if a constant can be represented by a
32 bit signed integer and a logical left shift. This reduces duplication
and increases readability. Also add test coverage now that this is an
independent function.

Change-Id: Id25395b1380b00cf5b69ca201b7715ef84f7ade6
Reviewed-on: https://go-review.googlesource.com/c/go/+/652777
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-03-21 17:40:34 -07:00
Joel Sing
574e836055 cmd/asm/internal/asm: add additional tests for constant loads on riscv64
This improves test coverage around the various constant load edge cases.

Change-Id: Ibafeec78e76d95e9f56b48fa6bd012772bf505c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/652776
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
2025-03-21 17:38:35 -07:00
Austin Clements
9003154206 testing: separate b.Loop counter from b.N
Currently, b.Loop uses b.N as the iteration count target. However,
since it updates the target as it goes, the behavior is quite
different from a b.N-style benchmark. To avoid user confusion, this CL
gives b.Loop a separate, unexported iteration count target. It ensures
b.N is 0 within the b.Loop loop to help catch misuses, and commits the
final iteration count to b.N only once the loop is done (as the
documentation states "After Loop returns false, b.N contains the total
number of iterations that ran, so the benchmark may use b.N to compute
other average metrics.")

Since there are now two variables used by b.Loop, we put them in an
unnamed struct. Also, we rename b.loopN to b.loop.i because this
variable tracks the current iteration index (conventionally "i"), not
the target (conventionally "n").

Unfortunately, a simple renaming causes B.Loop to be too large for the
inliner. Thus, we make one simplification to B.Loop to keep it under
the threshold. We're about to lean into that simplification anyway in
a follow-up CL, so this is just temporary.

Prep for #72933 and #72971.

Change-Id: Ide1c4f1b9ca37f300f3beb0e60ba6202331b183e
Reviewed-on: https://go-review.googlesource.com/c/go/+/659655
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Austin Clements <austin@google.com>
2025-03-21 16:12:09 -07:00
Derek Parker
afe11db4a7 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>
2025-03-21 15:02:04 -07:00
qmuntal
ba01453bbe 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>
2025-03-21 14:24:52 -07:00
qmuntal
3108366214 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>
2025-03-21 14:24:40 -07:00
Damien Neil
2cc0ea46e4 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>
2025-03-21 12:16:10 -07:00
Damien Neil
a39046f6ad 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>
2025-03-21 12:00:30 -07:00
Damien Neil
c0392e7e49 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>
2025-03-21 09:32:55 -07:00
Cherry Mui
69ea62fe95 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>
2025-03-21 09:29:02 -07:00
Mark Ryan
c386ed107e 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>
2025-03-20 21:24:28 -07:00
Damien Neil
c558f017ef 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>
2025-03-20 20:47:05 -07:00
Derek Parker
a20d583bb9 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>
2025-03-20 15:45:30 -07:00
Damien Neil
2ffda87f2d 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>
2025-03-20 15:12:24 -07:00
Damien Neil
686128a9f3 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>
2025-03-20 15:02:35 -07:00
Julien Cretel
93fe8c0415 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>
2025-03-20 14:49:24 -07:00
Junyang Shao
b613d21ffd 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>
2025-03-20 12:42:51 -07:00
Damien Neil
ba50de8429 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>
2025-03-20 11:23:35 -07:00
Mateusz Poliwczak
9dc572eab5 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>
2025-03-20 09:10:17 -07:00
qmuntal
e9558d3947 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>
2025-03-20 09:10:13 -07:00
qmuntal
a4a5ef08bd 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>
2025-03-20 09:09:46 -07:00
Max Neverov
665af86992 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>
2025-03-20 09:05:13 -07:00
Sean Liao
84e0061460 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>
2025-03-20 09:04:21 -07:00
Julien Cretel
2fb5610c3a 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>
2025-03-20 08:53:39 -07:00
Mateusz Poliwczak
19b6f01161 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>
2025-03-20 08:38:53 -07:00
qiulaidongfeng
02014706f0 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>
2025-03-20 08:28:57 -07:00
Kir Kolyshkin
b59b0580a1 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>
2025-03-20 08:15:51 -07:00
Joel Sing
03cb8d408e 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>
2025-03-20 08:15:01 -07:00
Kir Kolyshkin
af0d51c70f 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>
2025-03-20 08:11:21 -07:00
Edoardo Spadolini
b1ec5ad00a 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>
2025-03-20 08:08:47 -07:00
Filippo Valsorda
dc49aba8e4 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>
2025-03-20 08:07:01 -07:00
Sean Liao
57dac327d1 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>
2025-03-20 04:38:55 -07:00
Damien Neil
4bc6c71ee0 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>
2025-03-19 22:21:07 -07:00
Kir Kolyshkin
f233739850 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>
2025-03-19 17:33:15 -07:00
Damien Neil
48240ad3f9 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>
2025-03-19 15:39:13 -07:00
Damien Neil
cb0d767a10 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>
2025-03-19 12:00:51 -07:00
Damien Neil
1eb1579fba 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>
2025-03-19 10:48:54 -07:00
Damien Neil
f9f5d1e844 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>
2025-03-19 10:21:06 -07:00
Robert Griesemer
011b7ce8d1 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>
2025-03-19 10:15:42 -07:00
Damien Neil
1aa9c31ffc 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>
2025-03-19 09:57:03 -07:00
Keith Randall
deb6790fcf 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>
2025-03-19 09:55:46 -07:00
Florian Zenker
56e5476e10 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>
2025-03-19 07:06:55 -07:00
Mark Ryan
1aee4f3464 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>
2025-03-19 07:00:36 -07:00
Mark Ryan
24b395119b 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>
2025-03-18 18:36:01 -07:00
Jordan Liggitt
2e749a645a 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>
2025-03-18 18:13:33 -07:00
Damien Neil
2148309963 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>
2025-03-18 17:32:48 -07:00
Keith Randall
3309658d39 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>
2025-03-18 15:22:33 -07:00
Sean Liao
bfb27fb36f 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>
2025-03-18 15:12:18 -07:00
Filippo Valsorda
fcb27f717b 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>
2025-03-18 14:04:58 -07:00
Sean Liao
c8eced8580 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>
2025-03-18 12:57:12 -07:00
Michael Matloob
6b18311bbc 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>
2025-03-18 11:22:30 -07:00
Damien Neil
a17c092c2c 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>
2025-03-18 10:52:10 -07:00
Damien Neil
5916bc5b57 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>
2025-03-18 10:50:51 -07:00
limeidan
0694718389 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>
2025-03-17 18:31:30 -07:00
limeidan
180795ceac 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>
2025-03-17 18:30:39 -07:00
古大羊
cd2f347c61 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>
2025-03-17 14:34:46 -07:00
Sean Liao
c7ea87132f 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>
2025-03-17 13:39:09 -07:00
qmuntal
eb7ab11aaf 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>
2025-03-17 13:28:25 -07:00
qmuntal
44d1d2e5ad 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>
2025-03-17 13:27:50 -07:00
Mohammed Al Sahaf
7a8ce5e3de 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>
2025-03-17 13:23:49 -07:00
Rhys Hiltner
5e98202455 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>
2025-03-17 13:10:18 -07:00
Ilya Priven
e41ec30c8a 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>
2025-03-17 13:09:29 -07:00
Michael Matloob
bceade5ef8 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>
2025-03-17 10:23:40 -07:00
Sean Liao
57c44fdefc 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>
2025-03-17 08:52:14 -07:00
Michael Pratt
7dd7d70c03 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>
2025-03-17 06:04:15 -07:00
Xiaolin Zhao
f41fdd962d 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>
2025-03-16 20:39:28 -07:00
Julien Cretel
38d146d572 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>
2025-03-16 15:46:25 -07:00
Joel Sing
6fb7bdc96d 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>
2025-03-15 19:07:53 -07:00
Jorropo
e6ffe764cf 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>
2025-03-15 13:13:56 -07:00
cui fliter
e0edd3e155 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>
2025-03-15 13:12:47 -07:00
Tobias Klauser
bb6a400028 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>
2025-03-15 13:07:33 -07:00
Rhys Hiltner
35139d6e45 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>
2025-03-15 13:07:01 -07:00
Joel Sing
21417518a9 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>
2025-03-15 06:05:16 -07:00
Joel Sing
10d070668c 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>
2025-03-15 06:04:28 -07:00
Joel Sing
a8f2e63f2f 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>
2025-03-15 06:02:57 -07:00
Joel Sing
e1f9013a58 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>
2025-03-15 06:02:27 -07:00
Joel Sing
c01fa0cc21 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>
2025-03-15 05:58:43 -07:00
Rhys Hiltner
3c3b8dd4f0 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>
2025-03-14 15:42:34 -07:00
Maciej Żok
580b6ee646 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>
2025-03-14 15:09:04 -07:00
Meng Zhuo
5bb73e6504 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>
2025-03-14 15:08:23 -07:00
1911860538
853b514417 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>
2025-03-14 15:08:20 -07:00
Joel Sing
c1c7e5902f 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>
2025-03-14 15:04:38 -07:00
Michael Pratt
577bb3d0ce 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>
2025-03-14 12:54:11 -07:00
Roland Shoemaker
7e3d2aa69f 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>
2025-03-14 11:40:43 -07:00
Keith Randall
a1ddbdd3ef 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>
2025-03-13 21:24:20 -07:00
Xiaolin Zhao
80f068928f 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>
2025-03-13 17:18:49 -07:00
Roland Shoemaker
937368f84e 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>
2025-03-13 16:44:25 -07:00
Roland Shoemaker
3b456ff421 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>
2025-03-13 16:42:59 -07:00
qmuntal
d704ef7606 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>
2025-03-13 14:01:46 -07:00
Filippo Valsorda
6114b69e0c 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>
2025-03-13 13:33:22 -07:00
Filippo Valsorda
59afdd3ed0 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>
2025-03-13 13:32:40 -07:00
Holger Hans Peter Freyther
0f5d86c5a0 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>
2025-03-13 11:36:59 -07:00
Filippo Valsorda
6bd5741a4c 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>
2025-03-13 08:19:32 -07:00
Filippo Valsorda
fbdd994166 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>
2025-03-13 08:10:52 -07:00
Michael Matloob
12ea4f7785 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>
2025-03-13 08:02:03 -07:00
Jes Cok
f3c69c2e78 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>
2025-03-13 07:40:35 -07:00
Tobias Klauser
fb8691edae 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>
2025-03-13 05:24:54 -07:00
Joel Sing
af92bb594d 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>
2025-03-13 05:19:13 -07:00
Than McIntosh
bdfa604b2e 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>
2025-03-13 05:16:59 -07:00
Than McIntosh
d7f58834cb 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>
2025-03-13 05:16:49 -07:00
Joel Sing
8cdef129fb 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>
2025-03-13 04:22:49 -07:00
Xiaolin Zhao
b143c98169 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>
2025-03-12 18:18:03 -07:00
Xiaolin Zhao
b10c35945d 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>
2025-03-12 17:52:19 -07:00
Luca Maltagliati
d729053edf mime/multipart: add helper to build content-disposition header contents
This PR adds an helper FileContentDisposition that builds multipart
Content-Disposition header contents with field name and file name,
escaping quotes and escape characters.

The  function is then called in the related helper CreateFormFile.

The new function allows users to add other custom MIMEHeaders,
without having to rewrite the char escaping logic of field name and
file name, which is provided by the new helper.

Fixes #46771

Change-Id: Ifc82a79583feb6dd609ca1e6024e612fb58c05ce
GitHub-Last-Rev: 969f846fa967d2b3eca7a21ee096b299b8a94546
GitHub-Pull-Request: golang/go#63324
Reviewed-on: https://go-review.googlesource.com/c/go/+/531995
Reviewed-by: 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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-03-12 16:20:01 -07:00
Michael Matloob
a68bf75d34 cmd/go: don't write own toolchain line when updating go line
The Go command had a behavior of writing its own toolchain name when
updating the go line in a go.mod (for example when a user runs go get
go@version). This behavior was often undesirable and the toolchain line
was often removed by users before checking in go.mod files (including in
the x/ repos). It also led to user confusion.

This change removes that behavior. A toolchain line will not be added if
one wasn't present before. The toolchain line can still be removed
though: the toolchain line must be at least the go version, so if the go
version is increased above the toolchain version, the toolchain version
will be bumped up to that go version. Then the toolchain line will then
be dropped because go <version> implies toolchain <version>.

Making this change slightly hurts reproducability because future go
commands run on the go.mod file may be run with a different toolchain
than the one that used it, but that doesn't seem to be worth the
confusion the behavior resulted in.

We expect this change will not have negative consequences, but it could
be possible, and we would like to hear from any users that depended on
the previous behavior in case we need to roll it back before the
release.

Fixes #65847

Change-Id: Id795b7f762e4f90ba0fa8c7935d03f32dfc8590e
Reviewed-on: https://go-review.googlesource.com/c/go/+/656835
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-12 11:44:56 -07:00
Brad Fitzpatrick
485480faaa net: deflake recently added TestCloseUnblocksReadUDP
Fixes #72802

Change-Id: I0dd457ef81a354f61c9de306e4609efdbe3d69b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/656857
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Brad Fitzpatrick <bradfitz@golang.org>
2025-03-12 11:02:25 -07:00
Than McIntosh
955cf0873f cmd/internal/dwarf: fix bug in inlined func DIE range DWARF 5 info
This patch changes the strategy we use in the compiler for handling
range information for inlined subroutine bodies, fixing a bug in how
this was handled for DWARF 5.  The high and lo PC values being emitted
for DW_TAG_inlined_subroutine DIEs were incorrect, pointing to the
start of functions instead of the proper location. The fix in this
patch is to move to unconditionally using DW_AT_ranges for inlined
subroutines, even those with only a single range.

Background: prior to this point, if a given inlined function body had
a single contiguous range, we'd pick an abbrev entry for it with
explicit DW_AT_low_pc and DW_AT_high_pc attributes. If the extent of
the code for the inlined body was not contiguous (which can happen),
we'd select an abbrev that used a DW_AT_ranges attribute instead. This
strategy (preferring explicit hi/lo PC attrs for a single-range func)
made sense for DWARF 4, since in DWARF 4 the representation used in
the .debug_ranges section was especially heavyweight (lots of space,
lots of relocations), so having explicit hi/lo PC attrs was less
expensive.

With DWARF 5 range info is written to the .debug_rnglists section, and
the representation here is much more compact. Specifically, a single
hi/lo range can be represented using a base address in addrx format
(max of 4 bytes, but more likely 2 or 3) followed by start and
endpoints of the range in ULEB128 format. This combination is more
compact spacewise than the explicit hi/lo values, and has fewer
relocations (0 as opposed to 2).

Note: we should at some point consider applying this same strategy to
lexical scopes, since we can probably reap some of the same benefits
there as well.

Updates #26379.
Fixes #72821.

Change-Id: Ifb65ecc6221601bad2ca3939f9b69964c1fafc7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/657175
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: Alessandro Arzilli <alessandro.arzilli@gmail.com>
2025-03-12 10:15:52 -07:00
Aoang
bec12f153a log/slog: optimize appendKey to reduce allocations
This change introduces a new method, `appendTwoStrings`, which
optimizes the `appendKey` function by avoiding the allocation of a
temporary string (string concatenation of prefix and key). Instead, it
directly appends the prefix and key to the buffer.

Additionally, added `BenchmarkAppendKey` benchmark tests to validate performance improvements.

This change improves performance in cases where large prefixes are used,
as verified by the following benchmarks:

goos: darwin
goarch: arm64
pkg: log/slog
cpu: Apple M1 Max
                             │   old.out   │               new.out               │
                             │   sec/op    │   sec/op     vs base                │
AppendKey/prefix_size_5-10     44.41n ± 0%   35.62n ± 0%  -19.80% (p=0.000 n=10)
AppendKey/prefix_size_10-10    48.17n ± 0%   39.12n ± 0%  -18.80% (p=0.000 n=10)
AppendKey/prefix_size_30-10    84.50n ± 0%   62.30n ± 0%  -26.28% (p=0.000 n=10)
AppendKey/prefix_size_50-10    124.9n ± 0%   102.3n ± 0%  -18.09% (p=0.000 n=10)
AppendKey/prefix_size_100-10   203.6n ± 1%   168.7n ± 0%  -17.14% (p=0.000 n=10)
geomean                        85.61n        68.41n       -20.09%

                             │    old.out    │                 new.out                 │
                             │     B/op      │    B/op     vs base                     │
AppendKey/prefix_size_5-10      0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
AppendKey/prefix_size_10-10     0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
AppendKey/prefix_size_30-10     48.00 ± 0%      0.00 ± 0%  -100.00% (p=0.000 n=10)
AppendKey/prefix_size_50-10    128.00 ± 0%     64.00 ± 0%   -50.00% (p=0.000 n=10)
AppendKey/prefix_size_100-10    224.0 ± 0%     112.0 ± 0%   -50.00% (p=0.000 n=10)
geomean                                    ²               ?                       ² ³
¹ all samples are equal
² summaries must be >0 to compute geomean
³ ratios must be >0 to compute geomean

                             │   old.out    │                 new.out                 │
                             │  allocs/op   │ allocs/op   vs base                     │
AppendKey/prefix_size_5-10     0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
AppendKey/prefix_size_10-10    0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
AppendKey/prefix_size_30-10    1.000 ± 0%     0.000 ± 0%  -100.00% (p=0.000 n=10)
AppendKey/prefix_size_50-10    2.000 ± 0%     1.000 ± 0%   -50.00% (p=0.000 n=10)
AppendKey/prefix_size_100-10   2.000 ± 0%     1.000 ± 0%   -50.00% (p=0.000 n=10)
geomean                                   ²               ?                       ² ³
¹ all samples are equal
² summaries must be >0 to compute geomean
³ ratios must be >0 to compute geomean

This patch improves performance without altering the external behavior of the `slog` package.

Change-Id: I8b47718de522196f06e0ddac48af73e352d2e5cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/631415
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-12 09:53:59 -07:00
Joel Sing
7e8ceadf85 cmd/compile/internal/ssagen: use an alias for math/bits.Len
Rather than using a specific intrinsic for math/bits.Len, use a pair of
aliases instead. This requires less code and automatically adapts when
platforms have a math/bits.Len32 or math/bits.Len64 intrinsic.

Change-Id: I28b300172daaee26ef82a7530d9e96123663f541
Reviewed-on: https://go-review.googlesource.com/c/go/+/656995
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2025-03-12 09:04:33 -07:00
Russ Cox
a812e5f3c3 math/big: update calibration tests and recalibrate
Refactor calibration tests to use the same logic for all.

Choosing thresholds that are broadly appropriate for all systems is part science
but also part guesswork and judgement. We could instead set per-GOOS/GOARCH
thresholds, but that seems like too much work, and even then there would be
variation between different chips within a GOOS/GOARCH.
(For example see the three linux/amd64 systems benchmarked below.)

The thresholds chosen in this CL are:

	karatsubaThreshold = 40 // unchanged
	basicSqrThreshold = 12 // was 20
	karatsubaSqrThreshold = 80 // was 260
	divRecursiveThreshold = 40 // was 100

The new file calibrate.md explains the calibration process and links to graphs
justifying those values. (The graphs are hosted on swtch.com to avoid adding
a megabyte of extra data to the Go repo and Go distributions.)

A rendered copy of calibrate.md is at https://swtch.com/math/big/calibrate.html.

goos: linux
goarch: amd64
pkg: math/big
cpu: Intel(R) Xeon(R) Platinum 8481C CPU @ 2.70GHz
                         │     old      │                 new                 │
                         │    sec/op    │   sec/op     vs base                │
Div/20/10-88                13.13n ± 2%   13.14n ± 2%        ~ (p=0.494 n=15)
Div/40/20-88                13.13n ± 2%   13.14n ± 2%        ~ (p=0.137 n=15)
Div/100/50-88               25.50n ± 0%   25.51n ± 0%        ~ (p=0.038 n=15)
Div/200/100-88              113.1n ± 1%   116.0n ± 3%   +2.56% (p=0.000 n=15)
Div/400/200-88              135.3n ± 0%   137.1n ± 1%        ~ (p=0.004 n=15)
Div/1000/500-88             259.9n ± 1%   259.0n ± 2%        ~ (p=0.182 n=15)
Div/2000/1000-88            568.8n ± 1%   564.7n ± 3%        ~ (p=0.927 n=15)
Div/20000/10000-88          25.79µ ± 1%   22.11µ ± 2%  -14.26% (p=0.000 n=15)
Div/200000/100000-88        755.1µ ± 1%   737.6µ ± 1%   -2.32% (p=0.000 n=15)
Div/2000000/1000000-88      31.30m ± 0%   31.20m ± 1%        ~ (p=0.081 n=15)
Div/20000000/10000000-88     1.268 ± 0%    1.265 ± 0%        ~ (p=0.011 n=15)
NatMul/10-88                142.6n ± 0%   142.9n ± 7%        ~ (p=0.145 n=15)
NatMul/100-88               4.347µ ± 0%   4.350µ ± 3%        ~ (p=0.430 n=15)
NatMul/1000-88              187.6µ ± 0%   188.4µ ± 2%        ~ (p=0.004 n=15)
NatMul/10000-88             8.052m ± 0%   8.057m ± 1%        ~ (p=0.148 n=15)
NatMul/100000-88            260.6m ± 0%   260.7m ± 0%        ~ (p=0.512 n=15)
NatSqr/1-88                 26.58n ± 5%   27.96n ± 8%        ~ (p=0.574 n=15)
NatSqr/2-88                 42.35n ± 7%   44.87n ± 6%        ~ (p=0.690 n=15)
NatSqr/3-88                 53.28n ± 4%   55.62n ± 5%        ~ (p=0.151 n=15)
NatSqr/5-88                 76.26n ± 6%   81.43n ± 6%   +6.78% (p=0.000 n=15)
NatSqr/8-88                 110.8n ± 5%   116.4n ± 6%        ~ (p=0.040 n=15)
NatSqr/10-88                141.4n ± 4%   147.8n ± 4%        ~ (p=0.011 n=15)
NatSqr/20-88                325.8n ± 3%   341.7n ± 4%   +4.88% (p=0.000 n=15)
NatSqr/30-88                536.8n ± 3%   556.1n ± 4%        ~ (p=0.027 n=15)
NatSqr/50-88                1.168µ ± 3%   1.197µ ± 3%        ~ (p=0.442 n=15)
NatSqr/80-88                2.527µ ± 2%   2.480µ ± 2%   -1.86% (p=0.000 n=15)
NatSqr/100-88               3.771µ ± 2%   3.535µ ± 2%   -6.26% (p=0.000 n=15)
NatSqr/200-88               14.03µ ± 2%   10.57µ ± 3%  -24.68% (p=0.000 n=15)
NatSqr/300-88               24.06µ ± 2%   20.57µ ± 2%  -14.52% (p=0.000 n=15)
NatSqr/500-88               65.43µ ± 1%   45.45µ ± 1%  -30.55% (p=0.000 n=15)
NatSqr/800-88              126.41µ ± 1%   94.13µ ± 2%  -25.54% (p=0.000 n=15)
NatSqr/1000-88              196.4µ ± 1%   135.1µ ± 1%  -31.18% (p=0.000 n=15)
NatSqr/10000-88             6.404m ± 0%   5.326m ± 1%  -16.84% (p=0.000 n=15)
NatSqr/100000-88            267.2m ± 0%   198.7m ± 0%  -25.64% (p=0.000 n=15)
geomean                     7.318µ        6.948µ        -5.06%

goos: linux
goarch: amd64
pkg: math/big
cpu: Intel(R) Xeon(R) CPU @ 3.10GHz
                         │     old     │                 new                 │
                         │   sec/op    │   sec/op     vs base                │
Div/20/10-16               22.23n ± 0%   22.23n ± 0%        ~ (p=0.973 n=15)
Div/40/20-16               22.23n ± 0%   22.23n ± 0%        ~ (p=0.226 n=15)
Div/100/50-16              55.27n ± 1%   55.59n ± 0%        ~ (p=0.004 n=15)
Div/200/100-16             174.7n ± 3%   175.9n ± 2%        ~ (p=0.645 n=15)
Div/400/200-16             208.8n ± 1%   209.5n ± 2%        ~ (p=0.169 n=15)
Div/1000/500-16            378.7n ± 2%   380.5n ± 2%        ~ (p=0.091 n=15)
Div/2000/1000-16           778.4n ± 1%   781.1n ± 2%        ~ (p=0.104 n=15)
Div/20000/10000-16         25.16µ ± 1%   24.93µ ± 1%   -0.91% (p=0.000 n=15)
Div/200000/100000-16       926.4µ ± 0%   927.7µ ± 1%        ~ (p=0.436 n=15)
Div/2000000/1000000-16     35.58m ± 0%   35.53m ± 0%        ~ (p=0.267 n=15)
Div/20000000/10000000-16    1.333 ± 0%    1.330 ± 0%        ~ (p=0.126 n=15)
NatMul/10-16               172.6n ± 0%   165.4n ± 0%   -4.17% (p=0.000 n=15)
NatMul/100-16              5.706µ ± 0%   5.503µ ± 0%   -3.56% (p=0.000 n=15)
NatMul/1000-16             220.8µ ± 0%   219.1µ ± 0%   -0.76% (p=0.000 n=15)
NatMul/10000-16            8.688m ± 0%   8.621m ± 0%   -0.77% (p=0.000 n=15)
NatMul/100000-16           333.3m ± 0%   333.5m ± 0%        ~ (p=0.512 n=15)
NatSqr/1-16                28.66n ± 1%   28.42n ± 3%   -0.84% (p=0.000 n=15)
NatSqr/2-16                48.29n ± 2%   48.19n ± 2%        ~ (p=0.042 n=15)
NatSqr/3-16                59.93n ± 0%   59.64n ± 2%   -0.48% (p=0.000 n=15)
NatSqr/5-16                88.05n ± 0%   87.89n ± 3%        ~ (p=0.066 n=15)
NatSqr/8-16                127.7n ± 0%   126.9n ± 3%   -0.63% (p=0.000 n=15)
NatSqr/10-16               170.4n ± 0%   169.7n ± 3%        ~ (p=0.004 n=15)
NatSqr/20-16               388.8n ± 0%   392.9n ± 3%        ~ (p=0.123 n=15)
NatSqr/30-16               635.2n ± 0%   641.7n ± 3%        ~ (p=0.123 n=15)
NatSqr/50-16               1.304µ ± 1%   1.314µ ± 3%        ~ (p=0.927 n=15)
NatSqr/80-16               2.709µ ± 1%   2.899µ ± 4%   +7.01% (p=0.000 n=15)
NatSqr/100-16              3.885µ ± 0%   3.981µ ± 4%        ~ (p=0.123 n=15)
NatSqr/200-16              13.29µ ± 2%   12.14µ ± 4%   -8.67% (p=0.000 n=15)
NatSqr/300-16              23.39µ ± 0%   22.51µ ± 3%   -3.78% (p=0.000 n=15)
NatSqr/500-16              58.13µ ± 1%   50.56µ ± 2%  -13.02% (p=0.000 n=15)
NatSqr/800-16              118.4µ ± 1%   107.6µ ± 2%   -9.11% (p=0.000 n=15)
NatSqr/1000-16             172.7µ ± 1%   151.8µ ± 2%  -12.11% (p=0.000 n=15)
NatSqr/10000-16            6.065m ± 1%   5.757m ± 1%   -5.08% (p=0.000 n=15)
NatSqr/100000-16           240.9m ± 0%   228.1m ± 0%   -5.32% (p=0.000 n=15)
geomean                    8.601µ        8.453µ        -1.71%

goos: linux
goarch: amd64
pkg: math/big
cpu: AMD Ryzen 9 7950X 16-Core Processor
                         │     old      │                  new                  │
                         │    sec/op    │    sec/op      vs base                │
Div/20/10-32               11.11n ±  0%    11.11n ±  1%        ~ (p=0.532 n=15)
Div/40/20-32               11.08n ±  1%    11.11n ±  0%        ~ (p=0.815 n=15)
Div/100/50-32              16.81n ±  0%    16.84n ± 29%        ~ (p=0.020 n=15)
Div/200/100-32             73.91n ±  0%    76.85n ± 11%   +3.98% (p=0.000 n=15)
Div/400/200-32             87.35n ±  0%    88.91n ± 34%   +1.79% (p=0.000 n=15)
Div/1000/500-32            169.3n ±  1%    168.9n ±  1%        ~ (p=0.049 n=15)
Div/2000/1000-32           369.3n ±  0%    369.0n ±  0%        ~ (p=0.108 n=15)
Div/20000/10000-32         15.92µ ±  0%    13.55µ ±  2%  -14.91% (p=0.000 n=15)
Div/200000/100000-32       491.4µ ±  0%    482.4µ ±  1%   -1.84% (p=0.000 n=15)
Div/2000000/1000000-32     20.09m ±  0%    19.96m ±  0%   -0.69% (p=0.000 n=15)
Div/20000000/10000000-32   756.5m ±  0%    755.5m ±  0%        ~ (p=0.089 n=15)
NatMul/10-32               125.4n ±  5%    124.8n ±  1%        ~ (p=0.588 n=15)
NatMul/100-32              2.952µ ±  3%    2.969µ ±  0%        ~ (p=0.237 n=15)
NatMul/1000-32             120.7µ ±  0%    121.1µ ±  0%   +0.30% (p=0.000 n=15)
NatMul/10000-32            4.845m ±  0%    4.839m ±  1%        ~ (p=0.653 n=15)
NatMul/100000-32           173.3m ±  0%    173.3m ±  0%        ~ (p=0.838 n=15)
NatSqr/1-32                31.18n ± 23%    32.08n ±  2%        ~ (p=0.015 n=15)
NatSqr/2-32                57.22n ± 28%    58.88n ±  2%        ~ (p=0.054 n=15)
NatSqr/3-32                61.34n ± 18%    64.33n ±  2%        ~ (p=0.237 n=15)
NatSqr/5-32                72.47n ± 17%    79.81n ±  3%        ~ (p=0.067 n=15)
NatSqr/8-32                83.26n ± 26%   100.10n ±  3%        ~ (p=0.016 n=15)
NatSqr/10-32               87.31n ± 43%   125.50n ±  2%        ~ (p=0.003 n=15)
NatSqr/20-32               193.5n ± 25%    244.4n ± 13%        ~ (p=0.002 n=15)
NatSqr/30-32               323.9n ± 17%    380.9n ±  6%        ~ (p=0.003 n=15)
NatSqr/50-32               713.4n ±  9%    761.7n ±  8%        ~ (p=0.419 n=15)
NatSqr/80-32               1.486µ ±  7%    1.609µ ±  5%   +8.28% (p=0.000 n=15)
NatSqr/100-32              2.115µ ±  9%    2.253µ ±  1%        ~ (p=0.104 n=15)
NatSqr/200-32              7.201µ ±  4%    6.610µ ±  1%   -8.21% (p=0.000 n=15)
NatSqr/300-32              13.08µ ±  2%    12.37µ ±  1%   -5.41% (p=0.000 n=15)
NatSqr/500-32              32.56µ ±  2%    27.83µ ±  2%  -14.52% (p=0.000 n=15)
NatSqr/800-32              66.83µ ±  3%    59.59µ ±  1%  -10.83% (p=0.000 n=15)
NatSqr/1000-32             98.09µ ±  1%    83.59µ ±  1%  -14.78% (p=0.000 n=15)
NatSqr/10000-32            3.445m ±  1%    3.245m ±  0%   -5.81% (p=0.000 n=15)
NatSqr/100000-32           137.3m ±  0%    127.0m ±  0%   -7.54% (p=0.000 n=15)
geomean                    4.897µ          4.972µ         +1.52%

goos: linux
goarch: arm64
pkg: math/big
                         │     old     │                 new                 │
                         │   sec/op    │   sec/op     vs base                │
Div/20/10-16               15.26n ± 2%   15.14n ± 1%        ~ (p=0.212 n=15)
Div/40/20-16               15.22n ± 1%   15.16n ± 0%        ~ (p=0.190 n=15)
Div/100/50-16              26.53n ± 2%   26.42n ± 0%   -0.41% (p=0.000 n=15)
Div/200/100-16             124.3n ± 0%   124.0n ± 0%        ~ (p=0.704 n=15)
Div/400/200-16             142.4n ± 0%   141.8n ± 0%        ~ (p=0.074 n=15)
Div/1000/500-16            262.0n ± 1%   261.3n ± 1%        ~ (p=0.046 n=15)
Div/2000/1000-16           532.6n ± 0%   532.5n ± 1%        ~ (p=0.798 n=15)
Div/20000/10000-16         22.27µ ± 0%   22.88µ ± 0%   +2.73% (p=0.000 n=15)
Div/200000/100000-16       890.4µ ± 0%   902.8µ ± 0%   +1.39% (p=0.000 n=15)
Div/2000000/1000000-16     35.03m ± 0%   35.10m ± 0%        ~ (p=0.305 n=15)
Div/20000000/10000000-16    1.380 ± 0%    1.385 ± 0%        ~ (p=0.019 n=15)
NatMul/10-16               177.6n ± 1%   175.6n ± 3%        ~ (p=0.480 n=15)
NatMul/100-16              5.675µ ± 0%   5.669µ ± 1%        ~ (p=0.705 n=15)
NatMul/1000-16             224.3µ ± 0%   224.6µ ± 0%        ~ (p=0.653 n=15)
NatMul/10000-16            8.735m ± 0%   8.739m ± 0%        ~ (p=0.567 n=15)
NatMul/100000-16           331.6m ± 0%   331.6m ± 1%        ~ (p=0.412 n=15)
NatSqr/1-16                43.69n ± 2%   42.77n ± 6%        ~ (p=0.383 n=15)
NatSqr/2-16                65.26n ± 2%   63.91n ± 5%        ~ (p=0.285 n=15)
NatSqr/3-16                73.95n ± 1%   72.25n ± 6%        ~ (p=0.198 n=15)
NatSqr/5-16                95.06n ± 1%   94.21n ± 3%        ~ (p=0.721 n=15)
NatSqr/8-16                155.5n ± 1%   153.4n ± 4%        ~ (p=0.170 n=15)
NatSqr/10-16               175.4n ± 1%   174.0n ± 2%        ~ (p=0.271 n=15)
NatSqr/20-16               360.8n ± 0%   358.5n ± 2%        ~ (p=0.170 n=15)
NatSqr/30-16               584.7n ± 0%   582.9n ± 1%        ~ (p=0.170 n=15)
NatSqr/50-16               1.323µ ± 0%   1.322µ ± 0%        ~ (p=0.627 n=15)
NatSqr/80-16               2.916µ ± 0%   2.674µ ± 0%   -8.30% (p=0.000 n=15)
NatSqr/100-16              4.365µ ± 0%   3.802µ ± 0%  -12.90% (p=0.000 n=15)
NatSqr/200-16              16.42µ ± 0%   11.29µ ± 0%  -31.26% (p=0.000 n=15)
NatSqr/300-16              28.07µ ± 0%   22.83µ ± 0%  -18.68% (p=0.000 n=15)
NatSqr/500-16              76.30µ ± 0%   50.06µ ± 0%  -34.39% (p=0.000 n=15)
NatSqr/800-16              147.5µ ± 0%   101.2µ ± 1%  -31.41% (p=0.000 n=15)
NatSqr/1000-16             228.6µ ± 0%   149.5µ ± 0%  -34.61% (p=0.000 n=15)
NatSqr/10000-16            7.417m ± 0%   6.025m ± 0%  -18.76% (p=0.000 n=15)
NatSqr/100000-16           309.2m ± 0%   214.9m ± 0%  -30.50% (p=0.000 n=15)
geomean                    8.559µ        7.906µ        -7.63%

goos: darwin
goarch: arm64
pkg: math/big
cpu: Apple M3 Pro
                         │     old      │                 new                 │
                         │    sec/op    │   sec/op     vs base                │
Div/20/10-12                9.577n ± 6%   9.473n ± 5%        ~ (p=0.384 n=15)
Div/40/20-12                9.480n ± 1%   9.430n ± 1%        ~ (p=0.019 n=15)
Div/100/50-12               14.82n ± 0%   14.82n ± 0%        ~ (p=0.845 n=15)
Div/200/100-12              83.94n ± 1%   84.35n ± 4%        ~ (p=0.512 n=15)
Div/400/200-12              102.7n ± 1%   102.9n ± 0%        ~ (p=0.845 n=15)
Div/1000/500-12             185.3n ± 1%   181.9n ± 1%   -1.83% (p=0.000 n=15)
Div/2000/1000-12            397.0n ± 1%   396.7n ± 0%        ~ (p=0.959 n=15)
Div/20000/10000-12          14.05µ ± 0%   13.70µ ± 1%        ~ (p=0.002 n=15)
Div/200000/100000-12        529.4µ ± 3%   526.7µ ± 2%        ~ (p=0.967 n=15)
Div/2000000/1000000-12      20.05m ± 0%   20.05m ± 0%        ~ (p=0.653 n=15)
Div/20000000/10000000-12    788.2m ± 1%   789.0m ± 1%        ~ (p=0.412 n=15)
NatMul/10-12                79.95n ± 1%   80.87n ± 1%   +1.15% (p=0.000 n=15)
NatMul/100-12               2.973µ ± 0%   2.986µ ± 2%        ~ (p=0.051 n=15)
NatMul/1000-12              122.6µ ± 5%   123.0µ ± 1%        ~ (p=0.783 n=15)
NatMul/10000-12             4.990m ± 1%   5.000m ± 1%        ~ (p=0.653 n=15)
NatMul/100000-12            185.3m ± 3%   190.3m ± 1%        ~ (p=0.089 n=15)
NatSqr/1-12                 11.84n ± 1%   11.88n ± 1%        ~ (p=0.735 n=15)
NatSqr/2-12                 21.01n ± 1%   21.44n ± 6%        ~ (p=0.039 n=15)
NatSqr/3-12                 25.59n ± 0%   26.74n ± 9%   +4.49% (p=0.000 n=15)
NatSqr/5-12                 36.78n ± 0%   37.04n ± 1%   +0.71% (p=0.000 n=15)
NatSqr/8-12                 63.09n ± 3%   63.22n ± 1%        ~ (p=0.846 n=15)
NatSqr/10-12                79.98n ± 0%   79.78n ± 0%        ~ (p=0.100 n=15)
NatSqr/20-12                174.0n ± 0%   175.5n ± 1%        ~ (p=0.361 n=15)
NatSqr/30-12                290.0n ± 0%   291.4n ± 0%        ~ (p=0.002 n=15)
NatSqr/50-12                655.2n ± 4%   658.1n ± 0%        ~ (p=0.060 n=15)
NatSqr/80-12                1.506µ ± 0%   1.397µ ± 5%   -7.24% (p=0.000 n=15)
NatSqr/100-12               2.273µ ± 0%   2.005µ ± 5%  -11.79% (p=0.000 n=15)
NatSqr/200-12               8.833µ ± 6%   6.109µ ± 0%  -30.84% (p=0.000 n=15)
NatSqr/300-12               15.15µ ± 4%   12.37µ ± 0%  -18.34% (p=0.000 n=15)
NatSqr/500-12               41.89µ ± 0%   27.70µ ± 1%  -33.88% (p=0.000 n=15)
NatSqr/800-12               80.72µ ± 0%   56.40µ ± 0%  -30.12% (p=0.000 n=15)
NatSqr/1000-12             127.06µ ± 1%   84.06µ ± 1%  -33.84% (p=0.000 n=15)
NatSqr/10000-12             4.130m ± 0%   3.390m ± 0%  -17.91% (p=0.000 n=15)
NatSqr/100000-12            173.2m ± 0%   131.2m ± 6%  -24.25% (p=0.000 n=15)
geomean                     4.489µ        4.189µ        -6.68%

Change-Id: Iaf65fd85457b003ebf07a787c875cda321b40cc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/652058
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2025-03-12 05:41:50 -07:00
Russ Cox
40c953cd46 runtime: remove nextSampleNoFP from plan9
Plan 9 can use floating point now.

Change-Id: If721b243daa31853609cb3d2c535d86c106a1ee1
Reviewed-on: https://go-review.googlesource.com/c/go/+/655879
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
2025-03-12 05:41:22 -07:00
Russ Cox
d037ed62bc math/big: simplify, speed up Karatsuba multiplication
The old Karatsuba implementation only operated on lengths that are
a power of two times a number smaller than karatsubaThreshold.
For example, when karatsubaThreshold = 40, multiplying a pair
of 99-word numbers runs karatsuba on the low 96 (= 39<<2) words
and then has to fix up the answer to include the high 3 words of each.

I suspect this requirement was needed to make the analysis of
how many temporary words to reserve easier, back when the
answer was 3*n and depended on exactly halving the size at
each Karatsuba step.

Now that we have the more flexible temporary allocation stack,
we can change Karatsuba to accept operands of odd length.
Doing so avoids most of the fixup that the old approach required.
For example, multiplying a pair of 99-word numbers runs
karatsuba on all 99 words now.

This is simpler and about the same speed or, for large cases, faster.

goos: linux
goarch: amd64
pkg: math/big
cpu: Intel(R) Xeon(R) CPU @ 3.10GHz
                            │     old     │                 new                 │
                            │   sec/op    │   sec/op     vs base                │
GCD10x10/WithoutXY-16         99.62n ± 3%   99.10n ± 3%        ~ (p=0.009 n=15)
GCD10x10/WithXY-16            243.4n ± 1%   245.2n ± 1%        ~ (p=0.009 n=15)
GCD100x100/WithoutXY-16       921.9n ± 1%   919.2n ± 1%        ~ (p=0.076 n=15)
GCD100x100/WithXY-16          1.527µ ± 1%   1.526µ ± 0%        ~ (p=0.813 n=15)
GCD1000x1000/WithoutXY-16     9.704µ ± 1%   9.696µ ± 0%        ~ (p=0.532 n=15)
GCD1000x1000/WithXY-16        14.03µ ± 1%   13.96µ ± 0%        ~ (p=0.014 n=15)
GCD10000x10000/WithoutXY-16   206.5µ ± 2%   206.5µ ± 0%        ~ (p=0.967 n=15)
GCD10000x10000/WithXY-16      398.0µ ± 1%   397.4µ ± 0%        ~ (p=0.683 n=15)
Div/20/10-16                  22.22n ± 0%   22.23n ± 0%        ~ (p=0.105 n=15)
Div/40/20-16                  22.23n ± 0%   22.23n ± 0%        ~ (p=0.307 n=15)
Div/100/50-16                 55.47n ± 0%   55.47n ± 0%        ~ (p=0.573 n=15)
Div/200/100-16                174.9n ± 1%   174.6n ± 1%        ~ (p=0.814 n=15)
Div/400/200-16                209.5n ± 1%   210.5n ± 1%        ~ (p=0.454 n=15)
Div/1000/500-16               379.9n ± 0%   383.5n ± 2%        ~ (p=0.123 n=15)
Div/2000/1000-16              780.1n ± 0%   784.6n ± 1%   +0.58% (p=0.000 n=15)
Div/20000/10000-16            25.22µ ± 1%   25.15µ ± 0%        ~ (p=0.213 n=15)
Div/200000/100000-16          921.8µ ± 1%   926.1µ ± 0%        ~ (p=0.009 n=15)
Div/2000000/1000000-16        37.91m ± 0%   35.63m ± 0%   -6.02% (p=0.000 n=15)
Div/20000000/10000000-16       1.378 ± 0%    1.336 ± 0%   -3.03% (p=0.000 n=15)
NatMul/10-16                  166.8n ± 4%   168.9n ± 3%        ~ (p=0.008 n=15)
NatMul/100-16                 5.519µ ± 2%   5.548µ ± 4%        ~ (p=0.032 n=15)
NatMul/1000-16                230.4µ ± 1%   220.2µ ± 1%   -4.43% (p=0.000 n=15)
NatMul/10000-16               8.569m ± 1%   8.640m ± 1%        ~ (p=0.005 n=15)
NatMul/100000-16              376.5m ± 1%   334.1m ± 0%  -11.26% (p=0.000 n=15)
NatSqr/1-16                   27.85n ± 5%   28.60n ± 2%        ~ (p=0.123 n=15)
NatSqr/2-16                   47.99n ± 2%   48.84n ± 1%        ~ (p=0.008 n=15)
NatSqr/3-16                   59.41n ± 2%   60.87n ± 2%   +2.46% (p=0.001 n=15)
NatSqr/5-16                   87.27n ± 2%   89.31n ± 3%        ~ (p=0.087 n=15)
NatSqr/8-16                   124.6n ± 3%   128.9n ± 3%        ~ (p=0.006 n=15)
NatSqr/10-16                  166.3n ± 3%   172.7n ± 3%        ~ (p=0.002 n=15)
NatSqr/20-16                  385.2n ± 2%   394.7n ± 3%        ~ (p=0.036 n=15)
NatSqr/30-16                  622.7n ± 3%   642.9n ± 3%        ~ (p=0.032 n=15)
NatSqr/50-16                  1.274µ ± 3%   1.323µ ± 4%        ~ (p=0.003 n=15)
NatSqr/80-16                  2.606µ ± 4%   2.714µ ± 4%        ~ (p=0.044 n=15)
NatSqr/100-16                 3.731µ ± 4%   3.871µ ± 4%        ~ (p=0.038 n=15)
NatSqr/200-16                 12.99µ ± 2%   13.09µ ± 3%        ~ (p=0.838 n=15)
NatSqr/300-16                 22.87µ ± 2%   23.25µ ± 2%        ~ (p=0.285 n=15)
NatSqr/500-16                 58.43µ ± 1%   58.25µ ± 2%        ~ (p=0.345 n=15)
NatSqr/800-16                 115.3µ ± 3%   116.2µ ± 3%        ~ (p=0.126 n=15)
NatSqr/1000-16                173.9µ ± 1%   174.3µ ± 1%        ~ (p=0.935 n=15)
NatSqr/10000-16               6.133m ± 2%   6.034m ± 1%   -1.62% (p=0.000 n=15)
NatSqr/100000-16              253.8m ± 1%   241.5m ± 0%   -4.87% (p=0.000 n=15)
geomean                       7.745µ        7.760µ        +0.19%

goos: linux
goarch: amd64
pkg: math/big
cpu: Intel(R) Xeon(R) Platinum 8481C CPU @ 2.70GHz
                            │     old     │                 new                  │
                            │   sec/op    │    sec/op     vs base                │
GCD10x10/WithoutXY-88         62.17n ± 4%   61.44n ±  0%   -1.17% (p=0.000 n=15)
GCD10x10/WithXY-88            173.4n ± 2%   172.4n ±  4%        ~ (p=0.615 n=15)
GCD100x100/WithoutXY-88       584.0n ± 1%   582.9n ±  0%        ~ (p=0.009 n=15)
GCD100x100/WithXY-88          1.098µ ± 1%   1.091µ ±  2%        ~ (p=0.002 n=15)
GCD1000x1000/WithoutXY-88     6.055µ ± 0%   6.049µ ±  0%        ~ (p=0.007 n=15)
GCD1000x1000/WithXY-88        9.430µ ± 0%   9.417µ ±  1%        ~ (p=0.123 n=15)
GCD10000x10000/WithoutXY-88   153.4µ ± 2%   149.0µ ±  2%   -2.85% (p=0.000 n=15)
GCD10000x10000/WithXY-88      350.6µ ± 3%   349.0µ ±  2%        ~ (p=0.126 n=15)
Div/20/10-88                  13.12n ± 0%   13.12n ±  1%    0.00% (p=0.042 n=15)
Div/40/20-88                  13.12n ± 0%   13.13n ±  0%        ~ (p=0.004 n=15)
Div/100/50-88                 25.49n ± 0%   25.49n ±  0%        ~ (p=0.452 n=15)
Div/200/100-88                115.7n ± 2%   113.8n ±  2%        ~ (p=0.212 n=15)
Div/400/200-88                135.0n ± 1%   136.1n ±  1%        ~ (p=0.005 n=15)
Div/1000/500-88               257.5n ± 1%   259.9n ±  1%        ~ (p=0.004 n=15)
Div/2000/1000-88              567.5n ± 1%   572.4n ±  2%        ~ (p=0.616 n=15)
Div/20000/10000-88            25.65µ ± 0%   25.77µ ±  1%        ~ (p=0.032 n=15)
Div/200000/100000-88          777.4µ ± 1%   754.3µ ±  1%   -2.97% (p=0.000 n=15)
Div/2000000/1000000-88        33.66m ± 0%   31.37m ±  0%   -6.81% (p=0.000 n=15)
Div/20000000/10000000-88       1.320 ± 0%    1.266 ±  0%   -4.04% (p=0.000 n=15)
NatMul/10-88                  151.9n ± 7%   143.3n ±  7%        ~ (p=0.878 n=15)
NatMul/100-88                 4.418µ ± 2%   4.337µ ±  3%        ~ (p=0.512 n=15)
NatMul/1000-88                206.8µ ± 1%   189.8µ ±  1%   -8.25% (p=0.000 n=15)
NatMul/10000-88               8.531m ± 1%   8.095m ±  0%   -5.12% (p=0.000 n=15)
NatMul/100000-88              298.9m ± 0%   260.5m ±  1%  -12.85% (p=0.000 n=15)
NatSqr/1-88                   27.55n ± 6%   28.25n ±  7%        ~ (p=0.024 n=15)
NatSqr/2-88                   44.71n ± 6%   46.21n ±  9%        ~ (p=0.024 n=15)
NatSqr/3-88                   55.44n ± 4%   58.41n ± 10%        ~ (p=0.126 n=15)
NatSqr/5-88                   80.71n ± 5%   81.41n ±  5%        ~ (p=0.032 n=15)
NatSqr/8-88                   115.7n ± 4%   115.4n ±  5%        ~ (p=0.814 n=15)
NatSqr/10-88                  147.4n ± 4%   147.3n ±  4%        ~ (p=0.505 n=15)
NatSqr/20-88                  337.8n ± 3%   337.3n ±  4%        ~ (p=0.814 n=15)
NatSqr/30-88                  556.9n ± 3%   557.6n ±  4%        ~ (p=0.814 n=15)
NatSqr/50-88                  1.208µ ± 4%   1.208µ ±  3%        ~ (p=0.910 n=15)
NatSqr/80-88                  2.591µ ± 3%   2.581µ ±  3%        ~ (p=0.705 n=15)
NatSqr/100-88                 3.870µ ± 3%   3.858µ ±  3%        ~ (p=0.846 n=15)
NatSqr/200-88                 14.43µ ± 3%   14.28µ ±  2%        ~ (p=0.383 n=15)
NatSqr/300-88                 24.68µ ± 2%   24.49µ ±  2%        ~ (p=0.624 n=15)
NatSqr/500-88                 66.27µ ± 1%   66.18µ ±  1%        ~ (p=0.735 n=15)
NatSqr/800-88                 128.7µ ± 1%   127.4µ ±  1%        ~ (p=0.050 n=15)
NatSqr/1000-88                198.7µ ± 1%   197.7µ ±  1%        ~ (p=0.229 n=15)
NatSqr/10000-88               6.582m ± 1%   6.426m ±  1%   -2.37% (p=0.000 n=15)
NatSqr/100000-88              274.3m ± 0%   267.3m ±  0%   -2.57% (p=0.000 n=15)
geomean                       6.518µ        6.438µ         -1.22%

goos: linux
goarch: arm64
pkg: math/big
                            │     old     │                 new                 │
                            │   sec/op    │   sec/op     vs base                │
GCD10x10/WithoutXY-16         61.70n ± 1%   61.32n ± 1%        ~ (p=0.361 n=15)
GCD10x10/WithXY-16            217.3n ± 1%   217.0n ± 1%        ~ (p=0.395 n=15)
GCD100x100/WithoutXY-16       569.7n ± 0%   572.6n ± 2%        ~ (p=0.213 n=15)
GCD100x100/WithXY-16          1.241µ ± 1%   1.236µ ± 1%        ~ (p=0.157 n=15)
GCD1000x1000/WithoutXY-16     5.558µ ± 0%   5.566µ ± 0%        ~ (p=0.228 n=15)
GCD1000x1000/WithXY-16        9.319µ ± 0%   9.326µ ± 0%        ~ (p=0.233 n=15)
GCD10000x10000/WithoutXY-16   126.4µ ± 2%   128.7µ ± 3%        ~ (p=0.081 n=15)
GCD10000x10000/WithXY-16      279.3µ ± 0%   278.3µ ± 5%        ~ (p=0.187 n=15)
Div/20/10-16                  15.12n ± 1%   15.21n ± 1%        ~ (p=0.490 n=15)
Div/40/20-16                  15.11n ± 0%   15.23n ± 1%        ~ (p=0.107 n=15)
Div/100/50-16                 26.53n ± 0%   26.50n ± 0%        ~ (p=0.299 n=15)
Div/200/100-16                123.7n ± 0%   124.0n ± 0%        ~ (p=0.086 n=15)
Div/400/200-16                142.5n ± 0%   142.4n ± 0%        ~ (p=0.039 n=15)
Div/1000/500-16               259.9n ± 1%   261.2n ± 1%        ~ (p=0.044 n=15)
Div/2000/1000-16              539.4n ± 1%   532.3n ± 1%   -1.32% (p=0.001 n=15)
Div/20000/10000-16            22.43µ ± 0%   22.32µ ± 0%   -0.49% (p=0.000 n=15)
Div/200000/100000-16          898.3µ ± 0%   889.6µ ± 0%   -0.96% (p=0.000 n=15)
Div/2000000/1000000-16        38.37m ± 0%   35.11m ± 0%   -8.49% (p=0.000 n=15)
Div/20000000/10000000-16       1.449 ± 0%    1.384 ± 0%   -4.48% (p=0.000 n=15)
NatMul/10-16                  182.0n ± 1%   177.8n ± 1%   -2.31% (p=0.000 n=15)
NatMul/100-16                 5.537µ ± 0%   5.693µ ± 0%   +2.82% (p=0.000 n=15)
NatMul/1000-16                229.9µ ± 0%   224.8µ ± 0%   -2.24% (p=0.000 n=15)
NatMul/10000-16               8.985m ± 0%   8.751m ± 0%   -2.61% (p=0.000 n=15)
NatMul/100000-16              371.1m ± 0%   331.5m ± 0%  -10.66% (p=0.000 n=15)
NatSqr/1-16                   46.77n ± 6%   42.76n ± 1%   -8.57% (p=0.000 n=15)
NatSqr/2-16                   66.99n ± 4%   63.62n ± 1%   -5.03% (p=0.000 n=15)
NatSqr/3-16                   76.79n ± 4%   73.42n ± 1%        ~ (p=0.007 n=15)
NatSqr/5-16                   99.00n ± 3%   95.35n ± 1%   -3.69% (p=0.000 n=15)
NatSqr/8-16                   160.0n ± 3%   155.1n ± 1%   -3.06% (p=0.001 n=15)
NatSqr/10-16                  178.4n ± 2%   175.9n ± 0%   -1.40% (p=0.001 n=15)
NatSqr/20-16                  361.9n ± 2%   361.3n ± 0%        ~ (p=0.083 n=15)
NatSqr/30-16                  584.7n ± 0%   586.8n ± 0%   +0.36% (p=0.000 n=15)
NatSqr/50-16                  1.327µ ± 0%   1.329µ ± 0%        ~ (p=0.349 n=15)
NatSqr/80-16                  2.893µ ± 1%   2.925µ ± 0%   +1.11% (p=0.000 n=15)
NatSqr/100-16                 4.330µ ± 1%   4.381µ ± 0%   +1.18% (p=0.000 n=15)
NatSqr/200-16                 16.25µ ± 1%   16.43µ ± 0%   +1.07% (p=0.000 n=15)
NatSqr/300-16                 27.85µ ± 1%   28.06µ ± 0%   +0.77% (p=0.000 n=15)
NatSqr/500-16                 76.01µ ± 0%   76.34µ ± 0%        ~ (p=0.002 n=15)
NatSqr/800-16                 146.8µ ± 0%   148.1µ ± 0%   +0.83% (p=0.000 n=15)
NatSqr/1000-16                228.2µ ± 0%   228.6µ ± 0%        ~ (p=0.123 n=15)
NatSqr/10000-16               7.524m ± 0%   7.426m ± 0%   -1.31% (p=0.000 n=15)
NatSqr/100000-16              316.7m ± 0%   309.2m ± 0%   -2.36% (p=0.000 n=15)
geomean                       7.264µ        7.172µ        -1.27%

goos: darwin
goarch: arm64
pkg: math/big
cpu: Apple M3 Pro
                            │     old     │                new                 │
                            │   sec/op    │   sec/op     vs base               │
GCD10x10/WithoutXY-12         32.61n ± 1%   32.42n ± 1%       ~ (p=0.021 n=15)
GCD10x10/WithXY-12            87.70n ± 1%   88.42n ± 1%       ~ (p=0.010 n=15)
GCD100x100/WithoutXY-12       305.9n ± 0%   306.4n ± 0%       ~ (p=0.003 n=15)
GCD100x100/WithXY-12          560.3n ± 2%   556.6n ± 1%       ~ (p=0.018 n=15)
GCD1000x1000/WithoutXY-12     3.509µ ± 2%   3.464µ ± 1%       ~ (p=0.145 n=15)
GCD1000x1000/WithXY-12        5.347µ ± 2%   5.372µ ± 1%       ~ (p=0.046 n=15)
GCD10000x10000/WithoutXY-12   73.75µ ± 1%   73.99µ ± 1%       ~ (p=0.004 n=15)
GCD10000x10000/WithXY-12      148.4µ ± 0%   147.8µ ± 1%       ~ (p=0.076 n=15)
Div/20/10-12                  9.481n ± 0%   9.462n ± 1%       ~ (p=0.631 n=15)
Div/40/20-12                  9.457n ± 0%   9.462n ± 1%       ~ (p=0.798 n=15)
Div/100/50-12                 14.91n ± 0%   14.79n ± 1%  -0.80% (p=0.000 n=15)
Div/200/100-12                84.56n ± 1%   84.60n ± 1%       ~ (p=0.271 n=15)
Div/400/200-12                103.8n ± 0%   102.8n ± 0%  -0.96% (p=0.000 n=15)
Div/1000/500-12               181.3n ± 1%   184.2n ± 2%       ~ (p=0.091 n=15)
Div/2000/1000-12              397.5n ± 0%   397.4n ± 0%       ~ (p=0.299 n=15)
Div/20000/10000-12            14.04µ ± 1%   13.99µ ± 0%       ~ (p=0.221 n=15)
Div/200000/100000-12          523.1µ ± 0%   514.0µ ± 3%       ~ (p=0.775 n=15)
Div/2000000/1000000-12        21.58m ± 0%   20.01m ± 1%  -7.29% (p=0.000 n=15)
Div/20000000/10000000-12      813.5m ± 0%   796.2m ± 1%  -2.13% (p=0.000 n=15)
NatMul/10-12                  80.46n ± 1%   80.02n ± 1%       ~ (p=0.063 n=15)
NatMul/100-12                 2.904µ ± 0%   2.979µ ± 1%  +2.58% (p=0.000 n=15)
NatMul/1000-12                127.8µ ± 0%   122.3µ ± 0%  -4.28% (p=0.000 n=15)
NatMul/10000-12               5.141m ± 0%   4.975m ± 1%  -3.23% (p=0.000 n=15)
NatMul/100000-12              208.8m ± 0%   189.6m ± 3%  -9.21% (p=0.000 n=15)
NatSqr/1-12                   11.90n ± 1%   11.76n ± 1%       ~ (p=0.059 n=15)
NatSqr/2-12                   21.33n ± 1%   21.12n ± 0%       ~ (p=0.063 n=15)
NatSqr/3-12                   26.05n ± 1%   25.79n ± 0%       ~ (p=0.002 n=15)
NatSqr/5-12                   37.31n ± 0%   36.98n ± 1%       ~ (p=0.008 n=15)
NatSqr/8-12                   63.07n ± 0%   62.75n ± 1%       ~ (p=0.061 n=15)
NatSqr/10-12                  79.48n ± 0%   79.59n ± 0%       ~ (p=0.455 n=15)
NatSqr/20-12                  173.1n ± 0%   173.2n ± 1%       ~ (p=0.518 n=15)
NatSqr/30-12                  288.6n ± 1%   289.2n ± 0%       ~ (p=0.030 n=15)
NatSqr/50-12                  653.3n ± 0%   653.3n ± 0%       ~ (p=0.361 n=15)
NatSqr/80-12                  1.492µ ± 0%   1.496µ ± 0%       ~ (p=0.018 n=15)
NatSqr/100-12                 2.270µ ± 1%   2.270µ ± 0%       ~ (p=0.326 n=15)
NatSqr/200-12                 8.776µ ± 1%   8.784µ ± 1%       ~ (p=0.083 n=15)
NatSqr/300-12                 15.07µ ± 0%   15.09µ ± 0%       ~ (p=0.455 n=15)
NatSqr/500-12                 41.71µ ± 0%   41.77µ ± 1%       ~ (p=0.305 n=15)
NatSqr/800-12                 80.77µ ± 1%   80.59µ ± 0%       ~ (p=0.113 n=15)
NatSqr/1000-12                126.4µ ± 1%   126.5µ ± 0%       ~ (p=0.683 n=15)
NatSqr/10000-12               4.204m ± 0%   4.119m ± 0%  -2.02% (p=0.000 n=15)
NatSqr/100000-12              177.0m ± 0%   172.9m ± 0%  -2.31% (p=0.000 n=15)
geomean                       3.790µ        3.757µ       -0.87%

Change-Id: Ifc7a9b61f678df216690511ac8bb9143189a795e
Reviewed-on: https://go-review.googlesource.com/c/go/+/652057
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-03-12 05:41:17 -07:00
Russ Cox
26040b1dd7 cmd/compile: remove noDuffDevice
noDuffDevice was for Plan 9, but Plan 9 doesn't need it anymore.
It was also being set in s390x, mips, mipsle, and wasm, but
on those systems it had no effect since the SSA rules for those
architectures don't refer to it at all.

Change-Id: Ib85c0832674c714f3ad5091f0a022eb7cd3ebcdf
Reviewed-on: https://go-review.googlesource.com/c/go/+/655878
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
2025-03-12 05:40:38 -07:00
Russ Cox
c9b07e8871 cmd/compile: use FMA on plan9, and drop UseFMA
Every OS uses FMA now.

Change-Id: Ia7ffa77c52c45aefca611ddc54e9dfffb27a48da
Reviewed-on: https://go-review.googlesource.com/c/go/+/655877
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-12 05:40:34 -07:00
Russ Cox
35cb497d6e cmd/compile: remove useSSE
Every OS uses SSE now.

Change-Id: I4df7e2fbc8e5ccb1fc84a884d4c922b7a2a628e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/655876
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-03-12 05:40:30 -07:00
Jorropo
644b984027 cmd/compile: compute bitsize from type size in prove to clean some switches
Change-Id: I215adda9050d214576433700aed4c371a36aaaed
Reviewed-on: https://go-review.googlesource.com/c/go/+/656335
Reviewed-by: Keith Randall <khr@google.com>
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>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
2025-03-11 20:17:59 -07:00
Jorropo
b60b9cf21f cmd/compile: add constant folding for bits.Add64
Change-Id: I0ed4ebeaaa68e274e5902485ccc1165c039440bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/656275
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>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
2025-03-11 20:17:53 -07:00
Jorropo
4ff70cf868 cmd/compile: add MakeTuple generic SSA op to remove duplicate Select[01] rules
Change-Id: Id94a5e503f02aa29dc1e334b521770107d4261db
Reviewed-on: https://go-review.googlesource.com/c/go/+/656615
Reviewed-by: Keith Randall <khr@google.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>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
2025-03-11 20:17:48 -07:00
Jorropo
99411d7847 cmd/compile: compute bits.OnesCount's limits from argument's limits
Change-Id: Ia90d48ea0fab363c8592221fad88958b522edefe
Reviewed-on: https://go-review.googlesource.com/c/go/+/656159
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.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-03-11 20:17:36 -07:00
Than McIntosh
8d767ff38d runtime: increase GDB version testing requirement to 10 from 7.7
Bump the required version of GDB up to 10 from 7.7 in the runtime GDB
tests, so as to ensure that we have something that can handle DWARF 5
when running tests. In theory there is some DWARF 5 support on the
version 9 release branch, but we get "Dwarf Error: DW_FORM_addrx"
errors for some archs on builders where GDB 9.2 is installed.

Updates #26379.

Change-Id: I1b7b45f8e4dd1fafccf22f2dda0124458ecf7cba
Reviewed-on: https://go-review.googlesource.com/c/go/+/656836
Auto-Submit: 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>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-11 20:07:53 -07:00
Than McIntosh
c032b04219 internal/buildcfg: fix typo in DWARF 5 enabling code
Fix a typo in the code that decides which GOOS values will support use
of DWARF 5 ("darwin" was not spelled correctly).

Updates #26379.

Change-Id: I3a7906d708550fcedc3a8e89d0444bf12b9143f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/656895
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>
Reviewed-by: David Chase <drchase@google.com>
2025-03-11 20:07:11 -07:00
Jorropo
c00647b49b cmd/compile: set bits.OnesCount's limits to [0, 64]
Change-Id: I2f60de836f58ef91baae856f44d8f73c190326f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/656158
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
2025-03-11 19:52:29 -07:00
Jorropo
554a3c51dc cmd/compile: use min & max builtins to assert constant bounds in prove's tests
I've originally used |= and &= to setup assumptions exploitable by the
operation under test but theses have multiple issues making it poor
for this usecase:
- &= does not pass the minimum value as-is, rather always set it to 0
- |= rounds up the max value to a number of the same length with all ones set
- I've never implemented them to work with negative signed numbers

Change-Id: Ie43c576fb10393e69d6f989b048823daa02b1df8
Reviewed-on: https://go-review.googlesource.com/c/go/+/656160
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
2025-03-11 19:51:59 -07:00
Jorropo
d2842229fc cmd/compile: compute min's & max's limits from argument's limits inside flowLimit
Updates #68857

Change-Id: Ied07e656bba42f3b1b5f9b9f5442806aa2e7959b
Reviewed-on: https://go-review.googlesource.com/c/go/+/656157
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
2025-03-11 19:51:31 -07:00
Guoqi Chen
bcd0ebbd2a internal/cpu: use correct variable when parsing CPU features lamcas and lam_bh on loong64
Change-Id: I5019f4e32243911f735f775bcb3c0dba5adb4162
Reviewed-on: https://go-review.googlesource.com/c/go/+/655395
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-11 18:36:01 -07:00
Ian Lance Taylor
4364893149 cmd/internal/script/scripttest: use GOHOSTARCH to find tool directory
Fixes #72800

Change-Id: Idde7eae13d1c0098e5314935cf8ca823cbc7a7cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/656855
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-11 18:16:13 -07:00
Guoqi Chen
17b9c9f2ad internal/bytealg: optimize Count{,String} in loong64
Benchmark on Loongson 3A6000 and 3A5000:

goos: linux
goarch: loong64
pkg: bytes
cpu: Loongson-3A6000 @ 2500.00MHz
                |  bench.old   |              bench.new              |
                |    sec/op    |   sec/op     vs base                |
CountSingle/10    13.210n ± 0%   9.984n ± 0%  -24.42% (p=0.000 n=15)
CountSingle/32    31.970n ± 1%   7.205n ± 0%  -77.46% (p=0.000 n=15)
CountSingle/4K    4039.0n ± 0%   108.7n ± 0%  -97.31% (p=0.000 n=15)
CountSingle/4M    4158.9µ ± 0%   117.3µ ± 0%  -97.18% (p=0.000 n=15)
CountSingle/64M   68.641m ± 0%   2.585m ± 1%  -96.23% (p=0.000 n=15)
geomean            13.72µ        1.189µ       -91.34%

                |  bench.old   |                bench.new                 |
                |     B/s      |      B/s        vs base                  |
CountSingle/10    722.0Mi ± 0%     955.2Mi ± 0%    +32.30% (p=0.000 n=15)
CountSingle/32    954.6Mi ± 1%    4235.4Mi ± 0%   +343.68% (p=0.000 n=15)
CountSingle/4K    967.2Mi ± 0%   35947.6Mi ± 0%  +3616.64% (p=0.000 n=15)
CountSingle/4M    961.8Mi ± 0%   34092.7Mi ± 0%  +3444.71% (p=0.000 n=15)
CountSingle/64M   932.4Mi ± 0%   24757.2Mi ± 1%  +2555.24% (p=0.000 n=15)
geomean           902.2Mi          10.17Gi       +1054.77%

goos: linux
goarch: loong64
pkg: bytes
cpu: Loongson-3A5000 @ 2500.00MHz
                |  bench.old   |              bench.new               |
                |    sec/op    |    sec/op     vs base                |
CountSingle/10     14.41n ± 0%   12.81n ±  0%  -11.10% (p=0.000 n=15)
CountSingle/32    36.230n ± 0%   9.609n ±  0%  -73.48% (p=0.000 n=15)
CountSingle/4K    4366.0n ± 0%   165.5n ±  0%  -96.21% (p=0.000 n=15)
CountSingle/4M    4464.7µ ± 0%   325.2µ ±  0%  -92.72% (p=0.000 n=15)
CountSingle/64M   75.627m ± 0%   8.307m ± 69%  -89.02% (p=0.000 n=15)
geomean            15.04µ        2.229µ        -85.18%

                |  bench.old   |                 bench.new                 |
                |     B/s      |       B/s        vs base                  |
CountSingle/10    661.8Mi ± 0%     744.4Mi ±  0%    +12.49% (p=0.000 n=15)
CountSingle/32    842.4Mi ± 0%    3176.1Mi ±  0%   +277.03% (p=0.000 n=15)
CountSingle/4K    894.7Mi ± 0%   23596.7Mi ±  0%  +2537.34% (p=0.000 n=15)
CountSingle/4M    895.9Mi ± 0%   12299.7Mi ±  0%  +1272.88% (p=0.000 n=15)
CountSingle/64M   846.3Mi ± 0%    7703.9Mi ± 41%   +810.34% (p=0.000 n=15)
geomean           823.3Mi          5.424Gi         +574.68%

Change-Id: Ie07592beac61bdb093470c524049ed494df4d703
Reviewed-on: https://go-review.googlesource.com/c/go/+/586055
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2025-03-11 17:59:52 -07:00
Than McIntosh
ca19f987ca internal/buildcfg: enable DWARF version 5 by default
This patch enables the DWARF version 5 experiment by default for most
platforms that support DWARF. Note that MacOS is kept at version 4,
due to problems with CGO builds; the "dsymutil" tool from older
versions of Xcode (prior to V16) can't handle DWARF5. Similar we keep
DWARF 4 for GOOS=aix, where XCOFF doesn't appear to support the new
section subtypes in DWARF 5.

Updates #26379.

Change-Id: I5edd600c611f03ce8e11be3ca18c1e6686ac74ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/637895
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>
2025-03-11 17:24:39 -07:00
cuishuang
4acc5b4da6 cmp: add examples for Compare and Less
Change-Id: I6900f52736d5316ca523a213c65896861d855433
Reviewed-on: https://go-review.googlesource.com/c/go/+/656635
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>
2025-03-11 15:22:39 -07:00
Sean Liao
908af6529c archive/zip: error on ReadDir if there are invalid file names
Fixes #50179

Change-Id: I616a6d1279d025e345d2daa6d44b687c8a2d09e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/656495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-11 15:19:38 -07:00
Ian Lance Taylor
817218a26c net/http: document Redirect behavior for non-ASCII characters
For #4385
For #72745

Change-Id: Ibd54fc03467eb948001299001bb2e2529512a7c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/656135
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>
Reviewed-by: Damien Neil <dneil@google.com>
2025-03-11 15:08:56 -07:00
Michael Pratt
3fb8b4f3db all: move //go:debug decoratemappings=0 test to cmd/go
test/decoratemappingszero.go is intended to test that
//go:debug decoratemappings=0 disables annonations.

Unfortunately, //go:debug processing is handled by cmd/go, but
cmd/internal/testdir (which runs tests from test/) generally invokes the
compiler directly, thus it does not set default GODEBUGs.

Move this test to the cmd/go script tests, alongside the similar test
for language version.

Fixes #72772.

Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64le_power10
Change-Id: I6a6a636c9d380ef984f760be5689fdc7f5cb2aeb
Reviewed-on: https://go-review.googlesource.com/c/go/+/656795
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-03-11 15:07:33 -07:00
qmuntal
8867af9207 os: add more File.WriteAt tests
The File.WriteAt doesn't verify that the file offset is not changed
when calling WriteAt, although it is what users expect.

Add some new tests to verify that this behavior doesn't regress.

Change-Id: Ib1e048c7333d6efec71bd8f75a4fa745775306f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/656355
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-11 14:29:30 -07:00
Xiaolin Zhao
b0e2f185c5 cmd/internal/obj/loong64: add {V,XV}MUL{B/H/W/V} and {V,XV}MUH{B/H/W/V}[U] instructions support
Go asm syntax:
	 VMUL{B/H/W/V}		VK, VJ, VD
	 VMUH{B/H/W/V}[U]	VK, VJ, VD
	XVMUL{B/H/W/V}		XK, XJ, XD
	XVMUH{B/H/W/V}[U]	XK, XJ, XD

Equivalent platform assembler syntax:
	 vmul.{b/h/w/d}		vd, vj, vk
	 vmuh.{b/h/w/d}[u]	vd, vj, vk
	xvmul.{b/h/w/d}		xd, xj, xk
	xvmuh.{b/h/w/d}[u]	xd, xj, xk

Change-Id: I2f15a5b4b6303a0f82cb85114477f58e1b5fd950
Reviewed-on: https://go-review.googlesource.com/c/go/+/636375
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
2025-03-11 14:25:30 -07:00
Alexander Musman
6c70f2b960 cmd/compile: Enable inlining of tail calls
Enable inlining tail calls and do not limit emitting tail calls only to the
non-inlineable methods when generating wrappers. This change produces
additional code size reduction.

 Code size difference measured with this change (tried for x86_64):
    etcd binary:
    .text section size: 10613393 -> 10593841 (0.18%)
    total binary size:  33450787 -> 33424307 (0.07%)

    compile binary:
    .text section size: 10171025 -> 10126545 (0.43%)
    total binary size:  28241012 -> 28192628 (0.17%)

    cockroach binary:
    .text section size:  83947260 -> 83694140  (0.3%)
    total binary size:  263799808 -> 263534160 (0.1%)

Change-Id: I694f83cb838e64bd4c51f05b7b9f2bf0193bb551
Reviewed-on: https://go-review.googlesource.com/c/go/+/650455
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
2025-03-11 14:18:43 -07:00
Russ Cox
c18ff21cc8 cmd/compile, runtime: remove plan9 special case avoiding SSE
Change-Id: Id5258a72b0727bf7c66d558e30486eac2c6c8c36
Reviewed-on: https://go-review.googlesource.com/c/go/+/655875
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
2025-03-11 14:11:35 -07:00
Jorropo
3e033b7553 cmd/compile: add constant folding for PopCount
Change-Id: I6ea3f75ddd5c7af114ef77bc48f28c7f8570997b
Reviewed-on: https://go-review.googlesource.com/c/go/+/656156
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-03-11 13:50:52 -07:00
Örjan Fors
8591f8e19e log/slog: use consistent call depth for all output
This makes all log functions keep a consistent call structure to be nice
with the handleWriter in the slog package which expects a strict level
of 4.

Fixes #67362.

Change-Id: Ib967c696074b1ca931f6656dd27ff1ec484233b8
GitHub-Last-Rev: 49bc424986875da2dd244b57f8b0851d3bfd1a29
GitHub-Pull-Request: golang/go#67645
Reviewed-on: https://go-review.googlesource.com/c/go/+/588335
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: 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>
2025-03-11 13:50:02 -07:00
1911860538
39b783780a net/mail: use sync.OnceValue to build dateLayouts
Simplify buildDateLayouts with sync.OnceValue.

Change-Id: Ib48ab20ee00f5e44cc1b0f6e1afe3fcd1b7dc3c7
GitHub-Last-Rev: 0866d463de1ec618d0d645b98f5e94917b8c3bde
GitHub-Pull-Request: golang/go#72743
Reviewed-on: https://go-review.googlesource.com/c/go/+/656055
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>
2025-03-11 13:47:59 -07:00
Jes Cok
31658ace9d runtime/internal: clean up completely
We've been slowly moving packages from runtime/internal to
internal/runtime. For now, runtime/internal only has test packages.

It's a good chance to clean up the references to runtime/internal
in the toolchain.

For #65355.

Change-Id: Ie6f9091a44511d0db9946ea6de7a78d3afe9f063
GitHub-Last-Rev: fad32e2e81d11508e734c3c3d3b0c1da583f89f5
GitHub-Pull-Request: golang/go#72137
Reviewed-on: https://go-review.googlesource.com/c/go/+/655515
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2025-03-11 12:26:32 -07:00
Brad Fitzpatrick
598df45fce net: unblock UDP Reads upon Close on plan9, add test
Fixes #72770

Change-Id: I42be7c7349961188f4b5d73287a3550aba323893
Reviewed-on: https://go-review.googlesource.com/c/go/+/656395
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2025-03-11 08:30:42 -07:00
Than McIntosh
be2ecfbff8 debug/dwarf: read DWARF 5 cu base offsets on SeekPC() path
This patch fixes a bug in CL 655976 relating to DWARF 5 support; we
were reading in compile unit base offsets on the Seek() path but not
on the corresponding SeekPC path (we need the offsets to be read in
both cases).

Updates #26379.
Fixes #72778.

Change-Id: I02850b786a53142307219292f2c5099eb0271559
Reviewed-on: https://go-review.googlesource.com/c/go/+/656675
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>
2025-03-11 08:18:19 -07:00
Michael Matloob
73fea035bf cmd/go: allow symlinks of non-directory files in embed
We previously disallowed all non-regular files being embedded. This CL
relaxes the restriction a little: if the GODEBUG embedfollowsymlinks=1
is set, we allow the leaf files being embedded (not the directories
containing them) to be symlinks. The files pointed to by the symlinks
must still be regular files.

This will be used when a Bazel build action executing the Go command is
running in a symlink-based sandbox. It's not something we want to enable
in general for now, so it's behind a GODEBUG.

Fixes #59924

Change-Id: I895be14c12de55b7d1b663d81bdda1df37d54804
Reviewed-on: https://go-review.googlesource.com/c/go/+/643215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-03-11 07:51:38 -07:00
Robert Griesemer
a588c6fba6 go/types, types2: report better error messages for make calls
Change-Id: I4593aeb4cad1e2c3f4705ed5249ac0bad910162f
Reviewed-on: https://go-review.googlesource.com/c/go/+/655518
Auto-Submit: 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>
Reviewed-by: Robert Findley <rfindley@google.com>
2025-03-11 05:45:04 -07:00
Robert Griesemer
ae4c13afc5 go/types, types2: report better error messages for slice expressions
Explicitly compute the common underlying type and while doing
so report better slice-expression relevant error messages.
Streamline message format for index and slice errors.

This removes the last uses of the coreString and match functions.
Delete them.

Change-Id: I4b50dda1ef7e2ab5e296021458f7f0b6f6e229cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/655935
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2025-03-11 05:44:15 -07:00
Robert Griesemer
e5d3ece35d go/types, types2: remove need for coreString in signature.go
Also, add additional test cases for NewSignatureType
to check expected panic behavior.

Change-Id: If26cd81a2af384bf2084dd09119483c0584715c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/655695
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>
Reviewed-by: Robert Findley <rfindley@google.com>
2025-03-11 05:44:12 -07:00
Robert Griesemer
2d097e363a go/types, types2: better error messages for copy built-in
Rather than relying on coreString, use the new commonUnder function
to determine the argument slice element types.

Factor out this functionality, which is shared for append and copy,
into a new helper function sliceElem (similar to chanElem).
Use sliceElem for both the append and copy implementation.
As a result, the error messages for invalid copy calls are
now more detailed.

While at it, handle the special cases for append and copy first
because they don't need the slice element computation.

Finally, share the same type recording code for the special and
general cases.

As an aside, in commonUnder, be clearer in the code that the
result is either a nil type and an error, or a non-nil type
and a nil error. This matches in style what we do in sliceElem.

Change-Id: I318bafc0d2d31df04f33b1b464ad50d581918671
Reviewed-on: https://go-review.googlesource.com/c/go/+/655675
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-03-10 21:30:51 -07:00
Guoqi Chen
e3ea8e68fb cmd/internal/obj/loong64: add {V,XV}SEQI, {V,XV}.{AND,OR,XOR,NOR} instructions support
Go asm syntax:
         VSEQB  $1, V2, V3
        XVSEQB  $2, X2, X3
         V{AND,OR,XOR,NOR}B  $1, V2, V3
        XV{AND,OR,XOR,NOR}B  $1, V2, V3
         V{AND,OR,XOR,NOR,ANDN,ORN}V V1, V2, V3
        XV{AND,OR,XOR,NOR,ANDN,ORN}V V1, V2, V3

Equivalent platform assembler syntax:
         vseqi.b v3, v2, $1
        xvseqi.b x3, x2 ,$2
         v{and,or,xor,nor}.b  v3, v2, $1
        xv{and,or,xor,nor}.b  x3, x2, $1
         v{and,or,xor,nor,andn,orn}v v3, v2, v1
        xv{and,or,xor,nor,andn,orn}v x3, x2, x1

Change-Id: I56ae0db72c7f473755cbdc7f7171c1058a9def97
Reviewed-on: https://go-review.googlesource.com/c/go/+/635515
Reviewed-by: Meidan Li <limeidan@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>
2025-03-10 17:55:19 -07:00
Xiaolin Zhao
2a772a2fe7 cmd/compile: optimize shifts of int32 and uint32 on loong64
goos: linux
goarch: loong64
pkg: math/bits
cpu: Loongson-3A6000-HV @ 2500.00MHz
                |  bench.old   |              bench.new               |
                |    sec/op    |    sec/op     vs base                |
LeadingZeros       1.100n ± 1%    1.101n ± 0%        ~ (p=0.566 n=10)
LeadingZeros8      1.501n ± 0%    1.502n ± 0%   +0.07% (p=0.000 n=10)
LeadingZeros16     1.501n ± 0%    1.502n ± 0%   +0.07% (p=0.000 n=10)
LeadingZeros32    1.2010n ± 0%   0.9511n ± 0%  -20.81% (p=0.000 n=10)
LeadingZeros64     1.104n ± 1%    1.119n ± 0%   +1.40% (p=0.000 n=10)
TrailingZeros     0.8137n ± 0%   0.8086n ± 0%   -0.63% (p=0.001 n=10)
TrailingZeros8     1.031n ± 1%    1.031n ± 1%        ~ (p=0.956 n=10)
TrailingZeros16   0.8204n ± 1%   0.8114n ± 0%   -1.11% (p=0.000 n=10)
TrailingZeros32   0.8145n ± 0%   0.8090n ± 0%   -0.68% (p=0.000 n=10)
TrailingZeros64   0.8159n ± 0%   0.8089n ± 1%   -0.86% (p=0.000 n=10)
OnesCount         0.8672n ± 0%   0.8677n ± 0%   +0.06% (p=0.000 n=10)
OnesCount8        0.8005n ± 0%   0.8009n ± 0%   +0.06% (p=0.000 n=10)
OnesCount16       0.9339n ± 0%   0.9344n ± 0%   +0.05% (p=0.000 n=10)
OnesCount32       0.8672n ± 0%   0.8677n ± 0%   +0.06% (p=0.000 n=10)
OnesCount64        1.201n ± 0%    1.201n ± 0%        ~ (p=0.474 n=10)
RotateLeft        0.8005n ± 0%   0.8009n ± 0%   +0.05% (p=0.000 n=10)
RotateLeft8        1.202n ± 0%    1.202n ± 0%        ~ (p=0.210 n=10)
RotateLeft16      0.8050n ± 0%   0.8036n ± 0%   -0.17% (p=0.002 n=10)
RotateLeft32      0.6674n ± 0%   0.6674n ± 0%        ~ (p=1.000 n=10)
RotateLeft64      0.6673n ± 0%   0.6674n ± 0%        ~ (p=0.072 n=10)
Reverse           0.4123n ± 0%   0.4067n ± 1%   -1.37% (p=0.000 n=10)
Reverse8          0.8005n ± 0%   0.8009n ± 0%   +0.05% (p=0.000 n=10)
Reverse16         0.8004n ± 0%   0.8009n ± 0%   +0.06% (p=0.000 n=10)
Reverse32         0.8004n ± 0%   0.8009n ± 0%   +0.06% (p=0.000 n=10)
Reverse64         0.8004n ± 0%   0.8009n ± 0%   +0.06% (p=0.001 n=10)
ReverseBytes      0.4100n ± 1%   0.4057n ± 1%   -1.06% (p=0.002 n=10)
ReverseBytes16    0.8004n ± 0%   0.8009n ± 0%   +0.07% (p=0.000 n=10)
ReverseBytes32    0.8005n ± 0%   0.8009n ± 0%   +0.05% (p=0.000 n=10)
ReverseBytes64    0.8005n ± 0%   0.8009n ± 0%   +0.05% (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.831n ± 0%    1.832n ± 0%        ~ (p=1.000 n=10)
Sub                1.201n ± 0%    1.201n ± 0%        ~ (p=1.000 n=10)
Sub32              1.601n ± 0%    1.602n ± 0%   +0.06% (p=0.000 n=10)
Sub64              1.201n ± 0%    1.201n ± 0%        ~ (p=0.474 n=10)
Sub64multiple      2.400n ± 0%    2.402n ± 0%   +0.10% (p=0.000 n=10)
Mul               0.8005n ± 0%   0.8009n ± 0%   +0.05% (p=0.000 n=10)
Mul32             0.8005n ± 0%   0.8009n ± 0%   +0.05% (p=0.000 n=10)
Mul64             0.8004n ± 0%   0.8008n ± 0%   +0.05% (p=0.000 n=10)
Div                9.107n ± 0%    9.083n ± 0%        ~ (p=0.255 n=10)
Div32              4.009n ± 0%    4.011n ± 0%   +0.05% (p=0.000 n=10)
Div64              9.705n ± 0%    9.711n ± 0%   +0.06% (p=0.000 n=10)
geomean            1.089n         1.083n        -0.62%

goos: linux
goarch: loong64
pkg: math/bits
cpu: Loongson-3A5000 @ 2500.00MHz
                |  bench.old   |              bench.new               |
                |    sec/op    |    sec/op     vs base                |
LeadingZeros       1.352n ± 0%    1.341n ± 4%   -0.81% (p=0.024 n=10)
LeadingZeros8      1.766n ± 0%    1.781n ± 0%   +0.88% (p=0.000 n=10)
LeadingZeros16     1.766n ± 0%    1.782n ± 0%   +0.88% (p=0.000 n=10)
LeadingZeros32     1.536n ± 0%    1.341n ± 1%  -12.73% (p=0.000 n=10)
LeadingZeros64     1.351n ± 1%    1.338n ± 0%   -0.96% (p=0.000 n=10)
TrailingZeros     0.9037n ± 0%   0.9025n ± 0%   -0.12% (p=0.020 n=10)
TrailingZeros8     1.087n ± 3%    1.056n ± 0%        ~ (p=0.060 n=10)
TrailingZeros16    1.101n ± 0%    1.101n ± 0%        ~ (p=0.211 n=10)
TrailingZeros32   0.9040n ± 0%   0.9024n ± 1%   -0.18% (p=0.017 n=10)
TrailingZeros64   0.9043n ± 0%   0.9028n ± 1%        ~ (p=0.118 n=10)
OnesCount          1.503n ± 2%    1.482n ± 1%   -1.43% (p=0.001 n=10)
OnesCount8         1.207n ± 0%    1.206n ± 0%   -0.12% (p=0.000 n=10)
OnesCount16        1.501n ± 0%    1.534n ± 0%   +2.13% (p=0.000 n=10)
OnesCount32        1.483n ± 1%    1.531n ± 1%   +3.27% (p=0.000 n=10)
OnesCount64        1.301n ± 0%    1.302n ± 0%   +0.08% (p=0.000 n=10)
RotateLeft        0.8136n ± 4%   0.8083n ± 0%   -0.66% (p=0.002 n=10)
RotateLeft8        1.311n ± 0%    1.310n ± 0%        ~ (p=0.786 n=10)
RotateLeft16       1.165n ± 0%    1.149n ± 0%   -1.33% (p=0.001 n=10)
RotateLeft32      0.8138n ± 1%   0.8093n ± 0%   -0.57% (p=0.017 n=10)
RotateLeft64      0.8149n ± 1%   0.8088n ± 0%   -0.74% (p=0.000 n=10)
Reverse           0.5195n ± 1%   0.5109n ± 0%   -1.67% (p=0.000 n=10)
Reverse8          0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.000 n=10)
Reverse16         0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.000 n=10)
Reverse32         0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.012 n=10)
Reverse64         0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.010 n=10)
ReverseBytes      0.5120n ± 1%   0.5122n ± 2%        ~ (p=0.306 n=10)
ReverseBytes16    0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.000 n=10)
ReverseBytes32    0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.000 n=10)
ReverseBytes64    0.8007n ± 0%   0.8010n ± 0%   +0.04% (p=0.000 n=10)
Add                1.201n ± 0%    1.201n ± 4%        ~ (p=0.334 n=10)
Add32              1.201n ± 0%    1.201n ± 0%        ~ (p=0.563 n=10)
Add64              1.201n ± 0%    1.201n ± 1%        ~ (p=0.652 n=10)
Add64multiple      1.909n ± 0%    1.902n ± 0%        ~ (p=0.126 n=10)
Sub                1.201n ± 0%    1.201n ± 0%        ~ (p=1.000 n=10)
Sub32              1.655n ± 0%    1.654n ± 0%        ~ (p=0.589 n=10)
Sub64              1.201n ± 0%    1.201n ± 0%        ~ (p=1.000 n=10)
Sub64multiple      2.150n ± 0%    2.180n ± 4%   +1.37% (p=0.000 n=10)
Mul               0.9341n ± 0%   0.9345n ± 0%   +0.04% (p=0.011 n=10)
Mul32              1.053n ± 0%    1.030n ± 0%   -2.23% (p=0.000 n=10)
Mul64             0.9341n ± 0%   0.9345n ± 0%   +0.04% (p=0.018 n=10)
Div                11.59n ± 0%    11.57n ± 1%        ~ (p=0.091 n=10)
Div32              4.337n ± 0%    4.337n ± 1%        ~ (p=0.783 n=10)
Div64              12.81n ± 0%    12.76n ± 0%   -0.39% (p=0.001 n=10)
geomean            1.257n         1.252n        -0.46%

Change-Id: I9e93ea49736760c19dc6b6463d2aa95878121b7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/627855
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-03-10 17:55:10 -07:00
Sean Liao
2abe5ceb19 testing: warn against calling Log after a test completes
Fixes #40343

Change-Id: Id266f4b57131e9e148e5aa2be86b67fe6d73b20a
Reviewed-on: https://go-review.googlesource.com/c/go/+/656415
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-10 15:02:26 -07:00
Daniel McCarney
574a9fa60e crypto/tls: reject TLS 1.3 compat session ID in TLS 1.2
If we weren't resuming an existing session, and we constructed a TLS 1.3
compatible client hello, ensure the server doesn't echo back the
made up compatibility session ID if we end up handshaking for TLS 1.2.

As part of an effort to make the initial stages of a TLS 1.3 handshake
compatible with TLS 1.2 middleboxes, TLS 1.3 requires that the client
hello contain a non-empty legacy_session_id value. For anti-ossification
purposes it's recommended this ID be randomly generated. This is the
strategy the crypto/tls package takes.

When we follow this approach, but then end up negotiating TLS 1.2, the
server should not have echoed back that random ID to us. It's impossible
for the server to have had a session with a matching ID and so it is
misbehaving and it's prudent for our side to abort the handshake.

See RFC 8446 Section 4.1.2 for more detail:
  https://www.rfc-editor.org/rfc/rfc8446#section-4.1.2

Adopting this behaviour allows un-ignoring the BoGo
EchoTLS13CompatibilitySessionID testcase.

Updates #72006

Change-Id: I1e52075177a13a7aa103b45498eae38d8a4c34b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/652997
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2025-03-10 14:20:44 -07:00
Daniel McCarney
4635ad047a crypto/tls: align cert decode alert w/ BSSL
For malformed client/server certificates in a TLS handshake send
a decode_error alert, matching BoringSSL behaviour.

Previously crypto/tls used a bad_certificate alert for this purpose.
The TLS specification is imprecise enough to allow this to be considered
a spec. justified choice, but since all other places in the protocol
encourage using decode_error for structurally malformed messages we may
as well do the same here and get some extra cross-impl consistency for
free.

This also allows un-ignoring the BoGo
GarbageCertificate-[Client|Server]-[TLS12|TLS13] tests.

Updates #72006

Change-Id: Ide45ba1602816e71c3289a60e77587266c3b9036
Reviewed-on: https://go-review.googlesource.com/c/go/+/652995
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-03-10 14:20:33 -07:00
Daniel McCarney
5b4209fedb crypto/tls: update GREASE-Server-TLS13 BoGo skip
Previously this test was skipped without a comment clarifying why. In
practice it's because crypto/tls doesn't generate GREASE extensions at
this time, and the test expects to find one in the NewSessionTicket
message extensions produced by a server.

We're already skipping some other GREASE related test as
not-yet-implemented without explicit bogo_config.json exclusion by way
of the -enable-grease flag not being implemented, however for TLS
1.3 servers the BoGo expectation is that they _always_ send GREASE, and
so the -enable-grease flag isn't provided and an explicit skip must be
used.

We should revisit this alongside implementing GREASE ext production in
general for both clients and servers.

Updates #72006

Change-Id: I8af4b555ac8c32cad42215fbf26aa0feae90fa21
Reviewed-on: https://go-review.googlesource.com/c/go/+/650717
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-03-10 14:20:22 -07:00
Daniel McCarney
01688daca6 crypto/tls: support bogo -wait-for-debugger
When this command line flag is provided to the BoGo runner it will:

* Disable some timeouts
* Limit concurrency to 1 worker at a time
* Pass the -wait-for-debugger flag to the shim process
* Print the PID of the shim process to status output

On the shim-side, we need to react to -wait-for-debugger by sending
ourselves a SIGSTOP signal. When a debugger attaches to the shim the
process will be resumed.

This makes it possible to debug both the runner side and the shim side
of a BoGo interaction without resorting to print style debugging.

Since SIGSTOP is not a signal we can use on Windows this functionality
is limited to unix builds.

Updates #72006

Change-Id: Iafa08cf71830cdfde3e6ee4826914236e3cd7e57
Reviewed-on: https://go-review.googlesource.com/c/go/+/650737
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-10 14:20:11 -07:00
Daniel McCarney
2611d81dc8 crypto/tls: ignore TLS 1.3 user canceled alerts
When encountering alertUserCanceled in a TLS 1.3 handshake, ignore the
alert and retry reading a record. This matches existing logic for how
TLS 1.2 alertLevelWarning alerts are handled.

For broader context, TLS 1.3 removed warning-level alerts except for
alertUserCanceled (RFC 8446, § 6.1). Since at least one major
implementation (https://bugs.openjdk.org/browse/JDK-8323517)
misuses this alert, many TLS stacks now ignore it outright when seen in
a TLS 1.3 handshake (e.g. BoringSSL, NSS, Rustls).

With the crypto/tls behaviour changed to match peer implementations we
can now enable the "SendUserCanceledAlerts-TLS13" BoGo test.

"SendUserCanceledAlerts-TooMany-TLS13" remains ignored, because like
"SendWarningAlerts*" fixing the test requires some general spam
protocol message enhancements be done first.

Updates #72006

Change-Id: I570c1fa674b5a4760836c514d35ee17f746fe28d
Reviewed-on: https://go-review.googlesource.com/c/go/+/650716
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-03-10 14:20:01 -07:00
Daniel McCarney
b0e7f95aac crypto/tls: run SkipNewSessionTicket bogo test
This commit removes SkipNewSessionTicket from the bogo_config.json
excluded tests list.

Previously this test was being skipped with a TODO that there might be
a bug here. In practice it seems like there's no bug and the test is
handled correctly by crypto/tls.

When activated, a TLS 1.2 client connecting to the bogo dispatcher goes
through the normal handshake process with the exception that the server
skips sending the NewSessionTicket msg expected by the client in
response to the client's final flight of handshake msgs.

The crypto/tls TLS 1.2 client_handshake.go logic correctly rejects the
unexpected message that follows (ChangeCipherSpec) when trying to read
the bytes necessary to unmarshal the expected NewSessionTicket message
that was omitted.

Updates #72006

Change-Id: I9faea4d18589d10b163211aa17b2d0da8af1187e
Reviewed-on: https://go-review.googlesource.com/c/go/+/650736
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: 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>
2025-03-10 14:19:47 -07:00
Prabhav Dogra
04164e5f5a internal/runtime/atomic: updated go assembler comments
Updated comments in go assembler package

Change-Id: I174e344ca45fae6ef70af2e0b29cd783b003b4c2
GitHub-Last-Rev: 8ab37208891e795561a943269ca82b1ce6e7eef5
GitHub-Pull-Request: golang/go#72048
Reviewed-on: https://go-review.googlesource.com/c/go/+/654478
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: PRABHAV DOGRA <prabhavdogra1@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-10 14:03:16 -07:00
Daniel McCarney
895bcf178d crypto/tls: reject empty TLS 1.3 session ticket
While not clearly motivated by normative language in RFC 8446 it seems
clear that an empty opaque ticket value is non-operable, and so we
should reject it with an appropriate alert/error.

This allows removing the SendEmptySessionTicket-TLS13 BoGo test from the
bogo excluded tests configuration.

Fixes #70513
Updates #72006

Change-Id: I589b34e86fb1eb27a349a230e920c22284597cde
Reviewed-on: https://go-review.googlesource.com/c/go/+/650735
Reviewed-by: Filippo Valsorda <filippo@golang.org>
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>
Auto-Submit: Daniel McCarney <daniel@binaryparadox.net>
2025-03-10 14:02:22 -07:00
Michael Matloob
2620cc1caa cmd/go/internal/mmap: close file after mmap
Closing the file after mmap will reduce the number of files associated
with the process. This will not likely help with #71698 but it doesn't
hurt to close the files and should simplify lsof output.

For #71698

Change-Id: I06a1bf91914afc7703783fe1a38d8bc5a6fb3d9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/653055
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-03-10 11:11:55 -07:00
Than McIntosh
fd3997168d cmd/cgo/internal/testsanitizers: bump GCC version for asan location checking
Require GCC 11 or greater to turn on the location checking portion of
the asan tests in this directory; the copy of libasan.so.6 shipped
with GCC 10 doesn't seem to properly digest the new DWARF 5 being
generated by the Go compiler+linker.

Updates #72752.

Change-Id: I92718c112df844d9333c4c798cddaae95665feb2
Reviewed-on: https://go-review.googlesource.com/c/go/+/656175
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-10 09:33:18 -07:00
Than McIntosh
e256e64060 debug/dwarf: fix problem with DWARF 5 and Seek method
When clients use debug/dwarf to examine DWARF 5 binaries, we can run
into problems when the Seek() method is used to skip ahead from a DIE
in one compilation unit to a DIE in another unit. The problem here is
that it is common for DWARF 5 comp units to have attributes (ex:
DW_AT_addr_base) whose value must be applied as an offset when reading
certain forms (ex: DW_FORM_addrx) within that unit. The existing
implementation didn't have a good way to recover these attrs following
the Seek call, and had to essentially punt in this case, resulting in
incorrect attr values.

This patch adds new support for reading and caching the key comp unit
DIE attributes (DW_AT_addr_base, DW_AT_loclists_base, etc) prior to
visiting any of the DIE entries in a unit, storing the cache values of
these attrs the main table of units. This base attribute
reading/caching behavior also happens (where needed) after Seek calls.

Should resolve delve issue 3861.
Supercedes Go pull request 70400.

Updates #26379.
Fixes #57046.

Change-Id: I536a57e2ba4fc55132d91c7f36f67a91ac408dc3
Reviewed-on: https://go-review.googlesource.com/c/go/+/655976
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-10 09:05:58 -07:00
Than McIntosh
c3e7d5f5ce debug/dwarf: refactor entry DIE reading helper
Simplify the signature of the "entry()" buf method to accept a unit as
opposed to a collection of unit components (version, atable, etc). No
change in functionality, this is a pure refactoring that will be
needed in subsequent patch.

Change-Id: I688def34e39d36b6a62733bc73dc42b49f78ca41
Reviewed-on: https://go-review.googlesource.com/c/go/+/655975
Reviewed-by: 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>
2025-03-10 08:35:44 -07:00
Michael Pratt
c40a3731f4 internal/godebugs: add decoratemappings as an opaque godebug setting
This adds a new godebug to control whether the runtime applies the
anonymous memory mapping annotations added in https://go.dev/cl/646095.
It is enabled by default.

This has several effects:

* The feature is only enabled by default when the main go.mod has go >=
  1.25.
* This feature can be disabled with GODEBUG=decoratemappings=0, or the
  equivalents in go.mod or package main. See https://go.dev/doc/godebug.
* As an opaque setting, this option will not appear in runtime/metrics.
* This setting is non-atomic, so it cannot be changed after startup.

I am not 100% sure about my decision for the last two points.

I've made this an opaque setting because it affects every memory mapping
the runtime performs. Thus every mapping would report "non-default
behavior", which doesn't seem useful.

This setting could trivially be atomic and allow changes at run time,
but those changes would only affect future mappings. That seems
confusing and not helpful. On the other hand, going back to annotate or
unannotate every previous mapping when the setting changes is
unwarranted complexity.

For #71546.

Change-Id: I6a6a636c5ad551d76691cba2a6f668d5cff0e352
Reviewed-on: https://go-review.googlesource.com/c/go/+/655895
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-03-10 08:29:59 -07:00
Gusted
c3950f8430 crypto/pbkdf2: fix code example for Key
The type for password is not `[]byte` (as it was in golang.org/x/crypto/pbkdf2), it is `string`.

Change-Id: I914a81a500a6d93f994b587814f26285aef7b96d
GitHub-Last-Rev: 5ec752e0def59c1058c649b4543f296467691813
GitHub-Pull-Request: golang/go#72746
Reviewed-on: https://go-review.googlesource.com/c/go/+/656115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
2025-03-10 08:11:48 -07:00
Damien Neil
22d5d09f1e net/http/httputil: close hijacked connections when CloseWrite not available
CL 637939 changed ReverseProxy's handling of hijacked connections:
After copying all data in one direction, it half-closes the outbound
connection rather than fully closing both.

Revert to the old behavior when the outbound connection does not support
CloseWrite, avoiding a case where one side of the proxied connection closes
but the other remains open.

Fixes #72140

Change-Id: Ic0cacaa6323290f89ba48fd6cae737e86045a435
Reviewed-on: https://go-review.googlesource.com/c/go/+/655595
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
2025-03-10 08:11:43 -07:00
Daniel McCarney
bc5f4a555e crypto/tls: small bogo shim test tidying
1. onResumeShimWritesFirst is unused, replace the binding with an
   underscore.
2. in the bogoShim() function when looping through resumeCount+1 the
   tlsConn read for loop only breaks for non-nil err, so there's no need
   to check that again after the loop body.

Updates #72006

Change-Id: Ieff45d26df33d71003a2509ea5b2b06c5fa0e1d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/650715
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-03-07 12:37:36 -08:00
Tobias Klauser
e6908846df os: remove unused testingForceReadDirLstat
It was introduced in CL 261540 but never set by any test.

Change-Id: Id2a59c58ed510b6041cc51ce47ab79199a60b215
Reviewed-on: https://go-review.googlesource.com/c/go/+/655797
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2025-03-07 11:33:06 -08:00
Filippo Valsorda
705fa920c1 crypto/internal/fips140: make Version return latest when not frozen
Fixes #71820

Change-Id: I6a6a46563da281a7b20efc61eefdcbb2e146db33
Reviewed-on: https://go-review.googlesource.com/c/go/+/655795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-03-07 11:33:03 -08:00
Olivier Mengué
d7e5cd5851 compress/flate,compress/lzw: fix incorrect godoc links
Fix incorrect godoc links related to the use of the name "Reader" for
different things in the various compress/* packages:
- in compress/flate Reader is the interface describing the underlying reader,
  not the decompressor as in other packages, so "returned reader" must
  not be linked to Reader.
- in compress/lzw and compress/gzip Reader is the decompressor, not the
  interface of the underlying reader, so "underlying reader" must not
  be linked to Reader.

With this patch the formatting of "underlying reader" and "returned
reader" is consistent accross compress/* packages.

Change-Id: Iea315fd5ee5b6c177855693d68841f3709a382cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/655335
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-07 11:33:01 -08:00
Filippo Valsorda
b4a333fea5 crypto/internal/fips140/bigmod: explicitly clear expanded limbs on reset
Russ Cox noticed that reset was clearing limbs up to the *previous* Nat
size, not up to the new size, because clear(x.limbs) was happening
before the x.limbs[:n] reslice.

That's potentially a severe issue, because it may leave garbage in
x.limbs[len(x.limbs):n] if n < cap(x.limbs).

We were saved by an accidental invariant caused by the bug itself,
though: x.limbs[len(x.limbs):cap(x.limbs)] are always zero.

reset was always clearing all exposed (and hence potentially non-zero)
limbs before shrinking the Nat, and the only other function that could
shrink the Nat was trim, which only trims zero limbs.

Near miss.

Preserve the accidental invariant in the fix, because memclr is cheap
and it just proved it can save us from potential mistakes.

Change-Id: I6a6a4656a77735d8e8d520c699c4d85dd33ce497
Reviewed-on: https://go-review.googlesource.com/c/go/+/655056
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-03-07 11:32:59 -08:00
linmaolin
e0b110b926 text/template: add an if func example
Updates #13880

Change-Id: I0fd3b1a32e485bc8f15238c86a8bbdc161f20fa5
GitHub-Last-Rev: d1e92b31243c86435add422ee46aaff768453cad
GitHub-Pull-Request: golang/go#71922
Reviewed-on: https://go-review.googlesource.com/c/go/+/651916
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-07 11:32:13 -08:00
Olivier Mengué
812a44ebd0 archive/zip: preallocate fileList size for Reader.Open
When building the index of file entries for Reader.Open (when the Reader
is used as an io/fs.FS), reduce reallocations by pre-allocating the
count of entries based on the count of file entries.

Change-Id: I05048337cb5e752054b3e984a8a5ec5199c4589b
Reviewed-on: https://go-review.googlesource.com/c/go/+/655476
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-03-07 11:31:30 -08:00
Rob Findley
fe9b292b11 go/types,types2: allocate the used* maps in initFiles
As described in the associated comment, we need to reallocate usedVars
and usedPkgNames in initFiles, as they are nilled out at the end of
Checker.Files, which may be called multiple times.

Fixes #72122

Change-Id: I9f6eb86e072d9d43a8720f6a5e86d827de6006a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/655437
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-03-07 10:54:49 -08:00
Ian Lance Taylor
d43c0f80d8 net: add comment about blocking to Conn.Close
Fixes #18187

Change-Id: I3d0119838ddbfb99a067ba563e5d247f574ef841
Reviewed-on: https://go-review.googlesource.com/c/go/+/655517
Reviewed-by: 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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-03-06 15:35:06 -08:00
Robert Griesemer
8a7742e78c go/types, types2: factor out shared for-range checking code into range.go
For go/types, generate its range.go file from the corresponding types2 file.

Change-Id: Iaff3ecbf1c536143c92f7b50e2461140469f9280
Reviewed-on: https://go-review.googlesource.com/c/go/+/655536
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2025-03-06 13:44:34 -08:00
Robert Griesemer
232dfd226b go/types, types2: rename errorCause to typeError
Change-Id: Ib8a63cdaa12dacb5223318a7166fe3dfdac71a45
Reviewed-on: https://go-review.googlesource.com/c/go/+/654655
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2025-03-06 13:41:01 -08:00
Robert Griesemer
5af3658eaa go/types, types2: use errorCause instead of reportf in comparableType
If the error cause is not further specified (empty string),
avoid allocating a new errorCause. This makes using errorCauses
as boolean signals efficient.

While at it, fix an error message for incomparable arrays:
report the array type rather than its underlying type.

Change-Id: I844b18a76695330ca726932ee760aa89635f6a38
Reviewed-on: https://go-review.googlesource.com/c/go/+/654575
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2025-03-06 13:40:58 -08:00
Robert Griesemer
584e631023 go/types, types2: better error messages for invalid calls
Rather than reporting "non-function" for an invalid type parameter,
report which type in the type parameter's type set is not a function.

Change-Id: I8beec25cc337bae8e03d23e62d97aa82db46bab4
Reviewed-on: https://go-review.googlesource.com/c/go/+/654475
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-06 13:35:49 -08:00
Robert Griesemer
8b7e376e71 go/types, types2: factor out single commonUnder function
Combine commonUnder and commonUnderOrChan:
- Provide an optional cond(ition) function argument to commonUnder
  to establish additional type set conditions.
- Instead of a *Checker and *string argument for error reporting,
  return an error cause that is only allocated in the presence of
  an error.
- Streamline some error messages.

Replace all calls to coreType with calls to commonUnder.

Change-Id: I81ac86d0d532cddc09164309acced61d90718b44
Reviewed-on: https://go-review.googlesource.com/c/go/+/654455
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>
2025-03-06 13:35:46 -08:00
Ian Lance Taylor
f55bb135d2 cmd/cgo/internal/testsanitizers: for "leak", use -fsanitize=address
We currently test the leak detector by running "go build -asan",
which will pass -fsanitize=address to the C compiler.
So use that when testing whether the option works.

Fixes #72128

Change-Id: I4efc0b689bfda04c80dbac30a5c757215f297d2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/655535
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-06 13:27:16 -08:00
Michael Matloob
24d22352d3 cmd/go: add 'work' package pattern
The 'work' package pattern will resolve to the set of packages in the
work (formerly called main) modules. It's essentially 'all', but without
the dependencies. And the implementation is similar to that of 'all',
except that we don't expand to the dependencies.

Fixes #71294

Change-Id: I3d02beb74fa4e5c6de2290e24eedc51745d13080
Reviewed-on: https://go-review.googlesource.com/c/go/+/643235
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-06 11:14:22 -08:00
Olivier Mengué
9bd2160790 os: add missing calls to Root.Close() in tests
In tests of os.Root, fix a few missing calls to Close().

Change-Id: I8fddd5468394f41d7e92741579fd47f90203ff9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/655337
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2025-03-06 10:29:01 -08:00
David Chase
1cf6b50263 cmd/compile: remove no-longer-necessary recursive inlining checks
this does result in a little bit more inlining,
cmd/compile text is 0.5% larger,
bent-benchmark text geomeans grow by only 0.02%.
some of our tests make assumptions about inlining.

Change-Id: I999d1798aca5dc64a1928bd434258a61e702951a
Reviewed-on: https://go-review.googlesource.com/c/go/+/655157
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-03-06 10:07:17 -08:00
Ryan Currah
6a4bc8d17e cmd/go: cache coverage profile with tests
This CL stores coverage profile data in the GOCACHE under the
'coverprofile' subkey alongside tests. This makes tests which use
coverage profiles cacheable. The values of the -coverprofile and
-outputdir flags are not included in the cache key to allow cached
profile data to be written to any output file.

Note: This is a rebase and squash from the original PRs below that
was created/closed/abandoned by @jproberts and @macnibblet that I
plan to maintain.

- https://github.com/golang/go/pull/50483
- https://github.com/golang/go/pull/65657

I made improvements to the change based on feedback from @bcmills in Gerrit
https://go-review.googlesource.com/c/go/+/563138.

From @macnibblet:

I don't know if anyone has considered the environmental impact
(Yes, of course, dev experience too), but on a team with 3 backend
developers, when I replaced our CI Golang version with this build,
it reduced the build time by 50%, which would have
equated to about 5000 hours of CI reduced in the past year.

Fixes #23565

Change-Id: I59a20af5ea156f990a17544cf06dc667ae7f8aa3
GitHub-Last-Rev: a5a1d1b9c87ff433d16f656fc8988e1cb1ce7100
GitHub-Pull-Request: golang/go#69339
Reviewed-on: https://go-review.googlesource.com/c/go/+/610564
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-03-06 08:27:15 -08:00
Olivier Mengué
938b6c15e9 os: more godoc links
Add missing links to *PathError.

Also a few links to O_ flags and Mode and syscall constants.

Change-Id: Ic6ec5780a44942050a83ed07dbf16d6fa9f83eb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/655375
Reviewed-by: Junyang Shao <shaojunyang@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>
2025-03-06 08:21:11 -08:00
Olivier Mengué
66b7640354 compress/lzw,compress/gzip,compress/flate,compress/zlib,compress/bzip2: go doc links
Add godoc links to compress/* package doc.

Change-Id: I768ca250a39b0bb70eca35ac5b3b77ead73ca5f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/655057
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-03-06 08:21:08 -08:00
Xiaolin Zhao
53d689ce99 cmd/internal/obj/loong64: add {V,XV}ILV{L/H}.{B/H/W/D} instructions support
Go asm syntax:
	 VILV{L/H}{B/H/W/V}	VK, VJ, VD
	XVILV{L/H}{B/H/W/V}	XK, XJ, XD

Equivalent platform assembler syntax:
	 vilv{l/h}.{b/h/w/d}	vd, vj, vk
	xvilv{l/h}.{b/h/w/d}	xd, xj, xk

Change-Id: I40e21737649d9fdbbc9a423e859f4c0a56d069fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/635936
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Junyang Shao <shaojunyang@google.com>
2025-03-06 08:15:51 -08:00
Michael Matloob
3aef716168 doc: update godebug doc to clarify godebug directive in workspace
Make it clear that we only use godebug directives in the go.work, and
that we don't use those in go.mod, when we're in a workspace.

Fixes #72109

Change-Id: I648bfa4dd9b3ca0ac299c0a890843d41fe1ac7f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/655158
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-06 08:08:42 -08:00
Russ Cox
70dcc78871 math/big: avoid negative slice size in nat.rem
In a division, normally the answer to N digits / D digits has N-D digits,
but not when N-D is negative. Fix the calculation of the number of
digits for the temporary in nat.rem not to be negative.

Fixes #72043.

Change-Id: Ib9faa430aeb6c5f4c4a730f1ec631d2bf3f7472c
Reviewed-on: https://go-review.googlesource.com/c/go/+/655156
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-06 08:08:34 -08:00
Filippo Valsorda
5e0dbec7c9 crypto/rsa: add a test with very different prime sizes
Change-Id: I6a6a46565bdd804790434e2a14216b9f788e5af4
Reviewed-on: https://go-review.googlesource.com/c/go/+/655055
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Junyang Shao <shaojunyang@google.com>
2025-03-06 08:07:28 -08:00
Filippo Valsorda
e7f9e760c7 crypto: test for unexpected concrete methods in interface value returns
Change-Id: I24188ad5f51953b2fbdef7487acc4ab6b1d77575
Reviewed-on: https://go-review.googlesource.com/c/go/+/638175
Auto-Submit: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-06 08:06:34 -08:00
Andy Pan
92a63bdfee runtime: explicitly disable async preempt for internal/runtime
For #71591
Relevant CL 560155

Change-Id: Iebc497d56b36d50c13a6dd88e7bca4578a03cf63
Reviewed-on: https://go-review.googlesource.com/c/go/+/654916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-03-06 07:57:52 -08:00
limeidan
6cb8c839f9 cmd/link/internal: remove trampoline for plt on loong64
When trampoline is called, the plt symbol has not been
added. If we add tramp here, plt will not work.

Change-Id: I64e5d2be9e08f78ca5e8a9dcb267620a481d4416
Reviewed-on: https://go-review.googlesource.com/c/go/+/654918
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
2025-03-06 00:18:36 -08:00
Xiaolin Zhao
6ba91df153 math: implement func archExp and archExp2 in assembly on loong64
goos: linux
goarch: loong64
pkg: math
cpu: Loongson-3A6000 @ 2500.00MHz
        |  bench.old  |              bench.new              |
        |   sec/op    |   sec/op     vs base                |
Exp       26.30n ± 0%   12.93n ± 0%  -50.85% (p=0.000 n=10)
ExpGo     26.86n ± 0%   26.92n ± 0%   +0.22% (p=0.000 n=10)
Expm1     16.76n ± 0%   16.75n ± 0%        ~ (p=0.060 n=10)
Exp2      23.05n ± 0%   12.12n ± 0%  -47.42% (p=0.000 n=10)
Exp2Go    23.41n ± 0%   23.47n ± 0%   +0.28% (p=0.000 n=10)
geomean   22.97n        17.54n       -23.64%

goos: linux
goarch: loong64
pkg: math/cmplx
cpu: Loongson-3A6000 @ 2500.00MHz
    |  bench.old  |              bench.new              |
    |   sec/op    |   sec/op     vs base                |
Exp   51.32n ± 0%   35.41n ± 0%  -30.99% (p=0.000 n=10)

goos: linux
goarch: loong64
pkg: math
cpu: Loongson-3A5000 @ 2500.00MHz
        |  bench.old  |              bench.new              |
        |   sec/op    |   sec/op     vs base                |
Exp       50.27n ± 0%   48.75n ± 1%   -3.01% (p=0.000 n=10)
ExpGo     50.72n ± 0%   50.44n ± 0%   -0.55% (p=0.000 n=10)
Expm1     28.40n ± 0%   28.32n ± 0%        ~ (p=0.360 n=10)
Exp2      50.09n ± 0%   21.49n ± 1%  -57.10% (p=0.000 n=10)
Exp2Go    50.05n ± 0%   49.69n ± 0%   -0.72% (p=0.000 n=10)
geomean   44.85n        37.52n       -16.35%

goos: linux
goarch: loong64
pkg: math/cmplx
cpu: Loongson-3A5000 @ 2500.00MHz
    |  bench.old  |              bench.new              |
    |   sec/op    |   sec/op     vs base                |
Exp   88.56n ± 0%   67.29n ± 0%  -24.03% (p=0.000 n=10)

Change-Id: I89e456d26fc075d83335ee4a31227d2aface5714
Reviewed-on: https://go-review.googlesource.com/c/go/+/653935
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-03-05 18:30:54 -08:00
Xiaolin Zhao
39d7a49736 cmd/internal/obj/loong64: add {V,XV}{ADD/SUB}.{B,H,W,D,Q} and {V,XV}{ADD/SUB}.{B,H,W,D}Uinstructions support
Go asm syntax:
	 V{ADD/SUB}{B,H,W,V,Q}		VK, VJ, VD
	XV{ADD/SUB}{B,H,W,V,Q}		XK, XJ, XD
	 V{ADD/SUB}{B,H,W,V}U		$1, VJ, VD
	XV{ADD/SUB}{B,H,W,V}U		$1, XJ, XD

Equivalent platform assembler syntax:
	 v{add/sub}.{b,h,w,d,q}		vd, vj, vk
	xv{add/sub}.{b,h,w,d,q}		xd, xj, xk
	 v{add/sub}i.{b,h,w,d}u		vd, vj, $1
	xv{add/sub}i.{b,h,w,d}u		xd, xj, $1

Change-Id: Ia1ef0bc062f4403bb0b1514c2cf1c0264f5d22ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/637795
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-05 18:29:37 -08:00
Ian Lance Taylor
645ea53019 runtime: in asan mode call __lsan_do_leak_check when exiting
This enables the ASAN default behavior of reporting C memory leaks.
It can be disabled with ASAN_OPTIONS=detect_leaks=0.

Fixes #67833

Change-Id: I420da1b5d79cf70d8cf134eaf97bf0a22f61ffd0
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-asan-clang15,gotip-linux-arm64-asan-clang15
Reviewed-on: https://go-review.googlesource.com/c/go/+/651755
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-05 18:23:46 -08:00
David Chase
cad4dca518 cmd/compile: use inline-Pos-based recursion test
Look at the inlining stack of positions for a call site,
if the line/col/file of the call site appears in that
stack, do not inline.  This subsumes all the other
recently-added recursive inlining checks, but they are
left in to make this easier+safer to backport.

Fixes #72090

Change-Id: I0f487bb0d4c514015907c649312672b7be464abd
Reviewed-on: https://go-review.googlesource.com/c/go/+/655155
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>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2025-03-05 15:02:38 -08:00
Rob Findley
9189921e47 go/types,types2: externalize used objects
The 'used' field on Var and PkgName is fundamentally an aspect of the
type checking pass: it records when objects are used, for the purposes
of reporting errors for unused variables or package names. While
expedient and performant, recording this information in the types.Object
instances themselves increases the memory footprint of type-checked
packages, and (as we saw in golang/go#71817) can lead to data races when
Objects are reused in follow-up type checking, such as is done with the
CheckExpr and Eval APIs.

Fix this by externalizing the 'used' information into two maps (one for
variables and one for packages) on the types.Checker, so that they are
garbage-collected after type checking, and cannot be a source of data
races.

Benchmarks showed essentially no change in performance.

Fixes golang/go#71817

Change-Id: I40daeabe4ecaca3bcb494e2f1c62a04232098e49
Reviewed-on: https://go-review.googlesource.com/c/go/+/650796
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-03-05 13:54:45 -08:00
Sean Liao
f7204d76bc html/template: example for disallowed script type change
Fixes #59112

Change-Id: I617f8a4581a55a0f134f488462f415ec22eb4ee3
Reviewed-on: https://go-review.googlesource.com/c/go/+/496145
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-05 12:18:08 -08:00
Grégoire Lodi
061efaa8a7 net/http: make http.FileServer return 404 when a path is invalid/unsafe
This PR adds error handling in net/http toHTTPError to return a 404
instead of a 500 when net/http fs.Dir.Open throws the error http:
invalid or unsafe file path.

Fixes #72091

Change-Id: I7941c8fca5160a4a82732dc1d05b9b95eac84fbf
GitHub-Last-Rev: 04b5019dfb629820621f3776d6f22fd754171565
GitHub-Pull-Request: golang/go#72108
Reviewed-on: https://go-review.googlesource.com/c/go/+/654975
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-03-05 11:26:39 -08:00
Michael Matloob
37026a7c56 cmd/go: skip some tests that run builds in short mode
cmd/go tests that run builds are generally skipped in short mode. This
change will adds skips for some tests that were running builds.

I found these by sorting tests by elapsed time and removing the top
tests that invoked go build. It's our practice to skip tests that run go
build without the -n flag (which prints but doesn't execute commands).

On my work laptop this reduces test run time from about 20 seconds to
about 16 seconds. On my linux workstation it reduces test run time from
about 10 seconds to about 5 seconds.

Change-Id: I18ffcc231df013cb6ac5f5eb3544bed28dadeda8
Reviewed-on: https://go-review.googlesource.com/c/go/+/653775
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-05 10:23:35 -08:00
Alan Donovan
932a4a4bef go/types: add Var.Kind() VarKind method
This CL adds an enum type, VarKind, that discriminates among
the various kinds of Var, and adds setter/getter methods
for Var's kind field.

Beware: NewVar has a weaker postcondition: the Var objects it
returns are not completely initialized and require a call to
Var.SetKind. This should only affect importers.

No changes are needed to the export data, since the kind can
always be deduced from the context when decoding.

See CL 645656 for the corresponding x/tools changes.

+ test, relnote, API

Updates golang/go#70250

Change-Id: Icde86ad22a880cde6f50bc12bf38004a5c6a1025
Reviewed-on: https://go-review.googlesource.com/c/go/+/645115
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2025-03-05 10:21:15 -08:00
rorycl
2c16041423 text/template: provide example of overwriting template func after parse
This example illustrates how to overwrite a template function after parsing a template.

This example is intended to clarify the point made in the template.Funcs docstring
that "[i]t is legal to overwrite elements of the map."

Change-Id: Ibded05974d580c54a24fcc16687fd52ce21133ff
GitHub-Last-Rev: ef19a221ab44f47695c27b3114281112231a1b42
GitHub-Pull-Request: golang/go#72094
Reviewed-on: https://go-review.googlesource.com/c/go/+/654416
Reviewed-by: Junyang Shao <shaojunyang@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>
2025-03-05 07:58:03 -08:00
Sean Liao
2e6cbab1c8 encoding/pem: clarify Decode only works on lines
Fixes #53524

Change-Id: I929ee3c055c3ca564cd6cc374124f493aea2fbf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/421636
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-03-05 07:57:03 -08:00
go101
6f90ae3623 cmd/compile: improve issue62407_test
The original issue62407_test also passes with versions prior to 1.23.
The improvement makes it fail with versions prior to 1.23.

Change-Id: I94bfb9d1ac695c8e07997d7029fc2101535e14f8
GitHub-Last-Rev: 44be2a610a1a79d04dc3d228af2b313200f4d900
GitHub-Pull-Request: golang/go#70938
Reviewed-on: https://go-review.googlesource.com/c/go/+/638036
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2025-03-05 07:55:58 -08:00
Keith Randall
f27d86c631 cmd/compile: add tests for too-large shift amounts
Update #72018

Change-Id: I3188019658c37da3c31f06472023b39e13170ebf
Reviewed-on: https://go-review.googlesource.com/c/go/+/654316
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-03-05 07:55:05 -08:00
Jes Cok
8abb8aa9a9 testing: modify got,want equal comparison for unordered example output
This change eliminates sortLines function to avoid strings.Join calls.

It's not a performance problem, this change tries to make the comparison
more straightforward.

Change-Id: I3a7ae877c9fc927833ab9f143205f7e007197f60
GitHub-Last-Rev: a71aa58c58533fed24ba9c101664b977a094caf9
GitHub-Pull-Request: golang/go#72025
Reviewed-on: https://go-review.googlesource.com/c/go/+/653556
Reviewed-by: Junyang Shao <shaojunyang@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>
2025-03-05 07:44:41 -08:00
Filippo Valsorda
583d586ef9 sync: document behavior of Map.Delete when key is not present
Change-Id: I6a6a465631e91141a5fcc9c04a7df0dc47780731
Reviewed-on: https://go-review.googlesource.com/c/go/+/643955
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-03-05 03:28:07 -08:00
Damien Neil
350118666d net/http: don't modify caller's tls.Config.NextProtos
Clone the input slice before adjusting NextProtos
to add or remove "http/1.1" and "h2" entries,
so as not to modify a slice that the caller might be using.
(We clone the tls.Config that contains the slice, but
that's a shallow clone.)

Fixes #72100

Change-Id: I9f228b8fb6f6f2ca5023179ec114929c002dbda9
Reviewed-on: https://go-review.googlesource.com/c/go/+/654875
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-04 16:56:00 -08:00
Damien Neil
a1889554fc context: skip allocs test with -asan
Allocates more with -asan after CL 653795.

Change-Id: Ib8cc1de1d649623713b6fc123c1c59a47528857b
Reviewed-on: https://go-review.googlesource.com/c/go/+/654876
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-03-04 16:37:03 -08:00
Junyang Shao
3705a6f1f0 all: update golang.org/x/net
For #71984

Change-Id: Ic15826f09ea818f8833bd3d979bffaede24d49df
Reviewed-on: https://go-review.googlesource.com/c/go/+/654717
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Junyang Shao <shaojunyang@google.com>
2025-03-04 13:19:15 -08:00
Filippo Valsorda
0cfc641420 crypto/elliptic: drop hidden Inverse and CombinedMult methods
These methods were previously used by crypto/ecdsa, but now not even
ecdsa_legacy.go uses them. Neither were ever documented.

Inverse was available only on P256() and only on amd64 and arm64, so
hopefully no one used it. CombinedMult was always available on all
curves, so it's possible some application might have used it, but all
the samples on GitHub I can find copied the old crypto/ecdsa package,
which does a conditional interface upgrade with a fallback, so they
won't break.

Change-Id: I6a6a4656ee1ab98438ca0fb20bea53b229cd7e71
Reviewed-on: https://go-review.googlesource.com/c/go/+/640116
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-04 12:43:35 -08:00
Lénaïc Huard
52eaed6633 runtime: decorate anonymous memory mappings
Leverage the prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, ...) API to name
the anonymous memory areas.

This API has been introduced in Linux 5.17 to decorate the anonymous
memory areas shown in /proc/<pid>/maps.

This is already used by glibc. See:
* https://sourceware.org/git/?p=glibc.git;a=blob;f=malloc/malloc.c;h=27dfd1eb907f4615b70c70237c42c552bb4f26a8;hb=HEAD#l2434
* https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/setvmaname.c;h=ea93a5ffbebc9e5a7e32a297138f465724b4725f;hb=HEAD#l63

This can be useful when investigating the memory consumption of a
multi-language program.
On a 100% Go program, pprof profiler can be used to profile the memory
consumption of the program. But pprof is only aware of what happens
within the Go world.

On a multi-language program, there could be a doubt about whether the
suspicious extra-memory consumption comes from the Go part or the native
part.

With this change, the following Go program:

        package main

        import (
                "fmt"
                "log"
                "os"
        )

        /*
        #include <stdlib.h>

        void f(void)
        {
          (void)malloc(1024*1024*1024);
        }
        */
        import "C"

        func main() {
                C.f()

                data, err := os.ReadFile("/proc/self/maps")
                if err != nil {
                        log.Fatal(err)
                }
                fmt.Println(string(data))
        }

produces this output:

        $ GLIBC_TUNABLES=glibc.mem.decorate_maps=1 ~/doc/devel/open-source/go/bin/go run .
        00400000-00402000 r--p 00000000 00:21 28451768                           /home/lenaic/.cache/go-build/9f/9f25a17baed5a80d03eb080a2ce2a5ff49c17f9a56e28330f0474a2bb74a30a0-d/test_vma_name
        00402000-004a4000 r-xp 00002000 00:21 28451768                           /home/lenaic/.cache/go-build/9f/9f25a17baed5a80d03eb080a2ce2a5ff49c17f9a56e28330f0474a2bb74a30a0-d/test_vma_name
        004a4000-00574000 r--p 000a4000 00:21 28451768                           /home/lenaic/.cache/go-build/9f/9f25a17baed5a80d03eb080a2ce2a5ff49c17f9a56e28330f0474a2bb74a30a0-d/test_vma_name
        00574000-00575000 r--p 00173000 00:21 28451768                           /home/lenaic/.cache/go-build/9f/9f25a17baed5a80d03eb080a2ce2a5ff49c17f9a56e28330f0474a2bb74a30a0-d/test_vma_name
        00575000-00580000 rw-p 00174000 00:21 28451768                           /home/lenaic/.cache/go-build/9f/9f25a17baed5a80d03eb080a2ce2a5ff49c17f9a56e28330f0474a2bb74a30a0-d/test_vma_name
        00580000-005a4000 rw-p 00000000 00:00 0
        2e075000-2e096000 rw-p 00000000 00:00 0                                  [heap]
        c000000000-c000400000 rw-p 00000000 00:00 0                              [anon: Go: heap]
        c000400000-c004000000 ---p 00000000 00:00 0                              [anon: Go: heap reservation]
        777f40000000-777f40021000 rw-p 00000000 00:00 0                          [anon: glibc: malloc arena]
        777f40021000-777f44000000 ---p 00000000 00:00 0
        777f44000000-777f44021000 rw-p 00000000 00:00 0                          [anon: glibc: malloc arena]
        777f44021000-777f48000000 ---p 00000000 00:00 0
        777f48000000-777f48021000 rw-p 00000000 00:00 0                          [anon: glibc: malloc arena]
        777f48021000-777f4c000000 ---p 00000000 00:00 0
        777f4c000000-777f4c021000 rw-p 00000000 00:00 0                          [anon: glibc: malloc arena]
        777f4c021000-777f50000000 ---p 00000000 00:00 0
        777f50000000-777f50021000 rw-p 00000000 00:00 0                          [anon: glibc: malloc arena]
        777f50021000-777f54000000 ---p 00000000 00:00 0
        777f55afb000-777f55afc000 ---p 00000000 00:00 0
        777f55afc000-777f562fc000 rw-p 00000000 00:00 0                          [anon: glibc: pthread stack: 216378]
        777f562fc000-777f562fd000 ---p 00000000 00:00 0
        777f562fd000-777f56afd000 rw-p 00000000 00:00 0                          [anon: glibc: pthread stack: 216377]
        777f56afd000-777f56afe000 ---p 00000000 00:00 0
        777f56afe000-777f572fe000 rw-p 00000000 00:00 0                          [anon: glibc: pthread stack: 216376]
        777f572fe000-777f572ff000 ---p 00000000 00:00 0
        777f572ff000-777f57aff000 rw-p 00000000 00:00 0                          [anon: glibc: pthread stack: 216375]
        777f57aff000-777f57b00000 ---p 00000000 00:00 0
        777f57b00000-777f58300000 rw-p 00000000 00:00 0                          [anon: glibc: pthread stack: 216374]
        777f58300000-777f58400000 rw-p 00000000 00:00 0                          [anon: Go: page alloc index]
        777f58400000-777f5a400000 rw-p 00000000 00:00 0                          [anon: Go: heap index]
        777f5a400000-777f6a580000 ---p 00000000 00:00 0                          [anon: Go: scavenge index]
        777f6a580000-777f6a581000 rw-p 00000000 00:00 0                          [anon: Go: scavenge index]
        777f6a581000-777f7a400000 ---p 00000000 00:00 0                          [anon: Go: scavenge index]
        777f7a400000-777f8a580000 ---p 00000000 00:00 0                          [anon: Go: page summary]
        777f8a580000-777f8a581000 rw-p 00000000 00:00 0                          [anon: Go: page alloc]
        777f8a581000-777f9c430000 ---p 00000000 00:00 0                          [anon: Go: page summary]
        777f9c430000-777f9c431000 rw-p 00000000 00:00 0                          [anon: Go: page alloc]
        777f9c431000-777f9e806000 ---p 00000000 00:00 0                          [anon: Go: page summary]
        777f9e806000-777f9e807000 rw-p 00000000 00:00 0                          [anon: Go: page alloc]
        777f9e807000-777f9ec00000 ---p 00000000 00:00 0                          [anon: Go: page summary]
        777f9ec36000-777f9ecb6000 rw-p 00000000 00:00 0                          [anon: Go: immortal metadata]
        777f9ecb6000-777f9ecc6000 rw-p 00000000 00:00 0                          [anon: Go: gc bits]
        777f9ecc6000-777f9ecd6000 rw-p 00000000 00:00 0                          [anon: Go: allspans array]
        777f9ecd6000-777f9ece7000 rw-p 00000000 00:00 0                          [anon: Go: immortal metadata]
        777f9ece7000-777f9ed67000 ---p 00000000 00:00 0                          [anon: Go: page summary]
        777f9ed67000-777f9ed68000 rw-p 00000000 00:00 0                          [anon: Go: page alloc]
        777f9ed68000-777f9ede7000 ---p 00000000 00:00 0                          [anon: Go: page summary]
        777f9ede7000-777f9ee07000 rw-p 00000000 00:00 0                          [anon: Go: page alloc]
        777f9ee07000-777f9ee0a000 rw-p 00000000 00:00 0                          [anon: glibc: loader malloc]
        777f9ee0a000-777f9ee2e000 r--p 00000000 00:21 48158213                   /usr/lib/libc.so.6
        777f9ee2e000-777f9ef9f000 r-xp 00024000 00:21 48158213                   /usr/lib/libc.so.6
        777f9ef9f000-777f9efee000 r--p 00195000 00:21 48158213                   /usr/lib/libc.so.6
        777f9efee000-777f9eff2000 r--p 001e3000 00:21 48158213                   /usr/lib/libc.so.6
        777f9eff2000-777f9eff4000 rw-p 001e7000 00:21 48158213                   /usr/lib/libc.so.6
        777f9eff4000-777f9effc000 rw-p 00000000 00:00 0
        777f9effc000-777f9effe000 rw-p 00000000 00:00 0                          [anon: glibc: loader malloc]
        777f9f00a000-777f9f04a000 rw-p 00000000 00:00 0                          [anon: Go: immortal metadata]
        777f9f04a000-777f9f04c000 r--p 00000000 00:00 0                          [vvar]
        777f9f04c000-777f9f04e000 r--p 00000000 00:00 0                          [vvar_vclock]
        777f9f04e000-777f9f050000 r-xp 00000000 00:00 0                          [vdso]
        777f9f050000-777f9f051000 r--p 00000000 00:21 48158204                   /usr/lib/ld-linux-x86-64.so.2
        777f9f051000-777f9f07a000 r-xp 00001000 00:21 48158204                   /usr/lib/ld-linux-x86-64.so.2
        777f9f07a000-777f9f085000 r--p 0002a000 00:21 48158204                   /usr/lib/ld-linux-x86-64.so.2
        777f9f085000-777f9f087000 r--p 00034000 00:21 48158204                   /usr/lib/ld-linux-x86-64.so.2
        777f9f087000-777f9f088000 rw-p 00036000 00:21 48158204                   /usr/lib/ld-linux-x86-64.so.2
        777f9f088000-777f9f089000 rw-p 00000000 00:00 0
        7ffc7bfa7000-7ffc7bfc8000 rw-p 00000000 00:00 0                          [stack]
        ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0                  [vsyscall]

The anonymous memory areas are now labelled so that we can see which
ones have been allocated by the Go runtime versus which ones have been
allocated by the glibc.

Fixes #71546

Change-Id: I304e8b4dd7f2477a6da794fd44e9a7a5354e4bf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/646095
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-04 11:22:33 -08:00
Ian Lance Taylor
f95941de49 net/http/httputil: skip new test on Plan 9
TestReverseProxyWebSocketHalfTCP requires half closed connections,
which aren't supported on Plan 9.

For #35892
Fixes #72095

Change-Id: I64b458bc15ac3b8eda43dc871bf67ada32a59708
Reviewed-on: https://go-review.googlesource.com/c/go/+/654636
Reviewed-by: Ian Lance Taylor <iant@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: Damien Neil <dneil@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-03-04 10:31:25 -08:00
Brad Fitzpatrick
ba3c57fc7c os: guarantee min buffer size for ReadFile reads on /proc-like files
For instance, this fixes os.ReadFile on plan9's /net/iproute file.

But it's not necessarily plan9-specific; Linux /proc and /sys filesystems
can exhibit the same problems.

Fixes #72080

Change-Id: I60b035913f583a91c6d84df95a6ea7b7ec2b3c92
Reviewed-on: https://go-review.googlesource.com/c/go/+/654315
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-04 08:58:31 -08:00
Julien Cretel
fd8938c799 net/http: speed up cookie and method validation
Fixes #67031

Change-Id: I1d764afdc7e50d61007f5f71a674eb6872ce507a
GitHub-Last-Rev: 869535e843d2133fa5279297b002dd96725384e0
GitHub-Pull-Request: golang/go#71798
Reviewed-on: https://go-review.googlesource.com/c/go/+/650195
Auto-Submit: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-03-04 05:02:52 -08:00
Simon Ser
32fdcd7ca5 mime/quotedprintable: accept LWSP-char after =
SP and HTAB are allowed after a = before the following CRLF.

RFC 2045 section 6.7 describes the ABNF for the quoted-printable encoding:

    qp-line := *(qp-segment transport-padding CRLF)
               qp-part transport-padding
    qp-segment := qp-section *(SPACE / TAB) "="
    transport-padding := *LWSP-char
                          ; Composers MUST NOT generate
                          ; non-zero length transport
                          ; padding, but receivers MUST
                          ; be able to handle padding
                          ; added by message transports.

RFC 822 defines LWSP-char as:

    LWSP-char   =  SPACE / HTAB

Dovecot's imaptest contains such a message in
src/tests/fetch-binary-mime-qp.mbox.

Fixes #70952

Change-Id: Ie05921088d7e4d6c92c4bf79b0f4a13586230753
GitHub-Last-Rev: e6e6eee8ebc2f629644a1d99129fb57cce58058f
GitHub-Pull-Request: golang/go#70951
Reviewed-on: https://go-review.googlesource.com/c/go/+/638276
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
2025-03-04 05:00:10 -08:00
Mark Wakefield
a053e79024 net/http: support TCP half-close when HTTP is upgraded in ReverseProxy
This CL propagates closing the write stream from either side of the
reverse proxy and ensures the proxy waits for both copy-to and the
copy-from the backend to complete.

The new unit test checks communication through the reverse proxy when
the backend or frontend closes either the read or write streams.
That closing the write stream is propagated through the proxy from
either the backend or the frontend. That closing the read stream is
not propagated through the proxy.

Fixes #35892

Change-Id: I83ce377df66a0f17b9ba2b53caf9e4991a95f6a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/637939
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Matej Kramny <matejkramny@gmail.com>
2025-03-04 04:59:32 -08:00
wineandchord
7181118a85 net/http: check server shutting down before processing the request
The root cause of issue #65802 is a small race condition that occurs between
two events:

1. During the HTTP server shutdown, a connection in an idle state is identified
and closed.
2. The connection, although idle, has just finished reading a complete request
before being closed and hasn't yet updated its state to active.

In this scenario, despite the connection being closed, the request continues to
be processed. This not only wastes server resources but also prevents the
client request from being retried.

Fixes #65802

Change-Id: Ic22abb4497be04f6c84dff059df00f2c319d8652
GitHub-Last-Rev: 426099a3e75f51b80f8ca866938f31417d75ff89
GitHub-Pull-Request: golang/go#65805
Reviewed-on: https://go-review.googlesource.com/c/go/+/565277
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
2025-03-04 04:56:10 -08:00
Than McIntosh
bef2bb80a9 cmd/compile,cmd/link: move to DWARF5-style location lists
This patch updates the compiler to generate DWARF5-style location
lists (e.g. entries that feed into .debug_loclists) as opposed to
DWARF4-style location lists (which wind up in .debug_loc). The DWARF5
format is much more compact, and can make indirect references to text
addresses via the .debug_addr section for further space savings.

Updates #26379.

Change-Id: If2e6fce1136d9cba5125ea51a71419596d1d1691
Reviewed-on: https://go-review.googlesource.com/c/go/+/635836
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-04 04:48:53 -08:00
Than McIntosh
4c0a47a8ff cmd/compile,cmd/link: move to DWARF5-style range lists
This patch updates the compiler to generate DWARF5-style range lists
(e.g. entries that feed into .debug_rnglists) as opposed to
DWARF4-style range lists (which wind up in .debug_ranges). The DWARF5
format is much more compact, and can make indirect references to text
address via the .debug_addr section for further space savings.

Updates #26379.

Change-Id: I273a6283484b7fe33d79d5412e31c5155b22a7c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/635345
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2025-03-04 04:48:46 -08:00
Cuong Manh Le
4f45b2b7e0 cmd/compile: fix out of memory when inlining closure
CL 629195 strongly favor closure inlining, allowing closures to be
inlined more aggressively.

However, if the closure body contains a call to a function, which itself
is one of the call arguments, it causes the infinite inlining.

Fixing this by prevent this kind of functions from being inlinable.

Fixes #72063

Change-Id: I5fb5723a819b1e2c5aadb57c1023ec84ca9fa53c
Reviewed-on: https://go-review.googlesource.com/c/go/+/654195
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-04 03:10:17 -08:00
Egon Elbre
82791889cc crypto/internal/fips140/bigmod/_asm: update avo to v0.6.0
avo v0.4.0 x/tools dependency crashes while parsing with Go 1.25.

Change-Id: Ic951066b0b39b477887ad0e32be44f4d88d4c2f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/653175
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-04 03:02:05 -08:00
Sean Liao
3b9d10cce7 net/textproto: document enforcement of RFC 9112 for headers
Fixes #68590

Change-Id: Ie7cf1fe8379182f86317d5ebb7f45a404ecd70e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/601555
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-03 22:12:55 -08:00
Xiaolin Zhao
2ce1fb4220 cmd/internal/obj/loong64: add F{MAXA/MINA}.{S/D} instructions
Go asm syntax:
	F{MAXA/MINA}{F/D}	FK, FJ, FD

Equivalent platform assembler syntax:
	f{maxa/mina}.{s/d}	fd, fj, fk

Ref: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Change-Id: I6790657d2f36bdf5e6818b6c0aaa48117e782b8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/653915
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-03-03 17:01:33 -08:00
Xiaolin Zhao
47fd73a51c cmd/internal/obj/loong64: add {V,XV}{SLL/SRL/SRA/ROTR}[I].{B/H/W/D} instructions support
Go asm syntax:
	 V{SLL/SRL/SRA/ROTR}{B/H/W/V}	$1, V2, V3
	XV{SLL/SRL/SRA/ROTR}{B/H/W/V}	$1, X2, X3
	 V{SLL/SRL/SRA/ROTR}{B/H/W/V}	VK, VJ, VD
	XV{SLL/SRL/SRA/ROTR}{B/H/W/V}	XK, XJ, XD

Equivalent platform assembler syntax:
	 v{sll/srl/sra/rotr}i.{b/h/w/d}	v3, v2, $1
	xv{sll/srl/sra/rotr}i.{b/h/w/d}	x3, x2, $1
	 v{sll/srl/sra/rotr}.{b/h/w/d}	vd, vj, vk
	xv{sll/srl/sra/rotr}.{b/h/w/d}	xd, xj, xk

Change-Id: Ie4f04de1c77491a71688d226f7d91cd1a699ab47
Reviewed-on: https://go-review.googlesource.com/c/go/+/637775
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-03-03 17:00:29 -08:00
Robert Griesemer
7e81bcf39f go/types, types2: remove remaining mentions of core type in error messages
The implementatiom still calls coreType in places and refers to
"core types" in comments, but user-visible error messages don't
know about core types anymore.

This brings the user-visible part of the implementation in sync with
the spec which doesn't have the notion of core types anymore.

For #70128.

Change-Id: I14bc6767a83e8f54b10ebe99a7df0b98cd9fca87
Reviewed-on: https://go-review.googlesource.com/c/go/+/654395
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-03-03 13:41:04 -08:00
Damien Neil
0a0e6af39b context: use atomic operation in ctx.Err
oos: darwin
goarch: arm64
pkg: context
cpu: Apple M1 Pro
               │ /tmp/bench.0.mac │          /tmp/bench.1.mac           │
               │      sec/op      │   sec/op     vs base                │
ErrOK-10             13.750n ± 1%   2.080n ± 0%  -84.87% (p=0.000 n=10)
ErrCanceled-10       13.530n ± 1%   3.248n ± 1%  -76.00% (p=0.000 n=10)
geomean               13.64n        2.599n       -80.94%

goos: linux
goarch: amd64
pkg: context
cpu: Intel(R) Xeon(R) CPU @ 2.30GHz
               │ /tmp/bench.0.linux │         /tmp/bench.1.linux          │
               │       sec/op       │   sec/op     vs base                │
ErrOK-16               21.435n ± 0%   4.243n ± 0%  -80.21% (p=0.000 n=10)
ErrCanceled-16         21.445n ± 0%   5.070n ± 0%  -76.36% (p=0.000 n=10)
geomean                 21.44n        4.638n       -78.37%

Fixes #72040

Change-Id: I3b337ab1934689d2da4134492ee7c5aac8f92845
Reviewed-on: https://go-review.googlesource.com/c/go/+/653795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-03-03 12:32:57 -08:00
qmuntal
14647b0ac8 os: only call GetConsoleMode for char devices
There is no need to call GetConsoleMode if we know that the file
type is not FILE_TYPE_CHAR. This is a tiny performance optimization,
as I sometimes see this call in profiles.

Change-Id: I9e9237908585d0ec8360930a0406b26f52699b92
Reviewed-on: https://go-review.googlesource.com/c/go/+/654155
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-03-03 11:33:48 -08:00
Robert Griesemer
05354fc3b4 go/types, types2: remove remaining references to coreType in literals.go
For now, use commonUnder (formerly called sharedUnder) and update
error messages and comments. We can provide better error messages
in individual cases eventually.

For #70128.

Change-Id: I906ba9a0c768f6499c1683dc9be3ad27da8007a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/653156
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2025-03-03 11:26:34 -08:00
Robert Griesemer
26ba61dfad go/types, types2: remove most remaining references to coreType in builtin.go
For now, use commonUnder (formerly called sharedUnder) and update
error messages and comments. We can provide better error messages
in individual cases eventually.

Kepp using coreType for make built-in for now because it must accept
different channel types with non-conflicting directions and identical
element types. Added extra test cases.

While at it, rename sharedUnder, sharedUnderOrChan to commonUnder
and commonUnderOrChan, respectively (per suggestion from rfindley).

For #70128.

Change-Id: I11f3d5ce858746574f4302271d8cb763c2cdcf98
Reviewed-on: https://go-review.googlesource.com/c/go/+/653139
Reviewed-by: Robert Findley <rfindley@google.com>
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>
2025-03-03 11:26:31 -08:00
Filippo Valsorda
19d0b3e81f crypto/rsa: use Div instead of GCD for trial division
Div is way faster. We could actually test a lot more primes and still
gain performance despite the diminishing returns, but necessarily it
would have marginal impact overall.

fips140: off
goos: linux
goarch: amd64
pkg: crypto/rsa
cpu: AMD Ryzen 7 PRO 8700GE w/ Radeon 780M Graphics
                    │  e325b41ad1  │             0f611af2e1              │
                    │    sec/op    │   sec/op     vs base                │
GenerateKey/2048-16   124.19m ± 0%   39.93m ± 0%  -67.85% (p=0.000 n=20)

Surprisingly, the performance gain is similar on ARM64, which doesn't
have intrinsified math.Div.

fips140: off
goos: darwin
goarch: arm64
pkg: crypto/rsa
cpu: Apple M2
                   │  e325b41ad1  │             6276161a7f              │
                   │    sec/op    │   sec/op     vs base                │
GenerateKey/2048-8   136.49m ± 0%   47.97m ± 1%  -64.86% (p=0.000 n=20)

Change-Id: I6a6a46560331198312bd09c1cbe4d2b3c370c552
Reviewed-on: https://go-review.googlesource.com/c/go/+/639955
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
2025-03-03 11:17:41 -08:00
Robert Griesemer
4b1ac7bbfe go/types, types2: remove references to core type in append
Writing explicit code for this case turned out to be simpler
and easier to reason about then relying on a helper functions
(except for typeset).

While at it, make append error messages more consistent.

For #70128.

Change-Id: I3dc79774249929de5061b4301ab2506d4b3da0d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/653095
Reviewed-by: Robert Findley <rfindley@google.com>
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>
2025-03-03 11:07:14 -08:00
Junyang Shao
f48b53f0f6 testing: fix testing.B.Loop doc on loop condition
As mentioned by
https://github.com/golang/go/issues/61515#issuecomment-2656656554,
the documentation should be relaxed.

Change-Id: I9f18301e1a4e4d9a72c9fa0b1132b1ba3cc57b03
Reviewed-on: https://go-review.googlesource.com/c/go/+/651435
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Commit-Queue: Junyang Shao <shaojunyang@google.com>
2025-03-03 10:37:29 -08:00
Brad Fitzpatrick
0312e31ed1 net: fix parsing of interfaces on plan9 without associated devices
Fixes #72060
Updates #39908

Change-Id: I7d5bda1654753acebc8aa9937d010b41c5722b36
Reviewed-on: https://go-review.googlesource.com/c/go/+/654055
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
2025-03-03 08:07:04 -08:00
Jakob Ackermann
bda9f85e5c net/http: allocate CloseNotifier channel lazily
The CloseNotifier interface is deprecated. We can defer allocating the
backing channel until the first use of CloseNotifier.

goos: linux
goarch: amd64
pkg: net/http
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                   │   before    │               after                │
                   │   sec/op    │   sec/op     vs base               │
Server-8             160.8µ ± 2%   160.1µ ± 1%       ~ (p=0.353 n=10)
CloseNotifier/h1-8   222.1µ ± 4%   226.4µ ± 7%       ~ (p=0.143 n=10)
geomean              189.0µ        190.4µ       +0.75%

                   │    before    │                after                │
                   │     B/op     │     B/op      vs base               │
Server-8             2.292Ki ± 0%   2.199Ki ± 0%  -4.07% (p=0.000 n=10)
CloseNotifier/h1-8   3.224Ki ± 0%   3.241Ki ± 0%  +0.51% (p=0.000 n=10)
geomean              2.718Ki        2.669Ki       -1.80%

                   │   before   │                after                │
                   │ allocs/op  │ allocs/op   vs base                 │
Server-8             21.00 ± 0%   20.00 ± 0%  -4.76% (p=0.000 n=10)
CloseNotifier/h1-8   50.00 ± 0%   50.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean              32.40        31.62       -2.41%
¹ all samples are equal

Change-Id: I3f35d56b8356fb660589b7708a023e4480f32067
GitHub-Last-Rev: c75696b9b8498ae03a4ad9527b9b7c8337415456
GitHub-Pull-Request: golang/go#71163
Reviewed-on: https://go-review.googlesource.com/c/go/+/640598
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-03 07:45:07 -08:00
Joel Sing
b199d9766a runtime: add padding to m struct for 64 bit architectures
CL 652276 reduced the m struct by 8 bytes, which has changed the
allocation class on 64 bit OpenBSD platforms. This results in build
failures due to:

    M structure uses sizeclass 1792/0x700 bytes; incompatible with mutex flag mask 0x3ff

Add 128 bytes of padding when spinbitmutex is enabled on 64 bit
architectures, moving the size to the half point between the
1792 and 2048 allocation size.

Change-Id: I71623a1f75714543c302217e619d20cf0e717aeb
Reviewed-on: https://go-review.googlesource.com/c/go/+/653335
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: Keith Randall <khr@golang.org>
2025-03-01 09:22:41 -08:00
Mark Ryan
5a7db813a6 cmd/internal/obj/riscv: add riscv64 CSR map
The map is automatically generated by running the latest version of
parse.py from github.com/riscv/riscv-opcodes.

Change-Id: I05e00ab27ec583750752c25e1835c2578b339fbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/630518
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Pengcheng Wang <wangpengcheng.pp@bytedance.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-03-01 04:59:21 -08:00
qmuntal
f4750a6cfb cmd/go/internal/work: use par.Cache to cache tool IDs.
The tool IDs can be calculated once and reused across multiple
threads. This is a small optimization that helps optimize system
resources.

On a normal Windows machine with 12 virtual CPUs, the time to build
a hello world program is reduced from over 1 second, with spikes of 2
seconds, to a consistent 0.7 seconds.

Updates #71981.

Change-Id: I85f4a19f8ad4230afa32213780c761b7eb22fa29
Reviewed-on: https://go-review.googlesource.com/c/go/+/653715
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-01 00:29:04 -08:00
Xiaolin Zhao
039b3ebeba runtime: use ABIInternal on syscall and other sys.stuff for loong64
Change-Id: I6b2942c413eab58c457980131022dace036cd76c
Reviewed-on: https://go-review.googlesource.com/c/go/+/623475
Reviewed-by: Meidan Li <limeidan@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
2025-02-28 17:10:54 -08:00
limeidan
f24d2e175e cmd/internal/obj, cmd/asm: reclassify 32-bit immediate value of loong64
Change-Id: If9fd257ca0837a8c8597889c4f5ed3d4edc602c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/636995
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-28 17:10:24 -08:00
Michael Matloob
6894904974 cmd/go/internal/modindex: clean modroot and pkgdir for openIndexPackage
GetPackage is sometimes called with a modroot or pkgdir that ends with a
path separator, and sometimes without. Clean them before passing them to
openIndexPackage to deduplicate calls to mcache.Do and action entry
files.

This shouldn't affect #71698 but was discovered while debugging that
issue.

Change-Id: I6a7fa4de93f45801504abea11bd97f6c6577f296
Reviewed-on: https://go-review.googlesource.com/c/go/+/652435
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-28 14:09:39 -08:00
guoguangwu
64feded8af cmd/covdata: close output meta-data file
Change-Id: Idd2a324eb51ffa3f40cb3df03a82a1d6d882295a
GitHub-Last-Rev: 62e22b309d9f4b31b1fb426e4fdbabd04fcc8371
GitHub-Pull-Request: golang/go#71993
Reviewed-on: https://go-review.googlesource.com/c/go/+/653140
Reviewed-by: Than McIntosh <thanm@golang.org>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-02-28 12:43:43 -08:00
qmuntal
2298215f5b cmd/link: use __got as the .got section name
The __nl_symbol_ptr is not a common section name anymore. LLVM prefers
__got for GOT symbols in the __DATA_CONST segment.

Note that the Go linker used to place the GOT section in the __DATA
segment, but since CL 644055 we place it in the __DATA_CONST segment.

Updates #71416.

Cq-Include-Trybots: luci.golang.try:gotip-darwin-amd64-longtest
Change-Id: Icb776e19855eaabb4777a9b1eb433497842413b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/652555
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>
2025-02-28 12:43:36 -08:00
Jes Cok
74ba2164a0 reflect: add more tests for Type.{CanSeq,CanSeq2}
For #71874.

Change-Id: I3850edfb3104305f3bf4847a73cdd826cc99837f
GitHub-Last-Rev: 574c1edb7a6152c71891fab011ac0aaeca955fc8
GitHub-Pull-Request: golang/go#71890
Reviewed-on: https://go-review.googlesource.com/c/go/+/651775
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-28 11:09:39 -08:00
Michael Anthony Knyszek
1dafccaaf3 runtime: increase timeout in TestSpuriousWakeupsNeverHangSemasleep
This change tries increasing the timeout in
TestSpuriousWakeupsNeverHangSemasleep. I'm not entirely sure of the
mechanism, but GODEBUG=gcstoptheworld=2 and GODEBUG=gccheckmark=1 can
cause this test to fail at it's regular timeout. It does not seem to
indicate a deadlock, because bumping the timeout 10x make the problem
go away. I suspect the problem is due to the long STW times these two
modes can induce, plus the fact this test runs in parallel with others.

Let's just bump the timeout. The test is fundamentally sound, and it's
unclear to me how else to test for a deadlock here.

Fixes #71691.
Fixes #71548.

Change-Id: I649531eeec8a8408ba90823ce5223f3a17863124
Reviewed-on: https://go-review.googlesource.com/c/go/+/652756
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-28 10:17:23 -08:00
Filippo Valsorda
6e8d7a113c crypto/x509: avoid crypto/rand.Int to generate serial number
It's probabyl safe enough, but just reading bytes from rand and then
using SetBytes is simpler, and doesn't require allowing calls from
crypto into math/big's Lsh, Sub, and Cmp.

Change-Id: I6a6a4656761f7073f9e149f288c48e97048ab13c
Reviewed-on: https://go-review.googlesource.com/c/go/+/643278
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>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-02-28 08:54:13 -08:00
KangJi
555974734f cmd/cgo: update generated headers for compatibility with latest MSVC C++ standards
Updates #71921

Change-Id: Idfbb72e259b169121c8ced6d89ee2f13d6254d0d
GitHub-Last-Rev: fcf12e5a221621f749841055df1d2c2ada3bf844
GitHub-Pull-Request: golang/go#72004
Reviewed-on: https://go-review.googlesource.com/c/go/+/653141
Reviewed-by: Dmitri Shuralyov <dmitshur@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>
2025-02-28 08:48:12 -08:00
Jes Cok
b3e36364b9 flag: replace interface{} -> any for textValue.Get method
Make it literally match the Getter interface.

Change-Id: I73f03780ba1d3fd2230e0e5e2343d40530d9e6d8
GitHub-Last-Rev: 398b90b2fb04fdd401a1d719bf3ce19152a4cf6a
GitHub-Pull-Request: golang/go#71975
Reviewed-on: https://go-review.googlesource.com/c/go/+/652795
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-28 08:43:46 -08:00
Damien Neil
d31c805535 net/http: reject newlines in chunk-size lines
Unlike request headers, where we are allowed to leniently accept
a bare LF in place of a CRLF, chunked bodies must always use CRLF
line terminators. We were already enforcing this for chunk-data lines;
do so for chunk-size lines as well. Also reject bare CRs anywhere
other than as part of the CRLF terminator.

Fixes CVE-2025-22871
Fixes #71988

Change-Id: Ib0e21af5a8ba28c2a1ca52b72af8e2265ec79e4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/652998
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-27 09:23:42 -08:00
Lin Lin
0135120922 cmd/go: update c document
Fixes: #11875

Change-Id: I0ea2c3e94d7d1647c2aaa3d488ac3c1f5fb6cb18
GitHub-Last-Rev: 7512b33f055aa225d365d6c949a53778834e8dcd
GitHub-Pull-Request: golang/go#71966
Reviewed-on: https://go-review.googlesource.com/c/go/+/652675
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>
Reviewed-by: Michael Matloob <matloob@golang.org>
2025-02-27 07:57:37 -08:00
Russ Cox
2b73707358 math/big: add tests for allocation during multiply
Test that big.Int.Mul reusing the same target is not allocating
temporary garbage during its computation. That code is going
to be modified in an upcoming CL.

Change-Id: I3ed55c06da030282233c29cd7af2a04f395dc7a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/652056
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2025-02-27 06:05:02 -08:00
Russ Cox
0ab2253ce1 math/big: move multiplication to natmul.go
No code changes.

This CL moves the multiplication (and squaring) code into natmul.go,
in preparation for cleaning up Karatsuba and then adding Toom-Cook
and FFT-based multiplication.

Change-Id: I7f84328284cc4e1ca4da0ebb9f666a5535e8d7f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/652055
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-02-27 06:05:00 -08:00
Russ Cox
1f7e28acdf math/big: optimize atoi of base 2, 4, 16
Avoid multiplies when converting base 2, 4, 16 inputs,
reducing conversion time from O(N²) to O(N).

The Base8 and Base10 code paths should be unmodified,
but the base-2,4,16 changes tickle the compiler to generate
better (amd64) or worse (arm64) when really it should not.
This is described in detail in #71868 and should be ignored
for the purposes of this CL.

goos: linux
goarch: amd64
pkg: math/big
cpu: Intel(R) Xeon(R) CPU @ 3.10GHz
                      │     old      │                 new                 │
                      │    sec/op    │   sec/op     vs base                │
Scan/10/Base2-16         324.4n ± 0%   258.7n ± 0%  -20.25% (p=0.000 n=15)
Scan/100/Base2-16        2.376µ ± 0%   1.968µ ± 0%  -17.17% (p=0.000 n=15)
Scan/1000/Base2-16       23.89µ ± 0%   19.16µ ± 0%  -19.80% (p=0.000 n=15)
Scan/10000/Base2-16      311.5µ ± 0%   190.4µ ± 0%  -38.86% (p=0.000 n=15)
Scan/100000/Base2-16    10.508m ± 0%   1.904m ± 0%  -81.88% (p=0.000 n=15)
Scan/10/Base8-16         138.3n ± 0%   127.9n ± 0%   -7.52% (p=0.000 n=15)
Scan/100/Base8-16        886.1n ± 0%   790.2n ± 0%  -10.82% (p=0.000 n=15)
Scan/1000/Base8-16       9.227µ ± 0%   8.234µ ± 0%  -10.76% (p=0.000 n=15)
Scan/10000/Base8-16      165.8µ ± 0%   155.6µ ± 0%   -6.19% (p=0.000 n=15)
Scan/100000/Base8-16     9.044m ± 0%   8.935m ± 0%   -1.20% (p=0.000 n=15)
Scan/10/Base10-16        129.9n ± 0%   120.0n ± 0%   -7.62% (p=0.000 n=15)
Scan/100/Base10-16       816.3n ± 0%   730.0n ± 0%  -10.57% (p=0.000 n=15)
Scan/1000/Base10-16      8.518µ ± 0%   7.628µ ± 0%  -10.45% (p=0.000 n=15)
Scan/10000/Base10-16     158.6µ ± 0%   149.4µ ± 0%   -5.80% (p=0.000 n=15)
Scan/100000/Base10-16    8.962m ± 0%   8.855m ± 0%   -1.20% (p=0.000 n=15)
Scan/10/Base16-16        114.5n ± 0%   108.6n ± 0%   -5.15% (p=0.000 n=15)
Scan/100/Base16-16       648.3n ± 0%   525.0n ± 0%  -19.02% (p=0.000 n=15)
Scan/1000/Base16-16      7.375µ ± 0%   5.636µ ± 0%  -23.58% (p=0.000 n=15)
Scan/10000/Base16-16    171.18µ ± 0%   66.99µ ± 0%  -60.87% (p=0.000 n=15)
Scan/100000/Base16-16   9490.9µ ± 0%   682.8µ ± 0%  -92.81% (p=0.000 n=15)
geomean                  20.11µ        13.69µ       -31.94%

goos: linux
goarch: amd64
pkg: math/big
cpu: Intel(R) Xeon(R) Platinum 8481C CPU @ 2.70GHz
                      │      old      │                 new                 │
                      │    sec/op     │   sec/op     vs base                │
Scan/10/Base2-88          275.4n ± 0%   215.0n ± 0%  -21.93% (p=0.000 n=15)
Scan/100/Base2-88         1.869µ ± 0%   1.629µ ± 0%  -12.84% (p=0.000 n=15)
Scan/1000/Base2-88        18.56µ ± 0%   15.81µ ± 0%  -14.82% (p=0.000 n=15)
Scan/10000/Base2-88       270.0µ ± 0%   157.2µ ± 0%  -41.77% (p=0.000 n=15)
Scan/100000/Base2-88     11.518m ± 0%   1.571m ± 0%  -86.36% (p=0.000 n=15)
Scan/10/Base8-88          108.9n ± 0%   106.0n ± 0%   -2.66% (p=0.000 n=15)
Scan/100/Base8-88         655.2n ± 0%   594.9n ± 0%   -9.20% (p=0.000 n=15)
Scan/1000/Base8-88        6.467µ ± 0%   5.966µ ± 0%   -7.75% (p=0.000 n=15)
Scan/10000/Base8-88       151.2µ ± 0%   147.4µ ± 0%   -2.53% (p=0.000 n=15)
Scan/100000/Base8-88      10.33m ± 0%   10.30m ± 0%   -0.25% (p=0.000 n=15)
Scan/10/Base10-88        100.20n ± 0%   98.53n ± 0%   -1.67% (p=0.000 n=15)
Scan/100/Base10-88        596.9n ± 0%   543.3n ± 0%   -8.98% (p=0.000 n=15)
Scan/1000/Base10-88       5.904µ ± 0%   5.485µ ± 0%   -7.10% (p=0.000 n=15)
Scan/10000/Base10-88      145.7µ ± 0%   142.0µ ± 0%   -2.55% (p=0.000 n=15)
Scan/100000/Base10-88     10.26m ± 0%   10.24m ± 0%   -0.18% (p=0.000 n=15)
Scan/10/Base16-88         90.33n ± 0%   87.60n ± 0%   -3.02% (p=0.000 n=15)
Scan/100/Base16-88        506.4n ± 0%   437.7n ± 0%  -13.57% (p=0.000 n=15)
Scan/1000/Base16-88       5.056µ ± 0%   4.007µ ± 0%  -20.75% (p=0.000 n=15)
Scan/10000/Base16-88     163.35µ ± 0%   65.37µ ± 0%  -59.98% (p=0.000 n=15)
Scan/100000/Base16-88   11027.2µ ± 0%   735.1µ ± 0%  -93.33% (p=0.000 n=15)
geomean                   17.13µ        11.74µ       -31.46%

goos: linux
goarch: arm64
pkg: math/big
                      │     old      │                 new                  │
                      │    sec/op    │    sec/op     vs base                │
Scan/10/Base2-16         324.7n ± 0%    348.4n ± 0%   +7.30% (p=0.000 n=15)
Scan/100/Base2-16        2.604µ ± 0%    3.031µ ± 0%  +16.40% (p=0.000 n=15)
Scan/1000/Base2-16       26.15µ ± 0%    29.94µ ± 0%  +14.52% (p=0.000 n=15)
Scan/10000/Base2-16      334.3µ ± 0%    298.8µ ± 0%  -10.64% (p=0.000 n=15)
Scan/100000/Base2-16    10.664m ± 0%    2.991m ± 0%  -71.95% (p=0.000 n=15)
Scan/10/Base8-16         144.4n ± 1%    162.2n ± 1%  +12.33% (p=0.000 n=15)
Scan/100/Base8-16        917.2n ± 0%   1084.0n ± 0%  +18.19% (p=0.000 n=15)
Scan/1000/Base8-16       9.367µ ± 0%   10.901µ ± 0%  +16.38% (p=0.000 n=15)
Scan/10000/Base8-16      164.2µ ± 0%    181.2µ ± 0%  +10.34% (p=0.000 n=15)
Scan/100000/Base8-16     8.871m ± 1%    9.140m ± 0%   +3.04% (p=0.000 n=15)
Scan/10/Base10-16        134.6n ± 1%    148.3n ± 1%  +10.18% (p=0.000 n=15)
Scan/100/Base10-16       837.1n ± 0%    986.6n ± 0%  +17.86% (p=0.000 n=15)
Scan/1000/Base10-16      8.563µ ± 0%    9.936µ ± 0%  +16.03% (p=0.000 n=15)
Scan/10000/Base10-16     156.5µ ± 1%    171.3µ ± 0%   +9.41% (p=0.000 n=15)
Scan/100000/Base10-16    8.863m ± 1%    9.011m ± 0%   +1.66% (p=0.000 n=15)
Scan/10/Base16-16        115.7n ± 2%    129.1n ± 1%  +11.58% (p=0.000 n=15)
Scan/100/Base16-16       708.6n ± 0%    796.8n ± 0%  +12.45% (p=0.000 n=15)
Scan/1000/Base16-16      7.314µ ± 0%    7.554µ ± 0%   +3.28% (p=0.000 n=15)
Scan/10000/Base16-16    149.05µ ± 0%    74.60µ ± 0%  -49.95% (p=0.000 n=15)
Scan/100000/Base16-16   9091.6µ ± 0%    741.5µ ± 0%  -91.84% (p=0.000 n=15)
geomean                  20.39µ         17.65µ       -13.44%

goos: darwin
goarch: arm64
pkg: math/big
cpu: Apple M3 Pro
                      │     old      │                 new                 │
                      │    sec/op    │   sec/op     vs base                │
Scan/10/Base2-12         193.8n ± 2%   157.3n ± 1%  -18.83% (p=0.000 n=15)
Scan/100/Base2-12        1.445µ ± 2%   1.362µ ± 1%   -5.74% (p=0.000 n=15)
Scan/1000/Base2-12       14.28µ ± 0%   13.51µ ± 0%   -5.42% (p=0.000 n=15)
Scan/10000/Base2-12      177.1µ ± 0%   134.6µ ± 0%  -24.04% (p=0.000 n=15)
Scan/100000/Base2-12     5.429m ± 1%   1.333m ± 0%  -75.45% (p=0.000 n=15)
Scan/10/Base8-12         75.52n ± 2%   76.09n ± 1%        ~ (p=0.010 n=15)
Scan/100/Base8-12        528.4n ± 1%   532.1n ± 1%        ~ (p=0.003 n=15)
Scan/1000/Base8-12       5.423µ ± 1%   5.427µ ± 0%        ~ (p=0.183 n=15)
Scan/10000/Base8-12      89.26µ ± 1%   89.37µ ± 0%        ~ (p=0.237 n=15)
Scan/100000/Base8-12     4.543m ± 2%   4.560m ± 1%        ~ (p=0.595 n=15)
Scan/10/Base10-12        69.87n ± 1%   70.51n ± 0%        ~ (p=0.002 n=15)
Scan/100/Base10-12       488.4n ± 1%   491.2n ± 0%        ~ (p=0.060 n=15)
Scan/1000/Base10-12      5.014µ ± 1%   5.008µ ± 0%        ~ (p=0.783 n=15)
Scan/10000/Base10-12     84.90µ ± 0%   85.10µ ± 0%        ~ (p=0.109 n=15)
Scan/100000/Base10-12    4.516m ± 1%   4.521m ± 1%        ~ (p=0.713 n=15)
Scan/10/Base16-12        59.21n ± 1%   57.70n ± 1%   -2.55% (p=0.000 n=15)
Scan/100/Base16-12       380.0n ± 1%   360.7n ± 1%   -5.08% (p=0.000 n=15)
Scan/1000/Base16-12      3.775µ ± 0%   3.421µ ± 0%   -9.38% (p=0.000 n=15)
Scan/10000/Base16-12     80.62µ ± 0%   34.44µ ± 1%  -57.28% (p=0.000 n=15)
Scan/100000/Base16-12   4826.4µ ± 2%   450.9µ ± 2%  -90.66% (p=0.000 n=15)
geomean                  11.05µ        8.448µ       -23.52%

Change-Id: Ifdb2049545f34072aa75cdbb72bed4cf465f0ad7
Reviewed-on: https://go-review.googlesource.com/c/go/+/650640
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-02-27 06:04:57 -08:00
Russ Cox
f8f08bfd7c math/big: improve scan test and benchmark
Add a few more test cases for scanning (integer conversion),
which were helpful in debugging some upcoming changes.

BenchmarkScan currently times converting the value 10**N
represented in base B back into []Word form.
When B = 10, the text is 1 followed by many zeros, which
could hit a "multiply by zero" special case when processing
many digit chunks, misrepresenting the actual time required
depending on whether that case is optimized.

Change the benchmark to use 9**N, which is about as big and
will not cause runs of zeros in any of the tested bases.

The benchmark comparison below is not showing faster code,
since of course the code is not changing at all here. Instead,
it is showing that the new benchmark work is roughly the same
size as the old benchmark work.

goos: darwin
goarch: arm64
pkg: math/big
cpu: Apple M3 Pro
                      │     old     │                new                 │
                      │   sec/op    │   sec/op     vs base               │
ScanPi-12               43.35µ ± 1%   43.59µ ± 1%       ~ (p=0.069 n=15)
Scan/10/Base2-12        202.3n ± 2%   193.7n ± 1%  -4.25% (p=0.000 n=15)
Scan/100/Base2-12       1.512µ ± 3%   1.447µ ± 1%  -4.30% (p=0.000 n=15)
Scan/1000/Base2-12      15.06µ ± 2%   14.33µ ± 0%  -4.83% (p=0.000 n=15)
Scan/10000/Base2-12     188.0µ ± 5%   177.3µ ± 1%  -5.65% (p=0.000 n=15)
Scan/100000/Base2-12    5.814m ± 3%   5.382m ± 1%  -7.43% (p=0.000 n=15)
Scan/10/Base8-12        78.57n ± 2%   75.02n ± 1%  -4.52% (p=0.000 n=15)
Scan/100/Base8-12       548.2n ± 2%   526.8n ± 1%  -3.90% (p=0.000 n=15)
Scan/1000/Base8-12      5.674µ ± 2%   5.421µ ± 0%  -4.46% (p=0.000 n=15)
Scan/10000/Base8-12     94.42µ ± 1%   88.61µ ± 1%  -6.15% (p=0.000 n=15)
Scan/100000/Base8-12    4.906m ± 2%   4.498m ± 3%  -8.31% (p=0.000 n=15)
Scan/10/Base10-12       73.42n ± 1%   69.56n ± 0%  -5.26% (p=0.000 n=15)
Scan/100/Base10-12      511.9n ± 1%   488.2n ± 0%  -4.63% (p=0.000 n=15)
Scan/1000/Base10-12     5.254µ ± 2%   5.009µ ± 0%  -4.66% (p=0.000 n=15)
Scan/10000/Base10-12    90.22µ ± 2%   84.52µ ± 0%  -6.32% (p=0.000 n=15)
Scan/100000/Base10-12   4.842m ± 3%   4.471m ± 3%  -7.65% (p=0.000 n=15)
Scan/10/Base16-12       62.28n ± 1%   58.70n ± 1%  -5.75% (p=0.000 n=15)
Scan/100/Base16-12      398.6n ± 0%   377.9n ± 1%  -5.19% (p=0.000 n=15)
Scan/1000/Base16-12     4.108µ ± 1%   3.782µ ± 0%  -7.94% (p=0.000 n=15)
Scan/10000/Base16-12    83.78µ ± 2%   80.51µ ± 1%  -3.90% (p=0.000 n=15)
Scan/100000/Base16-12   5.080m ± 3%   4.698m ± 3%  -7.53% (p=0.000 n=15)
geomean                 12.41µ        11.74µ       -5.36%

Change-Id: If3ce290ecc7f38672f11b42fd811afb53dee665d
Reviewed-on: https://go-review.googlesource.com/c/go/+/650639
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2025-02-27 05:58:49 -08:00
Russ Cox
872496da2b math/big: replace nat pool with Word stack
In the early days of math/big, algorithms that needed more space
grew the result larger than it needed to be and then used the
high words as extra space. This made results their own temporary
space caches, at the cost that saving a result in a data structure
might hold significantly more memory than necessary.
Specifically, new(big.Int).Mul(x, y) returned a big.Int with a
backing slice 3X as big as it strictly needed to be.
If you are storing many multiplication results, or even a single
large result, the 3X overhead can add up.

This approach to storage for temporaries also requires being able
to analyze the algorithms to predict the exact amount they need,
which can be difficult.

For both these reasons, the implementation of recursive long division,
which came later, introduced a “nat pool” where temporaries could be
stored and reused, or reclaimed by the GC when no longer used.
This avoids the storage and bookkeeping overheads but introduces a
per-temporary sync.Pool overhead. divRecursiveStep takes an array
of cached temporaries to remove some of that overhead.
The nat pool was better but is still not quite right.

This CL introduces something even better than the nat pool
(still probably not quite right, but the best I can see for now):
a sync.Pool holding stacks for allocating temporaries.
Now an operation can get one stack out of the pool and then
allocate as many temporaries as it needs during the operation,
eventually returning the stack back to the pool. The sync.Pool
operations are now per-exported-operation (like big.Int.Mul),
not per-temporary.

This CL converts both the pre-allocation in nat.mul and the
uses of the nat pool to use stack pools instead. This simplifies
some code and sets us up better for more complex algorithms
(such as Toom-Cook or FFT-based multiplication) that need
more temporaries. It is also a little bit faster.

goos: linux
goarch: amd64
pkg: math/big
cpu: Intel(R) Xeon(R) CPU @ 3.10GHz
                         │     old     │                 new                 │
                         │   sec/op    │   sec/op     vs base                │
Div/20/10-16               23.68n ± 0%   22.21n ± 0%   -6.21% (p=0.000 n=15)
Div/40/20-16               23.68n ± 0%   22.21n ± 0%   -6.21% (p=0.000 n=15)
Div/100/50-16              56.65n ± 0%   55.53n ± 0%   -1.98% (p=0.000 n=15)
Div/200/100-16             194.6n ± 1%   172.8n ± 0%  -11.20% (p=0.000 n=15)
Div/400/200-16             232.1n ± 0%   206.7n ± 0%  -10.94% (p=0.000 n=15)
Div/1000/500-16            405.3n ± 1%   383.8n ± 0%   -5.30% (p=0.000 n=15)
Div/2000/1000-16           810.4n ± 1%   795.2n ± 0%   -1.88% (p=0.000 n=15)
Div/20000/10000-16         25.88µ ± 0%   25.39µ ± 0%   -1.89% (p=0.000 n=15)
Div/200000/100000-16       931.5µ ± 0%   924.3µ ± 0%   -0.77% (p=0.000 n=15)
Div/2000000/1000000-16     37.77m ± 0%   37.75m ± 0%        ~ (p=0.098 n=15)
Div/20000000/10000000-16    1.367 ± 0%    1.377 ± 0%   +0.72% (p=0.003 n=15)
NatMul/10-16               168.5n ± 3%   164.0n ± 4%        ~ (p=0.751 n=15)
NatMul/100-16              6.086µ ± 3%   5.380µ ± 3%  -11.60% (p=0.000 n=15)
NatMul/1000-16             238.1µ ± 3%   228.3µ ± 1%   -4.12% (p=0.000 n=15)
NatMul/10000-16            8.721m ± 2%   8.518m ± 1%   -2.33% (p=0.000 n=15)
NatMul/100000-16           369.6m ± 0%   371.1m ± 0%   +0.42% (p=0.000 n=15)
geomean                    19.57µ        18.74µ        -4.21%

                 │     old      │                  new                   │
                 │     B/op     │     B/op      vs base                  │
NatMul/10-16         192.0 ± 0%     192.0 ± 0%        ~ (p=1.000 n=15) ¹
NatMul/100-16      4.750Ki ± 0%   1.751Ki ± 0%  -63.14% (p=0.000 n=15)
NatMul/1000-16     48.16Ki ± 0%   16.02Ki ± 0%  -66.73% (p=0.000 n=15)
NatMul/10000-16    482.9Ki ± 1%   165.4Ki ± 3%  -65.75% (p=0.000 n=15)
NatMul/100000-16   5.747Mi ± 7%   4.197Mi ± 0%  -26.97% (p=0.000 n=15)
geomean            41.42Ki        20.63Ki       -50.18%
¹ all samples are equal

                 │     old     │                 new                  │
                 │  allocs/op  │  allocs/op   vs base                 │
NatMul/10-16       1.000 ±  0%   1.000 ±  0%       ~ (p=1.000 n=15) ¹
NatMul/100-16      1.000 ±  0%   1.000 ±  0%       ~ (p=1.000 n=15) ¹
NatMul/1000-16     1.000 ±  0%   1.000 ±  0%       ~ (p=1.000 n=15) ¹
NatMul/10000-16    1.000 ±  0%   1.000 ±  0%       ~ (p=1.000 n=15) ¹
NatMul/100000-16   7.000 ± 14%   7.000 ± 14%       ~ (p=0.668 n=15)
geomean            1.476         1.476        +0.00%
¹ all samples are equal

goos: linux
goarch: amd64
pkg: math/big
cpu: Intel(R) Xeon(R) Platinum 8481C CPU @ 2.70GHz
                         │     old     │                 new                 │
                         │   sec/op    │   sec/op     vs base                │
Div/20/10-88               15.84n ± 1%   13.12n ± 0%  -17.17% (p=0.000 n=15)
Div/40/20-88               15.88n ± 1%   13.12n ± 0%  -17.38% (p=0.000 n=15)
Div/100/50-88              26.42n ± 0%   25.47n ± 0%   -3.60% (p=0.000 n=15)
Div/200/100-88             132.4n ± 0%   114.9n ± 0%  -13.22% (p=0.000 n=15)
Div/400/200-88             150.1n ± 0%   135.6n ± 0%   -9.66% (p=0.000 n=15)
Div/1000/500-88            275.5n ± 0%   264.1n ± 0%   -4.14% (p=0.000 n=15)
Div/2000/1000-88           586.5n ± 0%   581.1n ± 0%   -0.92% (p=0.000 n=15)
Div/20000/10000-88         25.87µ ± 0%   25.72µ ± 0%   -0.59% (p=0.000 n=15)
Div/200000/100000-88       772.2µ ± 0%   779.0µ ± 0%   +0.88% (p=0.000 n=15)
Div/2000000/1000000-88     33.36m ± 0%   33.63m ± 0%   +0.80% (p=0.000 n=15)
Div/20000000/10000000-88    1.307 ± 0%    1.320 ± 0%   +1.03% (p=0.000 n=15)
NatMul/10-88               140.4n ± 0%   148.8n ± 4%   +5.98% (p=0.000 n=15)
NatMul/100-88              4.663µ ± 1%   4.388µ ± 1%   -5.90% (p=0.000 n=15)
NatMul/1000-88             207.7µ ± 0%   205.8µ ± 0%   -0.89% (p=0.000 n=15)
NatMul/10000-88            8.456m ± 0%   8.468m ± 0%   +0.14% (p=0.021 n=15)
NatMul/100000-88           295.1m ± 0%   297.9m ± 0%   +0.94% (p=0.000 n=15)
geomean                    14.96µ        14.33µ        -4.23%

                 │     old      │                   new                   │
                 │     B/op     │     B/op       vs base                  │
NatMul/10-88         192.0 ± 0%     192.0 ±  0%        ~ (p=1.000 n=15) ¹
NatMul/100-88      4.750Ki ± 0%   1.758Ki ±  0%  -62.99% (p=0.000 n=15)
NatMul/1000-88     48.44Ki ± 0%   16.08Ki ±  0%  -66.80% (p=0.000 n=15)
NatMul/10000-88    489.7Ki ± 1%   166.1Ki ±  3%  -66.08% (p=0.000 n=15)
NatMul/100000-88   5.546Mi ± 0%   3.819Mi ± 60%  -31.15% (p=0.000 n=15)
geomean            41.29Ki        20.30Ki        -50.85%
¹ all samples are equal

                 │     old     │                 new                  │
                 │  allocs/op  │  allocs/op   vs base                 │
NatMul/10-88       1.000 ±  0%   1.000 ±  0%       ~ (p=1.000 n=15) ¹
NatMul/100-88      1.000 ±  0%   1.000 ±  0%       ~ (p=1.000 n=15) ¹
NatMul/1000-88     1.000 ±  0%   1.000 ±  0%       ~ (p=1.000 n=15) ¹
NatMul/10000-88    1.000 ±  0%   1.000 ±  0%       ~ (p=1.000 n=15) ¹
NatMul/100000-88   5.000 ± 20%   6.000 ± 67%       ~ (p=0.672 n=15)
geomean            1.380         1.431        +3.71%
¹ all samples are equal

goos: linux
goarch: arm64
pkg: math/big
                         │     old     │                 new                 │
                         │   sec/op    │   sec/op     vs base                │
Div/20/10-16               15.85n ± 0%   15.23n ± 0%   -3.91% (p=0.000 n=15)
Div/40/20-16               15.88n ± 0%   15.22n ± 0%   -4.16% (p=0.000 n=15)
Div/100/50-16              29.69n ± 0%   26.39n ± 0%  -11.11% (p=0.000 n=15)
Div/200/100-16             149.2n ± 0%   123.3n ± 0%  -17.36% (p=0.000 n=15)
Div/400/200-16             160.3n ± 0%   139.2n ± 0%  -13.16% (p=0.000 n=15)
Div/1000/500-16            271.0n ± 0%   256.1n ± 0%   -5.50% (p=0.000 n=15)
Div/2000/1000-16           545.3n ± 0%   527.0n ± 0%   -3.36% (p=0.000 n=15)
Div/20000/10000-16         22.60µ ± 0%   22.20µ ± 0%   -1.77% (p=0.000 n=15)
Div/200000/100000-16       889.0µ ± 0%   892.2µ ± 0%   +0.35% (p=0.000 n=15)
Div/2000000/1000000-16     38.01m ± 0%   38.12m ± 0%   +0.30% (p=0.000 n=15)
Div/20000000/10000000-16    1.437 ± 0%    1.444 ± 0%   +0.50% (p=0.000 n=15)
NatMul/10-16               166.4n ± 2%   169.5n ± 1%   +1.86% (p=0.000 n=15)
NatMul/100-16              5.733µ ± 1%   5.570µ ± 1%   -2.84% (p=0.000 n=15)
NatMul/1000-16             232.6µ ± 1%   229.8µ ± 0%   -1.22% (p=0.000 n=15)
NatMul/10000-16            9.039m ± 1%   8.969m ± 0%   -0.77% (p=0.000 n=15)
NatMul/100000-16           367.0m ± 0%   368.8m ± 0%   +0.48% (p=0.000 n=15)
geomean                    16.15µ        15.50µ        -4.01%

                 │     old      │                  new                   │
                 │     B/op     │     B/op      vs base                  │
NatMul/10-16         192.0 ± 0%     192.0 ± 0%        ~ (p=1.000 n=15) ¹
NatMul/100-16      4.750Ki ± 0%   1.751Ki ± 0%  -63.14% (p=0.000 n=15)
NatMul/1000-16     48.33Ki ± 0%   16.02Ki ± 0%  -66.85% (p=0.000 n=15)
NatMul/10000-16    536.5Ki ± 1%   165.7Ki ± 3%  -69.12% (p=0.000 n=15)
NatMul/100000-16   6.078Mi ± 6%   4.197Mi ± 0%  -30.94% (p=0.000 n=15)
geomean            42.81Ki        20.64Ki       -51.78%
¹ all samples are equal

                 │     old     │                  new                  │
                 │  allocs/op  │  allocs/op   vs base                  │
NatMul/10-16       1.000 ±  0%   1.000 ±  0%        ~ (p=1.000 n=15) ¹
NatMul/100-16      1.000 ±  0%   1.000 ±  0%        ~ (p=1.000 n=15) ¹
NatMul/1000-16     1.000 ±  0%   1.000 ±  0%        ~ (p=1.000 n=15) ¹
NatMul/10000-16    2.000 ± 50%   1.000 ±  0%  -50.00% (p=0.001 n=15)
NatMul/100000-16   9.000 ± 11%   8.000 ± 12%  -11.11% (p=0.001 n=15)
geomean            1.783         1.516        -14.97%
¹ all samples are equal

goos: darwin
goarch: arm64
pkg: math/big
cpu: Apple M3 Pro
                         │     old      │                new                 │
                         │    sec/op    │   sec/op     vs base               │
Div/20/10-12                9.850n ± 1%   9.405n ± 1%  -4.52% (p=0.000 n=15)
Div/40/20-12                9.858n ± 0%   9.403n ± 1%  -4.62% (p=0.000 n=15)
Div/100/50-12               16.40n ± 1%   14.81n ± 0%  -9.70% (p=0.000 n=15)
Div/200/100-12              88.48n ± 2%   80.88n ± 0%  -8.59% (p=0.000 n=15)
Div/400/200-12             107.90n ± 1%   99.28n ± 1%  -7.99% (p=0.000 n=15)
Div/1000/500-12             188.8n ± 1%   178.6n ± 1%  -5.40% (p=0.000 n=15)
Div/2000/1000-12            399.9n ± 0%   389.1n ± 0%  -2.70% (p=0.000 n=15)
Div/20000/10000-12          13.94µ ± 2%   13.81µ ± 1%       ~ (p=0.574 n=15)
Div/200000/100000-12        523.8µ ± 0%   521.7µ ± 0%  -0.40% (p=0.000 n=15)
Div/2000000/1000000-12      21.46m ± 0%   21.48m ± 0%       ~ (p=0.067 n=15)
Div/20000000/10000000-12    812.5m ± 0%   812.9m ± 0%       ~ (p=0.061 n=15)
NatMul/10-12                77.14n ± 0%   78.35n ± 1%  +1.57% (p=0.000 n=15)
NatMul/100-12               2.999µ ± 0%   2.871µ ± 1%  -4.27% (p=0.000 n=15)
NatMul/1000-12              126.2µ ± 0%   126.8µ ± 0%  +0.51% (p=0.011 n=15)
NatMul/10000-12             5.099m ± 0%   5.125m ± 0%  +0.51% (p=0.000 n=15)
NatMul/100000-12            206.7m ± 0%   208.4m ± 0%  +0.80% (p=0.000 n=15)
geomean                     9.512µ        9.236µ       -2.91%

                 │     old      │                   new                    │
                 │     B/op     │      B/op       vs base                  │
NatMul/10-12         192.0 ± 0%     192.0 ±   0%        ~ (p=1.000 n=15) ¹
NatMul/100-12      4.750Ki ± 0%   1.750Ki ±   0%  -63.16% (p=0.000 n=15)
NatMul/1000-12     48.13Ki ± 0%   16.01Ki ±   0%  -66.73% (p=0.000 n=15)
NatMul/10000-12    483.5Ki ± 1%   163.2Ki ±   2%  -66.24% (p=0.000 n=15)
NatMul/100000-12   5.480Mi ± 4%   1.532Mi ± 104%  -72.05% (p=0.000 n=15)
geomean            41.03Ki        16.82Ki         -59.01%
¹ all samples are equal

                 │    old     │                  new                   │
                 │ allocs/op  │  allocs/op    vs base                  │
NatMul/10-12       1.000 ± 0%   1.000 ±   0%        ~ (p=1.000 n=15) ¹
NatMul/100-12      1.000 ± 0%   1.000 ±   0%        ~ (p=1.000 n=15) ¹
NatMul/1000-12     1.000 ± 0%   1.000 ±   0%        ~ (p=1.000 n=15) ¹
NatMul/10000-12    1.000 ± 0%   1.000 ±   0%        ~ (p=1.000 n=15) ¹
NatMul/100000-12   5.000 ± 0%   1.000 ± 400%  -80.00% (p=0.007 n=15)
geomean            1.380        1.000         -27.52%
¹ all samples are equal

Change-Id: I7efa6fe37971ed26ae120a32250fcb47ece0a011
Reviewed-on: https://go-review.googlesource.com/c/go/+/650638
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-02-27 05:58:09 -08:00
Russ Cox
763766e9ab math/big: report allocs in BenchmarkNatMul, BenchmarkNatSqr
Change-Id: I112f55c0e3ee3b75e615a06b27552de164565c04
Reviewed-on: https://go-review.googlesource.com/c/go/+/650637
Reviewed-by: Robert Griesemer <gri@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: Russ Cox <rsc@golang.org>
2025-02-27 05:50:45 -08:00
Russ Cox
b66d83ccea math/big: clean up GCD a little
The GCD code was setting one *Int to the value of another
by smashing one struct on top of the other, instead of using Set.
That was safe in this one case, but it's not idiomatic in math/big
nor safe in general, so rewrite the code not to do that.
(In one case, by swapping variables around; in another, by calling Set.)

The added Set call does slow down GCDs by a small amount,
since the answer has to be copied out. To compensate for that,
optimize a bit: remove the s, t temporaries entirely and handle
vector x word multiplication directly. The net result is that almost
all GCDs are faster, except for small ones, which are a few
nanoseconds slower.

goos: darwin
goarch: arm64
pkg: math/big
cpu: Apple M3 Pro
                              │ bench.before │             bench.after             │
                              │    sec/op    │   sec/op     vs base                │
GCD10x10/WithoutXY-12            23.80n ± 1%   31.71n ± 1%  +33.24% (p=0.000 n=10)
GCD10x10/WithXY-12              100.40n ± 0%   92.14n ± 1%   -8.22% (p=0.000 n=10)
GCD10x100/WithoutXY-12           63.70n ± 0%   70.73n ± 0%  +11.05% (p=0.000 n=10)
GCD10x100/WithXY-12              278.6n ± 0%   233.1n ± 1%  -16.35% (p=0.000 n=10)
GCD10x1000/WithoutXY-12          153.4n ± 0%   162.2n ± 1%   +5.74% (p=0.000 n=10)
GCD10x1000/WithXY-12             456.0n ± 0%   411.8n ± 1%   -9.69% (p=0.000 n=10)
GCD10x10000/WithoutXY-12         1.002µ ± 1%   1.036µ ± 0%   +3.39% (p=0.000 n=10)
GCD10x10000/WithXY-12            2.330µ ± 1%   2.210µ ± 0%   -5.13% (p=0.000 n=10)
GCD10x100000/WithoutXY-12        8.894µ ± 0%   8.889µ ± 1%        ~ (p=0.754 n=10)
GCD10x100000/WithXY-12           20.84µ ± 0%   20.24µ ± 0%   -2.84% (p=0.000 n=10)
GCD100x100/WithoutXY-12          373.3n ± 3%   314.4n ± 0%  -15.76% (p=0.000 n=10)
GCD100x100/WithXY-12             662.5n ± 0%   572.4n ± 1%  -13.59% (p=0.000 n=10)
GCD100x1000/WithoutXY-12         641.8n ± 0%   598.1n ± 1%   -6.81% (p=0.000 n=10)
GCD100x1000/WithXY-12            1.123µ ± 0%   1.019µ ± 1%   -9.26% (p=0.000 n=10)
GCD100x10000/WithoutXY-12        2.870µ ± 0%   2.831µ ± 0%   -1.38% (p=0.000 n=10)
GCD100x10000/WithXY-12           4.930µ ± 1%   4.675µ ± 0%   -5.16% (p=0.000 n=10)
GCD100x100000/WithoutXY-12       24.08µ ± 0%   23.97µ ± 0%   -0.48% (p=0.007 n=10)
GCD100x100000/WithXY-12          43.66µ ± 0%   42.52µ ± 0%   -2.61% (p=0.001 n=10)
GCD1000x1000/WithoutXY-12        3.999µ ± 0%   3.569µ ± 1%  -10.75% (p=0.000 n=10)
GCD1000x1000/WithXY-12           6.397µ ± 0%   5.534µ ± 0%  -13.49% (p=0.000 n=10)
GCD1000x10000/WithoutXY-12       6.875µ ± 0%   6.450µ ± 0%   -6.18% (p=0.000 n=10)
GCD1000x10000/WithXY-12          20.75µ ± 1%   19.17µ ± 1%   -7.64% (p=0.000 n=10)
GCD1000x100000/WithoutXY-12      36.38µ ± 0%   35.60µ ± 1%   -2.13% (p=0.000 n=10)
GCD1000x100000/WithXY-12         172.1µ ± 0%   174.4µ ± 3%        ~ (p=0.052 n=10)
GCD10000x10000/WithoutXY-12      79.89µ ± 1%   75.16µ ± 2%   -5.92% (p=0.000 n=10)
GCD10000x10000/WithXY-12         160.1µ ± 0%   150.0µ ± 0%   -6.33% (p=0.000 n=10)
GCD10000x100000/WithoutXY-12     213.2µ ± 1%   209.0µ ± 1%   -1.98% (p=0.000 n=10)
GCD10000x100000/WithXY-12        1.399m ± 0%   1.342m ± 3%   -4.08% (p=0.002 n=10)
GCD100000x100000/WithoutXY-12    5.463m ± 1%   5.504m ± 2%        ~ (p=0.190 n=10)
GCD100000x100000/WithXY-12       11.36m ± 0%   11.46m ± 1%   +0.86% (p=0.000 n=10)
geomean                          6.953µ        6.695µ        -3.71%

goos: linux
goarch: amd64
pkg: math/big
cpu: AMD Ryzen 9 7950X 16-Core Processor
                              │ bench.before │             bench.after             │
                              │    sec/op    │   sec/op     vs base                │
GCD10x10/WithoutXY-32           39.66n ±  4%   44.34n ± 4%  +11.77% (p=0.000 n=10)
GCD10x10/WithXY-32              156.7n ± 12%   130.8n ± 2%  -16.53% (p=0.000 n=10)
GCD10x100/WithoutXY-32          115.8n ±  5%   120.2n ± 2%   +3.89% (p=0.000 n=10)
GCD10x100/WithXY-32             465.3n ±  3%   368.1n ± 2%  -20.91% (p=0.000 n=10)
GCD10x1000/WithoutXY-32         201.1n ±  1%   210.8n ± 2%   +4.82% (p=0.000 n=10)
GCD10x1000/WithXY-32            652.9n ±  4%   605.0n ± 1%   -7.32% (p=0.002 n=10)
GCD10x10000/WithoutXY-32        1.046µ ±  2%   1.143µ ± 1%   +9.33% (p=0.000 n=10)
GCD10x10000/WithXY-32           3.360µ ±  1%   3.258µ ± 1%   -3.04% (p=0.000 n=10)
GCD10x100000/WithoutXY-32       9.391µ ±  3%   9.997µ ± 1%   +6.46% (p=0.000 n=10)
GCD10x100000/WithXY-32          27.92µ ±  1%   28.21µ ± 0%   +1.04% (p=0.043 n=10)
GCD100x100/WithoutXY-32         443.7n ±  5%   320.0n ± 2%  -27.88% (p=0.000 n=10)
GCD100x100/WithXY-32            789.9n ±  2%   690.4n ± 1%  -12.60% (p=0.000 n=10)
GCD100x1000/WithoutXY-32        718.4n ±  3%   600.0n ± 1%  -16.48% (p=0.000 n=10)
GCD100x1000/WithXY-32           1.388µ ±  4%   1.175µ ± 1%  -15.28% (p=0.000 n=10)
GCD100x10000/WithoutXY-32       2.750µ ±  1%   2.668µ ± 1%   -2.96% (p=0.000 n=10)
GCD100x10000/WithXY-32          6.016µ ±  1%   5.590µ ± 1%   -7.09% (p=0.000 n=10)
GCD100x100000/WithoutXY-32      21.40µ ±  1%   22.30µ ± 1%   +4.21% (p=0.000 n=10)
GCD100x100000/WithXY-32         47.02µ ±  4%   48.80µ ± 0%   +3.78% (p=0.015 n=10)
GCD1000x1000/WithoutXY-32       3.417µ ±  4%   3.020µ ± 1%  -11.65% (p=0.000 n=10)
GCD1000x1000/WithXY-32          5.752µ ±  0%   5.418µ ± 2%   -5.81% (p=0.000 n=10)
GCD1000x10000/WithoutXY-32      6.150µ ±  0%   6.246µ ± 1%   +1.55% (p=0.000 n=10)
GCD1000x10000/WithXY-32         24.68µ ±  3%   25.07µ ± 1%        ~ (p=0.051 n=10)
GCD1000x100000/WithoutXY-32     34.60µ ±  2%   36.85µ ± 1%   +6.51% (p=0.000 n=10)
GCD1000x100000/WithXY-32        209.5µ ±  4%   227.4µ ± 0%   +8.56% (p=0.000 n=10)
GCD10000x10000/WithoutXY-32     90.69µ ±  0%   88.48µ ± 0%   -2.44% (p=0.000 n=10)
GCD10000x10000/WithXY-32        197.1µ ±  0%   200.5µ ± 0%   +1.73% (p=0.000 n=10)
GCD10000x100000/WithoutXY-32    239.1µ ±  0%   242.5µ ± 0%   +1.42% (p=0.000 n=10)
GCD10000x100000/WithXY-32       1.963m ±  3%   2.028m ± 0%   +3.28% (p=0.000 n=10)
GCD100000x100000/WithoutXY-32   7.466m ±  0%   7.412m ± 0%   -0.71% (p=0.000 n=10)
GCD100000x100000/WithXY-32      16.10m ±  2%   16.47m ± 0%   +2.25% (p=0.000 n=10)
geomean                         8.388µ         8.127µ        -3.12%

Change-Id: I161dc409bad11bcc553bc8116449905ae5b06742
Reviewed-on: https://go-review.googlesource.com/c/go/+/650636
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2025-02-27 05:49:50 -08:00
Joel Sing
37e9c5eaba cmd/internal/obj/riscv: implement vector load/store instructions
Implement vector unit stride, vector strided, vector indexed and
vector whole register load and store instructions.

The vector unit stride instructions take an optional vector mask
register, which if specified must be register V0. If only two
operands are given, the instruction is encoded as unmasked.

The vector strided and vector indexed instructions also take an
optional vector mask register, which if specified must be register
V0. If only three operands are given, the instruction is encoded as
unmasked.

Cq-Include-Trybots: luci.golang.try:gotip-linux-riscv64
Change-Id: I35e43bb8f1cf6ae8826fbeec384b95ac945da50f
Reviewed-on: https://go-review.googlesource.com/c/go/+/631937
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Pengcheng Wang <wangpengcheng.pp@bytedance.com>
2025-02-27 03:47:20 -08:00
Joel Sing
927fdb7843 cmd/compile: simplify intrinsification of TrailingZeros16 and TrailingZeros8
Decompose Ctz16 and Ctz8 within the SSA rules for LOONG64, MIPS, PPC64
and S390X, rather than having a custom intrinsic. Note that for PPC64 this
actually allows the existing Ctz16 and Ctz8 rules to be used.

Change-Id: I27a5e978f852b9d75396d2a80f5d7dfcb5ef7dd4
Reviewed-on: https://go-review.googlesource.com/c/go/+/651816
Reviewed-by: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2025-02-27 03:45:44 -08:00
Guoqi Chen
01ba8bfe86 runtime/cgo: use standard ABI call setg_gcc in crosscall1 on loong64
Change-Id: Ie38583d667d579751d643b2da2aa56390b69904c
Reviewed-on: https://go-review.googlesource.com/c/go/+/652255
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
2025-02-26 17:36:57 -08:00
Guoqi Chen
11c847e536 runtime: use correct memory barrier in exitThread function on loong64
In the runtime.exitThread function, a storeRelease barrier
is required instead of a full barrier.

Change-Id: I2815ddb03e4984c891d71811ccf650a82325e10d
Reviewed-on: https://go-review.googlesource.com/c/go/+/631915
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-26 17:35:25 -08:00
Keith Randall
c594762ad5 runtime: remove ret field from gobuf
It's not used for anything.

Change-Id: I031b3cdfe52b6b1cff4b3cb6713ffe588084542f
Reviewed-on: https://go-review.googlesource.com/c/go/+/652276
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-26 14:48:55 -08:00
Ian Lance Taylor
2e71ae33ca runtime/cgo: avoid errors from -Wdeclaration-after-statement
CL 652181 accidentally missed this iPhone only code.

For #71961

Change-Id: I567f8bb38958907442e69494da330d5199d11f54
Reviewed-on: https://go-review.googlesource.com/c/go/+/653135
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-26 14:39:37 -08:00
Mateusz Poliwczak
c55c1cbd04 net: return proper error from Context
Sadly err was a named parameter so this did not cause
compile error.

Fixes #71974

Change-Id: I10cf29ae14c52d48a793c9a6cb01b01d79b1b356
GitHub-Last-Rev: 4dc0e6670a9265612b8ec26dbc378219b25156b4
GitHub-Pull-Request: golang/go#71976
Reviewed-on: https://go-review.googlesource.com/c/go/+/652815
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
2025-02-26 14:16:12 -08:00
Ian Lance Taylor
9cceaf8736 cmd/link: require cgo for -linkmode=external test
For #71416
Fixes #71957

Change-Id: I2180dada34d9dd2d3f5b0aaf8525951fd2e86a27
Reviewed-on: https://go-review.googlesource.com/c/go/+/652277
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-26 14:12:58 -08:00
Egon Elbre
983e30bd3b crypto/internal/fips140/edwards25519/field: optimize AMD64
Replace constant multiplication with shift and adds,
this reduces pressure on multiplications, making things overall
faster.

goos: windows
goarch: amd64
pkg: crypto/internal/fips140/edwards25519/field
cpu: AMD Ryzen Threadripper 2950X 16-Core Processor
            │   v0.log~   │              v1.log~               │
            │   sec/op    │   sec/op     vs base               │
Add-32        4.768n ± 1%   4.763n ± 0%       ~ (p=0.683 n=20)
Multiply-32   20.93n ± 0%   19.48n ± 0%  -6.88% (p=0.000 n=20)
Square-32     15.88n ± 0%   15.00n ± 0%  -5.51% (p=0.000 n=20)
Invert-32     4.291µ ± 0%   4.072µ ± 0%  -5.10% (p=0.000 n=20)
Mult32-32     5.184n ± 0%   5.169n ± 0%  -0.30% (p=0.032 n=20)
Bytes-32      11.36n ± 0%   11.34n ± 0%       ~ (p=0.106 n=20)
geomean       27.15n        26.32n       -3.06%

Change-Id: I9c2f588fad29d89c3e6c712c092b32b66479f596
Reviewed-on: https://go-review.googlesource.com/c/go/+/652716
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-02-26 13:58:20 -08:00
Egon Elbre
16959799bd crypto/internal/fips140/edwards25519/field/_asm: update avo dependency
v0.4.0 does not work with Go 1.25.

Change-Id: Ib9081b0ee78cad7974b038d89fa92d9ccbfa305a
Reviewed-on: https://go-review.googlesource.com/c/go/+/652715
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Commit-Queue: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-26 13:58:17 -08:00
Mateusz Poliwczak
ee0d03fab6 sync: don't keep func alive after OnceFunc panics
This moves the f = nil assignment to the defer statement,
so that in case the functions panics, the f func is not
referenced anymore.

Change-Id: I3e53b90a10f21741e26602270822c8a75679f163
GitHub-Last-Rev: bda01100c6d48d1b0ca3e1baefef4d592cca1fee
GitHub-Pull-Request: golang/go#68636
Reviewed-on: https://go-review.googlesource.com/c/go/+/601240
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-02-26 12:52:02 -08:00
Michael Anthony Knyszek
1421b982dc runtime: document that cleanups can run concurrently with each other
Fixes #71825.

Change-Id: I25af19eb72d75f13cf661fc47ee5717782785326
Reviewed-on: https://go-review.googlesource.com/c/go/+/650696
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-26 11:35:44 -08:00
Ian Lance Taylor
76c7028253 runtime/cgo: avoid errors from -Wdeclaration-after-statement
It's used by the SWIG CI build, at least, and it's an easy fix.

Fixes #71961

Change-Id: Id21071a5aef216b35ecf0e9cd3e05d08972d92fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/652181
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-02-26 10:52:55 -08:00
qiulaidongfeng
194696f1d1 reflect: let Value.Seq return the iteration value correct type
Fixes #71905

Change-Id: I50a418f8552e071c6e5011af5b9accc7d41548d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/651855
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>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-26 09:41:14 -08:00
Keith Randall
8b8bff7bb2 cmd/compile: don't pull constant offsets out of pointer arithmetic
This could lead to manufacturing a pointer that points outside
its original allocation.

Bug was introduced in CL 629858.

Fixes #71932

Change-Id: Ia86ab0b65ce5f80a8e0f4f4c81babd07c5904f8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/652078
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>
2025-02-26 09:39:12 -08:00
Alexandr Primak
4c75671871 runtime: Added usage example for the runtime.AddCleanup() function.
The existing description of the function lacks usage examples, which makes it difficult to understand, so I added one.

There is no open issue about this, since the implementation seems trivial.

Change-Id: I96b29f0b21d1c7fda04128239633c8a2fc36fef2
Reviewed-on: https://go-review.googlesource.com/c/go/+/649995
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-26 08:54:51 -08:00
Cuong Manh Le
011da163f4 cmd/compile/internal/test: fix noopt builder
The function argument passed to hash function escaped to heap when
optimization is disabled, causing the builder failed.

To fix this, skip the test on noopt builder.

Updates #71943
Fixes #71965

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-noopt
Change-Id: I3a9ece09bfa10bf5eb102a7da3ade65634565cb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/652735
Reviewed-by: Dmitri Shuralyov <dmitshur@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: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2025-02-26 07:04:08 -08:00
Joel Sing
1b1c6b838e cmd/compile: simplify intrinsification of BitLen16 and BitLen8
Decompose BitLen16 and BitLen8 within the SSA rules for architectures that
support BitLen32 or BitLen64, rather than having a custom intrinsic.

Change-Id: Ie4188ce69d1021e63cec27a8e7418efb0714812b
Reviewed-on: https://go-review.googlesource.com/c/go/+/651817
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-26 02:02:07 -08:00
Ian Lance Taylor
969a0da362 runtime: route calls to msan_memmove through cgo
This avoids problems when the C linker doesn't want to see the Go relocation.

Fixes #71954

Change-Id: I7cf884c4059d596cad6074ade02020d5a724f20e
Reviewed-on: https://go-review.googlesource.com/c/go/+/652180
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-02-25 21:41:00 -08:00
Alan Donovan
767c0fb9fd go/scanner: report specific error for UCS-2 encoded files
Windows text files may be encoded as UCS-2 (i.e. 2-byte UTF-16).
This CL causes the scanner to emit a better error when it reads
a file in this encoding.

+ test

Fixes #71950

Change-Id: Ia65bbf9a60e36984b0f3e4865591aa6978d2bde2
Reviewed-on: https://go-review.googlesource.com/c/go/+/652515
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
2025-02-25 19:23:05 -08:00
Ian Lance Taylor
b38b0c0088 cmd/compile: document -embedcfg flag
Fixes #71942

Change-Id: Ie7e795506a9c8781f0e0963012233a7ed1093855
Reviewed-on: https://go-review.googlesource.com/c/go/+/652475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-02-25 12:26:38 -08:00
Cuong Manh Le
8203265d5e cmd/compile, runtime: optimize concatbytes
CL 527935 optimized []byte(string1 + string2) to use runtime.concatbytes
to prevent concatenating of strings before converting to slices.
However, the optimization is implemented without allowing temporary
buffer for slice on stack, causing un-necessary allocations.

To fix this, optimize concatbytes to use temporary buffer if the result
string length fit to the buffer size.

Fixes #71943

Change-Id: I1d3c374cd46aad8f83a271b8a5ca79094f9fd8db
Reviewed-on: https://go-review.googlesource.com/c/go/+/652395
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-25 12:23:56 -08:00
Tobias Klauser
beb314c0db os, syscall: use unix build tag where appropriate
These newly added files may use the unix build tag instead of explitly
listing all unix-like GOOS values.

For #51572

Change-Id: I31c71d2b5533b39bbccd89bf616a99b8e33565d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/651996
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-25 12:09:25 -08:00
Egon Elbre
8cbb512c76 crypto/internal/fips140/edwards25519/field: inline carryPropagate
Manually inlining carryPropagate seems to help quite a bit.

goos: linux
goarch: arm64
pkg: crypto/internal/fips140/edwards25519
                              │     OLD     │                NEW                 │
                              │   sec/op    │   sec/op     vs base               │
EncodingDecoding-4              141.4µ ± 0%   133.1µ ± 0%  -5.90% (p=0.000 n=10)
ScalarBaseMult-4                260.5µ ± 0%   254.0µ ± 0%  -2.49% (p=0.000 n=10)
ScalarMult-4                    916.6µ ± 0%   892.5µ ± 0%  -2.63% (p=0.000 n=10)
VarTimeDoubleScalarBaseMult-4   909.6µ ± 0%   886.6µ ± 0%  -2.52% (p=0.000 n=10)
geomean                         418.6µ        404.4µ       -3.40%

pkg: crypto/internal/fips140/edwards25519/field
           │     OLD     │                NEW                 │
           │   sec/op    │   sec/op     vs base               │
Add-4        33.50n ± 0%   33.52n ± 0%  +0.04% (p=0.013 n=10)
Multiply-4   406.8n ± 0%   400.0n ± 0%  -1.66% (p=0.000 n=10)
Square-4     246.4n ± 0%   234.4n ± 0%  -4.85% (p=0.000 n=10)
Invert-4     67.37µ ± 0%   63.53µ ± 0%  -5.69% (p=0.000 n=10)
Mult32-4     78.68n ± 0%   78.67n ± 0%       ~ (p=0.367 n=10)
Bytes-4      110.6n ± 0%   110.8n ± 0%       ~ (p=0.568 n=10)
geomean      354.0n        346.8n       -2.03%

goos: darwin
goarch: arm64
pkg: crypto/internal/fips140/edwards25519
cpu: Apple M1 Pro
                               │     OLD     │                NEW                 │
                               │   sec/op    │   sec/op     vs base               │
EncodingDecoding-10              7.610µ ± 2%   7.459µ ± 0%  -1.98% (p=0.000 n=10)
ScalarBaseMult-10                11.54µ ± 0%   11.36µ ± 0%  -1.53% (p=0.000 n=10)
ScalarMult-10                    38.59µ ± 2%   37.09µ ± 0%  -3.88% (p=0.000 n=10)
VarTimeDoubleScalarBaseMult-10   37.10µ ± 0%   35.79µ ± 0%  -3.54% (p=0.000 n=10)
geomean                          18.83µ        18.31µ       -2.74%

pkg: crypto/internal/fips140/edwards25519/field
            │     OLD     │                NEW                 │
            │   sec/op    │   sec/op     vs base               │
Add-10        5.116n ± 5%   5.168n ± 5%       ~ (p=0.669 n=10)
Multiply-10   18.00n ± 2%   16.90n ± 1%  -6.09% (p=0.000 n=10)
Square-10     13.66n ± 0%   13.48n ± 0%  -1.28% (p=0.000 n=10)
Invert-10     3.629µ ± 0%   3.508µ ± 2%  -3.33% (p=0.000 n=10)
Mult32-10     6.165n ± 2%   6.324n ± 1%  +2.57% (p=0.000 n=10)
Bytes-10      10.33n ± 8%   10.28n ± 4%       ~ (p=0.516 n=10)
geomean       25.74n        25.40n       -1.31%

tags: purego
goos: windows
goarch: amd64
pkg: crypto/internal/fips140/edwards25519
cpu: AMD Ryzen Threadripper 2950X 16-Core Processor
                               │     OLD     │                NEW                 │
                               │   sec/op    │   sec/op     vs base               │
EncodingDecoding-32              9.557µ ± 1%   8.966µ ± 0%  -6.18% (p=0.000 n=10)
ScalarBaseMult-32                19.14µ ± 2%   19.00µ ± 1%       ~ (p=0.190 n=10)
ScalarMult-32                    64.61µ ± 1%   65.83µ ± 2%  +1.88% (p=0.003 n=10)
VarTimeDoubleScalarBaseMult-32   62.36µ ± 1%   62.14µ ± 1%       ~ (p=0.529 n=10)
geomean                          29.30µ        28.89µ       -1.39%

pkg: crypto/internal/fips140/edwards25519/field
            │     OLD     │                NEW                 │
            │   sec/op    │   sec/op     vs base               │
Add-32        4.879n ± 1%   4.880n ± 1%       ~ (p=0.739 n=10)
Multiply-32   22.75n ± 2%   22.03n ± 3%  -3.14% (p=0.000 n=10)
Square-32     16.46n ± 2%   15.38n ± 1%  -6.59% (p=0.000 n=10)
Invert-32     4.466µ ± 1%   4.168µ ± 1%  -6.67% (p=0.000 n=10)
Mult32-32     5.311n ± 1%   5.492n ± 1%  +3.40% (p=0.000 n=10)
Bytes-32      11.51n ± 1%   11.53n ± 1%       ~ (p=0.303 n=10)
geomean       28.16n        27.54n       -2.20%

Change-Id: I6e60d2f1220661df4b4f2bf2d810864c19c03012
Reviewed-on: https://go-review.googlesource.com/c/go/+/650279
Auto-Submit: Filippo Valsorda <filippo@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: Michael Pratt <mpratt@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2025-02-25 12:08:12 -08:00
Egon Elbre
c578670dcb crypto/internal/fips140/edwards25519/field: optimize carryPropagate
Using pure Go solution for ARM64 seems to perform better when the
operation order is slightly tweaked.

goos: linux
goarch: arm64
pkg: crypto/internal/fips140/edwards25519
                              │     OLD      │                 NEW                 │
                              │    sec/op    │   sec/op     vs base                │
EncodingDecoding-4               158.7µ ± 0%   141.4µ ± 0%  -10.88% (p=0.000 n=10)
ScalarBaseMult-4                 281.2µ ± 0%   260.5µ ± 0%   -7.35% (p=0.000 n=10)
ScalarMult-4                    1008.9µ ± 0%   916.6µ ± 0%   -9.15% (p=0.000 n=10)
VarTimeDoubleScalarBaseMult-4   1003.4µ ± 0%   909.6µ ± 0%   -9.36% (p=0.000 n=10)
geomean                          461.0µ        418.6µ        -9.19%

pkg: crypto/internal/fips140/edwards25519/field
           │     OLD     │                 NEW                 │
           │   sec/op    │   sec/op     vs base                │
Add-4        45.22n ± 0%   33.50n ± 0%  -25.91% (p=0.000 n=10)
Multiply-4   454.0n ± 0%   406.8n ± 0%  -10.41% (p=0.000 n=10)
Square-4     278.2n ± 0%   246.4n ± 0%  -11.43% (p=0.000 n=10)
Invert-4     75.83µ ± 0%   67.37µ ± 0%  -11.16% (p=0.000 n=10)
Mult32-4     78.66n ± 0%   78.68n ± 0%   +0.02% (p=0.022 n=10)
Bytes-4      120.6n ± 0%   110.6n ± 0%   -8.25% (p=0.000 n=10)
geomean      400.2n        354.0n       -11.54%

goos: darwin
goarch: arm64
pkg: crypto/internal/fips140/edwards25519
cpu: Apple M1 Pro
                               │     OLD      │                 NEW                 │
                               │    sec/op    │   sec/op     vs base                │
EncodingDecoding-10              10.095µ ± 0%   7.610µ ± 2%  -24.62% (p=0.000 n=10)
ScalarBaseMult-10                 12.65µ ± 0%   11.54µ ± 0%   -8.80% (p=0.000 n=10)
ScalarMult-10                     51.49µ ± 0%   38.59µ ± 2%  -25.06% (p=0.000 n=10)
VarTimeDoubleScalarBaseMult-10    49.41µ ± 0%   37.10µ ± 0%  -24.92% (p=0.000 n=10)
geomean                           23.88µ        18.83µ       -21.14%

pkg: crypto/internal/fips140/edwards25519/field
            │     OLD     │                 NEW                  │
            │   sec/op    │    sec/op     vs base                │
Add-10        6.009n ± 1%    5.116n ± 5%  -14.85% (p=0.000 n=10)
Multiply-10   19.59n ± 0%    18.00n ± 2%   -8.14% (p=0.000 n=10)
Square-10     18.14n ± 0%    13.66n ± 0%  -24.70% (p=0.000 n=10)
Invert-10     4.854µ ± 0%    3.629µ ± 0%  -25.24% (p=0.000 n=10)
Mult32-10     6.151n ± 0%    6.165n ± 2%        ~ (p=0.224 n=10)
Bytes-10      7.463n ± 1%   10.330n ± 8%  +38.43% (p=0.000 n=10)
geomean       27.94n         25.74n        -7.89%

tags: purego
goos: windows
goarch: amd64
pkg: crypto/internal/fips140/edwards25519
cpu: AMD Ryzen Threadripper 2950X 16-Core Processor
                               │     OLD      │                 NEW                 │
                               │    sec/op    │   sec/op     vs base                │
EncodingDecoding-32              12.856µ ± 0%   9.557µ ± 1%  -25.66% (p=0.000 n=10)
ScalarBaseMult-32                 21.28µ ± 1%   19.14µ ± 2%  -10.04% (p=0.000 n=10)
ScalarMult-32                     74.83µ ± 1%   64.61µ ± 1%  -13.65% (p=0.000 n=10)
VarTimeDoubleScalarBaseMult-32    73.85µ ± 0%   62.36µ ± 1%  -15.56% (p=0.000 n=10)
geomean                           35.06µ        29.30µ       -16.44%

pkg: crypto/internal/fips140/edwards25519/field
            │     OLD     │                 NEW                 │
            │   sec/op    │   sec/op     vs base                │
Add-32        5.700n ± 1%   4.879n ± 1%  -14.40% (p=0.000 n=10)
Multiply-32   29.24n ± 2%   22.75n ± 2%  -22.21% (p=0.000 n=10)
Square-32     23.06n ± 1%   16.46n ± 2%  -28.60% (p=0.000 n=10)
Invert-32     5.952µ ± 2%   4.466µ ± 1%  -24.97% (p=0.000 n=10)
Mult32-32     5.240n ± 1%   5.311n ± 1%   +1.35% (p=0.006 n=10)
Bytes-32      12.39n ± 1%   11.51n ± 1%   -7.10% (p=0.000 n=10)
geomean       33.78n        28.16n       -16.63%

Change-Id: I71fa40307e803caec56227607ee666198e4c0b03
Reviewed-on: https://go-review.googlesource.com/c/go/+/650278
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-25 12:07:31 -08:00
Egon Elbre
6719336428 crypto/internal/fips140/edwards25519/field: optimize *19
Using a `x*19 == x + (x + x<<3)<<1` gives a significant performance
improvement for arm devices that have a slow multiply.
Surprisingly it also seems to help Mac M1 and AMD64+purgo a bit.

goos: linux
goarch: arm64
pkg: crypto/internal/fips140/edwards25519
                              │     OLD     │                NEW                 │
                              │   sec/op    │   sec/op     vs base               │
EncodingDecoding-4              166.3µ ± 0%   158.7µ ± 0%  -4.57% (p=0.000 n=10)
ScalarBaseMult-4                286.0µ ± 0%   281.2µ ± 0%  -1.70% (p=0.000 n=10)
ScalarMult-4                    1.042m ± 0%   1.009m ± 0%  -3.22% (p=0.000 n=10)
VarTimeDoubleScalarBaseMult-4   1.042m ± 0%   1.003m ± 0%  -3.66% (p=0.000 n=10)
geomean                         476.7µ        461.0µ       -3.29%

pkg: crypto/internal/fips140/edwards25519/field
           │     OLD     │                NEW                 │
           │   sec/op    │   sec/op     vs base               │
Add-4        45.24n ± 0%   45.22n ± 0%       ~ (p=0.166 n=10)
Multiply-4   447.5n ± 0%   454.0n ± 0%  +1.46% (p=0.000 n=10)
Square-4     289.7n ± 0%   278.2n ± 0%  -3.99% (p=0.000 n=10)
Invert-4     79.45µ ± 0%   75.83µ ± 0%  -4.55% (p=0.000 n=10)
Mult32-4     78.67n ± 0%   78.66n ± 0%       ~ (p=0.272 n=10)
Bytes-4      120.5n ± 0%   120.6n ± 0%       ~ (p=0.390 n=10)
geomean      405.0n        400.2n       -1.20%

goos: darwin
goarch: arm64
pkg: crypto/internal/fips140/edwards25519
cpu: Apple M1 Pro
                               │     OLD     │                NEW                 │
                               │   sec/op    │   sec/op     vs base               │
EncodingDecoding-10              10.04µ ± 0%   10.10µ ± 0%  +0.54% (p=0.000 n=10)
ScalarBaseMult-10                12.72µ ± 0%   12.65µ ± 0%  -0.50% (p=0.000 n=10)
ScalarMult-10                    51.82µ ± 0%   51.49µ ± 0%  -0.63% (p=0.000 n=10)
VarTimeDoubleScalarBaseMult-10   50.63µ ± 2%   49.41µ ± 0%  -2.41% (p=0.001 n=10)
geomean                          24.06µ        23.88µ       -0.75%

pkg: crypto/internal/fips140/edwards25519/field
            │     OLD     │                NEW                 │
            │   sec/op    │   sec/op     vs base               │
Add-10        6.327n ± 2%   6.009n ± 1%  -5.03% (p=0.000 n=10)
Multiply-10   19.12n ± 0%   19.59n ± 0%  +2.48% (p=0.000 n=10)
Square-10     17.88n ± 0%   18.14n ± 0%  +1.40% (p=0.000 n=10)
Invert-10     4.816µ ± 0%   4.854µ ± 0%  +0.78% (p=0.000 n=10)
Mult32-10     6.188n ± 0%   6.151n ± 0%  -0.61% (p=0.001 n=10)
Bytes-10      7.460n ± 0%   7.463n ± 1%       ~ (p=0.795 n=10)
geomean       27.99n        27.94n       -0.19%

tags: purego
goos: windows
goarch: amd64
pkg: crypto/internal/fips140/edwards25519
cpu: AMD Ryzen Threadripper 2950X 16-Core Processor
                               │     OLD     │                NEW                 │
                               │   sec/op    │   sec/op     vs base               │
EncodingDecoding-32              13.61µ ± 1%   12.86µ ± 0%  -5.54% (p=0.000 n=10)
ScalarBaseMult-32                22.88µ ± 2%   21.28µ ± 1%  -6.98% (p=0.000 n=10)
ScalarMult-32                    79.29µ ± 3%   74.83µ ± 1%  -5.63% (p=0.000 n=10)
VarTimeDoubleScalarBaseMult-32   77.91µ ± 2%   73.85µ ± 0%  -5.22% (p=0.000 n=10)
geomean                          37.24µ        35.06µ       -5.85%

pkg: crypto/internal/fips140/edwards25519/field
            │     OLD     │                NEW                 │
            │   sec/op    │   sec/op     vs base               │
Add-32        5.723n ± 2%   5.700n ± 1%       ~ (p=0.218 n=10)
Multiply-32   30.63n ± 1%   29.24n ± 2%  -4.52% (p=0.000 n=10)
Square-32     24.30n ± 1%   23.06n ± 1%  -5.10% (p=0.000 n=10)
Invert-32     6.368µ ± 1%   5.952µ ± 2%  -6.53% (p=0.000 n=10)
Mult32-32     5.303n ± 2%   5.240n ± 1%  -1.17% (p=0.041 n=10)
Bytes-32      12.47n ± 1%   12.39n ± 1%       ~ (p=0.137 n=10)
geomean       34.86n        33.78n       -3.10%

Change-Id: I889b322bf49293516574d3e9514734a49cca1f86
Reviewed-on: https://go-review.googlesource.com/c/go/+/650277
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-02-25 12:05:57 -08:00
qmuntal
b47ebb229f all: use testenv.GoToolPath instead of hardcoding go
Change-Id: I84ec73d3ddef913a87cb9b48147c44ac3e7c8a8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/651957
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-25 12:01:35 -08:00
qmuntal
00e793cfe3 runtime/cgo: use CreateThread instead of _beginthread
_beginthread is intended to be used together with the C runtime.
The cgo runtime doesn't use it, so better use CreateThread directly,
which is the Windows API for creating threads.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-arm64
Change-Id: Ic6cf75f69f62a3babf5e74155da1aac70961886c
Reviewed-on: https://go-review.googlesource.com/c/go/+/651995
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-25 12:01:21 -08:00
Brian Byrne
c5ff26a7a0 sync: reduce OnceFunc (and variants) heap allocations
The lifetime of the variables are identical; capture
them in a single struct to avoid individual allocations.
The inner closure can also avoid allocation by using the
capture of the outer closure.

Escape analysis for OnceValues:

  /go/src/sync/oncefunc.go:74:29: moved to heap: sync.f
  /go/src/sync/oncefunc.go:76:3: moved to heap: sync.once
  /go/src/sync/oncefunc.go:77:3: moved to heap: sync.valid
  /go/src/sync/oncefunc.go:78:3: moved to heap: sync.p
  /go/src/sync/oncefunc.go:79:3: moved to heap: sync.r1
  /go/src/sync/oncefunc.go:80:3: moved to heap: sync.r2
  /go/src/sync/oncefunc.go:82:7: func literal escapes to heap
  /go/src/sync/oncefunc.go:83:9: func literal does not escape
  /go/src/sync/oncefunc.go:93:9: func literal escapes to heap

After provided changes:

  /go/src/sync/oncefunc.go:86:2: moved to heap: sync.d
  /go/src/sync/oncefunc.go:96:9: func literal escapes to heap
  /go/src/sync/oncefunc.go:99:13: func literal does not escape
  /go/src/sync/oncefunc.go💯10: func literal does not escape

Change-Id: Ib06e650fd427b57e0bdbdf1fe759fe436104ff79
Reviewed-on: https://go-review.googlesource.com/c/go/+/601596
Auto-Submit: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2025-02-25 11:52:33 -08:00
qmuntal
61641c1145 cmd/link: put .got section in __DATA_CONST segment
On Darwin, the .got section can be placed in a read-only segment. Only the dynamic linker should modify it at start-up time.

Other read-only sections, like .typelink and .itablink, are already placed in the __DATA_CONST segment. Do the same for the .got section.

Fixes #71416.

Cq-Include-Trybots: luci.golang.try:gotip-darwin-amd64-longtest
Change-Id: I9cd9c20da63b655fabb61d742feb086c3ef3bea7
Reviewed-on: https://go-review.googlesource.com/c/go/+/644055
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-25 11:51:02 -08:00
Filippo Valsorda
eed2208f15 crypto/tls: require EMS in FIPS 140-3 mode
See Implementation Guidance D.Q.

Change-Id: I6a6a465607da94f2bb249934f0561ae04a55e7b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/650575
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-02-25 11:50:05 -08:00
Jes Cok
77ce76d761 all: gofmt -w
Change-Id: Ie30a780cbd98bab1e80035b3dfddf92eb281759e
GitHub-Last-Rev: 369ada24ffc297efb47768e430b1bd0216706998
GitHub-Pull-Request: golang/go#71898
Reviewed-on: https://go-review.googlesource.com/c/go/+/651795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-02-25 11:49:16 -08:00
Jes Cok
97571f3610 encoding/json: use builtin min function in appendString
To make code a bit simpler.

Change-Id: I59fca1d5760e304abd53873ecf9ca8b2903e02e8
GitHub-Last-Rev: 1369df6da16121c342a4e678efe3e5b082485b74
GitHub-Pull-Request: golang/go#71873
Reviewed-on: https://go-review.googlesource.com/c/go/+/651355
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-25 11:49:13 -08:00
qmuntal
f707e53fd5 all: surround -test.run arguments with ^$
If the -test.run value is not surrounded by ^$ then any test that
matches the -test.run value will be run. This is normally not the
desired behavior, as it can lead to unexpected tests being run.

Change-Id: I3447aaebad5156bbef7f263cdb9f6b8c32331324
Reviewed-on: https://go-review.googlesource.com/c/go/+/651956
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-25 10:58:29 -08:00
khr@golang.org
cc16fb52e6 cmd/compile: ensure we don't reuse temporary register
Before this CL, we could use the same register for both a temporary
register and for moving a value in the output register out of the way.

Fixes #71857

Change-Id: Iefbfd9d4139136174570d8aadf8a0fb391791ea9
Reviewed-on: https://go-review.googlesource.com/c/go/+/651221
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>
2025-02-25 10:19:25 -08:00
Jes Cok
1e92ff11f5 unicode/utf8: use builtin max function to simplify code
Change-Id: I6a73b645d074baaa4d09480bdf4192816a8c2450
GitHub-Last-Rev: 202d498eb019c18b9ba30bccc2cb169c9eb79366
GitHub-Pull-Request: golang/go#71945
Reviewed-on: https://go-review.googlesource.com/c/go/+/652177
Auto-Submit: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
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>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-25 10:16:36 -08:00
Filippo Valsorda
c441eecbe9 crypto/internal/fips140test: add a test for a non-approved function
Change-Id: I6a6a46560bfca588e5874f3769f33b561c33096a
Reviewed-on: https://go-review.googlesource.com/c/go/+/652415
Reviewed-by: Robert Griesemer <gri@google.com>
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: Damien Neil <dneil@google.com>
2025-02-25 09:51:40 -08:00
Mateusz Poliwczak
973a9eb8bf net: properly wrap context cancellation errors and return DNSErrors consistently
Fixes #71939

Change-Id: Id7cd720fcca2812ffca2b1b20fe923914422d994
GitHub-Last-Rev: 4671f338c91b5826c669fbd113c176e22f5020e5
GitHub-Pull-Request: golang/go#71941
Reviewed-on: https://go-review.googlesource.com/c/go/+/652275
Commit-Queue: 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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-02-25 09:40:57 -08:00
Robert Griesemer
434de2f8e9 spec: remove notion of core types
This CL removes the notion of core types from the spec.

Instead of referring to core types, each section that did
so before is reverted to approx. the pre-generics (1.17)
prose, and additional paragraphs cover the type parameter
cases as needed.

The hope is that this makes it easier to read the spec.
When type parameters are involved, the extra prose is
local to the language feature in question and thus more
readily available. When no type parameters are present,
readers do not have to concern themselves with core types.

In contrast to CL 621919, this change is not intended to
loosen the spec in any way and therefore does not change
the language (if the new prose implies otherwise, we will
correct it).

Except for adjustments to compiler error messages
(no mention of core types anymore), no other changes
to the compiler or tools are required.

Future CLs may selectively relax requirements on a language
construct by language construct basis; each such change can
be discussed and proposed independently.

For #70128.

Change-Id: I6ed879a472c615d7c8dbdc7b6bd7eef3d12eff7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/645716
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
2025-02-25 09:28:48 -08:00
Mateusz Poliwczak
bdef177831 go/parser: require label after goto
Fixes #70957

Change-Id: Ied7cf29ea3e02bb71ddce8a19ddd381ce5991ed1
GitHub-Last-Rev: 310bd1537b7a36758f3fbf8db476fa68e1a11599
GitHub-Pull-Request: golang/go#70958
Reviewed-on: https://go-review.googlesource.com/c/go/+/638395
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-02-25 09:14:35 -08:00
Carlos Amedee
2f036e1475 weak: test the use of runtime.AddCleanup
This change adds a test case for runtime.AddCleanup.

Updates #70907

Change-Id: I29cba9dc5b40cec8e610215974e61ee47e10d00f
Reviewed-on: https://go-review.googlesource.com/c/go/+/649459
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-25 08:44:32 -08:00
David Chase
c2ae5c7443 cmd/compile, runtime: use PC of deferreturn for panic transfer
this removes the old conditional-on-register-value
handshake from the deferproc/deferprocstack logic.

The "line" for the recovery-exit frame itself (not the defers
that it runs) is the closing brace of the function.

Reduces code size slightly (e.g. go command is 0.2% smaller)

Sample output showing effect of this change, also what sort of
code it requires to observe the effect:
```
package main

import "os"

func main() {
	g(len(os.Args) - 1)           // stack[0]
}

var gi int
var pi *int = &gi

//go:noinline
func g(i int) {
	switch i {
	case 0:
		defer func() {
			println("g0", i)
			q()                  // stack[2] if i == 0
		}()
		for j := *pi; j < 1; j++ {
			defer func() {
				println("recover0", recover().(string))
			}()
		}
	default:
		for j := *pi; j < 1; j++ {
			defer func() {
				println("g1", i)
				q()              // stack[2] if i == 1
			}()
		}
		defer func() {
			println("recover1", recover().(string))
		}()
	}
	p()
}                                // stack[1] (deferreturn)

//go:noinline
func p() {
	panic("p()")
}

//go:noinline
func q() {
	panic("q()")                 // stack[3]
}

/* Sample output for "./foo foo":
recover1 p()
g1 1
panic: q()

goroutine 1 [running]:
main.q()
	.../main.go:46 +0x2c
main.g.func3()
	.../main.go:29 +0x48
main.g(0x1?)
	.../main.go:37 +0x68
main.main()
	.../main.go:6 +0x28
*/
```

Change-Id: Ie39ea62ecc244213500380ea06d44024cadc2317
Reviewed-on: https://go-review.googlesource.com/c/go/+/650795
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-25 08:35:38 -08:00
Robert Griesemer
6adf08f747 go/types, types2: remove coreType call in lookup
For #70128.

Change-Id: I7d16ad7fdc6b07a2632b4eaefaedfa2bcceffe1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/652215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2025-02-25 08:17:21 -08:00
Keith Randall
f69703d389 internal/abi: use arch family instead of arch string
No point in using string comparison when we can use integer comparison instead.

Unify the constants in cmd/internal/sys and internal/goarch while
we are at it.

Change-Id: I5681a601030307b7b286f958a8965559cb43506d
Reviewed-on: https://go-review.googlesource.com/c/go/+/652175
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-02-25 06:55:59 -08:00
Robert Griesemer
7194caf11b go/types, types2: remove another coreType call in type checking range clause
For #70128.

Change-Id: I5949bccbfaaebc435ae8ac7c70580d9740de6f00
Reviewed-on: https://go-review.googlesource.com/c/go/+/652136
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2025-02-25 06:23:44 -08:00
Robert Griesemer
549a88fa53 go/types, types2: better error messages for calls
Provide the exact error cause instead of reporting a missing
core type.

For #70128.

Change-Id: I34bd401115742883cb6aef7997477473b2464abb
Reviewed-on: https://go-review.googlesource.com/c/go/+/651256
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2025-02-25 06:21:12 -08:00
Robert Griesemer
d45d502fbb go/types, types2: better error messages for for-range clauses
Provide the exact error cause instead of reporting a missing
core type.

For #70128.

Change-Id: I835698fa1f22382711bd54b974d2c87ee17e9065
Reviewed-on: https://go-review.googlesource.com/c/go/+/651215
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
2025-02-25 06:21:10 -08:00
Jes Cok
bdcd6d1b65 strconv: use builtin min function in commonPrefixLenIgnoreCase
To make code a bit simpler.

Change-Id: I33b3e04bc810a4838584c477854ef612b355579a
GitHub-Last-Rev: 6d5bbc2a2877193e1319b9e626f408eda399666e
GitHub-Pull-Request: golang/go#71927
Reviewed-on: https://go-review.googlesource.com/c/go/+/651975
Reviewed-by: Ian Lance Taylor <iant@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>
2025-02-24 17:38:00 -08:00
Ian Lance Taylor
f77bba43aa net: accept a valid IP address in LookupMX
Fixes #56025

Change-Id: I202fdd0e11afeb22c5bc22d91fe4bfea8987e727
Reviewed-on: https://go-review.googlesource.com/c/go/+/651056
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-24 15:01:37 -08:00
qmuntal
dceee2e983 all: use testenv.Executable instead of os.Executable and os.Args[0]
In test files, using testenv.Executable is more reliable than
os.Executable or os.Args[0].

Change-Id: I88e577efeabc20d02ada27bf706ae4523129128e
Reviewed-on: https://go-review.googlesource.com/c/go/+/651955
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>
2025-02-24 11:03:10 -08:00
Harald Nordgren
2ee775fd9b net/http: remove unused err parameter from cancel
Change-Id: I91f1b93298671bcb2aa5f86a59f5794bd3e3b2a9
GitHub-Last-Rev: f2e7ffb45f7b201381e1f1a3018b523dea4249f8
GitHub-Pull-Request: golang/go#71911
Reviewed-on: https://go-review.googlesource.com/c/go/+/651220
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-24 10:13:30 -08:00
Olivier Mengué
3ff943fce0 net: add godoc links for UnixConn, UnixListener
Change-Id: I8f332eb14c0ce4f31a2e0f44ddd227769d7b940f
Reviewed-on: https://go-review.googlesource.com/c/go/+/651875
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>
Reviewed-by: Damien Neil <dneil@google.com>
2025-02-24 09:44:13 -08:00
Albert Sundjaja
fda9183899 syscall: allow \x00-prefixed unix abstract socket to use full path length
Fixes #70893

Change-Id: Ia0aaa497dad335fe962d52d3f115d26e8046e36f
GitHub-Last-Rev: 7dd663678d8aecdfac94541a570dfbd1aa2577e7
GitHub-Pull-Request: golang/go#71851
Reviewed-on: https://go-review.googlesource.com/c/go/+/650875
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-02-24 09:43:24 -08:00
Carlos Amedee
e382bf5b32 unique: use runtime.AddCleanup instead of runtime.SetFinalizer
Replace the usage of runtime.SetFinalizer with runtime.AddCleanup in
tests.

Updates #70907

Change-Id: I0d91b6af9643bde278215318f6176277373ddd19
Reviewed-on: https://go-review.googlesource.com/c/go/+/649458
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-24 09:11:32 -08:00
Joel Sing
fba83cdfc6 cmd/compile/internal/ssa: correct MOVDnop handling for arm64
The extension-removing rules for ARM64 were moved to late lower in
CL 568616. This means that the late lower pass can now generate
MOVDreg, however the rules that potentially eliminate MOVDreg only
exist in the earlier pass. Fix this by duplicating the MOVDreg/NOVDnop
rules in late lower, such that we can potentially eliminate conversions.

Removes 400+ instructions from the Go binary on openbsd/arm64.

Change-Id: I14aad06b994c9179f3ecdda566629793ba167511
Reviewed-on: https://go-review.googlesource.com/c/go/+/651819
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2025-02-23 12:04:15 -08:00
Joel Sing
a65078204c cmd/compile: remove carriage returns from AMD64latelower.rules
AMD64latelower.rules currently has Windows style line endings,
rather than Unix style line endings. Correct this.

Change-Id: Ie068dc6c64bd51cf2aa5bd192839fca4f28f40b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/651818
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-23 11:54:21 -08:00
Tobias Klauser
cf875b8af8 syscall: use sync.OnceFunc for copyenv
Change-Id: I64f658c1962878685ba7736f19d58e10fbdcb94a
Reviewed-on: https://go-review.googlesource.com/c/go/+/651835
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-23 11:53:16 -08:00
Dmitrii Martynov
4dfae6aad5 runtime: exclude allocation(s) from memmove/memclr benchmarking
The overhead for allocation is not significant but it should be excluded
from the memmove/memclr benchmarking anyway.

Change-Id: I7ea86d1b85b13352ccbff16f7510caa250654dab
Reviewed-on: https://go-review.googlesource.com/c/go/+/645576
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-23 09:38:24 -08:00
Than McIntosh
e7cd4979be cmd: initial compiler+linker support for DWARF5 .debug_addr
This patch rolls the main .debug_info DWARF section from version 4 to
version 5, and also introduces machinery in the Go compiler and linker
for taking advantage of the DWARF5 ".debug_addr" section for
subprogram DIE "high" and "low" PC attributes. All functionality is
gated by GOEXPERIMENT=dwarf5.

For the compiler portion of this patch, we add a new DIE attribute
form "DW_FORM_addrx", which accepts as an argument a function (text)
symbol.  The dwarf "putattr" function is enhanced to handle this
format by invoking a new dwarf context method "AddIndirectTextRef".
Under the hood, this method invokes the Lsym method WriteDwTxtAddrx,
which emits a new objabi.R_DWTXTADDR_* relocation. The size of the
relocation is dependent on the number of functions in the package; we
pick a size that is just big enough for the largest func index.

In the linker portion of this patch, we now switch over to writing out
a version number of 5 (instead of 4) in the compile unit header (this
is required if we want to use addrx attributes). In the parallel portion
of DWARF gen, within each compilation unit we scan subprogram DIEs to
look for R_DWTXTADDR_* relocations, and when we find such a reloc,
we assign a slot in the .debug_addr section for the func targeted.
After the parallel portion is complete, we then walk through all of the
compilation units to assign a value to their DW_AT_addr_base attribute,
which points to the portion of the single .debug_addr section containing
the text addrs for that compilation unit.

Note that once this patch is in, programs built with GOEXPERIMENT=dwarf5
will have broken/damaged DWARF info; in particular, since we've changed
only the CU and subprogram DIEs and haven't incorported the other
changes mandated by DWARF5 (ex: .debug_ranges => .debug_rnglists)
a lot of the variable location info will be missing/incorrect. This
will obviously change in subsequent patches.

Note also that R_DWTXTADDR_* can't be used effectively for lexical
scope DIE hi/lo PC attrs, since there isn't a viable way to encode
"addrx + constant" in the attribute value (you would need a new entry
for each attr endpoint in .debug_addr, which would defeat the point).

Updates #26379.

Change-Id: I2dfc45c9a8333e7b2a58f8e3b88fc8701fefd006
Reviewed-on: https://go-review.googlesource.com/c/go/+/635337
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-22 20:38:27 -08:00
Than McIntosh
282a14ec61 cmd/internal/objabi,cmd/link/internal/sym: add SDWARFADDR symbol type
Add a new symbol type: SDWARFADDR. This kind of symbol stores content
to be added to the DWARF .debug_addr section (new with DWARF5). At the
moment these symbols are created only in the linker, but it's not hard to
imagine other implementations in which the compiler would create them,
so they are added to both the compiler and linker symbol kind space.

Updates #26379.

Change-Id: I4a82ead0d59fe6028abfd6d6e3fc3df2e28c0ef6
Reviewed-on: https://go-review.googlesource.com/c/go/+/634415
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-22 13:32:37 -08:00
Than McIntosh
31b800abe6 cmd/internal/objabi: add new R_DWTXTADDR_* relocation types
Add a set of new relocations to be used when the compiler is writing
debug information using DWARF version 5. No changes in compiler or
linker functionality, this patch just adds the relocations themselves
and some helper functions; uses will appear in a later patch. These
relocations are generated by the compiler when writing a DWARF DIE
attribute of form DW_FORM_addrx, or when writing a .debug_addr index
reference in a SDWARFRANGE or SDWARFLOC section. The target symbol of
the relocation is a function (STEXT symbol); the linker resolves the
relocation by replacing the target of the reloc with an index of a
slot in the .debug_addr section (.debug_addr is new with DWARF5).

Updates #26379.

Change-Id: I43c587d25d0836972dac487d09c8924d77345f4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/633880
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>
2025-02-22 13:32:19 -08:00
Than McIntosh
767e7680ec cmd/link, cmd/internal/dwarf: add DWARF5 line table support
This patch rolls out the necessary changes to migrate the DWARF line
table support in the compiler and linker to DWARF version 5, gated by
the "dwarf5" GOEXPERIMENT.

DWARF version 5 includes a number of changes to the line table,
notably a revamped prolog section and a change in the indexing system
used to refer to files and directories within the line table
program. Specifically, prior to DWARF 4 a compilation's directory
table was considered to have an implicit zero entry containing the
compilation directory of the translation unit (package), and the file
table was considered to have an implicit zero entry storing the
"primary source file" (stored in the compilation unit DIE name).
DWARF 5 does away with these implicity entries meaning that files and
dirs are now effectively a 0-based index.

Updates #26379.

Change-Id: I9b4f1be5415aacec1ba57366d60bd48819c56ea5
Reviewed-on: https://go-review.googlesource.com/c/go/+/633879
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-22 13:31:52 -08:00
Than McIntosh
41a30dd192 cmd/internal/dwarf: add DW_LNCT and DW_UT constant definitions
Add a set of constants for the DWARF version 5 line table content
description values found in the V5 line table prolog, and for the
new DWARF unit type encodings.

Updates #26379.

Change-Id: I8f4989ea6b6cbb303deda1a6a20ad243d73b46b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/633878
Reviewed-by: 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>
2025-02-22 13:26:58 -08:00
Than McIntosh
bdb4676043 internal/goexperiment: add a new experiment to gate DWARF version 5
Add new experiment to enable generation of DWARF version 5 in
the compiler and linker.

Updates #26379.

Change-Id: I5e686a5e66d13b01e8cc8cd7c04f6fffd90d597b
Reviewed-on: https://go-review.googlesource.com/c/go/+/633877
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>
2025-02-22 13:26:47 -08:00
Than McIntosh
38825ef347 cmd/link, cmd/internal/objabi: remove R_DWARFFILEREF relocation type
Get rid of the R_DWARFFILEREF relocation type -- we have not used this
relocation for a while now, ever since jfaller's revamp of the DWARF
line table file section in Go 1.15. No change in compiler or linker
functionality; this is purely a dead code cleanup.

Change-Id: I178760c87f3aa79694cfabe7364ca382605c6975
Reviewed-on: https://go-review.googlesource.com/c/go/+/633876
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-22 13:25:22 -08:00
Ian Lance Taylor
f062d7b10b cmd/go: look at runes, not bytes, when printing env vars
For #58508
Fixes #71863

Change-Id: Ib1ebaf751bcc6900da6ffd01a9462dd237e2c89a
Reviewed-on: https://go-review.googlesource.com/c/go/+/651295
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-21 22:12:14 -08:00
Julian Zhu
e15d14873f internal/runtime/atomic: add Xchg8 for mipsx
For #69735

Change-Id: I2a0336214786e14b9a37834d81a0a0d14231451c
Reviewed-on: https://go-review.googlesource.com/c/go/+/651315
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-21 18:57:27 -08:00
Julian Zhu
1776255742 internal/bytealg: add assembly implementation of Count/CountString for mips64x
Add a simple assembly implementation of Count/CountString for mips64x.

name            old sec/op    new sec/op     vs base
CountSingle/10-4   31.16n ±  0%    41.69n ±  0%  +33.79% (p=0.000 n=11)
CountSingle/32-4   69.58n ±  0%    59.61n ±  0%  -14.33% (p=0.000 n=11)
CountSingle/4K-4   7.428µ ±  0%    5.153µ ±  0%  -30.63% (p=0.000 n=11)
CountSingle/4M-4   7.634m ±  0%    5.300m ±  0%  -30.58% (p=0.000 n=11)
CountSingle/64M-4   134.4m ±  0%    100.8m ±  3%  -24.99% (p=0.000 n=11)

name             old B/s      new B/s       vs base
CountSingle/10-4   306.1Mi ±  0%    228.8Mi ±  0%  -25.25% (p=0.000 n=11)
CountSingle/32-4   438.6Mi ±  0%    512.0Mi ±  0%  +16.74% (p=0.000 n=11)
CountSingle/4K-4   525.9Mi ±  0%    758.0Mi ±  0%  +44.15% (p=0.000 n=11)
CountSingle/4M-4   523.9Mi ±  0%    754.7Mi ±  0%  +44.05% (p=0.000 n=11)
CountSingle/64M-4  476.3Mi ±  0%    635.0Mi ±  0%  +33.31% (p=0.000 n=11)

Change-Id: Id5ddbea0d080e2903156ef8dc86c030a8179115b
Reviewed-on: https://go-review.googlesource.com/c/go/+/650995
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
2025-02-21 18:57:24 -08:00
Alan Yee
d7a1261d62 crypto/rand: add example for Int
Change-Id: I401e6092b1cbbd332406ffa7f923c46de0a3ff49
GitHub-Last-Rev: ef2057888465be3cff7fb60bc6ffe3d7573ec348
GitHub-Pull-Request: golang/go#71773
Reviewed-on: https://go-review.googlesource.com/c/go/+/650035
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-21 15:24:41 -08:00
Filippo Valsorda
f24b299df2 crypto/internal/fips140/nistec: make SetBytes constant time
Similarly to CL 648035, SetBytes doesn't need to be constant time for
the uses we make of it in the standard library (ECDH and ECDSA public
keys), but it doesn't cost much to make it constant time for users of
the re-exported package, or even just to save the next person from
convincing themselves that it's ok for it not to be constant time.

Change-Id: I6a6a465622a0de08d9fc71db75c63185a82aa54a
Reviewed-on: https://go-review.googlesource.com/c/go/+/650579
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-02-21 10:31:33 -08:00
Michael Anthony Knyszek
d93f6df0cc reflect: correctly handle method values in Seq
Currently method values aren't correctly handled in Seq because we call
canRangeFunc on the reciever type, not the method value type, when we're
handling a method value. reflect.Value.Type has the logic to obtain the
method value type from the Value.

This change slightly refactors reflect.Value.Type into a separate
function so we can obtain the correct type as an abi.Type and pass it
off to canRangeFunc (and canRangeFunc2).

Fixes #71874.

Change-Id: Ie62dfca2a84b8f2f816bb87ff1ed1a58a7bb8122
Reviewed-on: https://go-review.googlesource.com/c/go/+/651416
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-02-21 09:17:39 -08:00
Michael Pratt
e1e65ae3ee runtime: use WCLONE when waiting on pidfd test child
As of CL 650835, the pidfd test child no longer sends SIGCHLD on exit.
Per clone(2), "If [the child termination] signal is specified as
anything other than SIGCHLD, then the parent process must specify the
__WALL or __WCLONE options when waiting for the child with wait(2)."

Align with this requirement.

For #71828.

Change-Id: I6a6a636c739e4a59abe1533fe429a433e8588939
Reviewed-on: https://go-review.googlesource.com/c/go/+/651415
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-21 08:57:04 -08:00
qmuntal
64d82cd72c os: don't log the entire environment in tests
TestEnvironConsistency logs the values of all the environment variables,
which can be quite large on some environments. This change limits the
output to just the variables that caused the test to fail.

Change-Id: Ie796b57ac2cc845093c73298058b720df344fa28
Reviewed-on: https://go-review.googlesource.com/c/go/+/650581
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-20 22:15:35 -08:00
Thomas Vaillant
e1f02e9ae5 doc: add a disclamer for the TLS handshake timeouts TL;DR bug in godebug.md
Relates to #71257. Since post-quantum TLS algorithms are enabled by default, we should warn about the possible bugs with legacy servers (see https://tldr.fail/)

Change-Id: I06a5d8a927497ea2141007b14a90af27e0891720
GitHub-Last-Rev: 476e6462dfc7db8c2a47a25dcb7eb342264aabad
GitHub-Pull-Request: golang/go#71865
Reviewed-on: https://go-review.googlesource.com/c/go/+/651036
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-20 15:31:03 -08:00
Michael Pratt
af00524a6c debug/buildinfo: base64-encode test binaries
Overzealous security scanners don't like the Go 1.17 binary because they
think it has every 1.17 security vulnerability. base64-encode the binary
to hide from them.

I've also extended the instructions to make the binary easier to
reproduce.

Since we do the Go binary, we might as well do the C binary too, as it
apparently makes some virus scanners unhappy.

Fixes #71753.
For #71734.
For #71821.

Change-Id: I6a6a636cccbf5312522f52f27f74eded64048fb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/651175
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-20 14:20:00 -08:00
Cherry Mui
3b25b3c195 cmd/compile: remove residual register GC map code
We used to generate register GC maps as an experimental approach
for asynchronous preemption, which later we chose not to take.
Most of the register GC map code are already removed. One
exception is that the ssa.Register type still contains a field
for the register map index. Remove it.

Change-Id: Ib177ebce9548aa5ffbcaedd4b507240ea7df8afe
Reviewed-on: https://go-review.googlesource.com/c/go/+/651076
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-20 12:51:47 -08:00
Julian Zhu
266b0cff18 internal/runtime/atomic: add Xchg8 for mips64x
For #69735

Change-Id: Ide6b3077768a96b76078e5d4f6460596b8ff1560
Reviewed-on: https://go-review.googlesource.com/c/go/+/631756
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
2025-02-20 09:44:53 -08:00
Jorropo
00635de759 cmd/compile: don't report newLimit discovered when unsat happens multiple times
Fixes #71852

Change-Id: I696fcb8fc8c0c2e5e5ae6ab50596f6bdb9b7d498
Reviewed-on: https://go-review.googlesource.com/c/go/+/650975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-02-20 09:44:28 -08:00
Ian Lance Taylor
0de8fc8527 syscall: don't send child signal when testing pidfd
Avoid a spurious SIGCHLD the first time we start a process.

Fixes #71828

Change-Id: I744100d21bf6aaaaafc99bc5eec9f9f807a50682
Reviewed-on: https://go-review.googlesource.com/c/go/+/650835
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-20 09:20:38 -08:00
Jes Cok
458ac1b015 context: replace newAfterFuncContext with a global declaration using blank identifier
newAfterFuncContext has never been used, the only reason I can imagine
for its existence is to guarantee that the implementation is correct.

It is a small cleanup and make code more idiomatic.

Change-Id: I61ee213a9284f3c3bda7f91196f3a1604babd0f6
GitHub-Last-Rev: c08bd69ef3f0dbc2f573f54095fea35dad2b1145
GitHub-Pull-Request: golang/go#71856
Reviewed-on: https://go-review.googlesource.com/c/go/+/651015
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-20 08:16:29 -08:00
limeidan
b9630c56db cmd/internal/obj/loong64: optimize immediate loading
|        old       |      new                           |
                      |      sec/op      |    sec/op             vs base      |
BinaryTree17               11.08 ± 2%        11.16 ± 1%        ~ (p=0.529 n=10)
Fannkuch11                 2.716 ± 0%        2.737 ± 0%   +0.79% (p=0.000 n=10)
FmtFprintfEmpty           67.37n ± 0%       66.42n ± 0%   -1.41% (p=0.000 n=10)
FmtFprintfString          95.28n ± 0%       90.85n ± 0%   -4.64% (p=0.000 n=10)
FmtFprintfInt             97.69n ± 0%       98.06n ± 0%   +0.38% (p=0.000 n=10)
FmtFprintfIntInt          149.1n ± 0%       147.4n ± 0%   -1.14% (p=0.000 n=10)
FmtFprintfPrefixedInt     223.6n ± 0%       196.5n ± 0%  -12.10% (p=0.000 n=10)
FmtFprintfFloat           290.9n ± 0%       281.6n ± 1%   -3.21% (p=0.000 n=10)
FmtManyArgs               670.6n ± 0%       642.6n ± 0%   -4.18% (p=0.000 n=10)
GobDecode                 10.26m ± 1%       10.23m ± 1%        ~ (p=0.105 n=10)
GobEncode                 12.09m ± 1%       11.94m ± 1%   -1.24% (p=0.000 n=10)
Gzip                      316.9m ± 0%       315.9m ± 0%   -0.32% (p=0.001 n=10)
Gunzip                    65.48m ± 0%       59.77m ± 0%   -8.72% (p=0.000 n=10)
HTTPClientServer          70.36µ ± 0%       68.72µ ± 0%   -2.34% (p=0.000 n=10)
JSONEncode                13.61m ± 1%       13.19m ± 1%   -3.13% (p=0.000 n=10)
JSONDecode                57.52m ± 1%       54.15m ± 1%   -5.86% (p=0.000 n=10)
Mandelbrot200             4.577m ± 0%       4.572m ± 0%   -0.10% (p=0.002 n=10)
GoParse                   6.466m ± 0%       6.363m ± 0%   -1.58% (p=0.000 n=10)
RegexpMatchEasy0_32       89.20n ± 0%       87.72n ± 0%   -1.65% (p=0.000 n=10)
RegexpMatchEasy0_1K       748.6n ± 0%       907.6n ± 0%  +21.22% (p=0.000 n=10)
RegexpMatchEasy1_32       94.14n ± 0%       93.81n ± 0%   -0.35% (p=0.000 n=10)
RegexpMatchEasy1_1K       832.1n ± 0%       953.6n ± 0%  +14.59% (p=0.000 n=10)
RegexpMatchMedium_32      982.7n ± 0%      1018.0n ± 0%   +3.59% (p=0.000 n=10)
RegexpMatchMedium_1K      30.51µ ± 0%       30.00µ ± 0%   -1.65% (p=0.000 n=10)
RegexpMatchHard_32        1.721µ ± 0%       1.664µ ± 0%   -3.34% (p=0.000 n=10)
RegexpMatchHard_1K        50.76µ ± 0%       50.92µ ± 0%   +0.32% (p=0.000 n=10)
Revcomp                   870.5m ± 0%       710.5m ± 0%  -18.38% (p=0.000 n=10)
Template                  93.18m ± 1%       93.67m ± 1%        ~ (p=0.123 n=10)
TimeParse                 309.2n ± 0%       307.8n ± 0%   -0.45% (p=0.000 n=10)
TimeFormat                401.5n ± 0%       394.2n ± 0%   -1.82% (p=0.000 n=10)
geomean                   72.73µ            71.70µ        -1.41%

Change-Id: Id8d342ef3bb82a420434b2b841674683efef67be
Reviewed-on: https://go-review.googlesource.com/c/go/+/620737
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
2025-02-20 06:31:35 -08:00
Joel Sing
ad39fd9486 internal/bytealg: clean up and simplify the riscv64 equal implementation
Now that riscv64 is only regabi, remove the entrypoint separation and
have runtime.memequal_varlen call runtime.memequal. Add a zero byte
length check and replace the equal and not equal exit paths with a
single exit path that conditions on length reaching zero.

Cq-Include-Trybots: luci.golang.try:gotip-linux-riscv64
Change-Id: Ida4e54378daa7fd423f759753eba04ce513a27cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/648855
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-20 03:21:09 -08:00
Joel Sing
04de448c6d cmd/internal/obj/x86: add support for the endbr64 instruction on amd64
Add support for endbr64, which terminates an indirect branch in 64-bit
mode. This is effectively used to mark locations where an indirect branch
is permitted to land, when Indirect Branch Tracking (IBT) is enforced on
Intel CPUs.

Updates #66054

Change-Id: Ib898031711cfaaa6e05c197bfe727ded0bce6f52
Reviewed-on: https://go-review.googlesource.com/c/go/+/649215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-20 03:20:03 -08:00
Roland Shoemaker
9b842e2e63 crypto/tls: improve ech parsing errors
Make the errors we return when parsing an ECHConfig slightly more
verbose.

Fixes #71706

Change-Id: Id138fd9defec71ce492a490a71af4981cb9ede51
Reviewed-on: https://go-review.googlesource.com/c/go/+/650720
Auto-Submit: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-19 19:33:58 -08:00
Roland Shoemaker
3013231f46 crypto/tls: fix incorrect EncryptedClientHelloKey comment
Updates #71706

Change-Id: Id689ec476eb3f76500dbf59d716a4376749de700
Reviewed-on: https://go-review.googlesource.com/c/go/+/650719
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-19 19:33:55 -08:00
Daniel Martí
07a121383c go/*: use go/types.Func.Signature and go/ast.Preorder
In the few obvious candidates that I found after a bit of grepping.

Change-Id: I36af79c46d29e4422bce1f43bbbac9db7de2001a
Reviewed-on: https://go-review.googlesource.com/c/go/+/650656
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-19 19:25:33 -08:00
Meng Zhuo
cdc9560794 all: implement plugin build mode for riscv64
Change-Id: I8d7bbeebbf4a46f2fd8d630b1edbaf79b8ffccc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/420114
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
TryBot-Bypass: Joel Sing <joel@sing.id.au>
2025-02-19 17:54:34 -08:00
Julian Zhu
58083b57d4 internal/runtime/atomic: add Xchg8 for riscv64
For #69735

Change-Id: I34ca2b027494525ab64f94beee89ca373a5031ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/631615
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-19 17:34:41 -08:00
Michael Pratt
0d8c512ce9 internal/poll: note that copy_file_range bug is fixed
We shouldn't drop the workaround in case we're running on an unpatched
kernel.

For #44272.

Change-Id: I6a6a636cb81c31856ac9b682e7d02fa1d8efa5d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/644878
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@golang.org>
2025-02-19 14:50:50 -08:00
Michael Anthony Knyszek
57cd75a351 runtime: minor mfinal.go code cleanup
This change moves finBlockSize into mfinal.go and renames finblock to
finBlock.

Change-Id: I20a0bc3907e7b028a2caa5d2fe8cf3f76332c871
Reviewed-on: https://go-review.googlesource.com/c/go/+/650695
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-19 14:25:03 -08:00
Michael Anthony Knyszek
6d7cb594b3 weak: accept linker-allocated objects to Make
Currently Make panics when passed a linker-allocated object. This is
inconsistent with both runtime.AddCleanup and runtime.SetFinalizer. Not
panicking in this case is important so that all pointers can be treated
equally by these APIs. Libraries should not have to worry where a
pointer came from to still make weak pointers.

Supporting this behavior is a bit complex for weak pointers versus
finalizers and cleanups. For the latter two, it means a function is
never called, so we can just drop everything on the floor. For weak
pointers, we still need to produce pointers that compare as per the API.
To do this, copy the tiny lock-free trace map implementation and use it
to store weak handles for "immortal" objects. These paths in the
runtime should be rare, so it's OK if it's not incredibly fast, but we
should keep the memory footprint relatively low (at least not have it be
any worse than specials), so this change tweaks the map implementation a
little bit to ensure that's the case.

Fixes #71726.

Change-Id: I0c87c9d90656d81659ac8d70f511773d0093ce27
Reviewed-on: https://go-review.googlesource.com/c/go/+/649460
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-19 14:25:00 -08:00
Rob Findley
51f3ca3594 go/types,types2: remove some unused parameters and results (cleanup)
This CL is the result of pulling the thread of some unused parameter
diagnostics reported by gopls: remove some variables holding partial
type argument expression information that are no longer needed.

Change-Id: Idfc1d0271252ce9bc5b75feb86e30dd2f6dd550b
Reviewed-on: https://go-review.googlesource.com/c/go/+/650775
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
2025-02-19 14:15:03 -08:00
Dan Peterson
f2ac0ae8bb cmd/go/internal/cacheprog: drop Request.ObjectID
ObjectID was a misnaming of OutputID from cacheprog's initial
implementation. It was maintained for compatibility with existing
cacheprog users in 1.24 but can be removed in 1.25.

Updates #64876

Change-Id: I8ff53bc581c16b7739e1cfbaa8bd35d285d3231d
Reviewed-on: https://go-review.googlesource.com/c/go/+/649435
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-19 13:49:56 -08:00
alirezaarzehgar
a2c959fe97 html/template: add available godoc link
Change-Id: I50404dbf0f10ee59007bd0dc5353f38e056a0430
Reviewed-on: https://go-review.googlesource.com/c/go/+/650655
Reviewed-by: Michael Knyszek <mknyszek@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>
2025-02-19 13:39:04 -08:00
Mateusz Poliwczak
7a33f793e8 cmd/compile/internal/ir: correct doc comment, miniNode in now 12 bytes
Change-Id: I5887565077f598bc7e3edc4b78188956fb13cdaa
GitHub-Last-Rev: 479a04b42e9dc2ffc72cb599ebb12b8fc669fe20
GitHub-Pull-Request: golang/go#71822
Reviewed-on: https://go-review.googlesource.com/c/go/+/650415
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-19 13:39:02 -08:00
Mateusz Poliwczak
43e6525986 cmd/compile: load properly constant values from itabs
While looking at the SSA of following code, i noticed
that these rules do not work properly, and the types
are loaded indirectly through an itab, instead of statically.

type M interface{ M() }
type A interface{ A() }

type Impl struct{}
func (*Impl) M() {}
func (*Impl) A() {}

func main() {
        var a M = &Impl{}
        a.(A).A()
}

Change-Id: Ia275993f81a2e7302102d4ff87ac28586023d13c
GitHub-Last-Rev: 4bfc9019172929d0b0f1c8a1b7eb28cdbc9b87ef
GitHub-Pull-Request: golang/go#71784
Reviewed-on: https://go-review.googlesource.com/c/go/+/649500
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2025-02-19 13:39:00 -08:00
Mateusz Poliwczak
ba3f568988 cmd/compile: determine static values of len and cap in make() calls
This change improves escape analysis by attempting to
deduce static values for the len and cap parameters,
allowing allocations to be made on the stack.

Change-Id: I1161019aed9f60cf2c2fe4d405da94ad415231ac
GitHub-Last-Rev: d78c1b4ca55fa53282e665009f689d0b013f1434
GitHub-Pull-Request: golang/go#71693
Reviewed-on: https://go-review.googlesource.com/c/go/+/649035
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2025-02-19 13:38:58 -08:00
Roland Shoemaker
28d7eec3a2 crypto/internal/fips140/drbg: add Counter warning
The support we provide is tightly scoped, and is not safe for generic
usage elsewhere in the standard library.

Change-Id: Ic38d5c4b416859ab30e2b4a3fc977ba8a2535ae8
Reviewed-on: https://go-review.googlesource.com/c/go/+/647815
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
2025-02-19 12:54:48 -08:00
qiulaidongfeng
abd0239113 go/parser: deprecate parser.ParseDir
Fixes #71122

Change-Id: Icaf27842f4a42e11eea4bd2203eba5d56610c196
Reviewed-on: https://go-review.googlesource.com/c/go/+/649275
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: 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>
Auto-Submit: Alan Donovan <adonovan@google.com>
2025-02-19 11:49:13 -08:00
Michael Matloob
3f46587fe0 cmd/go: explicitly reject overlays affecting GOMODCACHE
The go command assumes that GOMODCACHE is immutable. As an example of
one place the assumption is made, the modindex won't stat the files in
GOMODCACHE when getting the cache key for the index entry and just uses
the path of the module in the modcache (basically the module's name and
version). Explicitly reject overlays affecting GOMODCACHE to avoid
surprising and incorrect behavior.

For #71783
For #71075

Change-Id: I21dd5d39d71037de473b09ac8482a1867864e11f
Reviewed-on: https://go-review.googlesource.com/c/go/+/650475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2025-02-19 11:26:45 -08:00
Jes Cok
3c05790d48 bytes,strings: remove redundant return statement for Lines
To make it more idiomatic.

Change-Id: If48ae9931908e515df7f23185aac6f84aac72084
GitHub-Last-Rev: 525ed5031a08388f637bd2a09bd47c9e25df21f1
GitHub-Pull-Request: golang/go#71838
Reviewed-on: https://go-review.googlesource.com/c/go/+/650595
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Commit-Queue: Robert Griesemer <gri@google.com>
2025-02-19 10:22:08 -08:00
qmuntal
6e0a81ac61 path/filepath: use RtlIsDosDeviceName_U to detect Windows devices
RtlIsDosDeviceName_U is specifically designed to detect Windows devices.
We were using GetFullPathName to do this, but it's not the right API
for the job, as it is slower and allocates more memory.

goos: windows
goarch: amd64
pkg: path/filepath
cpu: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
           │   old.txt    │               new.txt                │
           │    sec/op    │    sec/op     vs base                │
IsLocal-12   5.685µ ± 59%   1.853µ ± 12%  -67.41% (p=0.000 n=10)

           │   old.txt   │              new.txt               │
           │    B/op     │    B/op     vs base                │
IsLocal-12   496.00 ± 0%   48.00 ± 0%  -90.32% (p=0.000 n=10)

           │   old.txt   │              new.txt               │
           │  allocs/op  │ allocs/op   vs base                │
IsLocal-12   10.000 ± 0%   6.000 ± 0%  -40.00% (p=0.000 n=10)

Change-Id: Ib40ad7a90ab93cf7051c8d6becbce4d287f10f4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/650578
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-02-19 09:41:00 -08:00
David Chase
9ddeac30b5 cmd/compile, runtime: use deferreturn as target PC for recover from deferrangefunc
The existing code for recover from deferrangefunc was broken in
several ways.

1. the code following a deferrangefunc call did not check the return
value for an out-of-band value indicating "return now" (i.e., recover
was called)

2. the returned value was delivered using a bespoke ABI that happened
to match on register-ABI platforms, but not on older stack-based
ABI.

3. the returned value was the wrong width (1 word versus 2) and
type/value(integer 1, not a pointer to anything) for deferrangefunc's
any-typed return value (in practice, the OOB value check could catch
this, but still, it's sketchy).

This -- using the deferreturn lookup method already in place for
open-coded defers -- turned out to be a much-less-ugly way of
obtaining the desired transfer of control for recover().

TODO: we also could do this for regular defer, and delete some code.

Fixes #71675

Change-Id: If7d7ea789ad4320821aab3b443759a7d71647ff0
Reviewed-on: https://go-review.googlesource.com/c/go/+/650476
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2025-02-19 08:27:06 -08:00
qmuntal
4267fd389e syscall: don't truncate newly created files on Windows
There is no need for syscall.OpenFile to truncate newly created files.
Some special Windows files, like the NUL device, can't be
truncated, so we should avoid truncating unless it is really necessary.

Fixes #71752.

Change-Id: I8238048594f706f6a5281053d55cfe3dc898828d
Reviewed-on: https://go-review.googlesource.com/c/go/+/650276
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-19 04:43:02 -08:00
Cuong Manh Le
a08984bc8f cmd/compile: add ir.ContainsClosure
And use it to unify all codes that need parent/closure checking.

Change-Id: I0b0aa1b007598668dff2c4bee31e21f0fb3830ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/650315
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-18 17:52:54 -08:00
Cuong Manh Le
34073a736a cmd/compile: avoid infinite recursion when inlining closures
CL 630696 changes budget for once-called closures, making them more
inlinable. However, when recursive inlining involve both the closure and
its parent, the inliner goes into an infinite loop:

	parent (a closure)  -> closure -> parent -> ...

The problem here dues to the closure name mangling, causing the inlined
checking condition failed, since the closure name affects how the
linker symbol generated.

To fix this, just prevent the closure from inlining its parent into
itself, avoid the infinite inlining loop.

Fixes #71680

Change-Id: Ib27626d70f95e5f1c24a3eb1c8e6c3443b7d90c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/649656
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-18 17:52:51 -08:00
Mateusz Poliwczak
a7489b8648 cmd/compile/internal/ir: reduce size of miniExpr by 8 bytes
By moving the bit field, we can reduce the miniExpr size by
8 bytes, reducing the sizes of Exprs embedding this type.
Hopefully we get a few types to a lower memory size class.

Change-Id: I4b1d4471cf905f998b26d235980e40ca91446f45
GitHub-Last-Rev: 6dea0bd27c38d9118d13d55052efcb4070b26751
GitHub-Pull-Request: golang/go#71823
Reviewed-on: https://go-review.googlesource.com/c/go/+/650435
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2025-02-18 17:51:54 -08:00
段仪
279da96532 runtime: add some linknames back for github.com/bytedance/sonic
Add some linknames back, therefore sonic (github.com/bytedance/sonic) can work correctly.

Fixes #71672

Change-Id: Iae86c837d8a714855106a26766aa08b128e17e58
GitHub-Last-Rev: 4de0a4871766f9e7763394fdcdcaa9d683e97987
GitHub-Pull-Request: golang/go#71673
Reviewed-on: https://go-review.googlesource.com/c/go/+/648537
Reviewed-by: Michael Pratt <mpratt@google.com>
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>
2025-02-18 10:23:57 -08:00
Damien Neil
fcdf444924 os: document that OpenRoot follows symlinks
OpenRoot is expected to be called with a trusted path,
and does not attempt to defend against symlinks in that path.

Fixes #71806

Change-Id: Ib8b2e123e323d22d5c23ed9f711d21995139a7ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/650355
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>
2025-02-18 10:00:13 -08:00
Zxilly
ad8b33002b syscall: disable O_DIRECTORY on Windows for js/wasm
O_DIRECTORY is not available on all platforms, as described at

https://nodejs.org/docs/latest/api/fs.html#file-open-constants .

On Windows, only O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR,
O_TRUNC, O_WRONLY, and UV_FS_O_FILEMAP are available.

Fixes #71758

Change-Id: Iacc890ba9a30dcd75eb746ec324fa0c3e368048e
GitHub-Last-Rev: a0160e8fc82583c4f903ae165fe9f204896cf56d
GitHub-Pull-Request: golang/go#71770
Reviewed-on: https://go-review.googlesource.com/c/go/+/650015
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
2025-02-18 09:30:04 -08:00
cuishuang
0bdc792145 all: use a more straightforward return value
Change-Id: I27e86c221da7f541c4823f501801e02942c9a829
Reviewed-on: https://go-review.googlesource.com/c/go/+/649935
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-18 09:28:50 -08:00
Luka Krmpotić
a3d11d280d go/format: format comment to match code
Change-Id: I9434a8d04ca4282da86cb2622a6a541db3961a2b
GitHub-Last-Rev: f28908e338e9160ca3d4033161647832fdd76840
GitHub-Pull-Request: golang/go#71763
Reviewed-on: https://go-review.googlesource.com/c/go/+/649955
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-02-18 09:27:46 -08:00
Jes Cok
43d8b1e8fe os: deal with chmod error for TestRootConsistencyChmod
Previously the error returned by chmod has not actually been used.

Change-Id: I97c947a2278a084c58784fd100630ce2a54bfb03
GitHub-Last-Rev: ddc60a044f641d264c9ee88d87b2da7e2f766741
GitHub-Pull-Request: golang/go#71744
Reviewed-on: https://go-review.googlesource.com/c/go/+/649418
Reviewed-by: Michael Knyszek <mknyszek@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>
2025-02-18 09:27:42 -08:00
Mauri de Souza Meneguzzo
896de17f80 cmd/cgo: explicitly use void for functions with no parameters
Currently, exported Go functions with no parameters generate C functions
with an empty parameter list. In C, a function with an empty parameter
list can accept any number of arguments, whereas a function with a single
void parameter explicitly declares that it takes no arguments.

To align the generated C functions with their Go prototypes, update the
code generation to explicitly include a void parameter for functions
with no parameters.

Fixes #68411

Change-Id: Iab9456aa0236200bf21d1181a2e18e82869df63f
GitHub-Last-Rev: 6ff21a98dfef81df649c76221d9c0858dc0e35e1
GitHub-Pull-Request: golang/go#70981
Reviewed-on: https://go-review.googlesource.com/c/go/+/638635
Reviewed-by: Michael Knyszek <mknyszek@google.com>
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>
2025-02-18 09:27:34 -08:00
Joel Sing
a73c6545d2 crypto/internal/fips140deps/cpu: use const and var blocks
Rather than repeating ourselves, use a single const block and a single
var block. Also separate architectures for readability.

Change-Id: Iab5bda3514eae0c9b5bb16a99277fd4b95f272aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/649658
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Joel Sing <joel@sing.id.au>
2025-02-18 09:03:31 -08:00
qmuntal
c47d1aa787 runtime: remove unused fipstls_runtime_arg0 function
fipstls_runtime_arg0 is unused since CL 629675.

Change-Id: I981e55e95f4d1cbd33f4c438c1947ec39385376b
Reviewed-on: https://go-review.googlesource.com/c/go/+/631215
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: 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>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-18 09:03:18 -08:00
Nicolas Hillegeer
5295722238 runtime: print pp.schedtick in scheddetail even when !detailed
Provides, on one line, an approximation of P scheduling throughput: how
many times execute() was called for a given P. Said another way: how
many RUNNABLE to RUNNING transitions have happened for this P.

This allows discerning whether a P actually did anything, and how it
compares to other periods of a processes operation.

This should be useful to analyze (kernel) scheduler hiccups.

Investigators will want to subtract the tick values from subsequent
schedtrace lines to get a rate of schedulings. I've opted to add a space
around the first and last element as well to make it more uniform to do
the proposed subtracting with tools like AWK.

Change-Id: I69d6dae1509ad285d43799f38bcaa3aa0fb2352e
Reviewed-on: https://go-review.googlesource.com/c/go/+/635636
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Nicolas Hillegeer <aktau@google.com>
2025-02-18 08:13:49 -08:00
Nicolas Hillegeer
ecda82012d runtime: only read pp.m in schedtrace if needed
Change-Id: Iad3353431a2ef97c1e0c440bdd84b78cb5ea990e
Reviewed-on: https://go-review.googlesource.com/c/go/+/635635
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Nicolas Hillegeer <aktau@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-18 08:13:46 -08:00
Andrey Bokhanko
81c66e71d4 runtime: check LSE support on ARM64 at runtime init
Check presence of LSE support on ARM64 chip if we targeted it at compile
time.

Related to #69124
Updates #60905
Fixes #71411

Change-Id: I65e899a28ff64a390182572c0c353aa5931fc85d
Reviewed-on: https://go-review.googlesource.com/c/go/+/645795
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2025-02-17 18:02:01 -08:00
Jakub Ciolek
d524e1eccd cmd/compile: on AMD64, turn x < 128 into x <= 127
x < 128 -> x <= 127
x >= 128 -> x > 127

This allows for shorter encoding as 127 fits into
a single-byte immediate.

archive/tar benchmark (Alder Lake 12600K)

name              old time/op    new time/op    delta
/Writer/USTAR-16    1.46µs ± 0%    1.32µs ± 0%  -9.43%  (p=0.008 n=5+5)
/Writer/GNU-16      1.85µs ± 1%    1.79µs ± 1%  -3.47%  (p=0.008 n=5+5)
/Writer/PAX-16      3.21µs ± 0%    3.11µs ± 2%  -2.96%  (p=0.008 n=5+5)
/Reader/USTAR-16    1.38µs ± 1%    1.37µs ± 0%    ~     (p=0.127 n=5+4)
/Reader/GNU-16       798ns ± 1%     800ns ± 2%    ~     (p=0.548 n=5+5)
/Reader/PAX-16      3.07µs ± 1%    3.00µs ± 0%  -2.35%  (p=0.008 n=5+5)
[Geo mean]          1.76µs         1.70µs       -3.15%

compilecmp:

hash/maphash
hash/maphash.(*Hash).Write 517 -> 510  (-1.35%)

runtime
runtime.traceReadCPU 1626 -> 1615  (-0.68%)

runtime [cmd/compile]
runtime.traceReadCPU 1626 -> 1615  (-0.68%)

math/rand/v2
type:.eq.[128]float32 65 -> 59  (-9.23%)

bytes
bytes.trimLeftUnicode 378 -> 373  (-1.32%)
bytes.IndexAny 1189 -> 1157  (-2.69%)
bytes.LastIndexAny 1256 -> 1239  (-1.35%)
bytes.lastIndexFunc 263 -> 261  (-0.76%)

strings
strings.FieldsFuncSeq.func1 411 -> 399  (-2.92%)
strings.EqualFold 625 -> 624  (-0.16%)
strings.trimLeftUnicode 248 -> 231  (-6.85%)

math/rand
type:.eq.[128]float32 65 -> 59  (-9.23%)

bytes [cmd/compile]
bytes.LastIndexAny 1256 -> 1239  (-1.35%)
bytes.lastIndexFunc 263 -> 261  (-0.76%)
bytes.trimLeftUnicode 378 -> 373  (-1.32%)
bytes.IndexAny 1189 -> 1157  (-2.69%)

regexp/syntax
regexp/syntax.(*parser).parseEscape 1113 -> 1102  (-0.99%)

math/rand/v2 [cmd/compile]
type:.eq.[128]float32 65 -> 59  (-9.23%)

strings [cmd/compile]
strings.EqualFold 625 -> 624  (-0.16%)
strings.FieldsFuncSeq.func1 411 -> 399  (-2.92%)
strings.trimLeftUnicode 248 -> 231  (-6.85%)

math/rand [cmd/compile]
type:.eq.[128]float32 65 -> 59  (-9.23%)

regexp
regexp.(*inputString).context 198 -> 197  (-0.51%)
regexp.(*inputBytes).context 221 -> 212  (-4.07%)

image/jpeg
image/jpeg.(*decoder).processDQT 500 -> 491  (-1.80%)

regexp/syntax [cmd/compile]
regexp/syntax.(*parser).parseEscape 1113 -> 1102  (-0.99%)

regexp [cmd/compile]
regexp.(*inputString).context 198 -> 197  (-0.51%)
regexp.(*inputBytes).context 221 -> 212  (-4.07%)

encoding/csv
encoding/csv.(*Writer).fieldNeedsQuotes 269 -> 266  (-1.12%)

cmd/vendor/golang.org/x/sys/unix
type:.eq.[131]struct 855 -> 823  (-3.74%)

vendor/golang.org/x/text/unicode/norm
vendor/golang.org/x/text/unicode/norm.nextDecomposed 4831 -> 4826  (-0.10%)
vendor/golang.org/x/text/unicode/norm.(*Iter).returnSlice 281 -> 275  (-2.14%)

vendor/golang.org/x/text/secure/bidirule
vendor/golang.org/x/text/secure/bidirule.init.0 85 -> 83  (-2.35%)

go/scanner
go/scanner.isDigit 100 -> 98  (-2.00%)
go/scanner.(*Scanner).next 431 -> 422  (-2.09%)
go/scanner.isLetter 142 -> 124  (-12.68%)

encoding/asn1
encoding/asn1.parseTagAndLength 1189 -> 1182  (-0.59%)
encoding/asn1.makeField 3481 -> 3463  (-0.52%)

text/scanner
text/scanner.(*Scanner).next 1242 -> 1236  (-0.48%)

archive/tar
archive/tar.isASCII 133 -> 127  (-4.51%)
archive/tar.(*Writer).writeRawFile 1206 -> 1198  (-0.66%)
archive/tar.(*Reader).readHeader.func1 9 -> 7  (-22.22%)
archive/tar.toASCII 393 -> 383  (-2.54%)
archive/tar.splitUSTARPath 405 -> 396  (-2.22%)
archive/tar.(*Writer).writePAXHeader.func1 627 -> 620  (-1.12%)

text/template
text/template.jsIsSpecial 59 -> 57  (-3.39%)

go/doc
go/doc.assumedPackageName 714 -> 701  (-1.82%)

vendor/golang.org/x/net/http/httpguts
vendor/golang.org/x/net/http/httpguts.headerValueContainsToken 965 -> 952  (-1.35%)
vendor/golang.org/x/net/http/httpguts.tokenEqual 280 -> 269  (-3.93%)
vendor/golang.org/x/net/http/httpguts.IsTokenRune 28 -> 26  (-7.14%)

net/mail
net/mail.isVchar 26 -> 24  (-7.69%)
net/mail.isAtext 106 -> 104  (-1.89%)
net/mail.(*Address).String 1084 -> 1052  (-2.95%)
net/mail.isQtext 39 -> 37  (-5.13%)
net/mail.isMultibyte 9 -> 7  (-22.22%)
net/mail.isDtext 45 -> 43  (-4.44%)
net/mail.(*addrParser).consumeQuotedString 1050 -> 1029  (-2.00%)
net/mail.quoteString 741 -> 714  (-3.64%)

cmd/internal/obj/s390x
cmd/internal/obj/s390x.preprocess 6405 -> 6393  (-0.19%)

cmd/internal/obj/x86
cmd/internal/obj/x86.toDisp8 303 -> 301  (-0.66%)

fmt [cmd/compile]
fmt.Fprintf 4726 -> 4662  (-1.35%)

go/scanner [cmd/compile]
go/scanner.(*Scanner).next 431 -> 422  (-2.09%)
go/scanner.isLetter 142 -> 124  (-12.68%)
go/scanner.isDigit 100 -> 98  (-2.00%)

cmd/compile/internal/syntax
cmd/compile/internal/syntax.(*source).nextch 879 -> 847  (-3.64%)

cmd/vendor/golang.org/x/mod/module
cmd/vendor/golang.org/x/mod/module.checkElem 1253 -> 1235  (-1.44%)
cmd/vendor/golang.org/x/mod/module.escapeString 519 -> 517  (-0.39%)

go/doc [cmd/compile]
go/doc.assumedPackageName 714 -> 701  (-1.82%)

cmd/compile/internal/syntax [cmd/compile]
cmd/compile/internal/syntax.(*scanner).escape 1965 -> 1933  (-1.63%)
cmd/compile/internal/syntax.(*scanner).next 8975 -> 8847  (-1.43%)

cmd/internal/obj/s390x [cmd/compile]
cmd/internal/obj/s390x.preprocess 6405 -> 6393  (-0.19%)

cmd/internal/obj/x86 [cmd/compile]
cmd/internal/obj/x86.toDisp8 303 -> 301  (-0.66%)

cmd/internal/gcprog
cmd/internal/gcprog.(*Writer).Repeat 688 -> 677  (-1.60%)
cmd/internal/gcprog.(*Writer).varint 442 -> 439  (-0.68%)

cmd/compile/internal/ir
cmd/compile/internal/ir.splitPkg 331 -> 325  (-1.81%)

cmd/compile/internal/ir [cmd/compile]
cmd/compile/internal/ir.splitPkg 331 -> 325  (-1.81%)

net/http
net/http.containsDotDot.FieldsFuncSeq.func1 411 -> 399  (-2.92%)
net/http.isNotToken 33 -> 30  (-9.09%)
net/http.containsDotDot 606 -> 588  (-2.97%)
net/http.isCookieNameValid 197 -> 191  (-3.05%)
net/http.parsePattern 4330 -> 4317  (-0.30%)
net/http.ParseCookie 1099 -> 1096  (-0.27%)
net/http.validMethod 197 -> 187  (-5.08%)

cmd/vendor/golang.org/x/text/unicode/norm
cmd/vendor/golang.org/x/text/unicode/norm.(*Iter).returnSlice 281 -> 275  (-2.14%)
cmd/vendor/golang.org/x/text/unicode/norm.nextDecomposed 4831 -> 4826  (-0.10%)

net/http/cookiejar
net/http/cookiejar.encode 1936 -> 1918  (-0.93%)

expvar
expvar.appendJSONQuote 972 -> 965  (-0.72%)

cmd/cgo/internal/test
cmd/cgo/internal/test.stack128 116 -> 114  (-1.72%)

cmd/vendor/rsc.io/markdown
cmd/vendor/rsc.io/markdown.newATXHeading 1637 -> 1628  (-0.55%)
cmd/vendor/rsc.io/markdown.isUnicodePunct 197 -> 179  (-9.14%)

Change-Id: I578bdf42ef229d687d526e378d697ced51e1880c
Reviewed-on: https://go-review.googlesource.com/c/go/+/639935
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>
Reviewed-by: Keith Randall <khr@google.com>
2025-02-16 07:23:13 -08:00
Artyom Litovets
d5b75e4046 runtime/maps: fix typo in group.go comment (H1 -> H2)
Fixes a typo to correctly describe the hash bits of the control word.

Change-Id: Id3c2ae0bd529e579a95258845f9d8028e23d10d2
GitHub-Last-Rev: 1baa81be5d292d5625d5d7788b8ea090453f962c
GitHub-Pull-Request: golang/go#71730
Reviewed-on: https://go-review.googlesource.com/c/go/+/649416
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-16 06:25:04 -08:00
Roland Shoemaker
b38415d7e9 crypto/internal/boring: remove unnecessary struct field
That could result in a hanging pointer.

Change-Id: I547950a3d3010e03b75f70f5f021f20124e2cef0
Reviewed-on: https://go-review.googlesource.com/c/go/+/644120
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: 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>
2025-02-15 21:47:27 -08:00
Alan Donovan
586e205522 std: add //go:fix inline directives to some deprecated functions
In particular, we apply it only to functions where it is always
a code improvement to inline the call.
We also apply it to some constants.

In a few cases this may introduce a panic statement at the
caller, which is debatable, but making the potential for panic
evident is the purpose of the deprecation.

The gofix analyzer in gopls v0.18 will show a diagnostic for calls
to the annotated functions, and will offer to inline the call.

The new //go:fix annotation needs a special exemption in the
pragma check in the compiler.

Updates #32816

Change-Id: I43bf15648ac12251734109eb7102394f8a76d55e
Reviewed-on: https://go-review.googlesource.com/c/go/+/648995
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-15 08:06:58 -08:00
Keith Randall
beac2f7d3b cmd/compile: fix sign extension of paired 32-bit loads on arm64
Fixes #71759

Change-Id: Iab05294ac933cc9972949158d3fe2bdc3073df5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/649895
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>
2025-02-15 07:53:28 -08:00
Joel Sing
c62c69dd5c crypto/internal/fips140/subtle: provide riscv64 assembly implementation for xorBytes
Provide a riscv64 assembly implementation of xorBytes, which
can process up to 64 bytes per loop and has better handling
for unaligned inputs. This provides a considerable performance
gain compared to the generic code.

On a StarFive VisionFive 2:

                                     │   subtle.1   │              subtle.2               │
                                     │    sec/op    │   sec/op     vs base                │
XORBytes/8Bytes-4                       59.54n ± 0%   58.15n ± 0%   -2.33% (p=0.000 n=10)
XORBytes/128Bytes-4                    125.60n ± 0%   74.93n ± 0%  -40.35% (p=0.000 n=10)
XORBytes/2048Bytes-4                   1088.5n ± 0%   602.4n ± 0%  -44.66% (p=0.000 n=10)
XORBytes/8192Bytes-4                    4.163µ ± 0%   2.271µ ± 0%  -45.45% (p=0.000 n=10)
XORBytes/32768Bytes-4                   35.47µ ± 0%   28.12µ ± 0%  -20.74% (p=0.000 n=10)
XORBytesUnaligned/8Bytes0Offset-4       59.80n ± 0%   57.48n ± 0%   -3.86% (p=0.000 n=10)
XORBytesUnaligned/8Bytes1Offset-4       72.97n ± 0%   57.48n ± 0%  -21.23% (p=0.000 n=10)
XORBytesUnaligned/8Bytes2Offset-4       72.97n ± 0%   57.50n ± 0%  -21.21% (p=0.000 n=10)
XORBytesUnaligned/8Bytes3Offset-4       72.99n ± 0%   57.48n ± 0%  -21.26% (p=0.000 n=10)
XORBytesUnaligned/8Bytes4Offset-4       72.96n ± 0%   57.44n ± 0%  -21.28% (p=0.000 n=10)
XORBytesUnaligned/8Bytes5Offset-4       72.93n ± 0%   57.48n ± 0%  -21.18% (p=0.000 n=10)
XORBytesUnaligned/8Bytes6Offset-4       72.97n ± 0%   57.47n ± 0%  -21.25% (p=0.000 n=10)
XORBytesUnaligned/8Bytes7Offset-4       72.96n ± 0%   57.47n ± 0%  -21.24% (p=0.000 n=10)
XORBytesUnaligned/128Bytes0Offset-4    125.30n ± 0%   74.18n ± 0%  -40.80% (p=0.000 n=10)
XORBytesUnaligned/128Bytes1Offset-4     557.4n ± 0%   131.1n ± 0%  -76.48% (p=0.000 n=10)
XORBytesUnaligned/128Bytes2Offset-4     557.3n ± 0%   132.5n ± 0%  -76.22% (p=0.000 n=10)
XORBytesUnaligned/128Bytes3Offset-4     557.6n ± 0%   133.7n ± 0%  -76.02% (p=0.000 n=10)
XORBytesUnaligned/128Bytes4Offset-4     557.4n ± 0%   125.0n ± 0%  -77.57% (p=0.000 n=10)
XORBytesUnaligned/128Bytes5Offset-4     557.7n ± 0%   125.7n ± 0%  -77.46% (p=0.000 n=10)
XORBytesUnaligned/128Bytes6Offset-4     557.5n ± 0%   127.0n ± 0%  -77.22% (p=0.000 n=10)
XORBytesUnaligned/128Bytes7Offset-4     557.7n ± 0%   128.3n ± 0%  -76.99% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes0Offset-4   1088.5n ± 0%   601.9n ± 0%  -44.71% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes1Offset-4   8243.0n ± 0%   655.7n ± 0%  -92.05% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes2Offset-4   8244.0n ± 0%   657.1n ± 0%  -92.03% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes3Offset-4   8247.5n ± 0%   658.7n ± 0%  -92.01% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes4Offset-4   8243.0n ± 0%   649.8n ± 0%  -92.12% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes5Offset-4   8247.0n ± 0%   650.2n ± 0%  -92.12% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes6Offset-4   8243.0n ± 0%   651.6n ± 0%  -92.09% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes7Offset-4   8244.0n ± 0%   652.8n ± 0%  -92.08% (p=0.000 n=10)
geomean                                 410.1n        147.2n       -64.10%

                                     │   subtle.1   │                subtle.2                 │
                                     │     B/s      │      B/s       vs base                  │
XORBytes/8Bytes-4                      128.1Mi ± 0%    131.2Mi ± 0%     +2.40% (p=0.000 n=10)
XORBytes/128Bytes-4                    971.6Mi ± 0%   1629.2Mi ± 0%    +67.69% (p=0.000 n=10)
XORBytes/2048Bytes-4                   1.752Gi ± 0%    3.166Gi ± 0%    +80.68% (p=0.000 n=10)
XORBytes/8192Bytes-4                   1.833Gi ± 0%    3.360Gi ± 0%    +83.35% (p=0.000 n=10)
XORBytes/32768Bytes-4                  881.0Mi ± 0%   1111.5Mi ± 0%    +26.16% (p=0.000 n=10)
XORBytesUnaligned/8Bytes0Offset-4      127.6Mi ± 0%    132.7Mi ± 0%     +4.02% (p=0.000 n=10)
XORBytesUnaligned/8Bytes1Offset-4      104.5Mi ± 0%    132.7Mi ± 0%    +26.95% (p=0.000 n=10)
XORBytesUnaligned/8Bytes2Offset-4      104.6Mi ± 0%    132.7Mi ± 0%    +26.92% (p=0.000 n=10)
XORBytesUnaligned/8Bytes3Offset-4      104.5Mi ± 0%    132.8Mi ± 0%    +27.01% (p=0.000 n=10)
XORBytesUnaligned/8Bytes4Offset-4      104.6Mi ± 0%    132.8Mi ± 0%    +27.02% (p=0.000 n=10)
XORBytesUnaligned/8Bytes5Offset-4      104.6Mi ± 0%    132.7Mi ± 0%    +26.89% (p=0.000 n=10)
XORBytesUnaligned/8Bytes6Offset-4      104.5Mi ± 0%    132.8Mi ± 0%    +26.99% (p=0.000 n=10)
XORBytesUnaligned/8Bytes7Offset-4      104.6Mi ± 0%    132.8Mi ± 0%    +26.97% (p=0.000 n=10)
XORBytesUnaligned/128Bytes0Offset-4    974.4Mi ± 0%   1645.7Mi ± 0%    +68.90% (p=0.000 n=10)
XORBytesUnaligned/128Bytes1Offset-4    219.0Mi ± 0%    931.3Mi ± 0%   +325.23% (p=0.000 n=10)
XORBytesUnaligned/128Bytes2Offset-4    219.0Mi ± 0%    921.2Mi ± 0%   +320.57% (p=0.000 n=10)
XORBytesUnaligned/128Bytes3Offset-4    218.9Mi ± 0%    912.9Mi ± 0%   +316.97% (p=0.000 n=10)
XORBytesUnaligned/128Bytes4Offset-4    219.0Mi ± 0%    976.4Mi ± 0%   +345.85% (p=0.000 n=10)
XORBytesUnaligned/128Bytes5Offset-4    218.9Mi ± 0%    971.2Mi ± 0%   +343.70% (p=0.000 n=10)
XORBytesUnaligned/128Bytes6Offset-4    219.0Mi ± 0%    961.1Mi ± 0%   +338.86% (p=0.000 n=10)
XORBytesUnaligned/128Bytes7Offset-4    218.9Mi ± 0%    951.1Mi ± 0%   +334.52% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes0Offset-4   1.752Gi ± 0%    3.169Gi ± 0%    +80.83% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes1Offset-4   236.9Mi ± 0%   2978.6Mi ± 0%  +1157.10% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes2Offset-4   236.9Mi ± 0%   2972.1Mi ± 0%  +1154.48% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes3Offset-4   236.8Mi ± 0%   2965.1Mi ± 0%  +1152.05% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes4Offset-4   236.9Mi ± 0%   3005.9Mi ± 0%  +1168.65% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes5Offset-4   236.8Mi ± 0%   3004.0Mi ± 0%  +1168.42% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes6Offset-4   236.9Mi ± 0%   2997.2Mi ± 0%  +1164.96% (p=0.000 n=10)
XORBytesUnaligned/2048Bytes7Offset-4   236.9Mi ± 0%   2991.9Mi ± 0%  +1162.93% (p=0.000 n=10)
geomean                                260.4Mi         806.7Mi        +209.73%

Change-Id: I9bec9c8f48df7284f8414ac745615c2a093e9ae9
Reviewed-on: https://go-review.googlesource.com/c/go/+/639858
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
TryBot-Bypass: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-14 20:58:15 -08:00
Jes Cok
63ae416720 os: explicitly return nil for rootChown in root_openat.go
It is consistent with the same function in root_noopenat.go.

Change-Id: I6ddbf4dfcc725cb2023bc6bed961cc525b9c43d2
GitHub-Last-Rev: 0802150a6a8e5d4bd395b702ecc518df1e8dd4c0
GitHub-Pull-Request: golang/go#71743
Reviewed-on: https://go-review.googlesource.com/c/go/+/649417
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: 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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-02-14 20:21:32 -08:00
Joel Sing
d7c242a19a cmd/internal/obj/riscv: support MOVD with floating point constants
Currently, we only support loading of values from memory (or other
registers). Add floating point constant support to MOVD. This is
implemented by storing the floating point constant to a symbol,
which is then loaded into the floating point register.

Change-Id: I6db242d27f606f0d5d084a3ab93538698d3a4f8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/631876
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
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-02-14 19:41:30 -08:00
Joel Sing
77343fa646 runtime: use return for async preemption resumption on arm64
Use return with register for async preemption resumption on arm64.
This has the same behaviour as the current use of JMP, however
is permitted when Branch Target Identification is being enforced,
while a JMP with register is considered an indirect call and
requires a `BTI J` marker at the resumption address.

Updates #66054

Change-Id: I135ac577073467bedd9efd8df15b76c97dc08767
Reviewed-on: https://go-review.googlesource.com/c/go/+/646782
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-14 19:36:58 -08:00
cuishuang
67903012f7 cmd/go/internal: use pathpkg name more
The package "path" is already imported under the name pathpkg and used
many times in these files. It's not worth it to also make it available
under the name path, so keep using pathpkg.

Change-Id: I7f8fa7a11de338b9a7c0f58a48d5af68b5639cfe
Reviewed-on: https://go-review.googlesource.com/c/go/+/630475
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-14 19:35:50 -08:00
Filippo Valsorda
1ce87bea47 crypto/internal/fips140/edwards25519: make Scalar.SetCanonicalBytes constant time
Internally we only use SetCanonicalBytes as part of Ed25519
verification, where all inputs are public, so it doesn't need to be
constant time.

However, this code is replicated outside of the standard library. Even
there, an attack is not practical, so this should not be considered a
security vulnerability:

  - For specific scalars, this only leaks at most four bits of
    information, and always the same four bits (so it's not an adaptive
    attack).

  - For derived scalars, assuming they are valid and uniformly
    distributed, the loop would return true on the first iteration with
    probability (1 - 2⁻¹²⁷) due to the shape of the scalar field order.

Still, making it constant time is easy enough and saves the next person
from having to think about it.

This was previously reported by Yawning Angel, and then as part of a
security audit.

Change-Id: I6a6a46563c8abecb0b4a6f12033a71c4c4da6fa7
Reviewed-on: https://go-review.googlesource.com/c/go/+/648035
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-02-14 16:09:56 -08:00
Ian Lance Taylor
10cef816aa internal/godebugs: add fips140 as an opaque godebug setting
This permits using "godebug fips140=on" in go.mod and
using "//go:debug fips140=on" in the main package.

Change code references to the godebug setting to remove the #
which is no longer required.

For #71666

Change-Id: I3a60ecc55b03848dadd6d431eb43137b6df6568b
Reviewed-on: https://go-review.googlesource.com/c/go/+/649495
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2025-02-14 16:08:33 -08:00
Filippo Valsorda
7b7307f632 crypto/rsa: add benchmarks for not and partially optimized keys
Updates #59695

Change-Id: I7944195c805cd9da819cdf2bd49ecb2423ccd73b
Reviewed-on: https://go-review.googlesource.com/c/go/+/637178
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
2025-02-14 16:01:58 -08:00
Ian Lance Taylor
5f65e5cb56 doc/godebug: mention GODEBUG=fips140
Fixes #71666

Change-Id: Ice816cf2943c5b6660f05934b4c7ca38545714b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/648520
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-14 15:54:46 -08:00
Andrey Bokhanko
11f7ea8ce0 cmd/compile: add type-based alias analysis
Make ssa.disjoint call ssa.disjointTypes to disambiguate Values based on
their types. Only one type-based rule is employed: a Type can't alias
with a pointer (https://pkg.go.dev/unsafe#Pointer).

Fixes #70488

Change-Id: I5a7e75292c2b6b5a01fb9048e3e2360e31dbcdd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/632176
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-02-14 15:32:55 -08:00
cuishuang
2299a4289d bytes: add examples for Lines, SplitSeq, SplitAfterSeq, FieldsSeq and FieldsFuncSeq
Change-Id: I0e755d5c73f14d2c98853bdd31a7f2e84c92a906
Reviewed-on: https://go-review.googlesource.com/c/go/+/648860
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-14 15:18:41 -08:00
Joel Sing
bad791343f internal/syscall/unix: correct fchmodat on openbsd
This is incorrectly calling the fchownat trampoline - call fchmodat
as intended.

Change-Id: I7b1e758d456006303ca95b70df9e6b52d3020158
Reviewed-on: https://go-review.googlesource.com/c/go/+/649655
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Commit-Queue: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2025-02-14 14:00:06 -08:00
Carlos Ramos Carreño
1959703ddd syscall: skip testAmbientCaps tests if there is no nobody user
When there is not a nobody user (for example inside Docker), the
tests TestAmbientCaps and TestAmbientCapsUserns should be skipped
instead of failing.

Fixes #71644

Change-Id: I7f92db19e2b6f449d8d897650a0ecd89f5150f4a
GitHub-Last-Rev: a4c4f5bb61929b4981dc0b92d773bd4ef13d7d3d
GitHub-Pull-Request: golang/go#71729
Reviewed-on: https://go-review.googlesource.com/c/go/+/649396
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@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-02-14 14:00:03 -08:00
Damien Neil
8c05e020d5 internal/syscall/unix: fix fchownat linkname for AIX & Solaris
Typo fix: libc_chownat => libc_fchownat

Change-Id: I6721a988c19e3438b967a73559159c948ed51a0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/649636
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>
2025-02-14 13:58:37 -08:00
Carlos Amedee
45447b4bff net/http: use runtime.AddCleanup instead of runtime.SetFinalizer
Replace the usage of runtime.SetFinalizer with runtime.AddCleanup in
tests.

Updates #70907

Change-Id: Idd3f1c07f6a7709352ca09948fbcb4a0ad9418bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/648655
Auto-Submit: Carlos Amedee <carlos@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-14 09:59:55 -08:00
Michael Anthony Knyszek
85f8e240fe internal/trace: emit sync event before deferred spilled error
CL 648315 and CL 648195 fixed #71615 in the case where we fail to read
the next generation by emitting an extra sync event before returning an
error. But, it's possible we failed to even read the next spilled batch
when we read the first generation, and have been carrying the error from
trying to read a spilled batch since the last generation. In this case,
we don't emit a final sync event, meaning that there are still some
cases where #71615 happens.

This change emits the final sync event in this corner case. I believe
this is the final corner case. I could previously reproduce the issue
by running the test under stress2, but I can no longer reproduce any
failures after this change.

Fixes #71615, for real this time.

Change-Id: I10688a3c0e4b8327a95f31add365338c77c091ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/649259
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-14 09:59:37 -08:00
Filippo Valsorda
242ef7cb05 crypto/rsa: normalize GenerateKey benchmark
Benchmarking key generation is a pain. The number of random candidates
explored before finding a prime varies greatly, and on top of that some
rejections happen in the trial divisions step and some in the
Miller-Rabin step.

However, we can calculate on average how many candidates we should
reject before finding a prime, and of those how many should be divisible
by small primes. (And even the number of multiplications in a
Miller-Rabin iteration.) The new checked in sequence of candidates is
normalized to represent the average case.

It doesn't normalize the runtime of GCD, but running the benchmark with
20 different randomly generated "average cases" produces very consistent
results, so it must not matter much.

goos: darwin
goarch: arm64
pkg: crypto/rsa
cpu: Apple M2
                   │  regen.txt  │
                   │   sec/op    │
GenerateKey/2048-8   136.4m ± 0%

Changed slightly the excess masking in keygen.go to make it easier to
feed fixed candidates. This might also make it easier to share test
vectors in the future.

Change-Id: I66696c693f35da7bda27db537aa3bf3b991e970e
Reviewed-on: https://go-review.googlesource.com/c/go/+/639335
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-14 09:38:08 -08:00
Dmitri Shuralyov
c0d96f30e8 net/http: unskip TestDisableContentLength/h2
h2_bundle.go has been updated.

Change-Id: I055b8db9aab964621c980e4731011c89f7694405
Reviewed-on: https://go-review.googlesource.com/c/go/+/649496
Reviewed-by: 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>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2025-02-14 09:11:01 -08:00
Carlos Amedee
a8487dadeb cmd/go: use runtime.AddCleanup instead of runtime.SetFinalizer
Replace the usage of runtime.SetFinalizer with runtime.AddCleanup.
This changes a test and how when the Go command panics when a file is
left locked.

Updates #70907

Change-Id: I8d8c56d16486728f9bd4b910b81796ae506bda74
Reviewed-on: https://go-review.googlesource.com/c/go/+/640736
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-14 07:29:47 -08:00
Carlos Amedee
954e2c0b06 sync: use runtime.AddCleanup instead of runtime.SetFinalizer
This changes the use of finalizers to the cleanup implementation in
tests.

Updates #70907

Change-Id: I7d7289999a83fa53f538698f34294f7d9651c921
Reviewed-on: https://go-review.googlesource.com/c/go/+/640735
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-14 07:29:34 -08:00
Joel Sing
c8545439b5 cmd/asm,cmd/internal/obj/riscv: implement vector configuration setting instructions
Implement vector configuration setting instructions (VSETVLI,
VSETIVLI, VSETL).  These allow the vector length (vl) and vector
type (vtype) CSRs to be configured via a single instruction.
Unfortunately each instruction has its own dedicated encoding.

In the case of VSETVLI/VSETIVLI, the vector type is specified via
a series of special operands, which specify the selected element
width (E8, E16, E32, E64), the vector register group multiplier
(M1, M2, M4, M8, MF2, MF4, MF8), the vector tail policy (TU, TA)
and vector mask policy (MU, MA). Note that the order of these
special operands matches non-Go assemblers.

Partially based on work by Pengcheng Wang <wangpengcheng.pp@bytedance.com>.

Cq-Include-Trybots: luci.golang.try:gotip-linux-riscv64
Change-Id: I431f59c1e048a3e84754f0643a963da473a741fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/631936
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
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: Dmitri Shuralyov <dmitshur@google.com>
2025-02-14 07:13:11 -08:00
qiulaidongfeng
b16c04f439 cmd/dist: use slices.Index
Change-Id: Ifcab176faa2ac55e60576cf6acd96a18d0e860ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/648859
Reviewed-by: Dmitri Shuralyov <dmitshur@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>
2025-02-14 07:04:42 -08:00
Russ Cox
baeab452d1 testing: panic in AllocsPerRun if parallel tests are running
If other tests are running, AllocsPerRun's result will be inherently flaky.
Saw this with CL 630136 and #70327.

Proposed in #70464.

Fixes #70464.

Change-Id: I190afdf26bc31299f6e5e8665b4fb420ffd554ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/630137
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-14 06:09:08 -08:00
Meng Zhuo
371ee1469c cmd/link,cmd/internal: add R_GOT_PCREL_ITYPE_RELOC for riscv64
This CL adds new relocation type for riscv64: R_GOT_PCREL_ITYPE_RELOC
which generate an AUIPC + I-type pair with relocation type of GOT_HI20
and PCREL_LO12_I.
According to RISCV elf psabi doc, medium position independent code
model, the GNU as example is:

```
		# Calculate address of non-local symbol
.Ltmp3: aupipc	a0, %got_pcrel_hi(symbol)
	ld	a0, %pcrel_lo(.Ltmp3)(a0)
```

Change-Id: I719dd05e009ca2d9291f0689b346c059f9c56918
Reviewed-on: https://go-review.googlesource.com/c/go/+/612635
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-13 19:04:13 -08:00
Damien Neil
5ff7a634e1 net/http, net/http/internal/httpcommon: add httpcommon package
The golang.org/x/net/internal/httpcommon package is
a new package containing internal functions common to the
HTTP/2 and HTTP/3 implementations.

Update to golang.org/x/net@v0.35.1-0.20250213222735-884432780bfd,
which includes the httpcommon package.

Since net/http can't depend on a x/net/internal package,
add net/http/internal/httpcommon which bundles the x/net
package.

Change-Id: Iba6c4be7b3e2d9a9d79c4b5153497b0e04b4497b
Reviewed-on: https://go-review.googlesource.com/c/go/+/649296
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2025-02-13 16:29:58 -08:00
Damien Neil
807a51b391 os: add Root.Chown
For #67002

Change-Id: I546537618cbe32217fa72264d49db2b1a1d3b6db
Reviewed-on: https://go-review.googlesource.com/c/go/+/648295
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>
2025-02-13 15:29:56 -08:00
Keith Randall
187fd2698d cmd/compile: make write barrier code amenable to paired loads/stores
It currently isn't because it does load/store/load/store/...
Rework to do overwrite processing in pairs so it is instead
load/load/store/store/...

Change-Id: If7be629bc4048da5f2386dafb8f05759b79e9e2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/631495
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-13 14:08:14 -08:00
Keith Randall
a0029e95e5 cmd/compile: regalloc: handle desired registers of 2-output insns
Particularly with 2-word load instructions, this becomes important.
Classic example is:

    func f(p *string) string {
        return *p
    }

We want the two loads to put the return values directly into
the two ABI return registers.

At this point in the stack, cmd/go is 1.1% smaller.

Change-Id: I51fd1710238e81d15aab2bfb816d73c8e7c207b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/631137
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-13 14:08:07 -08:00
khr@golang.org
20d7c57422 cmd/compile: pair loads and stores on arm64
Look for possible paired load/store operations on arm64.
I don't expect this would be a lot faster, but it will save
binary space, and indirectly through the icache at least a bit
of time.

Change-Id: I4dd73b0e6329c4659b7453998f9b75320fcf380b
Reviewed-on: https://go-review.googlesource.com/c/go/+/629256
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2025-02-13 14:07:47 -08:00
khr@golang.org
0b88a87879 cmd/compile: add variants of LDP/STP for arm64 load/store combining
These will be used in a subsequent CL.

Change-Id: I96562668da502e5cb41096c9831c59292644be72
Reviewed-on: https://go-review.googlesource.com/c/go/+/629255
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-13 14:07:25 -08:00
Jes Cok
eab3c1e697 os: explicitly return nil for {rootChmod,rootMkdir,rootRemove} in root_openat.go
It is consistent with same functions in root_noopenat.go.

Change-Id: I81415fd3922101499fcbbdec97e315add0671acb
GitHub-Last-Rev: 3444e8546ee1877feb644202ad2b05379b4b7e74
GitHub-Pull-Request: golang/go#71715
Reviewed-on: https://go-review.googlesource.com/c/go/+/649235
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-13 13:31:15 -08:00
Ian Lance Taylor
0044bc614a os: consolidate and clarify File.Fd docs
Change-Id: Id062b969fe7d6908a0797b36a4a379e4d46ba557
Reviewed-on: https://go-review.googlesource.com/c/go/+/648516
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>
Reviewed-by: Damien Neil <dneil@google.com>
2025-02-13 13:10:32 -08:00
Keith Randall
89c2f282dc cmd/compile: move []byte->string map key optimization to ssa
If we call slicebytetostring immediately (with no intervening writes)
before calling map access or delete functions with the resulting
string as the key, then we can just use the ptr/len of the
slicebytetostring argument as the key. This avoids an allocation.

Fixes #44898
Update #71132

There's old code in cmd/compile/internal/walk/order.go that handles
some of these cases.

1. m[string(b)]
2. s := string(b); m[s]
3. m[[2]string{string(b1),string(b2)}]

The old code handled cases 1&3. The new code handles cases 1&2.
We'll leave the old code around to keep 3 working, although it seems
not terribly common.

Case 2 happens particularly after inlining, so it is pretty common.

Change-Id: I8913226ca79d2c65f4e2bd69a38ac8c976a57e43
Reviewed-on: https://go-review.googlesource.com/c/go/+/640656
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-02-13 13:03:07 -08:00
Jakub Ciolek
43b7e67040 cmd/compile: lower x*z + y to FMA if FMA enabled
There is a generic opcode for FMA, but we don't use it in rewrite rules.
This is maybe because some archs, like WASM and MIPS don't have a late
lowering rule for it.

Fixes #71204

Intel Alder Lake 12600k (GOAMD64=v3):

math:

name                    old time/op  new time/op  delta
Acos-16                 4.58ns ± 0%  3.36ns ± 0%  -26.68%  (p=0.008 n=5+5)
Acosh-16                8.04ns ± 1%  6.44ns ± 0%  -19.95%  (p=0.008 n=5+5)
Asin-16                 4.28ns ± 0%  3.32ns ± 0%  -22.24%  (p=0.008 n=5+5)
Asinh-16                9.92ns ± 0%  8.62ns ± 0%  -13.13%  (p=0.008 n=5+5)
Atan-16                 2.31ns ± 0%  1.84ns ± 0%  -20.02%  (p=0.008 n=5+5)
Atanh-16                7.79ns ± 0%  7.03ns ± 0%   -9.67%  (p=0.008 n=5+5)
Atan2-16                3.93ns ± 0%  3.52ns ± 0%  -10.35%  (p=0.000 n=5+4)
Cbrt-16                 4.62ns ± 0%  4.41ns ± 0%   -4.57%  (p=0.016 n=4+5)
Ceil-16                 0.14ns ± 1%  0.14ns ± 2%     ~     (p=0.103 n=5+5)
Copysign-16             0.33ns ± 0%  0.33ns ± 0%   +0.03%  (p=0.029 n=4+4)
Cos-16                  4.87ns ± 0%  4.75ns ± 0%   -2.44%  (p=0.016 n=5+4)
Cosh-16                 4.86ns ± 0%  4.86ns ± 0%     ~     (p=0.317 n=5+5)
Erf-16                  2.71ns ± 0%  2.25ns ± 0%  -16.69%  (p=0.008 n=5+5)
Erfc-16                 3.06ns ± 0%  2.67ns ± 0%  -13.00%  (p=0.016 n=5+4)
Erfinv-16               3.88ns ± 0%  2.84ns ± 3%  -26.83%  (p=0.008 n=5+5)
Erfcinv-16              4.08ns ± 0%  3.01ns ± 1%  -26.27%  (p=0.008 n=5+5)
Exp-16                  3.29ns ± 0%  3.37ns ± 2%   +2.64%  (p=0.016 n=4+5)
ExpGo-16                8.44ns ± 0%  7.48ns ± 1%  -11.37%  (p=0.008 n=5+5)
Expm1-16                4.46ns ± 0%  3.69ns ± 2%  -17.26%  (p=0.016 n=4+5)
Exp2-16                 8.20ns ± 0%  7.39ns ± 2%   -9.94%  (p=0.008 n=5+5)
Exp2Go-16               8.26ns ± 0%  7.23ns ± 0%  -12.49%  (p=0.016 n=4+5)
Abs-16                  0.26ns ± 3%  0.22ns ± 1%  -16.34%  (p=0.008 n=5+5)
Dim-16                  0.38ns ± 1%  0.40ns ± 2%   +5.02%  (p=0.008 n=5+5)
Floor-16                0.11ns ± 1%  0.17ns ± 4%  +54.99%  (p=0.008 n=5+5)
Max-16                  1.24ns ± 0%  1.24ns ± 0%     ~     (p=0.619 n=5+5)
Min-16                  1.24ns ± 0%  1.24ns ± 0%     ~     (p=0.484 n=5+5)
Mod-16                  13.4ns ± 1%  12.8ns ± 0%   -4.21%  (p=0.016 n=5+4)
Frexp-16                1.70ns ± 0%  1.71ns ± 0%   +0.46%  (p=0.008 n=5+5)
Gamma-16                3.97ns ± 0%  3.97ns ± 0%     ~     (p=0.643 n=5+5)
Hypot-16                2.11ns ± 0%  2.11ns ± 0%     ~     (p=0.762 n=5+5)
HypotGo-16              2.48ns ± 4%  2.26ns ± 0%   -8.94%  (p=0.008 n=5+5)
Ilogb-16                1.67ns ± 0%  1.67ns ± 0%   -0.07%  (p=0.048 n=5+5)
J0-16                   19.8ns ± 0%  19.3ns ± 0%     ~     (p=0.079 n=4+5)
J1-16                   19.4ns ± 0%  18.9ns ± 0%   -2.63%  (p=0.000 n=5+4)
Jn-16                   41.5ns ± 0%  40.6ns ± 0%   -2.32%  (p=0.016 n=4+5)
Ldexp-16                2.26ns ± 0%  2.26ns ± 0%     ~     (p=0.683 n=5+5)
Lgamma-16               4.40ns ± 0%  4.21ns ± 0%   -4.21%  (p=0.008 n=5+5)
Log-16                  4.05ns ± 0%  4.05ns ± 0%     ~     (all equal)
Logb-16                 1.69ns ± 0%  1.69ns ± 0%     ~     (p=0.429 n=5+5)
Log1p-16                5.00ns ± 0%  3.99ns ± 0%  -20.14%  (p=0.008 n=5+5)
Log10-16                4.22ns ± 0%  4.21ns ± 0%   -0.15%  (p=0.008 n=5+5)
Log2-16                 2.27ns ± 0%  2.25ns ± 0%   -0.94%  (p=0.008 n=5+5)
Modf-16                 1.44ns ± 0%  1.44ns ± 0%     ~     (p=0.492 n=5+5)
Nextafter32-16          2.09ns ± 0%  2.09ns ± 0%     ~     (p=0.079 n=4+5)
Nextafter64-16          2.09ns ± 0%  2.09ns ± 0%     ~     (p=0.095 n=4+5)
PowInt-16               10.8ns ± 0%  10.8ns ± 0%     ~     (all equal)
PowFrac-16              25.3ns ± 0%  25.3ns ± 0%   -0.09%  (p=0.000 n=5+4)
Pow10Pos-16             0.52ns ± 1%  0.52ns ± 0%     ~     (p=0.810 n=5+5)
Pow10Neg-16             0.82ns ± 0%  0.82ns ± 0%     ~     (p=0.381 n=5+5)
Round-16                0.93ns ± 0%  0.93ns ± 0%     ~     (p=0.056 n=5+5)
RoundToEven-16          1.64ns ± 0%  1.64ns ± 0%     ~     (all equal)
Remainder-16            12.4ns ± 2%  12.0ns ± 0%   -3.27%  (p=0.008 n=5+5)
Signbit-16              0.37ns ± 0%  0.37ns ± 0%   -0.19%  (p=0.008 n=5+5)
Sin-16                  4.04ns ± 0%  3.92ns ± 0%   -3.13%  (p=0.000 n=4+5)
Sincos-16               5.99ns ± 0%  5.80ns ± 0%   -3.03%  (p=0.008 n=5+5)
Sinh-16                 5.22ns ± 0%  5.22ns ± 0%     ~     (p=0.651 n=5+4)
SqrtIndirect-16         0.41ns ± 0%  0.41ns ± 0%     ~     (p=0.333 n=4+5)
SqrtLatency-16          2.66ns ± 0%  2.66ns ± 0%     ~     (p=0.079 n=4+5)
SqrtIndirectLatency-16  2.66ns ± 0%  2.66ns ± 0%     ~     (p=1.000 n=5+5)
SqrtGoLatency-16        30.1ns ± 0%  28.6ns ± 1%   -4.84%  (p=0.008 n=5+5)
SqrtPrime-16             645ns ± 0%   645ns ± 0%     ~     (p=0.095 n=5+4)
Tan-16                  4.21ns ± 0%  4.09ns ± 0%   -2.76%  (p=0.029 n=4+4)
Tanh-16                 5.36ns ± 0%  5.36ns ± 0%     ~     (p=0.444 n=5+5)
Trunc-16                0.12ns ± 6%  0.11ns ± 1%   -6.79%  (p=0.008 n=5+5)
Y0-16                   19.2ns ± 0%  18.7ns ± 0%   -2.52%  (p=0.000 n=5+4)
Y1-16                   19.1ns ± 0%  18.4ns ± 0%     ~     (p=0.079 n=4+5)
Yn-16                   40.7ns ± 0%  39.5ns ± 0%   -2.82%  (p=0.008 n=5+5)
Float64bits-16          0.21ns ± 0%  0.21ns ± 0%     ~     (p=0.603 n=5+5)
Float64frombits-16      0.21ns ± 0%  0.21ns ± 0%     ~     (p=0.984 n=4+5)
Float32bits-16          0.21ns ± 0%  0.21ns ± 0%     ~     (p=0.778 n=4+5)
Float32frombits-16      0.21ns ± 0%  0.20ns ± 0%     ~     (p=0.397 n=5+5)
FMA-16                  0.82ns ± 0%  0.82ns ± 0%   +0.02%  (p=0.029 n=4+4)
[Geo mean]              2.87ns       2.74ns        -4.61%

math/cmplx:

name        old time/op  new time/op  delta
Abs-16      2.07ns ± 0%  2.05ns ± 0%   -0.70%  (p=0.016 n=5+4)
Acos-16     36.5ns ± 0%  35.7ns ± 0%   -2.33%  (p=0.029 n=4+4)
Acosh-16    37.0ns ± 0%  36.2ns ± 0%   -2.20%  (p=0.008 n=5+5)
Asin-16     36.5ns ± 0%  35.7ns ± 0%   -2.29%  (p=0.008 n=5+5)
Asinh-16    33.5ns ± 0%  31.6ns ± 0%   -5.51%  (p=0.008 n=5+5)
Atan-16     15.5ns ± 0%  13.9ns ± 0%  -10.61%  (p=0.008 n=5+5)
Atanh-16    15.0ns ± 0%  13.6ns ± 0%   -9.73%  (p=0.008 n=5+5)
Conj-16     0.11ns ± 5%  0.11ns ± 1%     ~     (p=0.421 n=5+5)
Cos-16      12.3ns ± 0%  12.2ns ± 0%   -0.60%  (p=0.000 n=4+5)
Cosh-16     12.1ns ± 0%  12.0ns ± 0%     ~     (p=0.079 n=4+5)
Exp-16      10.0ns ± 0%   9.8ns ± 0%   -1.77%  (p=0.008 n=5+5)
Log-16      14.5ns ± 0%  13.7ns ± 0%   -5.67%  (p=0.008 n=5+5)
Log10-16    14.5ns ± 0%  13.7ns ± 0%   -5.55%  (p=0.000 n=5+4)
Phase-16    5.11ns ± 0%  4.25ns ± 0%  -16.90%  (p=0.008 n=5+5)
Polar-16    7.12ns ± 0%  6.35ns ± 0%  -10.90%  (p=0.008 n=5+5)
Pow-16      64.3ns ± 0%  63.7ns ± 0%   -0.97%  (p=0.008 n=5+5)
Rect-16     5.74ns ± 0%  5.58ns ± 0%   -2.73%  (p=0.016 n=4+5)
Sin-16      12.2ns ± 0%  12.2ns ± 0%   -0.54%  (p=0.000 n=4+5)
Sinh-16     12.1ns ± 0%  12.0ns ± 0%   -0.58%  (p=0.000 n=5+4)
Sqrt-16     5.30ns ± 0%  5.18ns ± 0%   -2.36%  (p=0.008 n=5+5)
Tan-16      22.7ns ± 0%  22.6ns ± 0%   -0.33%  (p=0.008 n=5+5)
Tanh-16     21.2ns ± 0%  20.9ns ± 0%   -1.32%  (p=0.008 n=5+5)
[Geo mean]  11.3ns       10.8ns        -3.97%

Change-Id: Idcc4b357ba68477929c126289e5095b27a827b1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/646335
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-02-13 12:34:33 -08:00
Russ Cox
eab8e987c0 cmd: use cmd/internal/hash.New32 and Sum32 only
Do not use New16, New20, Sum16, Sum20 anymore.
As of CL 641096, these are just wrappers around New32 and Sum32.
Change call sites to use them directly.

Change-Id: Icea91a77449f6839b903894997057ba404bd04e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/641076
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2025-02-13 12:34:30 -08:00
Keith Randall
a7e331e671 cmd/compile: implement signed loads from read-only memory
In addition to unsigned loads which already exist.

This helps code that does switches on strings to constant-fold
the switch away when the string being switched on is constant.

Fixes #71699

Change-Id: If3051af0f7255d2a573da6f96b153a987a7f159d
Reviewed-on: https://go-review.googlesource.com/c/go/+/649295
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
2025-02-13 12:27:55 -08:00
Paul Murphy
ca4649747a runtime: fix usleep on s390x/linux
The timespec argument takes the remainder in nanoseconds, not
microseconds. Convert the remaining time to nsec.

Fixes #71714

Change-Id: I36cbbe3a088830c5e3afcc9516ef42e96ee21268
Reviewed-on: https://go-review.googlesource.com/c/go/+/648915
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Axel Busch <axel.busch@ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Vishwanatha HD <vishwanatha.hd@ibm.com>
2025-02-13 11:05:31 -08:00
Sam Thanawalla
769274bf14 cmd/go: do not apply kill timeout to go test with -bench
The testing package already does this. go test should do the same thing.

Fixes: #69181
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: I942bd09c5832b48d498a2eb1f1500e1d294d0a2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/648236
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2025-02-13 09:51:00 -08:00
Mateusz Poliwczak
aa8d4df9d9 go/types: propagate *ast.LabeledStmt in blockBranches properly
Fixes #70974

Change-Id: I330c0ae53dcbcdb173ab514ee94f2ca53944df09
GitHub-Last-Rev: 7c2b740da6d6e94ac8787f04ad8942f3776ac56c
GitHub-Pull-Request: golang/go#70976
Reviewed-on: https://go-review.googlesource.com/c/go/+/638257
Reviewed-by: Michael Knyszek <mknyszek@google.com>
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: Alan Donovan <adonovan@google.com>
2025-02-13 09:46:09 -08:00
Carlos Amedee
e4b12eb8af io: use runtime.AddCleanup instead of runtime.SetFinalizer
Replace the usage of runtime.SetFinalizer with runtime.AddCleanup.

Updates #70907

Change-Id: Id604ca44ea67dcf8f87797e27347c6f4e9ad0b86
Reviewed-on: https://go-review.googlesource.com/c/go/+/638556
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>
TryBot-Bypass: Carlos Amedee <carlos@golang.org>
2025-02-13 09:11:02 -08:00
Mateusz Poliwczak
f7becfc7f1 go/types: use documented version of gotypesalias GODEBUG
This way the code would panic, in case it does not exist.

Change-Id: I95de7460c0386afdc5d3f6a847e9fcbd22446010
GitHub-Last-Rev: 9ae0502a091feed45169f5c1a7e2761f8ffa2841
GitHub-Pull-Request: golang/go#70845
Reviewed-on: https://go-review.googlesource.com/c/go/+/636097
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-13 09:03:33 -08:00
Carlos Amedee
fdaac84480 os: use AddCleanup to close files
This changes the finalizer mechanism used to close files from
runtime.SetFinalizer to runtime.AddCleanup.

Updates #70907

Change-Id: I47582b81b0ed69609dd9dac158ec7bb8819c8c77
Reviewed-on: https://go-review.googlesource.com/c/go/+/638555
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-13 08:20:22 -08:00
Daniel McCarney
f91ac1b61e crypto/internal/fips140test: fix TestACVP env vars
Fix TestACVP environment construction to include both ACVP_WRAPPER and
GODEBUG.

Previously we were accidentally overwriting the cmd.Env, stomping the
ACVP_WRAPPER env var and replacing it with just the GODEBUG env var.
This in turn makes the tests start to fail when the test binary
subprocess is invoked without knowing it's fulfilling the role of the
wrapper, and not the test driver.

Change-Id: Ie6ee30c8b93b2051a671e12aaa63d2116c5eb8c8
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/649016
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>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-02-13 08:00:58 -08:00
Sean Liao
c4136a433c runtime/debug: document DefaultGODEBUG as a BuildSetting
Fixes #66465

Change-Id: I60c017ddba29fa5b452b665d8521cd6c8e20438c
Reviewed-on: https://go-review.googlesource.com/c/go/+/597979
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-13 07:11:41 -08:00
Filippo Valsorda
1eb4c0dcb1 cmd/dist: test GOFIPS140=latest rather than just the GODEBUG
GOFIPS140=latest turns on the GODEBUG by default, and it's otherwise
untested.

Change-Id: I6a6a4656ff7ad313ce2c61ee4144ad2858bd148c
Reviewed-on: https://go-review.googlesource.com/c/go/+/648819
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-02-13 02:49:33 -08:00
Filippo Valsorda
8659ad9049 crypto/internal/fips140test: require FIPS 140 mode for the ACVP wrapper
Change-Id: I6a6a46565c14cf1d924a8fcfbf6752e9646ec63d
Reviewed-on: https://go-review.googlesource.com/c/go/+/648818
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>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-13 02:43:08 -08:00
Filippo Valsorda
4ffa9a8305 crypto/internal/fips140test: support disabling PAA/PAI
FIPS 140-3 testing requires testing the module both with and without
platform hardware acceleration.

Change-Id: I6a6a4656faad883062d64bc8e2363d4c59bd8cce
Reviewed-on: https://go-review.googlesource.com/c/go/+/648817
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-02-13 02:43:06 -08:00
Filippo Valsorda
19f779dd4f crypto/internal/fips140test: make TestCASTFailures standalone
We want it to work even when fips140test.test is cross-compiled and
moved to a different machine. Also, make it log more.

Change-Id: I6a6a46566712f05f6b551ecde75672baf2c0fc6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/644644
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-02-13 02:43:04 -08:00
Filippo Valsorda
3e0f9e3973 crypto/internal/fips140test: add functional tests
Running TestIntegrityCheckFailure|TestCASTFailures|TestFIPS140 with -v
and the appropriate GOFIPS140 environment variables will produce logs
sufficient for the functional testing session of the FIPS 140-3
validation. The tests can also be cross-compiled with -c and executed on
the target.

Change-Id: I6a6a465606518923d3f288e030c0f1b977aa6415
Reviewed-on: https://go-review.googlesource.com/c/go/+/648816
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-02-13 02:42:23 -08:00
Keith Randall
3902e9ef4e internal/abi: remove go122 flag
We no longer need this flag in case we need to rollback.

Change-Id: Id8b8f76380237f2d80a14037e88df4917c843f03
Reviewed-on: https://go-review.googlesource.com/c/go/+/649095
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
2025-02-13 00:20:45 -08:00
Dmitri Shuralyov
f2cadb6b2e cmd/pprof: update vendored github.com/google/pprof [generated]
Pull in the latest published version of github.com/google/pprof
as part of the continuous process of keeping Go's dependencies
up to date.

For #36905.

[git-generate]
cd src/cmd
go get github.com/google/pprof@v0.0.0-20250208200701-d0013a598941
go mod tidy
go mod vendor

Change-Id: I87e5621286d3db85f358fb86875aaf65bd7811a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/648916
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
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>
2025-02-12 20:49:10 -08:00
Mateusz Poliwczak
679cd8e779 reflect, internal/abi: speed up TypeFor[T]
goos: linux
goarch: amd64
pkg: reflect
cpu: AMD Ryzen 5 4600G with Radeon Graphics
                 │ /tmp/before  │              /tmp/after              │
                 │    sec/op    │    sec/op     vs base                │
TypeForString-12    2.091n ± 1%    1.174n ± 1%  -43.84% (p=0.000 n=20)
TypeForError-12    7.5810n ± 3%   0.9372n ± 1%  -87.64% (p=0.000 n=20)

Change-Id: I22022f99b2dd2029f02d9ed8477b209adf7e9496
GitHub-Last-Rev: 64d2ac5bb2f3b2a659663832a4641ff4fc83bddd
GitHub-Pull-Request: golang/go#71654
Reviewed-on: https://go-review.googlesource.com/c/go/+/648395
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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-02-12 18:31:00 -08:00
Damien Neil
fb5f78a14f internal/syscall: add cgo_import_dynamic for Fchmodat on AIX and Solaris
For #67002

Change-Id: I1709fd51ba52c074501420943d311c785a49d851
Reviewed-on: https://go-review.googlesource.com/c/go/+/649015
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>
2025-02-12 18:25:30 -08:00
Filippo Valsorda
fc0049fb20 crypto/tls: document FIPS 140-3 mode behavior
Change-Id: I6a6a465612cf76d148b9758ee3fcdc8606497830
Reviewed-on: https://go-review.googlesource.com/c/go/+/648835
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-12 14:52:40 -08:00
Alan Donovan
6519aa955d vet: add regression test for printf checker regression
Updates golang/go#68796

Change-Id: I5bfa80216deff76fd9aabe9882f93fbfaebef957
Reviewed-on: https://go-review.googlesource.com/c/go/+/610737
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2025-02-12 11:18:11 -08:00
Sean Liao
024c900b43 cmd/go: clarify vcs suffix to repo mapping
For #71635

Change-Id: I12ec2a810cfcaf2565b0d9c518b0921ec54e9f12
Reviewed-on: https://go-review.googlesource.com/c/go/+/648475
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
2025-02-12 10:55:48 -08:00
Michael Matloob
127288b4c6 cmd/go: add errors obtaining c compiler version to cache key
If there's an error getting the version of the c compiler, add the error
to the input used to produce the cache key. In the case where we can't
parse the version, the text of the output of the command is part of the
error, so different unparseable versions will produce different cache
keys. Before, we wouldn't add anything to the key when there was an
error getting the version, so we wouldn't distinguish a missing compiler
from one where we couldn't parse the version.

Fixes #64589

Change-Id: I27f853e8ff40002e2f045b2210633b38f93d0130
Reviewed-on: https://go-review.googlesource.com/c/go/+/648196
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-02-12 10:20:47 -08:00
Dmitri Shuralyov
b1a11c5446 all: update vendored dependencies [generated]
The tree has opened for Go 1.25 development. This is a time to update
all golang.org/x/... module versions that contribute packages to the
std and cmd modules in the standard library to latest master versions.

For #36905.

[git-generate]
go install golang.org/x/build/cmd/updatestd@latest
go install golang.org/x/tools/cmd/bundle@latest
updatestd -goroot=$(pwd) -branch=master

# Update a cmd/vet test case.
cat <<EOF | patch
diff --git a/src/cmd/vet/testdata/print/print.go b/src/cmd/vet/testdata/print/print.go
index a2ad0f1298..fffe571163 100644
--- a/src/cmd/vet/testdata/print/print.go
+++ b/src/cmd/vet/testdata/print/print.go
@@ -200,8 +200,8 @@ func PrintfTests() {
 	// Bad argument reorderings.
 	Printf("%[xd", 3)                      // ERROR "Printf format %\[xd is missing closing \]"
 	Printf("%[x]d x", 3)                   // ERROR "Printf format has invalid argument index \[x\]"
-	Printf("%[3]*s x", "hi", 2)            // ERROR "Printf format has invalid argument index \[3\]"
-	_ = fmt.Sprintf("%[3]d x", 2)          // ERROR "Sprintf format has invalid argument index \[3\]"
+	Printf("%[3]*s x", "hi", 2)            // ERROR "Printf format %\[3\]\*s reads arg #3, but call has 2 args"
+	_ = fmt.Sprintf("%[3]d x", 2)          // ERROR "Sprintf format %\[3\]d reads arg #3, but call has 1 arg"
 	Printf("%[2]*.[1]*[3]d x", 2, "hi", 4) // ERROR "Printf format %\[2]\*\.\[1\]\*\[3\]d uses non-int \x22hi\x22 as argument of \*"
 	Printf("%[0]s x", "arg1")              // ERROR "Printf format has invalid argument index \[0\]"
 	Printf("%[0]d x", 1)                   // ERROR "Printf format has invalid argument index \[0\]"
EOF

# Temporarily hold x/net back to leave out CL 643780 because it's
# causing an import cycle in net/http's generated h2_bundle.go.
cd src
sed -i '' 's|"golang.org/x/net/internal/httpcommon"||' net/http/h2_bundle.go
go get golang.org/x/net@v0.34.1-0.20250123000230-c72e89d6a9e4  # version before CL 643780
go mod tidy
go mod vendor
go generate net/http

Change-Id: I91967ceb797bbc741af024cd2d2dba29dc558384
Reviewed-on: https://go-review.googlesource.com/c/go/+/648735
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>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2025-02-12 09:31:18 -08:00
Michael Anthony Knyszek
a935749091 runtime: make TestSpuriousWakeupsNeverHangSemasleep more robust
This change modifies this test (which involves an arbitrary timeout) to
be a little less flaky by double-checking that our subprocess program
completed even if the ticker fires and we've exceeded our timeout. The
logic behind this change is that the testing goroutine might get delayed
for any number of reasons, but the subprocess could still complete in
time. Still, the goroutine will wake up to handle the ticker and see its
over time, even though the event it was waiting for did actually happen.

I can't reproduce #71548 locally, so I suspect because this test calls
t.Parallel other load can delay the testing goroutine enough for this to
happen (especially with GODEBUG=gccheckmark=1, which pauses
everything to perform a full mark and sweep, and runtime tests love to
call runtime.GC).

For #71548.

Change-Id: I83e86a0115f65950886b57b5af0b4a517ef5f90f
Reviewed-on: https://go-review.googlesource.com/c/go/+/648576
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Commit-Queue: Michael Knyszek <mknyszek@google.com>
2025-02-12 08:23:26 -08:00
Quan Tong
58834c3ee0 cmd/go: initialize req.Header when loading git credential
Fixes #71604

Change-Id: I3d733a50b4451dfb571aba91a28387ba9e0614dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/647615
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-12 08:19:49 -08:00
thepudds
b574590c36 cmd/go: document -modfile and other flags for 'go tool'
Mention -modfile, -C, -overlay, and -modcacherw in the 'go tool'
documentation. We let a reference to 'go help build' give a pointer to
more detailed information.

The -modfile flag in particular is newly useful with the Go 1.24 support
for user-defined tools with 'go tool'.

Updates #48429
Updates #33926
Updates #71663
Fixes #71502

Change-Id: Ida67df50ff774a0886733d661a40e27c2cadc0f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/648577
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Conrad Irwin <conrad.irwin@gmail.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>
2025-02-12 08:15:01 -08:00
Cherry Mui
d9cc4944ce cmd/dist: correct gccheckmark test name
The test actually runs with gccheckmark=1, not gcstoptheworld=2.
Make the name match.

Change-Id: If38822a3f1ef65bc92fe47b375381df49a684c1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/648755
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-12 08:01:52 -08:00
qmuntal
30f515898c make.bat,race.bat: simplify --dist-tool handling
make.bat accepts the --dist-tool flag on multiple flag positions
and also allows omitting the trailing dash. Doing so adds complexity
and is not aligned with the make.bash and make.rc behavior. Remove that
flexibility to simplify the code and make it more consistent. This also
fixes a bug where dist.exe wouldn't be removed from cmd\dist when
running make.bat --dist-tool.

Also, there is no need for race.bat to invoke make.bat with --dist-tool.
It uses it to get the GOHOSTARCH env value, but we can already get
that from the built-in PROCESSOR_ARCHITECTURE env variable.

Change-Id: Ia673562c1ae6aff9bd3ec7aa8cdd25ff187eeb79
Reviewed-on: https://go-review.googlesource.com/c/go/+/648615
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-11 23:09:26 -08:00
Daniel McCarney
b941d2b6d8 crypto/internal/fips140test: add cSHAKE ACVP tests
Adds ACVP test coverage for the SP 800-185 cSHAKE-128 and cSHAKE-256
algorithms based on the NIST spec:

  https://pages.nist.gov/ACVP/draft-celi-acvp-xof.html

Updates #69642

Change-Id: I4a6ef9a99dfe520f3177e0e7c258326475690f5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/648455
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-11 13:31:01 -08:00
Daniel McCarney
102406edbf crypto/internal/fips140test: add KTS-IFC ACVP tests
Adds ACVP test coverage for the SP 800-56Brev2 KTS-OAEP-basic algorithm
based on the NIST spec:

   https://pages.nist.gov/ACVP/draft-hammett-acvp-kas-ifc.html

Change-Id: I31240af30a73ee9f0ef00f47129738860378ea8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/648436
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-11 13:30:59 -08:00
Daniel McCarney
11c642c2d3 crypto/internal/fips140test: add OneStepNoCounter ACVP tests
Adds ACVP test coverage for the SP 800-56Crev2 IG D.P KDA
OneStepNoCounter mode algorithm based on the NIST spec:

  https://pages.nist.gov/ACVP/draft-hammett-acvp-kas-kdf-onestepnocounter.html

Coverage is added for all SHA2 and SHA3 HMACs.

Updates #69642

Change-Id: I337bf824a71fce6c796a1440b7f08c4f5413d92f
Reviewed-on: https://go-review.googlesource.com/c/go/+/648435
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
2025-02-11 13:30:57 -08:00
Michael Anthony Knyszek
8c6fec6d25 runtime: update HACKING.md with execution traces and debuglog
Change-Id: Iedd3c6f292ad76f57c6c04beafd655e2e4d83043
Reviewed-on: https://go-review.googlesource.com/c/go/+/646017
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-02-11 11:23:37 -08:00
Michael Anthony Knyszek
34e8541d24 internal/trace/tracev2: add guide for trace experiments
Change-Id: I6fb354a57f3e73bd6589570868c7d68369adcf3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/645136
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-11 11:23:34 -08:00
Michael Anthony Knyszek
49eba8b15b internal/trace: interpret string ID arguments for experimental events
Currently one of the reasons experimental events are tricky to use is
because:
- There's no way to take advantage of the existing infrastructure, like
  strings and stacks, and
- There's no way to attach arbitrary data to an event (except through
  strings, possibly).

Fix this by abstracting away the raw arguments in an ExperimentalEvent
and requiring access to the arguments via a new method, ArgValue. This
returns a Value, which gives us an opportunity to construct a typed
value for the raw argument dynamically, and a way to access existing
tables. The type of the argument is deduced from conventions for the
argument's name. This seems more than sufficient for experimental
events.

To make this work, we also need to add a "string" variant to the Value
type. This may be a little confusing since they're primarily used for
metrics, but one could imagine other scenarios in which this is useful,
such as including build information in the trace as a metric, so I think
this is fine.

This change also updates the Value API to accomodate a String method for
use with things that expect a fmt.Stringer, which means renaming the
value assertion methods to have a "To" prefix.

Change-Id: I43a2334f6cd306122c5b94641a6252ca4258b39f
Reviewed-on: https://go-review.googlesource.com/c/go/+/645135
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-02-11 11:23:31 -08:00
Michael Anthony Knyszek
659b895067 internal/trace: move fake P IDs to internal/trace/traceviewer
These fake P IDs really only belong to the traceviewer.

Change-Id: I7976beb5750f1efca85e28975074a8c570a9c959
Reviewed-on: https://go-review.googlesource.com/c/go/+/644876
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-02-11 11:23:28 -08:00
Michael Anthony Knyszek
0be3701cb6 internal/trace: clean up parser.go
parser.go is an old file that contains trace v1 definitions and a second
equivalent definition for stack frames. These are redundant and useless.
Delete these definitions and rename the file to fakep.go, which
describes the only thing left in this file, a bunch of fake P IDs used
by the trace viewer.

We should consider moving the fake P definitions elsewhere, too.

Change-Id: Ifd0768bd73c39009069445afe0155f1e352f00c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/644875
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-11 11:23:26 -08:00
Michael Anthony Knyszek
b5f34aa4ab runtime: use internal/trace/tracev2 definitions
This change deduplicates trace wire format definitions between the
runtime and the trace parser by making the internal/trace/tracev2
package the source of truth.

Change-Id: Ia0721d3484a80417e40ac473ec32870bee73df09
Reviewed-on: https://go-review.googlesource.com/c/go/+/644221
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-11 11:23:24 -08:00
Michael Anthony Knyszek
0158ddad98 internal/trace: move maxArgs into tracev2 and validate specs
This change moves maxArgs to tracev2 and renames it MaxTimedEventArgs.
It also updates the tests to make sure the specs conform to this
requirement.

Change-Id: I7b0c888a4dfd83306a470a4c9b0f9e44fe2e7818
Reviewed-on: https://go-review.googlesource.com/c/go/+/646016
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-02-11 11:22:32 -08:00
Michael Anthony Knyszek
fadfe2fc80 internal/trace/tracev2: add test to validate spec invariants
This change adds a test to help guide people adding experiments to this
package by validating that the spec is written correctly.

Also, makes some minor tweaks to the package in order to get the tests
to pass.

Change-Id: I3daa420c5a9ec3ea536415c8e5d06f41666a9566
Reviewed-on: https://go-review.googlesource.com/c/go/+/646015
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-02-11 10:45:18 -08:00
qmuntal
e9eb88ae72 {all,clean,make,race,run}.bat: simplify error handling
The bat files can use "if" + parentheses to make it easier to
understand how the if-case is handled rather than the more cryptic
"if" + "goto".

While here, replace some "goto"s with direct "exit" calls.

Change-Id: I20e1804439b5088f8f1e5cbf8676f3d58560109d
Reviewed-on: https://go-review.googlesource.com/c/go/+/648375
Auto-Submit: Damien Neil <dneil@google.com>
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>
2025-02-11 09:45:10 -08:00
Sean Liao
450f3f608d net/http/httptest: match net/http ContentLength behavior for http.NoBody
Fixes #68476

Change-Id: I05122e5ec5e6b290eec93f3db444fcf1de19c030
Reviewed-on: https://go-review.googlesource.com/c/go/+/599815
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Daniel Martí <mvdan@mvdan.cc>
2025-02-11 08:49:01 -08:00
Sean Liao
dcbdc1a2f7 cmd/go/internal/modload: don't set GIT_SSH_COMMAND
Allows git core.sshcommand to take effect when set by the user.
This was originally added to work around an issue in
OpenSSH < 7.3 (2016), see https://go.dev/issue/13453 .
A fixed version of OpenSSH should be widely available enough
that it is no longer necessary

Fixes #71482

Change-Id: I6f44cc354e8a4063e226cac78ec27117fcc40e93
Reviewed-on: https://go-review.googlesource.com/c/go/+/647995
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Auto-Submit: Daniel Martí <mvdan@mvdan.cc>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2025-02-11 08:36:42 -08:00
Michael Anthony Knyszek
887d9ef610 internal/trace: increment sync counter before final Sync on error
CL 648195 was supposed to have fixed #71615, but it didn't include an
update to r.syncs. I can confirm this CL fixes the issue even when
running the test many times in a row.

Fixes #71615.

Change-Id: I97db3d639dc5bc8648a191696f90b0e5087307c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/648315
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
2025-02-11 08:21:30 -08:00
cuishuang
7c1a4134b4 strings: add examples for Lines, SplitSeq, SplitAfterSeq, FieldsSeq and FieldsFuncSeq
Change-Id: I1e5085ff2ed7f3d75ac3dc34ab72be6b55729fb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/647575
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-10 21:47:04 -08:00
Damien Neil
371e83cd7b os: add Root.Chmod
For #67002

Change-Id: Id6c3a2096bd10f5f5f6921a0441dc6d9e6cdeb3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/645718
Commit-Queue: 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>
Auto-Submit: Damien Neil <dneil@google.com>
2025-02-10 15:33:35 -08:00
Daniel McCarney
2e8973aeea crypto/internal/fips140test: add feedback KDF ACVP tests
Adds ACVP test coverage for the SP 800-108r1 KDF feedback mode algorithm
based on the NIST spec:

  https://pages.nist.gov/ACVP/draft-celi-acvp-kbkdf.html

The HKDF-based implementation in our FIPS module fixes some parameters,
requiring tailoring of the advertised capability to match. Notably:

* We only support fixedDataOrder "after fixed data"
* We only support a counter length of 8 bits
* We only support empty IVs

No acvp_test.config.json update accompanies this support because the
ACVP tests for this algorithm aren't amenable to fixed data testing.

Updates #69642

Change-Id: I729e899377a64d2b613d6435241aebabeef93bca
Reviewed-on: https://go-review.googlesource.com/c/go/+/640016
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-02-10 13:57:24 -08:00
Daniel McCarney
ea54d8a0ef crypto/internal/fips140test: add RSA ACVP tests
Adds ACVP test coverage for the RSA algorithm based on the NIST spec:
  https://pages.nist.gov/ACVP/draft-celi-acvp-rsa.html

Includes coverage for keyGen, sigGen and sigVer across a variety of
modulus sizes. For sigGen and sigVer both PKCS1v1.5 and PSS are
supported with a variety of SHA2 digests.

The static test data from go-acvp only includes sigVer vectors/expected.
The keyGen and sigGen test types aren't amenable to fixed data testing.

Updates #69642

Change-Id: Ia61a69115f2d2a984b95435a37d4c9c6db90a89a
Reviewed-on: https://go-review.googlesource.com/c/go/+/642135
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-02-10 13:55:31 -08:00
Daniel McCarney
0c94c5fcae crypto/internal/fips140test: add counter KDF ACVP tests
Adds ACVP test coverage for the SP 800-108r1 KDF counter mode algorithm
based on the NIST spec:

  https://pages.nist.gov/ACVP/draft-celi-acvp-kbkdf.html

The implementation in our FIPS module fixes some parameters, requiring
tailoring of the advertised capability to match. Notably:

* We only support macModes CMAC-AES-128, -192, and -256
* We only support supportedLengths 256 (matching the [32]byte output
  from CounterKDF.DeriveKey)
* We only support fixedDataOrder "before fixed data"
* We only support counterLength 16

No acvp_test.config.json update accompanies this support because the
ACVP tests for this algorithm aren't amenable to fixed data testing.

Updates #69642

Change-Id: I9e02d6c8cb6e209ac8e4c9fba926fffbad916098
Reviewed-on: https://go-review.googlesource.com/c/go/+/639776
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
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>
2025-02-10 13:55:28 -08:00
Daniel McCarney
0bc57a3e7f crypto/internal/fips140test: add ctr DRBG ACVP tests
Adds ACVP test coverage for the SP 800-90A rev 1 ctrDRBG algorithm based
on the NIST spec:
  https://pages.nist.gov/ACVP/draft-vassilev-acvp-drbg.html#section-7.2

The implementation in our FIPS module is a minimal implementation
tailored to the specific needs of stdlib crypto. As a result we
customize the ACVP capability registration so that:

* predResistanceEnabled is false
* only mode AES-256 is supported
* for that mode,
  * derFuncEnabled is false
  * persoStringLen is 0 to disable personalization
  * additionalInputLen is 384 to match the [48]byte argument in our API

Other capability values are chosen based on Table 4's ctrDRBG AES-256
w/o `derFuncEnabled` row:
  https://pages.nist.gov/ACVP/draft-vassilev-acvp-drbg.html#section-7.4

We do enable reseed in the capability, necessitating two acvptool
commands: one that expects only 6 args and doesn't reseed
("ctrDRBG/AES-256"), and one that expects 8 args and does
("ctrDRBG-reseed/AES-256").

Updates #69642

Change-Id: I0f01a2f9496f45b130ee7d10916708093236f473
Reviewed-on: https://go-review.googlesource.com/c/go/+/639795
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-10 13:54:29 -08:00
Michael Anthony Knyszek
283296195b internal/trace: emit a Sync event even if the next generation is broken
Since CL 644215 each Sync event now represents the coming generation,
with a final Sync event emitted even when there's nothing ahead. This
change however failed to emit a Sync event at the end of a completely
valid generation when the next generation was invalid, causing the
runtime test TestCrashWhileTracing to start failing.

Fix this by emitting a final Sync event even when the next generation is
broken. We hold onto the error in parsing the next generation and emit
it after that final Sync event.

(Should these "final" Sync events distinguish themselves in some way?)

Fixes #71615.

Change-Id: I1f8abee5abaa39e1219e6fa05e9f82f1478db4c9
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/648195
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-10 13:39:31 -08:00
Daniel McCarney
ee8db080c8 crypto/internal/fips140test: add KAS-ECC-SSC ACVP tests
Adds ACVP test coverage for the Sp800-56Ar3 KAS-ECC-SSC algorithm based
on the NIST spec:

  https://pages.nist.gov/ACVP/draft-hammett-acvp-kas-ssc-ecc.html

There's no acvp_test.config.json update for this algorithm as one test
type type requires random key generation and can't be separated from the
test type that doesn't, making it a bad fit for static data testing.

Updates #69642

Change-Id: I3b6538fad1c1e5c8b14b638ff3b933f11e98f75a
Reviewed-on: https://go-review.googlesource.com/c/go/+/637916
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-10 13:29:42 -08:00
Daniel McCarney
86aca87788 crypto/internal/fips140test: add SSH KDF ACVP tests
Adds ACVP test coverage for the SP 800-135rev1 SSH KDF based on the NIST
spec:

  https://pages.nist.gov/ACVP/draft-celi-acvp-kdf-ssh.html

Only SHA1, SHA2-224, SHA2-256, SHA2-384, and SHA2-512 are valid hash
algorithms for the SSH KDF algorithm. We do not include SHA-1 since it
is out of scope for our FIPS module.

Similarly only TDES, AES-128, AES-192 and AES-256 are valid ciphers, and
we do not include TDES.

Updates #69642

Change-Id: I70e45b77a91bd8aa631da30fab54c97e974f433c
Reviewed-on: https://go-review.googlesource.com/c/go/+/636355
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-02-10 13:29:40 -08:00
Keith Randall
072eea9b3b cmd/compile: avoid ifaceeq call if we know the interface is direct
We can just use == if the interface is direct.

Fixes #70738

Change-Id: Ia9a644791a370fec969c04c42d28a9b58f16911f
Reviewed-on: https://go-review.googlesource.com/c/go/+/635435
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@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>
2025-02-10 13:28:41 -08:00
Mateusz Poliwczak
c8664ced4e cmd/compile/internal/gc: handle errors from *bio.Writer
The error is stored internally in *bio.Writer, more specifically
in *bufio.Writer and the current code does not handle it, ignoring
errors silently.

Change-Id: Iefa9bf7ddabb3c4fc03377e676a8098dcad9be6d
GitHub-Last-Rev: a5d36223312773039c37bb1c52fffc96fff04fba
GitHub-Pull-Request: golang/go#71621
Reviewed-on: https://go-review.googlesource.com/c/go/+/647915
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
2025-02-10 13:08:23 -08:00
WANG Xuerui
3105e3dca7 cmd/go/internal/work: allow a bunch of loong64-specific flags
Recognize and allow all LoongArch-specific CFLAGS as standardized
in the LoongArch Toolchain Conventions v1.1, and implemented in current
versions of GCC and Clang, to enable advanced cgo use cases on loong64.
These flags are also allowed for linker invocations in case of possible
LTO.

See: https://github.com/loongson/la-toolchain-conventions/blob/releases/v1.1/LoongArch-toolchain-conventions-EN.adoc#list

While at it, also add support for -mtls-dialect as some C programs
may benefit performance-wise from the optional TLSDESC usage. This flag
is not specific to loong64 though; it is available for amd64, arm,
arm64, loong64, riscv64 and x86.

Fixes #71597.

Change-Id: I35d2507edb71fa324ae429a3ae3c739644a9cac1
Reviewed-on: https://go-review.googlesource.com/c/go/+/647956
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
2025-02-10 12:51:14 -08:00
apocelipes
7715ca32fc database/sql: use t.Context in tests
Replace "context.WithCancel(context.Background())" with "t.Context()".

Updates #36532

Change-Id: I78a8ba422f076f4c697910922cf6dc35c628b1a7
GitHub-Last-Rev: 2eacdbe9ea97ac8d928704c2b605b276626d95dd
GitHub-Pull-Request: golang/go#71599
Reviewed-on: https://go-review.googlesource.com/c/go/+/647555
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-10 12:34:55 -08:00
Tom Thorogood
6fd3ce52bb net/http: use standard time formatting methods
time.Time has had an AppendFormat method since go1.5 so there's no
need to carry around a custom implementation.

Change-Id: I8e7e5a9ac34e8bf251f5d70555405777ce4e22a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/647955
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-02-10 12:28:00 -08:00
Michael Anthony Knyszek
8b8ab2584d internal/trace: merge event and tracev2 packages
These two packages were historically separate in an attempt to provide a
unified description of trace v1 and trace v2 formats. In practice this
turned out to be pointless, since it made more sense to keep the trace
v1 parser in a self-contained bubble with a converter to v2. Future
trace wire format migrations should probably just follow the same
general strategy, if there's a substantial change. (Minor changes can be
handled more organically.)

Change-Id: Ic765df62065fe53cfae59b505297527c3fa42dfb
Reviewed-on: https://go-review.googlesource.com/c/go/+/645395
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-10 12:14:51 -08:00
Michael Anthony Knyszek
9faa00af74 internal/trace/internal/testgen: force trace version selection
Currently testgen only generates Go 1.22 tests. Allow generating tests
for different versions, especially now that we've tightened up which
events can be emitted by different versions.

Change-Id: Ia64309c6934f34eace03b3229d05fca5acfc7366
Reviewed-on: https://go-review.googlesource.com/c/go/+/644220
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-10 12:14:47 -08:00
Michael Anthony Knyszek
715754ba86 internal/trace: be stricter about allowed events in v2 trace versions
Currently all v2 trace versions, Go 1.22 and Go 1.23, share a full set
of specs. This is mostly OK, but it means quite a few events will be
accepted for 1.22 traces that should be rejected. This change fixes that
by limiting which event specs are returned by version.Version.Specs for
Go 1.22.

While we're here, let's be stricter about event names too, and move
tracev2.EventString to be a method on the version, so we can be more
precise. An intended consequence of this move is that tracev2 no longer
depends on fmt, since we will want the runtime to depend on tracev2 in
the near future.

Change-Id: If7285460c8ba59ab73da00993b7b12e61cdfe6a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/644219
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-10 12:14:44 -08:00
Michael Anthony Knyszek
0f62125487 internal/trace: rename go122 to tracev2
This change follows up from the previous one which renamed oldtrace to
tracev1, defining everything Go 1.22+ as trace v2.

This change also re-maps some packages in preparation for sharing with
other parts of the standard library, like the runtime. It also cleans up
some other uses of 'go122' that are just a bit misleading. The mappings
are as follows:

- internal/trace/event -> internal/trace/tracev2/event
- internal/trace/event/go122 -> internal/trace/tracev2
- internal/trace/internal/testgen/go122 ->
  internal/trace/internal/testgen

The CL updates all import paths and runs gofmt -w -s on the entire
subdirectory.

Change-Id: I35476c679a96d4eafad6b94bac5f88aa7b085d2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/644218
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-10 12:10:14 -08:00
Damien Neil
3924fe92b6 runtime: establish happens-before between goroutine and bubble exit
synctest.Run waits for all bubbled goroutines to exit before returning.
Establish a happens-before relationship between the bubbled goroutines
exiting and Run returning.

For #67434

Change-Id: Ibda7ec2075ae50838c0851e60dc5b3c6f3ca70fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/647755
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>
2025-02-10 10:48:27 -08:00
Michael Anthony Knyszek
a704d39b29 os: hide SetFinalizer from users of Root
Currently Root embeds a root and calls SetFinalizer on &r.root. This
sets the finalizer on the outer root, which is visible to users of
os.Root, and thus they can mutate the finalizer attached to it.

This change modifies Root to not embed its inner root, but rather to
refer to it by pointer. This allows us to set the finalizer on this
independent inner object, preventing users of os.Root from changing the
finalizer. This follows the same pattern as os.File's finalizer.

Fixes #71617.

Change-Id: Ibd199bab1b3c877d5e12ef380fd4647b4e10221f
Reviewed-on: https://go-review.googlesource.com/c/go/+/647876
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-10 10:18:55 -08:00
Daniel McCarney
47d0b0f2bf crypto/internal/fips140test: add TLS-v1.3 ACVP tests
Adds ACVP test coverage for the SP 800-56Crev2 IG 2.4.B TLS v1.3 KDF
based on the NIST spec:

  https://pages.nist.gov/ACVP/draft-hammett-acvp-kdf-tls-v1.3.html

Only SHA2-256 and SHA2-384 are valid hash algorithms for the TLS1.3 KDF
algorithm.

The BoringSSL acvptool "lowers" the more complicated TLS 1.3 KDF ACVP
test cases into simple invocations of our module wrapper's pre-existing
HKDF commands, and the new "HKDFExtract/$HASH" and
"HKDFExpandLabel/$HASH" commands added in this branch.

Updates #69642

Change-Id: I5fb1af5b5b33c1845b27cf8968e6523e89bcc589
Reviewed-on: https://go-review.googlesource.com/c/go/+/636117
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2025-02-10 09:33:15 -08:00
Daniel McCarney
3310f324ad crypto/internal/fips140test: add TLS-v1.2 ACVP tests
Adds ACVP test coverage for the SP 800-135rev1 RFC 7627 TLS v1.2 KDF
based on the NIST spec:

  https://pages.nist.gov/ACVP/draft-celi-acvp-kdf-tls.html

Only SHA2-256, SHA2-384 and SHA2-512 are valid hash algorithms for the
TLSKDF algorithm.

Updates #69642

Change-Id: I553d4f6a1d6652ed486af0e2c94730c8063fb47f
Reviewed-on: https://go-review.googlesource.com/c/go/+/636116
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2025-02-10 09:33:14 -08:00
Daniel McCarney
0580e2a496 crypto/internal/fips140test: add KDA HKDF ACVP tests
Adds ACVP test coverage for the SP 800-56Crev2 HKDF KDA based on the
NIST spec:

 https://pages.nist.gov/ACVP/draft-hammett-acvp-kas-kdf-hkdf.html

Updates #69642

Change-Id: Ie4f48f9b0181eaf6c2201a9796d366a31c474eba
Reviewed-on: https://go-review.googlesource.com/c/go/+/636115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-02-10 09:33:11 -08:00
Daniel McCarney
035d3c8f53 crypto/internal/fips140test: add SHAKE-* ACVP tests
This commit adds ACVP test coverage for SHAKE-128 and SHAKE-256
based on the NIST spec:

  https://pages.nist.gov/ACVP/draft-celi-acvp-sha3.html

Updates #69642

Change-Id: Ia6899def452fcb63a03603b7919fcb0c3576474b
Reviewed-on: https://go-review.googlesource.com/c/go/+/622395
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-10 09:33:03 -08:00
Jakub Ciolek
8cb6d3b826 cmd/compile: mark PCMPEQB as commutative
compilecmp linux/amd64:

internal/runtime/maps
internal/runtime/maps.(*table).Delete changed

internal/runtime/maps [cmd/compile]
internal/runtime/maps.(*Map).Delete changed
internal/runtime/maps.(*table).Delete changed

Change-Id: Ic3c95411c23cab7427e63105170de41e5766f809
Reviewed-on: https://go-review.googlesource.com/c/go/+/647935
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>
Auto-Submit: Keith Randall <khr@golang.org>
2025-02-10 08:44:42 -08:00
Pasha Radchenko
472d285906 crypto/aes: more precise description for AES keys requirements
The existing documentation is not certain in the place regarding requirements about AES key.
Added some notes for precise description.

Change-Id: I190562ab7c1566cce8e7771f9927d738c72880ce
GitHub-Last-Rev: 6565a8f4e5b37220fd14d55e876b809b2d763b7c
GitHub-Pull-Request: golang/go#71589
Reviewed-on: https://go-review.googlesource.com/c/go/+/647336
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-02-10 08:30:07 -08:00
Mateusz Poliwczak
74c3b3784e cmd/internal/bio: remove unused MustWriter
Change-Id: I70435781fbaeca2b6927a74afd79a3ff123b527b
GitHub-Last-Rev: cae569f4c4bf73a9a6cd8d26fb080962f94bf1b1
GitHub-Pull-Request: golang/go#71622
Reviewed-on: https://go-review.googlesource.com/c/go/+/647916
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
2025-02-10 08:22:10 -08:00
pgxiaolianzi
181cf3c95e text/template: handle UnsafePointer in isTrue
Change-Id: I4d0b5919d109f768ba04ab519e8f948a5749a752
GitHub-Last-Rev: 6f27f1193c21bb10e3b81660b4271f2c1f33be1e
GitHub-Pull-Request: golang/go#70520
Reviewed-on: https://go-review.googlesource.com/c/go/+/631076
Run-TryBot: Rob Pike <r@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2025-02-10 08:21:56 -08:00
Daniel McCarney
ae26a30bb0 crypto/internal/fips140test: add CMAC-AES ACVP tests
Adds ACVP test coverage for CMAC-AES based on the NIST spec:
  https://pages.nist.gov/ACVP/draft-fussell-acvp-mac.html

Updates #69642

Change-Id: Ie731863b84c6f8d74c64daa6a6848354420151b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/635762
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>
2025-02-10 05:50:37 -08:00
Cherry Mui
ff27d270c9 bytes: use "subslice" instead of "substring" in doc comments
The bytes package iterators return subslices, not substrings.

Updates #61901.

Change-Id: Ida91d3e33a0f178edfe9a267861adf4f13f9a965
Reviewed-on: https://go-review.googlesource.com/c/go/+/647875
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-09 13:15:13 -08:00
Meng Zhuo
215de81513 cmd/compile: don't merge symbols on riscv64 when dynamic linking
Each plugin is compiled as a separate shared object,
with its own symbol table. When dynamic linking plugin symbols
are resolved within the plugin's scope, not globally merged to
avoid conflicts.

Change-Id: I9e6986085855c17fbd6c39b937cb6129d216f5e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/435015
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-07 22:55:44 -08:00
Robert Griesemer
a4fcfaa167 go/types, types2: better error messages for channel sends and receives
Use the same code pattern for sends and receives and factor it out
into a new helper method Checker.chanElem.

Provide the exact error cause rather than simply referring to the
core type.

For #70128.

Change-Id: I4a0b597a487b78c057eebe06c4ac28f9bf1f7719
Reviewed-on: https://go-review.googlesource.com/c/go/+/647455
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-07 20:40:05 -08:00
Ian Lance Taylor
ff627d28db os: improve comments for process support, minor code cleanup
Change-Id: I97ecbc6fc0c73c6d8469144f86a7ad8c2655a658
Reviewed-on: https://go-review.googlesource.com/c/go/+/638581
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-07 17:12:12 -08:00
Ian Lance Taylor
646d285d7d os: simplify Process.Release
Consolidate release/deactivation into a single doRelease method.
It needs to check GOOS for backward compatibility, but it's
simpler to keep all the logic in one place.

Change-Id: I242eb084d44d2682f862a8fbf55c410fb8c53358
Reviewed-on: https://go-review.googlesource.com/c/go/+/638580
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-07 17:10:44 -08:00
Ian Lance Taylor
bdbc5ca1bd os: use AddCleanup, not SetFinalizer, for Process
There is no reason to use a cleanup/finalizer for a Process that
doesn't use a handle, because Release doesn't change anything visible
about the process.

For #70907

Change-Id: I3b92809175523ceee2e07d601cc2a8e8b86321e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/638579
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-07 16:21:02 -08:00
Michael Anthony Knyszek
8028731648 internal/trace: rename "oldtrace" to trace v1
This is part of a refactoring to better distinguish trace wire format
versions. Even though details may change between Go versions and they
might be backwards-incompatible, the trace format still broadly has two
wire formats: v1 and v2.

A follow-up change will rename go122 to v2 to make this more consistent.

Change-Id: If4fe1c82d8aeabc8baa05f525e08a9e7d469a5c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/644217
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-07 12:12:39 -08:00
Michael Anthony Knyszek
a4ef655ede internal/trace: move SchedReqs out of events package
It's only used by order.go; there's no reason for it to be in a shared
package.

Change-Id: If99df075089e6f6e37a78b12e64a1b81a556331c
Reviewed-on: https://go-review.googlesource.com/c/go/+/644216
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-02-07 12:12:36 -08:00
Michael Anthony Knyszek
ca1cfea371 internal/trace: refactor how experimental batches are exposed
This change modifies how per-generation experimental batches are
exposed. Rather than expose them on the ExperimentalEvent, it exposes it
as part of the Sync event, so it's clear to the caller when the
information becomes relevant and when it should be parsed.

This change also adds a field to each ExperimentalEvent indicating which
experiment the event is a part of.

Because this information needs to appear *before* a generation is
observed, we now ensure there is a sync event both before and after each
generation. This means the final sync event is now a special case;
previously we would only emit a sync event after each generation.

This change is based on feedback from Austin Clements on the
experimental events functionality.

For #62627.

Change-Id: I48b0fe12b22abb7ac8820a9e73447bfed8419856
Reviewed-on: https://go-review.googlesource.com/c/go/+/644215
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-07 12:12:33 -08:00
Ian Lance Taylor
d7f6f6fd54 bufio: skip network test if unixpacket socket not supported
Change-Id: I03434fdc4916fc8d195de2617edc28ec4b66a172
Reviewed-on: https://go-review.googlesource.com/c/go/+/647535
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>
Reviewed-by: Damien Neil <dneil@google.com>
2025-02-07 11:37:07 -08:00
Damien Neil
cb47156e90 testing/synctest: add an example of testing networked code
For #67434

Change-Id: If7dcd3bf7bb69e1730856405d55cffc72ce0e132
Reviewed-on: https://go-review.googlesource.com/c/go/+/645675
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>
2025-02-07 09:32:22 -08:00
qmuntal
1bfbefa159 make.bat: pass through all arguments to "dist bootstrap"
nolocal is (almost) no longer needed after CL 647115. If we remove it,
then we can pass through all arguments to the Go command, which is
useful for running tests with additional flags, like -json or -v.

This CL also updates all.bat to use "go tool dist" instead of
"%GOTOOLDIR%/dist", as %GOTOOLDIR% is no longer set after making
make.bat uncoditionally set nolocal.

Change-Id: I97dc687faa5686d023f7d7d2b96637295995fe67
Reviewed-on: https://go-review.googlesource.com/c/go/+/647117
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-07 09:14:03 -08:00
qmuntal
580a383103 {all,clean,make,race,run}.bat: use || instead of "if errorlevel 1"
"if errorlevel 1" is and old construct that returns true if the
errorlevel is greater than or equal to 1. There are better alternatives
since Windows NT. For example, the || operator runs the RHS operand if
the preceding command failed, determined by checking that the errorlevel
is different from 0. This approach is more robust -it also works with
negative errorlevels- and is less verbose.

Change-Id: I2070d654d8f9dd41a6cd586ba5ad5f4fea0638ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/647136
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>
2025-02-07 09:13:54 -08:00
Daniel McCarney
302bf36314 crypto/internal/fips140test: add AES ACVP tests
Adds ACVP AES test coverage for:

* AES CBC
* AES CTR
* AES GCM (both internal & external iv gen)

For AES key sizes of 128, 192, and 256 bits, based on the NIST spec:

  https://pages.nist.gov/ACVP/draft-celi-acvp-symmetric.html

ECB mode is excluded based on upcoming policy changes forbidding its
use.

Internal IV gen is excluded from the go-acvp static test data since it's
non-deterministic based on the DRBG.

Updates #69642

Change-Id: I34f471725e2f1a2f5d32ab9877bde153abf2db0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/627655
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-02-07 08:58:24 -08:00
Daniel McCarney
273db12cee crypto/internal/fips140test: add DetECDSA ACVP tests
Adds ACVP test coverage for deterministic ECDSA based on the NIST spec:
  https://pages.nist.gov/ACVP/draft-fussell-acvp-ecdsa.html

Notably there is no corresponding acvp_test.config.json update in this
commit because ACVP DetECDSA only specifies sigGen mode.

The ACVP ECDSA sigGen tests are not amenable to testing against
static data because the test vectors don't provide a key pair to use for
the signature, just the message. The module wrapper has to generate its
own keypair and return the public key components with the signature.
DetECDSA produces deterministic signatures only when signing the same
message with the same key.

Change-Id: I9921f52e943c96b32e02e79cb5556ba0fabeae17
Reviewed-on: https://go-review.googlesource.com/c/go/+/635341
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2025-02-07 08:57:41 -08:00
Daniel McCarney
78132a1f57 crypto/internal/fips140test: add ECDSA ACVP tests
This commit adds ACVP test coverage for the non-deterministic ECDSA
vectors (keyGen, keyVer, sigGen, sigVer) based on the NIST spec:

  https://pages.nist.gov/ACVP/draft-fussell-acvp-ecdsa.html

Updates #69642

Change-Id: Iec8b18a247b0a652d13f9167a78de2cb74f4dfd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/620935
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
TryBot-Bypass: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-07 08:57:34 -08:00
Daniel McCarney
f99a214d96 crypto/internal/fips140test: add EDDSA ACVP tests
This commit adds ACVP test coverage for EDDSA (Ed25519, and
HashEd25519/Ed25519ph) for the keyGen, keyVer, sigGen, and sigVer
capabilities.

Updates #69642

Change-Id: I5122d86180bd4d2f7d94570a6dc939808aa24fc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/621135
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-07 08:53:31 -08:00
Quim Muntal
d9d87edc56 Revert "cmd/go: report gcc ld error message when linking fails"
This reverts CL 646315.

Reason for revert: broke cgo_undef test

Change-Id: Ic992a1666a446736c605a8caefa77f791dceb64c
Reviewed-on: https://go-review.googlesource.com/c/go/+/647415
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-07 08:41:37 -08:00
Alexander Yastrebov
9125e214a1 crypto/internal/fips140/edwards25519/field: speed up Element.Bytes
Write bytes in 64-bit chunks made from adjacent limbs.

goos: linux
goarch: amd64
pkg: crypto/internal/fips140/edwards25519/field
cpu: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
        │   HEAD~1    │                HEAD                 │
        │   sec/op    │   sec/op     vs base                │
Bytes-8   76.14n ± 3%   13.61n ± 3%  -82.13% (p=0.000 n=10)

        │   HEAD~1   │              HEAD              │
        │    B/op    │    B/op     vs base            │
Bytes-8   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

        │   HEAD~1   │              HEAD              │
        │ allocs/op  │ allocs/op   vs base            │
Bytes-8   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

Change-Id: Iaecc32da7fd8df96ff048e1e855a990f44dc9db5
GitHub-Last-Rev: d0e1583a4faf8cc3471af03437107cc0e5770d57
GitHub-Pull-Request: golang/go#71603
Reviewed-on: https://go-review.googlesource.com/c/go/+/647595
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-02-07 08:39:38 -08:00
qmuntal
6563a23560 run.bat: pass through all arguments to "go tool dist test"
nolocal is no longer needed after CL 647115. If we remove it, then
we can pass through all arguments to the Go command, which is
useful for running tests with additional flags, like -json or -v.

Change-Id: I5c48d9b90720c039bf2ec3d9213e7ce5cea33818
Reviewed-on: https://go-review.googlesource.com/c/go/+/647116
Reviewed-by: Damien Neil <dneil@google.com>
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>
2025-02-07 08:37:00 -08:00
qmuntal
09fdcdc97d {all,clean,make,race,run}.bat: remove %GOBUILDEXIT% and %GOBUILDFAIL%
%GOBUILDEXIT% is used to avoid closing the terminal window when the
build or the tests fail on a dev machine. It is only set in CI to get
a non-zero exit code in case of failure.

%GOBUILDFAIL% is used to pass the exit code from a child batch file to
the parent batch file. It is set to 1 in the child batch file if the
build or the tests fail.

These two variables add complexity to the batch files and impose some
limitations on how they are implemented. For example, the child files
can't use setlocal, as it would make the parent file unable to read the
%GOBUILDFAIL% variable.

This CL removes these two variables and replaces them with unconditional
calls to "exit /b 1" in case of failure, which is more idiomatic and
composable. The trick is that the "/b" parameter makes the exit only
apply to the current batch file, not the entire shell session (unless
the bat file is the root, in which case the parameter is ignored), so
the parent batch file can continue executing, potentially checking the
errorlevel of the child batch file (which we always set to 1).

Change-Id: Ib053fb181ab14d58679551e03485700de77878d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/647115
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: Damien Neil <dneil@google.com>
2025-02-07 08:33:18 -08:00
Joel Sing
7a2f757c52 cmd/internal/obj/riscv: update references to RISC-V specification
Update references to version 20240411 of the RISC-V specifications.
Reorder and regroup instructions to maintain ordering. Also be
consistent with formatting.

The instruction encodings table was seemingly missed in CL 616115.

Change-Id: I47b7c8538383ff3b0503ba59db570c3d4f0d5653
Reviewed-on: https://go-review.googlesource.com/c/go/+/631935
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>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Pengcheng Wang <wangpengcheng.pp@bytedance.com>
2025-02-07 02:19:17 -08:00
Joel Sing
b8fb95becd crypto/internal/fips140/subtle: combine xor_<goarch>.go files
There is not much point in having per architecture files that all contain
the same content. Instead, merge the various xor_<goarch>.go files into a
single xor_asm.go file that has appropriate build tags.

Change-Id: I555d44b2fd83f260a4855d83cacb9e101d689bc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/639856
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: Filippo Valsorda <filippo@golang.org>
2025-02-07 01:33:26 -08:00
Joel Sing
85b5d11246 crypto/subtle: add additional benchmarks for XORBytes
Provide alignment benchmarks for XORBytes, as well as including
8192 byte blocks in the existing benchmarks. This allows us to
better evaluate performance with unaligned inputs.

Change-Id: Iad497c594c0425389ae02ca848aede5cb0ac3afd
Reviewed-on: https://go-review.googlesource.com/c/go/+/639316
Reviewed-by: Cherry Mui <cherryyz@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>
2025-02-07 01:32:39 -08:00
qmuntal
76c18e2ed2 cmd/link: add -e (no limit on errors) flag
The compiler and assembler have a -e flag that disables the limit
on the number of errors before the build fails. This flag is useful
for debugging, the linker should have it too.

Change-Id: I892cfd6ee1519e9e86261af7d05e1af2ded21684
Reviewed-on: https://go-review.googlesource.com/c/go/+/646435
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-02-06 22:43:06 -08:00
Ian Lance Taylor
e7c9667def os: simplify process status
Since it no longer holds a reference count, just use values.

For #70907

Change-Id: I19a42583988d4f8a9133b1c837356ca0179d688c
Reviewed-on: https://go-review.googlesource.com/c/go/+/638578
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-02-06 17:14:46 -08:00
Ian Lance Taylor
caf29da4cc os: don't store reference count in Process.state
We only need a reference count in processHandle.

For #70907
Fixes #71564

Change-Id: I209ded869203dea10f12b070190774fb5f1d3d71
Reviewed-on: https://go-review.googlesource.com/c/go/+/638577
Commit-Queue: 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>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-02-06 17:11:12 -08:00
Ian Lance Taylor
637c235b51 lib/time: build with Ubuntu backward compatibility options
Change-Id: I7e241eb602e45eea3c730793c14d8a5f666f9181
Reviewed-on: https://go-review.googlesource.com/c/go/+/644077
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-02-06 17:10:15 -08:00
Ian Lance Taylor
290ec2d92b bufio: don't do empty Write at start of WriteTo
The empty Write will cause the wrong thing to happen when using
io.Copy to copy to a package-based stream.

Fixes #71424

Change-Id: I046a27539447182692ac76a8bdd422327345dd8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/644535
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-02-06 17:08:54 -08:00
Ian Lance Taylor
7c6b047ea1 encoding/base64: use internal/byteorder
This permits us to remove the dependency on reflect.

Change-Id: I60b1e9fd713f340bfd5eec2edfa58fc724a8e2d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/641936
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-02-06 16:40:55 -08:00
Ian Lance Taylor
5c9b13d90f crypto/internal/fips140/drbg: add package comment
For #69536

Change-Id: I70d2ed10555fed244f08c898899399e3032e17b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/640597
Reviewed-by: Robert Griesemer <gri@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>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-02-06 15:59:26 -08:00
Ian Lance Taylor
88108cc563 cmd/go: adjust testsuite to add reraised panic message
A couple of tests generate different output due to CL 645916
for issue #71517.

Fixes #71593
Fixes #71594

Change-Id: Ifaeff4e9de8d881202bd9e6394c9b9cff8959596
Reviewed-on: https://go-review.googlesource.com/c/go/+/647495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-02-06 15:50:10 -08:00
Luka Krmpotic
372f2d8022 unicode/utf8: remove init from utf8_test
TestConstants and init test the same thing, remove init,
it does not exist in utf16_test.go either.

Fixes #71579

Change-Id: Ie0afd640bebde822733b6eac0bf98a17872f4e5f
GitHub-Last-Rev: d7224c18376e00038261279abdfa954abc3a8303
GitHub-Pull-Request: golang/go#71582
Reviewed-on: https://go-review.googlesource.com/c/go/+/647335
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-06 14:13:50 -08:00
thepudds
8163ea1458 weak: prevent unsafe conversions using weak pointers
Prevent conversions between Pointer types,
like we do for sync/atomic.Pointer.

Fixes #71583

Change-Id: I20e83106d8a27996f221e6cd9d52637b0442cea4
Reviewed-on: https://go-review.googlesource.com/c/go/+/647195
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-06 13:16:59 -08:00
Damien Neil
478ad013f9 runtime: don't duplicate reraised panic values in printpanics
Change the output printed when crashing with a reraised panic value
to not duplicate that value.

Changes output of panicking with "PANIC", recovering, and reraising
from:

  panic: PANIC [recovered]
    panic: PANIC

to:

  panic: PANIC [recovered, reraised]

Fixes #71517

Change-Id: Id59938c4ea0df555b851ffc650fe6f94c0845499
Reviewed-on: https://go-review.googlesource.com/c/go/+/645916
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-06 12:02:14 -08:00
Ian Lance Taylor
9b4a462a7d cmd/cgo: use strings.Builder to build long strings
Change-Id: I33ba7c8a7b731647cdff3ffe7c4274f76f8923ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/638736
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2025-02-06 09:49:04 -08:00
Jesse Rittner
0da7fafac4 net: fix ListenMulitcastUDP to work properly when interface has no IPv4
The existing implementation would either fail or bind to the wrong interface
when the requested interface had no IPv4 address, such as when the Ethernet cable
was unplugged.

Now on Linux, it will always bind to the requested interface.
On other operating systems, it will consistently fail if the requested interface
has no IPv4 address.

Fixes #70132

Change-Id: I22ec7f9d4adaa4b5afb21fc448050fb4219cacee
Reviewed-on: https://go-review.googlesource.com/c/go/+/644375
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: 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>
2025-02-06 09:36:55 -08:00
qmuntal
65004c7bf4 cmd/go: report gcc ld error message when linking fails
The output of the gcc ld command is useful to understand why a package
that uses cgo can't use internal linking. We should log it.

Change-Id: Id524065fc5348be57387f2b67d1e00861f9adf15
Reviewed-on: https://go-review.googlesource.com/c/go/+/646315
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>
2025-02-06 09:10:09 -08:00
Jakub Ciolek
cd595be6d6 cmd/compile: prefer an add when shifting left by 1
ADD(Q|L) has generally twice the throughput.

Came up in CL 626998.

Throughput by arch:

Zen 4:

SHLL (R64, 1):   0.5
ADD  (R64, R64): 0.25

Intel Alder Lake:

SHLL (R64, 1):   0.5
ADD  (R64, R64): 0.2

Intel Haswell:

SHLL (R64, 1):   0.5
ADD  (R64, R64): 0.25

Also include a minor opt for:

(x + x) << c -> x << (c + 1)

Before this, the code:

func addShift(x int64) int64 {
    return (x + x) << 1
}

emitted two instructions:

        ADDQ    AX, AX
        SHLQ    $1, AX

but we can do it in a single shift:

        SHLQ    $2, AX

Add a codegen test for clearing the last bit.

compilecmp linux/amd64:

math
math.sqrt 243 -> 242  (-0.41%)

math [cmd/compile]
math.sqrt 243 -> 242  (-0.41%)

runtime
runtime.selectgo 5455 -> 5445  (-0.18%)
runtime.sysargs 665 -> 662  (-0.45%)
runtime.isPinned 145 -> 141  (-2.76%)
runtime.atoi64 198 -> 194  (-2.02%)
runtime.setPinned 714 -> 709  (-0.70%)

runtime [cmd/compile]
runtime.sysargs 665 -> 662  (-0.45%)
runtime.setPinned 714 -> 709  (-0.70%)
runtime.atoi64 198 -> 194  (-2.02%)
runtime.isPinned 145 -> 141  (-2.76%)

strconv
strconv.computeBounds 109 -> 107  (-1.83%)
strconv.FormatInt 201 -> 197  (-1.99%)
strconv.ryuFtoaShortest 1298 -> 1266  (-2.47%)
strconv.small 144 -> 134  (-6.94%)
strconv.AppendInt 357 -> 344  (-3.64%)
strconv.ryuDigits32 490 -> 488  (-0.41%)
strconv.AppendUint 342 -> 340  (-0.58%)

strconv [cmd/compile]
strconv.FormatInt 201 -> 197  (-1.99%)
strconv.ryuFtoaShortest 1298 -> 1266  (-2.47%)
strconv.ryuDigits32 490 -> 488  (-0.41%)
strconv.AppendUint 342 -> 340  (-0.58%)
strconv.computeBounds 109 -> 107  (-1.83%)
strconv.small 144 -> 134  (-6.94%)
strconv.AppendInt 357 -> 344  (-3.64%)

image
image.Rectangle.Inset 101 -> 97  (-3.96%)

regexp/syntax
regexp/syntax.inCharClass.func1 111 -> 110  (-0.90%)
regexp/syntax.(*compiler).quest 586 -> 573  (-2.22%)
regexp/syntax.ranges.Less 153 -> 150  (-1.96%)
regexp/syntax.(*compiler).loop 583 -> 568  (-2.57%)

time
time.Time.Before 179 -> 161  (-10.06%)
time.Time.Compare 189 -> 166  (-12.17%)
time.Time.Sub 444 -> 425  (-4.28%)
time.Time.UnixMicro 106 -> 95  (-10.38%)
time.div 592 -> 587  (-0.84%)
time.Time.UnixNano 85 -> 78  (-8.24%)
time.(*Time).UnixMilli 141 -> 140  (-0.71%)
time.Time.UnixMilli 106 -> 95  (-10.38%)
time.(*Time).UnixMicro 141 -> 140  (-0.71%)
time.Time.After 179 -> 161  (-10.06%)
time.Time.Equal 170 -> 150  (-11.76%)
time.Time.AppendBinary 766 -> 757  (-1.17%)
time.Time.IsZero 74 -> 66  (-10.81%)
time.(*Time).UnixNano 124 -> 113  (-8.87%)
time.(*Time).IsZero 113 -> 108  (-4.42%)

regexp
regexp.(*Regexp).FindAllStringSubmatch.func1 590 -> 569  (-3.56%)
regexp.QuoteMeta 485 -> 469  (-3.30%)

regexp/syntax [cmd/compile]
regexp/syntax.inCharClass.func1 111 -> 110  (-0.90%)
regexp/syntax.(*compiler).loop 583 -> 568  (-2.57%)
regexp/syntax.(*compiler).quest 586 -> 573  (-2.22%)
regexp/syntax.ranges.Less 153 -> 150  (-1.96%)

encoding/base64
encoding/base64.decodedLen 92 -> 90  (-2.17%)
encoding/base64.(*Encoding).DecodedLen 99 -> 97  (-2.02%)

time [cmd/compile]
time.(*Time).IsZero 113 -> 108  (-4.42%)
time.Time.IsZero 74 -> 66  (-10.81%)
time.(*Time).UnixNano 124 -> 113  (-8.87%)
time.Time.UnixMilli 106 -> 95  (-10.38%)
time.Time.Equal 170 -> 150  (-11.76%)
time.Time.UnixMicro 106 -> 95  (-10.38%)
time.(*Time).UnixMicro 141 -> 140  (-0.71%)
time.Time.Before 179 -> 161  (-10.06%)
time.Time.UnixNano 85 -> 78  (-8.24%)
time.Time.AppendBinary 766 -> 757  (-1.17%)
time.div 592 -> 587  (-0.84%)
time.Time.After 179 -> 161  (-10.06%)
time.Time.Compare 189 -> 166  (-12.17%)
time.(*Time).UnixMilli 141 -> 140  (-0.71%)
time.Time.Sub 444 -> 425  (-4.28%)

index/suffixarray
index/suffixarray.sais_8_32 1677 -> 1645  (-1.91%)
index/suffixarray.sais_32 1677 -> 1645  (-1.91%)
index/suffixarray.sais_64 1677 -> 1654  (-1.37%)
index/suffixarray.sais_8_64 1677 -> 1654  (-1.37%)
index/suffixarray.writeInt 249 -> 247  (-0.80%)

os
os.Expand 1070 -> 1051  (-1.78%)
os.Chtimes 787 -> 774  (-1.65%)

regexp [cmd/compile]
regexp.(*Regexp).FindAllStringSubmatch.func1 590 -> 569  (-3.56%)
regexp.QuoteMeta 485 -> 469  (-3.30%)

encoding/base64 [cmd/compile]
encoding/base64.decodedLen 92 -> 90  (-2.17%)
encoding/base64.(*Encoding).DecodedLen 99 -> 97  (-2.02%)

encoding/hex
encoding/hex.Encode 138 -> 136  (-1.45%)
encoding/hex.(*decoder).Read 830 -> 824  (-0.72%)

crypto/des
crypto/des.initFeistelBox 235 -> 229  (-2.55%)
crypto/des.cryptBlock 549 -> 538  (-2.00%)

os [cmd/compile]
os.Chtimes 787 -> 774  (-1.65%)
os.Expand 1070 -> 1051  (-1.78%)

math/big
math/big.newFloat 238 -> 223  (-6.30%)
math/big.nat.mul 2138 -> 2122  (-0.75%)
math/big.karatsubaSqr 1372 -> 1369  (-0.22%)
math/big.(*Float).sqrtInverse 895 -> 878  (-1.90%)
math/big.basicSqr 1032 -> 1017  (-1.45%)

cmd/vendor/golang.org/x/sys/unix
cmd/vendor/golang.org/x/sys/unix.TimeToTimespec 72 -> 66  (-8.33%)

encoding/json
encoding/json.Indent 404 -> 403  (-0.25%)
encoding/json.MarshalIndent 303 -> 297  (-1.98%)

testing
testing.(*T).Deadline 84 -> 82  (-2.38%)
testing.(*M).Run 3545 -> 3525  (-0.56%)

archive/zip
archive/zip.headerFileInfo.ModTime 229 -> 223  (-2.62%)

encoding/gob
encoding/gob.(*encoderState).encodeInt 474 -> 469  (-1.05%)

crypto/elliptic
crypto/elliptic.Marshal 728 -> 714  (-1.92%)

debug/buildinfo
debug/buildinfo.readString 325 -> 315  (-3.08%)

image/png
image/png.(*decoder).readImagePass 10866 -> 10834  (-0.29%)

archive/tar
archive/tar.Header.allowedFormats.func3 1768 -> 1736  (-1.81%)
archive/tar.formatPAXTime 389 -> 358  (-7.97%)
archive/tar.(*Writer).writeGNUHeader 741 -> 727  (-1.89%)
archive/tar.readGNUSparseMap0x1 709 -> 695  (-1.97%)
archive/tar.(*Writer).templateV7Plus 915 -> 909  (-0.66%)

crypto/internal/cryptotest
crypto/internal/cryptotest.TestHash.func4 890 -> 879  (-1.24%)
crypto/internal/cryptotest.TestStream.func6.1 646 -> 645  (-0.15%)
crypto/internal/cryptotest.testCipher.func3 1300 -> 1289  (-0.85%)

internal/pkgbits
internal/pkgbits.(*Encoder).Int64 113 -> 103  (-8.85%)
internal/pkgbits.(*Encoder).rawVarint 74 -> 72  (-2.70%)

testing/quick
testing/quick.(*Config).getRand 316 -> 315  (-0.32%)

log/slog
log/slog.TimeValue 489 -> 479  (-2.04%)

runtime/pprof
runtime/pprof.(*profileBuilder).build 2341 -> 2322  (-0.81%)

internal/coverage/cfile
internal/coverage/cfile.(*emitState).openMetaFile 824 -> 822  (-0.24%)
internal/coverage/cfile.(*emitState).openCounterFile 904 -> 892  (-1.33%)

cmd/internal/objabi
cmd/internal/objabi.expandArgs 1177 -> 1169  (-0.68%)

crypto/ecdsa
crypto/ecdsa.pointFromAffine 1162 -> 1144  (-1.55%)

net
net.minNonzeroTime 313 -> 308  (-1.60%)
net.cgoLookupAddrPTR 812 -> 797  (-1.85%)
net.(*IPNet).String 851 -> 827  (-2.82%)
net.IP.AppendText 488 -> 471  (-3.48%)
net.IPMask.String 281 -> 270  (-3.91%)
net.partialDeadline 374 -> 366  (-2.14%)
net.hexString 249 -> 240  (-3.61%)
net.IP.String 454 -> 453  (-0.22%)

internal/fuzz
internal/fuzz.newPcgRand 240 -> 234  (-2.50%)

crypto/x509
crypto/x509.(*Certificate).isValid 2642 -> 2611  (-1.17%)

cmd/internal/obj/s390x
cmd/internal/obj/s390x.buildop 33676 -> 33644  (-0.10%)

encoding/hex [cmd/compile]
encoding/hex.(*decoder).Read 830 -> 824  (-0.72%)
encoding/hex.Encode 138 -> 136  (-1.45%)

cmd/internal/objabi [cmd/compile]
cmd/internal/objabi.expandArgs 1177 -> 1169  (-0.68%)

math/big [cmd/compile]
math/big.(*Float).sqrtInverse 895 -> 878  (-1.90%)
math/big.nat.mul 2138 -> 2122  (-0.75%)
math/big.karatsubaSqr 1372 -> 1369  (-0.22%)
math/big.basicSqr 1032 -> 1017  (-1.45%)
math/big.newFloat 238 -> 223  (-6.30%)

encoding/json [cmd/compile]
encoding/json.MarshalIndent 303 -> 297  (-1.98%)
encoding/json.Indent 404 -> 403  (-0.25%)

cmd/covdata
main.(*metaMerge).emitCounters 985 -> 973  (-1.22%)

runtime/pprof [cmd/compile]
runtime/pprof.(*profileBuilder).build 2341 -> 2322  (-0.81%)

cmd/compile/internal/syntax
cmd/compile/internal/syntax.(*source).fill 722 -> 703  (-2.63%)

cmd/dist
main.runInstall 19081 -> 19049  (-0.17%)

crypto/tls
crypto/tls.extractPadding 176 -> 175  (-0.57%)
slices.Clone[[]crypto/tls.SignatureScheme,crypto/tls.SignatureScheme] 253 -> 247  (-2.37%)
slices.Clone[[]uint16,uint16] 253 -> 247  (-2.37%)
slices.Clone[[]crypto/tls.CurveID,crypto/tls.CurveID] 253 -> 247  (-2.37%)
crypto/tls.(*Config).cipherSuites 335 -> 326  (-2.69%)
slices.DeleteFunc[go.shape.[]crypto/tls.CurveID,go.shape.uint16] 437 -> 434  (-0.69%)
crypto/tls.dial 1349 -> 1339  (-0.74%)
slices.DeleteFunc[go.shape.[]uint16,go.shape.uint16] 437 -> 434  (-0.69%)

internal/pkgbits [cmd/compile]
internal/pkgbits.(*Encoder).Int64 113 -> 103  (-8.85%)
internal/pkgbits.(*Encoder).rawVarint 74 -> 72  (-2.70%)

cmd/compile/internal/syntax [cmd/compile]
cmd/compile/internal/syntax.(*source).fill 722 -> 703  (-2.63%)

cmd/internal/obj/s390x [cmd/compile]
cmd/internal/obj/s390x.buildop 33676 -> 33644  (-0.10%)

cmd/go/internal/trace
cmd/go/internal/trace.Flow 910 -> 886  (-2.64%)
cmd/go/internal/trace.(*Span).Done 311 -> 304  (-2.25%)
cmd/go/internal/trace.StartSpan 620 -> 615  (-0.81%)

cmd/internal/script
cmd/internal/script.(*Engine).Execute.func2 534 -> 528  (-1.12%)

cmd/link/internal/loader
cmd/link/internal/loader.(*Loader).SetSymSect 344 -> 338  (-1.74%)

net/http
net/http.(*Transport).queueForIdleConn 1797 -> 1766  (-1.73%)
net/http.(*Transport).getConn 2149 -> 2131  (-0.84%)
net/http.(*http2ClientConn).tooIdleLocked 207 -> 197  (-4.83%)
net/http.(*http2responseWriter).SetWriteDeadline.func1 520 -> 508  (-2.31%)
net/http.(*Cookie).Valid 837 -> 818  (-2.27%)
net/http.(*http2responseWriter).SetReadDeadline 373 -> 357  (-4.29%)
net/http.checkIfRange 701 -> 690  (-1.57%)
net/http.(*http2SettingsFrame).Value 325 -> 298  (-8.31%)
net/http.(*http2SettingsFrame).HasDuplicates 777 -> 767  (-1.29%)
net/http.(*Server).Serve 1746 -> 1739  (-0.40%)
net/http.http2traceGotConn 569 -> 556  (-2.28%)

net/http/pprof
net/http/pprof.collectProfile 242 -> 239  (-1.24%)

cmd/compile/internal/coverage
cmd/compile/internal/coverage.metaHashAndLen 439 -> 438  (-0.23%)

cmd/vendor/golang.org/x/telemetry/internal/upload
cmd/vendor/golang.org/x/telemetry/internal/upload.(*uploader).findWork 4570 -> 4540  (-0.66%)
cmd/vendor/golang.org/x/telemetry/internal/upload.(*uploader).reports 3604 -> 3572  (-0.89%)

cmd/compile/internal/coverage [cmd/compile]
cmd/compile/internal/coverage.metaHashAndLen 439 -> 438  (-0.23%)

cmd/vendor/golang.org/x/text/language
cmd/vendor/golang.org/x/text/language.regionGroupDist 287 -> 284  (-1.05%)

cmd/go/internal/vcweb
cmd/go/internal/vcweb.(*Server).overview.func1 1045 -> 1041  (-0.38%)

cmd/go/internal/vcs
cmd/go/internal/vcs.expand 761 -> 741  (-2.63%)

cmd/compile/internal/inline/inlheur
slices.stableCmpFunc[go.shape.struct 2300 -> 2284  (-0.70%)

cmd/compile/internal/inline/inlheur [cmd/compile]
slices.stableCmpFunc[go.shape.struct 2300 -> 2284  (-0.70%)

cmd/go/internal/modfetch/codehost
cmd/go/internal/modfetch/codehost.bzrParseStat 2217 -> 2213  (-0.18%)

cmd/link/internal/ld
cmd/link/internal/ld.decodetypeStructFieldCount 157 -> 152  (-3.18%)
cmd/link/internal/ld.(*Link).address 12559 -> 12495  (-0.51%)
cmd/link/internal/ld.(*dodataState).allocateDataSections 18345 -> 18205  (-0.76%)
cmd/link/internal/ld.elfshreloc 618 -> 616  (-0.32%)
cmd/link/internal/ld.(*deadcodePass).decodetypeMethods 794 -> 779  (-1.89%)
cmd/link/internal/ld.(*dodataState).assignDsymsToSection 668 -> 663  (-0.75%)
cmd/link/internal/ld.relocSectFn 285 -> 284  (-0.35%)
cmd/link/internal/ld.decodetypeIfaceMethodCount 146 -> 144  (-1.37%)
cmd/link/internal/ld.decodetypeArrayLen 157 -> 152  (-3.18%)

cmd/link/internal/arm64
cmd/link/internal/arm64.gensymlate.func1 895 -> 888  (-0.78%)

cmd/go/internal/modload
cmd/go/internal/modload.queryProxy.func3 1029 -> 1012  (-1.65%)

cmd/go/internal/load
cmd/go/internal/load.(*Package).setBuildInfo 8453 -> 8447  (-0.07%)

cmd/go/internal/clean
cmd/go/internal/clean.runClean 2120 -> 2104  (-0.75%)

cmd/compile/internal/ssa
cmd/compile/internal/ssa.(*poset).aliasnodes 2010 -> 1978  (-1.59%)
cmd/compile/internal/ssa.rewriteValueARM64_OpARM64MOVHstoreidx2 730 -> 719  (-1.51%)
cmd/compile/internal/ssa.(*debugState).buildLocationLists 3326 -> 3294  (-0.96%)
cmd/compile/internal/ssa.rewriteValueAMD64_OpAMD64ADDLconst 3069 -> 2941  (-4.17%)
cmd/compile/internal/ssa.(*debugState).processValue 9756 -> 9724  (-0.33%)
cmd/compile/internal/ssa.rewriteValueAMD64_OpAMD64ADDQconst 3069 -> 2941  (-4.17%)
cmd/compile/internal/ssa.(*poset).mergeroot 1079 -> 1054  (-2.32%)

cmd/compile/internal/ssa [cmd/compile]
cmd/compile/internal/ssa.rewriteValueARM64_OpARM64MOVHstoreidx2 730 -> 719  (-1.51%)
cmd/compile/internal/ssa.(*poset).aliasnodes 2010 -> 1978  (-1.59%)
cmd/compile/internal/ssa.(*poset).mergeroot 1079 -> 1054  (-2.32%)
cmd/compile/internal/ssa.rewriteValueAMD64_OpAMD64ADDQconst 3069 -> 2941  (-4.17%)
cmd/compile/internal/ssa.rewriteValueAMD64_OpAMD64ADDLconst 3069 -> 2941  (-4.17%)

file                                                before   after    Δ       %
math/bits.s                                         2352     2354     +2      +0.085%
math/bits [cmd/compile].s                           2352     2354     +2      +0.085%
math.s                                              35675    35674    -1      -0.003%
math [cmd/compile].s                                35675    35674    -1      -0.003%
runtime.s                                           577251   577245   -6      -0.001%
runtime [cmd/compile].s                             642419   642438   +19     +0.003%
sort.s                                              37434    37435    +1      +0.003%
strconv.s                                           48391    48343    -48     -0.099%
sort [cmd/compile].s                                37434    37435    +1      +0.003%
bufio.s                                             21386    21418    +32     +0.150%
strconv [cmd/compile].s                             48391    48343    -48     -0.099%
image.s                                             34978    35022    +44     +0.126%
regexp/syntax.s                                     81719    81781    +62     +0.076%
time.s                                              94341    94184    -157    -0.166%
regexp.s                                            60411    60399    -12     -0.020%
bufio [cmd/compile].s                               21512    21544    +32     +0.149%
encoding/binary.s                                   34062    34087    +25     +0.073%
regexp/syntax [cmd/compile].s                       81719    81781    +62     +0.076%
encoding/base64.s                                   11907    11903    -4      -0.034%
time [cmd/compile].s                                94341    94184    -157    -0.166%
index/suffixarray.s                                 41633    41527    -106    -0.255%
os.s                                                101770   101738   -32     -0.031%
regexp [cmd/compile].s                              60411    60399    -12     -0.020%
encoding/binary [cmd/compile].s                     37173    37198    +25     +0.067%
encoding/base64 [cmd/compile].s                     11907    11903    -4      -0.034%
os/exec.s                                           23900    23907    +7      +0.029%
encoding/hex.s                                      6038     6030     -8      -0.132%
crypto/des.s                                        5073     5056     -17     -0.335%
os [cmd/compile].s                                  102030   101998   -32     -0.031%
vendor/golang.org/x/net/http2/hpack.s               22027    22033    +6      +0.027%
math/big.s                                          164808   164753   -55     -0.033%
cmd/vendor/golang.org/x/sys/unix.s                  121450   121444   -6      -0.005%
encoding/json.s                                     110294   110287   -7      -0.006%
testing.s                                           115303   115281   -22     -0.019%
archive/zip.s                                       65329    65325    -4      -0.006%
os/user.s                                           10078    10080    +2      +0.020%
encoding/gob.s                                      143788   143783   -5      -0.003%
crypto/elliptic.s                                   30686    30704    +18     +0.059%
go/doc/comment.s                                    49401    49433    +32     +0.065%
debug/buildinfo.s                                   9095     9085     -10     -0.110%
image/png.s                                         36113    36081    -32     -0.089%
archive/tar.s                                       71994    71897    -97     -0.135%
crypto/internal/cryptotest.s                        60872    60849    -23     -0.038%
internal/pkgbits.s                                  20441    20429    -12     -0.059%
testing/quick.s                                     8236     8235     -1      -0.012%
log/slog.s                                          77568    77558    -10     -0.013%
internal/trace/internal/oldtrace.s                  52885    52896    +11     +0.021%
runtime/pprof.s                                     123978   123969   -9      -0.007%
internal/coverage/cfile.s                           25198    25184    -14     -0.056%
cmd/internal/objabi.s                               19954    19946    -8      -0.040%
crypto/ecdsa.s                                      29159    29141    -18     -0.062%
log/slog/internal/benchmarks.s                      6694     6695     +1      +0.015%
net.s                                               299569   299503   -66     -0.022%
os/exec [cmd/compile].s                             23888    23895    +7      +0.029%
internal/trace.s                                    179226   179240   +14     +0.008%
internal/fuzz.s                                     86190    86191    +1      +0.001%
crypto/x509.s                                       177195   177164   -31     -0.017%
cmd/internal/obj/s390x.s                            121642   121610   -32     -0.026%
cmd/internal/obj/ppc64.s                            140118   140122   +4      +0.003%
encoding/hex [cmd/compile].s                        6149     6141     -8      -0.130%
cmd/internal/objabi [cmd/compile].s                 19954    19946    -8      -0.040%
cmd/internal/obj/arm64.s                            158523   158555   +32     +0.020%
go/doc/comment [cmd/compile].s                      49512    49544    +32     +0.065%
math/big [cmd/compile].s                            166394   166339   -55     -0.033%
encoding/json [cmd/compile].s                       110712   110705   -7      -0.006%
cmd/covdata.s                                       39699    39687    -12     -0.030%
runtime/pprof [cmd/compile].s                       125209   125200   -9      -0.007%
cmd/compile/internal/syntax.s                       181755   181736   -19     -0.010%
cmd/dist.s                                          177893   177861   -32     -0.018%
crypto/tls.s                                        389157   389113   -44     -0.011%
internal/pkgbits [cmd/compile].s                    41644    41632    -12     -0.029%
cmd/compile/internal/syntax [cmd/compile].s         196105   196086   -19     -0.010%
cmd/compile/internal/types.s                        71315    71345    +30     +0.042%
cmd/internal/obj/s390x [cmd/compile].s              121733   121701   -32     -0.026%
cmd/go/internal/trace.s                             4796     4760     -36     -0.751%
cmd/internal/obj/arm64 [cmd/compile].s              168120   168147   +27     +0.016%
cmd/internal/obj/ppc64 [cmd/compile].s              140219   140223   +4      +0.003%
cmd/internal/script.s                               83442    83436    -6      -0.007%
cmd/link/internal/loader.s                          93299    93294    -5      -0.005%
net/http.s                                          620639   620472   -167    -0.027%
net/http/pprof.s                                    35016    35013    -3      -0.009%
cmd/compile/internal/coverage.s                     6668     6667     -1      -0.015%
cmd/vendor/golang.org/x/telemetry/internal/upload.s 34210    34148    -62     -0.181%
cmd/compile/internal/coverage [cmd/compile].s       6664     6663     -1      -0.015%
cmd/vendor/golang.org/x/text/language.s             48077    48074    -3      -0.006%
cmd/go/internal/vcweb.s                             45193    45189    -4      -0.009%
cmd/go/internal/vcs.s                               44749    44729    -20     -0.045%
cmd/compile/internal/inline/inlheur.s               83758    83742    -16     -0.019%
cmd/compile/internal/inline/inlheur [cmd/compile].s 84773    84757    -16     -0.019%
cmd/go/internal/modfetch/codehost.s                 89098    89094    -4      -0.004%
cmd/trace.s                                         257550   257564   +14     +0.005%
cmd/link/internal/ld.s                              641945   641706   -239    -0.037%
cmd/link/internal/arm64.s                           34805    34798    -7      -0.020%
cmd/go/internal/modload.s                           328971   328954   -17     -0.005%
cmd/go/internal/load.s                              178877   178871   -6      -0.003%
cmd/go/internal/clean.s                             11006    10990    -16     -0.145%
cmd/compile/internal/ssa.s                          3552843  3553347  +504    +0.014%
cmd/compile/internal/ssa [cmd/compile].s            3752511  3753123  +612    +0.016%
total                                               36179015 36178687 -328    -0.001%

Change-Id: I251c2898ccf3c9931d162d87dabbd49cf4ec73a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/641757
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-06 09:05:20 -08:00
Ian Lance Taylor
a8e532b0f2 runtime/cgo: clarify that C code must not retain pointer
For #71566

Change-Id: I6dc365dd799d7b506b4a55895f1736d3dfd4684b
Reviewed-on: https://go-review.googlesource.com/c/go/+/647095
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
2025-02-06 05:37:51 -08:00
apocelipes
4cc7705e56 testing: use strings.SplitSeq and bytes.SplitSeq
To simplify the code. This is a follow-up for the CL 646216.

Change-Id: Ib09d1074a783482fb293527e9f1abeb3c02137c3
GitHub-Last-Rev: 2e7a6ad40cc22ea855e4d703ff39db9cc2c8a58e
GitHub-Pull-Request: golang/go#71568
Reviewed-on: https://go-review.googlesource.com/c/go/+/646755
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Salah (Globlost) <globlost@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-02-05 15:53:08 -08:00
Roland Shoemaker
51bf2cf7cf Revert "cmd/go/internal/work: allow @ character in some -Wl, linker flags on darwin"
This reverts CL 638075 (commit e3cd55e9d293d519e622e788e902f372dc30338a).

This change introduced a security issue as @ flags are first resolved as
files by the darwin linker, before their meaning as flags, allowing the
flag filtering logic to be entirely bypassed.

Thanks to Juho Forsén for reporting this issue.

Fixes #71476
Fixes CVE-2025-22867

Change-Id: I3a4b4a6fc534de105d930b8ed5b9900bc94b0c4e
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1900
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/646996
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-05 13:31:48 -08:00
Michael Matloob
220fe79871 cmd/go: add '-skip' to list of cacheable test flags
-run is cacheable, so -skip should be cacheable too.

Fixes #70692

Change-Id: I16880189b0d3a963f8f08008fc7fedcdc6f11630
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/646997
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
2025-02-05 13:25:26 -08:00
Dmitri Shuralyov
b45c7d5466 internal/trace: skip TestTraceCgoCallback on freebsd-amd64-race builders
For #71556.

Change-Id: I754f113bfdad244d0e978cf559bf45f2f4d7bf06
Reviewed-on: https://go-review.googlesource.com/c/go/+/646396
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-05 12:06:13 -08:00
Dmitri Shuralyov
ee6e0a5ed6 internal/routebsd: fix typo in sockAddrLen identifer name
For #70528.

Change-Id: I0db75cb998aeb299676384fe59bf241db18ebc5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/646975
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-05 11:19:56 -08:00
Tobias Klauser
721f5ca4ed runtime: adjust comments for auxv getAuxv
github.com/cilium/ebpf no longer accesses getAuxv using linkname but now
uses the golang.org/x/sys/unix.Auxv wrapper introduced in
go.dev/cl/644295.

Also adjust the list of users to include x/sys/unix.

Updates #67839
Updates #67401

Change-Id: Ieee266360b22cc0bc4be8f740e0302afd7dbd14f
Reviewed-on: https://go-review.googlesource.com/c/go/+/646535
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-05 09:41:51 -08:00
Dmitri Shuralyov
a7cbea8332 cmd/go: skip bzr tests if 'bzr help' has non-zero exit code
It appears to be quite easy to end up with a broken 'bzr' installation.
For example, if bzr was installed via a system-wide package manager and
intends to work with a system-wide Python installation, it may break if
another 'python3' binary is added to PATH.

If something as simple as 'bzr help' fails to exit with zero code,
consider it broken and skip tests that require a working bzr binary
just like if the 'bzr' binary isn't present in PATH at all.

This makes these tests more robust and capable of producing useful
signal in more environments. Separately from this, we'll want to
restore a working bzr installation on the linux-arm64 builders, but
at least there's still one on linux-amd64 builders.

For #71563.
Fixes #71504.

Change-Id: Ia147196f12b90a0731ebbfab63b5de308212ed65
Cq-Include-Trybots: luci.golang.try:gotip-linux-arm64-longtest,gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/646715
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-05 09:23:15 -08:00
Ian Lance Taylor
f6ea0621d2 internal/routebsd: fix parsing network address of length zero
This applies CL 646555 from the net repository to this copy.

For #70528

Change-Id: Ib7e23accfa3f278392e7bdca6f8544b8f1395e7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/646676
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Bypass: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-05 09:18:29 -08:00
Jakub Ciolek
b7c9cdd53c cmd/compile: establish limits of bool to uint8 conversions
Improves bound check elimination for:

func arrayLargeEnough(b bool, a [2]int64) int64 {
    c := byte(0)
    if b {
        c = 1
    }

    // this bound check gets elided
    return a[c]
}

We also detect never true branches like:

func cCanOnlyBe0or1(b bool) byte {
    var c byte
    if b {
        c = 1
    }
    // this statement can never be true so we can elide it
    if c == 2 {
        c = 3
    }

    return c
}

Hits a few times:

crypto/internal/sysrand
crypto/internal/sysrand.Read 357 -> 349  (-2.24%)

testing
testing.(*F).Fuzz.func1.1 837 -> 828  (-1.08%)

image/png
image/png.(*Encoder).Encode 1735 -> 1733  (-0.12%)

vendor/golang.org/x/crypto/cryptobyte
vendor/golang.org/x/crypto/cryptobyte.(*Builder).callContinuation 187 -> 185  (-1.07%)

crypto/internal/sysrand [cmd/compile]
crypto/internal/sysrand.Read 357 -> 349  (-2.24%)

go/parser
go/parser.(*parser).parseType 463 -> 457  (-1.30%)
go/parser.(*parser).embeddedElem 633 -> 626  (-1.11%)
go/parser.(*parser).parseFuncDecl 917 -> 914  (-0.33%)
go/parser.(*parser).parseDotsType 393 -> 391  (-0.51%)
go/parser.(*parser).error 1061 -> 1054  (-0.66%)
go/parser.(*parser).parseTypeName 537 -> 532  (-0.93%)
go/parser.(*parser).parseParamDecl 1478 -> 1451  (-1.83%)
go/parser.(*parser).parseFuncTypeOrLit 498 -> 495  (-0.60%)
go/parser.(*parser).parseValue 375 -> 371  (-1.07%)
go/parser.(*parser).parseElementList 594 -> 593  (-0.17%)
go/parser.(*parser).parseResult 593 -> 583  (-1.69%)
go/parser.(*parser).parseElement 506 -> 504  (-0.40%)
go/parser.(*parser).parseImportSpec 1110 -> 1108  (-0.18%)
go/parser.(*parser).parseStructType 741 -> 735  (-0.81%)
go/parser.(*parser).parseTypeSpec 1054 -> 1048  (-0.57%)
go/parser.(*parser).parseIdentList 625 -> 623  (-0.32%)
go/parser.(*parser).parseOperand 1221 -> 1199  (-1.80%)
go/parser.(*parser).parseIndexOrSliceOrInstance 2713 -> 2694  (-0.70%)
go/parser.(*parser).parseSwitchStmt 1458 -> 1447  (-0.75%)
go/parser.(*parser).parseArrayFieldOrTypeInstance 1865 -> 1861  (-0.21%)
go/parser.(*parser).parseExpr 307 -> 305  (-0.65%)
go/parser.(*parser).parseSelector 427 -> 425  (-0.47%)
go/parser.(*parser).parseTypeInstance 1433 -> 1420  (-0.91%)
go/parser.(*parser).parseCaseClause 629 -> 626  (-0.48%)
go/parser.(*parser).parseParameterList 4212 -> 4189  (-0.55%)
go/parser.(*parser).parsePointerType 393 -> 391  (-0.51%)
go/parser.(*parser).parseFuncType 465 -> 463  (-0.43%)
go/parser.(*parser).parseTypeAssertion 559 -> 557  (-0.36%)
go/parser.(*parser).parseSimpleStmt 2443 -> 2388  (-2.25%)
go/parser.(*parser).parseCallOrConversion 1093 -> 1087  (-0.55%)
go/parser.(*parser).parseForStmt 2168 -> 2159  (-0.42%)
go/parser.(*parser).embeddedTerm 657 -> 649  (-1.22%)
go/parser.(*parser).parseCommClause 1509 -> 1501  (-0.53%)

cmd/internal/objfile
cmd/internal/objfile.(*goobjFile).symbols 5299 -> 5274  (-0.47%)

net
net.initConfVal 378 -> 374  (-1.06%)
net.(*conf).hostLookupOrder 269 -> 267  (-0.74%)
net.(*conf).addrLookupOrder 261 -> 255  (-2.30%)

cmd/internal/obj/loong64
cmd/internal/obj/loong64.(*ctxt0).oplook 1829 -> 1813  (-0.87%)

cmd/internal/obj/mips
cmd/internal/obj/mips.(*ctxt0).oplook 1428 -> 1400  (-1.96%)

go/types
go/types.(*typeWriter).signature 605 -> 601  (-0.66%)
go/types.(*Checker).instantiateSignature 1469 -> 1467  (-0.14%)

go/parser [cmd/compile]
go/parser.(*parser).parseSwitchStmt 1458 -> 1447  (-0.75%)
go/parser.(*parser).parseDotsType 393 -> 391  (-0.51%)
go/parser.(*parser).embeddedElem 633 -> 626  (-1.11%)
go/parser.(*parser).parseTypeAssertion 559 -> 557  (-0.36%)
go/parser.(*parser).parseCommClause 1509 -> 1501  (-0.53%)
go/parser.(*parser).parseCaseClause 629 -> 626  (-0.48%)
go/parser.(*parser).parseImportSpec 1110 -> 1108  (-0.18%)
go/parser.(*parser).parseTypeSpec 1054 -> 1048  (-0.57%)
go/parser.(*parser).parseElementList 594 -> 593  (-0.17%)
go/parser.(*parser).parseParamDecl 1478 -> 1451  (-1.83%)
go/parser.(*parser).parseType 463 -> 457  (-1.30%)
go/parser.(*parser).parseSimpleStmt 2443 -> 2388  (-2.25%)
go/parser.(*parser).parseIdentList 625 -> 623  (-0.32%)
go/parser.(*parser).parseTypeInstance 1433 -> 1420  (-0.91%)
go/parser.(*parser).parseResult 593 -> 583  (-1.69%)
go/parser.(*parser).parseValue 375 -> 371  (-1.07%)
go/parser.(*parser).parseFuncDecl 917 -> 914  (-0.33%)
go/parser.(*parser).error 1061 -> 1054  (-0.66%)
go/parser.(*parser).parseElement 506 -> 504  (-0.40%)
go/parser.(*parser).parseFuncType 465 -> 463  (-0.43%)
go/parser.(*parser).parsePointerType 393 -> 391  (-0.51%)
go/parser.(*parser).parseTypeName 537 -> 532  (-0.93%)
go/parser.(*parser).parseExpr 307 -> 305  (-0.65%)
go/parser.(*parser).parseFuncTypeOrLit 498 -> 495  (-0.60%)
go/parser.(*parser).parseStructType 741 -> 735  (-0.81%)
go/parser.(*parser).parseOperand 1221 -> 1199  (-1.80%)
go/parser.(*parser).parseIndexOrSliceOrInstance 2713 -> 2694  (-0.70%)
go/parser.(*parser).parseForStmt 2168 -> 2159  (-0.42%)
go/parser.(*parser).parseParameterList 4212 -> 4189  (-0.55%)
go/parser.(*parser).parseArrayFieldOrTypeInstance 1865 -> 1861  (-0.21%)
go/parser.(*parser).parseSelector 427 -> 425  (-0.47%)
go/parser.(*parser).parseCallOrConversion 1093 -> 1087  (-0.55%)
go/parser.(*parser).embeddedTerm 657 -> 649  (-1.22%)

crypto/tls
crypto/tls.(*Conn).clientHandshake 3430 -> 3421  (-0.26%)

cmd/internal/obj/mips [cmd/compile]
cmd/internal/obj/mips.(*ctxt0).oplook 1428 -> 1400  (-1.96%)

cmd/internal/obj/loong64 [cmd/compile]
cmd/internal/obj/loong64.(*ctxt0).oplook 1829 -> 1813  (-0.87%)

cmd/compile/internal/types2
cmd/compile/internal/types2.(*typeWriter).signature 605 -> 601  (-0.66%)
cmd/compile/internal/types2.(*Checker).infer 10646 -> 10614  (-0.30%)
cmd/compile/internal/types2.(*Checker).instantiateSignature 1567 -> 1561  (-0.38%)

cmd/compile/internal/types2 [cmd/compile]
cmd/compile/internal/types2.(*Checker).instantiateSignature 1567 -> 1561  (-0.38%)
cmd/compile/internal/types2.(*typeWriter).signature 605 -> 601  (-0.66%)
cmd/compile/internal/types2.(*Checker).infer 10718 -> 10654  (-0.60%)

cmd/vendor/golang.org/x/arch/s390x/s390xasm
cmd/vendor/golang.org/x/arch/s390x/s390xasm.GoSyntax 36778 -> 36682  (-0.26%)

net/http
net/http.(*Client).do 4202 -> 4170  (-0.76%)
net/http.(*http2clientStream).writeRequest 3692 -> 3686  (-0.16%)

cmd/vendor/github.com/ianlancetaylor/demangle
cmd/vendor/github.com/ianlancetaylor/demangle.(*rustState).genericArgs 466 -> 463  (-0.64%)

cmd/compile/internal/devirtualize
cmd/compile/internal/devirtualize.ProfileGuided.func1 1364 -> 1357  (-0.51%)

cmd/compile/internal/inline/interleaved
cmd/compile/internal/inline/interleaved.DevirtualizeAndInlinePackage.func2 533 -> 526  (-1.31%)

cmd/compile/internal/devirtualize [cmd/compile]
cmd/compile/internal/devirtualize.ProfileGuided.func1 1343 -> 1332  (-0.82%)

cmd/compile/internal/inline/interleaved [cmd/compile]
cmd/compile/internal/inline/interleaved.DevirtualizeAndInlinePackage.func2 533 -> 526  (-1.31%)

cmd/link/internal/ld
cmd/link/internal/ld.mustLinkExternal 2739 -> 2674  (-2.37%)

cmd/compile/internal/ssa
cmd/compile/internal/ssa.(*poset).Ordered 391 -> 389  (-0.51%)
cmd/compile/internal/ssa.(*poset).Equal 318 -> 313  (-1.57%)
cmd/compile/internal/ssa.(*poset).Undo 1842 -> 1832  (-0.54%)
cmd/compile/internal/ssa.(*expandState).decomposeAsNecessary 4587 -> 4555  (-0.70%)
cmd/compile/internal/ssa.(*poset).OrderedOrEqual 390 -> 389  (-0.26%)
cmd/compile/internal/ssa.(*poset).NonEqual 613 -> 606  (-1.14%)

cmd/compile/internal/ssa [cmd/compile]
cmd/compile/internal/ssa.(*poset).OrderedOrEqual 368 -> 365  (-0.82%)
cmd/compile/internal/ssa.(*poset).Equal 318 -> 313  (-1.57%)
cmd/compile/internal/ssa.(*expandState).decomposeAsNecessary 4952 -> 4938  (-0.28%)
cmd/compile/internal/ssa.(*poset).NonEqual 613 -> 606  (-1.14%)
cmd/compile/internal/ssa.(*poset).SetEqual 2533 -> 2505  (-1.11%)
cmd/compile/internal/ssa.(*poset).SetNonEqual 785 -> 777  (-1.02%)
cmd/compile/internal/ssa.(*poset).Ordered 370 -> 366  (-1.08%)

cmd/compile/internal/gc [cmd/compile]
cmd/compile/internal/gc.Main.DevirtualizeAndInlinePackage.func2 492 -> 489  (-0.61%)

file                                                    before   after    Δ       %
crypto/internal/sysrand.s                               1553     1545     -8      -0.515%
internal/zstd.s                                         49179    49190    +11     +0.022%
testing.s                                               115197   115188   -9      -0.008%
image/png.s                                             36109    36107    -2      -0.006%
vendor/golang.org/x/crypto/cryptobyte.s                 30980    30978    -2      -0.006%
crypto/internal/sysrand [cmd/compile].s                 1553     1545     -8      -0.515%
go/parser.s                                             112638   112354   -284    -0.252%
cmd/internal/objfile.s                                  49994    49969    -25     -0.050%
net.s                                                   299558   299546   -12     -0.004%
cmd/internal/obj/loong64.s                              71651    71635    -16     -0.022%
cmd/internal/obj/mips.s                                 59681    59653    -28     -0.047%
go/types.s                                              558839   558833   -6      -0.001%
cmd/compile/internal/types.s                            71305    71306    +1      +0.001%
go/parser [cmd/compile].s                               112749   112465   -284    -0.252%
crypto/tls.s                                            388859   388850   -9      -0.002%
cmd/internal/obj/mips [cmd/compile].s                   59792    59764    -28     -0.047%
cmd/internal/obj/loong64 [cmd/compile].s                71762    71746    -16     -0.022%
cmd/compile/internal/types2.s                           540608   540566   -42     -0.008%
cmd/compile/internal/types2 [cmd/compile].s             577428   577354   -74     -0.013%
cmd/vendor/golang.org/x/arch/s390x/s390xasm.s           267664   267568   -96     -0.036%
net/http.s                                              620704   620666   -38     -0.006%
cmd/vendor/github.com/ianlancetaylor/demangle.s         299991   299988   -3      -0.001%
cmd/compile/internal/devirtualize.s                     21452    21445    -7      -0.033%
cmd/compile/internal/inline/interleaved.s               8358     8351     -7      -0.084%
cmd/compile/internal/devirtualize [cmd/compile].s       20994    20983    -11     -0.052%
cmd/compile/internal/inline/interleaved [cmd/compile].s 8328     8321     -7      -0.084%
cmd/link/internal/ld.s                                  641802   641737   -65     -0.010%
cmd/compile/internal/ssa.s                              3552939  3552957  +18     +0.001%
cmd/compile/internal/ssa [cmd/compile].s                3752191  3752197  +6      +0.000%
cmd/compile/internal/ssagen.s                           405780   405786   +6      +0.001%
cmd/compile/internal/ssagen [cmd/compile].s             434472   434496   +24     +0.006%
cmd/compile/internal/gc [cmd/compile].s                 38499    38496    -3      -0.008%
total                                                   36185267 36184243 -1024   -0.003%

Change-Id: I867222b0f907b29d32b2676e55c6b5789ec56511
Reviewed-on: https://go-review.googlesource.com/c/go/+/642716
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>
Reviewed-by: Keith Randall <khr@golang.org>
2025-02-05 09:04:25 -08:00
Mark Ryan
bcfa00cbd2 cpu/internal: provide runtime detection of RISC-V extensions on Linux
Add a RISCV64 variable to cpu/internal that indicates both the presence
of RISC-V extensions and performance information about the underlying
RISC-V cores.  The variable is only populated with non false values on
Linux.  The detection code relies on the riscv_hwprobe syscall
introduced in Linux 6.4.  The patch can detect RVV 1.0 and whether
the CPU supports fast misaligned accesses.  It can only detect RVV 1.0
on a 6.5 kernel or later (without backports).

Updates #61416

Change-Id: I2d8289345c885b699afff441d417cae38f6bdc54
Reviewed-on: https://go-review.googlesource.com/c/go/+/522995
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: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
2025-02-05 03:47:25 -08:00
Mark Ryan
664aebab7d cmd/go: add rva23u64 as a valid value for GORISCV64
The RVA23 profile was ratified on the 21st of October 2024.

https://riscv.org/announcements/2024/10/risc-v-announces-ratification-of-the-rva23-profile-standard/

Now that it's ratified we can add rva23u64 as a valid value for the
GORISCV64 environment variable. This will allow the compiler and
assembler to generate instructions made mandatory by the new profile
without a runtime check.  Examples of such instructions include those
introduced by the Vector and Zicond extensions.

Setting GORISCV64=rva23u64 defines the riscv64.rva20u64,
riscv64.rva22u64 and riscv64.rva23u64 build tags, sets the internal
variable buildcfg.GORISCV64 to 23 and defines the macros
GORISCV64_rva23u64, hasV, hasZba, hasZbb, hasZbs, hasZfa, and
hasZicond for use in assembly language code.

Updates #61476

Change-Id: I7641c23084fa52891c9a18df58f4013cb6597d88
Reviewed-on: https://go-review.googlesource.com/c/go/+/633417
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
2025-02-05 03:44:40 -08:00
Ian Lance Taylor
842e4b5207 net/rpc: move frozen notice to the start of the package doc
For #71559

Change-Id: I68b9518a26cab75789d596839267abab7997bc2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/646575
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
2025-02-04 21:26:47 -08:00
Amirhossein Akhlaghpour
be2b809e5b os: fix race condition in readdir by atomically initializing dirinfo
This change ensures that dirinfo in the File struct is initialized atomically,
avoiding redundant allocations when multiple goroutines access it concurrently.
Instead of creating separate buffers, we now use CompareAndSwap to guarantee
thread-safe initialization and reduce unnecessary memory usage.

Although this is not a strict race condition, the update enhances efficiency by
eliminating duplicate allocations and ensuring safer concurrent access.

Fixes #71496.

Change-Id: If08699a94afa05611cdf67e82a5957a8d8f9d5c8
GitHub-Last-Rev: 1e1f6191439cf3ad32f3ba54bba5a0185dd55b14
GitHub-Pull-Request: golang/go#71501
Reviewed-on: https://go-review.googlesource.com/c/go/+/645720
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-04 18:18:11 -08:00
apocelipes
a1ea78c470 net: use strings.SplitSeq and bytes.SplitSeq
Replace `for _, s := range {strings, bytes}.Split(v, sep)` with
`for s := range {strings, bytes}.SplitSeq(v, sep)`, to simplify
the code and reduce some memory allocations.

Change-Id: Idead4de1e3928fc75cc5ba8caeff85542f1243d5
GitHub-Last-Rev: 5fb196a073e7583b23b1ebb446d6c067580ed63a
GitHub-Pull-Request: golang/go#71554
Reviewed-on: https://go-review.googlesource.com/c/go/+/646216
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-04 17:20:47 -08:00
Ian Lance Taylor
0e35fb2f99 net: ignore unnamed interfaces on DragonFly
On DragonFly it seems that we can see an unnamed interface,
but be unable to retrieve it. Skip unnamed interface cases.

For #71064

Change-Id: Ie9af74bd656d403ddc19cc5f14062cd8e0fa2571
Reviewed-on: https://go-review.googlesource.com/c/go/+/646675
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2025-02-04 16:52:20 -08:00
Ian Lance Taylor
b485e5bceb os: remove Process.mode field
It's now redundant with checking whether the handle field is nil.

For #70907

Change-Id: I877f2a7c63d15ab5f8e3d2c9aa24776c2e3e2056
Reviewed-on: https://go-review.googlesource.com/c/go/+/638576
Reviewed-by: Robert Griesemer <gri@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>
Commit-Queue: Ian Lance Taylor <iant@google.com>
2025-02-04 15:03:18 -08:00
Ian Lance Taylor
5c2b5e02c4 os: separate Process.handle into a separate memory allocation
This is a step toward using AddCleanup rather than SetFinalizer
to close process handles.

For #70907

Change-Id: I7fb37461dd67b27135eab46fbdae94f0058ace85
Reviewed-on: https://go-review.googlesource.com/c/go/+/638575
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>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-02-04 13:10:59 -08:00
Youlin Feng
0825475599 cmd/compile: do not treat OpLocalAddr as load in DSE
Fixes #70409
Fixes #47107

Change-Id: I82a66c46f6b76c68e156b5d937273b0316975d44
Reviewed-on: https://go-review.googlesource.com/c/go/+/629016
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2025-02-04 12:52:01 -08:00
Ian Lance Taylor
5cb5437b6d cmd/go/internal/vcsweb/vcstest: skip bzr test if deps not found
The linux-arm64 trybots are consistently failing with

    vcstest_test.go:155: 2025/01/30 21:50:41 hello.txt:
        > handle bzr
        > env BZR_EMAIL='Russ Cox <rsc@google.com>'
        > env EMAIL='Russ Cox <rsc@google.com>'
        > bzr init-repo .
        [stderr]
        brz: ERROR: Couldn't import breezy and dependencies.
        Please check the directory containing breezy is on your PYTHONPATH.

        Error: PyErr { type: <class 'ModuleNotFoundError'>, value: ModuleNotFoundError("No module named 'breezy'"), traceback: None }

    vcstest_test.go:161: hello.txt:6: bzr init-repo .: exit status 1

This seems to be a problem with the builder.

For now, skip the test if we see that error message, just as we already
skip the test if the bzr executable is not found.

For #71504

Change-Id: If8b6d4dea02dc16198ba6067595dff3340a81299
Reviewed-on: https://go-review.googlesource.com/c/go/+/646635
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2025-02-04 12:19:45 -08:00
David Chase
7472b4c324 cmd/compile: include liveness info in GOSSAFUNC output
For this function
```
func test(a, b int, c string, s []int, r [3]int, f ifn) {
	in(a)
	in(b)
	sl(s)
	ar(r)
	fu(f)
}
```
this output
```
HASH live at entry to test: f s
HASH /Users/drchase/work/src/live/main.go
	00000 (15) TEXT main.test(SB), ABIInternal
	00001 (15) FUNCDATA $0, gclocals·vYpXgR4/KsH5nhFsqkHG1Q==(SB)
	00002 (15) FUNCDATA $1, gclocals·Soq6RzO4SX8YA1O9euewoQ==(SB)
	00003 (15) FUNCDATA $5, main.test.arginfo1(SB)
	00004 (15) FUNCDATA $6, main.test.argliveinfo(SB)
b1	00005 (15) PCDATA $3, $1
v32	00006 (21) MOVD R6, main.s+72(RSP)
v27	00007 (21) MOVD R5, main.s+64(RSP)
v30	00008 (21) MOVD R4, main.s+56(RSP)
v7	00009 (21) MOVD R1, main.b+32(RSP)
v34	00010 (21) MOVD R7, main.f+80(RSP)
v34	00011 (21) PCDATA $3, $2
v15	00012 (+16) PCDATA $1, $0
HASH live at call to in: f s
v15	00013 (+16) CALL main.in(SB)
v3	00014 (+17) MOVD main.b+32(RSP), R0
HASH live at call to in: f s
v17	00015 (+17) CALL main.in(SB)
v8	00016 (+18) MOVD main.s+56(RSP), R0
v21	00017 (18) MOVD main.s+64(RSP), R1
v33	00018 (18) MOVD main.s+72(RSP), R2
v19	00019 (+18) PCDATA $1, $1
HASH live at call to sl: f
v19	00020 (+18) CALL main.sl(SB)
v29	00021 (+19) LDP main.r(RSP), (R1, R2)
v9	00022 (19) STP (R1, R2), 8(RSP)
v12	00023 (19) MOVD main.r+16(RSP), R1
v31	00024 (19) MOVD R1, 24(RSP)
HASH live at call to ar: f
v22	00025 (+19) CALL main.ar(SB)
v35	00026 (+20) MOVD main.f+80(RSP), R0
v24	00027 (+20) PCDATA $1, $2
HASH live at call to fu:
v24	00028 (+20) CALL main.fu(SB)
b1	00029 (21) RET
	00030 (?) END
```

Where "HASH" is the git commit comment character I don't know how
to escape and this was easier than fighting with git.

Change-Id: I0691a3f7988db111d11d69388ace83641a841e57
Reviewed-on: https://go-review.googlesource.com/c/go/+/641360
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-04 11:05:42 -08:00
Jakub Ciolek
46fd6b4e37 cmd/compile: remove reduntant Zero rule
These two rules produce the same output but have opposite
s%16 conditions. Consolidate them into a single rule.

Change-Id: I6daa0e7f7af4a4e59a3125b66b85f59e888586c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/640475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-04 09:41:43 -08:00
Jakub Ciolek
bdc2d856a8 cmd/compile: use isGenericIntConst() in prove
Use the existing Value method to make it a bit shorter.

Change-Id: I47c4328b5241ab48b3490a04a3d93d4428f7b88c
Reviewed-on: https://go-review.googlesource.com/c/go/+/642735
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@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2025-02-04 09:39:40 -08:00
Keith Randall
3981b446dd cmd/internal/sys: allow unaligned loads on big-endian ppc64
According to https://go.dev/wiki/MinimumRequirements, we've required
power8 since Go 1.9.

Before that, we supported power5 which couldn't do unaligned loads.
But power8 should be able to (it does for ppc64le).

In fact, I think we already support unaligned loads in some cases,
for instance cmd/compile/internal/ssa/config.go lists big-endian ppc64
as having unaligned loads.

Change-Id: I4a75f09d4b5199a889e0e8db0b3b7a1fa23145f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/631318
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-04 09:39:01 -08:00
Jakub Ciolek
ef7f09149b cmd/compile: prefer hv2 <= 127 over hv2 < 128
This is shorter to encode on AMD64/x86. Shrinks a few functions and doesn't
seem to cause any regressions. No size impact on other archs.

Covers a bit more than CL 639935.

compilecmp linux/amd64:

unicode/utf8
unicode/utf8.RuneCountInString changed
unicode/utf8.RuneCount changed

unicode/utf8 [cmd/compile]
unicode/utf8.RuneCount changed
unicode/utf8.RuneCountInString changed

runtime
runtime.countrunes changed
runtime.stringtoslicerune 413 -> 379  (-8.23%)

runtime [cmd/compile]
runtime.countrunes changed
runtime.stringtoslicerune 413 -> 379  (-8.23%)

bytes
bytes.containsRune 143 -> 139  (-2.80%)
bytes.IndexAny changed
bytes.Runes 462 -> 455  (-1.52%)
bytes.trimLeftUnicode changed
bytes.trimRightUnicode 325 -> 316  (-2.77%)
bytes.LastIndexAny 1261 -> 1256  (-0.40%)
bytes.Count 524 -> 520  (-0.76%)

strings
strings.Map 1241 -> 1230  (-0.89%)
strings.TrimFunc 261 -> 255  (-2.30%)
strings.Count changed
strings.IndexRune changed
strings.TrimLeftFunc 249 -> 241  (-3.21%)
strings.explode 462 -> 441  (-4.55%)
strings.IndexAny changed
strings.ToValidUTF8 changed
strings.FieldsFunc 744 -> 741  (-0.40%)
strings.EqualFold 638 -> 625  (-2.04%)
strings.IndexFunc 185 -> 179  (-3.24%)
strings.ContainsFunc 189 -> 185  (-2.12%)
strings.indexFunc 213 -> 209  (-1.88%)

go/build/constraint
go/build/constraint.(*exprParser).lex changed
go/build/constraint.isValidTag changed

regexp/syntax
regexp/syntax.isValidCaptureName 180 -> 174  (-3.33%)
regexp/syntax.literalRegexp changed
regexp/syntax.(*parser).parsePerlFlags changed
regexp/syntax.parse changed

time
time.tzsetName 471 -> 455  (-3.40%)
time.tzsetRule 2476 -> 2444  (-1.29%)
time.tzsetNum 389 -> 365  (-6.17%)
time.quote 1239 -> 1221  (-1.45%)
time.tzsetOffset 1332 -> 1317  (-1.13%)

io/fs
io/fs.FileMode.String changed

reflect
reflect.Value.Seq2.func4 changed
reflect.Value.Seq.func4 changed
reflect.isValidFieldName 265 -> 261  (-1.51%)

bytes [cmd/compile]
bytes.Runes 462 -> 455  (-1.52%)
bytes.trimLeftUnicode changed
bytes.LastIndexAny 1261 -> 1256  (-0.40%)
bytes.IndexAny changed
bytes.trimRightUnicode 325 -> 316  (-2.77%)
bytes.Count 524 -> 520  (-0.76%)
bytes.containsRune 143 -> 139  (-2.80%)

strings [cmd/compile]
strings.indexFunc 213 -> 209  (-1.88%)
strings.IndexAny changed
strings.FieldsFunc 744 -> 741  (-0.40%)
strings.IndexRune changed
strings.Count changed
strings.IndexFunc 185 -> 179  (-3.24%)
strings.Map 1241 -> 1230  (-0.89%)
strings.TrimFunc 261 -> 255  (-2.30%)
strings.ToValidUTF8 changed
strings.explode 462 -> 441  (-4.55%)
strings.EqualFold 638 -> 625  (-2.04%)
strings.ContainsFunc 189 -> 185  (-2.12%)
strings.TrimLeftFunc 249 -> 241  (-3.21%)

go/build/constraint [cmd/compile]
go/build/constraint.(*exprParser).lex changed
go/build/constraint.isValidTag changed

regexp/syntax [cmd/compile]
regexp/syntax.literalRegexp changed
regexp/syntax.parse changed
regexp/syntax.(*parser).parsePerlFlags changed
regexp/syntax.isValidCaptureName 180 -> 174  (-3.33%)

fmt
fmt.(*ss).scanOne changed
fmt.(*ss).scanUint changed
fmt.(*ss).scanInt changed
fmt.(*fmt).pad changed
fmt.(*ss).getBase 447 -> 435  (-2.68%)
fmt.(*fmt).fmtS 217 -> 211  (-2.76%)
fmt.(*ss).consume changed
fmt.(*fmt).fmtQ 494 -> 485  (-1.82%)
fmt.(*fmt).truncateString changed
fmt.(*ss).scanComplex changed
fmt.(*ss).okVerb 410 -> 409  (-0.24%)
fmt.(*ss).convertString 447 -> 436  (-2.46%)
fmt.(*ss).peek changed
fmt.FormatString 650 -> 625  (-3.85%)
fmt.(*fmt).padString changed
fmt.(*ss).convertFloat changed
fmt.(*ss).scanBool changed
fmt.indexRune changed

time [cmd/compile]
time.tzsetNum 389 -> 365  (-6.17%)
time.tzsetOffset 1332 -> 1317  (-1.13%)
time.tzsetName 471 -> 455  (-3.40%)
time.tzsetRule 2476 -> 2444  (-1.29%)
time.quote 1239 -> 1221  (-1.45%)

net/url
net/url.validOptionalPort 189 -> 186  (-1.59%)
net/url.validUserinfo 229 -> 204  (-10.92%)
net/url.parseAuthority 972 -> 948  (-2.47%)
net/url.parseHost 1372 -> 1371  (-0.07%)
net/url.splitHostPort 584 -> 581  (-0.51%)

reflect [cmd/compile]
reflect.isValidFieldName 265 -> 261  (-1.51%)
reflect.Value.Seq2.func4 changed
reflect.Value.Seq.func4 changed

compress/gzip
compress/gzip.(*Writer).writeString changed

encoding/json
encoding/json.isValidTag 313 -> 308  (-1.60%)

testing
testing.rewrite changed
testing.(*B).ReportMetric changed

mime
mime.consumeValue 1012 -> 997  (-1.48%)
mime.isToken 180 -> 172  (-4.44%)
mime.checkMediaTypeDisposition changed
mime.FormatMediaType 6375 -> 6343  (-0.50%)
mime.consumeToken changed
mime.needsEncoding 137 -> 135  (-1.46%)
mime.WordEncoder.Encode 216 -> 210  (-2.78%)
mime.consumeMediaParam 1620 -> 1605  (-0.93%)
mime.hasNonWhitespace 142 -> 139  (-2.11%)
mime.(*WordDecoder).DecodeHeader 2643 -> 2630  (-0.49%)
mime.ParseMediaType 3037 -> 3035  (-0.07%)

go/token
go/token.IsIdentifier changed

encoding/asn1
encoding/asn1.makeField changed

text/tabwriter
text/tabwriter.(*Writer).Write 3465 -> 3454  (-0.32%)
text/tabwriter.(*Writer).updateWidth changed
text/tabwriter.(*Writer).endEscape 335 -> 327  (-2.39%)

internal/buildcfg
internal/buildcfg.goriscv64 changed

go/doc/comment
go/doc/comment.wrap 5496 -> 5489  (-0.13%)
go/doc/comment.(*Printer).Text 1033 -> 1030  (-0.29%)
go/doc/comment.validImportPath 661 -> 648  (-1.97%)
go/doc/comment.(*Heading).DefaultID changed
go/doc/comment.(*textPrinter).text 1070 -> 1069  (-0.09%)

archive/tar
archive/tar.splitUSTARPath changed
archive/tar.(*Writer).writeRawFile changed
archive/tar.(*Reader).readHeader 2416 -> 2415  (-0.04%)
archive/tar.isASCII 136 -> 133  (-2.21%)
archive/tar.Header.allowedFormats.func1 changed
archive/tar.toASCII 415 -> 393  (-5.30%)
archive/tar.(*Writer).writePAXHeader.func1 645 -> 627  (-2.79%)

crypto/x509/pkix
crypto/x509/pkix.RDNSequence.String 1502 -> 1486  (-1.07%)

go/constant
go/constant.(*stringVal).String changed

vendor/golang.org/x/net/idna
vendor/golang.org/x/net/idna.decode changed
vendor/golang.org/x/net/idna.encode 2000 -> 1968  (-1.60%)

internal/trace/raw
internal/trace/raw.readArgs 783 -> 781  (-0.26%)
internal/trace/raw.NewTextReader 1158 -> 1157  (-0.09%)
internal/trace/raw.readToken 542 -> 532  (-1.85%)

cmd/internal/objabi
cmd/internal/objabi.DecodeArg changed

cmd/internal/quoted
cmd/internal/quoted.Join changed

cmd/internal/pkgpath
cmd/internal/pkgpath.toSymbolV3 changed
cmd/internal/pkgpath.toSymbolV2 changed

testing/fstest
testing/fstest.(*fsTester).checkGlob changed

text/template
text/template.JSEscapeString changed
text/template.goodName changed

io/fs [cmd/compile]
io/fs.FileMode.String changed

go/printer
go/printer.sanitizeImportPath 470 -> 463  (-1.49%)
go/printer.(*printer).isOneLineFieldList changed
go/printer.identListSize 261 -> 254  (-2.68%)

go/doc
go/doc.assumedPackageName changed
go/doc.firstSentence changed

net
net.parseCriteria.func1 changed
net.hasUpperCase 181 -> 180  (-0.55%)
net.parsePort changed
net.lookupStaticHost changed

html/template
html/template.htmlNameFilter 251 -> 249  (-0.80%)

vendor/golang.org/x/net/http/httpguts
vendor/golang.org/x/net/http/httpguts.tokenEqual changed
vendor/golang.org/x/net/http/httpguts.headerValueContainsToken 971 -> 965  (-0.62%)

mime/multipart
mime/multipart.(*Writer).SetBoundary 510 -> 505  (-0.98%)

go/build
go/build.splitQuoted 1157 -> 1148  (-0.78%)
go/build.parseGoEmbed changed
go/build.isValidImport 203 -> 197  (-2.96%)

net/mail
net/mail.(*addrParser).parseAddress changed
net/mail.quoteString changed
net/mail.(*Address).String changed

crypto/x509
crypto/x509.(*Certificate).VerifyHostname 1020 -> 1018  (-0.20%)
crypto/x509.toLowerCaseASCII 223 -> 215  (-3.59%)
crypto/x509.matchHostnames changed
crypto/x509.validHostname 506 -> 505  (-0.20%)
crypto/x509.isIA5String 197 -> 186  (-5.58%)
crypto/x509.parseNameConstraintsExtension.func1 changed
crypto/x509.matchExactly changed
crypto/x509.parseSANExtension.func1 1996 -> 1982  (-0.70%)
crypto/x509.marshalSANs 3071 -> 3051  (-0.65%)
crypto/x509.domainToReverseLabels 820 -> 805  (-1.83%)
crypto/x509.buildCertExtensions.func2 changed
crypto/x509.(*OID).unmarshalOIDText 1359 -> 1355  (-0.29%)
crypto/x509.parseASN1String 1350 -> 1334  (-1.19%)

cmd/cgo
main.checkImportSymName changed
main.splitQuoted 1157 -> 1148  (-0.78%)

fmt [cmd/compile]
fmt.(*fmt).fmtQ 494 -> 485  (-1.82%)
fmt.(*ss).scanComplex changed
fmt.(*fmt).truncateString changed
fmt.(*fmt).pad changed
fmt.(*ss).getBase 447 -> 435  (-2.68%)
fmt.(*ss).convertFloat changed
fmt.(*fmt).padString changed
fmt.(*fmt).fmtS 217 -> 211  (-2.76%)
fmt.(*ss).scanInt changed
fmt.indexRune changed
fmt.(*ss).okVerb 410 -> 409  (-0.24%)
fmt.FormatString 650 -> 625  (-3.85%)
fmt.(*ss).consume changed
fmt.(*ss).scanUint changed
fmt.(*ss).scanOne changed
fmt.(*ss).peek changed
fmt.(*ss).convertString 447 -> 436  (-2.46%)
fmt.(*ss).scanBool changed

internal/buildcfg [cmd/compile]
internal/buildcfg.goriscv64 changed

cmd/compile/internal/base
cmd/compile/internal/base.lines.write 1451 -> 1450  (-0.07%)
cmd/compile/internal/base.isnumber 165 -> 154  (-6.67%)

go/token [cmd/compile]
go/token.IsIdentifier changed

net/url [cmd/compile]
net/url.validOptionalPort 189 -> 186  (-1.59%)
net/url.splitHostPort 584 -> 581  (-0.51%)
net/url.parseAuthority 972 -> 948  (-2.47%)
net/url.validUserinfo 229 -> 204  (-10.92%)
net/url.parseHost 1372 -> 1371  (-0.07%)

cmd/internal/objabi [cmd/compile]
cmd/internal/objabi.DecodeArg changed

text/tabwriter [cmd/compile]
text/tabwriter.(*Writer).endEscape 335 -> 327  (-2.39%)
text/tabwriter.(*Writer).updateWidth changed
text/tabwriter.(*Writer).Write 3465 -> 3454  (-0.32%)

go/doc/comment [cmd/compile]
go/doc/comment.validImportPath 661 -> 648  (-1.97%)
go/doc/comment.wrap 5496 -> 5489  (-0.13%)
go/doc/comment.(*Printer).Text 1033 -> 1030  (-0.29%)
go/doc/comment.(*textPrinter).text 1070 -> 1069  (-0.09%)
go/doc/comment.(*Heading).DefaultID changed

compress/gzip [cmd/compile]
compress/gzip.(*Writer).writeString changed

encoding/json [cmd/compile]
encoding/json.isValidTag 313 -> 308  (-1.60%)

cmd/doc
main.match 549 -> 542  (-1.28%)

go/types
go/types.validatedImportPath changed
go/types.(*Checker).lookupError 3109 -> 3082  (-0.87%)
go/types.stripAnnotations 233 -> 229  (-1.72%)
go/types.tail 153 -> 148  (-3.27%)
go/types.isValidName 345 -> 330  (-4.35%)

cmd/compile/internal/syntax
cmd/compile/internal/syntax.(*scanner).lineComment 655 -> 634  (-3.21%)
cmd/compile/internal/syntax.(*scanner).fullComment 527 -> 517  (-1.90%)

crypto/tls
crypto/tls.validDNSName changed

go/constant [cmd/compile]
go/constant.(*stringVal).String changed

cmd/go/internal/str
cmd/go/internal/str.ToFold 293 -> 278  (-5.12%)
cmd/go/internal/str.QuoteGlob changed

go/doc [cmd/compile]
go/doc.firstSentence changed
go/doc.assumedPackageName changed

cmd/compile/internal/base [cmd/compile]
cmd/compile/internal/base.lines.write 1451 -> 1450  (-0.07%)
cmd/compile/internal/base.isnumber 165 -> 154  (-6.67%)

cmd/compile/internal/syntax [cmd/compile]
cmd/compile/internal/syntax.(*scanner).fullComment 527 -> 517  (-1.90%)
cmd/compile/internal/syntax.(*scanner).lineComment changed

cmd/vendor/golang.org/x/mod/module
cmd/vendor/golang.org/x/mod/module.unescapeString 500 -> 487  (-2.60%)
cmd/vendor/golang.org/x/mod/module.escapeString 538 -> 519  (-3.53%)
cmd/vendor/golang.org/x/mod/module.checkPath changed
cmd/vendor/golang.org/x/mod/module.checkElem changed
cmd/vendor/golang.org/x/mod/module.CheckPath changed

cmd/vendor/golang.org/x/mod/sumdb/note
cmd/vendor/golang.org/x/mod/sumdb/note.isValidName 246 -> 244  (-0.81%)

cmd/go/internal/base
cmd/go/internal/base.validToolName 150 -> 142  (-5.33%)
cmd/go/internal/base.ToolPath 488 -> 474  (-2.87%)

cmd/go/internal/imports
cmd/go/internal/imports.matchTag changed

go/build [cmd/compile]
go/build.isValidImport 203 -> 197  (-2.96%)
go/build.splitQuoted 1157 -> 1148  (-0.78%)
go/build.parseGoEmbed changed

cmd/vendor/golang.org/x/mod/modfile
cmd/vendor/golang.org/x/mod/modfile.Position.add 421 -> 412  (-2.14%)
cmd/vendor/golang.org/x/mod/modfile.MustQuote 380 -> 372  (-2.11%)

cmd/vendor/golang.org/x/mod/zip
cmd/vendor/golang.org/x/mod/zip.strToFold changed

cmd/link/internal/benchmark
cmd/link/internal/benchmark.makeBenchString 476 -> 453  (-4.83%)

cmd/internal/script
cmd/internal/script.wrapLine 773 -> 766  (-0.91%)

cmd/compile/internal/ir
cmd/compile/internal/ir.splitPkg changed
cmd/compile/internal/ir.splitType changed
cmd/compile/internal/ir.LookupMethodSelector changed

cmd/go/internal/modindex
cmd/go/internal/modindex.parseGoEmbed changed
cmd/go/internal/modindex.splitQuoted 1157 -> 1148  (-0.78%)

cmd/pack
main.setOp 325 -> 308  (-5.23%)

cmd/vendor/golang.org/x/term
cmd/vendor/golang.org/x/term.(*Terminal).handleKey changed

cmd/compile/internal/types2
cmd/compile/internal/types2.validatedImportPath changed
cmd/compile/internal/types2.tail 153 -> 148  (-3.27%)
cmd/compile/internal/types2.(*Checker).lookupError 3717 -> 3690  (-0.73%)
cmd/compile/internal/types2.isValidName 345 -> 330  (-4.35%)
cmd/compile/internal/types2.stripAnnotations 233 -> 229  (-1.72%)

net/http
net/http.NewRequestWithContext 2251 -> 2245  (-0.27%)
net/http.isValidWildcardName 357 -> 351  (-1.68%)
net/http.ParseCookie 1100 -> 1099  (-0.09%)
net/http.ParseSetCookie changed
net/http.readCookies changed
net/http.(*http2Framer).readMetaFrame.func1 changed
net/http.isCookieNameValid changed
net/http.(*Cookie).String changed
net/http.(*Cookie).Valid changed
net/http.validMethod changed
net/http.parsePattern 4343 -> 4330  (-0.30%)
net/http.http2validWireHeaderFieldName changed
net/http.http2encodeHeaders changed
net/http.(*Transport).roundTrip changed

cmd/compile/internal/types2 [cmd/compile]
cmd/compile/internal/types2.validatedImportPath changed
cmd/compile/internal/types2.stripAnnotations 233 -> 229  (-1.72%)
cmd/compile/internal/types2.tail 153 -> 148  (-3.27%)
cmd/compile/internal/types2.(*Checker).lookupError 3717 -> 3690  (-0.73%)
cmd/compile/internal/types2.isValidName 345 -> 330  (-4.35%)

cmd/compile/internal/ir [cmd/compile]
cmd/compile/internal/ir.LookupMethodSelector changed
cmd/compile/internal/ir.splitType changed
cmd/compile/internal/ir.splitPkg changed

cmd/compile/internal/typecheck
cmd/compile/internal/typecheck.stringtoruneslit changed

net/http/cookiejar
net/http/cookiejar.encode 1944 -> 1936  (-0.41%)

expvar
expvar.appendJSONQuote changed

cmd/go/internal/web
cmd/go/internal/web.(*Response).formatErrorDetail 1552 -> 1529  (-1.48%)

cmd/vendor/golang.org/x/text/internal/language
cmd/vendor/golang.org/x/text/internal/language.Parse 1102 -> 1099  (-0.27%)

cmd/vendor/golang.org/x/tools/go/analysis
cmd/vendor/golang.org/x/tools/go/analysis.validIdent 351 -> 346  (-1.42%)

cmd/compile/internal/typecheck [cmd/compile]
cmd/compile/internal/typecheck.stringtoruneslit changed

cmd/vendor/github.com/google/pprof/internal/report
cmd/vendor/github.com/google/pprof/internal/report.rightPad 377 -> 365  (-3.18%)
cmd/vendor/github.com/google/pprof/internal/report.indentation 169 -> 165  (-2.37%)
cmd/vendor/github.com/google/pprof/internal/report.makeWebListLine changed

cmd/vendor/golang.org/x/tools/go/analysis/passes/buildtag
cmd/vendor/golang.org/x/tools/go/analysis/passes/buildtag.(*checker).plusBuildLine changed

cmd/vendor/golang.org/x/tools/go/analysis/passes/directive
cmd/vendor/golang.org/x/tools/go/analysis/passes/directive.(*checker).comment changed

cmd/vendor/rsc.io/markdown
cmd/vendor/rsc.io/markdown.(*CodeBlock).PrintHTML changed
cmd/vendor/rsc.io/markdown.(*Code).printMarkdown changed
cmd/vendor/rsc.io/markdown.newATXHeading changed
cmd/vendor/rsc.io/markdown.longestSequence 249 -> 237  (-4.82%)
cmd/vendor/rsc.io/markdown.newFence changed

cmd/link/internal/ld
cmd/link/internal/ld.methodref.isExported changed

cmd/go/internal/modload
cmd/go/internal/modload.ShortMessage changed

cmd/go/internal/work
cmd/go/internal/work.encodeArg changed

cmd/compile/internal/walk
cmd/compile/internal/walk.rangeAssign2 changed
cmd/compile/internal/walk.arrayRangeClear changed
cmd/compile/internal/walk.rangeAssign changed
cmd/compile/internal/walk.mapClear changed
cmd/compile/internal/walk.arrayClear changed
cmd/compile/internal/walk.isMapClear changed
cmd/compile/internal/walk.walkRange 15218 -> 15538  (+2.10%)
cmd/compile/internal/walk.mapRangeClear changed
cmd/compile/internal/walk.mapRangeClear.func1 changed
cmd/compile/internal/walk.rangeConvert changed

cmd/compile/internal/noder
cmd/compile/internal/noder.checkImportPath changed
cmd/compile/internal/noder.pragmaFields changed
cmd/compile/internal/noder.parseGoEmbed 1309 -> 1300  (-0.69%)

cmd/compile/internal/walk [cmd/compile]
cmd/compile/internal/walk.mapRangeClear changed
cmd/compile/internal/walk.rangeAssign2 changed
cmd/compile/internal/walk.arrayClear changed
cmd/compile/internal/walk.arrayRangeClear changed
cmd/compile/internal/walk.walkRange 14789 -> 15109  (+2.16%)
cmd/compile/internal/walk.mapRangeClear.func1 changed
cmd/compile/internal/walk.rangeConvert changed
cmd/compile/internal/walk.mapClear changed
cmd/compile/internal/walk.isMapClear changed
cmd/compile/internal/walk.rangeAssign changed

cmd/compile/internal/noder [cmd/compile]
cmd/compile/internal/noder.pragmaFields changed
cmd/compile/internal/noder.parseGoEmbed 1309 -> 1300  (-0.69%)
cmd/compile/internal/noder.checkImportPath changed

file                                                 before   after    Δ       %
runtime.s                                            577251   577217   -34     -0.006%
runtime [cmd/compile].s                              642419   642385   -34     -0.005%
bytes.s                                              36806    36777    -29     -0.079%
strings.s                                            44176    44100    -76     -0.172%
regexp/syntax.s                                      81719    81713    -6      -0.007%
time.s                                               94341    94236    -105    -0.111%
reflect.s                                            180291   180287   -4      -0.002%
bytes [cmd/compile].s                                38181    38152    -29     -0.076%
strings [cmd/compile].s                              44192    44116    -76     -0.172%
regexp/syntax [cmd/compile].s                        81719    81713    -6      -0.007%
fmt.s                                                75019    74955    -64     -0.085%
time [cmd/compile].s                                 94341    94236    -105    -0.111%
net/url.s                                            37111    37055    -56     -0.151%
reflect [cmd/compile].s                              180340   180336   -4      -0.002%
encoding/json.s                                      110294   110289   -5      -0.005%
mime.s                                               47009    46913    -96     -0.204%
text/tabwriter.s                                     9538     9519     -19     -0.199%
go/doc/comment.s                                     49401    49377    -24     -0.049%
archive/tar.s                                        71994    71950    -44     -0.061%
crypto/x509/pkix.s                                   8493     8477     -16     -0.188%
vendor/golang.org/x/net/idna.s                       21271    21239    -32     -0.150%
internal/trace/raw.s                                 15413    15400    -13     -0.084%
go/printer.s                                         93669    93655    -14     -0.015%
net.s                                                299569   299568   -1      -0.000%
html/template.s                                      97069    97067    -2      -0.002%
vendor/golang.org/x/net/http/httpguts.s              3187     3181     -6      -0.188%
mime/multipart.s                                     31070    31065    -5      -0.016%
go/build.s                                           75077    75062    -15     -0.020%
crypto/x509.s                                        177195   177104   -91     -0.051%
cmd/cgo.s                                            215638   215629   -9      -0.004%
fmt [cmd/compile].s                                  86358    86294    -64     -0.074%
cmd/compile/internal/base.s                          44380    44368    -12     -0.027%
net/url [cmd/compile].s                              37222    37166    -56     -0.150%
text/tabwriter [cmd/compile].s                       9649     9630     -19     -0.197%
go/doc/comment [cmd/compile].s                       49512    49488    -24     -0.048%
encoding/json [cmd/compile].s                        110712   110707   -5      -0.005%
cmd/doc.s                                            54581    54574    -7      -0.013%
go/types.s                                           558219   558168   -51     -0.009%
cmd/compile/internal/syntax.s                        181755   181724   -31     -0.017%
cmd/go/internal/str.s                                3166     3151     -15     -0.474%
cmd/compile/internal/base [cmd/compile].s            44589    44577    -12     -0.027%
cmd/compile/internal/syntax [cmd/compile].s          196105   196095   -10     -0.005%
cmd/vendor/golang.org/x/mod/module.s                 19140    19108    -32     -0.167%
cmd/vendor/golang.org/x/mod/sumdb/note.s             12831    12829    -2      -0.016%
cmd/go/internal/base.s                               20413    20391    -22     -0.108%
go/build [cmd/compile].s                             75188    75173    -15     -0.020%
cmd/vendor/golang.org/x/mod/modfile.s                116513   116496   -17     -0.015%
cmd/link/internal/benchmark.s                        4068     4045     -23     -0.565%
cmd/internal/script.s                                83442    83435    -7      -0.008%
cmd/go/internal/modindex.s                           83527    83518    -9      -0.011%
cmd/pack.s                                           9128     9111     -17     -0.186%
cmd/compile/internal/types2.s                        540279   540228   -51     -0.009%
net/http.s                                           620639   620613   -26     -0.004%
cmd/compile/internal/types2 [cmd/compile].s          577279   577228   -51     -0.009%
net/http/cookiejar.s                                 28569    28561    -8      -0.028%
cmd/go/internal/web.s                                16316    16293    -23     -0.141%
cmd/vendor/golang.org/x/text/internal/language.s     57819    57816    -3      -0.005%
cmd/vendor/golang.org/x/tools/go/analysis.s          5528     5523     -5      -0.090%
cmd/vendor/github.com/google/pprof/internal/report.s 83881    83865    -16     -0.019%
cmd/vendor/rsc.io/markdown.s                         117312   117300   -12     -0.010%
cmd/compile/internal/walk.s                          329328   329648   +320    +0.097%
cmd/compile/internal/noder.s                         262295   262286   -9      -0.003%
cmd/compile/internal/walk [cmd/compile].s            350300   350620   +320    +0.091%
cmd/compile/internal/noder [cmd/compile].s           298464   298455   -9      -0.003%
total                                                36179015 36177972 -1043   -0.003%

Change-Id: I191371db975761c24e53bb83bef0c42fa8ba3485
Reviewed-on: https://go-review.googlesource.com/c/go/+/641758
Reviewed-by: Keith Randall <khr@golang.org>
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>
2025-02-04 09:38:04 -08:00
Robert Griesemer
b07b20fbb5 spec: remove reference to Go 1.17 spec
Also, delete go1.17_spec.html.

Change-Id: I7c78029dcfbbe8dbabb4ca81052976c1c8f4ed9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/645717
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
2025-02-03 15:44:27 -08:00
Robert Griesemer
ad7b46ee4a go/parser, go/types, syntax, types2: report invalid uses of ... by parsers
Check correct use of ...'s in parameter lists in parsers.
This allows the type checkers to assume correct ASTs with
respect to ... use.

Adjust some error messages: if a ... is used in a result
parameter list, the error is now more accurate.

Eliminate a now unused error code.

Change-Id: I66058e114e84805e24c59e570604b607ef5ff1fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/631135
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2025-02-03 14:04:09 -08:00
Ian Lance Taylor
d96fd2e758 cmd/go: update new test for removal of nocoverageredesign
The new test was committed after the removal was tested.

For #51430
For #65570
For #70244

Change-Id: I5f94c36a68ea96ba76d018dc06a5a233ad684aa5
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/646355
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-02-03 13:59:54 -08:00
Robert Griesemer
64eed8ef1d go/parser: refactor parameter parsing (cleanup)
Refactor parser.parseParameters to only parse
ordinary parameters. Introduce a variant to
parse type parameters.

In the two places where we need ordinary and type
parameters, call the function twice.

Also, use a range loop in two places which is a
bit easier to read.

Change-Id: I0a62e1c508d6ccd16b7cb6e1b852ab1d32224ec2
Reviewed-on: https://go-review.googlesource.com/c/go/+/630816
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Commit-Queue: Robert Griesemer <gri@google.com>
2025-02-03 13:45:49 -08:00
Ian Lance Taylor
530c829270 syscall: use consistent message for ESTALE on Linux
For some reason the ESTALE error message differed on Linux systems.
On Linux strerror normally returns "Stale file handle" for ESTALE,
except possibly in the en_GB locale. The mkerrors.sh script sets
LC_ALL=C, so it should always produces "stale file handle".
However, for some reason, several targets use "stale NFS file handle"
instead.

Clean this up so that we use the same string on all Linux systems.
This is also consistent with golang.org/x/sys/unix.

Fixes #71309

Change-Id: Ic2ffaf114c85112bc6d0831e43dd5fd2f4237bc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/643335
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: 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: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2025-02-03 12:11:17 -08:00
Ian Lance Taylor
4160ebf28f net: permit Interface with no Name
On darwin the utun interface sometimes has no name.

Fixes #71064

Change-Id: Iec51641880515f8bd3f97bd892c26f68fd588fa3
Reviewed-on: https://go-review.googlesource.com/c/go/+/641855
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>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-02-03 12:11:12 -08:00
Ian Lance Taylor
dcebb675b3 internal/routebsd: simplify for standard library
Discard everything we don't need from x/net/route.

Change-Id: If6a4ecb37e5e2349bc4df46c151990719a14f2c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/637696
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
2025-02-03 12:11:07 -08:00
Ian Lance Taylor
c1a5889edb net, internal/routebsd: move vendored x/net/route to internal
This is a simple move of the contents of the vendored x/net/route
to internal/routebsd. I've also added some test files that
were not previously vendored.

This next CL will simplify the new internal/routebsd, removing the
code that is not needed by the new package.

This is a step toward simplifying the x/net/route package by
permitting it to import x/sys/unix.

Change-Id: I4d13df11fa9738cd68876b2ea456d03f82d8d64a
Reviewed-on: https://go-review.googlesource.com/c/go/+/637695
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-03 12:11:04 -08:00
Ian Lance Taylor
41298239cf all: remove coverageredesign experiment
The coverageredesign experiment was turned on by default by
CL 436236 in September, 2022. We've documented it and people
are using it. This CL removes the ability to turn off the experiment.
This removes some old code that is no longer being executed.

For #51430

Change-Id: I88d4998c8b5ea98eef8145d7ca6ebd96f64fbc2b
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-darwin-amd64-longtest,gotip-linux-arm64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/644997
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: Than McIntosh <thanm@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
2025-02-03 12:10:28 -08:00
qmuntal
26c59d3153 crypto/internal/fips140/sha3/_asm: remove unnecessary x/crypto dependency
There is no need to blank-import golang.org/x/crypto/sha3, as we are not
using any crypto.SHA3 variant in the code.

Change-Id: Ia5455647f737371fc4ec0972bf9a90d5ee854495
Reviewed-on: https://go-review.googlesource.com/c/go/+/637055
Reviewed-by: Filippo Valsorda <filippo@golang.org>
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-02-03 10:59:30 -08:00
Sean Liao
439d39a719 all: replace reflect.Value.Type.Kind with reflect.Value.Kind
Fixes #46107

Change-Id: I170f3cacda652752cd740e04b565a616a0e43fd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/632635
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Commit-Queue: 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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-02-03 10:30:40 -08:00
Ian Lance Taylor
82337de9f2 test/issue71226: add cast to avoid clang error
Change-Id: I2d8ecb7b5f48943697d454d09947fdb1817809d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/646295
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-02-03 10:14:38 -08:00
Ian Lance Taylor
77f5ecef3a all: run gofmt
Change-Id: I0af1903ed1e4f2bf4ea273847b024520c577ef6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/642496
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>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-02-03 09:55:31 -08:00
Michael Matloob
66e6f5c920 cmd/doc: add support for starting pkgsite instance for docs
This change adds a new flag "-http" to cmd/doc which enables starting
a pkgsite instance. -http will start a pkgsite instance and navigate to
the page for the requested package, at the anchor for the item
requested.

For #68106

Change-Id: Ic1c113795cb2e1035e99c89c8e972c799342385b
Reviewed-on: https://go-review.googlesource.com/c/go/+/628175
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-02-03 09:26:03 -08:00
cuishuang
39ceaf7961 all: use slices.Contains to simplify code
Change-Id: I9ef075bbb0e3c65f3c2a9d49e599ef50b18aa9be
Reviewed-on: https://go-review.googlesource.com/c/go/+/639535
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-03 08:47:55 -08:00
Sean Liao
3caf5bd09e text/scanner: add required ScanComments in example
Fixes #71133

Change-Id: I11f792bf4cb275e7bc3585cd92a4b327a3b6e368
Reviewed-on: https://go-review.googlesource.com/c/go/+/646036
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-03 08:46:25 -08:00
cuishuang
3a81ebea0d net/http: use strings.FieldsFuncSeq to reduce memory allocations
After using strings.FieldsFuncSeq, the number of memory allocations has been reduced from 2 to 0.

The following is the complete benchamark code and results:

package main

import (
	"strings"
	"testing"
)

func isSlashRune(r rune) bool { return r == '/' || r == '\\' }

func containsDotDotLoop(v string) bool {
	if !strings.Contains(v, "..") {
		return false
	}
	for _, ent := range strings.FieldsFunc(v, isSlashRune) {
		if ent == ".." {
			return true
		}
	}
	return false
}

func containsDotDotSeq(v string) bool {
	if !strings.Contains(v, "..") {
		return false
	}
	for ent := range strings.FieldsFuncSeq(v, isSlashRune) {
		if ent == ".." {
			return true
		}
	}
	return false
}

func BenchmarkDotDot(b *testing.B) {
	testCases := []string{
		"/path/to/somewhere",
		"/path/../to/somewhere",
		"/really/long/path/with/many/segments",
		"../../../deep/path",
	}

	b.Run("Loop", func(b *testing.B) {
		for i := 0; i < b.N; i++ {
			for _, tc := range testCases {
				containsDotDotLoop(tc)
			}
		}
	})

	b.Run("Seq", func(b *testing.B) {
		for i := 0; i < b.N; i++ {
			for _, tc := range testCases {
				containsDotDotSeq(tc)
			}
		}
	})
}

go test -bench=. -benchmem

goos: darwin
goarch: arm64
pkg: bc
cpu: Apple M1
BenchmarkDotDot/Loop-8         	 6133270	       193.7 ns/op	     144 B/op	       2 allocs/op
BenchmarkDotDot/Seq-8          	23172360	        51.19 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	bc	2.633s

Change-Id: I529c296e701b22710e21b53877aa798799980a3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/639536
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>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-03 08:46:19 -08:00
Jakub Ciolek
691b7ff1c7 internal/fuzz: use a lookup table for SnapshotCoverage
Previously, the implementation used bit manipulation to approximate
counters to the nearest power of two.

Given the 0-255 range of byte, we can precompute values at
initialization and use a lookup table, reducing runtime computation.

Benchmarks show an 18% performance gain on AMD64 and 5% on ARM64.

* net/netip/FuzzParse (n=10, t=60s, state reset per run)
  * AMD64 (Intel Alder Lake i5-12600k):

    17,349,217 -> 20,487,756 execs/s

  * ARM64 (M3 Pro):

    19,606,471 -> 20,657,041 execs/s

* compress/gzip/FuzzReader (n=10, t=60s, mature corpus)
  * AMD64 (Intel Alder Lake i5-12600k):

    5,655,956 -> 6,707,035 execs/s

Change-Id: If11f7fe866f54c7cd2c5a48e251c027b67980df7
Reviewed-on: https://go-review.googlesource.com/c/go/+/627378
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
2025-02-03 08:46:08 -08:00
qmuntal
52e32ad79e crypto/x509/internal/macos: remove unused types and functions
Some of the types and functions in the macos package are unused since
CL 353132. They can be removed.

Change-Id: Ifb7c9619d3c77b83852e785b82877dfa3ca8fe6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/643277
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-03 08:44:32 -08:00
Diego Lara
1118da2514 text/template improved comparison error addresses issue #71421
Addresses issue #71421, improves the error message given for comparison. Previous error message did not specify the types causing conflict, just said incompatible types, new error message specifies the two types causing the issue.

Change-Id: I9d940ab7573c2763a9d052445140ecd6d38cde5e
GitHub-Last-Rev: 6fe7d8101317ea616fd9a8f3f430874b5f946d3e
GitHub-Pull-Request: golang/go#71431
Reviewed-on: https://go-review.googlesource.com/c/go/+/644175
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Rob Pike <r@golang.org>
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>
2025-02-03 08:43:47 -08:00
Jakub Ciolek
e57769d5ad cmd/compile: on AMD64, prefer XOR/AND for (x & 1) == 0 check
It's shorter to encode. Additionally, XOR and AND generally
have higher throughput than BT/SET*.

compilecmp:

runtime
runtime.(*sweepClass).split 58 -> 56  (-3.45%)
runtime.sweepClass.split 14 -> 11  (-21.43%)

runtime [cmd/compile]
runtime.(*sweepClass).split 58 -> 56  (-3.45%)
runtime.sweepClass.split 14 -> 11  (-21.43%)

strconv
strconv.ryuFtoaShortest changed

strconv [cmd/compile]
strconv.ryuFtoaShortest changed

math/big
math/big.(*Int).MulRange 255 -> 252  (-1.18%)

testing/quick
testing/quick.sizedValue changed

internal/fuzz
internal/fuzz.(*pcgRand).bool 69 -> 70  (+1.45%)

cmd/internal/obj/x86
cmd/internal/obj/x86.(*AsmBuf).asmevex changed

math/big [cmd/compile]
math/big.(*Int).MulRange 255 -> 252  (-1.18%)

cmd/internal/obj/x86 [cmd/compile]
cmd/internal/obj/x86.(*AsmBuf).asmevex changed

net/http
net/http.(*http2stream).isPushed 11 -> 10  (-9.09%)

cmd/vendor/github.com/google/pprof/internal/binutils
cmd/vendor/github.com/google/pprof/internal/binutils.(*file).computeBase changed

Change-Id: I9cb2987eb263c85ee4e93d6f8455c91a55273173
Reviewed-on: https://go-review.googlesource.com/c/go/+/640975
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
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>
2025-02-03 08:42:01 -08:00
Jakub Ciolek
f7dbbf2519 cmd/compile: distribute 8 and 16-bit multiplication
Expand the existing rule to cover 8 and 16 bit variants.

compilecmp linux/amd64:

time
time.parseStrictRFC3339.func1 80 -> 70  (-12.50%)
time.Time.appendStrictRFC3339.func1 80 -> 70  (-12.50%)
time.Time.appendStrictRFC3339 439 -> 428  (-2.51%)

time [cmd/compile]
time.parseStrictRFC3339.func1 80 -> 70  (-12.50%)
time.Time.appendStrictRFC3339.func1 80 -> 70  (-12.50%)
time.Time.appendStrictRFC3339 439 -> 428  (-2.51%)

linux/arm64:

time
time.parseStrictRFC3339.func1 changed
time.Time.appendStrictRFC3339.func1 changed
time.Time.appendStrictRFC3339 416 -> 400  (-3.85%)

time [cmd/compile]
time.Time.appendStrictRFC3339 416 -> 400  (-3.85%)
time.parseStrictRFC3339.func1 changed
time.Time.appendStrictRFC3339.func1 changed

Change-Id: I0ad3b2363a9fe8c322dd05fbc13bf151a146d8cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/641756
Auto-Submit: Keith Randall <khr@golang.org>
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>
Reviewed-by: Keith Randall <khr@golang.org>
2025-02-03 08:41:08 -08:00
Roxy Light
f7b8dd9033 io/fs: add ReadLinkFS interface
Added implementations for *io/fs.subFS, os.DirFS, and testing/fstest.MapFS.
Amended testing/fstest.TestFS to check behavior.

Addressed TODOs in archive/tar and os.CopyFS around symbolic links.

I am deliberately not changing archive/zip in this CL,
since it currently does not resolve symlinks
as part of its filesystem implementation.
I am unsure of the compatibility restrictions on doing so,
so figured it would be better to address independently.

testing/fstest.MapFS now includes resolution of symlinks,
with MapFile.Data storing the symlink data.
The behavior change there seemed less intrusive,
especially given its intended usage in tests,
and it is especially helpful in testing the io/fs function implementations.

Fixes #49580

Change-Id: I58ec6915e8cc97341cdbfd9c24c67d1b60139447
Reviewed-on: https://go-review.googlesource.com/c/go/+/385534
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Funda Secgin <fundasecgin33@gmail.com>
2025-02-03 08:38:43 -08:00
Tobias Klauser
9896da303a internal/poll: use ignoringEINTR2 in (*FD).Pread
Change-Id: I2af5f3f039b6c0e8e77484bd6b2cdb88e919a85d
Reviewed-on: https://go-review.googlesource.com/c/go/+/641759
Auto-Submit: 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>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-03 08:34:15 -08:00
Eng Zer Jun
cc874072f3 math/big: use built-in max function
Change-Id: I65721039dab311762e55c6a60dd75b82f6b4622f
Reviewed-on: https://go-review.googlesource.com/c/go/+/642335
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-02-03 08:25:31 -08:00
Ian Lance Taylor
6adf54a3eb cmd/cgo: declare _GoString{Len,Ptr} in _cgo_export.h
Fixes #71226

Change-Id: I91c46a4310a9c7a9fcd1e3a131ca16e46949edb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/642235
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-03 08:24:48 -08:00
Ian Lance Taylor
bf351677c4 cmd/cgo: add C declaration parameter unused attribute
Fixes #71225

Change-Id: I3e60fdf632f2aa0e63b24225f13e4ace49906925
Reviewed-on: https://go-review.googlesource.com/c/go/+/642196
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@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-03 08:24:47 -08:00
Roland Shoemaker
9d6af4082b crypto/tls: disable additional SSLv2 bogo tests
We don't support SSLv2, at all.

Change-Id: Icd0579b81393fbd82bf5b4d961470928faa7d09d
Reviewed-on: https://go-review.googlesource.com/c/go/+/644017
Reviewed-by: Neal Patel <nealpatel@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-03 08:21:24 -08:00
Robert Griesemer
4ac729283c go/types, types2: don't register interface methods in Info.Types map
Methods declared in an interface have a signature and FuncType in the
AST, but they do not express a syntactic function type expression.
Treat them like ordinary function/method declarations and do not record
them in the Info.Types map. This removes an inconsistency in the way
function types are recorded.

Follow-up on CL 640776.

For #70908.

Change-Id: I60848f209b40b008039c014fb8b7b279361487b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/640596
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>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-02-03 08:21:20 -08:00
Michael Anthony Knyszek
b25b5f3ff4 runtime: fix GODEBUG=gccheckmark=1 and add smoke test
This change fixes GODEBUG=gccheckmark=1 which seems to have bit-rotted.
Because the root jobs weren't being reset, it wasn't doing anything.
Then, it turned out that checkmark mode would queue up noscan objects in
workbufs, which caused it to fail. Then it turned out checkmark mode was
broken with user arenas, since their heap arenas are not registered
anywhere. Then, it turned out that checkmark mode could just not run
properly if the goroutine's preemption flag was set (since
sched.gcwaiting is true during the STW). And lastly, it turned out that
async preemption could cause erroneous checkmark failures.

This change fixes all these issues and adds a simple smoke test to dist
to run the runtime tests under gccheckmark, which exercises all of these
issues.

Fixes #69074.
Fixes #69377.
Fixes #69376.

Change-Id: Iaa0bb7b9e63ed4ba34d222b47510d6292ce168bc
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/608915
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-02-03 08:21:09 -08:00
Ian Lance Taylor
4f11d5879a crypto/internal/cryptotest: print stderr if go tool fails
Trying to find out why "go env GOMODCACHE" is failing
on the Windows longtest builder.

For #71508

Change-Id: I0642d5a5d85a549c6edde0be5bed8f0a16cca200
Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/645895
Reviewed-by: Roland Shoemaker <roland@golang.org>
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>
2025-02-03 08:20:05 -08:00
Ian Lance Taylor
5aa3d162d5 cmd/go/internal/modindex: correct isDir doc comment
Change-Id: Ic7e272b14a24f78b9ef3ca8e0706775bc9f2a3f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/645715
Reviewed-by: Michael Matloob <matloob@golang.org>
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>
2025-02-03 08:20:02 -08:00
Ian Lance Taylor
caedd0a8f7 cmd/go/internal/auth: reduce to a single package coment
Change-Id: I4c3cf840fe71dfa677732d445c24233e11110dd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/645556
Reviewed-by: Sam Thanawalla <samthanawalla@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: Damien Neil <dneil@google.com>
2025-02-03 08:20:01 -08:00
alirezaarzehgar
e5ae12ab82 net/url: add panic to unhex for imposible error case
Change-Id: I9f39b3d2a1a0a3e510afc874dd071302b2b0c89e
Reviewed-on: https://go-review.googlesource.com/c/go/+/643555
Reviewed-by: 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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-02-03 08:19:56 -08:00
Cherry Mui
e2f342fc51 doc: initialize next directory for Go 1.25
Following the "For the release team" steps in README:

	cd doc
	cp -R initial/ next
	$EDITOR next/1-intro.md

For #70525

Change-Id: I31c271d95ccd72123f531fde4e72929ec7b310d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/646195
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-03 07:52:07 -08:00
Cherry Mui
9da530f11a internal/goversion: update Version to 1.25
Go 1.25 is in the process of being opened for development (to be
eventually released). This change marks the very beginning of its
development cycle, updating the Version value accordingly.

For #40705.
For #70525.

Change-Id: If673d4aeddc376fefe6bddc3ec2704ca91245777
Reviewed-on: https://go-review.googlesource.com/c/go/+/646155
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-03 07:28:02 -08:00
1889 changed files with 131321 additions and 34664 deletions

1
api/next/46771.txt Normal file
View File

@ -0,0 +1 @@
pkg mime/multipart, func FileContentDisposition(string, string) string #46771

8
api/next/49580.txt Normal file
View File

@ -0,0 +1,8 @@
pkg io/fs, func Lstat(FS, string) (FileInfo, error) #49580
pkg io/fs, func ReadLink(FS, string) (string, error) #49580
pkg io/fs, type ReadLinkFS interface { Lstat, Open, ReadLink } #49580
pkg io/fs, type ReadLinkFS interface, Lstat(string) (FileInfo, error) #49580
pkg io/fs, type ReadLinkFS interface, Open(string) (File, error) #49580
pkg io/fs, type ReadLinkFS interface, ReadLink(string) (string, error) #49580
pkg testing/fstest, method (MapFS) Lstat(string) (fs.FileInfo, error) #49580
pkg testing/fstest, method (MapFS) ReadLink(string) (string, error) #49580

1
api/next/63796.txt Normal file
View File

@ -0,0 +1 @@
pkg sync, method (*WaitGroup) Go(func()) #63769

8
api/next/67002.txt Normal file
View File

@ -0,0 +1,8 @@
pkg os, method (*Root) Chmod(string, fs.FileMode) error #67002
pkg os, method (*Root) Chown(string, int, int) error #67002
pkg os, method (*Root) Chtimes(string, time.Time, time.Time) error #67002
pkg os, method (*Root) Lchown(string, int, int) error #67002
pkg os, method (*Root) Link(string, string) error #67002
pkg os, method (*Root) Readlink(string) (string, error) #67002
pkg os, method (*Root) Rename(string, string) error #67002
pkg os, method (*Root) Symlink(string, string) error #67002

1
api/next/67516.txt Normal file
View File

@ -0,0 +1 @@
pkg crypto/tls, type ConnectionState struct, CurveID CurveID #67516

17
api/next/70250.txt Normal file
View File

@ -0,0 +1,17 @@
pkg go/types, const FieldVar = 6 #70250
pkg go/types, const FieldVar VarKind #70250
pkg go/types, const LocalVar = 2 #70250
pkg go/types, const LocalVar VarKind #70250
pkg go/types, const PackageVar = 1 #70250
pkg go/types, const PackageVar VarKind #70250
pkg go/types, const ParamVar = 4 #70250
pkg go/types, const ParamVar VarKind #70250
pkg go/types, const RecvVar = 3 #70250
pkg go/types, const RecvVar VarKind #70250
pkg go/types, const ResultVar = 5 #70250
pkg go/types, const ResultVar VarKind #70250
pkg go/types, func LookupSelection(Type, bool, *Package, string) (Selection, bool) #70737
pkg go/types, method (*Var) Kind() VarKind #70250
pkg go/types, method (*Var) SetKind(VarKind) #70250
pkg go/types, method (VarKind) String() string #70250
pkg go/types, type VarKind uint8 #70250

3
api/next/70780.txt Normal file
View File

@ -0,0 +1,3 @@
pkg unicode, var CategoryAliases map[string]string #70780
pkg unicode, var Cn *RangeTable #70780
pkg unicode, var LC *RangeTable #70780

1
api/next/71122.txt Normal file
View File

@ -0,0 +1 @@
pkg go/parser, func ParseDir //deprecated #71122

4
api/next/72843.txt Normal file
View File

@ -0,0 +1,4 @@
pkg debug/elf, const PT_RISCV_ATTRIBUTES = 1879048195 #72843
pkg debug/elf, const PT_RISCV_ATTRIBUTES ProgType #72843
pkg debug/elf, const SHT_RISCV_ATTRIBUTES = 1879048195 #72843
pkg debug/elf, const SHT_RISCV_ATTRIBUTES SectionType #72843

File diff suppressed because it is too large Load Diff

View File

@ -453,7 +453,7 @@ crash, or do something else.)
</p>
<p class="rule">
The <i>k</i>th receive on a channel with capacity <i>C</i> is synchronized before the completion of the <i>k</i>+<i>C</i>th send from that channel completes.
The <i>k</i>th receive from a channel with capacity <i>C</i> is synchronized before the completion of the <i>k</i>+<i>C</i>th send on that channel.
</p>
<p>

View File

@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Language version go1.24 (Dec 30, 2024)",
"Subtitle": "Language version go1.25 (Feb 25, 2025)",
"Path": "/ref/spec"
}-->
@ -8,8 +8,6 @@
<p>
This is the reference manual for the Go programming language.
The pre-Go1.18 version, without generics, can be found
<a href="/doc/go1.17_spec.html">here</a>.
For more information and other documents, see <a href="/">go.dev</a>.
</p>
@ -1858,110 +1856,10 @@ The underlying type of <code>[]B1</code>, <code>B3</code>, and <code>B4</code> i
The underlying type of <code>P</code> is <code>interface{}</code>.
</p>
<h3 id="Core_types">Core types</h3>
<p>
Each non-interface type <code>T</code> has a <i>core type</i>, which is the same as the
<a href="#Underlying_types">underlying type</a> of <code>T</code>.
</p>
<p>
An interface <code>T</code> has a core type if one of the following
conditions is satisfied:
</p>
<ol>
<li>
There is a single type <code>U</code> which is the <a href="#Underlying_types">underlying type</a>
of all types in the <a href="#Interface_types">type set</a> of <code>T</code>; or
</li>
<li>
the type set of <code>T</code> contains only <a href="#Channel_types">channel types</a>
with identical element type <code>E</code>, and all directional channels have the same
direction.
</li>
</ol>
<p>
No other interfaces have a core type.
</p>
<p>
The core type of an interface is, depending on the condition that is satisfied, either:
</p>
<ol>
<li>
the type <code>U</code>; or
</li>
<li>
the type <code>chan E</code> if <code>T</code> contains only bidirectional
channels, or the type <code>chan&lt;- E</code> or <code>&lt;-chan E</code>
depending on the direction of the directional channels present.
</li>
</ol>
<p>
By definition, a core type is never a <a href="#Type_definitions">defined type</a>,
<a href="#Type_parameter_declarations">type parameter</a>, or
<a href="#Interface_types">interface type</a>.
</p>
<p>
Examples of interfaces with core types:
</p>
<pre>
type Celsius float32
type Kelvin float32
interface{ int } // int
interface{ Celsius|Kelvin } // float32
interface{ ~chan int } // chan int
interface{ ~chan int|~chan&lt;- int } // chan&lt;- int
interface{ ~[]*data; String() string } // []*data
</pre>
<p>
Examples of interfaces without core types:
</p>
<pre>
interface{} // no single underlying type
interface{ Celsius|float64 } // no single underlying type
interface{ chan int | chan&lt;- string } // channels have different element types
interface{ &lt;-chan int | chan&lt;- int } // directional channels have different directions
</pre>
<p>
Some operations (<a href="#Slice_expressions">slice expressions</a>,
<a href="#Appending_and_copying_slices"><code>append</code> and <code>copy</code></a>)
rely on a slightly more loose form of core types which accept byte slices and strings.
Specifically, if there are exactly two types, <code>[]byte</code> and <code>string</code>,
which are the underlying types of all types in the type set of interface <code>T</code>,
the core type of <code>T</code> is called <code>bytestring</code>.
</p>
<p>
Examples of interfaces with <code>bytestring</code> core types:
</p>
<pre>
interface{ int } // int (same as ordinary core type)
interface{ []byte | string } // bytestring
interface{ ~[]byte | myString } // bytestring
</pre>
<p>
Note that <code>bytestring</code> is not a real type; it cannot be used to declare
variables or compose other types. It exists solely to describe the behavior of some
operations that read from a sequence of bytes, which may be a byte slice or a string.
</p>
<h3 id="Type_identity">Type identity</h3>
<p>
Two types are either <i>identical</i> or <i>different</i>.
Two types are either <i>identical</i> ("the same") or <i>different</i>.
</p>
<p>
@ -3255,7 +3153,8 @@ math.Sin // denotes the Sin function in package math
<h3 id="Composite_literals">Composite literals</h3>
<p>
Composite literals construct new composite values each time they are evaluated.
Composite literals construct new values for structs, arrays, slices, and maps
each time they are evaluated.
They consist of the type of the literal followed by a brace-bound list of elements.
Each element may optionally be preceded by a corresponding key.
</p>
@ -3273,10 +3172,14 @@ Element = Expression | LiteralValue .
</pre>
<p>
The LiteralType's <a href="#Core_types">core type</a> <code>T</code>
Unless the LiteralType is a type parameter,
its <a href="#Underlying_types">underlying type
must be a struct, array, slice, or map type
(the syntax enforces this constraint except when the type is given
as a TypeName).
If the LiteralType is a type parameter, all types in its type set
must have the same underlying type which must be
a valid composite literal type.
The types of the elements and keys must be <a href="#Assignability">assignable</a>
to the respective field, element, and key types of type <code>T</code>;
there is no additional conversion.
@ -3461,7 +3364,6 @@ noteFrequency := map[string]float32{
}
</pre>
<h3 id="Function_literals">Function literals</h3>
<p>
@ -3934,11 +3836,12 @@ The following rules apply:
</p>
<p>
If <code>a</code> is neither a map nor a type parameter:
If <code>a</code> is neither a map nor a <a href="#Type_parameter_declarations">type parameter</a>:
</p>
<ul>
<li>the index <code>x</code> must be an untyped constant or its
<a href="#Core_types">core type</a> must be an <a href="#Numeric_types">integer</a></li>
<li>the index <code>x</code> must be an untyped constant, or its type must be
an <a href="#Numeric_types">integer</a> or a type parameter whose type set
contains only integer types</li>
<li>a constant index must be non-negative and
<a href="#Representability">representable</a> by a value of type <code>int</code></li>
<li>a constant index that is untyped is given type <code>int</code></li>
@ -4052,14 +3955,26 @@ Assigning to an element of a <code>nil</code> map causes a
<p>
Slice expressions construct a substring or slice from a string, array, pointer
to array, or slice. There are two variants: a simple form that specifies a low
to array, or slice operand.
There are two variants: a simple form that specifies a low
and high bound, and a full form that also specifies a bound on the capacity.
</p>
<p>
If the operand type is a <a href="#Type_parameter_declarations">type parameter</a>,
unless its type set contains string types,
all types in the type set must have the same underlying type, and the slice expression
must be valid for an operand of that type.
If the type set contains string types it may also contain byte slices with underlying
type <code>[]byte</code>.
In this case, the slice expression must be valid for an operand of <code>string</code>
type.
</p>
<h4>Simple slice expressions</h4>
<p>
The primary expression
For a string, array, pointer to array, or slice <code>a</code>, the primary expression
</p>
<pre>
@ -4067,9 +3982,7 @@ a[low : high]
</pre>
<p>
constructs a substring or slice. The <a href="#Core_types">core type</a> of
<code>a</code> must be a string, array, pointer to array, slice, or a
<a href="#Core_types"><code>bytestring</code></a>.
constructs a substring or slice.
The <i>indices</i> <code>low</code> and
<code>high</code> select which elements of operand <code>a</code> appear
in the result. The result has indices starting at 0 and length equal to
@ -4149,7 +4062,7 @@ s3 := s[:0] // s3 == nil
<h4>Full slice expressions</h4>
<p>
The primary expression
For an array, pointer to array, or slice <code>a</code> (but not a string), the primary expression
</p>
<pre>
@ -4160,8 +4073,6 @@ a[low : high : max]
constructs a slice of the same type, and with the same length and elements as the simple slice
expression <code>a[low : high]</code>. Additionally, it controls the resulting slice's capacity
by setting it to <code>max - low</code>. Only the first index may be omitted; it defaults to 0.
The <a href="#Core_types">core type</a> of <code>a</code> must be an array, pointer to array,
or slice (but not a string).
After slicing the array <code>a</code>
</p>
@ -4267,8 +4178,8 @@ No <a href="#Run_time_panics">run-time panic</a> occurs in this case.
<h3 id="Calls">Calls</h3>
<p>
Given an expression <code>f</code> with a <a href="#Core_types">core type</a>
<code>F</code> of <a href="#Function_types">function type</a>,
Given an expression <code>f</code> of <a href="#Function_types">function type</a>
<code>F</code>,
</p>
<pre>
@ -4298,6 +4209,12 @@ If <code>f</code> denotes a generic function, it must be
or used as a function value.
</p>
<p>
If the type of <code>f</code> is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must have the same underlying type, which must be a function type,
and the function call must be valid for that type.
</p>
<p>
In a function call, the function value and arguments are evaluated in
<a href="#Order_of_evaluation">the usual order</a>.
@ -4811,17 +4728,28 @@ more complicated:
<ul>
<li>
If <code>C</code> has a <a href="#Core_types">core type</a>
<code>core(C)</code>
If all types in <code>C</code>'s type set have the same
underlying type <code>U</code>,
and <code>P</code> has a known type argument <code>A</code>,
<code>core(C)</code> and <code>A</code> must unify loosely.
<code>U</code> and <code>A</code> must unify loosely.
</li>
<li>
Similarly, if all types in <code>C</code>'s type set are
channel types with the same element type and non-conflicting
channel directions,
and <code>P</code> has a known type argument <code>A</code>,
the most restrictive channel type in <code>C</code>'s type
set and <code>A</code> must unify loosely.
</li>
<li>
If <code>P</code> does not have a known type argument
and <code>C</code> contains exactly one type term <code>T</code>
that is not an underlying (tilde) type, unification adds the
mapping <code>P ➞ T</code> to the map.
</li>
<li>
If <code>C</code> does not have a core type
If <code>C</code> does not have a type <code>U</code>
as described above
and <code>P</code> has a known type argument <code>A</code>,
<code>A</code> must have all methods of <code>C</code>, if any,
and corresponding method types must unify exactly.
@ -5372,10 +5300,10 @@ var x *int = nil
<h3 id="Receive_operator">Receive operator</h3>
<p>
For an operand <code>ch</code> whose <a href="#Core_types">core type</a> is a
<a href="#Channel_types">channel</a>,
For an operand <code>ch</code> of <a href="#Channel_types">channel type</a>,
the value of the receive operation <code>&lt;-ch</code> is the value received
from the channel <code>ch</code>. The channel direction must permit receive operations,
from the channel <code>ch</code>.
The channel direction must permit receive operations,
and the type of the receive operation is the element type of the channel.
The expression blocks until a value is available.
Receiving from a <code>nil</code> channel blocks forever.
@ -5391,6 +5319,12 @@ f(&lt;-ch)
&lt;-strobe // wait until clock pulse and discard received value
</pre>
<p>
If the operand type is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must be channel types that permit receive operations, and
they must all have the same element type, which is the type of the receive operation.
</p>
<p>
A receive expression used in an <a href="#Assignment_statements">assignment statement</a> or initialization of the special form
</p>
@ -6126,8 +6060,7 @@ len("foo") // illegal if len is the built-in function
<p>
A send statement sends a value on a channel.
The channel expression's <a href="#Core_types">core type</a>
must be a <a href="#Channel_types">channel</a>,
The channel expression must be of <a href="#Channel_types">channel type</a>,
the channel direction must permit send operations,
and the type of the value to be sent must be <a href="#Assignability">assignable</a>
to the channel's element type.
@ -6151,6 +6084,13 @@ A send on a <code>nil</code> channel blocks forever.
ch &lt;- 3 // send value 3 to channel ch
</pre>
<p>
If the type of the channel expression is a
<a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must be channel types that permit send operations,
they must all have the same element type,
and the type of the value to be sent must be assignable to that element type.
</p>
<h3 id="IncDec_statements">IncDec statements</h3>
@ -6743,8 +6683,7 @@ RangeClause = [ ExpressionList "=" | IdentifierList ":=" ] "range" Expression .
<p>
The expression on the right in the "range" clause is called the <i>range expression</i>,
its <a href="#Core_types">core type</a> must be
an array, pointer to an array, slice, string, map, channel permitting
which may be an array, pointer to an array, slice, string, map, channel permitting
<a href="#Receive_operator">receive operations</a>, an integer, or
a function with specific signature (see below).
As with an assignment, if present the operands on the left must be
@ -6958,6 +6897,12 @@ for k, v := range t.Walk {
}
</pre>
<p>
If the type of the range expression is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must have the same underlying type and the range expression must be valid
for that type, or, if the type set contains channel types, it must only contain channel types with
identical element types, and all channel types must permit receive operations.
</p>
<h3 id="Go_statements">Go statements</h3>
@ -7431,23 +7376,28 @@ by the arguments overlaps.
<p>
The <a href="#Function_types">variadic</a> function <code>append</code>
appends zero or more values <code>x</code> to a slice <code>s</code>
and returns the resulting slice of the same type as <code>s</code>.
The <a href="#Core_types">core type</a> of <code>s</code> must be a slice
of type <code>[]E</code>.
appends zero or more values <code>x</code> to a slice <code>s</code> of
type <code>S</code> and returns the resulting slice, also of type
<code>S</code>.
The values <code>x</code> are passed to a parameter of type <code>...E</code>
where <code>E</code> is the element type of <code>S</code>
and the respective <a href="#Passing_arguments_to_..._parameters">parameter
passing rules</a> apply.
As a special case, if the core type of <code>s</code> is <code>[]byte</code>,
<code>append</code> also accepts a second argument with core type
<a href="#Core_types"><code>bytestring</code></a> followed by <code>...</code>.
This form appends the bytes of the byte slice or string.
As a special case, <code>append</code> also accepts a first argument assignable
to type <code>[]byte</code> with a second argument of string type followed by
<code>...</code>.
This form appends the bytes of the string.
</p>
<pre class="grammar">
append(s S, x ...E) S // core type of S is []E
append(s S, x ...E) S // E is the element type of S
</pre>
<p>
If <code>S</code> is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must have the same underlying slice type <code>[]E</code>.
</p>
<p>
If the capacity of <code>s</code> is not large enough to fit the additional
values, <code>append</code> <a href="#Allocation">allocates</a> a new, sufficiently large underlying
@ -7473,14 +7423,14 @@ b = append(b, "bar"...) // append string contents b is []byte{'b
The function <code>copy</code> copies slice elements from
a source <code>src</code> to a destination <code>dst</code> and returns the
number of elements copied.
The <a href="#Core_types">core types</a> of both arguments must be slices
with <a href="#Type_identity">identical</a> element type.
Both arguments must have <a href="#Type_identity">identical</a> element type
<code>E</code> and must be assignable to a slice of type <code>[]E</code>.
The number of elements copied is the minimum of
<code>len(src)</code> and <code>len(dst)</code>.
As a special case, if the destination's core type is <code>[]byte</code>,
<code>copy</code> also accepts a source argument with core type
<a href="#Core_types"><code>bytestring</code></a>.
This form copies the bytes from the byte slice or string into the byte slice.
As a special case, <code>copy</code> also accepts a destination argument
assignable to type <code>[]byte</code> with a source argument of a
<code>string</code> type.
This form copies the bytes from the string into the byte slice.
</p>
<pre class="grammar">
@ -7488,6 +7438,11 @@ copy(dst, src []T) int
copy(dst []byte, src string) int
</pre>
<p>
If the type of one or both arguments is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in their respective type sets must have the same underlying slice type <code>[]E</code>.
</p>
<p>
Examples:
</p>
@ -7538,8 +7493,7 @@ If the map or slice is <code>nil</code>, <code>clear</code> is a no-op.
<h3 id="Close">Close</h3>
<p>
For an argument <code>ch</code> with a <a href="#Core_types">core type</a>
that is a <a href="#Channel_types">channel</a>, the built-in function <code>close</code>
For a channel <code>ch</code>, the built-in function <code>close(ch)</code>
records that no more values will be sent on the channel.
It is an error if <code>ch</code> is a receive-only channel.
Sending to or closing a closed channel causes a <a href="#Run_time_panics">run-time panic</a>.
@ -7551,6 +7505,12 @@ The multi-valued <a href="#Receive_operator">receive operation</a>
returns a received value along with an indication of whether the channel is closed.
</p>
<p>
If the type of the argument to <code>close</code> is a
<a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must be channels with the same element type.
It is an error if any of those channels is a receive-only channel.
</p>
<h3 id="Complex_numbers">Manipulating complex numbers</h3>
@ -7720,16 +7680,15 @@ var z complex128
<p>
The built-in function <code>make</code> takes a type <code>T</code>,
which must be a slice, map or channel type, or a type parameter,
optionally followed by a type-specific list of expressions.
The <a href="#Core_types">core type</a> of <code>T</code> must
be a slice, map or channel.
It returns a value of type <code>T</code> (not <code>*T</code>).
The memory is initialized as described in the section on
<a href="#The_zero_value">initial values</a>.
</p>
<pre class="grammar">
Call Core type Result
Call Type T Result
make(T, n) slice slice of type T with length n and capacity n
make(T, n, m) slice slice of type T with length n and capacity m
@ -7739,8 +7698,18 @@ make(T, n) map map of type T with initial space for approximately
make(T) channel unbuffered channel of type T
make(T, n) channel buffered channel of type T, buffer size n
make(T, n) type parameter see below
make(T, n, m) type parameter see below
</pre>
<p>
If the first argument is a <a href="#Type_parameter_declarations">type parameter</a>,
all types in its type set must have the same underlying type, which must be a slice
or map type, or, if there are channel types, there must only be channel types, they
must all have the same element type, and the channel directions must not conflict.
</p>
<p>
Each of the size arguments <code>n</code> and <code>m</code> must be of <a href="#Numeric_types">integer type</a>,
have a <a href="#Interface_types">type set</a> containing only integer types,
@ -8483,17 +8452,14 @@ func String(ptr *byte, len IntegerType) string
func StringData(str string) *byte
</pre>
<!--
These conversions also apply to type parameters with suitable core types.
Determine if we can simply use core type instead of underlying type here,
of if the general conversion rules take care of this.
-->
<p>
A <code>Pointer</code> is a <a href="#Pointer_types">pointer type</a> but a <code>Pointer</code>
value may not be <a href="#Address_operators">dereferenced</a>.
Any pointer or value of <a href="#Core_types">core type</a> <code>uintptr</code> can be
<a href="#Conversions">converted</a> to a type of core type <code>Pointer</code> and vice versa.
Any pointer or value of <a href="#Underlying_types">underlying type</a> <code>uintptr</code> can be
<a href="#Conversions">converted</a> to a type of underlying type <code>Pointer</code> and vice versa.
If the respective types are <a href="#Type_parameter_declarations">type parameters</a>, all types in
their respective type sets must have the same underlying type, which must be <code>uintptr</code> and
<code>Pointer</code>, respectively.
The effect of converting between <code>Pointer</code> and <code>uintptr</code> is implementation-defined.
</p>
@ -8847,9 +8813,9 @@ following conditions is true:
</li>
<li>
Exactly one type is an <a href="#Type_inference">unbound</a>
type parameter with a <a href="#Core_types">core type</a>,
and that core type unifies with the other type per the
unification rules for <code><sub>A</sub></code>
type parameter, and all the types in its type set unify with
the other type
per the unification rules for <code><sub>A</sub></code>
(loose unification at the top level and exact unification
for element types).
</li>

View File

@ -109,7 +109,9 @@ Only the work module's `go.mod` is consulted for `godebug` directives.
Any directives in required dependency modules are ignored.
It is an error to list a `godebug` with an unrecognized setting.
(Toolchains older than Go 1.23 reject all `godebug` lines, since they do not
understand `godebug` at all.)
understand `godebug` at all.) When a workspace is in use, `godebug`
directives in `go.mod` files are ignored, and `go.work` will be consulted
for `godebug` directives instead.
The defaults from the `go` and `godebug` lines apply to all main
packages that are built. For more fine-grained control,
@ -151,8 +153,35 @@ for example,
see the [runtime documentation](/pkg/runtime#hdr-Environment_Variables)
and the [go command documentation](/cmd/go#hdr-Build_and_test_caching).
### Go 1.25
Go 1.25 added a new `decoratemappings` setting that controls whether the Go
runtime annotates OS anonymous memory mappings with context about their
purpose. These annotations appear in /proc/self/maps and /proc/self/smaps as
"[anon: Go: ...]". This setting is only used on Linux. For Go 1.25, it defaults
to `decoratemappings=1`, enabling annotations. Using `decoratemappings=0`
reverts to the pre-Go 1.25 behavior. This setting is fixed at program startup
time, and can't be modified by changing the `GODEBUG` environment variable
after the program starts.
Go 1.25 added a new `embedfollowsymlinks` setting that controls whether the
Go command will follow symlinks to regular files embedding files.
The default value `embedfollowsymlinks=0` does not allow following
symlinks. `embedfollowsymlinks=1` will allow following symlinks.
### Go 1.24
Go 1.24 added a new `fips140` setting that controls whether the Go
Cryptographic Module operates in FIPS 140-3 mode.
The possible values are:
- "off": no special support for FIPS 140-3 mode. This is the default.
- "on": the Go Cryptographic Module operates in FIPS 140-3 mode.
- "only": like "on", but cryptographic algorithms not approved by
FIPS 140-3 return an error or panic.
For more information, see [FIPS 140-3 Compliance](/doc/security/fips140).
This setting is fixed at program startup time, and can't be modified
by changing the `GODEBUG` environment variable after the program starts.
Go 1.24 changed the global [`math/rand.Seed`](/pkg/math/rand/#Seed) to be a
no-op. This behavior is controlled by the `randseednop` setting.
For Go 1.24 it defaults to `randseednop=1`.
@ -206,6 +235,8 @@ field by default.
Go 1.24 enabled the post-quantum key exchange mechanism
X25519MLKEM768 by default. The default can be reverted using the
[`tlsmlkem` setting](/pkg/crypto/tls/#Config.CurvePreferences).
This can be useful when dealing with buggy TLS servers that do not handle large records correctly,
causing a timeout during the handshake (see [TLS post-quantum TL;DR fail](https://tldr.fail/)).
Go 1.24 also removed X25519Kyber768Draft00 and the Go 1.23 `tlskyber` setting.
Go 1.24 made [`ParsePKCS1PrivateKey`](/pkg/crypto/x509/#ParsePKCS1PrivateKey)
@ -242,6 +273,8 @@ Previous versions default to `winreadlinkvolume=0`.
Go 1.23 enabled the experimental post-quantum key exchange mechanism
X25519Kyber768Draft00 by default. The default can be reverted using the
[`tlskyber` setting](/pkg/crypto/tls/#Config.CurvePreferences).
This can be useful when dealing with buggy TLS servers that do not handle large records correctly,
causing a timeout during the handshake (see [TLS post-quantum TL;DR fail](https://tldr.fail/)).
Go 1.23 changed the behavior of
[crypto/x509.ParseCertificate](/pkg/crypto/x509/#ParseCertificate) to reject
@ -337,7 +370,7 @@ certificate policy OIDs with components larger than 31 bits. By default this
field is only used during parsing, when it is populated with policy OIDs, but
not used during marshaling. It can be used to marshal these larger OIDs, instead
of the existing PolicyIdentifiers field, by using the
[`x509usepolicies` setting.](/pkg/crypto/x509/#CreateCertificate).
[`x509usepolicies` setting](/pkg/crypto/x509/#CreateCertificate).
### Go 1.21

View File

@ -1,3 +1,10 @@
### Minor changes to the library {#minor_library_changes}
#### go/types
The `Var.Kind` method returns an enumeration of type `VarKind` that
classifies the variable (package-level, local, receiver, parameter,
result, or struct field). See issue #70250.
Callers of `NewVar` or `NewParam` are encouraged to call `Var.SetKind`
to ensure that this attribute is set correctly in all cases.

8
doc/next/1-intro.md Normal file
View File

@ -0,0 +1,8 @@
<style>
main ul li { margin: 0.5em 0; }
</style>
## DRAFT RELEASE NOTES — Introduction to Go 1.N {#introduction}
**Go 1.25 is not yet released. These are work-in-progress release notes.
Go 1.25 is expected to be released in August 2025.**

3
doc/next/2-language.md Normal file
View File

@ -0,0 +1,3 @@
## Changes to the language {#language}

42
doc/next/3-tools.md Normal file
View File

@ -0,0 +1,42 @@
## Tools {#tools}
### Go command {#go-command}
The `go build` `-asan` option now defaults to doing leak detection at
program exit.
This will report an error if memory allocated by C is not freed and is
not referenced by any other memory allocated by either C or Go.
These new error reports may be disabled by setting
`ASAN_OPTIONS=detect_leaks=0` in the environment when running the
program.
<!-- go.dev/issue/71294 -->
The new `work` package pattern matches all packages in the work (formerly called main)
modules: either the single work module in module mode or the set of workspace modules
in workspace mode.
<!-- go.dev/issue/65847 -->
When the go command updates the `go` line in a `go.mod` or `go.work` file,
it [no longer](/ref/mod#go-mod-file-toolchain) adds a toolchain line
specifying the command's current version.
### Cgo {#cgo}
### Vet {#vet}
The `go vet` command includes new analyzers:
<!-- go.dev/issue/18022 -->
- [waitgroup](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/waitgroup),
which reports misplaced calls to [sync.WaitGroup.Add]; and
<!-- go.dev/issue/28308 -->
- [hostport](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/hostport),
which reports uses of `fmt.Sprintf("%s:%d", host, port)` to
construct addresses for [net.Dial], as these will not work with
IPv6; instead it suggests using [net.JoinHostPort].

26
doc/next/4-runtime.md Normal file
View File

@ -0,0 +1,26 @@
## Runtime {#runtime}
<!-- go.dev/issue/71517 -->
The message printed when a program exits due to an unhandled panic
that was recovered and re-raised no longer repeats the text of
the panic value.
Previously, a program which panicked with `panic("PANIC")`,
recovered the panic, and then re-panicked with the original
value would print:
panic: PANIC [recovered]
panic: PANIC
This program will now print:
panic: PANIC [recovered, reraised]
<!-- go.dev/issue/71546 -->
On Linux systems with kernel support for anonymous VMA names
(`CONFIG_ANON_VMA_NAME`), the Go runtime will annotate anonymous memory
mappings with context about their purpose. e.g., `[anon: Go: heap]` for heap
memory. This can be disabled with the [GODEBUG setting](/doc/godebug)
`decoratemappings=0`.

44
doc/next/5-toolchain.md Normal file
View File

@ -0,0 +1,44 @@
## Compiler {#compiler}
<!-- https://go.dev/issue/26379 -->
The compiler and linker in Go 1.25 now generate debug information
using [DWARF version 5](https://dwarfstd.org/dwarf5std.html); the
newer DWARF version reduces the space required for debugging
information in Go binaries.
DWARF 5 generation is gated by the "dwarf5" GOEXPERIMENT; this
functionality can be disabled (for now) using GOEXPERIMENT=nodwarf5.
<!-- https://go.dev/issue/72860, CL 657715 -->
The compiler [has been fixed](/cl/657715)
to ensure that nil pointer checks are performed promptly. Programs like the following,
which used to execute successfully, will now panic with a nil-pointer exception:
```
package main
import "os"
func main() {
f, err := os.Open("nonExistentFile")
name := f.Name()
if err != nil {
return
}
println(name)
}
```
This program is incorrect in that it uses the result of `os.Open` before checking
the error. The main result of `os.Open` can be a nil pointer if the error result is non-nil.
But because of [a compiler bug](/issue/72860), this program ran successfully under
Go versions 1.21 through 1.24 (in violation of the Go spec). It will no longer run
successfully in Go 1.25. If this change is affecting your code, the solution is to put
the non-nil error check earlier in your code, preferably immediately after
the error-generating statement.
## Assembler {#assembler}
## Linker {#linker}

View File

@ -0,0 +1,2 @@
## Standard library {#library}

View File

@ -0,0 +1,3 @@
### Minor changes to the library {#minor_library_changes}

View File

@ -0,0 +1 @@
API changes and other small changes to the standard library go here.

View File

@ -0,0 +1,2 @@
The [*Writer.AddFS] implementation now supports symbolic links
for filesystems that implement [io/fs.ReadLinkFS].

View File

@ -0,0 +1,2 @@
The hidden and undocumented `Inverse` and `CombinedMult` methods on some [Curve]
implementations have been removed.

View File

@ -0,0 +1,2 @@
The new [ConnectionState.CurveID] field exposes the key exchange mechanism used
to establish the connection.

View File

@ -0,0 +1,2 @@
When [FIPS 140-3 mode](/doc/security/fips140) is enabled, Extended Master Secret
is now required in TLS 1.2, and Ed25519 and X25519MLKEM768 are now allowed.

View File

@ -0,0 +1,4 @@
The [debug/elf] package adds two new constants:
- [PT_RISCV_ATTRIBUTES]
- [SHT_RISCV_ATTRIBUTES]
for RISC-V ELF parsing.

View File

@ -0,0 +1 @@
The [ParseDir] function is deprecated.

View File

@ -0,0 +1,3 @@
[Var] now has a [Var.Kind] method that classifies the variable as one
of: package-level, receiver, parameter, result, or local variable, or
a struct field.

View File

@ -0,0 +1,3 @@
The new [LookupSelection] function looks up the field or method of a
given name and receiver type, like the existing [LookupFieldOrMethod]
function, but returns the result in the form of a [Selection].

View File

@ -0,0 +1 @@
A new [ReadLinkFS] interface provides the ability to read symbolic links in a filesystem.

View File

@ -0,0 +1,2 @@
The new helper function [FieldContentDisposition] builds multipart
Content-Disposition header fields.

View File

@ -0,0 +1,3 @@
On Windows, the [TCPConn.File], [UDPConn.File], [UnixConn.File],
[IPConn.File], [TCPListener.File], and [UnixListener.File]
methods are now supported.

View File

@ -0,0 +1,5 @@
[LookupMX] and [*Resolver.LookupMX] now return DNS names that look
like valid IP address, as well as valid domain names.
Previously if a name server returned an IP address as a DNS name,
LookupMX would discard it, as required by the RFCs.
However, name servers in practice do sometimes return IP addresses.

View File

@ -0,0 +1 @@
On Windows, the [ListenMulticastUDP] now supports IPv6 addresses.

View File

@ -0,0 +1,2 @@
On Windows, the [FileConn], [FilePacketConn], [FileListener]
functions are now supported.

View File

@ -0,0 +1,14 @@
On Windows, [NewFile] now supports handles opened for asynchronous I/O (that is,
[syscall.FILE_FLAG_OVERLAPPED] is specified in the [syscall.CreateFile] call).
These handles are associated with the Go runtime's I/O completion port,
which provides the following benefits for the resulting [File]:
- I/O methods ([File.Read], [File.Write], [File.ReadAt], and [File.WriteAt]) do not block an OS thread.
- Deadline methods ([File.SetDeadline], [File.SetReadDeadline], and [File.SetWriteDeadline]) are supported.
This enhancement is especially beneficial for applications that communicate via named pipes on Windows.
Note that a handle can only be associated with one completion port at a time.
If the handle provided to [NewFile] is already associated with a completion port,
the returned [File] is downgraded to synchronous I/O mode.
In this case, I/O methods will block an OS thread, and the deadline methods have no effect.

View File

@ -0,0 +1,2 @@
The filesystem returned by [DirFS] implements the new [io/fs.ReadLinkFS] interface.
[CopyFS] supports symlinks when copying filesystems that implement [io/fs.ReadLinkFS].

View File

@ -0,0 +1,10 @@
The [os.Root] type supports the following additional methods:
* [os.Root.Chmod]
* [os.Root.Chown]
* [os.Root.Chtimes]
* [os.Root.Lchown]
* [os.Root.Link]
* [os.Root.Readlink]
* [os.Root.Rename]
* [os.Root.Symlink]

View File

@ -0,0 +1,4 @@
The `\p{name}` and `\P{name}` character class syntaxes now accept the names
Any, ASCII, Assigned, Cn, and LC, as well as Unicode category aliases like `\p{Letter}` for `\pL`.
Following [Unicode TR18](https://unicode.org/reports/tr18/), they also now use
case-insensitive name lookups, ignoring spaces, underscores, and hyphens.

View File

@ -0,0 +1,2 @@
[WaitGroup] has added a new method [WaitGroup.Go],
that makes the common pattern of creating and counting goroutines more convenient.

View File

@ -0,0 +1,3 @@
[MapFS] implements the new [io/fs.ReadLinkFS] interface.
[TestFS] will verify the functionality of the [io/fs.ReadLinkFS] interface if implemented.
[TestFS] will no longer follow symlinks to avoid unbounded recursion.

View File

@ -0,0 +1,4 @@
The new [CategoryAliases] map provides access to category alias names, such as “Letter” for “L”.
The new categories [Cn] and [LC] define unassigned codepoints and cased letters, respectively.
These have always been defined by Unicode but were inadvertently omitted in earlier versions of Go.
The [C] category now includes [Cn], meaning it has added all unassigned code points.

11
doc/next/7-ports.md Normal file
View File

@ -0,0 +1,11 @@
## Ports {#ports}
### Darwin
<!-- go.dev/issue/69839 -->
As [announced](/doc/go1.24#darwin) in the Go 1.24 release notes, Go 1.25 requires macOS 12 Monterey or later; support for previous versions has been discontinued.
### Windows
<!-- go.dev/issue/71671 -->
Go 1.25 is the last release that contains the [broken](/doc/go1.24#windows) 32-bit windows/arm port (`GOOS=windows` `GOARCH=arm`). It will be removed in Go 1.26.

View File

@ -40,7 +40,12 @@ curl -sS -L -O https://www.iana.org/time-zones/repository/releases/tzdata$DATA.t
tar xzf tzcode$CODE.tar.gz
tar xzf tzdata$DATA.tar.gz
if ! make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo posix_only >make.out 2>&1; then
# The PACKRATLIST and PACKRATDATA options are copied from Ubuntu:
# https://git.launchpad.net/ubuntu/+source/tzdata/tree/debian/rules?h=debian/sid
#
# You can see the description of these make variables in the tzdata Makefile:
# https://github.com/eggert/tz/blob/main/Makefile
if ! make CFLAGS=-DSTD_INSPIRED AWK=awk TZDIR=zoneinfo PACKRATDATA=backzone PACKRATLIST=zone.tab posix_only >make.out 2>&1; then
cat make.out
exit 2
fi

Binary file not shown.

View File

@ -1,191 +0,0 @@
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// The linkcheck command finds missing links in the godoc website.
// It crawls a URL recursively and notes URLs and URL fragments
// that it's seen and prints a report of missing links at the end.
package main
import (
"errors"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
"regexp"
"strings"
"sync"
)
var (
root = flag.String("root", "http://localhost:6060", "Root to crawl")
verbose = flag.Bool("verbose", false, "verbose")
)
var wg sync.WaitGroup // outstanding fetches
var urlq = make(chan string) // URLs to crawl
// urlFrag is a URL and its optional #fragment (without the #)
type urlFrag struct {
url, frag string
}
var (
mu sync.Mutex
crawled = make(map[string]bool) // URL without fragment -> true
neededFrags = make(map[urlFrag][]string) // URL#frag -> who needs it
)
var aRx = regexp.MustCompile(`<a href=['"]?(/[^\s'">]+)`)
// Owned by crawlLoop goroutine:
var (
linkSources = make(map[string][]string) // url no fragment -> sources
fragExists = make(map[urlFrag]bool)
problems []string
)
func localLinks(body string) (links []string) {
seen := map[string]bool{}
mv := aRx.FindAllStringSubmatch(body, -1)
for _, m := range mv {
ref := m[1]
if strings.HasPrefix(ref, "/src/") {
continue
}
if !seen[ref] {
seen[ref] = true
links = append(links, m[1])
}
}
return
}
var idRx = regexp.MustCompile(`\bid=['"]?([^\s'">]+)`)
func pageIDs(body string) (ids []string) {
mv := idRx.FindAllStringSubmatch(body, -1)
for _, m := range mv {
ids = append(ids, m[1])
}
return
}
// url may contain a #fragment, and the fragment is then noted as needing to exist.
func crawl(url string, sourceURL string) {
if strings.Contains(url, "/devel/release") {
return
}
mu.Lock()
defer mu.Unlock()
if u, frag, ok := strings.Cut(url, "#"); ok {
url = u
if frag != "" {
uf := urlFrag{url, frag}
neededFrags[uf] = append(neededFrags[uf], sourceURL)
}
}
if crawled[url] {
return
}
crawled[url] = true
wg.Add(1)
go func() {
urlq <- url
}()
}
func addProblem(url, errmsg string) {
msg := fmt.Sprintf("Error on %s: %s (from %s)", url, errmsg, linkSources[url])
if *verbose {
log.Print(msg)
}
problems = append(problems, msg)
}
func crawlLoop() {
for url := range urlq {
if err := doCrawl(url); err != nil {
addProblem(url, err.Error())
}
}
}
func doCrawl(url string) error {
defer wg.Done()
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return err
}
res, err := http.DefaultTransport.RoundTrip(req)
if err != nil {
return err
}
// Handle redirects.
if res.StatusCode/100 == 3 {
newURL, err := res.Location()
if err != nil {
return fmt.Errorf("resolving redirect: %v", err)
}
if !strings.HasPrefix(newURL.String(), *root) {
// Skip off-site redirects.
return nil
}
crawl(newURL.String(), url)
return nil
}
if res.StatusCode != 200 {
return errors.New(res.Status)
}
slurp, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
log.Fatalf("Error reading %s body: %v", url, err)
}
if *verbose {
log.Printf("Len of %s: %d", url, len(slurp))
}
body := string(slurp)
for _, ref := range localLinks(body) {
if *verbose {
log.Printf(" links to %s", ref)
}
dest := *root + ref
linkSources[dest] = append(linkSources[dest], url)
crawl(dest, url)
}
for _, id := range pageIDs(body) {
if *verbose {
log.Printf(" url %s has #%s", url, id)
}
fragExists[urlFrag{url, id}] = true
}
return nil
}
func main() {
flag.Parse()
go crawlLoop()
crawl(*root, "")
wg.Wait()
close(urlq)
for uf, needers := range neededFrags {
if !fragExists[uf] {
problems = append(problems, fmt.Sprintf("Missing fragment for %+v from %v", uf, needers))
}
}
for _, s := range problems {
fmt.Println(s)
}
if len(problems) > 0 {
os.Exit(1)
}
}

View File

@ -6,17 +6,11 @@
setlocal
if exist make.bat goto ok
if not exist make.bat (
echo all.bat must be run from go\src
:: cannot exit: would kill parent command interpreter
goto end
:ok
exit /b 1
)
call .\make.bat --no-banner --no-local
if %GOBUILDFAIL%==1 goto end
call .\run.bat --no-rebuild --no-local
if %GOBUILDFAIL%==1 goto end
"%GOTOOLDIR%/dist" banner
:end
if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%
call .\make.bat --no-banner || exit /b 1
call .\run.bat --no-rebuild || exit /b 1
..\bin\go tool dist banner

View File

@ -415,11 +415,17 @@ func (tw *Writer) AddFS(fsys fs.FS) error {
if err != nil {
return err
}
// TODO(#49580): Handle symlinks when fs.ReadLinkFS is available.
if !d.IsDir() && !info.Mode().IsRegular() {
linkTarget := ""
if typ := d.Type(); typ == fs.ModeSymlink {
var err error
linkTarget, err = fs.ReadLink(fsys, name)
if err != nil {
return err
}
} else if !typ.IsRegular() && typ != fs.ModeDir {
return errors.New("tar: cannot add non-regular file")
}
h, err := FileInfoHeader(info, "")
h, err := FileInfoHeader(info, linkTarget)
if err != nil {
return err
}
@ -430,7 +436,7 @@ func (tw *Writer) AddFS(fsys fs.FS) error {
if err := tw.WriteHeader(h); err != nil {
return err
}
if d.IsDir() {
if !d.Type().IsRegular() {
return nil
}
f, err := fsys.Open(name)

View File

@ -1342,6 +1342,7 @@ func TestWriterAddFS(t *testing.T) {
"emptyfolder": {Mode: 0o755 | os.ModeDir},
"file.go": {Data: []byte("hello")},
"subfolder/another.go": {Data: []byte("world")},
"symlink.go": {Mode: 0o777 | os.ModeSymlink, Data: []byte("file.go")},
// Notably missing here is the "subfolder" directory. This makes sure even
// if we don't have a subfolder directory listed.
}
@ -1370,7 +1371,7 @@ func TestWriterAddFS(t *testing.T) {
for _, name := range names {
entriesLeft--
entryInfo, err := fsys.Stat(name)
entryInfo, err := fsys.Lstat(name)
if err != nil {
t.Fatalf("getting entry info error: %v", err)
}
@ -1396,18 +1397,23 @@ func TestWriterAddFS(t *testing.T) {
name, entryInfo.Mode(), hdr.FileInfo().Mode())
}
if entryInfo.IsDir() {
continue
switch entryInfo.Mode().Type() {
case fs.ModeDir:
// No additional checks necessary.
case fs.ModeSymlink:
origtarget := string(fsys[name].Data)
if hdr.Linkname != origtarget {
t.Fatalf("test fs has link content %s; archive header %v", origtarget, hdr.Linkname)
}
default:
data, err := io.ReadAll(tr)
if err != nil {
t.Fatal(err)
}
origdata := fsys[name].Data
if string(data) != string(origdata) {
t.Fatalf("test fs has file content %v; archive header has %v",
data, origdata)
t.Fatalf("test fs has file content %v; archive header has %v", origdata, data)
}
}
}
if entriesLeft > 0 {

View File

@ -8,6 +8,7 @@ import (
"bufio"
"encoding/binary"
"errors"
"fmt"
"hash"
"hash/crc32"
"internal/godebug"
@ -804,6 +805,9 @@ func toValidName(name string) string {
func (r *Reader) initFileList() {
r.fileListOnce.Do(func() {
// Preallocate the minimum size of the index.
// We may also synthesize additional directory entries.
r.fileList = make([]fileListEntry, 0, len(r.File))
// files and knownDirs map from a file/directory name
// to an index into the r.fileList entry that we are
// building. They are used to mark duplicate entries.
@ -985,6 +989,12 @@ func (d *openDir) ReadDir(count int) ([]fs.DirEntry, error) {
s, err := d.files[d.offset+i].stat()
if err != nil {
return nil, err
} else if s.Name() == "." || !fs.ValidPath(s.Name()) {
return nil, &fs.PathError{
Op: "readdir",
Path: d.e.name,
Err: fmt.Errorf("invalid file name: %v", d.files[d.offset+i].name),
}
}
list[i] = s
}

View File

@ -8,6 +8,7 @@ import (
"bytes"
"encoding/binary"
"encoding/hex"
"errors"
"internal/obscuretestdata"
"io"
"io/fs"
@ -1281,6 +1282,49 @@ func TestFSWalk(t *testing.T) {
}
}
func TestFSWalkBadFile(t *testing.T) {
t.Parallel()
var buf bytes.Buffer
zw := NewWriter(&buf)
hdr := &FileHeader{Name: "."}
hdr.SetMode(fs.ModeDir | 0o755)
w, err := zw.CreateHeader(hdr)
if err != nil {
t.Fatalf("create zip header: %v", err)
}
_, err = w.Write([]byte("some data"))
if err != nil {
t.Fatalf("write zip contents: %v", err)
}
err = zw.Close()
if err != nil {
t.Fatalf("close zip writer: %v", err)
}
zr, err := NewReader(bytes.NewReader(buf.Bytes()), int64(buf.Len()))
if err != nil {
t.Fatalf("create zip reader: %v", err)
}
var count int
var errRepeat = errors.New("repeated call to path")
err = fs.WalkDir(zr, ".", func(p string, d fs.DirEntry, err error) error {
count++
if count > 2 { // once for directory read, once for the error
return errRepeat
}
return err
})
if err == nil {
t.Fatalf("expected error from invalid file name")
} else if errors.Is(err, errRepeat) {
t.Fatal(err)
}
}
func TestFSModTime(t *testing.T) {
t.Parallel()
z, err := OpenReader("testdata/subdir.zip")

View File

@ -519,10 +519,12 @@ func (b *Reader) WriteTo(w io.Writer) (n int64, err error) {
b.lastByte = -1
b.lastRuneSize = -1
if b.r < b.w {
n, err = b.writeBuf(w)
if err != nil {
return
}
}
if r, ok := b.rd.(io.WriterTo); ok {
m, err := r.WriteTo(w)

View File

@ -1149,7 +1149,7 @@ func (w errorWriterToTest) Write(p []byte) (int, error) {
var errorWriterToTests = []errorWriterToTest{
{1, 0, nil, io.ErrClosedPipe, io.ErrClosedPipe},
{0, 1, io.ErrClosedPipe, nil, io.ErrClosedPipe},
{0, 0, io.ErrUnexpectedEOF, io.ErrClosedPipe, io.ErrClosedPipe},
{0, 0, io.ErrUnexpectedEOF, io.ErrClosedPipe, io.ErrUnexpectedEOF},
{0, 1, io.EOF, nil, nil},
}

96
src/bufio/net_test.go Normal file
View File

@ -0,0 +1,96 @@
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build unix
package bufio_test
import (
"bufio"
"io"
"net"
"path/filepath"
"strings"
"sync"
"testing"
)
// TestCopyUnixpacket tests that we can use bufio when copying
// across a unixpacket socket. This used to fail due to an unnecessary
// empty Write call that was interpreted as an EOF.
func TestCopyUnixpacket(t *testing.T) {
tmpDir := t.TempDir()
socket := filepath.Join(tmpDir, "unixsock")
// Start a unixpacket server.
addr := &net.UnixAddr{
Name: socket,
Net: "unixpacket",
}
server, err := net.ListenUnix("unixpacket", addr)
if err != nil {
t.Skipf("skipping test because opening a unixpacket socket failed: %v", err)
}
// Start a goroutine for the server to accept one connection
// and read all the data sent on the connection,
// reporting the number of bytes read on ch.
ch := make(chan int, 1)
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
tot := 0
defer func() {
ch <- tot
}()
serverConn, err := server.Accept()
if err != nil {
t.Error(err)
return
}
buf := make([]byte, 1024)
for {
n, err := serverConn.Read(buf)
tot += n
if err == io.EOF {
return
}
if err != nil {
t.Error(err)
return
}
}
}()
clientConn, err := net.DialUnix("unixpacket", nil, addr)
if err != nil {
// Leaves the server goroutine hanging. Oh well.
t.Fatal(err)
}
defer wg.Wait()
defer clientConn.Close()
const data = "data"
r := bufio.NewReader(strings.NewReader(data))
n, err := io.Copy(clientConn, r)
if err != nil {
t.Fatal(err)
}
if n != int64(len(data)) {
t.Errorf("io.Copy returned %d, want %d", n, len(data))
}
clientConn.Close()
tot := <-ch
if tot != len(data) {
t.Errorf("server read %d, want %d", tot, len(data))
}
}

View File

@ -451,7 +451,9 @@ var asciiSpace = [256]uint8{'\t': 1, '\n': 1, '\v': 1, '\f': 1, '\r': 1, ' ': 1}
// Fields interprets s as a sequence of UTF-8-encoded code points.
// It splits the slice s around each instance of one or more consecutive white space
// characters, as defined by [unicode.IsSpace], returning a slice of subslices of s or an
// empty slice if s contains only white space.
// empty slice if s contains only white space. Every element of the returned slice is
// non-empty. Unlike [Split], leading and trailing runs of white space characters
// are discarded.
func Fields(s []byte) [][]byte {
// First count the fields.
// This is an exact count if s is ASCII, otherwise it is an approximation.
@ -505,7 +507,9 @@ func Fields(s []byte) [][]byte {
// FieldsFunc interprets s as a sequence of UTF-8-encoded code points.
// It splits the slice s at each run of code points c satisfying f(c) and
// returns a slice of subslices of s. If all code points in s satisfy f(c), or
// len(s) == 0, an empty slice is returned.
// len(s) == 0, an empty slice is returned. Every element of the returned slice is
// non-empty. Unlike [SplitFunc], leading and trailing runs of code points
// satisfying f(c) are discarded.
//
// FieldsFunc makes no guarantees about the order in which it calls f(c)
// and assumes that f always returns the same value for a given c.
@ -1188,20 +1192,23 @@ func Replace(s, old, new []byte, n int) []byte {
t := make([]byte, len(s)+n*(len(new)-len(old)))
w := 0
start := 0
for i := 0; i < n; i++ {
j := start
if len(old) == 0 {
if i > 0 {
_, wid := utf8.DecodeRune(s[start:])
j += wid
}
} else {
j += Index(s[start:], old)
}
if len(old) > 0 {
for range n {
j := start + Index(s[start:], old)
w += copy(t[w:], s[start:j])
w += copy(t[w:], new)
start = j + len(old)
}
} else { // len(old) == 0
w += copy(t[w:], new)
for range n - 1 {
_, wid := utf8.DecodeRune(s[start:])
j := start + wid
w += copy(t[w:], s[start:j])
w += copy(t[w:], new)
start = j
}
}
w += copy(t[w:], s[start:])
return t[0:w]
}

View File

@ -7,6 +7,7 @@ package bytes_test
import (
. "bytes"
"fmt"
"internal/asan"
"internal/testenv"
"iter"
"math"
@ -1786,9 +1787,20 @@ var ReplaceTests = []ReplaceTest{
func TestReplace(t *testing.T) {
for _, tt := range ReplaceTests {
in := append([]byte(tt.in), "<spare>"...)
var (
in = []byte(tt.in)
old = []byte(tt.old)
new = []byte(tt.new)
)
if !asan.Enabled {
allocs := testing.AllocsPerRun(10, func() { Replace(in, old, new, tt.n) })
if allocs > 1 {
t.Errorf("Replace(%q, %q, %q, %d) allocates %.2f objects", tt.in, tt.old, tt.new, tt.n, allocs)
}
}
in = append(in, "<spare>"...)
in = in[:len(tt.in)]
out := Replace(in, []byte(tt.old), []byte(tt.new), tt.n)
out := Replace(in, old, new, tt.n)
if s := string(out); s != tt.out {
t.Errorf("Replace(%q, %q, %q, %d) = %q, want %q", tt.in, tt.old, tt.new, tt.n, s, tt.out)
}
@ -1796,7 +1808,7 @@ func TestReplace(t *testing.T) {
t.Errorf("Replace(%q, %q, %q, %d) didn't copy", tt.in, tt.old, tt.new, tt.n)
}
if tt.n == -1 {
out := ReplaceAll(in, []byte(tt.old), []byte(tt.new))
out := ReplaceAll(in, old, new)
if s := string(out); s != tt.out {
t.Errorf("ReplaceAll(%q, %q, %q) = %q, want %q", tt.in, tt.old, tt.new, s, tt.out)
}
@ -1804,6 +1816,69 @@ func TestReplace(t *testing.T) {
}
}
func FuzzReplace(f *testing.F) {
for _, tt := range ReplaceTests {
f.Add([]byte(tt.in), []byte(tt.old), []byte(tt.new), tt.n)
}
f.Fuzz(func(t *testing.T, in, old, new []byte, n int) {
differentImpl := func(in, old, new []byte, n int) []byte {
var out Buffer
if n < 0 {
n = math.MaxInt
}
for i := 0; i < len(in); {
if n == 0 {
out.Write(in[i:])
break
}
if HasPrefix(in[i:], old) {
out.Write(new)
i += len(old)
n--
if len(old) != 0 {
continue
}
if i == len(in) {
break
}
}
if len(old) == 0 {
_, length := utf8.DecodeRune(in[i:])
out.Write(in[i : i+length])
i += length
} else {
out.WriteByte(in[i])
i++
}
}
if len(old) == 0 && n != 0 {
out.Write(new)
}
return out.Bytes()
}
if simple, replace := differentImpl(in, old, new, n), Replace(in, old, new, n); !slices.Equal(simple, replace) {
t.Errorf("The two implementations do not match %q != %q for Replace(%q, %q, %q, %d)", simple, replace, in, old, new, n)
}
})
}
func BenchmarkReplace(b *testing.B) {
for _, tt := range ReplaceTests {
desc := fmt.Sprintf("%q %q %q %d", tt.in, tt.old, tt.new, tt.n)
var (
in = []byte(tt.in)
old = []byte(tt.old)
new = []byte(tt.new)
)
b.Run(desc, func(b *testing.B) {
b.ReportAllocs()
for b.Loop() {
Replace(in, old, new, tt.n)
}
})
}
}
type TitleTest struct {
in, out string
}

View File

@ -628,3 +628,93 @@ func ExampleToUpperSpecial() {
// Original : ahoj vývojári golang
// ToUpper : AHOJ VÝVOJÁRİ GOLANG
}
func ExampleLines() {
text := []byte("Hello\nWorld\nGo Programming\n")
for line := range bytes.Lines(text) {
fmt.Printf("%q\n", line)
}
// Output:
// "Hello\n"
// "World\n"
// "Go Programming\n"
}
func ExampleSplitSeq() {
s := []byte("a,b,c,d")
for part := range bytes.SplitSeq(s, []byte(",")) {
fmt.Printf("%q\n", part)
}
// Output:
// "a"
// "b"
// "c"
// "d"
}
func ExampleSplitAfterSeq() {
s := []byte("a,b,c,d")
for part := range bytes.SplitAfterSeq(s, []byte(",")) {
fmt.Printf("%q\n", part)
}
// Output:
// "a,"
// "b,"
// "c,"
// "d"
}
func ExampleFieldsSeq() {
text := []byte("The quick brown fox")
fmt.Println("Split byte slice into fields:")
for word := range bytes.FieldsSeq(text) {
fmt.Printf("%q\n", word)
}
textWithSpaces := []byte(" lots of spaces ")
fmt.Println("\nSplit byte slice with multiple spaces:")
for word := range bytes.FieldsSeq(textWithSpaces) {
fmt.Printf("%q\n", word)
}
// Output:
// Split byte slice into fields:
// "The"
// "quick"
// "brown"
// "fox"
//
// Split byte slice with multiple spaces:
// "lots"
// "of"
// "spaces"
}
func ExampleFieldsFuncSeq() {
text := []byte("The quick brown fox")
fmt.Println("Split on whitespace(similar to FieldsSeq):")
for word := range bytes.FieldsFuncSeq(text, unicode.IsSpace) {
fmt.Printf("%q\n", word)
}
mixedText := []byte("abc123def456ghi")
fmt.Println("\nSplit on digits:")
for word := range bytes.FieldsFuncSeq(mixedText, unicode.IsDigit) {
fmt.Printf("%q\n", word)
}
// Output:
// Split on whitespace(similar to FieldsSeq):
// "The"
// "quick"
// "brown"
// "fox"
//
// Split on digits:
// "abc"
// "def"
// "ghi"
}

View File

@ -28,7 +28,6 @@ func Lines(s []byte) iter.Seq[[]byte] {
return
}
}
return
}
}
@ -67,26 +66,26 @@ func splitSeq(s, sep []byte, sepSave int) iter.Seq[[]byte] {
}
}
// SplitSeq returns an iterator over all substrings of s separated by sep.
// The iterator yields the same strings that would be returned by [Split](s, sep),
// but without constructing the slice.
// SplitSeq returns an iterator over all subslices of s separated by sep.
// The iterator yields the same subslices that would be returned by [Split](s, sep),
// but without constructing a new slice containing the subslices.
// It returns a single-use iterator.
func SplitSeq(s, sep []byte) iter.Seq[[]byte] {
return splitSeq(s, sep, 0)
}
// SplitAfterSeq returns an iterator over substrings of s split after each instance of sep.
// The iterator yields the same strings that would be returned by [SplitAfter](s, sep),
// but without constructing the slice.
// SplitAfterSeq returns an iterator over subslices of s split after each instance of sep.
// The iterator yields the same subslices that would be returned by [SplitAfter](s, sep),
// but without constructing a new slice containing the subslices.
// It returns a single-use iterator.
func SplitAfterSeq(s, sep []byte) iter.Seq[[]byte] {
return splitSeq(s, sep, len(sep))
}
// FieldsSeq returns an iterator over substrings of s split around runs of
// FieldsSeq returns an iterator over subslices of s split around runs of
// whitespace characters, as defined by [unicode.IsSpace].
// The iterator yields the same strings that would be returned by [Fields](s),
// but without constructing the slice.
// The iterator yields the same subslices that would be returned by [Fields](s),
// but without constructing a new slice containing the subslices.
func FieldsSeq(s []byte) iter.Seq[[]byte] {
return func(yield func([]byte) bool) {
start := -1
@ -116,10 +115,10 @@ func FieldsSeq(s []byte) iter.Seq[[]byte] {
}
}
// FieldsFuncSeq returns an iterator over substrings of s split around runs of
// FieldsFuncSeq returns an iterator over subslices of s split around runs of
// Unicode code points satisfying f(c).
// The iterator yields the same strings that would be returned by [FieldsFunc](s),
// but without constructing the slice.
// The iterator yields the same subslices that would be returned by [FieldsFunc](s),
// but without constructing a new slice containing the subslices.
func FieldsFuncSeq(s []byte, f func(rune) bool) iter.Seq[[]byte] {
return func(yield func([]byte) bool) {
start := -1

View File

@ -6,27 +6,16 @@
setlocal
set GOBUILDFAIL=0
go tool dist env -w -p >env.bat
if errorlevel 1 goto fail
go tool dist env -w -p >env.bat || exit /b 1
call .\env.bat
del env.bat
echo.
if exist %GOTOOLDIR%\dist.exe goto distok
echo cannot find %GOTOOLDIR%\dist; nothing to clean
goto fail
:distok
if not exist %GOTOOLDIR%\dist.exe (
echo cannot find %GOTOOLDIR%\dist.exe; nothing to clean
exit /b 1
)
"%GOBIN%\go" clean -i std
"%GOBIN%\go" tool dist clean
"%GOBIN%\go" clean -i cmd
goto end
:fail
set GOBUILDFAIL=1
:end
if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%

View File

@ -99,6 +99,11 @@ func TestGolden(t *testing.T) {
}
func TestCompareAPI(t *testing.T) {
if *flagCheck {
// not worth repeating in -check
t.Skip("skipping with -check set")
}
tests := []struct {
name string
features, required, exception []string
@ -180,6 +185,11 @@ func TestCompareAPI(t *testing.T) {
}
func TestSkipInternal(t *testing.T) {
if *flagCheck {
// not worth repeating in -check
t.Skip("skipping with -check set")
}
tests := []struct {
pkg string
want bool
@ -294,14 +304,20 @@ func TestIssue41358(t *testing.T) {
}
func TestIssue64958(t *testing.T) {
if testing.Short() {
t.Skip("skipping with -short")
}
if *flagCheck {
// slow, not worth repeating in -check
t.Skip("skipping with -check set")
}
testenv.MustHaveGoBuild(t)
defer func() {
if x := recover(); x != nil {
t.Errorf("expected no panic; recovered %v", x)
}
}()
testenv.MustHaveGoBuild(t)
for _, context := range contexts {
w := NewWalker(context, "testdata/src/issue64958")
pkg, err := w.importFrom("p", "", 0)

View File

@ -1058,7 +1058,7 @@ func (w *Walker) emitIfaceType(name string, typ *types.Interface) {
if w.isDeprecated(m) {
w.emitf("%s //deprecated", m.Name())
}
w.emitf("%s%s", m.Name(), w.signatureString(m.Type().(*types.Signature)))
w.emitf("%s%s", m.Name(), w.signatureString(m.Signature()))
}
if !complete {
@ -1088,7 +1088,7 @@ func (w *Walker) emitIfaceType(name string, typ *types.Interface) {
}
func (w *Walker) emitFunc(f *types.Func) {
sig := f.Type().(*types.Signature)
sig := f.Signature()
if sig.Recv() != nil {
panic("method considered a regular function: " + f.String())
}

View File

@ -59,10 +59,10 @@ func jumpArm64(word string) bool {
var arm64SpecialOperand map[string]arm64.SpecialOperand
// GetARM64SpecialOperand returns the internal representation of a special operand.
func GetARM64SpecialOperand(name string) arm64.SpecialOperand {
// ARM64SpecialOperand returns the internal representation of a special operand.
func ARM64SpecialOperand(name string) arm64.SpecialOperand {
if arm64SpecialOperand == nil {
// Generate the mapping automatically when the first time the function is called.
// Generate mapping when function is first called.
arm64SpecialOperand = map[string]arm64.SpecialOperand{}
for opd := arm64.SPOP_BEGIN; opd < arm64.SPOP_END; opd++ {
arm64SpecialOperand[opd.String()] = opd

View File

@ -13,9 +13,8 @@ import (
"cmd/internal/obj/riscv"
)
// IsRISCV64AMO reports whether the op (as defined by a riscv.A*
// constant) is one of the AMO instructions that requires special
// handling.
// IsRISCV64AMO reports whether op is an AMO instruction that requires
// special handling.
func IsRISCV64AMO(op obj.As) bool {
switch op {
case riscv.ASCW, riscv.ASCD, riscv.AAMOSWAPW, riscv.AAMOSWAPD, riscv.AAMOADDW, riscv.AAMOADDD,
@ -26,3 +25,33 @@ func IsRISCV64AMO(op obj.As) bool {
}
return false
}
// IsRISCV64VTypeI reports whether op is a vtype immediate instruction that
// requires special handling.
func IsRISCV64VTypeI(op obj.As) bool {
return op == riscv.AVSETVLI || op == riscv.AVSETIVLI
}
var riscv64SpecialOperand map[string]riscv.SpecialOperand
// RISCV64SpecialOperand returns the internal representation of a special operand.
func RISCV64SpecialOperand(name string) riscv.SpecialOperand {
if riscv64SpecialOperand == nil {
// Generate mapping when function is first called.
riscv64SpecialOperand = map[string]riscv.SpecialOperand{}
for opd := riscv.SPOP_BEGIN; opd < riscv.SPOP_END; opd++ {
riscv64SpecialOperand[opd.String()] = opd
}
}
if opd, ok := riscv64SpecialOperand[name]; ok {
return opd
}
return riscv.SPOP_END
}
// RISCV64ValidateVectorType reports whether the given configuration is a
// valid vector type.
func RISCV64ValidateVectorType(vsew, vlmul, vtail, vmask int64) error {
_, err := riscv.EncodeVectorType(vsew, vlmul, vtail, vmask)
return err
}

View File

@ -915,6 +915,19 @@ func (p *Parser) asmInstruction(op obj.As, cond string, a []obj.Addr) {
prog.To = a[5]
break
}
if p.arch.Family == sys.RISCV64 && arch.IsRISCV64VTypeI(op) {
prog.From = a[0]
vsew := p.getSpecial(prog, op, &a[1])
vlmul := p.getSpecial(prog, op, &a[2])
vtail := p.getSpecial(prog, op, &a[3])
vmask := p.getSpecial(prog, op, &a[4])
if err := arch.RISCV64ValidateVectorType(vsew, vlmul, vtail, vmask); err != nil {
p.errorf("invalid vtype: %v", err)
}
prog.AddRestSourceArgs([]obj.Addr{a[1], a[2], a[3], a[4]})
prog.To = a[5]
break
}
fallthrough
default:
p.errorf("can't handle %s instruction with %d operands", op, len(a))
@ -965,3 +978,11 @@ func (p *Parser) getRegister(prog *obj.Prog, op obj.As, addr *obj.Addr) int16 {
}
return addr.Reg
}
// getSpecial checks that addr represents a special operand and returns its value.
func (p *Parser) getSpecial(prog *obj.Prog, op obj.As, addr *obj.Addr) int64 {
if addr.Type != obj.TYPE_SPECIAL || addr.Name != 0 || addr.Reg != 0 || addr.Index != 0 {
p.errorf("%s: expected special operand; found %s", op, obj.Dconv(prog, addr))
}
return addr.Offset
}

View File

@ -465,9 +465,15 @@ func TestLOONG64Encoder(t *testing.T) {
testEndToEnd(t, "loong64", "loong64enc1")
testEndToEnd(t, "loong64", "loong64enc2")
testEndToEnd(t, "loong64", "loong64enc3")
testEndToEnd(t, "loong64", "loong64enc4")
testEndToEnd(t, "loong64", "loong64enc5")
testEndToEnd(t, "loong64", "loong64")
}
func TestLOONG64Errors(t *testing.T) {
testErrors(t, "loong64", "loong64error")
}
func TestPPC64EndToEnd(t *testing.T) {
defer func(old int) { buildcfg.GOPPC64 = old }(buildcfg.GOPPC64)
for _, goppc64 := range []int{8, 9, 10} {
@ -487,6 +493,10 @@ func TestRISCVErrors(t *testing.T) {
testErrors(t, "riscv64", "riscv64error")
}
func TestRISCVValidation(t *testing.T) {
testErrors(t, "riscv64", "riscv64validation")
}
func TestS390XEndToEnd(t *testing.T) {
testEndToEnd(t, "s390x", "s390x")
}

View File

@ -21,6 +21,7 @@ import (
"cmd/asm/internal/lex"
"cmd/internal/obj"
"cmd/internal/obj/arm64"
"cmd/internal/obj/riscv"
"cmd/internal/obj/x86"
"cmd/internal/objabi"
"cmd/internal/src"
@ -398,16 +399,21 @@ func (p *Parser) operand(a *obj.Addr) {
tok := p.next()
name := tok.String()
if tok.ScanToken == scanner.Ident && !p.atStartOfRegister(name) {
// See if this is an architecture specific special operand.
switch p.arch.Family {
case sys.ARM64:
// arm64 special operands.
if opd := arch.GetARM64SpecialOperand(name); opd != arm64.SPOP_END {
if opd := arch.ARM64SpecialOperand(name); opd != arm64.SPOP_END {
a.Type = obj.TYPE_SPECIAL
a.Offset = int64(opd)
break
}
fallthrough
default:
case sys.RISCV64:
if opd := arch.RISCV64SpecialOperand(name); opd != riscv.SPOP_END {
a.Type = obj.TYPE_SPECIAL
a.Offset = int64(opd)
}
}
if a.Type != obj.TYPE_SPECIAL {
// We have a symbol. Parse $sym±offset(symkind)
p.symbolReference(a, p.qualifySymbol(name), prefix)
}

View File

@ -1059,5 +1059,7 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
RDPID DX // f30fc7fa
RDPID R11 // f3410fc7fb
ENDBR64 // f30f1efa
// End of tests.
RET

View File

@ -1888,4 +1888,10 @@ next:
DC CIGDVAC, R25 // b97e0bd5
DC CVAP, R26 // 3a7c0bd5
DC CVADP, R27 // 3b7d0bd5
// Branch Target Identification
BTI C // 5f2403d5
BTI J // 9f2403d5
BTI JC // df2403d5
END

View File

@ -420,4 +420,6 @@ TEXT errors(SB),$0
AESE V1.B16, V2.B8 // ERROR "invalid arrangement"
SHA256SU1 V1.S4, V2.B16, V3.S4 // ERROR "invalid arrangement"
SHA1H V1.B16, V2.B16 // ERROR "invalid operands"
BTI // ERROR "missing operand"
BTI PLDL1KEEP // ERROR "illegal argument"
RET

View File

@ -8,10 +8,14 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
lable1:
BFPT 1(PC) // 00050048
BFPT lable1 // BFPT 2 // 1ffdff4b
BFPT FCC0, lable1 // BFPT FCC0, 2 // 1ff9ff4b
BFPT FCC7, lable1 // BFPT FCC7, 2 // fff5ff4b
lable2:
BFPF 1(PC) // 00040048
BFPF lable2 // BFPF 4 // 1ffcff4b
BFPF lable2 // BFPF 6 // 1ffcff4b
BFPF FCC0, lable2 // BFPF FCC0, 6 // 1ff8ff4b
BFPF FCC7, lable2 // BFPF FCC7, 6 // fff4ff4b
// relocation in play so the assembled offset should be 0
JMP foo(SB) // 00000050
@ -107,8 +111,8 @@ lable2:
MOVV $4(R4), R5 // 8510c002
MOVW $-1, R4 // 04fcff02
MOVV $-1, R4 // 04fcff02
MOVW $1, R4 // 0404c002
MOVV $1, R4 // 0404c002
MOVW $1, R4 // 04048003
MOVV $1, R4 // 04048003
ADD $-1, R4, R5 // 85fcbf02
ADD $-1, R4 // 84fcbf02
ADDV $-1, R4, R5 // 85fcff02
@ -346,6 +350,15 @@ lable2:
FTINTVF F0, F1 // 01241b01
FTINTVD F0, F1 // 01281b01
FMAXAF F4, F5, F6 // a6900c01
FMAXAF F4, F5 // a5900c01
FMAXAD F4, F5, F6 // a6100d01
FMAXAD F4, F5 // a5100d01
FMINAF F4, F5, F6 // a6900e01
FMINAF F4, F5 // a5900e01
FMINAD F4, F5, F6 // a6100f01
FMINAD F4, F5 // a5100f01
FTINTRMWF F0, F2 // 02041a01
FTINTRMWD F0, F2 // 02081a01
FTINTRMVF F0, F2 // 02241a01
@ -506,6 +519,16 @@ lable2:
XVSEQH X3, X2, X4 // 448c0074
XVSEQW X3, X2, X4 // 440c0174
XVSEQV X3, X2, X4 // 448c0174
VSEQB $0, V2, V3 // 43008072
VSEQH $1, V2, V3 // 43848072
VSEQW $8, V2, V3 // 43208172
VSEQV $15, V2, V3 // 43bc8172
VSEQV $-15, V2, V3 // 43c48172
XVSEQB $0, X2, X4 // 44008076
XVSEQH $3, X2, X4 // 448c8076
XVSEQW $12, X2, X4 // 44308176
XVSEQV $15, X2, X4 // 44bc8176
XVSEQV $-15, X2, X4 // 44c48176
// VPCNT{B,H,W,V}, XVPCNT{B,H,W,V} instruction
VPCNTB V1, V2 // 22209c72
@ -516,3 +539,428 @@ lable2:
XVPCNTH X3, X2 // 62249c76
XVPCNTW X3, X2 // 62289c76
XVPCNTV X3, X2 // 622c9c76
// VANDV,VORV,VXORV,VNORV,VANDNV,VORNV
VANDV V1, V2, V3 // 43042671
VORV V1, V2, V3 // 43842671
VXORV V1, V2, V3 // 43042771
VNORV V1, V2, V3 // 43842771
VANDNV V1, V2, V3 // 43042871
VORNV V1, V2, V3 // 43842871
// VANDB,VORB,VXORB,VNORB
VANDB $0, V2, V3 // 4300d073
VORB $64, V2, V3 // 4300d573
VXORB $128, V2, V3 // 4300da73
VNORB $255, V2, V3 // 43fcdf73
// XVANDV,XVORV,XVXORV,XVNORV,XVANDNV,XVORNV
XVANDV X1, X2, X3 // 43042675
XVORV X1, X2, X3 // 43842675
XVXORV X1, X2, X3 // 43042775
XVNORV X1, X2, X3 // 43842775
XVANDNV X1, X2, X3 // 43042875
XVORNV X1, X2, X3 // 43842875
// XVANDB,XVORB,XVXORB,XVNORB
XVANDB $0, X2, X3 // 4300d077
XVORB $1, X2, X3 // 4304d477
XVXORB $127, X2, X3 // 43fcd977
XVNORB $255, X2, X3 // 43fcdf77
// MOVV C_DCON12_0, r
MOVV $0x7a90000000000000, R4 // MOVV $8831558869273542656, R4 // 04a41e03
MOVV $0xea90000000000000, R4 // MOVV $-1544734672188080128, R4 // 04a43a03
// MOVV C_UCON, r
MOVV $0x54321000, R4 // MOVV $1412567040, R4 // 2464a814
MOVV $0xffffffff8432f000, R4 // MOVV $-2077036544, R4 // e4650815
// MOVV C_ADDCON, r
MOVV $0xfffffffffffff821, R4 // MOVV $-2015, R4 // 0484e002
// MOVV C_ANDCON, r
MOVV $0x821, R4 // MOVV $2081, R4 // 0484a003
// ADDV C_SCON, [r1], r2
ADDV $0x321, R4 // ADDV $801, R4 // 8484cc02
ADDV $0x321, R5, R4 // ADDV $801, R5, R4 // a484cc02
ADDV $0xfffffffffffffc21, R4 // ADDV $-991, R4 // 8484f002
ADDV $0xfffffffffffffc21, R5, R4 // ADDV $-991, R5, R4 // a484f002
// AND C_SCON, [r1], r2
AND $0x321, R4 // AND $801, R4 // 84844c03
AND $0x321, R5, R4 // AND $801, R5, R4 // a4844c03
// [X]{VSLL/VSRL/VSRA/VROTR}{B,H,W,V} instructions
VSLLB V1, V2, V3 // 4304e870
VSLLH V1, V2, V3 // 4384e870
VSLLW V1, V2, V3 // 4304e970
VSLLV V1, V2, V3 // 4384e970
VSRLB V1, V2, V3 // 4304ea70
VSRLH V1, V2, V3 // 4384ea70
VSRLW V1, V2, V3 // 4304eb70
VSRLV V1, V2, V3 // 4384eb70
VSRAB V1, V2, V3 // 4304ec70
VSRAH V1, V2, V3 // 4384ec70
VSRAW V1, V2, V3 // 4304ed70
VSRAV V1, V2, V3 // 4384ed70
VROTRB V1, V2, V3 // 4304ee70
VROTRH V1, V2, V3 // 4384ee70
VROTRW V1, V2, V3 // 4304ef70
VROTRV V1, V2, V3 // 4384ef70
XVSLLB X3, X2, X1 // 410ce874
XVSLLH X3, X2, X1 // 418ce874
XVSLLW X3, X2, X1 // 410ce974
XVSLLV X3, X2, X1 // 418ce974
XVSRLB X3, X2, X1 // 410cea74
XVSRLH X3, X2, X1 // 418cea74
XVSRLW X3, X2, X1 // 410ceb74
XVSRLV X3, X2, X1 // 418ceb74
XVSRAB X3, X2, X1 // 410cec74
XVSRAH X3, X2, X1 // 418cec74
XVSRAW X3, X2, X1 // 410ced74
XVSRAV X3, X2, X1 // 418ced74
XVROTRB X3, X2, X1 // 410cee74
XVROTRH X3, X2, X1 // 418cee74
XVROTRW X3, X2, X1 // 410cef74
XVROTRV X3, X2, X1 // 418cef74
VSLLB $0, V1, V2 // 22202c73
VSLLB $7, V1, V2 // 223c2c73
VSLLB $5, V1 // 21342c73
VSLLH $0, V1, V2 // 22402c73
VSLLH $15, V1, V2 // 227c2c73
VSLLH $10, V1 // 21682c73
VSLLW $0, V1, V2 // 22802c73
VSLLW $31, V1, V2 // 22fc2c73
VSLLW $11, V1 // 21ac2c73
VSLLV $0, V1, V2 // 22002d73
VSLLV $63, V1, V2 // 22fc2d73
VSLLV $30, V1 // 21782d73
VSRLB $0, V1, V2 // 22203073
VSRLB $7, V1, V2 // 223c3073
VSRLB $4, V1 // 21303073
VSRLH $0, V1, V2 // 22403073
VSRLH $15, V1, V2 // 227c3073
VSRLH $9, V1 // 21643073
VSRLW $0, V1, V2 // 22803073
VSRLW $31, V1, V2 // 22fc3073
VSRLW $16, V1 // 21c03073
VSRLV $0, V1, V2 // 22003173
VSRLV $63, V1, V2 // 22fc3173
VSRLV $40, V1 // 21a03173
VSRAB $0, V1, V2 // 22203473
VSRAB $7, V1, V2 // 223c3473
VSRAB $6, V1 // 21383473
VSRAH $0, V1, V2 // 22403473
VSRAH $15, V1, V2 // 227c3473
VSRAH $8, V1 // 21603473
VSRAW $0, V1, V2 // 22803473
VSRAW $31, V1, V2 // 22fc3473
VSRAW $12, V1 // 21b03473
VSRAV $0, V1, V2 // 22003573
VSRAV $63, V1, V2 // 22fc3573
VSRAV $50, V1 // 21c83573
VROTRB $0, V1, V2 // 2220a072
VROTRB $7, V1, V2 // 223ca072
VROTRB $3, V1 // 212ca072
VROTRH $0, V1, V2 // 2240a072
VROTRH $15, V1, V2 // 227ca072
VROTRH $5, V1 // 2154a072
VROTRW $0, V1, V2 // 2280a072
VROTRW $31, V1, V2 // 22fca072
VROTRW $18, V1 // 21c8a072
VROTRV $0, V1, V2 // 2200a172
VROTRV $63, V1, V2 // 22fca172
VROTRV $52, V1 // 21d0a172
XVSLLB $0, X2, X1 // 41202c77
XVSLLB $7, X2, X1 // 413c2c77
XVSLLB $4, X2 // 42302c77
XVSLLH $0, X2, X1 // 41402c77
XVSLLH $15, X2, X1 // 417c2c77
XVSLLH $8, X2 // 42602c77
XVSLLW $0, X2, X1 // 41802c77
XVSLLW $31, X2, X1 // 41fc2c77
XVSLLW $13, X2 // 42b42c77
XVSLLV $0, X2, X1 // 41002d77
XVSLLV $63, X2, X1 // 41fc2d77
XVSLLV $36, X2 // 42902d77
XVSRLB $0, X2, X1 // 41203077
XVSRLB $7, X2, X1 // 413c3077
XVSRLB $5, X2 // 42343077
XVSRLH $0, X2, X1 // 41403077
XVSRLH $15, X2, X1 // 417c3077
XVSRLH $9, X2 // 42643077
XVSRLW $0, X2, X1 // 41803077
XVSRLW $31, X2, X1 // 41fc3077
XVSRLW $14, X2 // 42b83077
XVSRLV $0, X2, X1 // 41003177
XVSRLV $63, X2, X1 // 41fc3177
XVSRLV $45, X2 // 42b43177
XVSRAB $0, X2, X1 // 41203477
XVSRAB $7, X2, X1 // 413c3477
XVSRAB $6, X2 // 42383477
XVSRAH $0, X2, X1 // 41403477
XVSRAH $15, X2, X1 // 417c3477
XVSRAH $10, X2 // 42683477
XVSRAW $0, X2, X1 // 41803477
XVSRAW $31, X2, X1 // 41fc3477
XVSRAW $16, X2 // 42c03477
XVSRAV $0, X2, X1 // 41003577
XVSRAV $63, X2, X1 // 41fc3577
XVSRAV $48, X2 // 42c03577
XVROTRB $0, X2, X1 // 4120a076
XVROTRB $7, X2, X1 // 413ca076
XVROTRB $3, X2 // 422ca076
XVROTRH $0, X2, X1 // 4140a076
XVROTRH $15, X2, X1 // 417ca076
XVROTRH $13, X2 // 4274a076
XVROTRW $0, X2, X1 // 4180a076
XVROTRW $31, X2, X1 // 41fca076
XVROTRW $24, X2 // 42e0a076
XVROTRV $0, X2, X1 // 4100a176
XVROTRV $63, X2, X1 // 41fca176
XVROTRV $52, X2 // 42d0a176
// [X]VADD{B,H,W,V,Q}, [X]VSUB{B,H,W,V,Q} instructions
VADDB V1, V2, V3 // 43040a70
VADDH V1, V2, V3 // 43840a70
VADDW V1, V2, V3 // 43040b70
VADDV V1, V2, V3 // 43840b70
VADDQ V1, V2, V3 // 43042d71
VSUBB V1, V2, V3 // 43040c70
VSUBH V1, V2, V3 // 43840c70
VSUBW V1, V2, V3 // 43040d70
VSUBV V1, V2, V3 // 43840d70
VSUBQ V1, V2, V3 // 43842d71
XVADDB X3, X2, X1 // 410c0a74
XVADDH X3, X2, X1 // 418c0a74
XVADDW X3, X2, X1 // 410c0b74
XVADDV X3, X2, X1 // 418c0b74
XVADDQ X3, X2, X1 // 410c2d75
XVSUBB X3, X2, X1 // 410c0c74
XVSUBH X3, X2, X1 // 418c0c74
XVSUBW X3, X2, X1 // 410c0d74
XVSUBV X3, X2, X1 // 418c0d74
XVSUBQ X3, X2, X1 // 418c2d75
// [X]VADD{B,H,W,V}U, [X]VSUB{B,H,W,V}U instructions
VADDBU $1, V2, V1 // 41048a72
VADDHU $2, V2, V1 // 41888a72
VADDWU $3, V2, V1 // 410c8b72
VADDVU $4, V2, V1 // 41908b72
VSUBBU $5, V2, V1 // 41148c72
VSUBHU $6, V2, V1 // 41988c72
VSUBWU $7, V2, V1 // 411c8d72
VSUBVU $8, V2, V1 // 41a08d72
XVADDBU $9, X1, X2 // 22248a76
XVADDHU $10, X1, X2 // 22a88a76
XVADDWU $11, X1, X2 // 222c8b76
XVADDVU $12, X1, X2 // 22b08b76
XVSUBBU $13, X1, X2 // 22348c76
XVSUBHU $14, X1, X2 // 22b88c76
XVSUBWU $15, X1, X2 // 223c8d76
XVSUBVU $16, X1, X2 // 22c08d76
// [X]VILV{L/H}{B,H,W,V} instructions
VILVLB V1, V2, V3 // 43041a71
VILVLH V1, V2, V3 // 43841a71
VILVLW V1, V2, V3 // 43041b71
VILVLV V1, V2, V3 // 43841b71
VILVHB V1, V2, V3 // 43041c71
VILVHH V1, V2, V3 // 43841c71
VILVHW V1, V2, V3 // 43041d71
VILVHV V1, V2, V3 // 43841d71
XVILVLB X3, X2, X1 // 410c1a75
XVILVLH X3, X2, X1 // 418c1a75
XVILVLW X3, X2, X1 // 410c1b75
XVILVLV X3, X2, X1 // 418c1b75
XVILVHB X3, X2, X1 // 410c1c75
XVILVHH X3, X2, X1 // 418c1c75
XVILVHW X3, X2, X1 // 410c1d75
XVILVHV X3, X2, X1 // 418c1d75
// [X]VMUL{B/H/W/V} and [X]VMUH{B/H/W/V}[U] instructions
VMULB V1, V2, V3 // 43048470
VMULH V1, V2, V3 // 43848470
VMULW V1, V2, V3 // 43048570
VMULV V1, V2, V3 // 43848570
VMUHB V1, V2, V3 // 43048670
VMUHH V1, V2, V3 // 43848670
VMUHW V1, V2, V3 // 43048770
VMUHV V1, V2, V3 // 43848770
VMUHBU V1, V2, V3 // 43048870
VMUHHU V1, V2, V3 // 43848870
VMUHWU V1, V2, V3 // 43048970
VMUHVU V1, V2, V3 // 43848970
XVMULB X3, X2, X1 // 410c8474
XVMULH X3, X2, X1 // 418c8474
XVMULW X3, X2, X1 // 410c8574
XVMULV X3, X2, X1 // 418c8574
XVMUHB X3, X2, X1 // 410c8674
XVMUHH X3, X2, X1 // 418c8674
XVMUHW X3, X2, X1 // 410c8774
XVMUHV X3, X2, X1 // 418c8774
XVMUHBU X3, X2, X1 // 410c8874
XVMUHHU X3, X2, X1 // 418c8874
XVMUHWU X3, X2, X1 // 410c8974
XVMUHVU X3, X2, X1 // 418c8974
// [X]VDIV{B/H/W/V}[U] and [X]VMOD{B/H/W/V}[U] instructions
VDIVB V1, V2, V3 // 4304e070
VDIVH V1, V2, V3 // 4384e070
VDIVW V1, V2, V3 // 4304e170
VDIVV V1, V2, V3 // 4384e170
VDIVBU V1, V2, V3 // 4304e470
VDIVHU V1, V2, V3 // 4384e470
VDIVWU V1, V2, V3 // 4304e570
VDIVVU V1, V2, V3 // 4384e570
VMODB V1, V2, V3 // 4304e270
VMODH V1, V2, V3 // 4384e270
VMODW V1, V2, V3 // 4304e370
VMODV V1, V2, V3 // 4384e370
VMODBU V1, V2, V3 // 4304e670
VMODHU V1, V2, V3 // 4384e670
VMODWU V1, V2, V3 // 4304e770
VMODVU V1, V2, V3 // 4384e770
XVDIVB X3, X2, X1 // 410ce074
XVDIVH X3, X2, X1 // 418ce074
XVDIVW X3, X2, X1 // 410ce174
XVDIVV X3, X2, X1 // 418ce174
XVDIVBU X3, X2, X1 // 410ce474
XVDIVHU X3, X2, X1 // 418ce474
XVDIVWU X3, X2, X1 // 410ce574
XVDIVVU X3, X2, X1 // 418ce574
XVMODB X3, X2, X1 // 410ce274
XVMODH X3, X2, X1 // 418ce274
XVMODW X3, X2, X1 // 410ce374
XVMODV X3, X2, X1 // 418ce374
XVMODBU X3, X2, X1 // 410ce674
XVMODHU X3, X2, X1 // 418ce674
XVMODWU X3, X2, X1 // 410ce774
XVMODVU X3, X2, X1 // 418ce774
// [X]VF{SQRT/RECIP/RSQRT}{F/D} instructions
VFSQRTF V1, V2 // 22e49c72
VFSQRTD V1, V2 // 22e89c72
VFRECIPF V1, V2 // 22f49c72
VFRECIPD V1, V2 // 22f89c72
VFRSQRTF V1, V2 // 22049d72
VFRSQRTD V1, V2 // 22089d72
XVFSQRTF X2, X1 // 41e49c76
XVFSQRTD X2, X1 // 41e89c76
XVFRECIPF X2, X1 // 41f49c76
XVFRECIPD X2, X1 // 41f89c76
XVFRSQRTF X2, X1 // 41049d76
XVFRSQRTD X2, X1 // 41089d76
// [X]VNEG{B/H/W/V} instructions
VNEGB V1, V2 // 22309c72
VNEGH V1, V2 // 22349c72
VNEGW V1, V2 // 22389c72
VNEGV V1, V2 // 223c9c72
XVNEGB X2, X1 // 41309c76
XVNEGH X2, X1 // 41349c76
XVNEGW X2, X1 // 41389c76
XVNEGV X2, X1 // 413c9c76
// [X]{VMULW}{EV/OD}.{H.B/W.H/D.W/Q.D}[U] instructions
VMULWEVHB V1, V2, V3 // 43049070
VMULWEVWH V1, V2, V3 // 43849070
VMULWEVVW V1, V2, V3 // 43049170
VMULWEVQV V1, V2, V3 // 43849170
VMULWODHB V1, V2, V3 // 43049270
VMULWODWH V1, V2, V3 // 43849270
VMULWODVW V1, V2, V3 // 43049370
VMULWODQV V1, V2, V3 // 43849370
VMULWEVHBU V1, V2, V3 // 43049870
VMULWEVWHU V1, V2, V3 // 43849870
VMULWEVVWU V1, V2, V3 // 43049970
VMULWEVQVU V1, V2, V3 // 43849970
VMULWODHBU V1, V2, V3 // 43049a70
VMULWODWHU V1, V2, V3 // 43849a70
VMULWODVWU V1, V2, V3 // 43049b70
VMULWODQVU V1, V2, V3 // 43849b70
XVMULWEVHB X1, X2, X3 // 43049074
XVMULWEVWH X1, X2, X3 // 43849074
XVMULWEVVW X1, X2, X3 // 43049174
XVMULWEVQV X1, X2, X3 // 43849174
XVMULWODHB X1, X2, X3 // 43049274
XVMULWODWH X1, X2, X3 // 43849274
XVMULWODVW X1, X2, X3 // 43049374
XVMULWODQV X1, X2, X3 // 43849374
XVMULWEVHBU X1, X2, X3 // 43049874
XVMULWEVWHU X1, X2, X3 // 43849874
XVMULWEVVWU X1, X2, X3 // 43049974
XVMULWEVQVU X1, X2, X3 // 43849974
XVMULWODHBU X1, X2, X3 // 43049a74
XVMULWODWHU X1, X2, X3 // 43849a74
XVMULWODVWU X1, X2, X3 // 43049b74
XVMULWODQVU X1, X2, X3 // 43849b74
// [X]{VMULW}{EV/OD}.{H.BU.B/W.HU.H/D.WU.W/Q.DU.D} instructions
VMULWEVHBUB V1, V2, V3 // 4304a070
VMULWEVWHUH V1, V2, V3 // 4384a070
VMULWEVVWUW V1, V2, V3 // 4304a170
VMULWEVQVUV V1, V2, V3 // 4384a170
VMULWODHBUB V1, V2, V3 // 4304a270
VMULWODWHUH V1, V2, V3 // 4384a270
VMULWODVWUW V1, V2, V3 // 4304a370
VMULWODQVUV V1, V2, V3 // 4384a370
XVMULWEVHBUB X1, X2, X3 // 4304a074
XVMULWEVWHUH X1, X2, X3 // 4384a074
XVMULWEVVWUW X1, X2, X3 // 4304a174
XVMULWEVQVUV X1, X2, X3 // 4384a174
XVMULWODHBUB X1, X2, X3 // 4304a274
XVMULWODWHUH X1, X2, X3 // 4384a274
XVMULWODVWUW X1, X2, X3 // 4304a374
XVMULWODQVUV X1, X2, X3 // 4384a374
// [X]VSHUF4I.{B/H/W/D} instructions
VSHUF4IB $0, V2, V1 // 41009073
VSHUF4IB $16, V2, V1 // 41409073
VSHUF4IB $255, V2, V1 // 41fc9373
VSHUF4IH $0, V2, V1 // 41009473
VSHUF4IH $128, V2, V1 // 41009673
VSHUF4IH $255, V2, V1 // 41fc9773
VSHUF4IW $0, V2, V1 // 41009873
VSHUF4IW $96, V2, V1 // 41809973
VSHUF4IW $255, V2, V1 // 41fc9b73
VSHUF4IV $0, V2, V1 // 41009c73
VSHUF4IV $8, V2, V1 // 41209c73
VSHUF4IV $15, V2, V1 // 413c9c73
XVSHUF4IB $0, X1, X2 // 22009077
XVSHUF4IB $16, X1, X2 // 22409077
XVSHUF4IB $255, X1, X2 // 22fc9377
XVSHUF4IH $0, X1, X2 // 22009477
XVSHUF4IH $128, X1, X2 // 22009677
XVSHUF4IH $255, X1, X2 // 22fc9777
XVSHUF4IW $0, X1, X2 // 22009877
XVSHUF4IW $96, X1, X2 // 22809977
XVSHUF4IW $255, X1, X2 // 22fc9b77
XVSHUF4IV $0, X1, X2 // 22009c77
XVSHUF4IV $8, X1, X2 // 22209c77
XVSHUF4IV $15, X1, X2 // 223c9c77
// [X]VSETEQZ.V, [X]VSETNEZ.V
VSETEQV V1, FCC0 // 20989c72
VSETNEV V1, FCC0 // 209c9c72
XVSETEQV X1, FCC0 // 20989c76
XVSETNEV X1, FCC0 // 209c9c76
// [X]VSETANYEQZ.{B/H/W/D} instructions
VSETANYEQB V1, FCC0 // 20a09c72
VSETANYEQH V1, FCC0 // 20a49c72
VSETANYEQW V1, FCC0 // 20a89c72
VSETANYEQV V1, FCC0 // 20ac9c72
VSETALLNEB V1, FCC0 // 20b09c72
VSETALLNEH V1, FCC0 // 20b49c72
VSETALLNEW V1, FCC0 // 20b89c72
VSETALLNEV V1, FCC0 // 20bc9c72
XVSETANYEQB X1, FCC0 // 20a09c76
XVSETANYEQH X1, FCC0 // 20a49c76
XVSETANYEQW X1, FCC0 // 20a89c76
XVSETANYEQV X1, FCC0 // 20ac9c76
XVSETALLNEB X1, FCC0 // 20b09c76
XVSETALLNEH X1, FCC0 // 20b49c76
XVSETALLNEW X1, FCC0 // 20b89c76
XVSETALLNEV X1, FCC0 // 20bc9c76

View File

@ -12,7 +12,7 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
AND $-1, R4, R5 // 1efcbf0285f81400
AND $-1, R4 // 1efcbf0284f81400
MOVW $-1, F4 // 1efcbf02c4a71401
MOVW $1, F4 // 1e048002c4a71401
MOVW $1, F4 // 1e048003c4a71401
TEQ $4, R4, R5 // 8508005c04002a00
TEQ $4, R4 // 0408005c04002a00
TNE $4, R4, R5 // 8508005804002a00
@ -77,3 +77,49 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
MOVH name(SB), R4 // 1e00001ac4034028
MOVHU R4, name(SB) // 1e00001ac4034029
MOVHU name(SB), R4 // 1e00001ac403402a
// MOVV C_DCON12_20S, r
MOVV $0x273fffff80000000, R4 // MOVV $2828260563841187840, R4 // 0400001584cc0903
MOVV $0xf73fffff80000000, R4 // MOVV $-630503949979353088, R4 // 0400001584cc3d03
// MOVV C_DCON20S_20, r
MOVV $0xfff800000f000000, R4 // MOVV $-2251799562027008, R4 // 04001e1404000017
// MOVV C_DCON12_12S, r
MOVV $0x273ffffffffff800, R4 // MOVV $2828260565988669440, R4 // 0400e00284cc0903
MOVV $0xf73ffffffffff800, R4 // MOVV $-630503947831871488, R4 // 0400e00284cc3d03
// MOVV C_DCON20S_12S, r
MOVV $0xfff80000fffff800, R4 // MOVV $-2251795518720000, R4 // 0400a00204000017
MOVV $0xfff8000000000000, R4 // MOVV $-2251799813685248, R4 // 0400800204000017
// MOVV C_DCON12_12U, r
MOVV $0x2730000000000800, R4 // MOVV $2823756966361303040, R4 // 0400a00384cc0903
MOVV $0xf730000000000800, R4 // MOVV $-635007547459237888, R4 // 0400a00384cc3d03
// MOVV C_DCON20S_12U, r
MOVV $0xfff8000000000800, R4 // MOVV $-2251799813683200, R4 // 0400a00304000017
// ADDV/AND C_DCON12_0, [r1], r2
ADDV $0x3210000000000000, R4 // ADDV $3607383301523767296, R4 // 1e840c0384f81000
ADDV $0x3210000000000000, R5, R4 // ADDV $3607383301523767296, R5, R4 // 1e840c03a4f81000
ADDV $0xc210000000000000, R4 // ADDV $-4463067230724161536, R4 // 1e84300384f81000
ADDV $0xc210000000000000, R5, R4 // ADDV $-4463067230724161536, R5, R4 // 1e843003a4f81000
AND $0x3210000000000000, R4 // AND $3607383301523767296, R4 // 1e840c0384f81400
AND $0x3210000000000000, R5, R4 // AND $3607383301523767296, R5, R4 // 1e840c03a4f81400
AND $0xc210000000000000, R4 // AND $-4463067230724161536, R4 // 1e84300384f81400
AND $0xc210000000000000, R5, R4 // AND $-4463067230724161536, R5, R4 // 1e843003a4f81400
// ADDV/AND C_UCON, [r1], r2
ADDV $0x43210000, R4 // ADDV $1126236160, R4 // 1e42861484f81000
ADDV $0x43210000, R5, R4 // ADDV $1126236160, R5, R4 // 1e428614a4f81000
ADDV $0xffffffffc3210000, R4 // ADDV $-1021247488, R4 // 1e42861584f81000
ADDV $0xffffffffc3210000, R5, R4 // ADDV $-1021247488, R5, R4 // 1e428615a4f81000
AND $0x43210000, R4 // AND $1126236160, R4 // 1e42861484f81400
AND $0x43210000, R5, R4 // AND $1126236160, R5, R4 // 1e428614a4f81400
AND $0xffffffffc3210000, R4 // AND $-1021247488, R4 // 1e42861584f81400
AND $0xffffffffc3210000, R5, R4 // AND $-1021247488, R5, R4 // 1e428615a4f81400
// AND C_ADDCON, [r1], r2
AND $0xfffffffffffffc21, R4 // AND $-991, R4 // 1e84b00284f81400
AND $0xfffffffffffffc21, R5, R4 // AND $-991, R5, R4 // 1e84b002a4f81400

View File

@ -121,3 +121,68 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$0
XOR $74565, R4, R5 // 5e020014de178d0385f81500
XOR $4097, R4 // 3e000014de07800384f81500
XOR $4097, R4, R5 // 3e000014de07800385f81500
// MOVV C_DCON32_12S, r
MOVV $0x27312345fffff800, R4 // MOVV $2824077224892692480, R4 // 0400a002a468241684cc0903
MOVV $0xf7312345fffff800, R4 // MOVV $-634687288927848448, R4 // 0400a002a468241684cc3d03
// MOVV C_DCON32_0, r
MOVV $0x2731234500000000, R4 // MOVV $2824077220597727232, R4 // 04008002a468241684cc0903
MOVV $0xf731234500000000, R4 // MOVV $-634687293222813696, R4 // 04008002a468241684cc3d03
// MOVV C_DCON32_20, r
MOVV $0x2731234512345000, R4 // MOVV $2824077220903145472, R4 // a4682414a468241684cc0903
MOVV $0xf731234512345000, R4 // MOVV $-634687292917395456, R4 // a4682414a468241684cc3d03
// MOVV C_DCON12_32S, r
MOVV $0x273fffff80000800, R4 // MOVV $2828260563841189888, R4 // 040000158400a00384cc0903
MOVV $0xf73fffff80000800, R4 // MOVV $-630503949979351040, R4 // 040000158400a00384cc3d03
// MOVV C_DCON20S_32, r
MOVV $0xfff8000080000800, R4 // MOVV $-2251797666199552, R4 // 040000158400a00304000017
// MOVV C_DCON32_12U, r
MOVV $0x2731234500000800, R4 // MOVV $2824077220597729280, R4 // 0400a003a468241684cc0903
MOVV $0xf731234500000800, R4 // MOVV $-634687293222811648, R4 // 0400a003a468241684cc3d03
// ADDV/AND C_DCON12_20S, [r1], r2
ADDV $0x273fffff80000000, R4 // ADDV $2828260563841187840, R4 // 1e000015decf090384f81000
ADDV $0x273fffff80000000, R4, R5 // ADDV $2828260563841187840, R4, R5 // 1e000015decf090385f81000
AND $0x273fffff80000000, R4 // AND $2828260563841187840, R4 // 1e000015decf090384f81400
AND $0x273fffff80000000, R4, R5 // AND $2828260563841187840, R4, R5 // 1e000015decf090385f81400
// ADDV/AND C_DCON20S_20, [r1], r2
ADDV $0xfff800000f000000, R4 // ADDV $-2251799562027008, R4 // 1e001e141e00001784f81000
ADDV $0xfff800000f000000, R4, R5 // ADDV $-2251799562027008, R4, R5 // 1e001e141e00001785f81000
AND $0xfff800000f000000, R4 // AND $-2251799562027008, R4 // 1e001e141e00001784f81400
AND $0xfff800000f000000, R4, R5 // AND $-2251799562027008, R4, R5 // 1e001e141e00001785f81400
// ADDV/AND C_DCON12_12S, [r1], r2
ADDV $0x273ffffffffff800, R4 // ADDV $2828260565988669440, R4 // 1e00e002decf090384f81000
ADDV $0x273ffffffffff800, R4, R5 // ADDV $2828260565988669440, R4, R5 // 1e00e002decf090385f81000
AND $0x273ffffffffff800, R4 // AND $2828260565988669440, R4 // 1e00e002decf090384f81400
AND $0x273ffffffffff800, R4, R5 // AND $2828260565988669440, R4, R5 // 1e00e002decf090385f81400
// ADDV/AND C_DCON20S_12S, [r1], r2
ADDV $0xfff80000fffff800, R4 // ADDV $-2251795518720000, R4 // 1e00a0021e00001784f81000
ADDV $0xfff80000fffff800, R4, R5 // ADDV $-2251795518720000, R4, R5 // 1e00a0021e00001785f81000
AND $0xfff80000fffff800, R4 // AND $-2251795518720000, R4 // 1e00a0021e00001784f81400
AND $0xfff80000fffff800, R4, R5 // AND $-2251795518720000, R4, R5 // 1e00a0021e00001785f81400
// ADDV/AND C_DCON20S_0, [r1], r2
ADDV $0xfff8000000000000, R4 // ADDV $-2251799813685248, R4 // 1e0080021e00001784f81000
ADDV $0xfff8000000000000, R4, R5 // ADDV $-2251799813685248, R4, R5 // 1e0080021e00001785f81000
AND $0xfff8000000000000, R4 // AND $-2251799813685248, R4 // 1e0080021e00001784f81400
AND $0xfff8000000000000, R4, R5 // AND $-2251799813685248, R4, R5 // 1e0080021e00001785f81400
// ADDV/AND C_DCON12_12U, [r1], r2
ADDV $0x2730000000000800, R4 // ADDV $2823756966361303040, R4 // 1e00a003decf090384f81000
ADDV $0x2730000000000800, R4, R5 // ADDV $2823756966361303040, R4, R5 // 1e00a003decf090385f81000
AND $0x2730000000000800, R4 // AND $2823756966361303040, R4 // 1e00a003decf090384f81400
AND $0x2730000000000800, R4, R5 // AND $2823756966361303040, R4, R5 // 1e00a003decf090385f81400
// ADDV/AND C_DCON20S_12U, [r1], r2
ADDV $0xfff8000000000800, R4 // ADDV $-2251799813683200, R4 // 1e00a0031e00001784f81000
ADDV $0xfff8000000000800, R4, R5 // ADDV $-2251799813683200, R4, R5 // 1e00a0031e00001785f81000
AND $0xfff8000000000800, R4 // AND $-2251799813683200, R4 // 1e00a0031e00001784f81400
AND $0xfff8000000000800, R4, R5 // AND $-2251799813683200, R4, R5 // 1e00a0031e00001785f81400

View File

@ -0,0 +1,42 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "../../../../../runtime/textflag.h"
TEXT asmtest(SB),DUPOK|NOSPLIT,$0
// ADDV/AND C_DCON32_12S, [r1], r2
ADDV $0x27312345fffff800, R4 // ADDV $2824077224892692480, R4 // 1e00a002be682416decf090384f81000
ADDV $0x27312345fffff800, R4, R5 // ADDV $2824077224892692480, R4, R5 // 1e00a002be682416decf090385f81000
AND $0x27312345fffff800, R4 // AND $2824077224892692480, R4 // 1e00a002be682416decf090384f81400
AND $0x27312345fffff800, R4, R5 // AND $2824077224892692480, R4, R5 // 1e00a002be682416decf090385f81400
// ADDV/AND C_DCON32_0, [r1], r2
ADDV $0x2731234500000000, R4 // ADDV $2824077220597727232, R4 // 1e008002be682416decf090384f81000
ADDV $0x2731234500000000, R4, R5 // ADDV $2824077220597727232, R4, R5 // 1e008002be682416decf090385f81000
AND $0x2731234500000000, R4 // AND $2824077220597727232, R4 // 1e008002be682416decf090384f81400
AND $0x2731234500000000, R4, R5 // AND $2824077220597727232, R4, R5 // 1e008002be682416decf090385f81400
// ADDV/AND C_DCON32_20, [r1], r2
ADDV $0x2731234512345000, R4 // ADDV $2824077220903145472, R4 // be682414be682416decf090384f81000
ADDV $0x2731234512345000, R4, R5 // ADDV $2824077220903145472, R4, R5 // be682414be682416decf090385f81000
AND $0x2731234512345000, R4 // AND $2824077220903145472, R4 // be682414be682416decf090384f81400
AND $0x2731234512345000, R4, R5 // AND $2824077220903145472, R4, R5 // be682414be682416decf090385f81400
// ADDV/AND C_DCON12_32S, [r1], r2
ADDV $0x273fffff80000800, R4 // ADDV $2828260563841189888, R4 // 1e000015de03a003decf090384f81000
ADDV $0x273fffff80000800, R4, R5 // ADDV $2828260563841189888, R4, R5 // 1e000015de03a003decf090385f81000
AND $0x273fffff80000800, R4 // AND $2828260563841189888, R4 // 1e000015de03a003decf090384f81400
AND $0x273fffff80000800, R4, R5 // AND $2828260563841189888, R4, R5 // 1e000015de03a003decf090385f81400
// ADDV/AND C_DCON20S_32, [r1], r2
ADDV $0xfff8000080000800, R4 // ADDV $-2251797666199552, R4 // 1e000015de03a0031e00001784f81000
ADDV $0xfff8000080000800, R4, R5 // ADDV $-2251797666199552, R4, R5 // 1e000015de03a0031e00001785f81000
AND $0xfff8000080000800, R4 // AND $-2251797666199552, R4 // 1e000015de03a0031e00001784f81400
AND $0xfff8000080000800, R4, R5 // AND $-2251797666199552, R4, R5 // 1e000015de03a0031e00001785f81400
// ADDV/AND C_DCON32_12U, [r1], r2
ADDV $0x2731234500000800, R4 // ADDV $2824077220597729280, R4 // 1e00a003be682416decf090384f81000
ADDV $0x2731234500000800, R4, R5 // ADDV $2824077220597729280, R4, R5 // 1e00a003be682416decf090385f81000
AND $0x2731234500000800, R4 // AND $2824077220597729280, R4 // 1e00a003be682416decf090384f81400
AND $0x2731234500000800, R4, R5 // AND $2824077220597729280, R4, R5 // 1e00a003be682416decf090385f81400

View File

@ -0,0 +1,17 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "../../../../../runtime/textflag.h"
TEXT asmtest(SB),DUPOK|NOSPLIT,$0
// ADDV/AND C_DCON, [r1], r2
ADDV $0xfedcba9876543210, R4 // ADDV $-81985529216486896, R4 // 7ea8ec14de4388031e539717deb73f0384f81000
ADDV $0xfedcba9876543210, R5, R4 // ADDV $-81985529216486896, R5, R4 // 7ea8ec14de4388031e539717deb73f03a4f81000
ADDV $0x4edcba9876543210, R4 // ADDV $5682621993817747984, R4 // 7ea8ec14de4388031e539717deb7130384f81000
ADDV $0x4edcba9876543210, R5, R4 // ADDV $5682621993817747984, R5, R4 // 7ea8ec14de4388031e539717deb71303a4f81000
AND $0x4edcba9876543210, R4 // AND $5682621993817747984, R4 // 7ea8ec14de4388031e539717deb7130384f81400
AND $0x4edcba9876543210, R5, R4 // AND $5682621993817747984, R5, R4 // 7ea8ec14de4388031e539717deb71303a4f81400
AND $0xfedcba9876543210, R4 // AND $-81985529216486896, R4 // 7ea8ec14de4388031e539717deb73f0384f81400
AND $0xfedcba9876543210, R5, R4 // AND $-81985529216486896, R5, R4 // 7ea8ec14de4388031e539717deb73f03a4f81400

View File

@ -0,0 +1,7 @@
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
TEXT errors(SB),$0
VSHUF4IV $16, V1, V2 // ERROR "operand out of range 0 to 15"
XVSHUF4IV $16, X1, X2 // ERROR "operand out of range 0 to 15"

View File

@ -363,6 +363,10 @@ start:
SLLIUW $63, X17, X18 // 1b99f80b
SLLIUW $1, X18, X19 // 9b191908
//
// "B" Extension for Bit Manipulation, Version 1.0.0
//
// 28.4.2: Basic Bit Manipulation (Zbb)
ANDN X19, X20, X21 // b37a3a41 or 93caf9ffb37a5a01
ANDN X19, X20 // 337a3a41 or 93cff9ff337afa01
@ -372,14 +376,14 @@ start:
CPOPW X23, X24 // 1b9c2b60
CTZ X24, X25 // 931c1c60
CTZW X25, X26 // 1b9d1c60
MAX X26, X28, X29 // b36eae0b
MAX X26, X28 // 336eae0b
MAXU X28, X29, X30 // 33ffce0b
MAXU X28, X29 // b3fece0b
MIN X29, X30, X5 // b342df0b
MIN X29, X30 // 334fdf0b
MINU X30, X5, X6 // 33d3e20b
MINU X30, X5 // b3d2e20b
MAX X26, X28, X29 // b36eae0b or b32fae01b30ff041b34eae01b3fedf01b34ede01
MAX X26, X28 // 336eae0b or b32fcd01b30ff041334ecd0133fecf01334ecd01
MAXU X28, X29, X30 // 33ffce0b or b3bfce01b30ff04133cfce0133ffef0133cfee01
MAXU X28, X29 // b3fece0b or b33fde01b30ff041b34ede01b3fedf01b34ede01
MIN X29, X30, X5 // b342df0b or b3afee01b30ff041b342df01b3f25f00b3425f00
MIN X29, X30 // 334fdf0b or b32fdf01b30ff04133cfee0133ffef0133cfee01
MINU X30, X5, X6 // 33d3e20b or b33f5f00b30ff04133c3e20133f36f0033c36200
MINU X30, X5 // b3d2e20b or b3bfe201b30ff041b3425f00b3f25f00b3425f00
ORN X6, X7, X8 // 33e46340 or 1344f3ff33e48300
ORN X6, X7 // b3e36340 or 934ff3ffb3e3f301
SEXTB X16, X17 // 93184860
@ -420,6 +424,856 @@ start:
BSET $63, X9 // 9394f42b
BSETI $1, X10, X11 // 93151528
//
// "V" Standard Extension for Vector Operations, Version 1.0
//
// 31.6: Configuration Setting Instructions
VSETVLI X10, E8, M1, TU, MU, X12 // 57760500
VSETVLI X10, E16, M1, TU, MU, X12 // 57768500
VSETVLI X10, E32, M1, TU, MU, X12 // 57760501
VSETVLI X10, E64, M1, TU, MU, X12 // 57768501
VSETVLI X10, E32, M1, TU, MA, X12 // 57760509
VSETVLI X10, E32, M1, TA, MA, X12 // 5776050d
VSETVLI X10, E32, M2, TA, MA, X12 // 5776150d
VSETVLI X10, E32, M4, TA, MA, X12 // 5776250d
VSETVLI X10, E32, M8, TA, MA, X12 // 5776350d
VSETVLI X10, E32, MF2, TA, MA, X12 // 5776550d
VSETVLI X10, E32, MF4, TA, MA, X12 // 5776650d
VSETVLI X10, E32, MF8, TA, MA, X12 // 5776750d
VSETVLI X10, E32, M1, TA, MA, X12 // 5776050d
VSETVLI $15, E32, M1, TA, MA, X12 // 57f607cd
VSETIVLI $0, E32, M1, TA, MA, X12 // 577600cd
VSETIVLI $15, E32, M1, TA, MA, X12 // 57f607cd
VSETIVLI $31, E32, M1, TA, MA, X12 // 57f60fcd
VSETVL X10, X11, X12 // 57f6a580
// 31.7.4: Vector Unit-Stride Instructions
VLE8V (X10), V3 // 87010502
VLE8V (X10), V0, V3 // 87010500
VLE16V (X10), V3 // 87510502
VLE16V (X10), V0, V3 // 87510500
VLE32V (X10), V3 // 87610502
VLE32V (X10), V0, V3 // 87610500
VLE64V (X10), V3 // 87710502
VLE64V (X10), V0, V3 // 87710500
VSE8V V3, (X10) // a7010502
VSE8V V3, V0, (X10) // a7010500
VSE16V V3, (X10) // a7510502
VSE16V V3, V0, (X10) // a7510500
VSE32V V3, (X10) // a7610502
VSE32V V3, V0, (X10) // a7610500
VSE64V V3, (X10) // a7710502
VSE64V V3, V0, (X10) // a7710500
VLMV (X10), V3 // 8701b502
VSMV V3, (X10) // a701b502
// 31.7.5: Vector Strided Instructions
VLSE8V (X10), X11, V3 // 8701b50a
VLSE8V (X10), X11, V0, V3 // 8701b508
VLSE16V (X10), X11, V3 // 8751b50a
VLSE16V (X10), X11, V0, V3 // 8751b508
VLSE32V (X10), X11, V3 // 8761b50a
VLSE32V (X10), X11, V0, V3 // 8761b508
VLSE64V (X10), X11, V3 // 8771b50a
VLSE64V (X10), X11, V0, V3 // 8771b508
VSSE8V V3, X11, (X10) // a701b50a
VSSE8V V3, X11, V0, (X10) // a701b508
VSSE16V V3, X11, (X10) // a751b50a
VSSE16V V3, X11, V0, (X10) // a751b508
VSSE32V V3, X11, (X10) // a761b50a
VSSE32V V3, X11, V0, (X10) // a761b508
VSSE64V V3, X11, (X10) // a771b50a
VSSE64V V3, X11, V0, (X10) // a771b508
// 31.7.6: Vector Indexed Instructions
VLUXEI8V (X10), V2, V3 // 87012506
VLUXEI8V (X10), V2, V0, V3 // 87012504
VLUXEI16V (X10), V2, V3 // 87512506
VLUXEI16V (X10), V2, V0, V3 // 87512504
VLUXEI32V (X10), V2, V3 // 87612506
VLUXEI32V (X10), V2, V0, V3 // 87612504
VLUXEI64V (X10), V2, V3 // 87712506
VLUXEI64V (X10), V2, V0, V3 // 87712504
VLOXEI8V (X10), V2, V3 // 8701250e
VLOXEI8V (X10), V2, V0, V3 // 8701250c
VLOXEI16V (X10), V2, V3 // 8751250e
VLOXEI16V (X10), V2, V0, V3 // 8751250c
VLOXEI32V (X10), V2, V3 // 8761250e
VLOXEI32V (X10), V2, V0, V3 // 8761250c
VLOXEI64V (X10), V2, V3 // 8771250e
VLOXEI64V (X10), V2, V0, V3 // 8771250c
VSUXEI8V V3, V2, (X10) // a7012506
VSUXEI8V V3, V2, V0, (X10) // a7012504
VSUXEI16V V3, V2, (X10) // a7512506
VSUXEI16V V3, V2, V0, (X10) // a7512504
VSUXEI32V V3, V2, (X10) // a7612506
VSUXEI32V V3, V2, V0, (X10) // a7612504
VSUXEI64V V3, V2, (X10) // a7712506
VSUXEI64V V3, V2, V0, (X10) // a7712504
VSOXEI8V V3, V2, (X10) // a701250e
VSOXEI8V V3, V2, V0, (X10) // a701250c
VSOXEI16V V3, V2, (X10) // a751250e
VSOXEI16V V3, V2, V0, (X10) // a751250c
VSOXEI32V V3, V2, (X10) // a761250e
VSOXEI32V V3, V2, V0, (X10) // a761250c
VSOXEI64V V3, V2, (X10) // a771250e
VSOXEI64V V3, V2, V0, (X10) // a771250c
// 31.7.9: Vector Load/Store Whole Register Instructions
VL1RV (X10), V3 // 87018502
VL1RE8V (X10), V3 // 87018502
VL1RE16V (X10), V3 // 87518502
VL1RE32V (X10), V3 // 87618502
VL1RE64V (X10), V3 // 87718502
VL2RV (X10), V2 // 07018522
VL2RE8V (X10), V2 // 07018522
VL2RE16V (X10), V2 // 07518522
VL2RE32V (X10), V2 // 07618522
VL2RE64V (X10), V2 // 07718522
VL4RV (X10), V4 // 07028562
VL4RE8V (X10), V4 // 07028562
VL4RE16V (X10), V4 // 07528562
VL4RE32V (X10), V4 // 07628562
VL4RE64V (X10), V4 // 07728562
VL8RV (X10), V8 // 070485e2
VL8RE8V (X10), V8 // 070485e2
VL8RE16V (X10), V8 // 075485e2
VL8RE32V (X10), V8 // 076485e2
VL8RE64V (X10), V8 // 077485e2
VS1RV V3, (X11) // a7818502
VS2RV V2, (X11) // 27818522
VS4RV V4, (X11) // 27828562
VS8RV V8, (X11) // 278485e2
// 31.11.1: Vector Single-Width Integer Add and Subtract
VADDVV V1, V2, V3 // d7812002
VADDVV V1, V2, V0, V3 // d7812000
VADDVX X10, V2, V3 // d7412502
VADDVX X10, V2, V0, V3 // d7412500
VADDVI $15, V2, V3 // d7b12702
VADDVI $15, V2, V0, V3 // d7b12700
VADDVI $-16, V2, V3 // d7312802
VADDVI $-16, V2, V0, V3 // d7312800
VSUBVV V1, V2, V3 // d781200a
VSUBVV V1, V2, V0, V3 // d7812008
VSUBVX X10, V2, V3 // d741250a
VSUBVX X10, V2, V0, V3 // d7412508
VRSUBVX X10, V2, V3 // d741250e
VRSUBVX X10, V2, V0, V3 // d741250c
VRSUBVI $15, V2, V0, V3 // d7b1270c
VRSUBVI $-16, V2, V0, V3 // d731280c
VNEGV V2, V3 // d741200e
VNEGV V2, V0, V3 // d741200c
// 31.11.2: Vector Widening Integer Add/Subtract
VWADDUVV V1, V2, V3 // d7a120c2
VWADDUVV V1, V2, V0, V3 // d7a120c0
VWADDUVX X10, V2, V3 // d76125c2
VWADDUVX X10, V2, V0, V3 // d76125c0
VWSUBUVV V1, V2, V3 // d7a120ca
VWSUBUVV V1, V2, V0, V3 // d7a120c8
VWSUBUVX X10, V2, V3 // d76125ca
VWSUBUVX X10, V2, V0, V3 // d76125c8
VWADDVV V1, V2, V3 // d7a120c6
VWADDVV V1, V2, V0, V3 // d7a120c4
VWADDVX X10, V2, V3 // d76125c6
VWADDVX X10, V2, V0, V3 // d76125c4
VWSUBVV V1, V2, V3 // d7a120ce
VWSUBVV V1, V2, V0, V3 // d7a120cc
VWSUBVX X10, V2, V3 // d76125ce
VWSUBVX X10, V2, V0, V3 // d76125cc
VWADDUWV V1, V2, V3 // d7a120d2
VWADDUWV V1, V2, V0, V3 // d7a120d0
VWADDUWX X10, V2, V3 // d76125d2
VWADDUWX X10, V2, V0, V3 // d76125d0
VWSUBUWV V1, V2, V3 // d7a120da
VWSUBUWV V1, V2, V0, V3 // d7a120d8
VWSUBUWX X10, V2, V3 // d76125da
VWSUBUWX X10, V2, V0, V3 // d76125d8
VWADDWV V1, V2, V3 // d7a120d6
VWADDWV V1, V2, V0, V3 // d7a120d4
VWADDWX X10, V2, V3 // d76125d6
VWADDWX X10, V2, V0, V3 // d76125d4
VWSUBWV V1, V2, V3 // d7a120de
VWSUBWV V1, V2, V0, V3 // d7a120dc
VWSUBWX X10, V2, V3 // d76125de
VWSUBWX X10, V2, V0, V3 // d76125dc
VWCVTXXV V2, V3 // d76120c6
VWCVTXXV V2, V0, V3 // d76120c4
VWCVTUXXV V2, V3 // d76120c2
VWCVTUXXV V2, V0, V3 // d76120c0
// 31.11.3: Vector Integer Extension
VZEXTVF2 V2, V3 // d721234a
VZEXTVF2 V2, V0, V3 // d7212348
VSEXTVF2 V2, V3 // d7a1234a
VSEXTVF2 V2, V0, V3 // d7a12348
VZEXTVF4 V2, V3 // d721224a
VZEXTVF4 V2, V0, V3 // d7212248
VSEXTVF4 V2, V3 // d7a1224a
VSEXTVF4 V2, V0, V3 // d7a12248
VZEXTVF8 V2, V3 // d721214a
VZEXTVF8 V2, V0, V3 // d7212148
VSEXTVF8 V2, V3 // d7a1214a
VSEXTVF8 V2, V0, V3 // d7a12148
// 31.11.4: Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions
VADCVVM V1, V2, V0, V3 // d7812040
VADCVXM X11, V2, V0, V3 // d7c12540
VADCVIM $15, V2, V0, V3 // d7b12740
VMADCVVM V1, V2, V0, V3 // d7812044
VMADCVXM X11, V2, V0, V3 // d7c12544
VMADCVIM $15, V2, V0, V3 // d7b12744
VMADCVV V1, V2, V3 // d7812046
VMADCVX X11, V2, V3 // d7c12546
VMADCVI $15, V2, V3 // d7b12746
VSBCVVM V1, V2, V0, V3 // d7812048
VSBCVXM X11, V2, V0, V3 // d7c12548
VMSBCVVM V1, V2, V0, V3 // d781204c
VMSBCVXM X11, V2, V0, V3 // d7c1254c
VMSBCVV V1, V2, V3 // d781204e
VMSBCVX X11, V2, V3 // d7c1254e
// 31.11.5: Vector Bitwise Logical Instructions
VANDVV V1, V2, V3 // d7812026
VANDVV V1, V2, V0, V3 // d7812024
VANDVX X11, V2, V3 // d7c12526
VANDVX X11, V2, V0, V3 // d7c12524
VANDVI $15, V2, V3 // d7b12726
VANDVI $15, V2, V0, V3 // d7b12724
VORVV V1, V2, V3 // d781202a
VORVV V1, V2, V0, V3 // d7812028
VORVX X11, V2, V3 // d7c1252a
VORVX X11, V2, V0, V3 // d7c12528
VORVI $15, V2, V3 // d7b1272a
VORVI $15, V2, V0, V3 // d7b12728
VXORVV V1, V2, V3 // d781202e
VXORVV V1, V2, V0, V3 // d781202c
VXORVX X11, V2, V3 // d7c1252e
VXORVX X11, V2, V0, V3 // d7c1252c
VXORVI $15, V2, V3 // d7b1272e
VXORVI $15, V2, V0, V3 // d7b1272c
VNOTV V2, V3 // d7b12f2e
VNOTV V2, V0, V3 // d7b12f2c
// 31.11.6: Vector Single-Width Shift Instructions
VSLLVV V1, V2, V3 // d7812096
VSLLVV V1, V2, V0, V3 // d7812094
VSLLVX X11, V2, V3 // d7c12596
VSLLVX X11, V2, V0, V3 // d7c12594
VSLLVI $15, V2, V3 // d7b12796
VSLLVI $15, V2, V0, V3 // d7b12794
VSRLVV V1, V2, V3 // d78120a2
VSRLVV V1, V2, V0, V3 // d78120a0
VSRLVX X11, V2, V3 // d7c125a2
VSRLVX X11, V2, V0, V3 // d7c125a0
VSRLVI $15, V2, V3 // d7b127a2
VSRLVI $15, V2, V0, V3 // d7b127a0
VSRAVV V1, V2, V3 // d78120a6
VSRAVV V1, V2, V0, V3 // d78120a4
VSRAVX X11, V2, V3 // d7c125a6
VSRAVX X11, V2, V0, V3 // d7c125a4
VSRAVI $15, V2, V3 // d7b127a6
VSRAVI $15, V2, V0, V3 // d7b127a4
// 31.11.7: Vector Narrowing Integer Right Shift Instructions
VNSRLWV V1, V2, V3 // d78120b2
VNSRLWV V1, V2, V0, V3 // d78120b0
VNSRLWX X10, V2, V3 // d74125b2
VNSRLWX X10, V2, V0, V3 // d74125b0
VNSRLWI $31, V2, V3 // d7b12fb2
VNSRLWI $31, V2, V0, V3 // d7b12fb0
VNSRAWV V1, V2, V3 // d78120b6
VNSRAWV V1, V2, V0, V3 // d78120b4
VNSRAWX X10, V2, V3 // d74125b6
VNSRAWX X10, V2, V0, V3 // d74125b4
VNSRAWI $31, V2, V3 // d7b12fb6
VNSRAWI $31, V2, V0, V3 // d7b12fb4
VNCVTXXW V2, V3 // d74120b2
VNCVTXXW V2, V0, V3 // d74120b0
// 31.11.8: Vector Integer Compare Instructions
VMSEQVV V1, V2, V3 // d7812062
VMSEQVV V1, V2, V0, V3 // d7812060
VMSEQVX X10, V2, V3 // d7412562
VMSEQVX X10, V2, V0, V3 // d7412560
VMSEQVI $15, V2, V3 // d7b12762
VMSEQVI $15, V2, V0, V3 // d7b12760
VMSNEVV V1, V2, V3 // d7812066
VMSNEVV V1, V2, V0, V3 // d7812064
VMSNEVX X10, V2, V3 // d7412566
VMSNEVX X10, V2, V0, V3 // d7412564
VMSNEVI $15, V2, V3 // d7b12766
VMSNEVI $15, V2, V0, V3 // d7b12764
VMSLTUVV V1, V2, V3 // d781206a
VMSLTUVV V1, V2, V0, V3 // d7812068
VMSLTUVX X10, V2, V3 // d741256a
VMSLTUVX X10, V2, V0, V3 // d7412568
VMSLTVV V1, V2, V3 // d781206e
VMSLTVV V1, V2, V0, V3 // d781206c
VMSLTVX X10, V2, V3 // d741256e
VMSLTVX X10, V2, V0, V3 // d741256c
VMSLEUVV V1, V2, V3 // d7812072
VMSLEUVV V1, V2, V0, V3 // d7812070
VMSLEUVX X10, V2, V3 // d7412572
VMSLEUVX X10, V2, V0, V3 // d7412570
VMSLEUVI $15, V2, V3 // d7b12772
VMSLEUVI $15, V2, V0, V3 // d7b12770
VMSLEVV V1, V2, V3 // d7812076
VMSLEVV V1, V2, V0, V3 // d7812074
VMSLEVX X10, V2, V3 // d7412576
VMSLEVX X10, V2, V0, V3 // d7412574
VMSLEVI $15, V2, V3 // d7b12776
VMSLEVI $15, V2, V0, V3 // d7b12774
VMSGTUVX X10, V2, V3 // d741257a
VMSGTUVX X10, V2, V0, V3 // d7412578
VMSGTUVI $15, V2, V3 // d7b1277a
VMSGTUVI $15, V2, V0, V3 // d7b12778
VMSGTVX X10, V2, V3 // d741257e
VMSGTVX X10, V2, V0, V3 // d741257c
VMSGTVI $15, V2, V3 // d7b1277e
VMSGTVI $15, V2, V0, V3 // d7b1277c
VMSGTVV V1, V2, V3 // d701116e
VMSGTVV V1, V2, V0, V3 // d701116c
VMSGTUVV V1, V2, V3 // d701116a
VMSGTUVV V1, V2, V0, V3 // d7011168
VMSGEVV V1, V2, V3 // d7011176
VMSGEVV V1, V2, V0, V3 // d7011174
VMSGEUVV V1, V2, V3 // d7011172
VMSGEUVV V1, V2, V0, V3 // d7011170
VMSLTVI $15, V2, V3 // d7312776
VMSLTVI $15, V2, V0, V3 // d7312774
VMSLTUVI $15, V2, V3 // d7312772
VMSLTUVI $15, V2, V0, V3 // d7312770
VMSGEVI $15, V2, V3 // d731277e
VMSGEVI $15, V2, V0, V3 // d731277c
VMSGEUVI $15, V2, V3 // d731277a
VMSGEUVI $15, V2, V0, V3 // d7312778
// 31.11.9: Vector Integer Min/Max Instructions
VMINUVV V1, V2, V3 // d7812012
VMINUVV V1, V2, V0, V3 // d7812010
VMINUVX X10, V2, V3 // d7412512
VMINUVX X10, V2, V0, V3 // d7412510
VMINVV V1, V2, V3 // d7812016
VMINVV V1, V2, V0, V3 // d7812014
VMINVX X10, V2, V3 // d7412516
VMINVX X10, V2, V0, V3 // d7412514
VMAXUVV V1, V2, V3 // d781201a
VMAXUVV V1, V2, V0, V3 // d7812018
VMAXUVX X10, V2, V3 // d741251a
VMAXUVX X10, V2, V0, V3 // d7412518
VMAXVV V1, V2, V3 // d781201e
VMAXVV V1, V2, V0, V3 // d781201c
VMAXVX X10, V2, V3 // d741251e
VMAXVX X10, V2, V0, V3 // d741251c
// 31.11.10: Vector Single-Width Integer Multiply Instructions
VMULVV V1, V2, V3 // d7a12096
VMULVV V1, V2, V0, V3 // d7a12094
VMULVX X10, V2, V3 // d7612596
VMULVX X10, V2, V0, V3 // d7612594
VMULHVV V1, V2, V3 // d7a1209e
VMULHVV V1, V2, V0, V3 // d7a1209c
VMULHVX X10, V2, V3 // d761259e
VMULHVX X10, V2, V0, V3 // d761259c
VMULHUVV V1, V2, V3 // d7a12092
VMULHUVV V1, V2, V0, V3 // d7a12090
VMULHUVX X10, V2, V3 // d7612592
VMULHUVX X10, V2, V0, V3 // d7612590
VMULHSUVV V1, V2, V3 // d7a1209a
VMULHSUVV V1, V2, V0, V3 // d7a12098
VMULHSUVX X10, V2, V3 // d761259a
VMULHSUVX X10, V2, V0, V3 // d7612598
// 31.11.11: Vector Integer Divide Instructions
VDIVUVV V1, V2, V3 // d7a12082
VDIVUVV V1, V2, V0, V3 // d7a12080
VDIVUVX X10, V2, V3 // d7612582
VDIVUVX X10, V2, V0, V3 // d7612580
VDIVVV V1, V2, V3 // d7a12086
VDIVVV V1, V2, V0, V3 // d7a12084
VDIVVX X10, V2, V3 // d7612586
VDIVVX X10, V2, V0, V3 // d7612584
VREMUVV V1, V2, V3 // d7a1208a
VREMUVV V1, V2, V0, V3 // d7a12088
VREMUVX X10, V2, V3 // d761258a
VREMUVX X10, V2, V0, V3 // d7612588
VREMVV V1, V2, V3 // d7a1208e
VREMVV V1, V2, V0, V3 // d7a1208c
VREMVX X10, V2, V3 // d761258e
VREMVX X10, V2, V0, V3 // d761258c
// 31.11.12: Vector Widening Integer Multiply Instructions
VWMULVV V1, V2, V3 // d7a120ee
VWMULVV V1, V2, V0, V3 // d7a120ec
VWMULVX X10, V2, V3 // d76125ee
VWMULVX X10, V2, V0, V3 // d76125ec
VWMULUVV V1, V2, V3 // d7a120e2
VWMULUVV V1, V2, V0, V3 // d7a120e0
VWMULUVX X10, V2, V3 // d76125e2
VWMULUVX X10, V2, V0, V3 // d76125e0
VWMULSUVV V1, V2, V3 // d7a120ea
VWMULSUVV V1, V2, V0, V3 // d7a120e8
VWMULSUVX X10, V2, V3 // d76125ea
VWMULSUVX X10, V2, V0, V3 // d76125e8
// 31.11.13: Vector Single-Width Integer Multiply-Add Instructions
VMACCVV V1, V2, V3 // d7a120b6
VMACCVV V1, V2, V0, V3 // d7a120b4
VMACCVX X10, V2, V3 // d76125b6
VMACCVX X10, V2, V0, V3 // d76125b4
VNMSACVV V1, V2, V3 // d7a120be
VNMSACVV V1, V2, V0, V3 // d7a120bc
VNMSACVX X10, V2, V3 // d76125be
VNMSACVX X10, V2, V0, V3 // d76125bc
VMADDVV V1, V2, V3 // d7a120a6
VMADDVV V1, V2, V0, V3 // d7a120a4
VMADDVX X10, V2, V3 // d76125a6
VMADDVX X10, V2, V0, V3 // d76125a4
VNMSUBVV V1, V2, V3 // d7a120ae
VNMSUBVV V1, V2, V0, V3 // d7a120ac
VNMSUBVX X10, V2, V3 // d76125ae
VNMSUBVX X10, V2, V0, V3 // d76125ac
// 31.11.14: Vector Widening Integer Multiply-Add Instructions
VWMACCUVV V1, V2, V3 // d7a120f2
VWMACCUVV V1, V2, V0, V3 // d7a120f0
VWMACCUVX X10, V2, V3 // d76125f2
VWMACCUVX X10, V2, V0, V3 // d76125f0
VWMACCVV V1, V2, V3 // d7a120f6
VWMACCVV V1, V2, V0, V3 // d7a120f4
VWMACCVX X10, V2, V3 // d76125f6
VWMACCVX X10, V2, V0, V3 // d76125f4
VWMACCSUVV V1, V2, V3 // d7a120fe
VWMACCSUVV V1, V2, V0, V3 // d7a120fc
VWMACCSUVX X10, V2, V3 // d76125fe
VWMACCSUVX X10, V2, V0, V3 // d76125fc
VWMACCUSVX X10, V2, V3 // d76125fa
VWMACCUSVX X10, V2, V0, V3 // d76125f8
// 31.11.15: Vector Integer Merge Instructions
VMERGEVVM V1, V2, V0, V3 // d781205c
VMERGEVXM X10, V2, V0, V3 // d741255c
VMERGEVIM $15, V2, V0, V3 // d7b1275c
// 31.11.16: Vector Integer Move Instructions
VMVVV V2, V3 // d701015e
VMVVX X10, V3 // d741055e
VMVVI $15, V3 // d7b1075e
// 31.12.1: Vector Single-Width Saturating Add and Subtract
VSADDUVV V1, V2, V3 // d7812082
VSADDUVV V1, V2, V0, V3 // d7812080
VSADDUVX X10, V2, V3 // d7412582
VSADDUVX X10, V2, V0, V3 // d7412580
VSADDUVI $15, V2, V3 // d7b12782
VSADDUVI $15, V2, V0, V3 // d7b12780
VSADDVV V1, V2, V3 // d7812086
VSADDVV V1, V2, V0, V3 // d7812084
VSADDVX X10, V2, V3 // d7412586
VSADDVX X10, V2, V0, V3 // d7412584
VSADDVI $15, V2, V3 // d7b12786
VSADDVI $15, V2, V0, V3 // d7b12784
VSSUBUVV V1, V2, V3 // d781208a
VSSUBUVV V1, V2, V0, V3 // d7812088
VSSUBUVX X10, V2, V3 // d741258a
VSSUBUVX X10, V2, V0, V3 // d7412588
VSSUBVV V1, V2, V3 // d781208e
VSSUBVV V1, V2, V0, V3 // d781208c
VSSUBVX X10, V2, V3 // d741258e
VSSUBVX X10, V2, V0, V3 // d741258c
// 31.12.2: Vector Single-Width Averaging Add and Subtract
VAADDUVV V1, V2, V3 // d7a12022
VAADDUVV V1, V2, V0, V3 // d7a12020
VAADDUVX X10, V2, V3 // d7612522
VAADDUVX X10, V2, V0, V3 // d7612520
VAADDVV V1, V2, V3 // d7a12026
VAADDVV V1, V2, V0, V3 // d7a12024
VAADDVX X10, V2, V3 // d7612526
VAADDVX X10, V2, V0, V3 // d7612524
VASUBUVV V1, V2, V3 // d7a1202a
VASUBUVV V1, V2, V0, V3 // d7a12028
VASUBUVX X10, V2, V3 // d761252a
VASUBUVX X10, V2, V0, V3 // d7612528
VASUBVV V1, V2, V3 // d7a1202e
VASUBVV V1, V2, V0, V3 // d7a1202c
VASUBVX X10, V2, V3 // d761252e
VASUBVX X10, V2, V0, V3 // d761252c
// 31.12.3: Vector Single-Width Fractional Multiply with Rounding and Saturation
VSMULVV V1, V2, V3 // d781209e
VSMULVV V1, V2, V0, V3 // d781209c
VSMULVX X10, V2, V3 // d741259e
VSMULVX X10, V2, V0, V3 // d741259c
// 31.12.4: Vector Single-Width Scaling Shift Instructions
VSSRLVV V1, V2, V3 // d78120aa
VSSRLVV V1, V2, V0, V3 // d78120a8
VSSRLVX X10, V2, V3 // d74125aa
VSSRLVX X10, V2, V0, V3 // d74125a8
VSSRLVI $15, V2, V3 // d7b127aa
VSSRLVI $15, V2, V0, V3 // d7b127a8
VSSRAVV V1, V2, V3 // d78120ae
VSSRAVV V1, V2, V0, V3 // d78120ac
VSSRAVX X10, V2, V3 // d74125ae
VSSRAVX X10, V2, V0, V3 // d74125ac
VSSRAVI $16, V2, V3 // d73128ae
VSSRAVI $16, V2, V0, V3 // d73128ac
// 31.12.5: Vector Narrowing Fixed-Point Clip Instructions
VNCLIPUWV V1, V2, V3 // d78120ba
VNCLIPUWV V1, V2, V0, V3 // d78120b8
VNCLIPUWX X10, V2, V3 // d74125ba
VNCLIPUWX X10, V2, V0, V3 // d74125b8
VNCLIPUWI $16, V2, V3 // d73128ba
VNCLIPUWI $16, V2, V0, V3 // d73128b8
VNCLIPWV V1, V2, V3 // d78120be
VNCLIPWV V1, V2, V0, V3 // d78120bc
VNCLIPWX X10, V2, V3 // d74125be
VNCLIPWX X10, V2, V0, V3 // d74125bc
VNCLIPWI $16, V2, V3 // d73128be
VNCLIPWI $16, V2, V0, V3 // d73128bc
// 31.13.2: Vector Single-Width Floating-Point Add/Subtract Instructions
VFADDVV V1, V2, V3 // d7912002
VFADDVV V1, V2, V0, V3 // d7912000
VFADDVF F10, V2, V3 // d7512502
VFADDVF F10, V2, V0, V3 // d7512500
VFSUBVV V1, V2, V3 // d791200a
VFSUBVV V1, V2, V0, V3 // d7912008
VFSUBVF F10, V2, V3 // d751250a
VFSUBVF F10, V2, V0, V3 // d7512508
VFRSUBVF F10, V2, V3 // d751259e
VFRSUBVF F10, V2, V0, V3 // d751259c
// 31.13.3: Vector Widening Floating-Point Add/Subtract Instructions
VFWADDVV V1, V2, V3 // d79120c2
VFWADDVV V1, V2, V0, V3 // d79120c0
VFWADDVF F10, V2, V3 // d75125c2
VFWADDVF F10, V2, V0, V3 // d75125c0
VFWSUBVV V1, V2, V3 // d79120ca
VFWSUBVV V1, V2, V0, V3 // d79120c8
VFWSUBVF F10, V2, V3 // d75125ca
VFWSUBVF F10, V2, V0, V3 // d75125c8
VFWADDWV V1, V2, V3 // d79120d2
VFWADDWV V1, V2, V0, V3 // d79120d0
VFWADDWF F10, V2, V3 // d75125d2
VFWADDWF F10, V2, V0, V3 // d75125d0
VFWSUBWV V1, V2, V3 // d79120da
VFWSUBWV V1, V2, V0, V3 // d79120d8
VFWSUBWF F10, V2, V3 // d75125da
VFWSUBWF F10, V2, V0, V3 // d75125d8
// 31.13.4: Vector Single-Width Floating-Point Multiply/Divide Instructions
VFMULVV V1, V2, V3 // d7912092
VFMULVV V1, V2, V0, V3 // d7912090
VFMULVF F10, V2, V3 // d7512592
VFMULVF F10, V2, V0, V3 // d7512590
VFDIVVV V1, V2, V3 // d7912082
VFDIVVV V1, V2, V0, V3 // d7912080
VFDIVVF F10, V2, V3 // d7512582
VFDIVVF F10, V2, V0, V3 // d7512580
VFRDIVVF F10, V2, V3 // d7512586
VFRDIVVF F10, V2, V0, V3 // d7512584
// 31.13.5: Vector Widening Floating-Point Multiply
VFWMULVV V1, V2, V3 // d79120e2
VFWMULVV V1, V2, V0, V3 // d79120e0
VFWMULVF F10, V2, V3 // d75125e2
VFWMULVF F10, V2, V0, V3 // d75125e0
// 31.13.6: Vector Single-Width Floating-Point Fused Multiply-Add Instructions
VFMACCVV V2, V1, V3 // d79120b2
VFMACCVV V2, V1, V0, V3 // d79120b0
VFMACCVF V2, F10, V3 // d75125b2
VFMACCVF V2, F10, V0, V3 // d75125b0
VFNMACCVV V2, V1, V3 // d79120b6
VFNMACCVV V2, V1, V0, V3 // d79120b4
VFNMACCVF V2, F10, V3 // d75125b6
VFNMACCVF V2, F10, V0, V3 // d75125b4
VFMSACVV V2, V1, V3 // d79120ba
VFMSACVV V2, V1, V0, V3 // d79120b8
VFMSACVF V2, F10, V3 // d75125ba
VFMSACVF V2, F10, V0, V3 // d75125b8
VFNMSACVV V2, V1, V3 // d79120be
VFNMSACVV V2, V1, V0, V3 // d79120bc
VFNMSACVF V2, F10, V3 // d75125be
VFNMSACVF V2, F10, V0, V3 // d75125bc
VFMADDVV V2, V1, V3 // d79120a2
VFMADDVV V2, V1, V0, V3 // d79120a0
VFMADDVF V2, F10, V3 // d75125a2
VFMADDVF V2, F10, V0, V3 // d75125a0
VFNMADDVV V2, V1, V3 // d79120a6
VFNMADDVV V2, V1, V0, V3 // d79120a4
VFNMADDVF V2, F10, V3 // d75125a6
VFNMADDVF V2, F10, V0, V3 // d75125a4
VFMSUBVV V2, V1, V3 // d79120aa
VFMSUBVV V2, V1, V0, V3 // d79120a8
VFMSUBVF V2, F10, V3 // d75125aa
VFMSUBVF V2, F10, V0, V3 // d75125a8
VFNMSUBVV V2, V1, V3 // d79120ae
VFNMSUBVV V2, V1, V0, V3 // d79120ac
VFNMSUBVF V2, F10, V3 // d75125ae
VFNMSUBVF V2, F10, V0, V3 // d75125ac
// 31.13.7: Vector Widening Floating-Point Fused Multiply-Add Instructions
VFWMACCVV V2, V1, V3 // d79120f2
VFWMACCVV V2, V1, V0, V3 // d79120f0
VFWMACCVF V2, F10, V3 // d75125f2
VFWMACCVF V2, F10, V0, V3 // d75125f0
VFWNMACCVV V2, V1, V3 // d79120f6
VFWNMACCVV V2, V1, V0, V3 // d79120f4
VFWNMACCVF V2, F10, V3 // d75125f6
VFWNMACCVF V2, F10, V0, V3 // d75125f4
VFWMSACVV V2, V1, V3 // d79120fa
VFWMSACVV V2, V1, V0, V3 // d79120f8
VFWMSACVF V2, F10, V3 // d75125fa
VFWMSACVF V2, F10, V0, V3 // d75125f8
VFWNMSACVV V2, V1, V3 // d79120fe
VFWNMSACVV V2, V1, V0, V3 // d79120fc
VFWNMSACVF V2, F10, V3 // d75125fe
VFWNMSACVF V2, F10, V0, V3 // d75125fc
// 31.13.8: Vector Floating-Point Square-Root Instruction
VFSQRTV V2, V3 // d711204e
VFSQRTV V2, V0, V3 // d711204c
// 31.13.9: Vector Floating-Point Reciprocal Square-Root Estimate Instruction
VFRSQRT7V V2, V3 // d711224e
VFRSQRT7V V2, V0, V3 // d711224c
// 31.13.10: Vector Floating-Point Reciprocal Estimate Instruction
VFREC7V V2, V3 // d791224e
VFREC7V V2, V0, V3 // d791224c
// 31.13.11: Vector Floating-Point MIN/MAX Instructions
VFMINVV V1, V2, V3 // d7912012
VFMINVV V1, V2, V0, V3 // d7912010
VFMINVF F10, V2, V3 // d7512512
VFMINVF F10, V2, V0, V3 // d7512510
VFMAXVV V1, V2, V3 // d791201a
VFMAXVV V1, V2, V0, V3 // d7912018
VFMAXVF F10, V2, V3 // d751251a
VFMAXVF F10, V2, V0, V3 // d7512518
// 31.13.12: Vector Floating-Point Sign-Injection Instructions
VFSGNJVV V1, V2, V3 // d7912022
VFSGNJVV V1, V2, V0, V3 // d7912020
VFSGNJVF F10, V2, V3 // d7512522
VFSGNJVF F10, V2, V0, V3 // d7512520
VFSGNJNVV V1, V2, V3 // d7912026
VFSGNJNVV V1, V2, V0, V3 // d7912024
VFSGNJNVF F10, V2, V3 // d7512526
VFSGNJNVF F10, V2, V0, V3 // d7512524
VFSGNJXVV V1, V2, V3 // d791202a
VFSGNJXVV V1, V2, V0, V3 // d7912028
VFSGNJXVF F10, V2, V3 // d751252a
VFSGNJXVF F10, V2, V0, V3 // d7512528
VFNEGV V2, V3 // d7112126
VFNEGV V2, V0, V3 // d7112124
VFABSV V2, V3 // d711212a
VFABSV V2, V0, V3 // d7112128
// 31.13.13: Vector Floating-Point Compare Instructions
VMFEQVV V1, V2, V3 // d7912062
VMFEQVV V1, V2, V0, V3 // d7912060
VMFEQVF F10, V2, V3 // d7512562
VMFEQVF F10, V2, V0, V3 // d7512560
VMFNEVV V1, V2, V3 // d7912072
VMFNEVV V1, V2, V0, V3 // d7912070
VMFNEVF F10, V2, V3 // d7512572
VMFNEVF F10, V2, V0, V3 // d7512570
VMFLTVV V1, V2, V3 // d791206e
VMFLTVV V1, V2, V0, V3 // d791206c
VMFLTVF F10, V2, V3 // d751256e
VMFLTVF F10, V2, V0, V3 // d751256c
VMFLEVV V1, V2, V3 // d7912066
VMFLEVV V1, V2, V0, V3 // d7912064
VMFLEVF F10, V2, V3 // d7512566
VMFLEVF F10, V2, V0, V3 // d7512564
VMFGTVF F10, V2, V3 // d7512576
VMFGTVF F10, V2, V0, V3 // d7512574
VMFGEVF F10, V2, V3 // d751257e
VMFGEVF F10, V2, V0, V3 // d751257c
VMFGTVV V1, V2, V3 // d711116e
VMFGTVV V1, V2, V0, V3 // d711116c
VMFGEVV V1, V2, V3 // d7111166
VMFGEVV V1, V2, V0, V3 // d7111164
// 31.13.14: Vector Floating-Point Classify Instruction
VFCLASSV V2, V3 // d711284e
VFCLASSV V2, V0, V3 // d711284c
// 31.13.15: Vector Floating-Point Merge Instruction
VFMERGEVFM F10, V2, V0, V3 // d751255c
// 31.13.16: Vector Floating-Point Move Instruction
VFMVVF F10, V3 // d751055e
// 31.13.17: Single-Width Floating-Point/Integer Type-Convert Instructions
VFCVTXUFV V2, V3 // d711204a
VFCVTXUFV V2, V0, V3 // d7112048
VFCVTXFV V2, V3 // d791204a
VFCVTXFV V2, V0, V3 // d7912048
VFCVTRTZXUFV V2, V3 // d711234a
VFCVTRTZXUFV V2, V0, V3 // d7112348
VFCVTRTZXFV V2, V3 // d791234a
VFCVTRTZXFV V2, V0, V3 // d7912348
VFCVTFXUV V2, V3 // d711214a
VFCVTFXUV V2, V0, V3 // d7112148
VFCVTFXV V2, V3 // d791214a
VFCVTFXV V2, V0, V3 // d7912148
// 31.13.18: Widening Floating-Point/Integer Type-Convert Instructions
VFWCVTXUFV V2, V3 // d711244a
VFWCVTXUFV V2, V0, V3 // d7112448
VFWCVTXFV V2, V3 // d791244a
VFWCVTXFV V2, V0, V3 // d7912448
VFWCVTRTZXUFV V2, V3 // d711274a
VFWCVTRTZXUFV V2, V0, V3 // d7112748
VFWCVTRTZXFV V2, V3 // d791274a
VFWCVTRTZXFV V2, V0, V3 // d7912748
VFWCVTFXUV V2, V3 // d711254a
VFWCVTFXUV V2, V0, V3 // d7112548
VFWCVTFXV V2, V3 // d791254a
VFWCVTFXV V2, V0, V3 // d7912548
VFWCVTFFV V2, V3 // d711264a
VFWCVTFFV V2, V0, V3 // d7112648
// 31.13.19: Narrowing Floating-Point/Integer Type-Convert Instructions
VFNCVTXUFW V2, V3 // d711284a
VFNCVTXUFW V2, V0, V3 // d7112848
VFNCVTXFW V2, V3 // d791284a
VFNCVTXFW V2, V0, V3 // d7912848
VFNCVTRTZXUFW V2, V3 // d7112b4a
VFNCVTRTZXUFW V2, V0, V3 // d7112b48
VFNCVTRTZXFW V2, V3 // d7912b4a
VFNCVTRTZXFW V2, V0, V3 // d7912b48
VFNCVTFXUW V2, V3 // d711294a
VFNCVTFXUW V2, V0, V3 // d7112948
VFNCVTFXW V2, V3 // d791294a
VFNCVTFXW V2, V0, V3 // d7912948
VFNCVTFFW V2, V3 // d7112a4a
VFNCVTFFW V2, V0, V3 // d7112a48
VFNCVTRODFFW V2, V3 // d7912a4a
VFNCVTRODFFW V2, V0, V3 // d7912a48
// 31.14.1: Vector Single-Width Integer Reduction Instructions
VREDSUMVS V1, V2, V3 // d7a12002
VREDSUMVS V1, V2, V0, V3 // d7a12000
VREDMAXUVS V1, V2, V3 // d7a1201a
VREDMAXUVS V1, V2, V0, V3 // d7a12018
VREDMAXVS V1, V2, V3 // d7a1201e
VREDMAXVS V1, V2, V0, V3 // d7a1201c
VREDMINUVS V1, V2, V3 // d7a12012
VREDMINUVS V1, V2, V0, V3 // d7a12010
VREDMINVS V1, V2, V3 // d7a12016
VREDMINVS V1, V2, V0, V3 // d7a12014
VREDANDVS V1, V2, V3 // d7a12006
VREDANDVS V1, V2, V0, V3 // d7a12004
VREDORVS V1, V2, V3 // d7a1200a
VREDORVS V1, V2, V0, V3 // d7a12008
VREDXORVS V1, V2, V3 // d7a1200e
VREDXORVS V1, V2, V0, V3 // d7a1200c
// 31.14.2: Vector Widening Integer Reduction Instructions
VWREDSUMUVS V1, V2, V3 // d78120c2
VWREDSUMUVS V1, V2, V0, V3 // d78120c0
VWREDSUMVS V1, V2, V3 // d78120c6
VWREDSUMVS V1, V2, V0, V3 // d78120c4
// 31.14.3: Vector Single-Width Floating-Point Reduction Instructions
VFREDOSUMVS V1, V2, V3 // d791200e
VFREDOSUMVS V1, V2, V0, V3 // d791200c
VFREDUSUMVS V1, V2, V3 // d7912006
VFREDUSUMVS V1, V2, V0, V3 // d7912004
VFREDMAXVS V1, V2, V3 // d791201e
VFREDMAXVS V1, V2, V0, V3 // d791201c
VFREDMINVS V1, V2, V3 // d7912016
VFREDMINVS V1, V2, V0, V3 // d7912014
// 31.14.4: Vector Widening Floating-Point Reduction Instructions
VFWREDOSUMVS V1, V2, V3 // d79120ce
VFWREDOSUMVS V1, V2, V0, V3 // d79120cc
VFWREDUSUMVS V1, V2, V3 // d79120c6
VFWREDUSUMVS V1, V2, V0, V3 // d79120c4
// 31.15: Vector Mask Instructions
VMANDMM V1, V2, V3 // d7a12066
VMNANDMM V1, V2, V3 // d7a12076
VMANDNMM V1, V2, V3 // d7a12062
VMXORMM V1, V2, V3 // d7a1206e
VMORMM V1, V2, V3 // d7a1206a
VMNORMM V1, V2, V3 // d7a1207a
VMORNMM V1, V2, V3 // d7a12072
VMXNORMM V1, V2, V3 // d7a1207e
VMMVM V2, V3 // d7212166
VMCLRM V3 // d7a1316e
VMSETM V3 // d7a1317e
VMNOTM V2, V3 // d7212176
VCPOPM V2, X10 // 57252842
VCPOPM V2, V0, X10 // 57252840
VFIRSTM V2, X10 // 57a52842
VFIRSTM V2, V0, X10 // 57a52840
VMSBFM V2, V3 // d7a12052
VMSBFM V2, V0, V3 // d7a12050
VMSIFM V2, V3 // d7a12152
VMSIFM V2, V0, V3 // d7a12150
VMSOFM V2, V3 // d7212152
VMSOFM V2, V0, V3 // d7212150
VIOTAM V2, V3 // d7212852
VIOTAM V2, V0, V3 // d7212850
VIDV V3 // d7a10852
VIDV V0, V3 // d7a10850
// 31.16.1: Integer Scalar Move Instructions
VMVXS V2, X10 // 57252042
VMVSX X10, V2 // 57610542
// 31.16.2: Floating-Point Scalar Move Instructions
VFMVFS V2, F10 // 57152042
VFMVSF F10, V2 // 57510542
// 31.16.3: Vector Slide Instructions
VSLIDEUPVX X10, V2, V3 // d741253a
VSLIDEUPVX X10, V2, V0, V3 // d7412538
VSLIDEUPVI $16, V2, V3 // d731283a
VSLIDEUPVI $16, V2, V0, V3 // d7312838
VSLIDEDOWNVX X10, V2, V3 // d741253e
VSLIDEDOWNVX X10, V2, V0, V3 // d741253c
VSLIDEDOWNVI $16, V2, V3 // d731283e
VSLIDEDOWNVI $16, V2, V0, V3 // d731283c
VSLIDE1UPVX X10, V2, V3 // d761253a
VSLIDE1UPVX X10, V2, V0, V3 // d7612538
VFSLIDE1UPVF F10, V2, V3 // d751253a
VFSLIDE1UPVF F10, V2, V0, V3 // d7512538
VSLIDE1DOWNVX X10, V2, V3 // d761253e
VSLIDE1DOWNVX X10, V2, V0, V3 // d761253c
VFSLIDE1DOWNVF F10, V2, V3 // d751253e
VFSLIDE1DOWNVF F10, V2, V0, V3 // d751253c
// 31.16.4: Vector Register Gather Instructions
VRGATHERVV V1, V2, V3 // d7812032
VRGATHERVV V1, V2, V0, V3 // d7812030
VRGATHEREI16VV V1, V2, V3 // d781203a
VRGATHEREI16VV V1, V2, V0, V3 // d7812038
VRGATHERVX X10, V2, V3 // d7412532
VRGATHERVX X10, V2, V0, V3 // d7412530
VRGATHERVI $16, V2, V3 // d7312832
VRGATHERVI $16, V2, V0, V3 // d7312830
// 31.16.5: Vector Compress Instruction
VCOMPRESSVM V1, V2, V3 // d7a1205e
// 31.16.6: Whole Vector Register Move
VMV1RV V2, V1 // d730209e
VMV2RV V12, V10 // 57b5c09e
VMV4RV V8, V4 // 57b2819e
VMV8RV V8, V0 // 57b0839e
//
// Privileged ISA
//
@ -441,14 +1295,30 @@ start:
MOV $2048, X5 // b71200009b820280
MOV $-2049, X5 // b7f2ffff9b82f27f
MOV $4096, X5 // b7120000
MOV $2147479552, X5 // b7f2ff7f
MOV $2147483647, X5 // b70200809b82f2ff
MOV $-2147483647, X5 // b70200809b821200
MOV $0x7ffff000, X5 // MOV $2147479552, X5 // b7f2ff7f
MOV $-0x7ffff000, X5 // MOV $-2147479552, X5 // b7120080
MOV $0x7fffffff, X5 // MOV $2147483647, X5 // b70200809b82f2ff
MOV $-0x7fffffff, X5 // MOV $-2147483647, X5 // b70200809b821200
// Converted to load and shift(s)
MOV $0xffffffff, X5 // MOV $4294967295, X5 // 9302f0ff93d20202
MOV $0x100000000, X5 // MOV $4294967296, X5 // 9302100093920202
MOV $0xfffffffffffda, X5 // MOV $4503599627370458, X5 // 9302d0fe9392d20093d2c200
MOV $0xffffffffffffe, X5 // MOV $4503599627370494, X5 // 9302f0ff9392d20093d2c200
MOV $0x7fffffff00000000, X5 // MOV $9223372032559808512, X5 // b70200809b82f2ff93920202
MOV $0x8000000100000000, X5 // MOV $-9223372032559808512, X5 // b70200809b82120093920202
MOV $0xffffffff00000000, X5 // MOV $-4294967296, X5 // 9302f0ff93920202
MOV $0x1ffffffff0000000, X5 // MOV $2305843008945258496, X5 // 9302f0ff9392f20193d23200
MOV $0x7fffffffffffffff, X5 // MOV $9223372036854775807, X5 // 9302f0ff93d21200
// Converted to load of symbol (AUIPC + LD)
MOV $4294967295, X5 // 9702000083b20200
// Converted to MOV $1, X5 + SLLI $32, X5
MOV $4294967296, X5 // 9302100093920202
MOV $0x80000001, X5 // MOV $2147483649, X5 // 9702000083b20200
MOV $0x100000001, X5 // MOV $4294967297, X5 // 9702000083b20200
MOV $0x0800000010000000, X5 // MOV $576460752571858944, X5 // 9702000083b20200
MOV $0x8000000010000000, X5 // MOV $-9223372036586340352, X5 // 9702000083b20200
MOV $0x0abcdabcd0000000, X5 // MOV $773733740479250432, X5 // 9702000083b20200
MOV $0x8abcdabcd0000000, X5 // MOV $-8449638296375525376, X5 // 9702000083b20200
MOV $0xfff0000000ffffff, X5 // MOV $-4503599610593281, X5 // 9702000083b20200
MOV (X5), X6 // 03b30200
MOV 4(X5), X6 // 03b34200
@ -482,6 +1352,9 @@ start:
MOVD F0, 4(X5) // 27b20200
MOVD F0, F1 // d3000022
// Convert to load of symbol (AUIPC + FLD)
MOVD $(709.78271289338397), F3 // 970f000087b10f00
// TLS load with local-exec (LUI + ADDIW + ADD of TP + load)
MOV tls(SB), X5 // b70f00009b8f0f00b38f4f0083b20f00
MOVB tls(SB), X5 // b70f00009b8f0f00b38f4f0083820f00

View File

@ -30,6 +30,8 @@ TEXT errors(SB),$0
SLLI $64, X5, X6 // ERROR "immediate out of range 0 to 63"
SRLI $64, X5, X6 // ERROR "immediate out of range 0 to 63"
SRAI $64, X5, X6 // ERROR "immediate out of range 0 to 63"
BEQ X5, X6, $1 // ERROR "instruction with branch-like opcode lacks destination"
BEQ X5, X6, 31(X10) // ERROR "instruction with branch-like opcode lacks destination"
RORI $-1, X5, X6 // ERROR "immediate out of range 0 to 63"
SLLI $-1, X5, X6 // ERROR "immediate out of range 0 to 63"
SRLI $-1, X5, X6 // ERROR "immediate out of range 0 to 63"
@ -43,7 +45,340 @@ TEXT errors(SB),$0
SRLIW $-1, X5, X6 // ERROR "immediate out of range 0 to 31"
SRAIW $-1, X5, X6 // ERROR "immediate out of range 0 to 31"
SD X5, 4294967296(X6) // ERROR "constant 4294967296 too large"
SRLI $1, X5, F1 // ERROR "expected integer register in rd position but got non-integer register F1"
SRLI $1, F1, X5 // ERROR "expected integer register in rs1 position but got non-integer register F1"
FNES F1, (X5) // ERROR "needs an integer register output"
//
// "V" Standard Extension for Vector Operations, Version 1.0
//
VSETIVLI X10, E32, M2, TA, MA, X12 // ERROR "expected immediate value"
VLE8V (X10), V1, V3 // ERROR "invalid vector mask register"
VSE8V V3, V1, (X10) // ERROR "invalid vector mask register"
VLSE8V (X10), X10, V1, V3 // ERROR "invalid vector mask register"
VSSE8V V3, X11, V1, (X10) // ERROR "invalid vector mask register"
VLUXEI8V (X10), V2, V1, V3 // ERROR "invalid vector mask register"
VSUXEI8V V3, V2, V1, (X10) // ERROR "invalid vector mask register"
VLOXEI8V (X10), V2, V1, V3 // ERROR "invalid vector mask register"
VSOXEI8V V3, V2, V1, (X10) // ERROR "invalid vector mask register"
VL1RV (X10), V0, V3 // ERROR "too many operands for instruction"
VS1RV V3, V0, (X11) // ERROR "too many operands for instruction"
VADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VADDVX X10, V2, V1, V3 // ERROR "invalid vector mask register"
VADDVI $15, V4, V1, V2 // ERROR "invalid vector mask register"
VSUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSUBVX X10, V2, V1, V3 // ERROR "invalid vector mask register"
VRSUBVX X10, V2, V1, V3 // ERROR "invalid vector mask register"
VRSUBVI $15, V4, V1, V2 // ERROR "invalid vector mask register"
VNEGV V2, V3, V4 // ERROR "invalid vector mask register"
VWADDUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDUWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDUWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBUWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBUWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWADDWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWSUBWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWCVTXXV V2, V1, V3 // ERROR "invalid vector mask register"
VWCVTUXXV V2, V1, V3 // ERROR "invalid vector mask register"
VZEXTVF2 V2, V3, V4 // ERROR "invalid vector mask register"
VSEXTVF2 V2, V3, V4 // ERROR "invalid vector mask register"
VZEXTVF4 V2, V3, V4 // ERROR "invalid vector mask register"
VSEXTVF4 V2, V3, V4 // ERROR "invalid vector mask register"
VZEXTVF8 V2, V3, V4 // ERROR "invalid vector mask register"
VSEXTVF8 V2, V3, V4 // ERROR "invalid vector mask register"
VADCVVM V1, V2, V4, V3 // ERROR "invalid vector mask register"
VADCVVM V1, V2, V3 // ERROR "invalid vector mask register"
VADCVXM X10, V2, V4, V3 // ERROR "invalid vector mask register"
VADCVXM X10, V2, V3 // ERROR "invalid vector mask register"
VADCVIM $15, V2, V1, V3 // ERROR "invalid vector mask register"
VADCVIM $15, V2, V3 // ERROR "invalid vector mask register"
VMADCVVM V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMADCVVM V1, V2, V3 // ERROR "invalid vector mask register"
VMADCVXM X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMADCVXM X10, V2, V3 // ERROR "invalid vector mask register"
VMADCVIM $15, V2, V1, V3 // ERROR "invalid vector mask register"
VMADCVIM $15, V2, V3 // ERROR "invalid vector mask register"
VSBCVVM V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSBCVVM V1, V2, V3 // ERROR "invalid vector mask register"
VSBCVXM X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSBCVXM X10, V2, V3 // ERROR "invalid vector mask register"
VMSBCVVM V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSBCVVM V1, V2, V3 // ERROR "invalid vector mask register"
VMSBCVXM X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSBCVXM X10, V2, V3 // ERROR "invalid vector mask register"
VANDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VANDVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VANDVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VORVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VORVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VORVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VXORVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VXORVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VXORVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VNOTV V1, V2, V3 // ERROR "invalid vector mask register"
VSLLVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSLLVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSLLVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VSRLVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSRLVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSRLVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VSRAVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSRAVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSRAVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VNSRLWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VNSRLWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VNSRLWI $31, V2, V4, V3 // ERROR "invalid vector mask register"
VNSRAWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VNSRAWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VNSRAWI $31, V2, V4, V3 // ERROR "invalid vector mask register"
VNCVTXXW V2, V4, V3 // ERROR "invalid vector mask register"
VMSEQVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSEQVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSEQVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSNEVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSNEVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSNEVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLTUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLTUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLTVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLTVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLEUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLEUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLEUVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLEVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLEVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLEVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGTUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGTUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGTUVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGTVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGTVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGTVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGEVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGEUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLTVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSLTUVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGEVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMSGEUVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMINUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMINUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMINVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMINVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMAXUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMAXUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMAXVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMAXVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMULVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMULVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMULHVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMULHVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMULHUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMULHUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMULHSUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMULHSUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VDIVUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VDIVUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VDIVVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VDIVVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VREMUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREMUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VREMVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREMVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMULVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWMULVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMULUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWMULUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMULSUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWMULSUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMACCVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMACCVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VNMSACVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VNMSACVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMADDVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VNMSUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VNMSUBVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCSUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCSUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VWMACCUSVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMERGEVVM V1, V2, V3 // ERROR "invalid vector mask register"
VMERGEVVM V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMERGEVXM X10, V2, V3 // ERROR "invalid vector mask register"
VMERGEVXM X10, V2, V4, V3 // ERROR "invalid vector mask register"
VMERGEVIM $15, V2, V3 // ERROR "invalid vector mask register"
VMERGEVIM $15, V2, V4, V3 // ERROR "invalid vector mask register"
VMVVV V1, V2, V3 // ERROR "too many operands for instruction"
VMVVX X10, V2, V3 // ERROR "too many operands for instruction"
VMVVI $15, V2, V3 // ERROR "too many operands for instruction"
VSADDUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSADDUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSADDUVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VSADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSADDVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSADDVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VSSUBUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSSUBUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSSUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSSUBVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VAADDUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VAADDUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VAADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VAADDVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VASUBUVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VASUBUVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VASUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VASUBVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSMULVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSMULVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSSRLVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSSRLVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSSRLVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VSSRAVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VSSRAVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSSRAVI $15, V2, V4, V3 // ERROR "invalid vector mask register"
VNCLIPUWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VNCLIPUWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VNCLIPUWI $16, V2, V4, V3 // ERROR "invalid vector mask register"
VNCLIPWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VNCLIPWX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VNCLIPWI $16, V2, V4, V3 // ERROR "invalid vector mask register"
VFADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFADDVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFSUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFSUBVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFRSUBVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFWADDVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFWADDVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFWSUBVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFWSUBVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFWADDWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFWADDWF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFWSUBWV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFWSUBWF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFMULVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFMULVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFDIVVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFDIVVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFRDIVVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFWMULVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFWMULVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFMACCVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFMACCVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFNMACCVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFNMACCVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFMSACVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFMSACVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFNMSACVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFNMSACVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFMADDVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFMADDVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFNMADDVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFNMADDVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFMSUBVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFMSUBVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFNMSUBVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFNMSUBVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFWMACCVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFWMACCVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFWNMACCVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFWNMACCVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFWMSACVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFWMSACVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFWNMSACVV V2, V1, V4, V3 // ERROR "invalid vector mask register"
VFWNMSACVF V2, F10, V4, V3 // ERROR "invalid vector mask register"
VFSQRTV V2, V4, V3 // ERROR "invalid vector mask register"
VFRSQRT7V V2, V4, V3 // ERROR "invalid vector mask register"
VFREC7V V2, V4, V3 // ERROR "invalid vector mask register"
VFMINVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFMINVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFMAXVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFMAXVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFSGNJVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFSGNJVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFSGNJNVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFSGNJNVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFSGNJXVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFSGNJXVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFNEGV V2, V4, V3 // ERROR "invalid vector mask register"
VFABSV V2, V4, V3 // ERROR "invalid vector mask register"
VMFEQVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMFEQVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VMFNEVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMFNEVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VMFLTVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMFLTVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VMFLEVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMFLEVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VMFGTVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VMFGEVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VMFGTVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VMFGEVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFMERGEVFM X10, V2, V3 // ERROR "invalid vector mask register"
VFMERGEVFM F10, V2, V4, V3 // ERROR "invalid vector mask register"
VFCVTXUFV V2, V4, V3 // ERROR "invalid vector mask register"
VFCVTXFV V2, V4, V3 // ERROR "invalid vector mask register"
VFCVTRTZXUFV V2, V4, V3 // ERROR "invalid vector mask register"
VFCVTRTZXFV V2, V4, V3 // ERROR "invalid vector mask register"
VFCVTFXUV V2, V4, V3 // ERROR "invalid vector mask register"
VFCVTFXV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTXUFV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTXFV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTRTZXUFV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTRTZXFV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTFXUV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTFXV V2, V4, V3 // ERROR "invalid vector mask register"
VFWCVTFFV V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTXUFW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTXFW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTRTZXUFW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTRTZXFW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTFXUW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTFXW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTFFW V2, V4, V3 // ERROR "invalid vector mask register"
VFNCVTRODFFW V2, V4, V3 // ERROR "invalid vector mask register"
VREDSUMVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDMAXUVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDMAXVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDMINUVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDMINVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDANDVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDORVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VREDXORVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWREDSUMUVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VWREDSUMVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFREDOSUMVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFREDUSUMVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFREDMAXVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFREDMINVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VFWREDOSUMVS V1, V2, V4, V3 // ERROR "invalid vector mask register"
VCPOPM V2, V4, X10 // ERROR "invalid vector mask register"
VFIRSTM V2, V4, X10 // ERROR "invalid vector mask register"
VMSBFM V2, V4, V3 // ERROR "invalid vector mask register"
VMSIFM V2, V4, V3 // ERROR "invalid vector mask register"
VMSOFM V2, V4, V3 // ERROR "invalid vector mask register"
VIOTAM V2, V4, V3 // ERROR "invalid vector mask register"
VSLIDEUPVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSLIDEUPVI $16, V2, V4, V3 // ERROR "invalid vector mask register"
VSLIDEDOWNVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VSLIDEDOWNVI $16, V2, V4, V3 // ERROR "invalid vector mask register"
VSLIDE1UPVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VFSLIDE1UPVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VSLIDE1DOWNVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VFSLIDE1DOWNVF F10, V2, V4, V3 // ERROR "invalid vector mask register"
VRGATHERVV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VRGATHEREI16VV V1, V2, V4, V3 // ERROR "invalid vector mask register"
VRGATHERVX X10, V2, V4, V3 // ERROR "invalid vector mask register"
VRGATHERVI $16, V2, V4, V3 // ERROR "invalid vector mask register"
RET

View File

@ -0,0 +1,431 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file is for validation errors only, i.e., errors reported by the validate function.
// Negative test cases for errors generated earlier in the assembler's preprocess stage
// should be added to riscv64error.s. If they are added to this file, they will prevent
// the validate function from being run and TestRISCVValidation will report missing
// errors.
TEXT validation(SB),$0
SRLI $1, X5, F1 // ERROR "expected integer register in rd position but got non-integer register F1"
SRLI $1, F1, X5 // ERROR "expected integer register in rs1 position but got non-integer register F1"
//
// "V" Standard Extension for Vector Operations, Version 1.0
//
VSETVLI $32, E16, M1, TU, MU, X12 // ERROR "must be in range [0, 31] (5 bits)"
VSETVLI $-1, E32, M2, TA, MA, X12 // ERROR "must be in range [0, 31] (5 bits)"
VSETVL X10, X11 // ERROR "expected integer register in rs1 position"
VLE8V (X10), X10 // ERROR "expected vector register in vd position"
VLE8V (V1), V3 // ERROR "expected integer register in rs1 position"
VSE8V X10, (X10) // ERROR "expected vector register in vs1 position"
VSE8V V3, (V1) // ERROR "expected integer register in rd position"
VLSE8V (X10), V3 // ERROR "expected integer register in rs2 position"
VLSE8V (X10), X10, X11 // ERROR "expected vector register in vd position"
VLSE8V (V1), X10, V3 // ERROR "expected integer register in rs1 position"
VLSE8V (X10), V1, V0, V3 // ERROR "expected integer register in rs2 position"
VSSE8V V3, (X10) // ERROR "expected integer register in rs2 position"
VSSE8V X10, X11, (X10) // ERROR "expected vector register in vd position"
VSSE8V V3, X11, (V1) // ERROR "expected integer register in rs1 position"
VSSE8V V3, V1, V0, (X10) // ERROR "expected integer register in rs2 position"
VLUXEI8V (X10), V2, X11 // ERROR "expected vector register in vd position"
VLUXEI8V (X10), V2, X11 // ERROR "expected vector register in vd position"
VLUXEI8V (V1), V2, V3 // ERROR "expected integer register in rs1 position"
VLUXEI8V (X10), X11, V0, V3 // ERROR "expected vector register in vs2 position"
VSUXEI8V X10, V2, (X10) // ERROR "expected vector register in vd position"
VSUXEI8V V3, V2, (V1) // ERROR "expected integer register in rs1 position"
VSUXEI8V V3, X11, V0, (X10) // ERROR "expected vector register in vs2 position"
VLOXEI8V (X10), V2, X11 // ERROR "expected vector register in vd position"
VLOXEI8V (V1), V2, V3 // ERROR "expected integer register in rs1 position"
VLOXEI8V (X10), X11, V0, V3 // ERROR "expected vector register in vs2 position"
VSOXEI8V X10, V2, (X10) // ERROR "expected vector register in vd position"
VSOXEI8V V3, V2, (V1) // ERROR "expected integer register in rs1 position"
VSOXEI8V V3, X11, V0, (X10) // ERROR "expected vector register in vs2 position"
VL1RV (X10), X10 // ERROR "expected vector register in vd position"
VL1RV (V1), V3 // ERROR "expected integer register in rs1 position"
VS1RV X11, (X11) // ERROR "expected vector register in vs1 position"
VS1RV V3, (V1) // ERROR "expected integer register in rd position"
VADDVV V1, X10, V3 // ERROR "expected vector register in vs2 position"
VADDVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VADDVI $16, V4, V2 // ERROR "signed immediate 16 must be in range [-16, 15] (5 bits)"
VADDVI $-17, V4, V2 // ERROR "signed immediate -17 must be in range [-16, 15] (5 bits)"
VSUBVV V1, X10, V3 // ERROR "expected vector register in vs2 position"
VSUBVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VRSUBVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VRSUBVI $16, V4, V2 // ERROR "signed immediate 16 must be in range [-16, 15] (5 bits)"
VRSUBVI $-17, V4, V2 // ERROR "signed immediate -17 must be in range [-16, 15] (5 bits)"
VNEGV X10, V3 // ERROR "expected vector register in vs2 position"
VNEGV V2 // ERROR "expected vector register in vd position"
VWADDUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWADDUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWSUBUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWSUBUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWADDVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWADDVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWSUBVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWSUBVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWADDUWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWADDUWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWSUBUWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWSUBUWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWADDWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWADDWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWSUBWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWSUBWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWCVTXXV X10, V3 // ERROR "expected vector register in vs2 position"
VWCVTUXXV X10, V3 // ERROR "expected vector register in vs2 position"
VZEXTVF2 V2, V0, V3, V4 // ERROR "expected no register in rs3"
VZEXTVF2 X10, V3 // ERROR "expected vector register in vs2 position"
VSEXTVF2 V2, V0, V3, V4 // ERROR "expected no register in rs3"
VSEXTVF2 X10, V3 // ERROR "expected vector register in vs2 position"
VZEXTVF4 V2, V0, V3, V4 // ERROR "expected no register in rs3"
VZEXTVF4 X10, V3 // ERROR "expected vector register in vs2 position"
VSEXTVF4 V2, V0, V3, V4 // ERROR "expected no register in rs3"
VSEXTVF4 X10, V3 // ERROR "expected vector register in vs2 position"
VZEXTVF8 V2, V0, V3, V4 // ERROR "expected no register in rs3"
VZEXTVF8 X10, V3 // ERROR "expected vector register in vs2 position"
VSEXTVF8 V2, V0, V3, V4 // ERROR "expected no register in rs3"
VSEXTVF8 X10, V3 // ERROR "expected vector register in vs2 position"
VADCVVM X10, V2, V0, V3 // ERROR "expected vector register in vs1 position"
VADCVXM V1, V2, V0, V3 // ERROR "expected integer register in rs1 position"
VADCVIM $16, V2, V0, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VADCVIM $-17, V2, V0, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMADCVVM X10, V2, V0, V3 // ERROR "expected vector register in vs1 position"
VMADCVXM V1, V2, V0, V3 // ERROR "expected integer register in rs1 position"
VMADCVIM $16, V2, V0, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMADCVIM $-17, V2, V0, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMADCVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMADCVV V1, V2, V0, V3 // ERROR "expected no register in rs3"
VMADCVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMADCVX X10, V2, V0, V3 // ERROR "expected no register in rs3"
VMADCVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMADCVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMADCVI $15, V2, V0, V3 // ERROR "expected no register in rs3"
VSBCVVM X10, V2, V0, V3 // ERROR "expected vector register in vs1 position"
VSBCVXM V1, V2, V0, V3 // ERROR "expected integer register in rs1 position"
VMSBCVVM X10, V2, V0, V3 // ERROR "expected vector register in vs1 position"
VMSBCVXM V1, V2, V0, V3 // ERROR "expected integer register in rs1 position"
VMSBCVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSBCVV V1, V2, V0, V3 // ERROR "expected no register in rs3"
VMSBCVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSBCVX X10, V2, V0, V3 // ERROR "expected no register in rs3"
VANDVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VANDVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VANDVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VANDVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VORVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VORVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VORVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VORVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VXORVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VXORVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VXORVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VXORVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VNOTV V3 // ERROR "expected vector register in vd position"
VNOTV X10, V3 // ERROR "expected vector register in vs2 position"
VSLLVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSLLVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSLLVI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VSLLVI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VSRLVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSRLVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSRLVI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VSRLVI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VSRAVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSRAVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSRAVI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VSRAVI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VNSRLWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VNSRLWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VNSRLWI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VNSRLWI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VNSRAWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VNSRAWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VNSRAWI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VNSRAWI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VNCVTXXW X10, V3 // ERROR "expected vector register in vs2 position"
VMSEQVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSEQVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSEQVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSEQVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSNEVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSNEVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSNEVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSNEVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSLTUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSLTUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSLTVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSLTVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSLEUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSLEUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSLEUVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSLEUVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSLEVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMSLEVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSLEVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSLEVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSGTUVV X10, V2, V3 // ERROR "expected vector register in vs2 position"
VMSGTUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSGTUVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSGTUVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSGTVV X10, V2, V3 // ERROR "expected vector register in vs2 position"
VMSGTVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMSGTVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSGTVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSGEVV X10, V2, V3 // ERROR "expected vector register in vs2 position"
VMSGEUVV X10, V2, V3 // ERROR "expected vector register in vs2 position"
VMSLTVI $17, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSLTVI $-16, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSLTUVI $17, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSLTUVI $-16, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSGEVI $17, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSGEVI $-16, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMSGEUVI $17, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMSGEUVI $-16, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMINUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMINUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMINVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMINVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMAXUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMAXUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMAXVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMAXVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMULVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMULVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMULHVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMULHVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMULHUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMULHUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMULHSUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMULHSUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VDIVUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VDIVUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VDIVVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VDIVVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VREMUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREMUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VREMVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREMVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMULVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWMULVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMULUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWMULUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMULSUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWMULSUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMACCVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMACCVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VNMSACVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VNMSACVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMADDVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMADDVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VNMSUBVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VNMSUBVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMACCUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWMACCUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMACCVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWMACCVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMACCSUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWMACCSUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VWMACCUSVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VMERGEVVM X10, V2, V0, V3 // ERROR "expected vector register in vs1 position"
VMERGEVXM V1, V2, V0, V3 // ERROR "expected integer register in rs1 position"
VMERGEVIM $16, V2, V0, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMERGEVIM $-17, V2, V0, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VMVVV X10, V3 // ERROR "expected vector register in vs1 position"
VMVVX V1, V2 // ERROR "expected integer register in rs1 position"
VMVVI $16, V2 // ERROR "signed immediate 16 must be in range [-16, 15]"
VMVVI $-17, V2 // ERROR "signed immediate -17 must be in range [-16, 15]"
VSADDUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSADDUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSADDUVI $16, V2, V3 // ERROR "signed immediate 16 must be in range [-16, 15]"
VSADDUVI $-17, V2, V3 // ERROR "signed immediate -17 must be in range [-16, 15]"
VSSUBUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSSUBUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VAADDUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VAADDUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VAADDVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VAADDVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VASUBUVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VASUBUVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VASUBVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VASUBVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSMULVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSMULVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSSRLVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSSRLVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSSRLVI $32, V2, V3 // ERROR "signed immediate 32 must be in range [0, 31]"
VSSRLVI $-1, V2, V3 // ERROR "signed immediate -1 must be in range [0, 31]"
VSSRAVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VSSRAVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSSRAVI $32, V2, V3 // ERROR "signed immediate 32 must be in range [0, 31]"
VSSRAVI $-1, V2, V3 // ERROR "signed immediate -1 must be in range [0, 31]"
VNCLIPUWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VNCLIPUWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VNCLIPUWI $32, V2, V3 // ERROR "signed immediate 32 must be in range [0, 31]"
VNCLIPUWI $-1, V2, V3 // ERROR "signed immediate -1 must be in range [0, 31]"
VNCLIPWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VNCLIPWX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VNCLIPWI $32, V2, V3 // ERROR "signed immediate 32 must be in range [0, 31]"
VNCLIPWI $-1, V2, V3 // ERROR "signed immediate -1 must be in range [0, 31]"
VFADDVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFADDVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFSUBVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFSUBVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFRSUBVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFWADDVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWADDVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFWSUBVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWSUBVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFWADDWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWADDWF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFWSUBWV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWSUBWF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFMULVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFMULVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFDIVVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFDIVVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFRDIVVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFWMULVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWMULVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFMACCVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFMACCVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFNMACCVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFNMACCVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFMSACVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFMSACVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFNMSACVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFNMSACVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFMADDVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFMADDVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFNMADDVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFNMADDVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFMSUBVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFMSUBVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFNMSUBVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFNMSUBVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFWMACCVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFWMACCVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFWNMACCVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFWNMACCVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFWMSACVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFWMSACVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFWNMSACVV V2, X10, V3 // ERROR "expected vector register in vs1 position"
VFWNMSACVF V2, X10, V3 // ERROR "expected float register in rs1 position"
VFSQRTV X10, V3 // ERROR "expected vector register in vs2 position"
VFRSQRT7V X10, V3 // ERROR "expected vector register in vs2 position"
VFREC7V X10, V3 // ERROR "expected vector register in vs2 position"
VFMINVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFMINVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFMAXVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFMAXVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFSGNJVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFSGNJVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFSGNJNVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFSGNJNVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFSGNJXVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFSGNJXVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VFNEGV V2, X10 // ERROR "expected vector register in vd position"
VFABSV V2, X10 // ERROR "expected vector register in vd position"
VMFEQVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMFEQVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VMFNEVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMFNEVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VMFLTVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMFLTVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VMFLEVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMFLEVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VMFGTVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VMFGEVF X10, V2, V3 // ERROR "expected float register in rs1 position"
VMFGTVV X10, V2, V3 // ERROR "expected vector register in vs2 position"
VMFGEVV X10, V2, V3 // ERROR "expected vector register in vs2 position"
VFCLASSV X10, V3 // ERROR "expected vector register in vs2 position"
VFMERGEVFM X10, V2, V0, V3 // ERROR "expected float register in rs1 position"
VFMVVF X10, V3 // ERROR "expected float register in rs1 position"
VFCVTXUFV X10, V3 // ERROR "expected vector register in vs2 position"
VFCVTXFV X10, V3 // ERROR "expected vector register in vs2 position"
VFCVTRTZXUFV X10, V3 // ERROR "expected vector register in vs2 position"
VFCVTRTZXFV X10, V3 // ERROR "expected vector register in vs2 position"
VFCVTFXUV X10, V3 // ERROR "expected vector register in vs2 position"
VFCVTFXV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTXUFV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTXFV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTRTZXUFV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTRTZXFV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTFXUV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTFXV X10, V3 // ERROR "expected vector register in vs2 position"
VFWCVTFFV X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTXUFW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTXFW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTRTZXUFW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTRTZXFW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTFXUW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTFXW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTFFW X10, V3 // ERROR "expected vector register in vs2 position"
VFNCVTRODFFW X10, V3 // ERROR "expected vector register in vs2 position"
VREDSUMVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDMAXUVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDMAXVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDMINUVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDMINVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDANDVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDORVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VREDXORVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWREDSUMUVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VWREDSUMVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFREDOSUMVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFREDUSUMVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFREDMAXVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFREDMINVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWREDOSUMVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VFWREDUSUMVS X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMANDMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMNANDMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMANDNMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMXORMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMORMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMNORMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMORNMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMXNORMM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMMVM V3, X10 // ERROR "expected vector register in vd position"
VMNOTM V3, X10 // ERROR "expected vector register in vd position"
VCPOPM V2, V1 // ERROR "expected integer register in rd position"
VCPOPM X11, X10 // ERROR "expected vector register in vs2 position"
VFIRSTM V2, V1 // ERROR "expected integer register in rd position"
VFIRSTM X11, X10 // ERROR "expected vector register in vs2 position"
VMSBFM X10, V3 // ERROR "expected vector register in vs2 position"
VMSIFM X10, V3 // ERROR "expected vector register in vs2 position"
VMSOFM X10, V3 // ERROR "expected vector register in vs2 position"
VIOTAM X10, V3 // ERROR "expected vector register in vs2 position"
VIDV X10 // ERROR "expected vector register in vd position"
VMVXS X11, X10 // ERROR "expected vector register in vs2 position"
VMVXS V2, V1 // ERROR "expected integer register in rd position"
VMVSX X11, X10 // ERROR "expected vector register in vd position"
VMVSX V2, V1 // ERROR "expected integer register in rs2 position"
VFMVFS X10, F10 // ERROR "expected vector register in vs2 position"
VFMVFS V2, V1 // ERROR "expected float register in rd position"
VFMVSF X10, V2 // ERROR "expected float register in rs2 position"
VFMVSF V2, V1 // ERROR "expected float register in rs2 position"
VSLIDEUPVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSLIDEUPVI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VSLIDEUPVI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VSLIDEDOWNVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VSLIDEDOWNVI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VSLIDEDOWNVI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VSLIDE1UPVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VFSLIDE1UPVF V1, V2, V3 // ERROR "expected float register in rs1 position"
VSLIDE1DOWNVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VFSLIDE1DOWNVF V1, V2, V3 // ERROR "expected float register in rs1 position"
VRGATHERVV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VRGATHEREI16VV X10, V2, V3 // ERROR "expected vector register in vs1 position"
VRGATHERVX V1, V2, V3 // ERROR "expected integer register in rs1 position"
VRGATHERVI $-1, V2, V3 // ERROR "unsigned immediate -1 must be in range [0, 31]"
VRGATHERVI $32, V2, V3 // ERROR "unsigned immediate 32 must be in range [0, 31]"
VCOMPRESSVM X10, V2, V3 // ERROR "expected vector register in vs1 position"
VMV1RV X10, V1 // ERROR "expected vector register in vs2 position"
VMV2RV X10, V10 // ERROR "expected vector register in vs2 position"
VMV4RV X10, V4 // ERROR "expected vector register in vs2 position"
VMV8RV X10, V0 // ERROR "expected vector register in vs2 position"
RET

View File

@ -401,6 +401,7 @@ TEXT main·foo(SB),DUPOK|NOSPLIT,$16-0 // TEXT main.foo(SB), DUPOK|NOSPLIT, $16-
FMADDS F1, F2, F3 // b30e3012
FMSUB F4, F5, F5 // b31f5045
FMSUBS F6, F6, F7 // b30f7066
LCDBR F0, F2 // b3130020
LPDFR F1, F2 // b3700021
LNDFR F3, F4 // b3710043
CPSDR F5, F6, F7 // b3725076

View File

@ -49,6 +49,7 @@ func main() {
ctxt.Debugpcln = flags.DebugFlags.PCTab
ctxt.IsAsm = true
ctxt.Pkgpath = *flags.Importpath
ctxt.DwTextCount = objabi.DummyDwarfFunctionCountForAssembler()
switch *flags.Spectre {
default:
log.Printf("unknown setting -spectre=%s", *flags.Spectre)

View File

@ -2863,7 +2863,7 @@ func (c *typeConv) loadType(dtype dwarf.Type, pos token.Pos, parent string) *Typ
if ss, ok := dwarfToName[s]; ok {
s = ss
}
s = strings.Replace(s, " ", "", -1)
s = strings.ReplaceAll(s, " ", "")
name := c.Ident("_Ctype_" + s)
tt := *t
typedef[name.Name] = &tt

View File

@ -40,8 +40,9 @@ func TestCallback(t *testing.T) {
}
func run(t *testing.T, dir string, lto bool, args ...string) {
testenv.MustHaveGoRun(t)
runArgs := append([]string{"run", "."}, args...)
cmd := exec.Command("go", runArgs...)
cmd := exec.Command(testenv.GoToolPath(t), runArgs...)
cmd.Dir = dir
if lto {
// On the builders we're using the default /usr/bin/ld, but
@ -68,7 +69,7 @@ func run(t *testing.T, dir string, lto bool, args ...string) {
func mustHaveCxx(t *testing.T) {
// Ask the go tool for the CXX it's configured to use.
cxx, err := exec.Command("go", "env", "CXX").CombinedOutput()
cxx, err := exec.Command(testenv.GoToolPath(t), "env", "CXX").CombinedOutput()
if err != nil {
t.Fatalf("go env CXX failed: %s", err)
}

View File

@ -11,6 +11,7 @@ package cgotest
import (
"bytes"
"crypto/md5"
"internal/testenv"
"os"
"os/exec"
"runtime"
@ -73,7 +74,7 @@ func test18146(t *testing.T) {
}
runtime.GOMAXPROCS(threads)
argv := append(os.Args, "-test.run=^$")
if err := syscall.Exec(os.Args[0], argv, os.Environ()); err != nil {
if err := syscall.Exec(testenv.Executable(t), argv, os.Environ()); err != nil {
t.Fatal(err)
}
}
@ -87,7 +88,7 @@ func test18146(t *testing.T) {
args := append(append([]string(nil), os.Args[1:]...), "-test.run=^Test18146$")
for n := attempts; n > 0; n-- {
cmd := exec.Command(os.Args[0], args...)
cmd := exec.Command(testenv.Executable(t), args...)
cmd.Env = append(os.Environ(), "test18146=exec")
buf := bytes.NewBuffer(nil)
cmd.Stdout = buf

View File

@ -11,6 +11,7 @@ package cgotest
/*
#include <stdint.h>
#include <stdlib.h>
#include <dlfcn.h>
#cgo linux LDFLAGS: -ldl
@ -24,6 +25,7 @@ import "C"
import (
"testing"
"unsafe"
)
var callbacks int
@ -66,7 +68,9 @@ func loadThySelf(t *testing.T, symbol string) {
}
defer C.dlclose4029(this_process)
symbol_address := C.dlsym4029(this_process, C.CString(symbol))
symCStr := C.CString(symbol)
defer C.free(unsafe.Pointer(symCStr))
symbol_address := C.dlsym4029(this_process, symCStr)
if symbol_address == 0 {
t.Error("dlsym:", C.GoString(C.dlerror()))
return

View File

@ -27,6 +27,7 @@ func test42018(t *testing.T) {
recurseHWND(400, hwnd, uintptr(unsafe.Pointer(&i)))
}
//go:noinline
func recurseHANDLE(n int, p C.HANDLE, v uintptr) {
if n > 0 {
recurseHANDLE(n-1, p, v)
@ -36,6 +37,7 @@ func recurseHANDLE(n int, p C.HANDLE, v uintptr) {
}
}
//go:noinline
func recurseHWND(n int, p C.HWND, v uintptr) {
if n > 0 {
recurseHWND(n-1, p, v)

View File

@ -1098,6 +1098,7 @@ func testErrno(t *testing.T) {
func testMultipleAssign(t *testing.T) {
p := C.CString("234")
n, m := C.strtol(p, nil, 345), C.strtol(p, nil, 10)
defer C.free(unsafe.Pointer(p))
if runtime.GOOS == "openbsd" {
// Bug in OpenBSD strtol(3) - base > 36 succeeds.
if (n != 0 && n != 239089) || m != 234 {
@ -1106,7 +1107,6 @@ func testMultipleAssign(t *testing.T) {
} else if n != 0 || m != 234 {
t.Fatal("Strtol x2: ", n, m)
}
C.free(unsafe.Pointer(p))
}
var (
@ -1632,7 +1632,9 @@ func testNaming(t *testing.T) {
func test6907(t *testing.T) {
want := "yarn"
if got := C.GoString(C.Issue6907CopyString(want)); got != want {
s := C.Issue6907CopyString(want)
defer C.free(unsafe.Pointer(s))
if got := C.GoString(s); got != want {
t.Errorf("C.GoString(C.Issue6907CopyString(%q)) == %q, want %q", want, got, want)
}
}
@ -1881,6 +1883,7 @@ func test17537(t *testing.T) {
}
p := (*C.char)(C.malloc(1))
defer C.free(unsafe.Pointer(p))
*p = 17
if got, want := C.F17537(&p), C.int(17); got != want {
t.Errorf("got %d, want %d", got, want)

View File

@ -218,7 +218,7 @@ func genHeader(t *testing.T, header, dir string) {
t.Fatal(err)
}
cmd := exec.Command("go", "tool", "cgo",
cmd := exec.Command(testenv.GoToolPath(t), "tool", "cgo",
"-objdir", objDir,
"-exportheader", header)
cmd.Args = append(cmd.Args, files...)
@ -524,7 +524,7 @@ func TestEarlySignalHandler(t *testing.T) {
}()
}
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo2.a", "./libgo2")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo2.a", "./libgo2")
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
@ -674,7 +674,7 @@ func buildSignalForwardingTest(t *testing.T) {
}
t.Log("go build -buildmode=c-archive -o libgo2.a ./libgo2")
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo2.a", "./libgo2")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo2.a", "./libgo2")
out, err := cmd.CombinedOutput()
if len(out) > 0 {
t.Logf("%s", out)
@ -801,7 +801,7 @@ func TestOsSignal(t *testing.T) {
}()
}
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo3.a", "./libgo3")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo3.a", "./libgo3")
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
@ -843,7 +843,7 @@ func TestSigaltstack(t *testing.T) {
}()
}
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo4.a", "./libgo4")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo4.a", "./libgo4")
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
@ -908,7 +908,7 @@ func TestExtar(t *testing.T) {
t.Fatal(err)
}
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-ldflags=-extar="+filepath.Join(dir, "testar"), "-o", "libgo4.a", "./libgo4")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-ldflags=-extar="+filepath.Join(dir, "testar"), "-o", "libgo4.a", "./libgo4")
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
@ -955,7 +955,7 @@ func TestPIE(t *testing.T) {
// be running this test in a GOROOT owned by root.)
genHeader(t, "p.h", "./p")
cmd := exec.Command("go", "build", "-buildmode=c-archive", "./libgo")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "./libgo")
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
@ -1042,7 +1042,7 @@ func TestSIGPROF(t *testing.T) {
}()
}
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo6.a", "./libgo6")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo6.a", "./libgo6")
out, err := cmd.CombinedOutput()
t.Logf("%v\n%s", cmd.Args, out)
if err != nil {
@ -1089,7 +1089,7 @@ func TestCompileWithoutShared(t *testing.T) {
}()
}
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-gcflags=-shared=false", "-o", "libgo2.a", "./libgo2")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-gcflags=-shared=false", "-o", "libgo2.a", "./libgo2")
out, err := cmd.CombinedOutput()
t.Logf("%v\n%s", cmd.Args, out)
if err != nil {
@ -1204,7 +1204,7 @@ func TestManyCalls(t *testing.T) {
}()
}
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo7.a", "./libgo7")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo7.a", "./libgo7")
out, err := cmd.CombinedOutput()
t.Logf("%v\n%s", cmd.Args, out)
if err != nil {
@ -1259,7 +1259,7 @@ func TestPreemption(t *testing.T) {
}()
}
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo8.a", "./libgo8")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo8.a", "./libgo8")
out, err := cmd.CombinedOutput()
t.Logf("%v\n%s", cmd.Args, out)
if err != nil {
@ -1309,7 +1309,7 @@ func TestDeepStack(t *testing.T) {
}()
}
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo9.a", "./libgo9")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo9.a", "./libgo9")
out, err := cmd.CombinedOutput()
t.Logf("%v\n%s", cmd.Args, out)
if err != nil {
@ -1372,7 +1372,7 @@ func BenchmarkCgoCallbackMainThread(b *testing.B) {
}()
}
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo10.a", "./libgo10")
cmd := exec.Command(testenv.GoToolPath(b), "build", "-buildmode=c-archive", "-o", "libgo10.a", "./libgo10")
out, err := cmd.CombinedOutput()
b.Logf("%v\n%s", cmd.Args, out)
if err != nil {
@ -1414,7 +1414,7 @@ func TestSharedObject(t *testing.T) {
}()
}
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo_s.a", "./libgo")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-buildmode=c-archive", "-o", "libgo_s.a", "./libgo")
out, err := cmd.CombinedOutput()
t.Logf("%v\n%s", cmd.Args, out)
if err != nil {

View File

@ -407,7 +407,7 @@ func main() {
argv = append(argv, "-ldflags", "-extldflags=-Wl,--export-all-symbols")
}
argv = append(argv, "-o", objfile, srcfile)
out, err := exec.Command("go", argv...).CombinedOutput()
out, err := exec.Command(testenv.GoToolPath(t), argv...).CombinedOutput()
if err != nil {
t.Fatalf("build failure: %s\n%s\n", err, string(out))
}
@ -880,3 +880,44 @@ func TestIssue36233(t *testing.T) {
t.Error("missing functions")
}
}
func TestIssue68411(t *testing.T) {
globalSkip(t)
testenv.MustHaveCGO(t)
t.Parallel()
// Test that the export header uses a void function parameter for
// exported Go functions with no parameters.
tmpdir := t.TempDir()
const exportHeader = "issue68411.h"
run(t, nil, "go", "tool", "cgo", "-exportheader", exportHeader, "-objdir", tmpdir, "./issue68411/issue68411.go")
data, err := os.ReadFile(exportHeader)
if err != nil {
t.Fatal(err)
}
funcs := []struct{ name, signature string }{
{"exportFuncWithNoParams", "void exportFuncWithNoParams(void)"},
{"exportFuncWithParams", "exportFuncWithParams(GoInt a, GoInt b)"},
}
var found int
for line := range bytes.Lines(data) {
for _, fn := range funcs {
if bytes.Contains(line, []byte(fn.name)) {
found++
if !bytes.Contains(line, []byte(fn.signature)) {
t.Errorf("function signature mismatch; got %q, want %q", line, fn.signature)
}
}
}
}
if found != len(funcs) {
t.Error("missing functions")
}
}

View File

@ -0,0 +1,15 @@
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "C"
//export exportFuncWithNoParams
func exportFuncWithNoParams() {}
//export exportFuncWithParams
func exportFuncWithParams(a, b int) {}
func main() {}

View File

@ -81,7 +81,7 @@ func TestArgumentsPositions(t *testing.T) {
t.Fatal(err)
}
cmd := exec.Command("go", "tool", "cgo",
cmd := exec.Command(testenv.GoToolPath(t), "tool", "cgo",
"-srcdir", testdata,
"-objdir", dir,
"issue42580.go")

View File

@ -136,7 +136,7 @@ func TestBadSymbol(t *testing.T) {
makeFile(godir, "go.mod", "module badsym")
// Try to build our little package.
cmd := exec.Command("go", "build", "-ldflags=-v")
cmd := exec.Command(testenv.GoToolPath(t), "build", "-ldflags=-v")
cmd.Dir = godir
output, err := cmd.CombinedOutput()

View File

@ -76,7 +76,7 @@ func expect(t *testing.T, errors []*regexp.Regexp, files ...string) {
for _, file := range files {
args = append(args, path(file))
}
cmd := exec.Command("go", args...)
cmd := exec.Command(testenv.GoToolPath(t), args...)
out, err := cmd.CombinedOutput()
if err == nil {
t.Errorf("expected cgo to fail but it succeeded")
@ -105,10 +105,10 @@ func expect(t *testing.T, errors []*regexp.Regexp, files ...string) {
func sizeofLongDouble(t *testing.T) int {
testenv.MustHaveGoRun(t)
testenv.MustHaveCGO(t)
cmd := exec.Command("go", "run", path("long_double_size.go"))
cmd := exec.Command(testenv.GoToolPath(t), "run", path("long_double_size.go"))
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("%#q: %v:\n%s", strings.Join(cmd.Args, " "), err, out)
t.Fatalf("%#q: %v:\n%s", cmd, err, out)
}
i, err := strconv.Atoi(strings.TrimSpace(string(out)))
@ -158,11 +158,11 @@ func TestToleratesOptimizationFlag(t *testing.T) {
testenv.MustHaveCGO(t)
t.Parallel()
cmd := exec.Command("go", "build", path("issue14669.go"))
cmd := exec.Command(testenv.GoToolPath(t), "build", path("issue14669.go"))
cmd.Env = append(os.Environ(), "CGO_CFLAGS="+cflags)
out, err := cmd.CombinedOutput()
if err != nil {
t.Errorf("%#q: %v:\n%s", strings.Join(cmd.Args, " "), err, out)
t.Errorf("%#q: %v:\n%s", cmd, err, out)
}
})
}
@ -173,10 +173,10 @@ func TestMallocCrashesOnNil(t *testing.T) {
testenv.MustHaveGoRun(t)
t.Parallel()
cmd := exec.Command("go", "run", path("malloc.go"))
cmd := exec.Command(testenv.GoToolPath(t), "run", path("malloc.go"))
out, err := cmd.CombinedOutput()
if err == nil {
t.Logf("%#q:\n%s", strings.Join(cmd.Args, " "), out)
t.Logf("%#q:\n%s", cmd, out)
t.Fatalf("succeeded unexpectedly")
}
}

View File

@ -609,7 +609,7 @@ func buildPtrTests(t *testing.T, gopath string, cgocheck2 bool) (exe string) {
if cgocheck2 {
exeName = "ptrtest2.exe"
}
cmd := exec.Command("go", "build", "-o", exeName)
cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", exeName)
cmd.Dir = src
cmd.Env = append(os.Environ(), "GOPATH="+gopath)

View File

@ -75,7 +75,7 @@ func TestFortran(t *testing.T) {
// Finally, run the actual test.
t.Log("go", "run", "./testdata/testprog")
var stdout, stderr strings.Builder
cmd := exec.Command("go", "run", "./testdata/testprog")
cmd := exec.Command(testenv.GoToolPath(t), "run", "./testdata/testprog")
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err := cmd.Run()

View File

@ -51,7 +51,7 @@ func TestGoDefs(t *testing.T) {
}
for _, fp := range filePrefixes {
cmd := exec.Command("go", "tool", "cgo",
cmd := exec.Command(testenv.GoToolPath(t), "tool", "cgo",
"-godefs",
"-srcdir", testdata,
"-objdir", dir,
@ -60,7 +60,7 @@ func TestGoDefs(t *testing.T) {
out, err := cmd.Output()
if err != nil {
t.Fatalf("%s: %v\n%s", strings.Join(cmd.Args, " "), err, cmd.Stderr)
t.Fatalf("%#q: %v\n%s", cmd, err, cmd.Stderr)
}
fn := fp + "_defs.go"
@ -107,10 +107,10 @@ func TestGoDefs(t *testing.T) {
// instead of invoking 'go build' and the resulting binary separately, so that
// this test can pass on mobile builders, which do not copy artifacts back
// from remote invocations.
cmd := exec.Command("go", "run", ".")
cmd := exec.Command(testenv.GoToolPath(t), "run", ".")
cmd.Env = append(os.Environ(), "GOPATH="+gopath)
cmd.Dir = dir
if out, err := cmd.CombinedOutput(); err != nil {
t.Fatalf("%s [%s]: %v\n%s", strings.Join(cmd.Args, " "), dir, err, out)
t.Fatalf("%#q [%s]: %v\n%s", cmd, dir, err, out)
}
}

View File

@ -50,7 +50,7 @@ func TestTestRun(t *testing.T) {
testenv.MustHaveGoRun(t)
testenv.MustHaveCGO(t)
cmd := exec.Command("go", "run", "main.go")
cmd := exec.Command(testenv.GoToolPath(t), "run", "main.go")
got, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("%v: %s\n%s", cmd, err, got)

View File

@ -145,8 +145,8 @@ func goCmd(t *testing.T, op string, args ...string) string {
// escape converts a string to something suitable for a shell command line.
func escape(s string) string {
s = strings.Replace(s, "\\", "\\\\", -1)
s = strings.Replace(s, "'", "\\'", -1)
s = strings.ReplaceAll(s, "\\", "\\\\")
s = strings.ReplaceAll(s, "'", "\\'")
// Conservative guess at characters that will force quoting
if s == "" || strings.ContainsAny(s, "\\ ;#*&$~?!|[]()<>{}`") {
s = "'" + s + "'"
@ -194,10 +194,10 @@ func run(t *testing.T, bin string, args ...string) string {
out, err := cmd.Output()
if err != nil {
if t == nil {
log.Panicf("%s: %v\n%s", strings.Join(cmd.Args, " "), err, cmd.Stderr)
log.Panicf("%#q: %v\n%s", cmd, err, cmd.Stderr)
} else {
t.Helper()
t.Fatalf("%s: %v\n%s", strings.Join(cmd.Args, " "), err, cmd.Stderr)
t.Fatalf("%#q: %v\n%s", cmd, err, cmd.Stderr)
}
}
@ -245,7 +245,7 @@ func TestIssue18676(t *testing.T) {
cmd := exec.CommandContext(ctx, "./issue18676.exe")
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("%s: %v\n%s", strings.Join(cmd.Args, " "), err, out)
t.Fatalf("%#q: %v\n%s", cmd, err, out)
}
}

View File

@ -71,11 +71,11 @@ func TestASAN(t *testing.T) {
!strings.Contains(out, noSymbolizer) &&
compilerSupportsLocation() {
t.Errorf("%#q exited without expected location of the error\n%s; got failure\n%s", strings.Join(cmd.Args, " "), tc.errorLocation, out)
t.Errorf("%#q exited without expected location of the error\n%s; got failure\n%s", cmd, tc.errorLocation, out)
}
return
}
t.Fatalf("%#q exited without expected memory access error\n%s; got failure\n%s", strings.Join(cmd.Args, " "), tc.memoryAccessError, out)
t.Fatalf("%#q exited without expected memory access error\n%s; got failure\n%s", cmd, tc.memoryAccessError, out)
}
mustRun(t, cmd)
})

View File

@ -266,7 +266,12 @@ func compilerSupportsLocation() bool {
}
switch compiler.name {
case "gcc":
return compiler.major >= 10
// TODO(72752): the asan runtime support library
// (libasan.so.6) shipped with GCC 10 has problems digesting
// version 5 DWARF produced by the Go toolchain. Disable
// location checking if gcc is not sufficiently up to date in
// this case.
return compiler.major > 10
case "clang":
// TODO(65606): The clang toolchain on the LUCI builders is not built against
// zlib, the ASAN runtime can't actually symbolize its own stack trace. Once
@ -328,6 +333,12 @@ func compilerRequiredAsanVersion(goos, goarch string) bool {
}
}
// compilerRequiredLsanVersion reports whether the compiler is the
// version required by Lsan.
func compilerRequiredLsanVersion(goos, goarch string) bool {
return compilerRequiredAsanVersion(goos, goarch)
}
type compilerCheck struct {
once sync.Once
err error
@ -355,10 +366,18 @@ func configure(sanitizer string) *config {
return c
}
sanitizerOpt := sanitizer
// For the leak detector, we use "go build -asan",
// which implies the address sanitizer.
// We may want to adjust this someday.
if sanitizer == "leak" {
sanitizerOpt = "address"
}
c := &config{
sanitizer: sanitizer,
cFlags: []string{"-fsanitize=" + sanitizer},
ldFlags: []string{"-fsanitize=" + sanitizer},
cFlags: []string{"-fsanitize=" + sanitizerOpt},
ldFlags: []string{"-fsanitize=" + sanitizerOpt},
}
if testing.Verbose() {
@ -377,7 +396,7 @@ func configure(sanitizer string) *config {
c.ldFlags = append(c.ldFlags, "-fPIC", "-static-libtsan")
}
case "address":
case "address", "leak":
c.goFlags = append(c.goFlags, "-asan")
// Set the debug mode to print the C stack trace.
c.cFlags = append(c.cFlags, "-g")
@ -475,7 +494,7 @@ func (c *config) checkCSanitizer() (skip bool, err error) {
bytes.Contains(out, []byte("unsupported"))) {
return true, errors.New(string(out))
}
return true, fmt.Errorf("%#q failed: %v\n%s", strings.Join(cmd.Args, " "), err, out)
return true, fmt.Errorf("%#q failed: %v\n%s", cmd, err, out)
}
if c.sanitizer == "fuzzer" {
@ -485,10 +504,10 @@ func (c *config) checkCSanitizer() (skip bool, err error) {
if out, err := exec.Command(dst).CombinedOutput(); err != nil {
if os.IsNotExist(err) {
return true, fmt.Errorf("%#q failed to produce executable: %v", strings.Join(cmd.Args, " "), err)
return true, fmt.Errorf("%#q failed to produce executable: %v", cmd, err)
}
snippet, _, _ := bytes.Cut(out, []byte("\n"))
return true, fmt.Errorf("%#q generated broken executable: %v\n%s", strings.Join(cmd.Args, " "), err, snippet)
return true, fmt.Errorf("%#q generated broken executable: %v\n%s", cmd, err, snippet)
}
return false, nil
@ -523,13 +542,12 @@ func (c *config) checkRuntime() (skip bool, err error) {
return false, err
}
cmd.Args = append(cmd.Args, "-dM", "-E", "../../../../runtime/cgo/libcgo.h")
cmdStr := strings.Join(cmd.Args, " ")
out, err := cmd.CombinedOutput()
if err != nil {
return false, fmt.Errorf("%#q exited with %v\n%s", cmdStr, err, out)
return false, fmt.Errorf("%#q exited with %v\n%s", cmd, err, out)
}
if !bytes.Contains(out, []byte("#define CGO_TSAN")) {
return true, fmt.Errorf("%#q did not define CGO_TSAN", cmdStr)
return true, fmt.Errorf("%#q did not define CGO_TSAN", cmd)
}
return false, nil
}

Some files were not shown because too many files have changed in this diff Show More