]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
9 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>

9 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>

9 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>

9 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>

9 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>
9 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>

9 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>

9 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>

9 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>
9 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>

9 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>
9 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>
9 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>

9 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>
9 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>
9 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>

9 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>
9 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>
9 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>

9 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>
9 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>

9 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>

9 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>
9 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>

9 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>

9 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>

9 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>

9 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>
9 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>

10 months agoRevert "runtime: move pcvalue cache to M"
Austin Clements [Mon, 7 Aug 2023 22:11:39 +0000 (18:11 -0400)]
Revert "runtime: move pcvalue cache to M"

This reverts CL 515276.

This broke the longtest builders. For example:
https://build.golang.org/log/351a1a198a6b843b1881c1fb6cdef51f3e413e8b

Change-Id: Ie79067464fe8e226da31721cf127f3efb6011452
Reviewed-on: https://go-review.googlesource.com/c/go/+/516856
Auto-Submit: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agoRevert "runtime: drop stack-allocated pcvalueCaches"
Austin Clements [Mon, 7 Aug 2023 22:11:17 +0000 (18:11 -0400)]
Revert "runtime: drop stack-allocated pcvalueCaches"

This reverts CL 515277

Change-Id: Ie10378eed4993cb69f4a9b43a38af32b9d743155
Reviewed-on: https://go-review.googlesource.com/c/go/+/516855
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agogo/types: fix panic in allowVersion when pos is invalid
Robert Findley [Mon, 7 Aug 2023 19:46:34 +0000 (15:46 -0400)]
go/types: fix panic in allowVersion when pos is invalid

CL 515656 updated go/types to use file base as key in the posVers map,
but introduced a panic when the corresponding *token.File is nil.

Check that pos is valid before performing the lookup.

Fixes #61822

Change-Id: I1ac9d48c831a470de8439a50022ba5f59b3e0bed
Reviewed-on: https://go-review.googlesource.com/c/go/+/516738
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Robert Findley <rfindley@google.com>

10 months agoruntime: drop stack-allocated pcvalueCaches
Austin Clements [Tue, 1 Aug 2023 18:41:42 +0000 (14:41 -0400)]
runtime: drop stack-allocated pcvalueCaches

Now that pcvalue keeps its cache on the M, we can drop all of the
stack-allocated pcvalueCaches and stop carefully passing them around
between lots of operations. This significantly simplifies a fair
amount of code and makes several structures smaller.

This series of changes has no statistically significant effect on any
runtime Stack benchmarks.

I also experimented with making the cache larger, now that the impact
is limited to the M struct, but wasn't able to measure any
improvements.

Change-Id: I4719ebf347c7150a05e887e75a238e23647c20cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/515277
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
10 months agoruntime: move pcvalue cache to M
Austin Clements [Tue, 1 Aug 2023 17:54:32 +0000 (13:54 -0400)]
runtime: move pcvalue cache to M

Currently, the pcvalue cache is stack allocated for each operation
that needs to look up a lot of pcvalues. It's not always clear where
to put it, a lot of the time we just pass a nil cache, it doesn't get
reused across operations, and we put a surprising amount of effort
into threading these caches around.

This CL moves it to the M, where it can be long-lived and used by all
pcvalue lookups, and we don't have to carefully thread it across
operations.

Change-Id: I675e583e0daac887c8ef77a402ba792648d96027
Reviewed-on: https://go-review.googlesource.com/c/go/+/515276
Run-TryBot: Austin Clements <austin@google.com>
Auto-Submit: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
10 months agoruntime: store start PC in pcvalueCache
Austin Clements [Tue, 1 Aug 2023 17:45:31 +0000 (13:45 -0400)]
runtime: store start PC in pcvalueCache

Currently, pcvalue only returns a valid start PC if cache is nil.
We're about to eliminate the cache argument and always use a pcvalue
cache, so make sure the cache stores the start PC and always return it
from pcvalue.

