]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
10 months agocmd/compile: in expandCalls, move all arg marshalling into call block
David Chase [Tue, 15 Aug 2023 21:45:50 +0000 (17:45 -0400)]
cmd/compile: in expandCalls, move all arg marshalling into call block

For aggregate-typed arguments passed to a call, expandCalls
decomposed them into parts in the same block where the value
was created.  This is not necessarily the call block, and in
the case where stores are involved, can change the memory
leaving that block, and getting that right is problematic.

Instead, do all the expanding in the same block as the call,
which avoids the problems of (1) not being able to reorder
loads/stores across a block boundary to conform to memory
order and (2) (incorrectly, not) exposing the new memory to
consumers in other blocks.  Putting it all in the same block
as the call allows reordering, and the call creates its own
new memory (which is already dealt with correctly).

Fixes #61992.

Change-Id: Icc7918f0d2dd3c480cc7f496cdcd78edeca7f297
Reviewed-on: https://go-review.googlesource.com/c/go/+/519276
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agosync: document why copyChecker checks the condition twice
qiulaidongfeng [Tue, 15 Aug 2023 02:14:00 +0000 (02:14 +0000)]
sync: document why copyChecker checks the condition twice

Fixes #40924

Change-Id: I249a278be1ec3c67088819af4456e6c393431724

Change-Id: I249a278be1ec3c67088819af4456e6c393431724
GitHub-Last-Rev: 772c7ae7e140ebd3896fc7786aae8b43ab3128c3
GitHub-Pull-Request: golang/go#61978
Reviewed-on: https://go-review.googlesource.com/c/go/+/518961
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Auto-Submit: Austin Clements <austin@google.com>

10 months agoos: support file systems without file IDs when reading directories on windows
qmuntal [Thu, 10 Aug 2023 09:17:25 +0000 (11:17 +0200)]
os: support file systems without file IDs when reading directories on windows

Some file systems do not support file IDs. We should not use
FILE_ID_BOTH_DIR_INFO when reading directories on these file systems,
as it will fail. Instead, we should use FILE_ID_FULL_DIR_INFO,
which doesn't require file ID support.

Fixes #61907
Fixes #61918

Change-Id: I83d0a898f8eb254dffe5b8fc68a4ca4ef21c0d85
Reviewed-on: https://go-review.googlesource.com/c/go/+/518195
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
10 months agocmd/go: remove conversion of legacy pre-module dependency configs
Russ Cox [Fri, 11 Aug 2023 15:24:07 +0000 (11:24 -0400)]
cmd/go: remove conversion of legacy pre-module dependency configs

This kind of worked, kind of didn't, but by now no one is running into
those configs anymore during "go mod init", the code is complex,
and the tests are slow. Not worth the trouble of maintaining anymore.

Change-Id: I02d4188d531c68334d17b2462bafec4c5dd49777
Reviewed-on: https://go-review.googlesource.com/c/go/+/518776
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

10 months agocmd/go: delete GOPATH-mode get
Russ Cox [Tue, 18 Jul 2023 18:01:13 +0000 (14:01 -0400)]
cmd/go: delete GOPATH-mode get

We've decided to keep basic GOPATH mode running
for trees that already exist, but GOPATH-mode get is
being removed. It is old and not useful and probably
full of security holes. See #60915 for more details.

Fixes #60915.

Change-Id: I9db4c445579bf0b79f6543624602652555b66c1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/518775
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
10 months agoerrors: add a colon after Output to make the Example in the document display correctly
cui fliter [Tue, 15 Aug 2023 15:07:18 +0000 (23:07 +0800)]
errors: add a colon after Output to make the Example in the document display correctly

Change-Id: Iaa1751c6ac0df9d5b2cb74efb16996f4eaea0503
Reviewed-on: https://go-review.googlesource.com/c/go/+/519236
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: shuang cui <imcusg@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
10 months agobufio: clarify the maximum token size
qiulaidongfeng [Wed, 16 Aug 2023 02:04:19 +0000 (02:04 +0000)]
bufio: clarify the maximum token size

Fixes #43183.

Change-Id: I50d99ef8ed513bba47166a25ea5c7c80cd8bd799
GitHub-Last-Rev: 684d70e9a3dbc0ce280e1112105d666cd5754e9f
GitHub-Pull-Request: golang/go#61979
Reviewed-on: https://go-review.googlesource.com/c/go/+/518860
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
10 months agodoc/go1.22: mention new sql.Null[T]
Inada Naoki [Tue, 15 Aug 2023 04:33:37 +0000 (04:33 +0000)]
doc/go1.22: mention new sql.Null[T]

For #60370.

Change-Id: Idae906ec7027be6d95f78bf43f7ce8f9d07e6c00
GitHub-Last-Rev: c645f0cf82ac595855fa154ce342869262932770
GitHub-Pull-Request: golang/go#62033
Reviewed-on: https://go-review.googlesource.com/c/go/+/519555
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

10 months agogo/types, types2: don't verify infer result if no Config.Error is given
Robert Griesemer [Tue, 15 Aug 2023 21:17:02 +0000 (14:17 -0700)]
go/types, types2: don't verify infer result if no Config.Error is given

With no error handler installed, an error leads to an (internal panic
and) immediate abort of type checking. Not all invariants hold up in
this case, but it also doesn't matter.

In Checker.infer, verify result conditions always if an error handler
is installed, but only then.

Fixes #61938.

Change-Id: I4d3d61bbccc696a75639fee5010f5d3cef17e855
Reviewed-on: https://go-review.googlesource.com/c/go/+/519775
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
10 months agogo/types, types2: use correct parameter list when checking argument passing
Robert Griesemer [Mon, 14 Aug 2023 22:56:08 +0000 (15:56 -0700)]
go/types, types2: use correct parameter list when checking argument passing

The existing code was simply wrong: we cannot ever use the result
signature parameter list (rsig.params) if sigParams was adjusted
for variadic functions. If it was adjusted, we always must either
use sigParams or its separately instantiated version.

In the condition "n > 0 && adjusted", the "n > 0" should have
been in either of the respective "if statement" branches.

Simplified the code by merging with the result signature parameter
update.

Fixes #61931.

Change-Id: I5d39bc8bbc4dd85c7c985055d29532b4b176955e
Reviewed-on: https://go-review.googlesource.com/c/go/+/519456
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
10 months agocmd/compile: improve ir.StaticValue and extract ir.StaticCalleeName
Matthew Dempsky [Sat, 12 Aug 2023 01:21:22 +0000 (18:21 -0700)]
cmd/compile: improve ir.StaticValue and extract ir.StaticCalleeName

This CL extends ir.StaticValue to also work on closure variables.

Also, it extracts the code from escape analysis that's responsible for
determining the static callee of a function. This will be useful when
go/defer statement normalization is moved to typecheck.

Change-Id: I69e1f7fb185658dc9fbfdc69d0f511c84df1d3ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/518959
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agogo/types, types2: move emode computation closer to use (cleanup)
Robert Griesemer [Mon, 14 Aug 2023 21:15:23 +0000 (14:15 -0700)]
go/types, types2: move emode computation closer to use (cleanup)

Follow-up on https://go.dev/cl/519435.

Change-Id: I8febf5544f28acb87607331ff8be8454470328ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/519436
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

10 months agogo/types, types2: use exact unification when comparing interface methods
Robert Griesemer [Mon, 14 Aug 2023 21:07:56 +0000 (14:07 -0700)]
go/types, types2: use exact unification when comparing interface methods

Irrespective of whether unification is exact or inexact, method
signatures of interfaces must always match exactly: a type never
satisfies/implements an interface if relevant method signatures
are different (i.e., not identical, possibly after substitution).

Fixes #61879.

Change-Id: I20c0aa28ac86e2edec615b40f2269938e4a96938
Reviewed-on: https://go-review.googlesource.com/c/go/+/519435
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

10 months agointernal/syscall/unix: fix gofmt
sivchari [Mon, 14 Aug 2023 16:01:46 +0000 (01:01 +0900)]
internal/syscall/unix: fix gofmt

Change-Id: I24203c4e52bf4d55a6391d10fb4d30771c2674b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/518637
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
10 months agodoc: fix broken x509sha1 setting link
Cian Ruane [Tue, 15 Aug 2023 14:34:18 +0000 (14:34 +0000)]
doc: fix broken x509sha1 setting link

The link was missing the /pkg/ prefix.

