]> Cypherpunks repositories - gostls13.git/log
gostls13.git
7 months agounique: don't retain uncloned input as key
Michael Anthony Knyszek [Wed, 4 Sep 2024 16:46:33 +0000 (16:46 +0000)]
unique: don't retain uncloned input as key

Currently the unique package tries to clone strings that get stored in
its internal map to avoid retaining large strings.

However, this falls over entirely due to the fact that the original
string is *still* stored in the map as a key. Whoops. Fix this by
storing the cloned value in the map instead.

This change also adds a test which fails without this change.

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

7 months agointernal/weak: shade pointer in weak-to-strong conversion
Michael Anthony Knyszek [Wed, 4 Sep 2024 03:08:26 +0000 (03:08 +0000)]
internal/weak: shade pointer in weak-to-strong conversion

There's a bug in the weak-to-strong conversion in that creating the
*only* strong pointer to some weakly-held object during the mark phase
may result in that object not being properly marked.

The exact mechanism for this is that the new strong pointer will always
point to a white object (because it was only weakly referenced up until
this point) and it can then be stored in a blackened stack, hiding it
from the garbage collector.

This "hide a white pointer in the stack" problem is pretty much exactly
what the Yuasa part of the hybrid write barrier is trying to catch, so
we need to do the same thing the write barrier would do: shade the
pointer.

Added a test and confirmed that it fails with high probability if the
pointer shading is missing.

Fixes #69210.

Change-Id: Iaae64ae95ea7e975c2f2c3d4d1960e74e1bd1c3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/610396
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>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

7 months agoruntime: size maps.Clone destination bucket array safely
Keith Randall [Thu, 29 Aug 2024 22:08:33 +0000 (15:08 -0700)]
runtime: size maps.Clone destination bucket array safely

In rare situations, like during same-sized grows, the source map for
maps.Clone may be overloaded (has more than 6.5 entries per
bucket). This causes the runtime to allocate a larger bucket array for
the destination map than for the source map. The maps.Clone code
walks off the end of the source array if it is smaller than the
destination array.

This is a pretty simple fix, ensuring that the destination bucket
array is never longer than the source bucket array. Maybe a better fix
is to make the Clone code handle shorter source arrays correctly, but
this fix is deliberately simple to reduce the risk of backporting this
fix.

Fixes #69110

Change-Id: I824c93d1db690999f25a3c43b2816fc28ace7509
Reviewed-on: https://go-review.googlesource.com/c/go/+/609757
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@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>
7 months agocmd/internal/obj: drop NOFRAME TODO
Michael Pratt [Wed, 4 Sep 2024 14:34:40 +0000 (10:34 -0400)]
cmd/internal/obj: drop NOFRAME TODO

NOFRAME is long since implemented beyond ppc64x.

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

7 months agocrypto/cipher: update documentation for aead Open
komuw [Wed, 28 Aug 2024 14:12:31 +0000 (14:12 +0000)]
crypto/cipher: update documentation for aead Open

The remaining capacity of dst should not overlap ciphertext.
The previous wording was probably a copy paste mistake from aead Seal.

Change-Id: Iaa28073f9ea90cbe2032c0c1149a78feab6c9239
GitHub-Last-Rev: fb54bc84c471648eb9d4c56492a8ff6d7db69b2b
GitHub-Pull-Request: golang/go#69108
Reviewed-on: https://go-review.googlesource.com/c/go/+/609075
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agomath: add large exact float rounding tests
Meng Zhuo [Wed, 24 Jul 2024 06:49:18 +0000 (14:49 +0800)]
math: add large exact float rounding tests

This CL adds trunc,ceil,floor tests for large exact float.

Change-Id: Ib7ffec1d2d50d2ac955398a3dd0fd06d494fcf4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/601095
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>
Reviewed-by: Keith Randall <khr@golang.org>
7 months agogo/printer: do not panic on *ast.ParenExpr in combinesWithName
Mateusz Poliwczak [Mon, 2 Sep 2024 12:37:51 +0000 (12:37 +0000)]
go/printer: do not panic on *ast.ParenExpr in combinesWithName

Fixes #69206

Change-Id: I1b5a664c22d5739e2c6748d562591f57345b536e
GitHub-Last-Rev: 1798e2c65b3c2c0c1ef674b000dce2636c834783
GitHub-Pull-Request: golang/go#69208
Reviewed-on: https://go-review.googlesource.com/c/go/+/610115
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
7 months agoencoding/xml: allow ]]> in attribute values
Demi Marie Obenour [Tue, 3 Sep 2024 01:33:29 +0000 (01:33 +0000)]
encoding/xml: allow ]]> in attribute values

This is permitted by the XML specification.

Fixes #68387

Change-Id: Ic4ab5520a08a5a997f1c3d13c6d5f80c0521e45c
GitHub-Last-Rev: 6d2ac307bbd0ba7d50830ad8b879c00cc3a7242b
GitHub-Pull-Request: golang/go#69197
Reviewed-on: https://go-review.googlesource.com/c/go/+/610056
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>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agoruntime: update comment for golinkname
Wei Fu [Mon, 2 Sep 2024 02:40:39 +0000 (10:40 +0800)]
runtime: update comment for golinkname

containerd deleted unsafe, golinkname usage from whole project in
the https://github.com/containerd/containerd/pull/10611. This patch is
to delete contained name in the comment.

Change-Id: Ide55ad9c65b3b622650a0b5813a7817306e87d3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/609996
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>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agoos/user: User.GroupIds shouldn't error on users with no groups
qmuntal [Mon, 19 Aug 2024 13:14:23 +0000 (15:14 +0200)]
os/user: User.GroupIds shouldn't error on users with no groups

On Windows, the User.GroupIds currently errors out if the user has no
groups. This is incorrect, as the user may not be a member of any groups
as demonstrated by the new TestGroupIdsTestUser test.

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-arm64
Change-Id: I436aa6214f2b98ef98dfb6064caec3d682b3f3d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/606675
Reviewed-by: Michael Pratt <mpratt@google.com>
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>
7 months agoos: treat Getwd result of ENOMEM the same as ENAMETOOLONG
Ian Lance Taylor [Tue, 3 Sep 2024 22:13:01 +0000 (15:13 -0700)]
os: treat Getwd result of ENOMEM the same as ENAMETOOLONG

We can see ENOMEM on FreeBSD.

Also don't fail the test if we get an EPERM error when reading
all the way up the tree; on Android we get that, perhaps because
the root directory is unreadable.

Also accept an EFAULT from a stat of a long name on Dragonfly,
which we see on the builders.

Change-Id: If37e6bf414b7b568c9a06130f71e79af153bfb75
Reviewed-on: https://go-review.googlesource.com/c/go/+/610415
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
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: Keith Randall <khr@google.com>
7 months agoall: use t.Chdir in tests
Kir Kolyshkin [Fri, 8 Sep 2023 00:21:16 +0000 (17:21 -0700)]
all: use t.Chdir in tests

Change-Id: I5bc514bedeb1155e6db52e37736fd6101774aea0
Reviewed-on: https://go-review.googlesource.com/c/go/+/529896
Auto-Submit: Ian Lance Taylor <iant@golang.org>
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>
Commit-Queue: Ian Lance Taylor <iant@golang.org>

7 months agocrypto/internal/bigmod: provide assembly addMulVVW* for loong64
Xiaolin Zhao [Wed, 19 Jun 2024 07:09:21 +0000 (15:09 +0800)]
crypto/internal/bigmod: provide assembly addMulVVW* for loong64

goos: linux
goarch: loong64
pkg: crypto/internal/bigmod
cpu: Loongson-3A6000 @ 2500.00MHz
               │  bench.old   │              bench.new              │
               │    sec/op    │   sec/op     vs base                │
ModAdd            159.5n ± 0%   159.8n ± 0%   +0.19% (p=0.000 n=20)
ModSub            161.5n ± 0%   161.7n ± 0%   +0.12% (p=0.038 n=20)
MontgomeryRepr    4.126µ ± 0%   2.932µ ± 0%  -28.94% (p=0.000 n=20)
MontgomeryMul     4.144µ ± 0%   2.930µ ± 0%  -29.30% (p=0.000 n=20)
ModMul            8.331µ ± 0%   5.956µ ± 0%  -28.51% (p=0.000 n=20)
ExpBig            11.65m ± 0%   11.64m ± 0%   -0.04% (p=0.000 n=20)
Exp              11.015m ± 0%   7.860m ± 0%  -28.65% (p=0.000 n=20)
geomean           17.34µ        14.28µ       -17.64%

goos: linux
goarch: loong64
pkg: crypto/internal/bigmod
cpu: Loongson-3A5000 @ 2500.00MHz
               │  bench.old   │              bench.new              │
               │    sec/op    │   sec/op     vs base                │
ModAdd            211.3n ± 0%   213.9n ± 0%   +1.23% (p=0.000 n=20)
ModSub            210.6n ± 0%   207.2n ± 0%   -1.61% (p=0.000 n=20)
MontgomeryRepr    5.442µ ± 0%   3.825µ ± 0%  -29.71% (p=0.000 n=20)
MontgomeryMul     5.379µ ± 0%   4.011µ ± 0%  -25.43% (p=0.000 n=20)
ModMul           10.868µ ± 0%   7.859µ ± 0%  -27.69% (p=0.000 n=20)
ExpBig            14.64m ± 0%   14.63m ± 0%   -0.06% (p=0.035 n=20)
Exp               14.39m ± 0%   10.38m ± 0%  -27.86% (p=0.000 n=20)
geomean           22.57µ        18.74µ       -16.96%