Change-Id: Ie8854af4b7e7ba1c2a17a495d9229320821daa23
Reviewed-on: https://go-review.googlesource.com/c/go/+/515275
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agosort: use the builtin min function
Muhammad Falak R Wani [Mon, 7 Aug 2023 13:44:06 +0000 (13:44 +0000)]
sort: use the builtin min function

Change-Id: I9603de9abff8d5c8fb9efdf688ff1a5f8c7d19b2
GitHub-Last-Rev: c6fe3acc41a3a9c7d07e3c291985867a704013b1
GitHub-Pull-Request: golang/go#61808
Reviewed-on: https://go-review.googlesource.com/c/go/+/516635
Auto-Submit: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
10 months agotesting: use the builtin max/min function
Muhammad Falak R Wani [Mon, 7 Aug 2023 13:44:17 +0000 (13:44 +0000)]
testing: use the builtin max/min function

Change-Id: I1250b6a33f5f3509a216d307f1783ad4aa5937fc
GitHub-Last-Rev: 98dc6b1a11eea8542551a368780a74c1ee2d7083
GitHub-Pull-Request: golang/go#61809
Reviewed-on: https://go-review.googlesource.com/c/go/+/516616
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agostrings: use the builtin max function
Muhammad Falak R Wani [Mon, 7 Aug 2023 13:43:52 +0000 (13:43 +0000)]
strings: use the builtin max function

Change-Id: I9093c0ce822f0620152a7b911321c57bc50dc90b
GitHub-Last-Rev: dc6be231b315262e13925814b16786618ef5dad4
GitHub-Pull-Request: golang/go#61807
Reviewed-on: https://go-review.googlesource.com/c/go/+/516615
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agotesting: improve the usage message of -benchtime
montag451 [Fri, 4 Aug 2023 22:04:10 +0000 (22:04 +0000)]
testing: improve the usage message of -benchtime

Specify that -benchtime can take the form Nx.

Change-Id: I1e711cdb2e19e3ff5eb2cea4e7c8843bc58696b1
GitHub-Last-Rev: 1cb13f7dba829497c5cbb3d4c578f4984e1cbd28
GitHub-Pull-Request: golang/go#61756
Reviewed-on: https://go-review.googlesource.com/c/go/+/515801
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: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agoruntime: avoid relying on the unwinder in deferreturn
Matthew Dempsky [Fri, 4 Aug 2023 03:29:47 +0000 (20:29 -0700)]
runtime: avoid relying on the unwinder in deferreturn

This CL changes deferreturn so that it never needs to invoke the
unwinder. Instead, in the unusual case that we recover into a frame
with pending open-coded defers, we now save the extra state needed to
find them in g.param.

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

10 months agotesting/slogtest: reword a confusing explanation
Jonathan Amsterdam [Fri, 4 Aug 2023 18:39:48 +0000 (14:39 -0400)]
testing/slogtest: reword a confusing explanation

Updates #61758.

Change-Id: I4ce0359f676b6832e40203e1034ba1c4f6d2b2ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/516155
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Patrick Ohly <patrick.ohly@googlemail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
10 months agoruntime, cmd/compile: optimize open-coded defers
Matthew Dempsky [Fri, 4 Aug 2023 21:10:59 +0000 (14:10 -0700)]
runtime, cmd/compile: optimize open-coded defers

This CL optimizes open-coded defers in two ways:

1. It modifies local variable sorting to place all open-coded defer
closure slots in order, so that rather than requiring the metadata to
contain each offset individually, we just need a single offset to the
first slot.

2. Because the slots are in ascending order and can be directly
indexed, we can get rid of the count of how many defers are in the
frame. Instead, we just find the top set bit in the active defers
bitmask, and load the corresponding closure.

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

10 months agonet/http: add ServeFileFS, FileServerFS, NewFileTransportFS
Mauri de Souza Meneguzzo [Mon, 31 Jul 2023 20:58:45 +0000 (20:58 +0000)]
net/http: add ServeFileFS, FileServerFS, NewFileTransportFS

These new apis are analogous to ServeFile, FileServer and NewFileTransport respectively. The main difference is that these functions operate on an fs.FS.

Fixes #51971