Fixes #62034.

Change-Id: I96c43f06621e30241e140948129e90f0bd5f8d13
GitHub-Last-Rev: c1e7413f76a25ea18a460fb3af732532429d7ff9
GitHub-Pull-Request: golang/go#62040
Reviewed-on: https://go-review.googlesource.com/c/go/+/519575
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
10 months agocmd/go/testdata/script: ensure go test -skip skips ExampleTest1
Tobias Klauser [Tue, 15 Aug 2023 13:32:42 +0000 (15:32 +0200)]
cmd/go/testdata/script: ensure go test -skip skips ExampleTest1

CL 511837 added a check for go test -skip Example but it currently
doesn't verify that the example doesn't show up in the command output.
Add such a check.

For #61482

Change-Id: I3a8f82fc137739bf291f39bf7719ff92cfc74f9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/519595
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
10 months agocmd/pprof: update vendored github.com/google/pprof
Dmitri Shuralyov [Tue, 15 Aug 2023 15:45:57 +0000 (11:45 -0400)]
cmd/pprof: update vendored github.com/google/pprof

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. Done with:

go get github.com/google/pprof
go mod tidy
go mod vendor

For #36905.

Change-Id: I2a48e912712bc916c9d749acb1550682f919477e
Reviewed-on: https://go-review.googlesource.com/c/go/+/519657
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

10 months agocmd/internal/archive: skip sentinel archive entries created by Go cmd
Than McIntosh [Tue, 15 Aug 2023 14:24:41 +0000 (10:24 -0400)]
cmd/internal/archive: skip sentinel archive entries created by Go cmd

When reading an archive, check for the presence of sentinel entries
created by the Go command. These zero-sized marker entries don't contain
any useful symbols, but rather are there to communicate info to the
linker; ignore them during symbol dumping.

Fixes #62036.

Change-Id: Ied017b0c5b92a3cf6fd13bb9c9f3a9664e4f20f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/519635
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agoruntime/cgo: use fatalf on solaris
Joel Sing [Fri, 11 Aug 2023 13:08:25 +0000 (23:08 +1000)]
runtime/cgo: use fatalf on solaris

Change-Id: I3302cc2f0e03014e9497976e36d1c7a381a2f962
Reviewed-on: https://go-review.googlesource.com/c/go/+/518623
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agoruntime: restore caller's frame pointer when recovering from panic
Nick Ripley [Fri, 4 Aug 2023 21:31:43 +0000 (17:31 -0400)]
runtime: restore caller's frame pointer when recovering from panic

When recovering from a panic, restore the caller's frame pointer before
returning control to the caller. Otherwise, if the function proceeds to
run more deferred calls before returning, the deferred functions will
get invalid frame pointers pointing to an address lower in the stack.
This can cause frame pointer unwinding to crash, such as if an execution
trace event is recorded during the deferred call on architectures which
support frame pointer unwinding.

Fixes #61766

Change-Id: I45f41aedcc397133560164ab520ca638bbd93c4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/516157
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
10 months agoruntime: zero saved frame pointer when reusing goroutine stack on arm64
Nick Ripley [Mon, 3 Apr 2023 13:32:05 +0000 (09:32 -0400)]
runtime: zero saved frame pointer when reusing goroutine stack on arm64

When a goroutine stack is reused on arm64, the spot on the stack where
the "caller's" frame pointer goes for the topmost frame should be
explicitly zeroed. Otherwise, the frame pointer check in adjustframe
with debugCheckBP enabled will fail on the topmost frame of a call stack
the first time a reused stack is grown.

Updates #39524, #58432

Change-Id: Ic1210dc005e3ecdbf9cd5d7b98846566e56df8f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/481636
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

10 months agocrypto/internal/bigmod: provide assembly addMulVVW* for riscv64
Joel Sing [Mon, 7 Aug 2023 15:18:17 +0000 (01:18 +1000)]
crypto/internal/bigmod: provide assembly addMulVVW* for riscv64

This provides an assembly implementation of addMulVVW* for riscv64,
processing four words per loop, resulting in a performance gain
of 23%+ for RSA decryption/signing on a StarFive VisionFive 2:

                       │    rsa1     │                rsa2                 │
                       │   sec/op    │   sec/op     vs base                │
DecryptPKCS1v15/2048-4   24.29m ± 0%   18.65m ± 0%  -23.24% (p=0.000 n=10)
DecryptPKCS1v15/3072-4   73.28m ± 0%   54.08m ± 0%  -26.20% (p=0.000 n=10)
DecryptPKCS1v15/4096-4   163.5m ± 0%   119.1m ± 0%  -27.17% (p=0.000 n=10)
EncryptPKCS1v15/2048-4   1.505m ± 0%   1.446m ± 0%   -3.93% (p=0.000 n=10)
DecryptOAEP/2048-4       24.37m ± 0%   18.72m ± 0%  -23.17% (p=0.000 n=10)
EncryptOAEP/2048-4       1.570m ± 0%   1.510m ± 0%   -3.84% (p=0.000 n=10)
SignPKCS1v15/2048-4      24.52m ± 0%   18.80m ± 0%  -23.36% (p=0.000 n=10)
VerifyPKCS1v15/2048-4    1.491m ± 0%   1.431m ± 0%   -4.00% (p=0.000 n=10)
SignPSS/2048-4           24.60m ± 0%   18.89m ± 0%  -23.21% (p=0.000 n=10)
VerifyPSS/2048-4         1.565m ± 0%   1.504m ± 0%   -3.87% (p=0.000 n=10)
geomean                  10.90m        9.066m       -16.79%

Change-Id: I8414ba0028b0781a945610abe02c285d2387aef3
Reviewed-on: https://go-review.googlesource.com/c/go/+/516536
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: M Zhuo <mzh@golangcn.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agoruntime/cgo: consolidate openbsd cgo code
Joel Sing [Fri, 11 Aug 2023 13:02:32 +0000 (23:02 +1000)]
runtime/cgo: consolidate openbsd cgo code

All openbsd architectures now use the same code, deduplicate accordingly.

Change-Id: I65f1d9bd78c97dbdf552ec95ebba7ec4d04c8d2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/518622
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agoruntime/cgo: consolidate netbsd cgo code
Joel Sing [Fri, 11 Aug 2023 12:46:32 +0000 (22:46 +1000)]
runtime/cgo: consolidate netbsd cgo code

All netbsd architectures now use the same code, deduplicate accordingly.

Change-Id: Ieb179fd76885b7af6d388d7f2aee0f9fac6f1264
Reviewed-on: https://go-review.googlesource.com/c/go/+/518621
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>

10 months agoruntime/cgo: consolidate linux cgo code
Joel Sing [Fri, 11 Aug 2023 08:54:52 +0000 (18:54 +1000)]
runtime/cgo: consolidate linux cgo code

Much of the gcc_linux_*.c code is identical and duplicated across
architectures. Consolidate code for 386, arm, loong64, mips* and
riscv64, where the only difference is the build tags (386 also
has some non-functional ordering differences).

Change-Id: I14ee9a4cc6b72e165239d196b68b6343efaddf0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/518620
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
10 months agoruntime/cgo: consolidate freebsd cgo code
Joel Sing [Fri, 11 Aug 2023 12:53:30 +0000 (22:53 +1000)]
runtime/cgo: consolidate freebsd cgo code

Most freebsd architectures now use the same code, deduplicate accordingly.

The arm code differs slightly in that it has a compile time check for
ARM_TP_ADDRESS, however this is written in a way that it can be included
for all architectures.

Change-Id: I7f6032b63521d24d0c3b5e0e08d57e32b4f9ddc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/518619
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
10 months agoruntime/cgo: rename crosscall_arm1 to crosscall1
Joel Sing [Fri, 11 Aug 2023 09:49:38 +0000 (19:49 +1000)]
runtime/cgo: rename crosscall_arm1 to crosscall1

This reduces inconsistency with other architectures and will allow
for further code deduplication.

Change-Id: Icf0d02f765546c3193cccaa22c79e632e12d6bba
Reviewed-on: https://go-review.googlesource.com/c/go/+/518616
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agoruntime/cgo: use fatalf on dragonfly, freebsd, netbsd and openbsd
Joel Sing [Fri, 11 Aug 2023 08:20:21 +0000 (18:20 +1000)]
runtime/cgo: use fatalf on dragonfly, freebsd, netbsd and openbsd