Change-Id: Id6ddc9552494e2a26e1a123f38e22d18bb78fdad
Reviewed-on: https://go-review.googlesource.com/c/go/+/593595
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
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>
7 months agocmd: use built-in clear for maps instead of range+delete
Keith Randall [Tue, 3 Sep 2024 20:53:37 +0000 (13:53 -0700)]
cmd: use built-in clear for maps instead of range+delete

Now that we're bootstrapping from a toolchain that has the clear builtin.

Update #64751

Change-Id: Ia86d96c253c9f7c66131cd02048a493047569641
Reviewed-on: https://go-review.googlesource.com/c/go/+/610237
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@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agocmd: use built-in min/max instead of bespoke versions
Keith Randall [Tue, 3 Sep 2024 20:29:42 +0000 (13:29 -0700)]
cmd: use built-in min/max instead of bespoke versions

Now that we're bootstrapping from a toolchain that has min/max builtins.

Update #64751

Change-Id: I63eedf3cca00f56f62ca092949cb2dc61db03361
Reviewed-on: https://go-review.googlesource.com/c/go/+/610355
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>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
7 months agocmd/compile: compute Negation's limits from argument's limits
Jorropo [Thu, 15 Aug 2024 02:54:46 +0000 (04:54 +0200)]
cmd/compile: compute Negation's limits from argument's limits

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

7 months agocmd/compile: compute Complement's limits from argument's limits
Jorropo [Wed, 14 Aug 2024 20:28:00 +0000 (22:28 +0200)]
cmd/compile: compute Complement's limits from argument's limits

I was not sure this was correct so I exhaustively checked all possibilities:
https://go.dev/play/p/hjmCLm4Iagz
https://go.dev/play/p/R9RuRGKwCbN

Change-Id: I85f053df825a4d77f978de42f8a1fcaf4b881def
Reviewed-on: https://go-review.googlesource.com/c/go/+/605696
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
7 months agocmd/compile: compute Trunc's limits from argument's limits
Jorropo [Wed, 14 Aug 2024 19:25:08 +0000 (21:25 +0200)]
cmd/compile: compute Trunc's limits from argument's limits

Change-Id: I419faa781db085b98ea25008ca127d0317fb34e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/605695
Reviewed-by: Keith Randall <khr@golang.org>
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>
Reviewed-by: Carlos Amedee <carlos@golang.org>
7 months agocmd/compile: propagate unsigned limits for Div and Mod if arguments are positive
Jorropo [Tue, 13 Aug 2024 16:40:44 +0000 (18:40 +0200)]
cmd/compile: propagate unsigned limits for Div and Mod if arguments are positive

I didn't implemented negative limits since prove is most useful for BCE which
should never be negative in the first place.

Change-Id: I302ee462cdc20bd4edff0618f7e49ff66fc2a007
Reviewed-on: https://go-review.googlesource.com/c/go/+/605136
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>
7 months agocmd: replace many sort.Interface with slices.Sort and SortFunc
Zxilly [Tue, 3 Sep 2024 17:46:10 +0000 (17:46 +0000)]
cmd: replace many sort.Interface with slices.Sort and SortFunc

with slices there's no need to implement sort.Interface

Change-Id: I59167e78881cb1df89a71e33d738d6aeca7adb71
GitHub-Last-Rev: 507ba84453f7305b6b2bf6317292111c00c93ffe
GitHub-Pull-Request: golang/go#68724
Reviewed-on: https://go-review.googlesource.com/c/go/+/602895
Reviewed-by: Ian Lance Taylor <iant@golang.org>
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@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
7 months agoall: omit unnecessary 0 in slice expression
nlwkobe30 [Fri, 30 Aug 2024 19:05:07 +0000 (19:05 +0000)]
all: omit unnecessary 0 in slice expression

All changes are related to the code, except for the comments in src/regexp/syntax/parse.go and src/slices/slices.go.

Change-Id: I73c5d3c54099749b62210aa7f3182c5eb84bb6a6
GitHub-Last-Rev: 794aa9b0539811d00e1cd42be1e8d9fe9afe0281
GitHub-Pull-Request: golang/go#69170
Reviewed-on: https://go-review.googlesource.com/c/go/+/609678
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: Ian Lance Taylor <iant@google.com>

7 months agounicode: improve SimpleFold performance by 2x for non-foldable code points
Charlie Vieth [Sat, 3 Dec 2022 03:53:26 +0000 (22:53 -0500)]
unicode: improve SimpleFold performance by 2x for non-foldable code points

Change SimpleFold to search the CaseRanges table only once when no
folding is specified for the rune (previously up to two searches could
be performed). This improves performance by 2x for runes that have no
folds or are already upper case. As a side effect this improves the
performance of To by roughly ~15%

goos: darwin
goarch: arm64
pkg: unicode
cpu: Apple M1 Max
                     │ base.10.txt  │             new.10.txt              │
                     │    sec/op    │   sec/op     vs base                │
ToUpper-10             11.860n ± 1%   9.731n ± 1%  -17.95% (p=0.000 n=10)
ToLower-10              12.31n ± 1%   10.34n ± 1%  -16.00% (p=0.000 n=10)
SimpleFold/Upper-10     19.16n ± 0%   15.98n ± 1%  -16.64% (p=0.000 n=10)
SimpleFold/Lower-10     32.41n ± 1%   17.09n ± 1%  -47.27% (p=0.000 n=10)
SimpleFold/Fold-10      8.884n ± 4%   8.856n ± 8%        ~ (p=0.700 n=10)
SimpleFold/NoFold-10    30.87n ± 0%   15.49n ± 3%  -49.84% (p=0.000 n=10)
geomean                 17.09n        12.47n       -26.99%

Change-Id: I6e5c7554106842955aadeef7b266c4c7944d3a97
Reviewed-on: https://go-review.googlesource.com/c/go/+/454958
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>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agoos: treat Getwd result of EINVAL/ERANGE the same as ENAMETOOLONG
Ian Lance Taylor [Tue, 3 Sep 2024 18:28:42 +0000 (11:28 -0700)]
os: treat Getwd result of EINVAL/ERANGE the same as ENAMETOOLONG

At least Darwin and OpenBSD seem to return EINVAL if the resulting
name would be too long. Solaris seems to return ERANGE.

Fixes #69233
Fixes #69234

Change-Id: I9b51d41461e9576c633bf2fc0e96ca3e4d986255
Reviewed-on: https://go-review.googlesource.com/c/go/+/609579
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: 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: Ian Lance Taylor <iant@golang.org>

7 months agoos: improve TestExecutable
Kir Kolyshkin [Fri, 30 Aug 2024 06:37:08 +0000 (23:37 -0700)]
os: improve TestExecutable

Instead of running all tests and relying on an init function, let's
embed the child code into the test case and only run one specific test.

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

7 months agosyscall: use t.TempDir in tests
Kir Kolyshkin [Fri, 30 Aug 2024 06:22:21 +0000 (23:22 -0700)]
syscall: use t.TempDir in tests

Change-Id: Ibeb00306ee8f038c11f261abd99c05324bf2ab51
Reviewed-on: https://go-review.googlesource.com/c/go/+/609837
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
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>

7 months agosyscall: use testenv.Executable
Kir Kolyshkin [Fri, 30 Aug 2024 05:24:30 +0000 (22:24 -0700)]
syscall: use testenv.Executable

Change-Id: I4390d4bfb7deb974df6546e30ebbb4b6fff74730
Reviewed-on: https://go-review.googlesource.com/c/go/+/609836
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
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>