Change-Id: Ie56b245b795eeb7edf613657578592306945469b
GitHub-Last-Rev: 26e75c0368f155a2299fbdcb72f47036b71a5e06
GitHub-Pull-Request: golang/go#61641
Reviewed-on: https://go-review.googlesource.com/c/go/+/513956
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
10 months agolog/slog: restore the original log setting before test exits
Andy Pan [Thu, 3 Aug 2023 22:47:56 +0000 (06:47 +0800)]
log/slog: restore the original log setting before test exits

Change-Id: Ib3daffb8a4cc018d62ed6e5741355b1c1a206034
Reviewed-on: https://go-review.googlesource.com/c/go/+/515775
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
10 months agoruntime, cmd/compile: prune unused _defer fields
Matthew Dempsky [Fri, 4 Aug 2023 21:15:39 +0000 (14:15 -0700)]
runtime, cmd/compile: prune unused _defer fields

These fields are no longer needed since go.dev/cl/513837.

Change-Id: I980fc9db998c293e930094bbb87e8c8f1654e39c
Reviewed-on: https://go-review.googlesource.com/c/go/+/516198
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
10 months agogo/types: use file start position as key for Info.FileVersions
Robert Griesemer [Thu, 3 Aug 2023 19:55:16 +0000 (12:55 -0700)]
go/types: use file start position as key for Info.FileVersions

Per discussion on CL 515135.

While at it, also use the file start position as key for the
internal map Checker.posVers.

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

10 months agolog/slog: don't panic on aliased Record
Jonathan Amsterdam [Fri, 28 Jul 2023 14:35:10 +0000 (10:35 -0400)]
log/slog: don't panic on aliased Record

If the shared slice in a copied is modified, make a copy of it
and insert an attribute that warns of the bug.

Previously, we panicked, and panics in logging code should be avoided.

Change-Id: I24e9b0bf5c8cd09cf733e7dae8a82d025ef214e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/513760
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agodatabase/sql: add Null[T]
Inada Naoki [Sat, 5 Aug 2023 16:22:48 +0000 (16:22 +0000)]
database/sql: add Null[T]

Generic version of NullString, NullInt64, etc.

Fixes #60370

Change-Id: I166a05a6126e8b8571db5cbb026303bb6551d56b
GitHub-Last-Rev: 3c8d2d5141c36f034d2124e19ee090620363ba24
GitHub-Pull-Request: golang/go#60677
Reviewed-on: https://go-review.googlesource.com/c/go/+/501700
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
10 months agotime: amend time resolution docs
qmuntal [Thu, 3 Aug 2023 08:07:21 +0000 (10:07 +0200)]
time: amend time resolution docs

Updates #44343

Change-Id: Id1497f0236fe7b4937e64877fa943329e280d192
Reviewed-on: https://go-review.googlesource.com/c/go/+/515495
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agogo/ast: deprecate Object
Alan Donovan [Wed, 21 Jun 2023 17:49:42 +0000 (13:49 -0400)]
go/ast: deprecate Object

The following declarations related to syntactic object resolution
are now deprecated:
- Ident.Obj
- Object
- Scope
- File.{Scope,Unresolved}
- Importer
- Package, NewPackage
New programs should use the type checker instead.

Updates golang/go#52463
Updates golang/go#48141

Change-Id: I82b315f49b1341c11ae20dcbf81106084bd2ba86
Reviewed-on: https://go-review.googlesource.com/c/go/+/504915
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>

10 months agoos: fix test failure when Workstation service is not enabled
qiulaidongfeng [Sat, 29 Jul 2023 08:27:21 +0000 (08:27 +0000)]
os: fix test failure when Workstation service is not enabled

TestNetworkSymbolicLink needs to enable the Workstation service, otherwise it will fail.

This CL avoids failure by skipping testing when the Workstation service is not enabled.

Fixes #61467

Change-Id: I395952fc18329e0b0dfdec55c8a18f4007ea91de