Use fatalf consistently on freebsd. Also use it on dragonfly, netbsd
and openbsd.

Change-Id: I8643c0b7bc13c3cb5173209d311d6d297913955b
Reviewed-on: https://go-review.googlesource.com/c/go/+/518615
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agocmd/compile: sign or zero extend for 32 bit equality on riscv64
Joel Sing [Wed, 19 Oct 2022 05:43:22 +0000 (16:43 +1100)]
cmd/compile: sign or zero extend for 32 bit equality on riscv64

For 32 bit equality (Eq32), rather than always zero extending to 64 bits,
sign extend for signed types and zero extend for unsigned types. This makes
no difference to the equality test (via SUB), however it increases the
likelihood of avoiding unnecessary sign or zero extension simply for the
purpose of equality testing.

While here, replace the Neq* rules with (Not (Eq*)) - this makes no
difference to the generated code (as the intermediates get expanded and
eliminated), however it means that changes to the equality rules also
reflect in the inequality rules.

As an example, the following:

   lw      t0,956(t0)
   slli    t0,t0,0x20
   srli    t0,t0,0x20
   li      t1,1
   bne     t1,t0,278fc

Becomes:

   lw      t0,1024(t0)
   li      t1,1
   bne     t1,t0,278b0

Removes almost 1000 instructions from the Go binary on riscv64.

Change-Id: Iac60635f494f6db87faa47752bd1cc16e6b5967f
Reviewed-on: https://go-review.googlesource.com/c/go/+/516595
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: M Zhuo <mzh@golangcn.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agoruntime: mark traceEnabled and traceShuttingDown as no:split
Mauri de Souza Meneguzzo [Sun, 13 Aug 2023 14:04:53 +0000 (14:04 +0000)]
runtime: mark traceEnabled and traceShuttingDown as no:split

This fixes a regression from CL 494181.
The traceEnabled function splits the stack and is being
called by reentersyscall that shouldn't call anything
that splits the stack. Same with traceShuttingDown.

Fixes #61975

Change-Id: I5eca0ba74cfa6acb0259e8400b03c2093cd59dd1
GitHub-Last-Rev: 9e55ae9d7cc700de9757d32a7905127a349d973a
GitHub-Pull-Request: golang/go#61981
Reviewed-on: https://go-review.googlesource.com/c/go/+/519055
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@google.com>

10 months agoencoding/json: declare hex as a const
Jes Cok [Mon, 14 Aug 2023 11:53:26 +0000 (11:53 +0000)]
encoding/json: declare hex as a const

hex is in fact immutable, declare it as a const to avoid accidental
modification, also for consistency with other packages.

Change-Id: I99f292e98c82d4c4526e46c9897d154d0c073da5
GitHub-Last-Rev: d2f06965e7e03df470d8c3c8882619187abf1609
GitHub-Pull-Request: golang/go#62011
Reviewed-on: https://go-review.googlesource.com/c/go/+/519155
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
10 months agocmd: fix mismatched symbols
cui fliter [Mon, 31 Jul 2023 13:40:45 +0000 (21:40 +0800)]
cmd: fix mismatched symbols

Change-Id: I8852c0a29dffec9635d61b7670cfed78ebed07f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/514315
Run-TryBot: shuang cui <imcusg@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
10 months agointernal/fuzz: use the built-in min function
cui fliter [Fri, 11 Aug 2023 03:00:44 +0000 (11:00 +0800)]
internal/fuzz: use the built-in min function

Change-Id: I26be9a9faa27c6c03cf8b9dec5908d8617d61312
Reviewed-on: https://go-review.googlesource.com/c/go/+/518276
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
10 months agocmd/compile/internal: add RLDICR opcode for PPC64
Paul E. Murphy [Tue, 27 Jun 2023 16:30:29 +0000 (11:30 -0500)]
cmd/compile/internal: add RLDICR opcode for PPC64

This is encoded similarly to RLDICL, but can clear the least
significant bits.

Likewise, update the auxint encoding of RLDICL to match those
used by the rotate and mask word ssa opcodes for easier usage
within lowering rules. The RLDICL ssa opcode is not used yet.

Change-Id: I42486dd95714a3e8e2f19ab237a6cf3af520c905
Reviewed-on: https://go-review.googlesource.com/c/go/+/515575
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agointernal/bytealg: optimize Count/CountString for PPC64/Power10
Paul E. Murphy [Mon, 17 Jul 2023 20:23:28 +0000 (15:23 -0500)]
internal/bytealg: optimize Count/CountString for PPC64/Power10

Power10 adds a handful of new instructions which make this
noticeably quicker for smaller values.

Likewise, since the vector loop requires 32B to enter,
unroll it once to count 32B per iteration. This
improvement benefits all PPC64 cpus.

On Power10 comparing a binary built with GOPPC64=power8

CountSingle/10     8.99ns ± 0%    5.55ns ± 3%   -38.24%
CountSingle/16     7.55ns ± 0%    5.56ns ± 3%   -26.37%
CountSingle/17     7.45ns ± 0%    5.25ns ± 0%   -29.52%
CountSingle/31     18.4ns ± 0%     6.2ns ± 0%   -66.41%
CountSingle/32     6.17ns ± 0%    5.04ns ± 0%   -18.37%
CountSingle/33     7.13ns ± 0%    5.99ns ± 0%   -15.94%
CountSingle/4K      198ns ± 0%     115ns ± 0%   -42.08%
CountSingle/4M      190µs ± 0%     109µs ± 0%   -42.49%
CountSingle/64M    3.28ms ± 0%    2.08ms ± 0%   -36.53%

Furthermore, comparing the new tail implementation on
GOPPC64=power8 with GOPPC64=power10:

CountSingle/10     5.55ns ± 3%    4.52ns ± 1%  -18.66%
CountSingle/16     5.56ns ± 3%    4.80ns ± 0%  -13.65%
CountSingle/17     5.25ns ± 0%    4.79ns ± 0%   -8.78%
CountSingle/31     6.17ns ± 0%    4.82ns ± 0%  -21.79%
CountSingle/32     5.04ns ± 0%    5.09ns ± 6%   +1.01%
CountSingle/33     5.99ns ± 0%    5.42ns ± 2%   -9.54%

Change-Id: I62d80be3b5d706e1abbb4bec7d6278a939a5eed4
Reviewed-on: https://go-review.googlesource.com/c/go/+/512695
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agocmd/go/internal/cache: use == to test for io.EOF
Jes Cok [Mon, 14 Aug 2023 11:16:48 +0000 (11:16 +0000)]
cmd/go/internal/cache: use == to test for io.EOF

The documentation of io.EOF: Read must return EOF itself, not an error
wrapping EOF, because callers will test for EOF using ==.

encoding/json package provides an example "ExampleDecoder" which uses
"err == io.EOF" as well, so I think it's more idiomatic to use == to test for io.EOF.

Change-Id: I8a9f06d655ca63b3ec3e7dbbdfc519a2686980e1
GitHub-Last-Rev: 665929e2a20bff231bcb5bad1384998379b41165
GitHub-Pull-Request: golang/go#62012
Reviewed-on: https://go-review.googlesource.com/c/go/+/519156
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
10 months agocmd/compile: desugar ORECOVER during typecheck
Matthew Dempsky [Sat, 12 Aug 2023 00:29:08 +0000 (17:29 -0700)]
cmd/compile: desugar ORECOVER during typecheck

This never belonged in escape analysis, but the non-unified generics
frontend didn't use typecheck. That frontend is gone, so now we can
desugar it earlier.

Change-Id: I70f34a851f27fce1133777c5eeca0f549fc60ede
Reviewed-on: https://go-review.googlesource.com/c/go/+/518958
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

10 months agocmd/compile: move IsDeadcodeClosure check into enqueueFunc
Matthew Dempsky [Fri, 11 Aug 2023 22:16:12 +0000 (15:16 -0700)]
cmd/compile: move IsDeadcodeClosure check into enqueueFunc

Keeps the top-level loop in Main slightly cleaner.

Change-Id: I9c8d38d4bbb34d53edc0796893534763e9eef2f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/518957
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
10 months agocmd/compile: remove reflectdata.{TypePtr,ITabAddr} wrappers
Matthew Dempsky [Fri, 11 Aug 2023 21:35:23 +0000 (14:35 -0700)]
cmd/compile: remove reflectdata.{TypePtr,ITabAddr} wrappers