7 months agomath,os,os/*: use testenv.Executable
Kir Kolyshkin [Fri, 30 Aug 2024 02:51:22 +0000 (19:51 -0700)]
math,os,os/*: use testenv.Executable

As some callers don't have a testing context, modify testenv.Executable
to accept nil (similar to how testenv.GOROOT works).

Change-Id: I39112a7869933785a26b5cb6520055b3cc42b847
Reviewed-on: https://go-review.googlesource.com/c/go/+/609835
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: Dmitri Shuralyov <dmitshur@google.com>
7 months agointernal/testenv: add missing t.Helper calls
Kir Kolyshkin [Fri, 30 Aug 2024 01:23:25 +0000 (18:23 -0700)]
internal/testenv: add missing t.Helper calls

...and move a few so they won't be called when not needed.

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

7 months agointernal/testenv: use sync.OnceValues for hasSymlink
Kir Kolyshkin [Fri, 30 Aug 2024 07:23:50 +0000 (00:23 -0700)]
internal/testenv: use sync.OnceValues for hasSymlink

On some platforms (android, wasip1) this function is called many
times which probably results in some slowdown, especially for wasip1.

Wrap it into sync.OnceValues.

Change-Id: Id290ffd8d1e7ad806302f457e8fff2e3123b49a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/609418
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>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agotesting: use testenv.Executable
Kir Kolyshkin [Fri, 30 Aug 2024 02:06:57 +0000 (19:06 -0700)]
testing: use testenv.Executable

Note that this changes some nuances of how the tests work:
 - some tests had a fallback to using os.Args[0], which is removed;
 - some tests skipped (rather than failed) the test upon getting an
   error from os.Executable.

I think these changes are not practically relevant.

Change-Id: I0655add6d959a8b7e3359f94c38203aa06e8f490
Reviewed-on: https://go-review.googlesource.com/c/go/+/609303
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agocmd: use testenv.Executable helper
Kir Kolyshkin [Fri, 30 Aug 2024 02:00:00 +0000 (19:00 -0700)]
cmd: use testenv.Executable helper

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

7 months agointernal/testenv: add Executable
Kir Kolyshkin [Fri, 30 Aug 2024 01:51:10 +0000 (18:51 -0700)]
internal/testenv: add Executable

Tests commonly use code to get os.Executable value, and some cache the
resulting value.

To reduce code duplication, add a helper that does just that.

Change-Id: I9dd7eb24e24a3abd92be2b87227e823f0fca5cb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/609301
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: Alan Donovan <adonovan@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agotesting: skip TestChdir/relative when on Windows when GOROOT and TMPDIR are on differ...
qiulaidongfeng [Sun, 1 Sep 2024 00:55:35 +0000 (00:55 +0000)]
testing: skip TestChdir/relative when on Windows when GOROOT and TMPDIR are on different drives

Fixes #69159

Change-Id: I0bbcf7075bdcf7a277a5053bcb543563a3074784
GitHub-Last-Rev: 86052a9ce32a871d6ad62f772f22852b2c6139a6
GitHub-Pull-Request: golang/go#69160
Reviewed-on: https://go-review.googlesource.com/c/go/+/609304
Reviewed-by: Damien Neil <dneil@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>

7 months agocmd/compile: compute Divu's limits from argument's limits
Jorropo [Tue, 13 Aug 2024 16:27:38 +0000 (18:27 +0200)]
cmd/compile: compute Divu's limits from argument's limits

Change-Id: Id522bde5bba627d9cdc8c3d8e907bdc168e5b13c
Reviewed-on: https://go-review.googlesource.com/c/go/+/605157
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
7 months agocmd/compile: compute Modu's maximum limits from argument's limits
Jorropo [Tue, 13 Aug 2024 15:17:06 +0000 (17:17 +0200)]
cmd/compile: compute Modu's maximum limits from argument's limits

addLocalFacts loop already ft.update which sets up limits correctly, but doing this in flowLimit help us since other values might depend on this limit.

Updates #68857

We could improve this further:
- remove mod alltogheter when we can prove a < b.
- we could do more adhoc computation in flowLimit to set umax and umin tighter

Change-Id: I5184913577b6a51a07cb53a6e6b73552a982de0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/605156
Reviewed-by: Keith Randall <khr@golang.org>
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>

7 months agocmd/compile: compute OR's maximum limits from argument's limits
Jorropo [Fri, 9 Aug 2024 14:35:46 +0000 (16:35 +0200)]
cmd/compile: compute OR's maximum limits from argument's limits

Change-Id: I6902c405cab7bd573f6a721a6ca7c783713ea39a
Reviewed-on: https://go-review.googlesource.com/c/go/+/604456
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>
7 months agocmd/compile: compute XOR's limits from argument's limits
Jorropo [Fri, 9 Aug 2024 13:45:39 +0000 (15:45 +0200)]
cmd/compile: compute XOR's limits from argument's limits

This help to optimize code like this:

  func f(buckets *[512]bucket, v value) {
    a, b := v.computeSomething()
    // assume a and b are proved < 512
    b := &buckets[a ^ b] // pick a random bucket
    b.store(v)
  }

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

7 months agocmd/compile: remove outdated comment in prove.go
Jorropo [Fri, 9 Aug 2024 13:22:28 +0000 (15:22 +0200)]
cmd/compile: remove outdated comment in prove.go

See the cases above all of theses are implemented (except XOR which has a blank case with comments).

Change-Id: I9e2994490dac89e86ba70c1abeb1af1cbcf032e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/604416
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>
7 months agocmd/compile: compute bits.TrailingZeros*'s limits from argument's limits
Jorropo [Wed, 7 Aug 2024 20:16:00 +0000 (22:16 +0200)]
cmd/compile: compute bits.TrailingZeros*'s limits from argument's limits

y := bits.TrailingZeros(x)
if y > bits.Len(x.umax)-1 {
 then must always be true 1 << y > x.umax which is impossible
}

Change-Id: Iab4fce1c2ef828bee3a8a4a977cbadb5f9333136
Reviewed-on: https://go-review.googlesource.com/c/go/+/603996
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: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
7 months agocmd/compile: do constant folding for BitLen*
Jorropo [Wed, 7 Aug 2024 19:40:43 +0000 (21:40 +0200)]
cmd/compile: do constant folding for BitLen*

Change-Id: I56c27d606b55ea882f4db264fd4735b0cccdf7c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/604015
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>
7 months agocmd/compile: compute bits.Len*'s limits from argument's limits
Jorropo [Wed, 7 Aug 2024 18:20:21 +0000 (20:20 +0200)]
cmd/compile: compute bits.Len*'s limits from argument's limits

Change-Id: Ie3c7e5eaba6a9a29389018625c4b784d07c6f173
Reviewed-on: https://go-review.googlesource.com/c/go/+/603537
Reviewed-by: David Chase <drchase@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>

7 months agogo/ast: remove unused code
qiulaidongfeng [Fri, 30 Aug 2024 01:13:44 +0000 (01:13 +0000)]
go/ast: remove unused code

Change-Id: I57a03961dc97d20224498a67687a8c8ecfbbb627
GitHub-Last-Rev: 07ca14263feb7476c7163cc4172b8d3b324d74e9
GitHub-Pull-Request: golang/go#69157
Reviewed-on: https://go-review.googlesource.com/c/go/+/609758
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: Ian Lance Taylor <iant@google.com>

7 months agoos: Getwd: fallback to slow method on ENAMETOOLONG
Kir Kolyshkin [Tue, 27 Aug 2024 06:04:40 +0000 (23:04 -0700)]
os: Getwd: fallback to slow method on ENAMETOOLONG

As of CL 257637, all currently supported platforms have syscall.Getwd
implemented, so the code which deduces wd by traversing up to root
directory is never used and thus can be removed.

Or, as it was suggested by Ian Lance Taylor in CL 607436 review
comments, it can be reused when syscall.Getwd returns ENAMETOOLONG
(which usually happens than the current working dir is longer than
syscall.PathMax).

Let's do that. The only caveat is, such a long path returned from Getwd
couldn't be used for any file-related operations (they will probably
fail with ENAMETOOLONG).

While at it:
 - make the stat(".") code conditional, slightly improving the
   performance on Unix when $PWD is not set;
 - reuse variables dir and err;
 - use openDirNolog instead of openFileNolog to obtain a dirfd;
 - ensure the errors returned are wrapped;
 - document the new functionality;
 - add test cases (which fail before this change).

Change-Id: I60f7a70e6ebb1751699416f587688a1a97305fd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/608635
Reviewed-by: Ian Lance Taylor <iant@google.com>
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>

7 months agoencoding/json: add embedded structs to the UnmarshalTypeError's Field
j2gg0s [Tue, 27 Aug 2024 14:35:59 +0000 (14:35 +0000)]
encoding/json: add embedded structs to the UnmarshalTypeError's Field

Including embedded struct inforamtion in error message.

Fixes #68941

Change-Id: I6a6f7d506104839a9a7cf1a2c3003272f5534a79
GitHub-Last-Rev: 717f680acafd3f6509c0495f9092e028be502750
GitHub-Pull-Request: golang/go#68966
Reviewed-on: https://go-review.googlesource.com/c/go/+/606956
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: Dmitri Shuralyov <dmitshur@google.com>
7 months agointernal/poll: check return value instead of errno for copy_file_range(2)
Andy Pan [Thu, 29 Aug 2024 05:01:12 +0000 (13:01 +0800)]
internal/poll: check return value instead of errno for copy_file_range(2)

There is one special case of (0, nil) indicating EOF where the updates
of zero to remain and written are redundant.

Change-Id: I017471657a9424fab88c72d14d3eb66d14a7e5c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/609297
Run-TryBot: Andy Pan <panjf2000@gmail.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>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agoos: update the linux minimal version and fix a typo for zero-copy
Andy Pan [Thu, 29 Aug 2024 04:58:35 +0000 (12:58 +0800)]
os: update the linux minimal version and fix a typo for zero-copy

Change-Id: Ia6a2768be0e044112831c278d88ff31ba3caa9f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/609298
Reviewed-by: Dmitri Shuralyov <dmitshur@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>
7 months agocmd/cgo: parallelize loadDefines calls
Michael Podtserkovskii [Thu, 18 Apr 2024 11:28:13 +0000 (12:28 +0100)]
cmd/cgo: parallelize loadDefines calls

```
export CC="zig cc -target x86_64-linux"
hyperfine '../pkg/tool/darwin_arm64/cgo -objdir /tmp net/cgo_linux.go net/cgo_resnew.go net/cgo_socknew.go net/cgo_unix_cgo.go net/cgo_unix_cgo_res.go'
```

**Before**
```
  Time (mean ± sig):      1.293 s ±  0.017 s    [User: 0.472 s, System: 0.451 s]
  Range (min ... max):    1.263 s ...  1.316 s    10 runs

```

**After**
```
  Time (mean ±sig):     986.5 ms ±  22.6 ms    [User: 487.0 ms, System: 519.5 ms]
  Range (min ... max):   950.7 ms ... 1022.2 ms    10 runs

```

The version after changes is 25% faster for 5 input files (std "net" package).
I also tried to make CC artifictially slower (wrapper with sleep 0.2) and it showes same 25% performance increase.

Change-Id: I7a26fdc8d8a23b0df9bc71d30b96e82e2ddb943b
Reviewed-on: https://go-review.googlesource.com/c/go/+/581336
Auto-Submit: Ian Lance Taylor <iant@google.com>
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>

7 months agonet: enable multipath TCP by default for listeners
Aperence [Wed, 28 Aug 2024 17:45:58 +0000 (17:45 +0000)]
net: enable multipath TCP by default for listeners

A previous change [1] was introduced to enable MPTCP by default
for both the clients and servers, based on the discussions [2] in
golang#56539, where MPTCP would be an opt-in for a release or
two, and then would become an opt-out.

This change was not accepted at the time because the support for
a few socket options was missing [3]. Now that this support has been
added [4] and backported to stable versions not to block MPTCP
deployment with Go, it sounds like a good time to reconsider the use
of MPTCP by default.

Instead of enabling MPTCP on both ends by default, as a first step,
it seems safer to change the default behaviour only for the server
side (Listeners). On the server side, the impact is minimal: when
clients don't request to use MPTCP, server applications will create
"plain" TCP sockets within the kernel when connections are accepted,
making the performance impact minimal. This should also ease
experiments where MPTCP is enabled by default on the client side
(Dialer).

The changes in this patch consist of a duplication of the mptcpStatus
enumeration to have both a mptcpStatusDial and a mptcpStatusListen,
where MPTCP is enabled by default in mptcpStatusListen, but disabled
by default in mptcpStatusDial. It is still possible to turn MPTCP support
on and off by using GODEBUG=multipathtcp=1.

[1] https://go-review.googlesource.com/c/go/+/563575
[2] https://go.dev/issue/56539#issuecomment-1309294637
[3] https://github.com/multipath-tcp/mptcp_net-next/issues/383
[4] https://github.com/torvalds/linux/commit/bd11dc4fb969ec148e50cd87f88a78246dbc4d0b
[5] https://www.mptcp.dev/faq.html#why--when-should-mptcp-be-enabled-by-default

Updates #56539

Change-Id: I1ca0d6aaf74d3bda5468af135e29cdb405d3fd00
GitHub-Last-Rev: 5f9f29bfc13ad4ea6bfd1e0fc95a91bd824f4048
GitHub-Pull-Request: golang/go#69016
Reviewed-on: https://go-review.googlesource.com/c/go/+/607715
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>
Reviewed-by: Matthieu Baerts <matttbe@kernel.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

8 months agocontext: document that WithValue returns a derived context
Ian Lance Taylor [Sun, 18 Aug 2024 00:53:19 +0000 (17:53 -0700)]
context: document that WithValue returns a derived context

Also replace "copy of parent" with "derived context" in doc comments.

Fixes #68923

Change-Id: I319c1594f390e35b32b4e58ee979927bb84bfdf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/606555
Reviewed-by: Sameer Ajmani <sameer@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Sameer Ajmani <sameer@golang.org>
Commit-Queue: 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>

8 months agoimage: use Rectangle{} instead of ZR
tomocy [Thu, 29 Aug 2024 12:47:40 +0000 (12:47 +0000)]
image: use Rectangle{} instead of ZR

ZR is deprecated,
so replace it with the literal Rectangle to represent the zero value.

Change-Id: I68c0ffec808eaed1e8c352bf364d295c0041594e
GitHub-Last-Rev: 850472888d3d0f5e68feb9ec09f0b544fe1f9446
GitHub-Pull-Request: golang/go#69136
Reviewed-on: https://go-review.googlesource.com/c/go/+/609516
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Nigel Tao <nigeltao@google.com>
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>
8 months agoos: dup pidfd if caller sets PidFD manually
Wei Fu [Thu, 22 Aug 2024 08:22:53 +0000 (16:22 +0800)]
os: dup pidfd if caller sets PidFD manually

Fixes #68984
Change-Id: I16d25777cb38a337cd4204a8147eaf866c3df9e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/607695
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

8 months agodoc: fix wording of GODEBUG history item from CL 606055
Paschalis T [Fri, 30 Aug 2024 20:24:40 +0000 (23:24 +0300)]
doc: fix wording of GODEBUG history item from CL 606055

Change-Id: Ia53d4a58810948d83a3e87e08239602da1bad815
Reviewed-on: https://go-review.googlesource.com/c/go/+/609935
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>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Cherry Mui <cherryyz@google.com>

8 months agocmd/dist: do not rewrite "any" -> "interface{}"
Cuong Manh Le [Fri, 30 Aug 2024 17:26:37 +0000 (00:26 +0700)]
cmd/dist: do not rewrite "any" -> "interface{}"

Since go1.22, generic can now be used when building bootstrap toolchain.

Updates #54265
Updates #64751

Change-Id: I93209fc23c92114d37ef36787ea2b520de3ed89d
Reviewed-on: https://go-review.googlesource.com/c/go/+/609915
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agosyscall: honor prlimit set by a different process
Ian Lance Taylor [Wed, 21 Aug 2024 20:43:42 +0000 (13:43 -0700)]
syscall: honor prlimit set by a different process

On Linux one process can call prlimit to change the resource limit
of another process. With this change we treat that as though the
current process called prlimit (or setrlimit) to set its own limit.
The cost is one additional getrlimit system call per fork/exec,
for cases in which the rlimit Cur and Max values differ at startup.

This revealed a bug: the setrlimit (not Setrlimit) function should not
change the cached rlimit. That means that it must call prlimit1, not prlimit.

Fixes #66797

Change-Id: I46bfd06e09ab7273fe8dd9b5b744dffdf31d828b
Reviewed-on: https://go-review.googlesource.com/c/go/+/607516
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Aleksa Sarai <cyphar@cyphar.com>
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

8 months agoencoding/base32, encoding/base64: document Decode to short buffer
Ian Lance Taylor [Thu, 22 Aug 2024 20:47:13 +0000 (13:47 -0700)]
encoding/base32, encoding/base64: document Decode to short buffer

Document that if one of the Decode methods in these packages is given
a short buffer, it panics.

Fixes #69024

Change-Id: I1c0e4c74274965c1cfa0422cc8f86af4fefb1d00
Reviewed-on: https://go-review.googlesource.com/c/go/+/607499
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agosyscall: always use prlimit for getrlimit/setrlimit on Linux
Ian Lance Taylor [Wed, 28 Aug 2024 23:20:44 +0000 (16:20 -0700)]
syscall: always use prlimit for getrlimit/setrlimit on Linux

Linux added the prlimit system call in version 2.6.36.
As our minimum Linux kernel version is now 3.2,
simplify the various getrlimit/setlrimit implementations
to just always use prlimit.

For #67001

Change-Id: I2512c21c947d0bc83f8f9077c143163fd8d83be3
Reviewed-on: https://go-review.googlesource.com/c/go/+/609178
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/cgo: correct padding required by alignment
Ian Lance Taylor [Tue, 27 Aug 2024 17:19:17 +0000 (10:19 -0700)]
cmd/cgo: correct padding required by alignment

If the aligned offset isn't sufficient for the field offset,
we were padding based on the aligned offset. We need to pad
based on the original offset instead.

Also set the Go alignment correctly for int128. We were defaulting
to the maximum alignment, but since we translate int128 into an
array of uint8 the correct Go alignment is 1.

Fixes #69086

Change-Id: I23ce583335c81beac2ac51f7f9336ac97ccebf09
Reviewed-on: https://go-review.googlesource.com/c/go/+/608815
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>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

8 months agomisc/wasm: move wasm runtime files to lib/wasm
Zxilly [Sat, 24 Aug 2024 08:39:47 +0000 (08:39 +0000)]
misc/wasm: move wasm runtime files to lib/wasm

Fixes #68024

Change-Id: I730c3ecfb14472f3eea3895c2a4d5e1d4ac146f5
GitHub-Last-Rev: 4242f360103ba1fd1f4085b8257ccce0f07a68e5
GitHub-Pull-Request: golang/go#68840
Reviewed-on: https://go-review.googlesource.com/c/go/+/604696
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
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@golang.org>
8 months agodebug/macho: fix DWARF for section names longer than 16 chars
Alessandro Arzilli [Wed, 28 Aug 2024 08:16:10 +0000 (10:16 +0200)]
debug/macho: fix DWARF for section names longer than 16 chars

The Mach-O file format truncates section names to 16 characters
maximum, which makes some sections unrecognizable to debug/dwarf.
This CL works around this problem by re-expanding the truncated section
names.

This problem was originally reported as:
https://github.com/go-delve/delve/issues/3797

Change-Id: I8c4a02493b8d5c3f63c831da43f6292124edf670
Reviewed-on: https://go-review.googlesource.com/c/go/+/608995
Auto-Submit: Ian Lance Taylor <iant@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: Cherry Mui <cherryyz@google.com>
8 months agointernal/testenv: simplify hasSymlink for windows
Kir Kolyshkin [Fri, 30 Aug 2024 00:35:13 +0000 (17:35 -0700)]
internal/testenv: simplify hasSymlink for windows

1. Combine two functions into one.

2. Use errors.Is to check for wrapped errors.

3. Use sync.OnceValues.

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

8 months agointernal/testenv: use sync.OnceValue[s]
Kir Kolyshkin [Fri, 30 Aug 2024 00:31:03 +0000 (17:31 -0700)]
internal/testenv: use sync.OnceValue[s]

Modernize the code to use sync.OnceValue[s] instead of sync.Once.

While at it, reuse the result of exec.LookPath("go") in tryGoBuild.

Change-Id: I13eff3dd55797846680e506fffb7c49c8296829d
Reviewed-on: https://go-review.googlesource.com/c/go/+/609796
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agointernal/testenv: MustHaveExec: use sync.OnceValue
Kir Kolyshkin [Thu, 29 Aug 2024 23:46:16 +0000 (16:46 -0700)]
internal/testenv: MustHaveExec: use sync.OnceValue

Change-Id: I048474fc93bb8c149672b66f98d71eec0eb8aad7
Reviewed-on: https://go-review.googlesource.com/c/go/+/609795
Reviewed-by: 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>
Auto-Submit: Ian Lance Taylor <iant@google.com>

8 months agocmd/go/testdata/script: add a test case for issue #68658
Michael Matloob [Thu, 29 Aug 2024 18:11:15 +0000 (14:11 -0400)]
cmd/go/testdata/script: add a test case for issue #68658

Test that go files with a //go:build fileVersion earlier than go1.21
don't downgrade past go1.21.

Fixes #68658

Change-Id: If16a1b3867ad2cfa8867e60995f7d1eb801306e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/609436
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agoos/exec: document interaction of Dir, PWD, os.Getwd and C
Alan Donovan [Wed, 28 Aug 2024 22:13:05 +0000 (18:13 -0400)]
os/exec: document interaction of Dir, PWD, os.Getwd and C

Fixes #68000

Change-Id: Ie70a8ecc9573b2a4cf57119bda57e0af5e16c42f
Reviewed-on: https://go-review.googlesource.com/c/go/+/609395
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agonet/http: add HTTP2Config
Damien Neil [Tue, 4 Jun 2024 18:06:44 +0000 (11:06 -0700)]
net/http: add HTTP2Config

Add a field to Server and Transport containing HTTP/2 configuration
parameters.

This field will have no effect until golang.org/x/net/http2 is updated
to make use of it, and h2_bundle.go is updated with the new http2
package.

For #67813

Change-Id: I81d7f8e9ddea78f9666383983aec43e3884c13ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/602175
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
8 months agocmd: vendor golang.org/x/telemetry@a797f33
Rob Findley [Wed, 28 Aug 2024 20:32:37 +0000 (20:32 +0000)]
cmd: vendor golang.org/x/telemetry@a797f33

Update x/telemetry to fix #68976 and #68946.

Commands run:
  go get golang.org/x/telemetry@a797f33
  go mod tidy
  go mod vendor

Fixes #68946
Fixes #68946

Change-Id: I321ce609b41ef210a19150dce1f07b204e7c118e
Reviewed-on: https://go-review.googlesource.com/c/go/+/609237
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
8 months agointernal/cpu, runtime: make linux/loong64 HWCAP data available
WANG Xuerui [Wed, 5 Apr 2023 07:56:42 +0000 (15:56 +0800)]
internal/cpu, runtime: make linux/loong64 HWCAP data available

This can be used to toggle runtime usages of ISA extensions as such
usages appear.

Only the CRC32 bit is exposed for now, as the others are not going to be
utilized in the standard library for a while.

Change-Id: I774032ca84dc8bcf1c9f17558917315af07c7314
Reviewed-on: https://go-review.googlesource.com/c/go/+/482416
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: xiaodong liu <teaofmoli@gmail.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>
8 months agocmd/compile/internal/noder: write V2 bitstream aliastypeparams=1
Tim King [Mon, 26 Aug 2024 22:49:09 +0000 (15:49 -0700)]
cmd/compile/internal/noder: write V2 bitstream aliastypeparams=1

Enables V2 unified IR bitstreams when GOEXPERIMENT aliastypeparams
are enabled.

Allows pkgbits.NewPkgEncoder to set the output version.
Reenables support for writing V0 streams.

Updates #68778
Updates #68526

Change-Id: I590c494d81ab7db148232ceaba52229068d1e986
Reviewed-on: https://go-review.googlesource.com/c/go/+/608595
Reviewed-by: David Chase <drchase@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>
8 months agoslices: clarify Insert behavior if i == len(s)
Ian Lance Taylor [Wed, 28 Aug 2024 16:33:49 +0000 (09:33 -0700)]
slices: clarify Insert behavior if i == len(s)

Fixes #69104

Change-Id: Ie928239d5ef198ce36759ec4cffb7f6320ff3b82
Reviewed-on: https://go-review.googlesource.com/c/go/+/609175
Reviewed-by: Eli Bendersky <eliben@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>

8 months agocmd/go: print the proper error message for setting telemetry vars
Michael Matloob [Wed, 28 Aug 2024 15:15:32 +0000 (11:15 -0400)]
cmd/go: print the proper error message for setting telemetry vars

For #68960

Change-Id: I5495b3d45ad3817d7edf6336a5e24a331d5cf8d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/609115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
8 months agocmd/compile/internal/ssa: combine shift and addition for riscv64 rva22u64
Joel Sing [Mon, 19 Aug 2024 13:54:17 +0000 (23:54 +1000)]
cmd/compile/internal/ssa: combine shift and addition for riscv64 rva22u64

When GORISCV64 enables rva22u64, combined shift and addition using the
SH1ADD, SH2ADD and SH3ADD instructions that are available via the Zba
extension. This results in more than 2000 instructions being removed
from the Go binary on riscv64.

Change-Id: Ia62ae7dda3d8083cff315113421bee73f518eea8
Reviewed-on: https://go-review.googlesource.com/c/go/+/606636
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
8 months agogo/types, types2: use max(fileVersion, go1.21) if fileVersion present
Michael Matloob [Fri, 16 Aug 2024 19:13:39 +0000 (15:13 -0400)]
go/types, types2: use max(fileVersion, go1.21) if fileVersion present

Change the rules for how //go:build "file versions" are applied: instead
of considering whether a file version is an upgrade or downgrade from
the -lang version, always use max(fileVersion, go1.21). This prevents
file versions from downgrading the version below go1.21.  Before Go 1.21
the //go:build version did not have the meaning of setting the file's
langage version.

This fixes an issue that was appearing in GOPATH builds: Go 1.23.0
started providing -lang versions to the compiler in GOPATH mode (among
other places) which it wasn't doing before, and it set -lang to the
toolchain version (1.23). Because the -lang version was greater than
go1.21, language version used to compile the file would be set to the
//go:build file version. //go:build file versions below 1.21 could cause
files that could previously build to stop building.

For example, take a Go file with a //go:build line specifying go1.10.
If that file used a 1.18 feature, that use would compile fine with a Go
1.22 toolchain. But it would produce an error when compiling with the
1.23.0 toolchain because it set the language version to 1.10 and
disallowed the 1.18 feature. This breaks backwards compatibility: when
the build tag was added, it did not have the meaning of restricting the
language version.

For #68658

Change-Id: I6cedda81a55bcccffaa3501eef9e2be6541b6ece
Reviewed-on: https://go-review.googlesource.com/c/go/+/607955
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
8 months agoruntime: store bp on cgocallback as unsafe.Pointer
Michael Anthony Knyszek [Tue, 27 Aug 2024 15:34:10 +0000 (15:34 +0000)]
runtime: store bp on cgocallback as unsafe.Pointer

As of CL 580255, the runtime tracks the frame pointer (or base pointer,
bp) when entering syscalls, so that we can use fpTracebackPCs on
goroutines that are sitting in syscalls. That CL mostly got things
right, but missed one very subtle detail.

When calling from Go->C->Go, the goroutine stack performing the calls
when returning to Go is free to move around in memory due to growth,
shrinking, etc. But upon returning back to C, it needs to restore
gp.syscall*, including gp.syscallsp and gp.syscallbp. The way syscallsp
currently gets updated is automagically: it's stored as an
unsafe.Pointer on the stack so that it shows up in a stack map. If the
stack ever moves, it'll get updated correctly. But gp.syscallbp isn't
saved to the stack as an unsafe.Pointer, but rather as a uintptr, so it
never gets updated! As a result, in rare circumstances, fpTracebackPCs
can correctly try to use gp.syscallbp as the starting point for the
traceback, but the value is stale.

This change fixes the problem by just storing gp.syscallbp to the stack
on cgocallback as an unsafe.Pointer, like gp.syscallsp. It also adds a
comment documenting this subtlety; the lack of explanation for the
unsafe.Pointer type on syscallsp meant this detail was missed -- let's
not miss it again in the future.

Now, we have a fix, what about a test? Unfortunately, testing this is
going to be incredibly annoying because the circumstances under which
gp.syscallbp are actually used for traceback are non-deterministic and
hard to arrange, especially from within testprogcgo where we don't have
export_test.go and can't reach into the runtime.

So, instead, add a gp.syscallbp check to reentersyscall and
entersyscallblock that mirrors the gp.syscallbp consistency check. This
probably causes some miniscule slowdown to the syscall path, but it'll
catch the issue without having to actually perform a traceback.

Fixes #69085.

Change-Id: Iaf771758f1666024b854f5fbe2b2c63cbe35b201
Reviewed-on: https://go-review.googlesource.com/c/go/+/608775
Reviewed-by: Nick Ripley <nick.ripley@datadoghq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
8 months agohtml/template: track continue nodes correctly when escaping
cuishuang [Fri, 23 Aug 2024 17:23:24 +0000 (01:23 +0800)]
html/template: track continue nodes correctly when escaping

Fixes #69076

Change-Id: I1a16675c466722f44d0734e95d3c8111e33ff580
Reviewed-on: https://go-review.googlesource.com/c/go/+/607736
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Zxilly Chou <zxilly@outlook.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agonet/http: simplify http.Request.Clone
Jes Cok [Mon, 26 Aug 2024 13:33:06 +0000 (13:33 +0000)]
net/http: simplify http.Request.Clone

By using maps.Clone and omitting nil checks when calling
http.Header.Clone.

I'm not using slices.Clone because the result of slices.Clone
may have additional unused capacity.

Change-Id: I4aed0fea218404c7270e35324e6bd62d855296c7
GitHub-Last-Rev: 9fd5dd59078c69c9a8057f6fc4a90f7c6aac893b
GitHub-Pull-Request: golang/go#69070
Reviewed-on: https://go-review.googlesource.com/c/go/+/608295
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agodebug/buildinfo: stop searchMagic search at EOF
Michael Pratt [Tue, 27 Aug 2024 15:13:46 +0000 (11:13 -0400)]
debug/buildinfo: stop searchMagic search at EOF

An invalid executable may claim to have a data section bigger than the
executable, causing readData in searchMagic to hit EOF. Since readData
suppresses all EOF errors, searchData would keep attempting to search
through a potentially huge "section" despite readData continuously
failing.

Fix by suppressing EOF only on partial read. If nothing is read, allow
EOF. Note that most of the admittedly tedious EOF handling in this
package is around ensuring we return errNotGoExe in most cases.

This was discovered by the new fuzz test. This fuzz test was inspired
by #69066, though it has not found that specific bug.

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

8 months agocmd/dist: update tryDirs list to match make scripts
Dmitri Shuralyov [Tue, 20 Aug 2024 23:12:19 +0000 (19:12 -0400)]
cmd/dist: update tryDirs list to match make scripts

The $HOME/sdk/go1.17 and $HOME/go1.17 paths were initially added as
places to look for a bootstrap toolchain to make.{bash,bat,rc} scripts
and in cmd/dist (CL 370274). Those two go1.17 directories have since
been updated in the make scripts to go1.20.6 (CL 512275) and later on
to go1.22.6 (CL 606156), but the same list in cmd/dist was missed.

Fix the inconsistency now. But maybe cmd/dist doesn't need to maintain
this logic, if it's required to be invoked via one of the make scripts,
since they're responsible for setting GOROOT_BOOTSTRAP?

For #64751.

Change-Id: I0988005c559014791363138f2f722cc1f9a78bcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/607821
Reviewed-by: 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>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

8 months agodebug/buildinfo: don't crash on corrupt object file
Ian Lance Taylor [Mon, 26 Aug 2024 22:17:07 +0000 (15:17 -0700)]
debug/buildinfo: don't crash on corrupt object file

If the length reported for the object file is more than the amount of
data we actually read, then the count can tell us that there is
sufficient remaining data but the slice operation can fail.

No test case because the problem can only happen for invalid data.
Let the fuzzer find cases like this.

Fixes #69066

Change-Id: I8d12ca8ade3330517ade45c7578b477772b7efd2
Reviewed-on: https://go-review.googlesource.com/c/go/+/608517
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>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
8 months agocmd/compile/internal/ssagen: add check for duplicate intrinsics
Joel Sing [Sun, 4 Aug 2024 14:33:25 +0000 (00:33 +1000)]
cmd/compile/internal/ssagen: add check for duplicate intrinsics

Add a check to ensure that intrinsics are not being overwritten.
Remove two S390X intrinsics that are being replaced by aliases and
are therefore ineffective.

Change-Id: I4187a169c14ca75c45a67f41a1d626d76b82bb72
Reviewed-on: https://go-review.googlesource.com/c/go/+/605479
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>
Reviewed-by: Keith Randall <khr@golang.org>
8 months agocmd/compile/internal/ssagen: improve intrinsic test
Joel Sing [Thu, 15 Aug 2024 15:17:05 +0000 (01:17 +1000)]
cmd/compile/internal/ssagen: improve intrinsic test

Now that we can pass configuration to initIntrinsics, clean up the
intrinsic test and always enable power10. Additionally, provide an
-update flag that prints out updated golden values.

Change-Id: Ibfef339d513a4d67d53a5a310a82165592ca338f
Reviewed-on: https://go-review.googlesource.com/c/go/+/607055
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>
8 months agocmd/compile/internal/ssagen: provide intrinsicBuilders
Joel Sing [Sat, 3 Aug 2024 18:45:14 +0000 (04:45 +1000)]
cmd/compile/internal/ssagen: provide intrinsicBuilders

Create an intrinsicBuilders type that has functions for adding and
looking up intrinsics. This makes the implementation more self contained,
readable and testable. Additionally, pass an *intrinsicBuildConfig to
initIntrinsics to improve testability without needing to modify package
level variables.

Change-Id: I0ee0a19c192dd6da9f1c5f1c29b98a3ad8161fe2
Reviewed-on: https://go-review.googlesource.com/c/go/+/605478
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Joel Sing <joel@sing.id.au>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
8 months agoos/user: test that Current does not depend on netapi32.dll
qmuntal [Fri, 9 Aug 2024 08:57:51 +0000 (10:57 +0200)]
os/user: test that Current does not depend on netapi32.dll

Updates #21867.

Change-Id: I1eb923ef66aa0f338bfa0d683159edc1d8ae2a6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/604415
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
8 months agocmd/compile: regalloc: drop values that aren't used until after a call
Keith Randall [Wed, 12 Jul 2023 22:31:25 +0000 (15:31 -0700)]
cmd/compile: regalloc: drop values that aren't used until after a call

No point in keeping values in registers when their next use is after
a call, as we'd have to spill/restore them anyway.

cmd/go is 0.1% smaller.

Fixes #59297

Change-Id: I10ee761d0d23229f57de278f734c44d6a8dccd6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/509255
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
8 months agocmd/go: avoid making some paths relative in go work use
Michael Matloob [Mon, 5 Aug 2024 20:10:14 +0000 (16:10 -0400)]
cmd/go: avoid making some paths relative in go work use

filepath.Rel can sometimes return the a relative path that doesn't work.
If the basepath contains a symlink as a path component, and the targpath
does not exist with the directory pointed to by the innermost symlink,
the relative path can "cross" the symlink. The issue is that for the
return value for filepath.Rel to be correct, the ".." components of the
relative path would need to be collapsed before the symlinks are
expanded, but it was verified by doing local testing that the opposite
is true.

go work use (and cmd/go/internal/modload.ReadModFile) both try to
shorten absolute path arguments to relative paths from the working
directory (for better error messages, for instance). Avoid doing so when
the relative path could be wrong using a more conservative rule than the
above: if expanding the symlinks in the current directory produces a
different result, and the relative path we'd return starts with ".." and
then the path separator.

Fixes #68383

Change-Id: I0a6202be672484d4000fc753c69f2165615f3f72
Reviewed-on: https://go-review.googlesource.com/c/go/+/603136
TryBot-Bypass: Michael Matloob <matloob@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agogo/internal/gcimporter: parse materialized aliases
Tim King [Thu, 22 Aug 2024 20:38:25 +0000 (13:38 -0700)]
go/internal/gcimporter: parse materialized aliases

Parse materialized aliases in indexed format.

This was in https://go.dev/cl/574717 in x/tools.

Updates #68778

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

8 months agocmd/go: scale go list with GOMAXPROCS
goto1134 [Mon, 26 Aug 2024 19:27:00 +0000 (19:27 +0000)]
cmd/go: scale go list with GOMAXPROCS

Benchmark from the go-list-benchmark branch shows the following result:

goos: darwin
goarch: arm64
pkg: cmd/go
cpu: Apple M1 Max
                     │   old.txt   │               new.txt               │
                     │   sec/op    │   sec/op     vs base                │
ListModules/Empty-10   7.768m ± 5%   7.768m ± 6%        ~ (p=0.989 n=20)
ListModules/Cmd-10     272.3m ± 2%   137.8m ± 2%  -49.40% (p=0.000 n=20)
ListModules/K8S-10     10.741 ± 2%    2.525 ± 5%  -76.49% (p=0.000 n=20)
geomean                283.2m        139.3m       -50.82%

                     │   old.txt    │               new.txt               │
                     │  sys-sec/op  │  sys-sec/op   vs base               │
ListModules/Empty-10   2.380m ±  9%   2.443m ±  9%       ~ (p=0.314 n=20)
ListModules/Cmd-10     51.84m ± 13%   47.27m ± 14%       ~ (p=0.289 n=20)
ListModules/K8S-10      1.660 ±  8%    1.485 ± 28%       ~ (p=0.512 n=20)
geomean                58.95m         55.56m        -5.75%

                     │   old.txt    │               new.txt                │
                     │ user-sec/op  │ user-sec/op   vs base                │
ListModules/Empty-10   3.034m ±  4%   3.053m ±  3%        ~ (p=0.445 n=20)
ListModules/Cmd-10     18.01m ± 11%   15.39m ±  5%  -14.55% (p=0.000 n=20)
ListModules/K8S-10     407.6m ± 11%   209.2m ± 49%  -48.67% (p=0.000 n=20)
geomean                28.13m         21.42m        -23.86%

Fixes #63136

Change-Id: Ifd406a52494eb37430306ee1f29a8bf5c1973007
GitHub-Last-Rev: eba40c944e8a8c57c11fa075e98e1ee5420be1a8
GitHub-Pull-Request: golang/go#63137
Reviewed-on: https://go-review.googlesource.com/c/go/+/530037
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/compile: deprecate derived info needed field
Cuong Manh Le [Sun, 25 Aug 2024 14:06:49 +0000 (21:06 +0700)]
cmd/compile: deprecate derived info needed field

This field is unused since shape-based stenciling was added for Unified
IR (CL 421821). The derived types information is now explicitly using
derived-type dictionaries (CL 331829).

This CL follows the pattern used in CL 606035.

Updates #68778

Change-Id: Ie784b6443c0a651854bfbcebb8a5166b1481408b
Reviewed-on: https://go-review.googlesource.com/c/go/+/608216
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Tim King <taking@google.com>
8 months agointernal/pkgbits: add DerivedInfoNeeded
Cuong Manh Le [Sun, 25 Aug 2024 14:05:00 +0000 (21:05 +0700)]
internal/pkgbits: add DerivedInfoNeeded

So next CL can use it to remove unnecessary derivedInfo needed field.

Updates #68778

Change-Id: Ia4e0f638beaf4a448fbf10a9aa1bc9425349a5e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/608215
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/compile: intrinsify math.MulUintptr on PPC64
Paul E. Murphy [Wed, 27 Mar 2024 21:03:11 +0000 (16:03 -0500)]
cmd/compile: intrinsify math.MulUintptr on PPC64

This can be done efficiently with few instructions.

This also adds MULHDUCC for further codegen improvement.

Change-Id: I06320ba4383a679341b911a237a360ef07b19168
Reviewed-on: https://go-review.googlesource.com/c/go/+/605975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Archana Ravindar <aravinda@redhat.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
8 months agointernal/runtime/sys: fix typo in comment
Kevin Z [Sat, 24 Aug 2024 17:36:18 +0000 (17:36 +0000)]
internal/runtime/sys: fix typo in comment

just removed a single byte :)

Change-Id: Icd734f9f8f22b2ed0d9d0125d18b6d291bb14cd6
GitHub-Last-Rev: 93c0fd00d863c8a992c63f1bc01c0877b1bdff0c
GitHub-Pull-Request: golang/go#69056
Reviewed-on: https://go-review.googlesource.com/c/go/+/607878
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>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agobytes: fix a typo
Jes Cok [Fri, 23 Aug 2024 13:19:17 +0000 (13:19 +0000)]
bytes: fix a typo

Change-Id: Iecbfe986da386b5c9b8c366904f659acc8f34cfc
GitHub-Last-Rev: ed6c744bbd9ff61874e8dd92f4cef01851ed1f09
GitHub-Pull-Request: golang/go#69039
Reviewed-on: https://go-review.googlesource.com/c/go/+/608015
Reviewed-by: 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>
Auto-Submit: Ian Lance Taylor <iant@google.com>

8 months agodatabase/sql: fix panic with concurrent Conn and Close
Nic Klaassen [Thu, 22 Aug 2024 23:37:00 +0000 (23:37 +0000)]
database/sql: fix panic with concurrent Conn and Close

The current implementation has a panic when the database is closed
concurrently with a new connection attempt.

connRequestSet.CloseAndRemoveAll sets connRequestSet.s to a nil slice.
If this happens between calls to connRequestSet.Add and
connRequestSet.Delete, there is a panic when trying to write to the nil
slice. This is sequence is likely to occur in DB.conn, where the mutex
is released between calls to db.connRequests.Add and
db.connRequests.Delete

This change updates connRequestSet.CloseAndRemoveAll to set the curIdx
to -1 for all pending requests before setting its internal slice to nil.
CloseAndRemoveAll already iterates the full slice to close all the request
channels. It seems appropriate to set curIdx to -1 before deleting the
slice for 3 reasons:
1. connRequestSet.deleteIndex also sets curIdx to -1
2. curIdx will not be relevant to anything after the slice is set to nil
3. connRequestSet.Delete already checks for negative indices

Fixes #68949

Change-Id: I6b7ebc5a71b67322908271d13865fa12f2469b87
GitHub-Last-Rev: 7d2669155b24043dd9d276f915689511572f2e49
GitHub-Pull-Request: golang/go#68953
Reviewed-on: https://go-review.googlesource.com/c/go/+/607238
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
8 months agocmd/compile/internal: write type parameters for aliases
Tim King [Tue, 20 Aug 2024 19:43:59 +0000 (12:43 -0700)]
cmd/compile/internal: write type parameters for aliases

Writes the field for type parameter names for aliases when
the bitstream is >= V2.

This is a no-op at the moment as the writer is hardwired to V1.

Updates #68778

Change-Id: I5887e3608239b9a6a47e3cc21cacb75b84e1d186
Reviewed-on: https://go-review.googlesource.com/c/go/+/607235
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
8 months agotest/codegen: add initial codegen tests for integer min/max
Joel Sing [Tue, 20 Aug 2024 13:41:40 +0000 (23:41 +1000)]
test/codegen: add initial codegen tests for integer min/max

Change-Id: I006370053748edbec930c7279ee88a805009aa0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/606976
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocrypto/aes: add missing aes-gcm buffer overlap checks to PPC64
Paul E. Murphy [Thu, 22 Aug 2024 14:50:08 +0000 (09:50 -0500)]
crypto/aes: add missing aes-gcm buffer overlap checks to PPC64

The tests added by CL 601778 highlighted missing buffer overlap
checks in the ppc64 specific aes-gcm implementation.

Fixes #69007

Change-Id: I80c3b5628c5079cfed2c3dace7298512c16a8f46
Reviewed-on: https://go-review.googlesource.com/c/go/+/607519
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>
8 months agomath/big: implement addMulVVW in riscv64 assembly
Joel Sing [Thu, 27 Jun 2024 10:03:28 +0000 (20:03 +1000)]
math/big: implement addMulVVW in riscv64 assembly

This provides an assembly implementation of addMulVVW for riscv64,
processing up to four words per loop, resulting in a significant
performance gain.

On a StarFive VisionFive 2:

                   │ addmulvvw.1  │             addmulvvw.2             │
                   │    sec/op    │   sec/op     vs base                │
AddMulVVW/1-4         65.49n ± 0%   50.79n ± 0%  -22.44% (p=0.000 n=10)
AddMulVVW/2-4         82.81n ± 0%   66.83n ± 0%  -19.29% (p=0.000 n=10)
AddMulVVW/3-4        100.20n ± 0%   82.87n ± 0%  -17.30% (p=0.000 n=10)
AddMulVVW/4-4        117.50n ± 0%   84.20n ± 0%  -28.34% (p=0.000 n=10)
AddMulVVW/5-4         134.9n ± 0%   100.3n ± 0%  -25.69% (p=0.000 n=10)
AddMulVVW/10-4        221.7n ± 0%   164.4n ± 0%  -25.85% (p=0.000 n=10)
AddMulVVW/100-4       1.794µ ± 0%   1.250µ ± 0%  -30.32% (p=0.000 n=10)
AddMulVVW/1000-4      17.42µ ± 0%   12.08µ ± 0%  -30.68% (p=0.000 n=10)
AddMulVVW/10000-4     254.9µ ± 0%   214.8µ ± 0%  -15.75% (p=0.000 n=10)
AddMulVVW/100000-4    2.569m ± 0%   2.178m ± 0%  -15.20% (p=0.000 n=10)
geomean               1.443µ        1.107µ       -23.29%

                   │ addmulvvw.1  │              addmulvvw.2              │
                   │     B/s      │      B/s       vs base                │
AddMulVVW/1-4        932.0Mi ± 0%   1201.6Mi ± 0%  +28.93% (p=0.000 n=10)
AddMulVVW/2-4        1.440Gi ± 0%    1.784Gi ± 0%  +23.90% (p=0.000 n=10)
AddMulVVW/3-4        1.785Gi ± 0%    2.158Gi ± 0%  +20.87% (p=0.000 n=10)
AddMulVVW/4-4        2.029Gi ± 0%    2.832Gi ± 0%  +39.59% (p=0.000 n=10)
AddMulVVW/5-4        2.209Gi ± 0%    2.973Gi ± 0%  +34.55% (p=0.000 n=10)
AddMulVVW/10-4       2.689Gi ± 0%    3.626Gi ± 0%  +34.86% (p=0.000 n=10)
AddMulVVW/100-4      3.323Gi ± 0%    4.770Gi ± 0%  +43.54% (p=0.000 n=10)
AddMulVVW/1000-4     3.421Gi ± 0%    4.936Gi ± 0%  +44.27% (p=0.000 n=10)
AddMulVVW/10000-4    2.338Gi ± 0%    2.776Gi ± 0%  +18.69% (p=0.000 n=10)
AddMulVVW/100000-4   2.320Gi ± 0%    2.736Gi ± 0%  +17.93% (p=0.000 n=10)
geomean              2.109Gi         2.749Gi       +30.36%

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

8 months agomath/big: implement mulAddVWW in riscv64 assembly
Joel Sing [Thu, 27 Jun 2024 10:03:13 +0000 (20:03 +1000)]
math/big: implement mulAddVWW in riscv64 assembly

This provides an assembly implementation of mulAddVWW for riscv64,
processing up to four words per loop, resulting in a significant
performance gain.

On a StarFive VisionFive 2:

                   │ muladdvww.1  │             muladdvww.2             │
                   │    sec/op    │   sec/op     vs base                │
MulAddVWW/1-4         68.18n ± 0%   65.49n ± 0%   -3.95% (p=0.000 n=10)
MulAddVWW/2-4         82.81n ± 0%   78.85n ± 0%   -4.78% (p=0.000 n=10)
MulAddVWW/3-4         97.49n ± 0%   72.18n ± 0%  -25.96% (p=0.000 n=10)
MulAddVWW/4-4        112.20n ± 0%   85.54n ± 0%  -23.76% (p=0.000 n=10)
MulAddVWW/5-4        126.90n ± 0%   98.90n ± 0%  -22.06% (p=0.000 n=10)
MulAddVWW/10-4        200.3n ± 0%   144.3n ± 0%  -27.96% (p=0.000 n=10)
MulAddVWW/100-4      1532.0n ± 0%   860.0n ± 0%  -43.86% (p=0.000 n=10)
MulAddVWW/1000-4     14.757µ ± 0%   8.076µ ± 0%  -45.27% (p=0.000 n=10)
MulAddVWW/10000-4     204.0µ ± 0%   137.1µ ± 0%  -32.77% (p=0.000 n=10)
MulAddVWW/100000-4    2.066m ± 0%   1.382m ± 0%  -33.12% (p=0.000 n=10)
geomean               1.311µ        950.0n       -27.51%

                   │ muladdvww.1  │             muladdvww.2              │
                   │     B/s      │     B/s       vs base                │
MulAddVWW/1-4        895.1Mi ± 0%   932.0Mi ± 0%   +4.11% (p=0.000 n=10)
MulAddVWW/2-4        1.440Gi ± 0%   1.512Gi ± 0%   +5.02% (p=0.000 n=10)
MulAddVWW/3-4        1.834Gi ± 0%   2.477Gi ± 0%  +35.07% (p=0.000 n=10)
MulAddVWW/4-4        2.125Gi ± 0%   2.787Gi ± 0%  +31.15% (p=0.000 n=10)
MulAddVWW/5-4        2.349Gi ± 0%   3.013Gi ± 0%  +28.28% (p=0.000 n=10)
MulAddVWW/10-4       2.975Gi ± 0%   4.130Gi ± 0%  +38.79% (p=0.000 n=10)
MulAddVWW/100-4      3.891Gi ± 0%   6.930Gi ± 0%  +78.11% (p=0.000 n=10)
MulAddVWW/1000-4     4.039Gi ± 0%   7.380Gi ± 0%  +82.72% (p=0.000 n=10)
MulAddVWW/10000-4    2.922Gi ± 0%   4.346Gi ± 0%  +48.74% (p=0.000 n=10)
MulAddVWW/100000-4   2.884Gi ± 0%   4.313Gi ± 0%  +49.52% (p=0.000 n=10)
geomean              2.321Gi        3.202Gi       +37.95%

Change-Id: If08191607913ce5c7641f34bae8fa5c9dfb44777
Reviewed-on: https://go-review.googlesource.com/c/go/+/595399
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
8 months agocrypto/sha256: provide optimised assembly for riscv64
Joel Sing [Tue, 15 Aug 2023 15:03:51 +0000 (01:03 +1000)]
crypto/sha256: provide optimised assembly for riscv64

Provide an optimised assembly implementation of sha256 for riscv64.
This results in considerable performance gains.

On a StarFive VisionFive 2:

                    │   sha256.1   │              sha256.2               │
                    │    sec/op    │   sec/op     vs base                │
Hash8Bytes/New-4       7.820µ ± 0%   5.193µ ± 0%  -33.59% (p=0.000 n=10)
Hash8Bytes/Sum224-4    7.918µ ± 0%   5.294µ ± 0%  -33.15% (p=0.000 n=10)
Hash8Bytes/Sum256-4    7.950µ ± 0%   5.320µ ± 0%  -33.08% (p=0.000 n=10)
Hash1K/New-4          108.03µ ± 0%   66.12µ ± 0%  -38.79% (p=0.000 n=10)
Hash1K/Sum224-4       108.12µ ± 0%   66.22µ ± 0%  -38.76% (p=0.000 n=10)
Hash1K/Sum256-4       108.15µ ± 0%   66.24µ ± 0%  -38.75% (p=0.000 n=10)
Hash8K/New-4           808.5µ ± 0%   493.0µ ± 0%  -39.02% (p=0.000 n=10)
Hash8K/Sum224-4        808.6µ ± 0%   493.1µ ± 0%  -39.02% (p=0.000 n=10)
Hash8K/Sum256-4        808.6µ ± 0%   493.1µ ± 0%  -39.02% (p=0.000 n=10)
geomean                88.37µ        55.61µ       -37.08%

                    │   sha256.1   │               sha256.2                │
                    │     B/s      │      B/s       vs base                │
Hash8Bytes/New-4      996.1Ki ± 0%   1503.9Ki ± 0%  +50.98% (p=0.000 n=10)
Hash8Bytes/Sum224-4   986.3Ki ± 0%   1474.6Ki ± 0%  +49.50% (p=0.000 n=10)
Hash8Bytes/Sum256-4   986.3Ki ± 0%   1464.8Ki ± 0%  +48.51% (p=0.000 n=10)
Hash1K/New-4          9.041Mi ± 0%   14.772Mi ± 0%  +63.40% (p=0.000 n=10)
Hash1K/Sum224-4       9.031Mi ± 0%   14.744Mi ± 0%  +63.25% (p=0.000 n=10)
Hash1K/Sum256-4       9.031Mi ± 0%   14.744Mi ± 0%  +63.25% (p=0.000 n=10)
Hash8K/New-4          9.661Mi ± 0%   15.850Mi ± 0%  +64.07% (p=0.000 n=10)
Hash8K/Sum224-4       9.661Mi ± 0%   15.841Mi ± 0%  +63.97% (p=0.000 n=10)
Hash8K/Sum256-4       9.661Mi ± 0%   15.841Mi ± 0%  +63.97% (p=0.000 n=10)
geomean               4.386Mi         6.966Mi       +58.85%

Change-Id: Ieead7b7c02291d70ddc472a7a8cf3c044c1da4b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/519695
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>
Reviewed-by: Cherry Mui <cherryyz@google.com>
8 months agoos: improve Getwd documentation
Kir Kolyshkin [Wed, 21 Aug 2024 19:47:04 +0000 (12:47 -0700)]
os: improve Getwd documentation

1. Replace "rooted path name" with a more accurate "absolute path name".
Using "absolute" seems to be preferred terminology on Unix. On Windows,
there are multiple roots in Windows, thus "a rooted path name" can be
one relative to a drive letter or a server name. Note that Windows'
GetCurrentDirectory documentation [1] also says "the absolute path to the
current directory".

2. Add a note about using $PWD on Unix.

[1]: https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getcurrentdirectory

Change-Id: Ic310f0f8776ff059544789306ae5cfa1fa267b12
Reviewed-on: https://go-review.googlesource.com/c/go/+/607615
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: Cherry Mui <cherryyz@google.com>
8 months agocmd/internal/obj/loong64: add support for instructions BSTRPICK.{W/D} and BSTRINS...
Xiaolin Zhao [Mon, 12 Aug 2024 07:18:45 +0000 (15:18 +0800)]
cmd/internal/obj/loong64: add support for instructions BSTRPICK.{W/D} and BSTRINS.{W/D}

Go asm syntax:
BSTRPICK{W/V} $msb, RJ, $lsb, RD
BSTRINS{W/V} $msb, RJ, $lsb, RD

Equivalent platform assembler syntax:
bstrpick.{w/d} rd, rj, $msb, $lsb
bstrins.{w/d} rd, rj, $msb, $lsb

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

Change-Id: I8b89b766ed22a96da7d8d5b2b2873382a49208de
Reviewed-on: https://go-review.googlesource.com/c/go/+/604735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>