Change-Id: I395952fc18329e0b0dfdec55c8a18f4007ea91de
GitHub-Last-Rev: 7f089d1dff3ca939915fc8b3e49eba3908f15180
GitHub-Pull-Request: golang/go#61564
Reviewed-on: https://go-review.googlesource.com/c/go/+/512736
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
10 months agoall: add a few more godoc links
Daniel Martí [Fri, 7 Jul 2023 09:06:05 +0000 (11:06 +0200)]
all: add a few more godoc links

Over the past few months as I read the standard library's documentation
I kept finding spots where godoc links would have helped me.
I kept adding to a stash of changes to fix them up bit by bit.

The stash has grown big enough by now, and we're nearing a release,
so I think it's time to merge to avoid git conflicts or bit rot.

Note that a few sentences are slightly reworded,
since "implements the Fooer interface" can just be "implements [Fooer]"
now that the link provides all the context needed to the user.

Change-Id: I01c31d3d3ff066d06aeb44f545f8dd0fb9a8d998
Reviewed-on: https://go-review.googlesource.com/c/go/+/508395
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agocmd/compile: fix missing init nodes for len(string([]byte)) optimization
Cuong Manh Le [Sat, 5 Aug 2023 15:51:49 +0000 (22:51 +0700)]
cmd/compile: fix missing init nodes for len(string([]byte)) optimization

CL 497276 added optimization for len(string([]byte)) by avoiding call to
slicebytetostring. However, the bytes to string expression may contain
init nodes, which need to be preserved. Otherwise, it would make the
liveness analysis confusing about the lifetime of temporary variables
created by init nodes.

Fixes #61778

Change-Id: I6d1280a7d61bcc75f11132af41bda086f084ab54
Reviewed-on: https://go-review.googlesource.com/c/go/+/516375
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.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>
10 months agocmd/compile/internal/ssagen: sort locals by alignment, not size
Matthew Dempsky [Fri, 4 Aug 2023 19:53:11 +0000 (12:53 -0700)]
cmd/compile/internal/ssagen: sort locals by alignment, not size

Sorting variables by size doesn't actually do anything, but sorting by
alignment makes sure we can optimally pack variables into the stack
frame.

While here, replace the monolithic description at the top of
cmpstackvarlt with line-by-line explanations of what each comparison
is doing.

Change-Id: I860677799618130ce4a55f084cec637cb9a2e295
Reviewed-on: https://go-review.googlesource.com/c/go/+/516197
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agocmd/compile/internal/ir: remove unused Name.{Offset,SetOffset}
Matthew Dempsky [Fri, 4 Aug 2023 19:37:52 +0000 (12:37 -0700)]
cmd/compile/internal/ir: remove unused Name.{Offset,SetOffset}

These aren't used and don't do anything useful anyway.

Change-Id: I2865f6bbb0409fa59b1fde32abb7c5f81a6bdb7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/516195
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
10 months agoos: replace "used to used" with "used to use" in description text
Jes Cok [Fri, 4 Aug 2023 04:58:40 +0000 (04:58 +0000)]
os: replace "used to used" with "used to use" in description text

Change-Id: I5445f3393373423592dfdd88b91d267c2c98d113
GitHub-Last-Rev: f554da58f49deb38101fd9ffba744bf4bf35ab55
GitHub-Pull-Request: golang/go#61749
Reviewed-on: https://go-review.googlesource.com/c/go/+/515798
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

10 months agocrypto/rand, internal/syscall/unix: use simpler random seed on NetBSD
Maya Rashish [Wed, 2 Aug 2023 08:32:07 +0000 (08:32 +0000)]
crypto/rand, internal/syscall/unix: use simpler random seed on NetBSD

sysctl kern.arandom has been supported since NetBSD 4.0, works inside a
chroot, has no confusing bells and whistles like Linux getrandom,
requires no complicated querying to avoid SIGSYS traps, and is what
NetBSD 10 will usee for the getentropy(3) library routine soon to
appear in POSIX.