Remove these in favor of the explicit *At variants that take a
src.XPos.

Change-Id: I2c095b75e43b58fe31e3e1b15c811a66ac5a0f83
Reviewed-on: https://go-review.googlesource.com/c/go/+/518956
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

10 months agocmd/compile: mark generated eq/hash functions as //go:noinline
Matthew Dempsky [Fri, 11 Aug 2023 21:22:56 +0000 (14:22 -0700)]
cmd/compile: mark generated eq/hash functions as //go:noinline

Instead of having the inliner specially recognize that eq/hash
functions can't be inlined, change the geneq and genhash to mark them
as //go:noinline.

This is a prereq for a subsequent CL that will move more logic for
handling rtypes from package types to package reflectdata.

Change-Id: I091a9ededcc083fe8305cf5443a9af7d3a9053b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/518955
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

10 months agocmd/go: skip gotoolchain_net script test for new-ish go experiments
Than McIntosh [Mon, 14 Aug 2023 14:51:57 +0000 (10:51 -0400)]
cmd/go: skip gotoolchain_net script test for new-ish go experiments

Skip the gotoolchain_net script test if any new-ish GOEXPERIMENT is
set, since it will fail under these circumstances.

Updates #62106.

Change-Id: Idfef8af7246a3fbe6481347872a94fe64bbaed7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/519195
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agoruntime: profiling on Darwin cannot use blocking reads
David Chase [Fri, 11 Aug 2023 18:38:19 +0000 (14:38 -0400)]
runtime: profiling on Darwin cannot use blocking reads

On Darwin (and assume also on iOS but not sure), notetsleepg
cannot be called in a signal-handling context.  Avoid this
by disabling block reads on Darwin.

An alternate approach was to add "sigNote" with a pipe-based
implementation on Darwin, but that ultimately would have required
at least one more linkname between runtime and syscall to avoid
racing with fork and opening the pipe, so, not.

Fixes #61768.

Change-Id: I0e8dd4abf9a606a3ff73fc37c3bd75f55924e07e
Reviewed-on: https://go-review.googlesource.com/c/go/+/518836
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agointernal/coverage: separate out cmd defs to separate package
Than McIntosh [Wed, 9 Aug 2023 12:50:41 +0000 (08:50 -0400)]
internal/coverage: separate out cmd defs to separate package

Relocate the definitions in cmddefs.go (used by the compiler and
the cover tool) to a separate package "covcmd". No change
in functionality, this is a pure refactoring, in preparation
for a subsequent change that will require updating the
imports for the package.

Change-Id: Ic1d277c94d9a574de0a11ec5ed77e892302b9a47
Reviewed-on: https://go-review.googlesource.com/c/go/+/517696
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
10 months agoruntime/cgo: rename crosscall_386 to crosscall1 and standardise API
Joel Sing [Fri, 11 Aug 2023 10:19:59 +0000 (20:19 +1000)]
runtime/cgo: rename crosscall_386 to crosscall1 and standardise API

Most architectures have a crosscall1 function that takes a function
pointer, a setg_gcc function pointer and a g pointer. However,
crosscall_386 only takes a function pointer and the call to setg_gcc
is performed in the thread entry function.

Rename crosscall_386 to crosscall1 for consistency with other
architectures, as well as standardising the API - while not strictly
necessary, it will allow for further deduplication as the calling
code becomes more consistent.

Change-Id: I77cf42e1e15e0a4c5802359849a849c32cebd92f
Reviewed-on: https://go-review.googlesource.com/c/go/+/518618
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agoruntime/cgo: rename crosscall_amd64 to crosscall1
Joel Sing [Fri, 11 Aug 2023 09:58:26 +0000 (19:58 +1000)]
runtime/cgo: rename crosscall_amd64 to crosscall1

This reduces inconsistency with other architectures and will allow
for further code deduplication.

Change-Id: I5becbf29af2ef714974b5e338f869281f2b4de8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/518617
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agonet/http: disallow empty Content-Length header
Mauri de Souza Meneguzzo [Thu, 10 Aug 2023 20:56:27 +0000 (20:56 +0000)]
net/http: disallow empty Content-Length header

The Content-Length must be a valid numeric value, empty values should not be accepted.

See: https://www.rfc-editor.org/rfc/rfc9110.html#name-content-length

Fixes #61679

Change-Id: Icbcd933087fe5e50199b62ff34c58bf92a09d3d4
GitHub-Last-Rev: 932e46b55b54d5f2050453bcaa50e9476c8559fd
GitHub-Pull-Request: golang/go#61865
Reviewed-on: https://go-review.googlesource.com/c/go/+/517336
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agocmd/compile: simplify asmhdr and plugin exports handling
Matthew Dempsky [Fri, 11 Aug 2023 19:04:22 +0000 (12:04 -0700)]
cmd/compile: simplify asmhdr and plugin exports handling

This CL removes a bunch of obsolete code, which made the overall
possible data flow of the compiler much harder to understand. In
particular, it:

1. Removes typecheck.Declare by inlining its only two remaining uses,
and simplifying them down to just the couple of relevant assignments
for each remaining caller.

2. Renames ir.Package.{Asms,Exports} to {AsmHdrDecls,PluginExports},
respectively, to better describe what they're used for. In particular,
PluginExports now actually holds only the subset of Exports that used
to be confusingly called "ptabs" in package reflectdata.

3. Renames reflectdata.WriteTabs to reflectdata.WritePluginTable, to
make it clearer what it does.

4. Removes the consistency checks on len(Exports) and len(ptabs),
since now it's plainly obvious that only the unified importer ever
appends to PluginExports.

Change-Id: Iedc9d0a4e7648de4e734f7e3e7df302580fed542
Reviewed-on: https://go-review.googlesource.com/c/go/+/518757
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

10 months agocmd/asm: add KDSA instruction support
Srinivas Pokala [Wed, 14 Jun 2023 05:13:37 +0000 (07:13 +0200)]
cmd/asm: add KDSA instruction support

KDSA(Compute Digital Signature Authentication) instruction provides
support for the signing and verification of elliptic curves

Change-Id: I19996a307162dd4f476a1cfe4f8d1a74a609e6c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/503215
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agocmd/compile: separate out unsafe mark for end-of-block instructions
Keith Randall [Fri, 11 Aug 2023 04:09:33 +0000 (21:09 -0700)]
cmd/compile: separate out unsafe mark for end-of-block instructions

Even if a block is empty, we need to keep track of whether the
end-of-block instructions are preemptible.

This CL allows us to not mark the load+compare in instruction
sequences like

CMPL $0, runtime·writeBarrier(SB)
JEQ  ...

Before, we had to mark the CMPL as uninterruptible because there
was no way to mark just the JEQ. Now there is, so there is no need
to mark the CMPL itself.

Change-Id: I4c27c0dc211c03b14637d420899cd2c2cccf3493
Reviewed-on: https://go-review.googlesource.com/c/go/+/518539
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>

10 months agoruntime: test that write barriers are correctly marked unpreemptible
Keith Randall [Thu, 10 Aug 2023 22:07:43 +0000 (15:07 -0700)]
runtime: test that write barriers are correctly marked unpreemptible

Followon to CL 518055.

Change-Id: I05c4b429f49feb7012070e467fefbf3392260915
Reviewed-on: https://go-review.googlesource.com/c/go/+/518538
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
10 months agocmd/compile/internal/coverage: merge Fixup{Vars,Init} into Fixup
Matthew Dempsky [Wed, 9 Aug 2023 16:21:56 +0000 (09:21 -0700)]
cmd/compile/internal/coverage: merge Fixup{Vars,Init} into Fixup

There's no need for separate fixups phases anymore.

Change-Id: Ie30a75bda4d326aa9811db3b3bd1dade0b242706
Reviewed-on: https://go-review.googlesource.com/c/go/+/517858
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

10 months agocmd/compile: cleanup ir.Package
Matthew Dempsky [Wed, 9 Aug 2023 15:39:47 +0000 (08:39 -0700)]
cmd/compile: cleanup ir.Package

Decls used to contain initializer statement for package-level
variables, but now it only contains ir.Funcs. So we might as well
rename it to Funcs and tighten its type to []*ir.Func.

Similarly, Externs always contains *ir.Names, so its type can be
constrained too.

Change-Id: I85b833e2f83d9d3559ab0ef8ab5d8324f4bc37b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/517855
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agocmd/compile: move early deadcode into unified writer
Matthew Dempsky [Wed, 9 Aug 2023 11:05:35 +0000 (04:05 -0700)]
cmd/compile: move early deadcode into unified writer

This CL moves the early deadcode elimination pass into the unified
writer. This allows shrinking the export data, by simplifying
expressions and removing unreachable statements. It also means we
don't need to repeatedly apply deadcode elimination on inlined calls
or instantiated generics.

Change-Id: I19bdb04861e50815fccdab39790f4aaa076121fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/517775
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agocmd/compile: make use of types2.InitOrder
Matthew Dempsky [Wed, 9 Aug 2023 08:43:47 +0000 (01:43 -0700)]
cmd/compile: make use of types2.InitOrder

types2 already computes the order that package-level variables need to
be initialized in. Start using it.

Change-Id: Idf2740f963b8146f7c927f57effdbf245f41d355
Reviewed-on: https://go-review.googlesource.com/c/go/+/517617
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agocmd/distpack: include directory entries in tar files
Russ Cox [Thu, 10 Aug 2023 03:47:27 +0000 (23:47 -0400)]
cmd/distpack: include directory entries in tar files

Various tools expect tar files to contain entries for directories.
I dropped them when writing cmd/distpack because they're not
strictly necessary and omitting them saves space, but it also
turns out to break some things, so add them back.

We will backport this to release-branch.go1.21 so that Go 1.21.1
will include the directory entries. We can't do anything about
Go 1.21.0 retroactively.

% tar tzvf go1.22rsc1.src.tar.gz | sed 10q
drwxr-xr-x  0 0      0           0 Aug 10 10:07 go/
-rw-r--r--  0 0      0        1337 Aug 10 10:07 go/CONTRIBUTING.md
-rw-r--r--  0 0      0        1479 Aug 10 10:07 go/LICENSE
-rw-r--r--  0 0      0        1303 Aug 10 10:07 go/PATENTS
-rw-r--r--  0 0      0        1455 Aug 10 10:07 go/README.md
-rw-r--r--  0 0      0         419 Aug 10 10:07 go/SECURITY.md
-rw-r--r--  0 0      0          42 Aug 10 10:07 go/VERSION
drwxr-xr-x  0 0      0           0 Aug 10 10:07 go/api/
-rw-r--r--  0 0      0        1142 Aug 10 10:07 go/api/README
-rw-r--r--  0 0      0       35424 Aug 10 10:07 go/api/except.txt
% tar tzvf go1.22rsc1.darwin-amd64.tar.gz | sed 10q
drwxr-xr-x  0 0      0           0 Aug 10 10:07 go/
-rw-r--r--  0 0      0        1337 Aug 10 10:07 go/CONTRIBUTING.md
-rw-r--r--  0 0      0        1479 Aug 10 10:07 go/LICENSE
-rw-r--r--  0 0      0        1303 Aug 10 10:07 go/PATENTS
-rw-r--r--  0 0      0        1455 Aug 10 10:07 go/README.md
-rw-r--r--  0 0      0         419 Aug 10 10:07 go/SECURITY.md
-rw-r--r--  0 0      0          42 Aug 10 10:07 go/VERSION
drwxr-xr-x  0 0      0           0 Aug 10 10:07 go/api/
-rw-r--r--  0 0      0        1142 Aug 10 10:07 go/api/README
-rw-r--r--  0 0      0       35424 Aug 10 10:07 go/api/except.txt
%

Fixes #61862.

Change-Id: Iecd9ba893015295e88715b031b79a104236b9ced
Reviewed-on: https://go-review.googlesource.com/c/go/+/518335
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>

10 months agotime: make time.Since a few nanoseconds faster
Russ Cox [Thu, 10 Aug 2023 15:56:53 +0000 (11:56 -0400)]
time: make time.Since a few nanoseconds faster

time.Since(base) is an idiom that can be used to read the system
monotonic time as efficiently as possible, when that matters.
The current code structure adds a few nanoseconds on top of
the 15-20ns the time read already takes. Remove those few.

After this CL, there is no reason at all for anyone to
//go:linkname runtime.nanotime1 instead.

Came up while investigating #61765.

Change-Id: Ic9e688af039babfc2a5a8e67dcbb02847a5eb686
Reviewed-on: https://go-review.googlesource.com/c/go/+/518336
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
10 months agostrconv: use the built-in min/max function
qiulaidongfeng [Thu, 10 Aug 2023 02:00:54 +0000 (02:00 +0000)]
strconv: use the built-in min/max function

Change-Id: Iab170943e6e80ffe08bb061e563c106b53740372

Change-Id: Iab170943e6e80ffe08bb061e563c106b53740372
GitHub-Last-Rev: 2964e03f1fbc499247bb6c3365475a91ef64547a
GitHub-Pull-Request: golang/go#61828
Reviewed-on: https://go-review.googlesource.com/c/go/+/516875
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agointernal/itoa, os: move os.uitox to itoa.Uitox
Tobias Klauser [Thu, 10 Aug 2023 19:48:58 +0000 (21:48 +0200)]
internal/itoa, os: move os.uitox to itoa.Uitox

This packages already contains other similar functions. Also add a test
for it.

Change-Id: Iafa8c14f5cb1f5ef89a0e16ccc855c568a3b5727
Reviewed-on: https://go-review.googlesource.com/c/go/+/518317
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agoos: remove unused func itox
Tobias Klauser [Thu, 10 Aug 2023 19:42:00 +0000 (21:42 +0200)]
os: remove unused func itox

It was added by CL 288792 but was never used.

Change-Id: I0c21237c0c32ee5df2ebe99b6ecd8831f9c28649
Reviewed-on: https://go-review.googlesource.com/c/go/+/518316
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agomath/big: using the min built-in function
qiulaidongfeng [Thu, 10 Aug 2023 02:01:04 +0000 (02:01 +0000)]
math/big: using the min built-in function

Change-Id: I9e95806116a8547ec782f66226d1b1382c6156de

Change-Id: I9e95806116a8547ec782f66226d1b1382c6156de
GitHub-Last-Rev: 5b4ce994c162775e91aa00c942571bc0ac8b1eca
GitHub-Pull-Request: golang/go#61829
Reviewed-on: https://go-review.googlesource.com/c/go/+/516895
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agocmd/go: enter vendor mode depending on new modules.txt workspace line
Michael Matloob [Wed, 26 Jul 2023 18:09:06 +0000 (14:09 -0400)]
cmd/go: enter vendor mode depending on new modules.txt workspace line

modules.txt gets a new ## workspace line at the start of the file if
it's generated in workspace mode. Then, when deciding whether the go
command runs in mod=vendor, we only do so if we're in the same mode
(workspace or not) as the modules.txt specifies.

For #60056

Change-Id: If478a9891a7135614326fcb80c4c33a431e4e531
Reviewed-on: https://go-review.googlesource.com/c/go/+/513756
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>

10 months agocmd/internal/objabi: add support for bisect.Matcher debug flags
Matthew Dempsky [Wed, 9 Aug 2023 07:53:03 +0000 (00:53 -0700)]
cmd/internal/objabi: add support for bisect.Matcher debug flags

Makes it more convenient to add new bisection targets.

Change-Id: I7ac14018bac1e25751234a2267f8747a281b6088
Reviewed-on: https://go-review.googlesource.com/c/go/+/517616
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
10 months agocmd/compile: ensure write barrier branches get marked uninterruptible
Keith Randall [Wed, 9 Aug 2023 22:49:48 +0000 (15:49 -0700)]
cmd/compile: ensure write barrier branches get marked uninterruptible

The branch itself can't be marked, so we ensure we mark the last
ssa.Value in the block as uninterruptible, because that's where the
branch ends up getting its uninterruptibility from.

This is somewhat conservative, as we're marking an instruction as
uninterruptible that doesn't need to be. But it is an easy fix.

TODO: figure out a test

Change-Id: Icd314f0bbdce8f80019bafb9e861baca4e7ecbb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/518055
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agocrypto/tls: add GODEBUG to control max RSA key size
Roland Shoemaker [Wed, 9 Aug 2023 01:25:59 +0000 (18:25 -0700)]
crypto/tls: add GODEBUG to control max RSA key size

Add a new GODEBUG setting, tlsmaxrsasize, which allows controlling the
maximum RSA key size we will accept during TLS handshakes.