Change-Id: I23bd84ecd5ff3e33e8958c60896db842c44667ba
GitHub-Last-Rev: 5db094c85ae14bbd9f80247d46d90e00061187cc
GitHub-Pull-Request: golang/go#61441
Reviewed-on: https://go-review.googlesource.com/c/go/+/511036
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
10 months agoencoding/base32: optimize Encode
korzhao [Wed, 5 Jul 2023 12:23:35 +0000 (20:23 +0800)]
encoding/base32: optimize Encode

Converts the 5 x 8-bit source byte to two 32-bit integers.
This will reduce the number of shift operations.

benchmark                      old ns/op     new ns/op     delta
BenchmarkEncode-10             9005          4426          -50.85%
BenchmarkEncodeToString-10     10739         6155          -42.69%

benchmark                      old MB/s     new MB/s     speedup
BenchmarkEncode-10             909.69       1850.81      2.03x
BenchmarkEncodeToString-10     762.84       1331.02      1.74x

Change-Id: I9418d3436b73f94a4eb4b2b525e4f83612ff4d47
Reviewed-on: https://go-review.googlesource.com/c/go/+/514095
Reviewed-by: Michael Knyszek <mknyszek@google.com>
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>

10 months agocmd/fix: use reflect.TypeFor for known types
cui fliter [Wed, 2 Aug 2023 08:38:12 +0000 (16:38 +0800)]
cmd/fix: use reflect.TypeFor for known types

For #60088

Change-Id: Id19435e864bcfd2adbb1492db3f8cdf2ee3c915e
Reviewed-on: https://go-review.googlesource.com/c/go/+/515175
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agoarchive/tar: add FileInfoNames interface
qiulaidongfeng [Fri, 4 Aug 2023 05:15:41 +0000 (05:15 +0000)]
archive/tar: add FileInfoNames interface

An optional interface FileInfoNames has been added.

If the parameter fi of FileInfoHeader implements the interface
the Gname and Uname of the return value Header are
provided by the method of the interface.

Also added testing.

Fixes #50102

Change-Id: I6fd06c7c9aaf29b22b7384542fe57affed33009a

Change-Id: I6fd06c7c9aaf29b22b7384542fe57affed33009a
GitHub-Last-Rev: 5e82257948759e13880d8af12743b9524ae3df5a
GitHub-Pull-Request: golang/go#61662
Reviewed-on: https://go-review.googlesource.com/c/go/+/514235
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

10 months agoencoding/xml, image/jpeg, image/png: use the builtin min function
apocelipes [Fri, 4 Aug 2023 03:15:12 +0000 (03:15 +0000)]
encoding/xml, image/jpeg, image/png: use the builtin min function

Change-Id: I9bafc7aa4e20e7cd994b75e7576156ca68f4fc8b
GitHub-Last-Rev: e037f689bddd0ef03a6ad38982fe98b4c26aaede
GitHub-Pull-Request: golang/go#61746
Reviewed-on: https://go-review.googlesource.com/c/go/+/515855
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

10 months agoos: use t.Fatalf instead of t.Errorf in TestErrProcessDone
Jes Cok [Thu, 3 Aug 2023 23:50:14 +0000 (23:50 +0000)]
os: use t.Fatalf instead of t.Errorf in TestErrProcessDone

If err is non-nil, use t.Fatalf to avoid panic when calling p.Wait().

Change-Id: Ief4e43ba5ad782999063941ed3b12f3fe4d93621
GitHub-Last-Rev: 5d32b3c082e54a914360cb4434d4cc7682e7031e
GitHub-Pull-Request: golang/go#61740
Reviewed-on: https://go-review.googlesource.com/c/go/+/515655
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agoregexp: improve Regexp.ReplaceAll documentation and tests related to Expand part
Eduard Bondarenko [Tue, 1 Aug 2023 14:48:16 +0000 (14:48 +0000)]
regexp: improve Regexp.ReplaceAll documentation and tests related to Expand part

For #40329