Change-Id: I52f060be132014d219f4cd438f59990011a35c96
Reviewed-on: https://go-review.googlesource.com/c/go/+/517495
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agocmd/compile/internal/inline: refactor inline budget computation
Than McIntosh [Mon, 31 Jul 2023 19:26:26 +0000 (15:26 -0400)]
cmd/compile/internal/inline: refactor inline budget computation

Split out the code that computes the initial inline "hairyness" budget
for a function so that it can be reused (in a later patch). This is a
pure refactoring; no change in compiler functionality.

Change-Id: I9b1b7b10a7c480559b837492b10eb08771b7a145
Reviewed-on: https://go-review.googlesource.com/c/go/+/514795
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
10 months agocmd/compile/internal/ir: export 'reassigned', handle OASOP
Than McIntosh [Fri, 30 Jun 2023 20:06:10 +0000 (16:06 -0400)]
cmd/compile/internal/ir: export 'reassigned', handle OASOP

Rename the ir-local function "reassigned" to "Reassigned" so that it
can be used as part of inline heuristic analysis. Fix up the header
comment along that way, which had some stale material. Add support for
detecting reassignments via OASOP (as opposed to just simple
assignments).

Updates #61502.

Change-Id: I50f40f81263c0d7f61f30fcf0258f0b0f93acdca
Reviewed-on: https://go-review.googlesource.com/c/go/+/511560
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>

10 months agocmd/compile/internal/inline: add framework to compute func "properties"
Than McIntosh [Thu, 29 Jun 2023 19:37:26 +0000 (15:37 -0400)]
cmd/compile/internal/inline: add framework to compute func "properties"

Add some machinery to support computing function "properties" for use
in driving inlining heuristics, and a unit testing framework to check
to see if the property computations are correct for a given set of
canned Go source files. This CL is mainly the analysis skeleton and a
testing framework; the code to compute the actual props will arrive in
a later patch.

Updates #61502.

Change-Id: I7970b64f713d17d7fdd7e8e9ccc7d9b0490571bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/511557
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agocmd/compile: function "property" defs for inl heuristics
Than McIntosh [Thu, 29 Jun 2023 17:43:50 +0000 (13:43 -0400)]
cmd/compile: function "property" defs for inl heuristics

Add definitions for a set of Go function "properties" intended to be
useful for driving inlining decisions. This CL just defines a set of
flags and a container to hold them; a subsequent CL will add code to
compute the properties for a function given its IR/AST representation.

Updates #61502.

Change-Id: Ifa26c1ad055c02ca0ce9cf37078cee7b3385e18a
Reviewed-on: https://go-review.googlesource.com/c/go/+/511556
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
10 months agocmd/go/internal/web: remove a redundant return value
Bryan C. Mills [Wed, 9 Aug 2023 21:22:20 +0000 (17:22 -0400)]
cmd/go/internal/web: remove a redundant return value

The URL return value from the fetch helper in web.get was always
either the passed in URL (on success) or nil (on failure).
Remove it to reduce code complexity.

For #61877.

Change-Id: I0ce4602b921d1c996aa988e7d3f83996511ccd72
Reviewed-on: https://go-review.googlesource.com/c/go/+/518016
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>

10 months agocmd/go/internal/web: release the net token when an HTTP request fails due to CheckRed...
Bryan C. Mills [Wed, 9 Aug 2023 21:14:30 +0000 (17:14 -0400)]
cmd/go/internal/web: release the net token when an HTTP request fails due to CheckRedirect

Fixes #61877.

Change-Id: I38c63565aaf9dc9b0c8085974521daccfbcbc790
Reviewed-on: https://go-review.googlesource.com/c/go/+/518015
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agocmd/go: keep BuildInfo list sorted even with -pgo
Russ Cox [Tue, 20 Jun 2023 17:14:11 +0000 (13:14 -0400)]
cmd/go: keep BuildInfo list sorted even with -pgo

The -pgo build setting is added late, so sort it into place.
Noticed while working on CL 504536.

Change-Id: I080d2389dc0b3176fb72c9e2434e5f3ae70e294e
Reviewed-on: https://go-review.googlesource.com/c/go/+/504537
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agocmd/compile: add -env key=value flag
Russ Cox [Wed, 5 Jul 2023 19:11:41 +0000 (15:11 -0400)]
cmd/compile: add -env key=value flag

This flag is not terribly useful with the go command, which will pass
all environment variables through to subprocesses it invokes,
but it can be useful in other build systems, notably blaze and bazel,
to pass compiler-debugging variables like GOSSAFUNC through to
the compiler.

We have been maintaining this as a patch against Google's internal
toolchain for many years, and it has proven useful in those non-go-command
contexts.

Change-Id: Ic123193319f3c838a694eda2575347c516b85ac7
Reviewed-on: https://go-review.googlesource.com/c/go/+/507977
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

10 months agoos: define TestIssue60181 only on Unix platforms
Bryan C. Mills [Thu, 10 Aug 2023 14:39:58 +0000 (10:39 -0400)]
os: define TestIssue60181 only on Unix platforms

In CL 517755 the test was added in the unconstrained os_test.go
because it appeared to be portable, but it turned out not to be
valid on plan9.

(The build error was masked on the misc-compile TryBots by #61923.)

Although the test can also compile and run on Windows, the bug it
checks for is specific to Linux and only really needs to run there, so
I am moving it to os_unix_test.go instead of adding yet another test
file for “Unix and Windows but not Plan 9”.

Updates #60181.

Change-Id: I41fd11b288217e95652b5daa72460c0d26bde606
Reviewed-on: https://go-review.googlesource.com/c/go/+/518255
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
10 months agoruntime/pprof: fix build breakage on ios
Cosmos Nicolaou [Wed, 9 Aug 2023 15:15:51 +0000 (08:15 -0700)]
runtime/pprof: fix build breakage on ios

CL 503919 breaks tests for ios, this change fixes that.

Fixes #61891

Change-Id: I58508a780abb7a2150faec83c0f002cb22abafb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/517795
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

10 months agosyscall: avoid setting O_NONBLOCK needlessly by checking flags beforehand
Andy Pan [Wed, 9 Aug 2023 13:13:50 +0000 (21:13 +0800)]
syscall: avoid setting O_NONBLOCK needlessly by checking flags beforehand

Change-Id: I097a2941f1d1a7fd98ccf1534940d03f47ac3229
Reviewed-on: https://go-review.googlesource.com/c/go/+/517675
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>

10 months agoarchive/tar: correct value passed to Uname method
Ian Lance Taylor [Thu, 10 Aug 2023 00:46:00 +0000 (17:46 -0700)]
archive/tar: correct value passed to Uname method

For #50102

Change-Id: I28b5579611b07952b6379bc4603daf29a86a3be0
Reviewed-on: https://go-review.googlesource.com/c/go/+/518056
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tianon Gravi (Andrew) <admwiggin@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
10 months agocmd/compile: fold most repetitive operations to simplify riscv64 rules
Junxian Zhu [Fri, 26 May 2023 02:43:01 +0000 (10:43 +0800)]
cmd/compile: fold most repetitive operations to simplify riscv64 rules

Most of repetitive rules in riscv64 are simple, so that we can simplify and fold it with | without losting rules readability.

No change in the actual compiler code after running rulegen.

Change-Id: Id0bbfd93e63b49b7f66ecb62eb9440b4900c7938
Reviewed-on: https://go-review.googlesource.com/c/go/+/498455
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: M Zhuo <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: M Zhuo <mzh@golangcn.org>
10 months agoruntime: fix asan asm on amd64
Matthew Dempsky [Wed, 9 Aug 2023 09:51:59 +0000 (02:51 -0700)]
runtime: fix asan asm on amd64

On amd64, the 8-byte move instruction is MOVQ, not MOVD.

Change-Id: I48d9b6f5f9f6c7f2e3fe20fd017b816cfb3983a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/517635
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agoos: test that copying to append-only files doesn't fail on Linux
Tobias Klauser [Wed, 9 Aug 2023 14:51:10 +0000 (16:51 +0200)]
os: test that copying to append-only files doesn't fail on Linux

Before CL 494915, this test would fail on Linux in io.Copy with error
"write /dev/stdout: copy_file_range: bad file descriptor" because the
copy_file_range syscall doesn't support destination files opened with
O_APPEND, see
https://man7.org/linux/man-pages/man2/copy_file_range.2.html#ERRORS

For #60181

Change-Id: I2eb4bcac71175121821e0033eb2297a2bc4ec759
Reviewed-on: https://go-review.googlesource.com/c/go/+/517755
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>

10 months agoall: update vendored dependencies
Michael Anthony Knyszek [Wed, 9 Aug 2023 19:38:27 +0000 (19:38 +0000)]
all: update vendored dependencies

Generated by:

go install golang.org/x/tools/cmd/bundle@latest
go install golang.org/x/build/cmd/updatestd@latest
updatestd -goroot=$GOROOT -branch=master

For #36905.

Change-Id: I11c3376452b0b03eb91a87619b70d74e6ce897bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/517875
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agocmd/compile: make backingArrayPtrLen to return typecheck-ed nodes
Cuong Manh Le [Wed, 9 Aug 2023 18:51:17 +0000 (01:51 +0700)]
cmd/compile: make backingArrayPtrLen to return typecheck-ed nodes

Fixes #61908

Change-Id: Ief8e3a6c42c0644c9f71ebef5f28a294cd7c153f
Reviewed-on: https://go-review.googlesource.com/c/go/+/517936
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agocmd/go: fix missing case checking for empty slice
Michael Matloob [Mon, 7 Aug 2023 21:03:43 +0000 (17:03 -0400)]
cmd/go: fix missing case checking for empty slice

When we were comparing the first element of import stacks when sorting
depserrors we checked if the first stack was non empty, but not the
second one. Do the check for both stacks.

Fixes #61816
For #59905

Change-Id: Id5c11c2b1104eec93196a08c53372ee2ba97c701
Reviewed-on: https://go-review.googlesource.com/c/go/+/516739
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>

10 months agocmd/compile: mark instantiated functions from package runtime as norace
Cuong Manh Le [Tue, 13 Jun 2023 15:25:50 +0000 (22:25 +0700)]
cmd/compile: mark instantiated functions from package runtime as norace

Fixes #60439

Change-Id: I09fcd2d3deb7f80ed012a769fdb6f53b09c0290b
Reviewed-on: https://go-review.googlesource.com/c/go/+/502895
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
10 months agocmd/compile: keep all open-coded defer slots as used
Matthew Dempsky [Wed, 9 Aug 2023 16:04:37 +0000 (09:04 -0700)]
cmd/compile: keep all open-coded defer slots as used

Open-coded defer slots are assigned indices upfront, so they're
logically like elements in an array. Without reassigning the indices,
we need to keep all of the elements alive so their relative offsets
are correct.

Fixes #61895.

Change-Id: Ie0191fdb33276f4e8ed0becb69086524fff022b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/517856
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agoruntime: improve performance of empty map with interface key type
cuiweixie [Fri, 9 Jun 2023 14:59:48 +0000 (22:59 +0800)]
runtime: improve performance of empty map with interface key type

name                            old time/op    new time/op    delta
MegEmptyMapWithInterfaceKey-10    15.5µs ± 0%     0.0µs ± 0%  -99.97%  (p=0.000 n=20+16)

name                            old alloc/op   new alloc/op   delta
MegEmptyMapWithInterfaceKey-10     0.00B          0.00B          ~     (all equal)

name                            old allocs/op  new allocs/op  delta
MegEmptyMapWithInterfaceKey-10      0.00           0.00          ~     (all equal)

Change-Id: I46248223100e98b7877464da640075d272c14802
Reviewed-on: https://go-review.googlesource.com/c/go/+/502075
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
10 months agoos: make MkdirAll support volume names
qmuntal [Tue, 8 Aug 2023 13:31:43 +0000 (15:31 +0200)]
os: make MkdirAll support volume names

MkdirAll fails to create directories under root paths using volume
names (e.g. //?/Volume{GUID}/foo). This is because fixRootDirectory
only handle extended length paths using drive letters (e.g. //?/C:/foo).

This CL fixes that issue by also detecting volume names without path
separator.

Updates #22230
Fixes #39785

Change-Id: I813fdc0b968ce71a4297f69245b935558e6cd789
Reviewed-on: https://go-review.googlesource.com/c/go/+/517015
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agocmd/dist: remove unnecessary parts of bootstrapDirs
qiulaidongfeng [Wed, 9 Aug 2023 02:48:54 +0000 (02:48 +0000)]
cmd/dist: remove unnecessary parts of bootstrapDirs

Change-Id: I7658f2f1716f74b4ff0b4b9f8ccd386e99dd9d51

Change-Id: I7658f2f1716f74b4ff0b4b9f8ccd386e99dd9d51
GitHub-Last-Rev: f55b84dafb646fbfc0e4d0824d28d0dbf27e56c3
GitHub-Pull-Request: golang/go#61831
Reviewed-on: https://go-review.googlesource.com/c/go/+/516935
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: 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@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

10 months agointernal/bisect: fix PrintMarker and examples
Matthew Dempsky [Wed, 9 Aug 2023 08:19:38 +0000 (01:19 -0700)]
internal/bisect: fix PrintMarker and examples

PrintMarker was printing 50 NUL bytes before the marker.

Also, the examples for writing your own ShouldEnable helper suggest
"if m == nil { return false }", but this is inconsistent with how
Matcher.ShouldEnable handles nil pointers.

Change-Id: Ie45075ba7fb8fcc63eadce9d793a06ef0c8aa9f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/517615
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

10 months agoruntime/cgo: use frame address to set g0 stack bound
Ian Lance Taylor [Tue, 8 Aug 2023 19:49:48 +0000 (12:49 -0700)]
runtime/cgo: use frame address to set g0 stack bound

This extends CL 419434 to all Unix targets. Rather than repeating
the code, pull all the similar code into a single function.

CL 419434 description:

For a cgo binary, at startup we set g0's stack bounds using the
address of a local variable (&size) in a C function x_cgo_init and
the stack size from pthread_attr_getstacksize. Normally, &size is
an address within the current stack frame. However, when  it is
compiled with ASAN, it may be instrumented to __asan_stack_malloc_0
and the address may not live in the current stack frame, causing
the stack bound to be set incorrectly, e.g. lo > hi.

Using __builtin_frame_address(0) to get the stack address instead.

Change-Id: I914a09d32c66a79515b6f700be18c690f3c0c77b
Reviewed-on: https://go-review.googlesource.com/c/go/+/517335
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

10 months agonet/http: sanitize User-Agent header in request writer
Damien Neil [Mon, 7 Aug 2023 22:57:54 +0000 (15:57 -0700)]
net/http: sanitize User-Agent header in request writer

Apply the same transformations to the User-Agent header value that we
do to other headers.

Avoids header and request smuggling in Request.Write and
Request.WriteProxy. RoundTrip already validates values in
Request.Header, and didn't allow bad User-Agent values to
make it as far as the request writer.

Fixes #61824

Change-Id: I360a915c7e08d014e0532bd5af196a5b59c89395
Reviewed-on: https://go-review.googlesource.com/c/go/+/516836
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agopath/filepath: don't drop .. elements when cleaning invalid Windows paths
Damien Neil [Tue, 8 Aug 2023 21:07:08 +0000 (14:07 -0700)]
path/filepath: don't drop .. elements when cleaning invalid Windows paths

Fix a bug where Clean could improperly drop .. elements from a
path on Windows, when the path contains elements containing a ':'.

For example, Clean("a/../b:/../../c") now correctly returns "..\c"
rather than "c".

Fixes #61866

Change-Id: I97b0238953c183b2ce19ca89c14f26700008ea72
Reviewed-on: https://go-review.googlesource.com/c/go/+/517216
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
10 months agocmd/compile: use new for loop semantics for Go 1.22+ compilations
David Chase [Wed, 5 Jul 2023 20:21:19 +0000 (16:21 -0400)]
cmd/compile: use new for loop semantics for Go 1.22+ compilations

This includes version-dependent support for GOEXPERIMENT and
-d=loopvar, -d=loopvarhash, to allow testing/porting of old code.

Includes tests of downgrade (1.22 -> 1.21) and upgrade (1.21 -> 1.22)
based on //go:build lines (while running a 1.22 build/compiler).

Change-Id: Idd3be61a2b46acec33c7e7edac0924158cc726b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/508819
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agodatabase/sql: use reflect.TypeFor for known types
Ian Lance Taylor [Tue, 1 Aug 2023 19:37:15 +0000 (12:37 -0700)]
database/sql: use reflect.TypeFor for known types

For #60088

Change-Id: Ib05ba3d456b22f7370459037b3d263c4b3ebe3b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/514975
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: 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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agocmd/cgo/internal/testplugin: simplify TestForkExec and log stderr output
Bryan C. Mills [Tue, 8 Aug 2023 16:02:02 +0000 (12:02 -0400)]
cmd/cgo/internal/testplugin: simplify TestForkExec and log stderr output

This test used to run with a separate goroutine for timeout behavior,
presumably because it was difficult to set an appropriate timeout.

Now that the test is in cmd instead of misc, we can use
internal/testenv.Command, which makes adding the test timeout much
simpler and eliminates the need for the explicit goroutine.

For #61846.

Change-Id: I68ea09fcf2aa394bed1e900cf30ef7d143fa249f
Reviewed-on: https://go-review.googlesource.com/c/go/+/517095
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

10 months agoos: follow all name surrogate reparse points in Stat on Windows
qmuntal [Mon, 7 Aug 2023 09:24:13 +0000 (11:24 +0200)]
os: follow all name surrogate reparse points in Stat on Windows

Previously, os.Stat only followed IO_REPARSE_TAG_SYMLINK
and IO_REPARSE_TAG_MOUNT_POINT reparse points.

This CL generalize the logic to detect which reparse points to follow
by using the reparse tag value to determine whether the reparse point
refers to another named entity, as documented in
https://learn.microsoft.com/en-us/windows/win32/fileio/reparse-point-tags.

The new behavior adds implicit support for correctly stat-ing reparse
points other than mount points and symlinks, e.g.,
IO_REPARSE_TAG_WCI_LINK and IO_REPARSE_TAG_IIS_CACHE.

Updates #42184

Change-Id: I51f56127d4dc6c0f43eb5dfa3bfa6d9e3922d000
Reviewed-on: https://go-review.googlesource.com/c/go/+/516555
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>

10 months agoslices: add Concat
Carl Johnson [Tue, 8 Aug 2023 01:14:22 +0000 (01:14 +0000)]
slices: add Concat

Fixes #56353

Change-Id: I985e1553e7b02237403b833e96fb5ceec890f5b8
GitHub-Last-Rev: 96a35e524c168e5004c5cd28e693437462218eeb
GitHub-Pull-Request: golang/go#60929
Reviewed-on: https://go-review.googlesource.com/c/go/+/504882
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agocmd/internal/obj/mips: add SEB/SEH instructions
Junxian Zhu [Thu, 3 Aug 2023 06:44:01 +0000 (14:44 +0800)]
cmd/internal/obj/mips: add SEB/SEH instructions

Add support for SEB/SEH instructions, which are introduced in mips32r2.

SEB/SEH can be used to sign-extend byte/halfword in registers directly without passing through memory.

Ref: The MIPS32 Instruction Set, Revision 5.04: https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00086-2B-MIPS32BIS-AFP-05.04.pdf

Updates #60072

Change-Id: I33175ae9d943ead5983ac004bd2a158039046d65
Reviewed-on: https://go-review.googlesource.com/c/go/+/515475
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>

10 months agointernal/syscall/unix: don't define libc_getentropy_trampoline on ios
Ian Lance Taylor [Mon, 31 Jul 2023 18:13:35 +0000 (11:13 -0700)]
internal/syscall/unix: don't define libc_getentropy_trampoline on ios

It is only used on Darwin. This fixes "go vet" on ios.

Fixes #61667

Change-Id: Iaf00fcee5d89eb8e454f75bb1c0ea62c3950b684
Reviewed-on: https://go-review.googlesource.com/c/go/+/514495
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

10 months agointernal/bytealg: optimize Count/CountString in amd64
Mauri de Souza Meneguzzo [Mon, 7 Aug 2023 00:53:33 +0000 (00:53 +0000)]
internal/bytealg: optimize Count/CountString in amd64

Another optimization by aligning a hot loop.

```
                   │   sec/op    │   sec/op     vs base                │
Count/10-16          11.29n ± 1%   10.50n ± 1%   -7.04% (p=0.000 n=10)
Count/32-16          11.06n ± 1%   11.36n ± 2%   +2.76% (p=0.000 n=10)
Count/4K-16          2.852µ ± 1%   1.953µ ± 1%  -31.52% (p=0.000 n=10)
Count/4M-16          2.884m ± 1%   1.958m ± 1%  -32.11% (p=0.000 n=10)
Count/64M-16         46.27m ± 1%   30.86m ± 0%  -33.31% (p=0.000 n=10)
CountEasy/10-16      9.873n ± 1%   9.669n ± 1%   -2.07% (p=0.000 n=10)
CountEasy/32-16      11.07n ± 1%   11.23n ± 1%   +1.49% (p=0.000 n=10)
CountEasy/4K-16      73.47n ± 1%   54.20n ± 0%  -26.22% (p=0.000 n=10)
CountEasy/4M-16      61.12µ ± 1%   49.42µ ± 0%  -19.15% (p=0.000 n=10)
CountEasy/64M-16     1.303m ± 3%   1.082m ± 4%  -16.97% (p=0.000 n=10)
CountSingle/10-16    4.150n ± 1%   3.679n ± 1%  -11.36% (p=0.000 n=10)
CountSingle/32-16    4.815n ± 1%   4.588n ± 1%   -4.71% (p=0.000 n=10)
CountSingle/4M-16    72.18µ ± 2%   75.38µ ± 1%   +4.44% (p=0.000 n=10)
CountHard3-16        462.6µ ± 1%   484.4µ ± 1%   +4.73% (p=0.000 n=10)

                   │   old.txt    │               new.txt                │
                   │     B/s      │     B/s       vs base                │
Count/10-16          844.1Mi ± 1%   908.3Mi ± 1%   +7.60% (p=0.000 n=10)
Count/32-16          2.695Gi ± 1%   2.623Gi ± 2%   -2.66% (p=0.000 n=10)
Count/4K-16          1.337Gi ± 1%   1.953Gi ± 1%  +46.06% (p=0.000 n=10)
Count/4M-16          1.355Gi ± 1%   1.995Gi ± 1%  +47.29% (p=0.000 n=10)
Count/64M-16         1.351Gi ± 1%   2.026Gi ± 0%  +49.95% (p=0.000 n=10)
CountEasy/10-16      965.9Mi ± 1%   986.3Mi ± 1%   +2.11% (p=0.000 n=10)
CountEasy/32-16      2.693Gi ± 1%   2.653Gi ± 1%   -1.48% (p=0.000 n=10)
CountEasy/4K-16      51.93Gi ± 1%   70.38Gi ± 0%  +35.54% (p=0.000 n=10)
CountEasy/4M-16      63.91Gi ± 1%   79.05Gi ± 0%  +23.68% (p=0.000 n=10)
CountEasy/64M-16     47.97Gi ± 3%   57.77Gi ± 4%  +20.44% (p=0.000 n=10)
CountSingle/10-16    2.244Gi ± 1%   2.532Gi ± 1%  +12.80% (p=0.000 n=10)
CountSingle/32-16    6.190Gi ± 1%   6.496Gi ± 1%   +4.94% (p=0.000 n=10)
CountSingle/4M-16    54.12Gi ± 2%   51.82Gi ± 1%   -4.25% (p=0.000 n=10)
```

Change-Id: I847b36125d2b11e2a88d31f48f6c160f041b3624
GitHub-Last-Rev: faacba662ee6bf41f69960060d48d340cfdbbbd6
GitHub-Pull-Request: golang/go#61793
Reviewed-on: https://go-review.googlesource.com/c/go/+/516455
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>

10 months agonet/http: permit requests with invalid Host headers
Damien Neil [Wed, 19 Jul 2023 17:30:46 +0000 (10:30 -0700)]
net/http: permit requests with invalid Host headers

Historically, the Transport has silently truncated invalid
Host headers at the first '/' or ' ' character. CL 506996 changed
this behavior to reject invalid Host headers entirely.
Unfortunately, Docker appears to rely on the previous behavior.

When sending a HTTP/1 request with an invalid Host, send an empty
Host header. This is safer than truncation: If you care about the
Host, then you should get the one you set; if you don't care,
then an empty Host should be fine.

Continue to fully validate Host headers sent to a proxy,
since proxies generally can't productively forward requests
without a Host.

For #60374
Fixes #61431

Change-Id: If170c7dd860aa20eb58fe32990fc93af832742b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/511155
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>