Change-Id: Ie0cb337545ce39cd169129227c45f7d2eaebc898
GitHub-Last-Rev: c017d4c7c1bc1f8cd39e6c70b60885cef1231dcd
GitHub-Pull-Request: golang/go#56507
Reviewed-on: https://go-review.googlesource.com/c/go/+/446836
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agocmd/compile/internal/base: optimize the readImportCfg function to make it clearer
cui fliter [Sat, 5 Aug 2023 15:52:52 +0000 (15:52 +0000)]
cmd/compile/internal/base: optimize the readImportCfg function to make it clearer

Change-Id: If8fc77d5b04b2979707032d91112d4f33ef5e3da
GitHub-Last-Rev: d82d769c04569af8a0c99a0ba9a78db641b97368
GitHub-Pull-Request: golang/go#55913
Reviewed-on: https://go-review.googlesource.com/c/go/+/435536
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agoarm64: replace "PCALGIN with PCALIGN" in package documentation
adetunjii [Sat, 5 Aug 2023 21:14:36 +0000 (21:14 +0000)]
arm64: replace "PCALGIN with PCALIGN" in package documentation

Change-Id: I476e2a75f39c876fa9c071cada36573740d546de
GitHub-Last-Rev: dec3fb438f4dd0d8e0aff300356c8d92e8ee6749
GitHub-Pull-Request: golang/go#61783
Reviewed-on: https://go-review.googlesource.com/c/go/+/516395
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

10 months agointernal/bytealg: optimize Index/IndexString in amd64
Mauri de Souza Meneguzzo [Sun, 6 Aug 2023 23:34:18 +0000 (23:34 +0000)]
internal/bytealg: optimize Index/IndexString in amd64

Now with PCALIGN available on amd64 we can start optimizing some routines that benefit from instruction alignment.

```
                         │    sec/op     │    sec/op     vs base               │
IndexByte/4K-16             69.89n ± ∞ ¹   45.88n ± ∞ ¹  -34.35% (p=0.008 n=5)
IndexByte/4M-16             65.36µ ± ∞ ¹   47.32µ ± ∞ ¹  -27.60% (p=0.008 n=5)
IndexByte/64M-16            1.435m ± ∞ ¹   1.140m ± ∞ ¹  -20.57% (p=0.008 n=5)
                         │      B/s      │      B/s       vs base               │
IndexByte/4K-16            54.58Gi ± ∞ ¹   83.14Gi ± ∞ ¹  +52.32% (p=0.008 n=5)
IndexByte/4M-16            59.76Gi ± ∞ ¹   82.54Gi ± ∞ ¹  +38.12% (p=0.008 n=5)
IndexByte/64M-16           43.56Gi ± ∞ ¹   54.84Gi ± ∞ ¹  +25.89% (p=0.008 n=5)
```

Change-Id: Iff3dfd542c55e7569242be81f38b2887b9e04e87
GitHub-Last-Rev: f309f898b13ad8fdf88a21f2f105382db9ada2f5
GitHub-Pull-Request: golang/go#61792
Reviewed-on: https://go-review.googlesource.com/c/go/+/516435
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
10 months agoio: remove manual SectionReader.Size in SectionReader.ReadAt
Jorropo [Fri, 2 Jun 2023 18:20:18 +0000 (20:20 +0200)]
io: remove manual SectionReader.Size in SectionReader.ReadAt

Change-Id: Ib3e8953dbdefa2b78c31b1bcbf0909bce248e423
Reviewed-on: https://go-review.googlesource.com/c/go/+/500475
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

10 months agoruntime,syscall: invert openbsd architecture tests
Joel Sing [Fri, 4 Aug 2023 11:27:20 +0000 (21:27 +1000)]
runtime,syscall: invert openbsd architecture tests

Rather than testing for architectures that use libc-based system calls,
test that it is not the single architecture that Go is still using direct
system calls. This reduces the number of changes needed for new openbsd
ports.

Updates #36435
Updates #61546

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

10 months agointernal/testenv: replace “go run.” with “go run”. in comments
Jes Cok [Fri, 4 Aug 2023 20:50:12 +0000 (20:50 +0000)]
internal/testenv: replace “go run.” with “go run”. in comments

Change-Id: I7d960ebeac38262c8ee39deeed9e1a2ea2803f5f
GitHub-Last-Rev: 59c5d7ea76dcca5424ce79f6030196c8adbf1fd9
GitHub-Pull-Request: golang/go#61755
Reviewed-on: https://go-review.googlesource.com/c/go/+/515800
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@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>

10 months agoruntime/pprof: correct field alignment in machVMRegionBasicInfoData
Cherry Mui [Fri, 4 Aug 2023 20:30:40 +0000 (16:30 -0400)]
runtime/pprof: correct field alignment in machVMRegionBasicInfoData

The type machVMRegionBasicInfoData is generated from C type
vm_region_basic_info_data_64_t, which is a packed struct with a
64-bit field at offset 20. We cannot use uint64 as the field type
in the Go struct, as that will be aligned at offset 24, which does
not match the C struct. Change back to [8]byte (which is what the
cgo command generates), but keep the name Offset.

Updates #61707.
Updates #50891.

Change-Id: I2932328d7f9dfe9d79cff89752666c794d4d3788
Reviewed-on: https://go-review.googlesource.com/c/go/+/516156
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>

10 months agodoc: move Go 1.21 release notes to x/website
David Chase [Fri, 4 Aug 2023 16:57:32 +0000 (12:57 -0400)]
doc: move Go 1.21 release notes to x/website

Now that the development of the Go 1.21 release is almost done, its
release notes are moved to their eventual long-term home in x/website
in CL 516095. Delete the initial development copy here.

For golang/go#58645.

Change-Id: I5207d21289b2e7b9328c943a088f45bc81c710a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/516075
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
10 months agodoc/go1.21: update crypto release notes
Filippo Valsorda [Fri, 4 Aug 2023 13:47:36 +0000 (15:47 +0200)]
doc/go1.21: update crypto release notes

Left out the following commits that felt more bug-fixy.

f0de4b4f03 - crypto/x509: fix certificate validation with FQDN on Windows <Patryk Chelmecki>
20e08fe68c - crypto/tls: advertise correct ciphers in TLS 1.3 only mode <Monis Khan>
295c237b4d - crypto/tls: enforce 1.3 record version semantics <Roland Shoemaker>

Change-Id: Idd38b5c6897130424a0e8b857f371d7d384fc143
Reviewed-on: https://go-review.googlesource.com/c/go/+/515955
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>

10 months agocmd/compile: don't use BTS when OR works, add direct memory BTS operations
Keith Randall [Tue, 1 Aug 2023 21:32:56 +0000 (14:32 -0700)]
cmd/compile: don't use BTS when OR works, add direct memory BTS operations

Stop using BTSconst and friends when ORLconst can be used instead.
OR can be issued by more function units than BTS can, so it could
lead to better IPC. OR might take a few more bytes to encode, but
not a lot more.

Still use BTSconst for cases where the constant otherwise wouldn't
fit and would require a separate movabs instruction to materialize
the constant. This happens when setting bits 31-63 of 64-bit targets.

Add BTS-to-memory operations so we don't need to load/bts/store.

Fixes #61694

Change-Id: I00379608df8fb0167cb01466e97d11dec7c1596c
Reviewed-on: https://go-review.googlesource.com/c/go/+/515755
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
10 months agoruntime: add deferreturn fast path for linked defers
Matthew Dempsky [Thu, 3 Aug 2023 20:52:00 +0000 (13:52 -0700)]
runtime: add deferreturn fast path for linked defers

A consequence of go.dev/cl/513837 was that calling deferreturn would
now use the unwinder to find (just) the current frame, and it turns
out there are workloads where this has a significant performance
impact.

As a simple optimization, this CL adds a fast path for deferreturn to
detect when there are pending linked defers, which allows us to skip
invoking the unwinder entirely.

Notably, this still doesn't handle the corner case of calling
deferreturn in a function that uses linked defer when dynamically
there just aren't any defers pending. It also means that after
recovering from a panic and returning to a frame that used open-coded,
we still need to use the unwinder too.

I hope to further optimize defer handling to improve these cases too,
but this is an easy, short-term optimization that relieves the
performance impact to the affected workloads.

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