]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
12 months agoRevert "math: add Compare and Compare32"
Ian Lance Taylor [Tue, 30 May 2023 22:19:44 +0000 (15:19 -0700)]
Revert "math: add Compare and Compare32"

This reverts CL 467515. Now that we have cmp.Compare,
we don't need math.Compare or math.Compare32 after all.

For #56491
Fixes #60519

Change-Id: I8ed33464adfc6d69bd6b328edb26aa2ee3d234d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/499416
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>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eli Bendersky <eliben@google.com>
12 months agocmd/link: support R_PPC64_REL24_P9NOTOC
Paul E. Murphy [Mon, 22 May 2023 16:20:35 +0000 (11:20 -0500)]
cmd/link: support R_PPC64_REL24_P9NOTOC

This can be treated identically to R_PPC64_REL24_NOTOC as stubs
are generated based on GOPPC64 and -buildmode.

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

12 months agodoc/go1.21: fix link in WTF-8 section
Tobias Klauser [Wed, 31 May 2023 16:56:47 +0000 (18:56 +0200)]
doc/go1.21: fix link in WTF-8 section

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

12 months agoruntime: preserve R29 in the write barrier flush path on ppc64
David Chase [Wed, 31 May 2023 19:33:58 +0000 (15:33 -0400)]
runtime: preserve R29 in the write barrier flush path on ppc64

Surprisingly, it usually survived the call to flush a write
barrier.  Usually.

Fixes #60368

Change-Id: I4792a57738e5829c79baebae4d13b62abe9526b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/499679
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
12 months agoruntime: fix alignment code in memmove_riscv64.s
Mark Ryan [Fri, 26 May 2023 08:51:21 +0000 (10:51 +0200)]
runtime: fix alignment code in memmove_riscv64.s

The riscv64 implementation of memmove has two optimizations that are
applied when both source and destination pointers share the same alignment
but that alignment is not 8 bytes. Both optimizations attempt to align the
source and destination pointers to 8 byte boundaries before performing 8 byte
aligned loads and stores.  Both optimizations are incorrect.  The first
optimization is applied when the destination pointer is smaller than the source
pointer.  In this case the code increments both pointers by (pointer & 3) bytes
rather than (8 - (pointer & 7)) bytes.  The second optimization is applied
when the destination pointer is larger than the source pointer.  In this
case the existing code decrements the pointers by (pointer & 3) bytes instead
of (pointer & 7).

This commit fixes both optimizations avoiding unaligned 8 byte accesses.
As this particular optimization is not covered by any of the existing
benchmarks a new benchmark, BenchmarkMemmoveUnalignedSrcDst,
is provided that exercises both optimizations. Results of the new
benchmark, which were run on a SiFive HiFive Unmatched A00 with 16GB of RAM
running Ubuntu 23.04 are presented below.

MemmoveUnalignedSrcDst/f_16_0-4            39.48n ±  5%   43.47n ± 2%  +10.13% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_16_0-4            45.39n ±  5%   41.55n ± 4%   -8.47% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_16_1-4          1230.50n ±  1%   83.44n ± 5%  -93.22% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_16_1-4            69.34n ±  4%   67.83n ± 8%        ~ (p=0.436 n=10)
MemmoveUnalignedSrcDst/f_16_4-4          2349.00n ±  1%   72.09n ± 4%  -96.93% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_16_4-4          2357.00n ±  0%   77.61n ± 4%  -96.71% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_16_7-4          1235.00n ±  0%   62.02n ± 2%  -94.98% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_16_7-4          1246.00n ±  0%   84.05n ± 6%  -93.25% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_64_0-4            49.96n ±  2%   50.01n ± 2%        ~ (p=0.755 n=10)
MemmoveUnalignedSrcDst/b_64_0-4            52.06n ±  3%   51.65n ± 3%        ~ (p=0.631 n=10)
MemmoveUnalignedSrcDst/f_64_1-4          8105.50n ±  0%   97.63n ± 1%  -98.80% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_64_1-4            84.07n ±  4%   84.90n ± 5%        ~ (p=0.315 n=10)
MemmoveUnalignedSrcDst/f_64_4-4          9192.00n ±  0%   86.16n ± 3%  -99.06% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_64_4-4          9195.50n ±  1%   91.88n ± 5%  -99.00% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_64_7-4          8106.50n ±  0%   78.44n ± 9%  -99.03% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_64_7-4          8107.00n ±  0%   99.19n ± 1%  -98.78% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_256_0-4           90.95n ±  1%   92.16n ± 8%        ~ (p=0.123 n=10)
MemmoveUnalignedSrcDst/b_256_0-4           96.09n ± 12%   94.90n ± 2%        ~ (p=0.143 n=10)
MemmoveUnalignedSrcDst/f_256_1-4         35492.5n ±  0%   133.5n ± 0%  -99.62% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_256_1-4           128.7n ±  1%   130.1n ± 1%   +1.13% (p=0.005 n=10)
MemmoveUnalignedSrcDst/f_256_4-4         36599.0n ±  0%   123.0n ± 1%  -99.66% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_256_4-4         36675.5n ±  0%   130.7n ± 1%  -99.64% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_256_7-4         35555.5n ±  0%   121.6n ± 2%  -99.66% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_256_7-4         35584.0n ±  0%   139.1n ± 1%  -99.61% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_4096_0-4          956.3n ±  2%   960.8n ± 1%        ~ (p=0.306 n=10)
MemmoveUnalignedSrcDst/b_4096_0-4          1.015µ ±  2%   1.012µ ± 2%        ~ (p=0.076 n=10)
MemmoveUnalignedSrcDst/f_4096_1-4        584.406µ ±  0%   1.002µ ± 1%  -99.83% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_4096_1-4          1.044µ ±  1%   1.040µ ± 2%        ~ (p=0.090 n=10)
MemmoveUnalignedSrcDst/f_4096_4-4       585113.5n ±  0%   988.6n ± 2%  -99.83% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_4096_4-4        586.521µ ±  0%   1.044µ ± 1%  -99.82% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_4096_7-4       585374.5n ±  0%   986.2n ± 0%  -99.83% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_4096_7-4        584.595µ ±  1%   1.055µ ± 0%  -99.82% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_65536_0-4         54.83µ ±  0%   55.00µ ± 0%   +0.31% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_65536_0-4         56.54µ ±  0%   56.64µ ± 0%   +0.19% (p=0.011 n=10)
MemmoveUnalignedSrcDst/f_65536_1-4       9450.51µ ±  0%   58.25µ ± 0%  -99.38% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_65536_1-4         56.65µ ±  0%   56.68µ ± 0%        ~ (p=0.353 n=10)
MemmoveUnalignedSrcDst/f_65536_4-4       9449.48µ ±  0%   58.24µ ± 0%  -99.38% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_65536_4-4       9462.91µ ±  0%   56.69µ ± 0%  -99.40% (p=0.000 n=10)
MemmoveUnalignedSrcDst/f_65536_7-4       9477.37µ ±  0%   58.26µ ± 0%  -99.39% (p=0.000 n=10)
MemmoveUnalignedSrcDst/b_65536_7-4       9467.96µ ±  0%   56.68µ ± 0%  -99.40% (p=0.000 n=10)
geomean                                    11.16µ         509.8n       -95.43%

Change-Id: Idfa1873b81fece3b2b1a0aed398fa5663cc73b83
Reviewed-on: https://go-review.googlesource.com/c/go/+/498377
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
12 months agodoc/go1.21: mention upgrade to Unicode 15.0.0
Ian Lance Taylor [Wed, 31 May 2023 18:51:28 +0000 (11:51 -0700)]
doc/go1.21: mention upgrade to Unicode 15.0.0

For #48621
For #55079

Change-Id: I279b4fbf07d2fa9de9577559a4e17a57f5692aa3
Reviewed-on: https://go-review.googlesource.com/c/go/+/499618
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>

12 months agodoc/go1.21: document new bytes.Buffer methods
Ian Lance Taylor [Wed, 31 May 2023 18:47:14 +0000 (11:47 -0700)]
doc/go1.21: document new bytes.Buffer methods

For #53685

Change-Id: I237297d19afeb36ad738074d0c61caa7012f65ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/499617
Reviewed-by: Eli Bendersky <eliben@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>

12 months agodoc/go1.21: mention debug/elf changes
Ian Lance Taylor [Wed, 31 May 2023 18:41:31 +0000 (11:41 -0700)]
doc/go1.21: mention debug/elf changes

For #55107
For #56887
For #56892

Change-Id: Ibcca34c931ed3595d877c4573bba221dec66bb5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/499616
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

12 months agodoc/go1.21: reading from debug/pe uninitialized section fails
Ian Lance Taylor [Tue, 30 May 2023 22:36:16 +0000 (15:36 -0700)]
doc/go1.21: reading from debug/pe uninitialized section fails

For #47653

Change-Id: Id44c9dba58966f43f188030a53343d890a6ffde7
Reviewed-on: https://go-review.googlesource.com/c/go/+/499419
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
12 months agodoc/go1.21: mention that embedded files implement ReadAt
Ian Lance Taylor [Tue, 30 May 2023 22:31:39 +0000 (15:31 -0700)]
doc/go1.21: mention that embedded files implement ReadAt

For #57803

Change-Id: I8e33f4dd3fc3071bfbf4d2848faefbe8488f5742
Reviewed-on: https://go-review.googlesource.com/c/go/+/499418
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

12 months agodoc/go1.21: mention flag.BoolFunc
Ian Lance Taylor [Tue, 30 May 2023 22:27:29 +0000 (15:27 -0700)]
doc/go1.21: mention flag.BoolFunc

For #53747

Change-Id: Ia5e2f89c1184f2dfd6d672b838b0dbb579e6c954
Reviewed-on: https://go-review.googlesource.com/c/go/+/499417
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

12 months agodoc/go1.21: document io/fs formatting functions
Ian Lance Taylor [Tue, 30 May 2023 17:42:57 +0000 (10:42 -0700)]
doc/go1.21: document io/fs formatting functions

Also document the new String methods that call them.

For #54451

Change-Id: I5cd7e0fc6c84097bba6d29c4d6012ed3c8bb1e0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/499177
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

12 months agodoc/go1.21: mention directive handling in go/{ast,build}
Ian Lance Taylor [Tue, 30 May 2023 22:15:43 +0000 (15:15 -0700)]
doc/go1.21: mention directive handling in go/{ast,build}

For #56986
For #59033

Change-Id: I7d03fe34d418aff97a551b236b5d43506e402871
Reviewed-on: https://go-review.googlesource.com/c/go/+/499415
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

12 months agoruntime: fix race in BenchmarkSetType* benchmarks
Michael Anthony Knyszek [Mon, 22 May 2023 21:39:54 +0000 (21:39 +0000)]
runtime: fix race in BenchmarkSetType* benchmarks

Currently the BenchmarkSetType* benchmarks are racy: they call
heapBitsSetType on an allocation that might be in a span in-use for
allocation on another P. Because heap bits are bits but are written
byte-wise non-atomically (because a P assumes it has total ownership of
a span's bits), two threads can race writing the same heap bitmap byte
creating incorrect metadata.

Fix this by forcing every value we're writing heap bits for into a large
object. Large object spans will never be written to concurrently unless
they're freed first.

Also, while we're here, refactor the benchmarks a bit. Use generics to
eliminate the reflect nastiness in gc_test.go, and pass b.ResetTimer
down into the test to get slightly more accurate results.

Fixes #60050.

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

12 months agocmd/go: introduce WriteOpts argument for WriteGoMod
Russ Cox [Wed, 31 May 2023 13:57:03 +0000 (09:57 -0400)]
cmd/go: introduce WriteOpts argument for WriteGoMod

This CL is a no-op, just adding the new options and plumbing it through.
'go get' will use this option to let commitRequirements know whether
toolchain was mentioned explicitly on the command line.

For #57001.

Change-Id: Iee7145f3335e899704df3e98fb840f1aa4063b0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/499555
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go: clean up handling of go mod tidy -go=v during modload
Russ Cox [Wed, 31 May 2023 13:38:29 +0000 (09:38 -0400)]
cmd/go: clean up handling of go mod tidy -go=v during modload

Slight cleanup of the special case for "mod tidy" during modload
of a module with no go version. Now it's clearer what is special.

For #57001.

Change-Id: I4a3ad0a948ccb5c62365f2a7f7f7de5582cc57c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/499535
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

12 months agocmd/go: add detection of toolchain switch loops
Russ Cox [Fri, 26 May 2023 03:28:39 +0000 (23:28 -0400)]
cmd/go: add detection of toolchain switch loops

This happens mainly during testing because the virtual
toolchain switch is not terribly robust, and if you accidentally
try to exec "1.23" instead of "go1.23" it will let you, but it
won't work right.

Of course, although we feel pretty good about the non-test
implementation, perhaps it has a toolchain switch loop lurking too,
or perhaps one will be introduced in the future.

To handle the test bug, and just in case we have a real bug later,
add detection of toolchain switch loops with clear messages.

Also fixes a bug in setting the -lang flag properly when invoking
the Go compiler: this is the first test using 'go 1.21.x' lines
during a build.

For #57001.

Change-Id: I0ece3dd718596689a23b677cf08ddf32ea97bc57
Reviewed-on: https://go-review.googlesource.com/c/go/+/498436
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime: make TestCPUMetricsSleep even more lenient
Michael Anthony Knyszek [Fri, 26 May 2023 17:56:39 +0000 (17:56 +0000)]
runtime: make TestCPUMetricsSleep even more lenient

This test was introduced as a regression test for #60276. However, it
was quite flaky on a number of different platforms because there are
myriad ways the runtime can eat into time one might expect is completely
idle.

This change re-enables the test, but makes it much more resilient.
Because the issue we're testing for is persistent, we now require 10
consecutive failures to count. Any single success counts as a test
success. This change also makes the test's idle time bound more lenient,
allowing for a little bit of time to be eaten up. The regression we're
testing for results in nearly zero idle time being accounted for.

If this is still not good enough to eliminate flakes, this test should
just be deleted.

For #60276.
Fixes #60376.

Change-Id: Icd81f0c9970821b7f386f6d27c8a566fee4d0ff7
Reviewed-on: https://go-review.googlesource.com/c/go/+/498274
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
12 months agocmd/go: scan $PATH to find version list in NewerToolchain
Russ Cox [Tue, 30 May 2023 17:28:56 +0000 (13:28 -0400)]
cmd/go: scan $PATH to find version list in NewerToolchain

NewerToolchain needs a list of candidate toolchains.
Currently it always consults the module version list, using the network.
When GOTOOLCHAIN=path, it should probably not do this,
both because =path implies we don't want to use the network
and because not every released version will be in $PATH.
Instead, scan $PATH to find the available versions.

For #57001.

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

12 months agodoc: document WER and SEH changes in Go 1.21
qmuntal [Wed, 31 May 2023 13:07:03 +0000 (15:07 +0200)]
doc: document WER and SEH changes in Go 1.21

While here, I've removed the CL 472195 TODO, which I marked as
RELNOTE=yes by mistake.

For #57441
For #57302

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

12 months agointernal/coverage/pods: sort counter files first by origin, then name
Than McIntosh [Tue, 30 May 2023 23:16:56 +0000 (19:16 -0400)]
internal/coverage/pods: sort counter files first by origin, then name

This patch fixes a problem with the way pods (clumps of related
coverage meta+counter data files) are collected, which was causing
problems for "go tool covdata subtract".

A subtract operation such as "go tool covdata subtract -i=dir1,dir2
-o=out" works by loading in all the counter data files from "dir1"
before any of the data files from "dir2" are loaded. The sorting
function in the pods code was sorting counter files for a given pod
based purely on name, which meant that differences in process ID
assignment could result in some files from "dir2" being presented
before "dir1". The fix is to change the sorting compare function to
prefer origin directory over filename.

Fixes #60526.

Change-Id: I2226ea675fc99666a9a28e6550d823bcdf2d6977
Reviewed-on: https://go-review.googlesource.com/c/go/+/499317
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
12 months agodoc: document new panic behavior of flag definition after Set
Keith Randall [Tue, 30 May 2023 17:54:21 +0000 (10:54 -0700)]
doc: document new panic behavior of flag definition after Set

For #57411

Change-Id: I56c112bb03dde24c2e2643c9b72ce06158a8e717
Reviewed-on: https://go-review.googlesource.com/c/go/+/499278
TryBot-Bypass: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
12 months agodoc: document change of cgocheck=2 from debug to experiment
Keith Randall [Tue, 30 May 2023 18:36:19 +0000 (11:36 -0700)]
doc: document change of cgocheck=2 from debug to experiment

Change-Id: I98bdfe8ab338a5b92c466a5aacfa95266171e5c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/499279
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Bypass: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
12 months agodoc: mention the new purego implementation of hash/maphash
Keith Randall [Tue, 30 May 2023 20:00:00 +0000 (13:00 -0700)]
doc: mention the new purego implementation of hash/maphash

Change-Id: Ieedddf52ae09cf5a8e9347f0f30aff21e8369787
Reviewed-on: https://go-review.googlesource.com/c/go/+/499281
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Bypass: Keith Randall <khr@golang.org>

12 months agodoc: mention improvements in checking R15 use in assembly when dynamic linking
Keith Randall [Tue, 30 May 2023 19:47:34 +0000 (12:47 -0700)]
doc: mention improvements in checking R15 use in assembly when dynamic linking

Change-Id: I223649818763c0620875c034a77a8865252e3e69
Reviewed-on: https://go-review.googlesource.com/c/go/+/499280
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Keith Randall <khr@golang.org>

12 months agogo/types, types2: use exact unification for component types
Robert Griesemer [Fri, 26 May 2023 23:27:28 +0000 (16:27 -0700)]
go/types, types2: use exact unification for component types

This change defines two unification modes used to control unification:

- assign  set when unifying types involved in an assignment
- exact   if set, types unify if they can be made identical

Currently, unification is inexact: when a defined type is compared
against a type literal, the underlying type of the defined type is
considered. When channel types are compared, the channel direction
is ignored. And when defined types are compared where one (or both)
are interfaces, interface unification is used.

By contrast, exact unification requires types to match exactly:
if they can be unified, the types must be identical (with suitable
type arguments).

Exact unification is required when comparing component types.
For instance, when unifying func(x P) with func(x Q), the two
signatures unify only if P is identical to Q per Go's assignment
rules.

Until now we have ignored exact unification and made due with inexact
unification everywhere, even for component types. In some cases this
led to infinite recursions in the unifier, which we guarded against
with a depth limit (and unification failure).

Go's assignmemt rules allow inexact matching at the top-level but
require exact matching for element types.

This change passes 'assign' to the unifier when unifying parameter
against argument types because those follow assignment rules.
When comparing constraints, inexact unification is used as before.

In 'assign' mode, when comparing element types, the unifyier is
called recursively, this time with the 'exact' mode set, causing
element types to be compared exactly. If unification succeeds for
element types, they are identical (with suitable type arguments).

This change fixes #60460. It also fixes a bug in the test for
issue #60377. We also don't need to rely anymore on the recursion
depth limit (a temporary fix) for #59740. Finally, because we use
exact unification when comparing element types which are channels,
errors caused by assignment failures (due to inexact inference which
succeeded when it shouldn't have) now produce the correct inference
error.

Fixes #60460.
For #60377.
For #59740.

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

12 months agogo/types, types2: add unifyMode to unifier, pass it through
Robert Griesemer [Sat, 27 May 2023 21:31:14 +0000 (14:31 -0700)]
go/types, types2: add unifyMode to unifier, pass it through

Pass a mode parameter through all unifier calls but make no use of it.
When unifying type elements (components of composite types), use emode,
which currently is set to mode.

Preparatory step to fix #60460. Factoring out this mechanical change
will make the actual fix smaller and easier to review and understand.
Because this change doesn't affect the behavior of the unifier, it is
safe.

For #60460.

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

12 months agocmd/cgo: rewrite pointer passing rules in terms of pinning
Michael Anthony Knyszek [Wed, 24 May 2023 19:53:14 +0000 (19:53 +0000)]
cmd/cgo: rewrite pointer passing rules in terms of pinning

With the introduction of runtime.Pinner, we need to update the cgo
pointer passing rules to accomodate the new functionality. These rule
changes are easier to describe if the rest of the pointer passing rules
are described in terms of pinning as well (Go memory is implicitly
pinned when a pointer to it is passed to a C function, and implicitly
unpinned when that function returns).

For #46787.

Change-Id: I263f03412bc9165f19c9ada72fb005ed0483a8ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/498116
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

12 months agodoc/go1.21: fix HTML tag
Cherry Mui [Tue, 30 May 2023 18:59:55 +0000 (14:59 -0400)]
doc/go1.21: fix HTML tag

Fix a broken HTML tag.

Change-Id: I9e7c65c2cc12c7b14ca205f78b78ac1e9c92a3ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/499355
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agocmd/go: lock in new toolchain semantics
Russ Cox [Thu, 25 May 2023 15:59:50 +0000 (11:59 -0400)]
cmd/go: lock in new toolchain semantics

The design doc says 'toolchain' lines apply even if the default
toolchain is older than the one specified in the toolchain line.
However, that leads to various confusing behavior and security issues.
Instead, treat toolchain as a min go version that only applies
in the current module (not in dependencies).

As an example of confusing behavior / security issue, if I install
Go 1.30 and then run 'go build' in a module I've checked out,
I expect to use Go 1.30 or newer, not to silently use an older toolchain
that may have security problems fixed in Go 1.30.
Making toolchain a min establishes that guarantee.

Also clean up the tests quite a bit.

Finally drop + from the acceptable version suffixes; we use + for +auto and +path.

For #57001.

Change-Id: Ia92c66be75d6d0e31cb4e2c0aa936fa4ec5c0a8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/498260
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

12 months agocmd/go: switch to newer toolchain in go get as needed
Russ Cox [Wed, 24 May 2023 21:37:11 +0000 (17:37 -0400)]
cmd/go: switch to newer toolchain in go get as needed

If we run 'go get go@1.40' or 'go get m@v' where m has a go.mod
that says 'go 1.40', we need to write a new go.mod that says 'go 1.40'.
But we can't be sure we know how to write a Go 1.40-compatible go.mod.
Instead, download the latest point release of Go 1.40 and invoke it to
finish the get command.

For #57001.

Change-Id: I4133fc3c2ecf91226a6c09a3086275ecc517e223
Reviewed-on: https://go-review.googlesource.com/c/go/+/498118
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>

12 months agocmd/compile: remove special treatment for cover vars in initorder
Than McIntosh [Tue, 30 May 2023 14:49:11 +0000 (10:49 -0400)]
cmd/compile: remove special treatment for cover vars in initorder

This patch reverts a portion of the changes in CL 443715, specifically
the code in initorder that treats coverage counter variables as special
with respect to init order. The special casing is no longer needed
now after a change to the way coverage instrumention is done (the go and
cover cmds now make sure that coverage variables appear first in
the compilation order).

Updates #56293.

Change-Id: Idf803ff4c1a095e88d455a6adcd63991687eb288
Reviewed-on: https://go-review.googlesource.com/c/go/+/499216
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
12 months agocmd/{cover,go}: revise fix for pkg init order change with -cover
Than McIntosh [Tue, 30 May 2023 14:44:45 +0000 (10:44 -0400)]
cmd/{cover,go}: revise fix for pkg init order change with -cover

This patch contains a revised fix for issue #56293, switching to a
scheme in which coverage counter variables and meta-data variables are
written to a separate output file as opposed to being tacked onto the
end of an existing rewritten source file.

The advantage of writing counter vars to a separate file is that the
Go command can then present that file as the first source file to the
compiler when the package is built; this will ensure that counter
variable are treated as lexically "before" any other variable that
might call an instrumented function as part of its initializer.

Updates #56293.

Change-Id: Iccb8a6532b976d36ccbd5a2a339882d1f5d19477
Reviewed-on: https://go-review.googlesource.com/c/go/+/499215
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agoruntime: clarify Pinner doc
Jonathan Amsterdam [Sat, 27 May 2023 12:48:31 +0000 (08:48 -0400)]
runtime: clarify Pinner doc

Rewrite in idiomatic form, fix a typo, break into paragraph, rephrase
slightly.

Change-Id: If146db86aa84214e61128a3bc3e9905396d44710
Reviewed-on: https://go-review.googlesource.com/c/go/+/498716
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Ansiwen <ansiwen@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
12 months agodoc/go1.21: mention errors.ErrUnsupported
Ian Lance Taylor [Fri, 26 May 2023 23:22:24 +0000 (16:22 -0700)]
doc/go1.21: mention errors.ErrUnsupported

Also mention errors that implement it.

For #41198

Change-Id: I4f01b112f53b19e2494b701bb012cb2cb52f8962
Reviewed-on: https://go-review.googlesource.com/c/go/+/498775
Reviewed-by: Eli Bendersky <eliben@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: 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@golang.org>

12 months agocrypto/tls: fix cipher suite check when doing 0-RTT resumption
Marten Seemann [Thu, 25 May 2023 08:06:41 +0000 (11:06 +0300)]
crypto/tls: fix cipher suite check when doing 0-RTT resumption

Change-Id: Ia50898308b80149f862457f9cd9f1123da4e6b6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/498215
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Macrombi Lux <macrentals502@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>

12 months agodoc/go1.21: mention maps package
Ian Lance Taylor [Sat, 27 May 2023 00:07:49 +0000 (17:07 -0700)]
doc/go1.21: mention maps package

For #57436

Change-Id: I99e8b0819c76f1ccf12154a894c9c4c9d68124d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/498602
Reviewed-by: Eli Bendersky <eliben@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>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
12 months agodoc/go1.21: mention multipath TCP support
Ian Lance Taylor [Fri, 26 May 2023 23:52:28 +0000 (16:52 -0700)]
doc/go1.21: mention multipath TCP support

For #56539
For #59166

Change-Id: Ief392464916a1a74a8fcc6c3c7bdb213e8c6ef98
Reviewed-on: https://go-review.googlesource.com/c/go/+/498601
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: Eli Bendersky <eliben@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
12 months agocmd/go/internal/modload: break more cycles in readModGraph
Bryan C. Mills [Tue, 30 May 2023 14:35:54 +0000 (10:35 -0400)]
cmd/go/internal/modload: break more cycles in readModGraph

Before CL 471595, modload.readModGraph in module with graph pruning
enabled only ever chased down transitive dependencies of unpruned
roots, so pruned dependencies couldn't cause cycles and we didn't
need to dedup them in the loading queue.

However, in 'go get' we are now passing in a set of upgraded modules
to unprune, and those upgraded modules can potentially contain cycles,
leading to an infinite loop during loading.

We have two options for a fix: we could either drop the 'unprune'
check in the enqueue operation (and instead expand the 'unprune'
requirements in a separate pass, as we do in workspace mode), or we
could check for cycles for all modules (not just the ones that are
naturally unpruned). The latter option makes it clearer that this
process must terminate, so we choose that.

(It may be possible to clean up and simplify the workspace-mode case
now that we are passing in the 'unprune' map, but for now we're
looking for a minimal fix for the Go 1.21 release.)

Fixes #60490.

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

12 months agointernal/bytealg: fix alignment code in compare_riscv64.s
Mark Ryan [Wed, 24 May 2023 11:20:11 +0000 (13:20 +0200)]
internal/bytealg: fix alignment code in compare_riscv64.s

The riscv64 implementation of compare has an optimization that is
applied when both pointers share the same alignment but that alignment
is not 8 bytes.  In this case it tries to align both pointers to an 8 byte boundaries,
by individually comparing the first few bytes of each buffer.  Unfortunately,
the existing code is incorrect.  It adjusts the pointers by the wrong number
of bytes resulting, in most cases, in pointers that are not 8 byte aligned.

This commit fixes the issue by individually comparing the first
(8 - (pointer & 7)) bytes of each buffer rather than the first
(pointer & 7) bytes.

We also remove an unnecessary immediate MOV instruction.

This particular optimization is not covered by any of the existing
benchmarks so a new benchmark, benchmarkCompareBytesBigBothUnaligned,
is provided.  The benchmark tests the case where both pointers have
the same alignment but may not be 8 byte aligned.  Results of the
new benchmark along with some of the existing benchmarks generated on
a SiFive HiFive Unmatched A00 with 16GB of RAM running Ubuntu 23.04
are presented below.

CompareBytesEqual-4                           70.00n ±  6%   68.32n ±  0%   -2.40% (p=0.020 n=10)
CompareBytesToNil-4                           19.31n ±  0%   18.47n ±  0%   -4.35% (p=0.000 n=10)
CompareBytesEmpty-4                           16.79n ±  0%   15.95n ±  0%   -4.97% (p=0.000 n=10)
CompareBytesIdentical-4                       19.94n ± 15%   18.32n ± 13%   -8.15% (p=0.040 n=10)
CompareBytesSameLength-4                      37.93n ±  0%   42.44n ±  1%  +11.91% (p=0.000 n=10)
CompareBytesDifferentLength-4                 37.93n ±  0%   42.44n ±  0%  +11.89% (p=0.000 n=10)
CompareBytesBigUnaligned/offset=1-4           3.881m ± 14%   3.880m ± 15%        ~ (p=0.436 n=10)
CompareBytesBigUnaligned/offset=2-4           3.884m ±  0%   3.875m ±  0%        ~ (p=0.190 n=10)
CompareBytesBigUnaligned/offset=3-4           3.858m ±  1%   3.868m ±  1%        ~ (p=0.105 n=10)
CompareBytesBigUnaligned/offset=4-4           3.877m ±  1%   3.876m ±  0%        ~ (p=0.529 n=10)
CompareBytesBigUnaligned/offset=5-4           3.859m ±  0%   3.874m ±  0%   +0.39% (p=0.009 n=10)
CompareBytesBigUnaligned/offset=6-4           3.878m ±  1%   3.876m ±  0%        ~ (p=0.353 n=10)
CompareBytesBigUnaligned/offset=7-4           3.868m ±  1%   3.877m ±  0%        ~ (p=0.190 n=10)
CompareBytesBigBothUnaligned/offset=0-4       1.586m ±  0%   1.765m ±  0%  +11.30% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=1-4     153.132m ±  1%   1.765m ±  1%  -98.85% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=2-4     152.930m ±  1%   1.765m ±  1%  -98.85% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=3-4     152.093m ±  1%   1.769m ±  0%  -98.84% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=4-4       1.602m ±  0%   1.764m ±  0%  +10.11% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=5-4     152.314m ±  1%   1.768m ±  0%  -98.84% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=6-4     152.905m ±  1%   1.764m ±  1%  -98.85% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=7-4     152.951m ±  1%   1.804m ±  2%  -98.82% (p=0.000 n=10)
CompareBytesBig-4                             1.441m ± 21%   1.373m ± 55%        ~ (p=0.481 n=10)
CompareBytesBigIdentical-4                    19.94n ±  1%   19.10n ±  0%   -4.21% (p=0.001 n=10)
geomean                                       243.7µ         76.65µ        -68.54%

CompareBytesBigUnaligned/offset=1-4          257.7Mi ± 12%     257.7Mi ± 13%          ~ (p=0.424 n=10)
CompareBytesBigUnaligned/offset=2-4          257.5Mi ±  0%     258.1Mi ±  0%          ~ (p=0.190 n=10)
CompareBytesBigUnaligned/offset=3-4          259.2Mi ±  1%     258.5Mi ±  1%          ~ (p=0.105 n=10)
CompareBytesBigUnaligned/offset=4-4          257.9Mi ±  1%     258.0Mi ±  0%          ~ (p=0.529 n=10)
CompareBytesBigUnaligned/offset=5-4          259.1Mi ±  0%     258.1Mi ±  0%     -0.39% (p=0.008 n=10)
CompareBytesBigUnaligned/offset=6-4          257.9Mi ±  1%     258.0Mi ±  0%          ~ (p=0.353 n=10)
CompareBytesBigUnaligned/offset=7-4          258.5Mi ±  1%     257.9Mi ±  0%          ~ (p=0.190 n=10)
CompareBytesBigBothUnaligned/offset=0-4      630.6Mi ±  0%     566.6Mi ±  0%    -10.15% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=1-4      6.533Mi ±  1%   566.545Mi ±  1%  +8572.48% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=2-4      6.537Mi ±  1%   566.683Mi ±  1%  +8568.27% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=3-4      6.576Mi ±  1%   565.200Mi ±  0%  +8495.43% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=4-4      624.2Mi ±  0%     566.9Mi ±  0%     -9.18% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=5-4      6.566Mi ±  1%   565.758Mi ±  0%  +8516.41% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=6-4      6.542Mi ±  1%   567.036Mi ±  1%  +8567.35% (p=0.000 n=10)
CompareBytesBigBothUnaligned/offset=7-4      6.542Mi ±  1%   554.390Mi ±  2%  +8374.05% (p=0.000 n=10)
CompareBytesBig-4                            694.2Mi ± 18%     728.1Mi ± 35%          ~ (p=0.481 n=10)
CompareBytesBigIdentical-4                   47.83Ti ±  1%     49.92Ti ±  0%     +4.39% (p=0.002 n=10)
geomean                                      170.0Mi           813.8Mi         +378.66%

Change-Id: I0a2d0386d5ca1ffa249682a12ebd1533508e31e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/497838
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: M Zhuo <mzh@golangcn.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: M Zhuo <mzh@golangcn.org>

12 months agogo/types: don't use user string as format string
Robert Griesemer [Tue, 30 May 2023 15:38:56 +0000 (08:38 -0700)]
go/types: don't use user string as format string

Fixes #60500.

Change-Id: I272c71071f239d5c9472e19ae25461001e7f6a8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/499275
Reviewed-by: Robert Griesemer <gri@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 Findley <rfindley@google.com>
12 months agosyscall: fix ComputerName on Windows
qmuntal [Mon, 29 May 2023 09:45:14 +0000 (11:45 +0200)]
syscall: fix ComputerName on Windows

GetComputerName expects n to be the size of the buffer, and
on output contains the number of characters copied to the buffer.

CL 493036 broke ComputerName by always setting n to 0.

Change-Id: I3f4b30d2f9825d321a6d28ec82bdc7b6294e04e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/499035
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agocmd/go: update cover flag documentation
Enrico Candino [Thu, 25 May 2023 22:52:57 +0000 (00:52 +0200)]
cmd/go: update cover flag documentation

Cover flag documentation was not up to date, and the -covermode flag
documentation was missing.

Fixes #60438

Change-Id: I11e769fa2a32d074de7a748aa534afdfe2ca4e78
Reviewed-on: https://go-review.googlesource.com/c/go/+/498415
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agodoc/go1.21: document clear builtin and init order changes
Ian Lance Taylor [Fri, 26 May 2023 21:04:37 +0000 (14:04 -0700)]
doc/go1.21: document clear builtin and init order changes

Also move all the language changes to the same part of the release notes.

For #56351
For #57411

Change-Id: Id1c51b5eb8f7d85e61a2ae44ee7d73bb13036631
Reviewed-on: https://go-review.googlesource.com/c/go/+/498755
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

12 months agocmd/go: always track visited packages in setPGOProfilePath
Michael Pratt [Fri, 26 May 2023 19:49:22 +0000 (15:49 -0400)]
cmd/go: always track visited packages in setPGOProfilePath

Currently we only track visited (copied) packages when a copy is
required. When a copy is not required, we will rewalk each package's
entire dependency graph every time we see it, which is terribly
inefficient.

Pull the visited package check up a level so that we visit packages only
once regardless of how many times they are visited.

Fixes #60455.
Fixes #60428.

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

12 months agodoc/go1.21: mention os package changes
Ian Lance Taylor [Fri, 26 May 2023 23:03:32 +0000 (16:03 -0700)]
doc/go1.21: mention os package changes

Also mention WTF-8 support in the syscall package.

For #32558
For #58977
For #59971

Change-Id: Id1627889b5e498add498748d9bfc69fb58030b35
Reviewed-on: https://go-review.googlesource.com/c/go/+/498600
Reviewed-by: Eli Bendersky <eliben@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>
Run-TryBot: Ian Lance Taylor <iant@google.com>

12 months agodoc/go1.21: mention changes to the reflect package
Ian Lance Taylor [Fri, 26 May 2023 21:25:45 +0000 (14:25 -0700)]
doc/go1.21: mention changes to the reflect package

Added Value.Clear, deprecated SliceHeader and StringHeader.

For #55002
For #56906

Change-Id: Ib7497aff830d56fad90c31ec28596e71a448e9ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/498757
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: Eli Bendersky <eliben@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agodoc/go1.21: mention regexp.MarshalText and UnmarshalText
Ian Lance Taylor [Fri, 26 May 2023 21:16:24 +0000 (14:16 -0700)]
doc/go1.21: mention regexp.MarshalText and UnmarshalText

For #46159

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

12 months agoall: update vendored dependencies
Matthew Dempsky [Fri, 26 May 2023 21:34:56 +0000 (14:34 -0700)]
all: update vendored dependencies

Generated with x/build/cmd/updatestd.

Updates #36905.

Change-Id: Iecd76e820c5f40a0f5e013684f7e7bef4c3fd482
Reviewed-on: https://go-review.googlesource.com/c/go/+/498598
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agodoc/go1.21: remove TODOs for x/ repos
Ian Lance Taylor [Fri, 26 May 2023 20:45:01 +0000 (13:45 -0700)]
doc/go1.21: remove TODOs for x/ repos

Remove x/ repos changes that aren't part of the 1.21 release.

Change-Id: Ia5cbf02ed6c0cc4dc0ff80d68403723b3f9ae0ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/498596
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>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
12 months agocmd/internal/testdir: stop manually adding GOROOT/bin to PATH
Dmitri Shuralyov [Fri, 26 May 2023 00:26:00 +0000 (20:26 -0400)]
cmd/internal/testdir: stop manually adding GOROOT/bin to PATH

The go command already places $GOROOT/bin at the beginning of $PATH in
the test's environment as of Go 1.19¹, so there's no need for the test
to do it anymore. Start enjoying yet another benefit of using 'go test'.

¹ See go.dev/issue/57050.

For #56844.

Change-Id: If7732cd8b8979eabf185485d3c73858a4e546d69
Reviewed-on: https://go-review.googlesource.com/c/go/+/498271
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agocmd/go: remove stray reference to mkalldocs.sh
Than McIntosh [Fri, 26 May 2023 19:04:37 +0000 (15:04 -0400)]
cmd/go: remove stray reference to mkalldocs.sh

Clean up a stray reference in the docs to 'mkalldocs.sh', which no
longer exists (was replaced by a Go program, in 676794f73e).

Change-Id: I058e86395b14756d7afc184f99f89dbc5ba0184e
Reviewed-on: https://go-review.googlesource.com/c/go/+/498715
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agodoc: release notes for my humble contributions to go1.21
Alan Donovan [Thu, 18 May 2023 18:38:54 +0000 (14:38 -0400)]
doc: release notes for my humble contributions to go1.21

Updates #58645

Change-Id: Ieb4e6062613e26826ba8373cb4c2fd9198d0c692
Reviewed-on: https://go-review.googlesource.com/c/go/+/496116
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Bypass: Eli Bendersky <eliben@google.com>

12 months agosyscall: implement wasip1 Fcntl
Chris O'Hara [Thu, 25 May 2023 02:07:07 +0000 (12:07 +1000)]
syscall: implement wasip1 Fcntl

CL 494915 broke non-blocking I/O on wasip1 for files
opened with os.NewFile. This is fixed by providing an
implementation of fcntl(F_GETFL) for wasip1.

Change-Id: I78979076b95495fd4b94814552e5f5b043270cd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/498195
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Achille Roussel <achille.roussel@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

12 months agomisc/wasm: set PATH variable in exec
Johan Brandhorst-Satzkorn [Fri, 26 May 2023 16:58:43 +0000 (09:58 -0700)]
misc/wasm: set PATH variable in exec

The PATH variable is required to run the testenv tests.
Set it for all the runtime invocations where we don't
already set it by inheriting from the environment.

For #59583
For #59907
For #60097

Change-Id: If582dd8f086e3f40bc58d555f6034dcffe6f8e5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/498616
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>

12 months agodoc/go1.21: mention syscall package changes
Ian Lance Taylor [Thu, 25 May 2023 20:58:41 +0000 (13:58 -0700)]
doc/go1.21: mention syscall package changes

One of the changes also affects the os package, so mention it
there too.

For #46259

Change-Id: I8041a5ce009725ab210118ee668fc94196d9ff82
Reviewed-on: https://go-review.googlesource.com/c/go/+/498376
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoio: clarify that Read(nil) can return 0, EOF
Ian Lance Taylor [Thu, 25 May 2023 18:31:28 +0000 (11:31 -0700)]
io: clarify that Read(nil) can return 0, EOF

Fixes #40385

Change-Id: I965b5db985fd4418a992e883073cbc8309b2cb88
Reviewed-on: https://go-review.googlesource.com/c/go/+/498355
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
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: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

12 months agodoc: add release note on dead global map variable deletion
Than McIntosh [Fri, 26 May 2023 14:10:01 +0000 (10:10 -0400)]
doc: add release note on dead global map variable deletion

Add a short release note blurb on linker dead-coding of global map
variables.

Updates #58645.

Change-Id: Ibfdd3e2b2b78517db4245b1d7eedd5e75a643b47
Reviewed-on: https://go-review.googlesource.com/c/go/+/498575
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Bypass: Than McIntosh <thanm@google.com>

12 months agoruntime: delete a very stale comment
Austin Clements [Fri, 26 May 2023 01:43:33 +0000 (21:43 -0400)]
runtime: delete a very stale comment

This comment claims mark termination re-scans stacks and uses the
write barrier to determine how much of the stack needs to be
rescanned. This hasn't been true since we introduced the hybrid write
barrier and deleted stack rescanning with CL 31766 in Go 1.8.

Updates #17503 I suppose.

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

12 months agocmd/go/internal/modget: remove unused base.Errorf argument
Dmitri Shuralyov [Fri, 26 May 2023 02:43:36 +0000 (22:43 -0400)]
cmd/go/internal/modget: remove unused base.Errorf argument

Found by the vet check that runs with 'go test cmd/go/internal/modget'.

For #57001.
For #60463.

Change-Id: I4be94f7156724459a5c47bb9745cbb5651fb972c
Reviewed-on: https://go-review.googlesource.com/c/go/+/498270
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>

12 months agocrypto/tls: avoid referencing potentially unused symbols in init
Damien Neil [Fri, 26 May 2023 14:57:45 +0000 (07:57 -0700)]
crypto/tls: avoid referencing potentially unused symbols in init

A reference to a function in a "var _ = ..." init-time
initialization keeps the symbol live. Move references to
Config.EncryptTicket and Config.DecryptTicket into tests.
These references increase the size of an unused import of
crypto/tls by about 1MiB.

Change-Id: I6d62a6dcbd73e22972a217afcda7395e909b52cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/498595
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agodoc/go1.21: mention new go test -fullpath option
Ian Lance Taylor [Thu, 25 May 2023 21:17:56 +0000 (14:17 -0700)]
doc/go1.21: mention new go test -fullpath option

For #37708

Change-Id: I7b04d6331c15771c7d74ff77afd523c435e0dafe
Reviewed-on: https://go-review.googlesource.com/c/go/+/498396
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Eli Bendersky <eliben@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
12 months agodoc: fill out net/http.ErrSchemeMismatch note
Dan Peterson [Sun, 21 May 2023 13:54:28 +0000 (10:54 -0300)]
doc: fill out net/http.ErrSchemeMismatch note

For #44855

Change-Id: I517394b227ea948ed3e1f9ffdaab2bb2676863c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/496795
TryBot-Bypass: Dmitri Shuralyov <dmitshur@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>
Run-TryBot: Ian Lance Taylor <iant@google.com>

12 months agodatabase/sql: fix regression from earlier RawBytes fix
Brad Fitzpatrick [Thu, 25 May 2023 21:52:01 +0000 (14:52 -0700)]
database/sql: fix regression from earlier RawBytes fix

The earlier CL 497675 for #60304 introduced a behavior change
that, while not strictly a bug, caused a bunch of test failures
in a large codebase. Rather than add behavior changes in a 10 year
old package, revert to the old behavior: a context cancelation
between Rows.Next reporting false and a call to Rows.Err should
not result in Rows.Err returning the context error.

That behavior was accidentally added in CL 497675 as part of changing
how contexts and Rows iteration worked.

Updates #60304
Updates #53970

Change-Id: I22f8a6a6b0b5a94b430576cf50e015efd01ec652
Reviewed-on: https://go-review.googlesource.com/c/go/+/498398
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agodoc: add release notes for new min/max built-ins
Robert Griesemer [Thu, 25 May 2023 21:50:08 +0000 (14:50 -0700)]
doc: add release notes for new min/max built-ins

For #59488.

Change-Id: Iefabb06014767c5f633082a112a81e9ff5f09a30
Reviewed-on: https://go-review.googlesource.com/c/go/+/498397
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>

12 months agocmd/go: show full path name (testdata/script/foo.txt) in script errors
Russ Cox [Thu, 25 May 2023 01:00:22 +0000 (21:00 -0400)]
cmd/go: show full path name (testdata/script/foo.txt) in script errors

Showing the full path (relative to the current directory)
instead of just foo.txt lets editors that understand file:line
jump straight to the file without having to edit it to say
testdata/script/ first.

Change-Id: I44177b687249f3c7c724b45d02f5167607369e1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/498119
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agodoc/go1.21: merge x/exp/slices issue into slices package
Ian Lance Taylor [Thu, 25 May 2023 21:09:45 +0000 (14:09 -0700)]
doc/go1.21: merge x/exp/slices issue into slices package

For #57348

Change-Id: I84943711b033d63f0993133f93d9f09ce2af5965
Reviewed-on: https://go-review.googlesource.com/c/go/+/498395
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

12 months agogo/types, types2: don't infer type argument for unused parameter in interfaces
Robert Griesemer [Thu, 25 May 2023 16:54:11 +0000 (09:54 -0700)]
go/types, types2: don't infer type argument for unused parameter in interfaces

Two interface types that are assignable don't have to be identical;
specifically, if they are defined types, they can be different
defined types. If those defined types specify type parameters which
are never used, do not infer a type argument based on the instantiation
of a matching defined type.

Adjusted three existing tests where we inferred type arguments incorrectly.

Fixes #60377.

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

12 months agospec: document min and max built-ins
Robert Griesemer [Wed, 24 May 2023 20:23:14 +0000 (13:23 -0700)]
spec: document min and max built-ins

For #59488.

Change-Id: I50f65216bf02b42c1e0619702833f4a6dbed8925
Reviewed-on: https://go-review.googlesource.com/c/go/+/498136
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>

12 months agodoc: add release notes for additions to the slices package
Eli Bendersky [Thu, 25 May 2023 00:35:56 +0000 (17:35 -0700)]
doc: add release notes for additions to the slices package

Updates #60091

Change-Id: I7438811f4e41a2977acbb5ac74c22a02c28c6597
Reviewed-on: https://go-review.googlesource.com/c/go/+/498175
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Eli Bendersky‎ <eliben@golang.org>
Run-TryBot: Eli Bendersky‎ <eliben@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
12 months agocmd/go: fix reporting of test cycles to have proper order
Michael Matloob [Wed, 24 May 2023 18:59:01 +0000 (14:59 -0400)]
cmd/go: fix reporting of test cycles to have proper order

and begin and end with the same package to demonstrate the cyclical
nature of the stack. Also fix the list_test_cycle script test
which was testing for the wrong behavior.

Fixes #59970

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

12 months agoruntime: change heapObjectsCanMove to a func
Russ Cox [Thu, 25 May 2023 16:47:06 +0000 (12:47 -0400)]
runtime: change heapObjectsCanMove to a func

A var is problematic because the zero value is already false,
so if it goes away, it will appear to be false.
I'm also not sure about go:linkname on vars,
so switch to func for both reasons.

Also add a test.

Change-Id: I2318a5390d98577aec025152e65543491489defb
Reviewed-on: https://go-review.googlesource.com/c/go/+/498261
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
12 months agocmd/go: rename gover.ToolchainVersion to gover.FromToolchain
Russ Cox [Thu, 25 May 2023 04:33:44 +0000 (00:33 -0400)]
cmd/go: rename gover.ToolchainVersion to gover.FromToolchain

Suggested by bcmills in CL 497555 review but easier to do at the
top of the stack.

For #57001.

Change-Id: I6f2cc0f546e8d6b1e03c7335a89f07dcb45cf5b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/498077
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

12 months agocmd/go: avoid duplicate errors in module load
Russ Cox [Thu, 25 May 2023 04:32:39 +0000 (00:32 -0400)]
cmd/go: avoid duplicate errors in module load

Just a missing base.ExitIfErrors.

Fixes #46160.

Change-Id: I41949b0b7b036da94ba269220951677585d3f8e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/498122
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

12 months agocmd/go: expand acceptable toolchains a bit
Russ Cox [Wed, 24 May 2023 19:22:33 +0000 (15:22 -0400)]
cmd/go: expand acceptable toolchains a bit

Allow both prefix-goVERSION and goVERSION-suffix for custom toolchains.
Also make sure that a tie in the toolchain and min version goes to the
toolchain line.

For #57001.

Change-Id: Ibeea5f47db7349cfdf36da188bb43e195e196f5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/498076
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go: add go get go@version and toolchain@version
Russ Cox [Wed, 24 May 2023 01:12:23 +0000 (21:12 -0400)]
cmd/go: add go get go@version and toolchain@version

go get go@version and toolchain@version updates the
go and toolchain lines in go.mod. If toolchain ends up <= go,
it is dropped.

When the go version crosses certain version boundaries,
it may be necessary to run 'go mod tidy -go=version'.
That's left for a followup CL.

When the go or toolchain version ends up higher than the
current toolchain version, we cannot be sure we know how
to write the file out, so we fail with an error message.
In GOTOOLCHAIN auto mode, the newer toolchain should
be downloaded and reinvoked; that's left for a followup CL too.

For #57001.

Change-Id: Ibfdcc549b40555a53bdb2d019816d18f1bd16be6
Reviewed-on: https://go-review.googlesource.com/c/go/+/497081
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agocmd/go: handle queries properly in go install m@v
Russ Cox [Wed, 24 May 2023 11:10:17 +0000 (07:10 -0400)]
cmd/go: handle queries properly in go install m@v

The original code only handled go install m@v1.0.0
but not queries like go install m@v1 or m@master.
Handle those by invoking more of the module machinery.

For #57001.

Change-Id: I7d54fc3dd65072e5906a17ff95b407b0f7feac69
Reviewed-on: https://go-review.googlesource.com/c/go/+/497879
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go: refuse to download zip files for too-new modules
Russ Cox [Mon, 22 May 2023 16:34:17 +0000 (12:34 -0400)]
cmd/go: refuse to download zip files for too-new modules

In general an older version of Go does not know how to construct
a module written against a newer version of Go: the details may
change over time, such as for issues like #42965 (an ignore mechanism).

For #57001.

Change-Id: Id43fcfb71497375ad2eb5dfd292bad0adca0652e
Reviewed-on: https://go-review.googlesource.com/c/go/+/497795
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/dist: drop wasitest from special list
Austin Clements [Thu, 25 May 2023 13:25:05 +0000 (09:25 -0400)]
cmd/dist: drop wasitest from special list

CL 498255 made runtime/internal/wasitest compatible with all platforms
so that "go test std" works again. This means it no longer has to be
in the special dist test list.

While we're here explain the purpose of this list better and implore
people to please not expand it, since almost any addition is a sign
that "go test std cmd" no longer works.

Change-Id: I31c7fb767787fa587f65c2697aed9ed43e95fb18
Reviewed-on: https://go-review.googlesource.com/c/go/+/498256
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Austin Clements <austin@google.com>

12 months agoall: fix buildall.bash
Russ Cox [Thu, 25 May 2023 12:32:13 +0000 (08:32 -0400)]
all: fix buildall.bash

Disable the android and ios builds since cross-compiling fails there.
Also make runtime/internal/wasitest not build on systems that don't
have syscall.Mkfifo for it to use (including, ironically, wasm itself).

Change-Id: I28eb1f216f9952f81a107056e97ee38e350f9287
Reviewed-on: https://go-review.googlesource.com/c/go/+/498255
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoerrors: add godoc links
Olivier Mengué [Tue, 23 May 2023 14:51:04 +0000 (16:51 +0200)]
errors: add godoc links

Change-Id: I766e656e6b967290d692313ea1391878fc21c92d
Reviewed-on: https://go-review.googlesource.com/c/go/+/497375
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>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agoruntime: add heapObjectsCanMove
Russ Cox [Thu, 25 May 2023 04:21:13 +0000 (00:21 -0400)]
runtime: add heapObjectsCanMove

heapObjectsCanMove is always false in the current garbage collector.
It exists for go4.org/unsafe/assume-no-moving-gc, which is an
unfortunate idea that had an even more unfortunate implementation.
Every time a new Go release happened, the package stopped building,
and the authors had to add a new file with a new //go:build line, and
then the entire ecosystem of packages with that as a dependency had to
explicitly update to the new version. Many packages depend on
assume-no-moving-gc transitively, through paths like
inet.af/netaddr -> go4.org/intern -> assume-no-moving-gc.
This was causing a significant amount of friction around each new
release, so we added this bool for the package to //go:linkname
instead. The bool is still unfortunate, but it's not as bad as
breaking the ecosystem on every new release.

If the Go garbage collector ever does move heap objects, we can set
this to true to break all the programs using assume-no-moving-gc.

Change-Id: I06c32bf6ccc4601c8eef741d7382b678aada3508
Reviewed-on: https://go-review.googlesource.com/c/go/+/498121
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
12 months agocrypto/internal/bigmod: don't panic on NewModulusFromBig(0)
Roland Shoemaker [Wed, 24 May 2023 17:53:47 +0000 (10:53 -0700)]
crypto/internal/bigmod: don't panic on NewModulusFromBig(0)

Return an error instead. Makes usages of NewModulusFromBig a bit more
verbose, but better than returning nil or something and just moving the
panic down the road.

Fixes #60411

Change-Id: I10732c6ce56ccd9e4769281cea049dd4beb60a6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/498035
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
12 months agocrypto/tls: advertise correct ciphers in TLS 1.3 only mode
Monis Khan [Fri, 13 Jan 2023 00:37:56 +0000 (00:37 +0000)]
crypto/tls: advertise correct ciphers in TLS 1.3 only mode

This change updates the makeClientHello logic to only advertise TLS
1.3 ciphers when tls.Config.MinVersion is set to tls.VersionTLS13
(i.e the client only supports TLS 1.3).  Previously, TLS 1.2 ciphers
would be included in the client hello message.

Fixes #57771

Change-Id: Ife4123037b0a4609578ffffb1cdf1e1d4e0a8df6
GitHub-Last-Rev: 45f4275aa9b9550e519e1be5c337b53ab8882007
GitHub-Pull-Request: golang/go#49293
Reviewed-on: https://go-review.googlesource.com/c/go/+/360794
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Marten Seemann <martenseemann@gmail.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go: clear HGRCPATH in script test
Russ Cox [Wed, 24 May 2023 13:19:15 +0000 (09:19 -0400)]
cmd/go: clear HGRCPATH in script test

Invoking 'hg' in a nonexistant HOME can break extensions the user
may have installed; clear HGRCPATH in the script test to keep tests
working in that environment.

Change-Id: I4d21d024c6229ead38e5f24186883863511fd483
Reviewed-on: https://go-review.googlesource.com/c/go/+/497878
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

12 months agocmd/go: abstract build cache, support implementations via child process
Brad Fitzpatrick [Mon, 6 Feb 2023 03:52:06 +0000 (19:52 -0800)]
cmd/go: abstract build cache, support implementations via child process

Via setting GOCACHEPROG to a binary which speaks JSON over
stdin/stdout.

For now, it requires GOEXPERIMENT=cacheprog.

Fixes golang/go#59719

Change-Id: I824ff04d5ebdf0ba4d1b5bc2e9fbaee26d34c80f
Reviewed-on: https://go-review.googlesource.com/c/go/+/486715
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
12 months agocrypto/tls: don't reverify but check certificate expiration on resumption
Filippo Valsorda [Wed, 24 May 2023 13:49:56 +0000 (15:49 +0200)]
crypto/tls: don't reverify but check certificate expiration on resumption

We used to inconsistently run certificate verification on the server on
resumption, but not on the client. This made TLS 1.3 resumption pretty
much useless, as it didn't save bytes, CPU, or round-trips.

This requires serializing the verified chains into the session ticket,
so it's a tradeoff making the ticket bigger to save computation (and for
consistency).

The previous behavior also had a "stickyness" issue: if a ticket
contained invalid certificates, they would be used even if the client
had in the meantime configured valid certificates for a full handshake.

We also didn't check expiration on the client side on resumption if
InsecureSkipVerify was set. Again for consistency, we do that now.

Also, we used to run VerifyPeerCertificates on resumption even if
NoClientCerts was set.

Fixes #31641

Change-Id: Icc88269ea4adb544fa81158114aae76f3c91a15f
Reviewed-on: https://go-review.googlesource.com/c/go/+/497895
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>

12 months agocrypto/tls: add VersionName
Filippo Valsorda [Wed, 24 May 2023 00:29:15 +0000 (02:29 +0200)]
crypto/tls: add VersionName

Fixes #46308

Change-Id: I5162b26cbce61ae5df5d2e093cf8a28406d15863
Reviewed-on: https://go-review.googlesource.com/c/go/+/497377
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Marten Seemann <martenseemann@gmail.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Samuli Silvius <samuli.silvius@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>

12 months agocrypto/tls: implement Extended Master Secret
Filippo Valsorda [Tue, 23 May 2023 23:55:45 +0000 (01:55 +0200)]
crypto/tls: implement Extended Master Secret

All OpenSSL tests now test operation with EMS. To test a handshake
*without* EMS we need to pass -Options=-ExtendedMasterSecret which is
only available in OpenSSL 3.1, which breaks a number of other tests.

Updates #43922

Change-Id: Ib9ac79a1d03fab6bfba5fe9cd66689cff661cda7
Reviewed-on: https://go-review.googlesource.com/c/go/+/497376
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
12 months agocrypto/tls: add QUIC 0-RTT APIs
Filippo Valsorda [Mon, 22 May 2023 17:23:04 +0000 (19:23 +0200)]
crypto/tls: add QUIC 0-RTT APIs

Fixes #60107

Change-Id: I158b1c2d80d8ebb5ed7a8e6f313f69060754e220
Reviewed-on: https://go-review.googlesource.com/c/go/+/496995
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agonet: implement wasip1 FileListener and FileConn
Chris O'Hara [Mon, 8 May 2023 07:08:20 +0000 (17:08 +1000)]
net: implement wasip1 FileListener and FileConn

Implements net.FileListener and net.FileConn for wasip1.

net.FileListener can be used with a pre-opened socket. If the WASM
module knows the file descriptor, a listener can be constructed with:

    l, err := net.FileListener(os.NewFile(fd, ""))

If the WASM module does not know the file descriptor, but knows that at
least one of the preopens is a socket, it can find the file descriptor
and construct a listener like so:

    func findListener() (net.Listener, error) {
        // We start looking for pre-opened sockets at fd=3 because 0, 1,
        // and 2 are reserved for stdio. Pre-opened directories also
        // start at fd=3, so we skip fds that aren't sockets. Once we
        // reach EBADF we know there are no more pre-opens.
        for preopenFd := uintptr(3); ; preopenFd++ {
            l, err := net.FileListener(os.NewFile(preopenFd, ""))

            var se syscall.Errno
            switch errors.As(err, &se); se {
            case syscall.ENOTSOCK:
                continue
            case syscall.EBADF:
                err = nil
            }
            return l, err
        }
    }

A similar strategy can be used with net.FileConn and pre-opened
connection sockets.

The wasmtime runtime supports pre-opening listener sockets:

    $ wasmtime --tcplisten 127.0.0.1:8080 module.wasm

Change-Id: Iec6ae4ffa84b3753cce4f56a2817e150445db643
Reviewed-on: https://go-review.googlesource.com/c/go/+/493358
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agoruntime: implement wasip1 netpoll
Chris O'Hara [Mon, 8 May 2023 07:07:18 +0000 (17:07 +1000)]
runtime: implement wasip1 netpoll

Implements netpoll using WASI's poll_oneoff system call.

This enables non-blocking I/O support for wasip1.

Change-Id: Ie395fa49d651c8b8262d485e2847dd65b0a10bc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/493357
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Julien Fabre <ju.pryz@gmail.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

12 months agoencoding/json: document unsupported float values
Sean Liao [Fri, 19 May 2023 18:04:07 +0000 (19:04 +0100)]
encoding/json: document unsupported float values

Fixes #59627

Change-Id: Icd6a9803e213596de6136ec980b0a352c450e6f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/496142
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
12 months agocrypto/tls: add SessionState.Extra
Filippo Valsorda [Mon, 22 May 2023 09:06:58 +0000 (11:06 +0200)]
crypto/tls: add SessionState.Extra

This can be used by applications to store additional data in a session.

Fixes #57753
For #60105

Change-Id: Ib42387ad64750fa8dbbdf51de5e9c86378bef0ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/496822
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Marten Seemann <martenseemann@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
12 months agocrypto/tls: add WrapSession and UnwrapSession
Filippo Valsorda [Mon, 22 May 2023 08:49:07 +0000 (10:49 +0200)]
crypto/tls: add WrapSession and UnwrapSession

There was a bug in TestResumption: the first ExpiredSessionTicket was
inserting a ticket far in the future, so the second ExpiredSessionTicket
wasn't actually supposed to fail. However, there was a bug in
checkForResumption->sendSessionTicket, too: if a session was not resumed
because it was too old, its createdAt was still persisted in the next
ticket. The two bugs used to cancel each other out.

For #60105
Fixes #19199

Change-Id: Ic9b2aab943dcbf0de62b8758a6195319dc286e2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/496821
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
12 months agocrypto/tls: add ClientSessionState.ResumptionState and NewResumptionState
Filippo Valsorda [Sun, 21 May 2023 19:27:48 +0000 (21:27 +0200)]
crypto/tls: add ClientSessionState.ResumptionState and NewResumptionState

For #60105
Fixes #25351

Change-Id: Iffd658f2663cfc47b48157824226ed6c0260a59e
Reviewed-on: https://go-review.googlesource.com/c/go/+/496820
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Marten Seemann <martenseemann@gmail.com>
12 months agocrypto/tls: use SessionState on the client side
Filippo Valsorda [Sun, 21 May 2023 19:17:56 +0000 (21:17 +0200)]
crypto/tls: use SessionState on the client side

Another internal change, that allows exposing the new APIs easily in
following CLs.

For #60105

Change-Id: I9c61b9f6e9d29af633f952444f514bcbbe82fe4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/496819
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>

12 months agocrypto/tls: add SessionState and use it on the server side
Filippo Valsorda [Sat, 20 May 2023 15:49:21 +0000 (17:49 +0200)]
crypto/tls: add SessionState and use it on the server side

This change by itself is useless, because the application has no way to
access or provide SessionStates to crypto/tls, but they will be provided
in following CLs.

For #60105

Change-Id: I8d5de79b1eda0a778420134cf6f346246a1bb296
Reviewed-on: https://go-review.googlesource.com/c/go/+/496818
Reviewed-by: Marten Seemann <martenseemann@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>

12 months agocrypto/tls: reduce session ticket linkability
Filippo Valsorda [Fri, 19 May 2023 21:28:43 +0000 (23:28 +0200)]
crypto/tls: reduce session ticket linkability

Ever since session ticket key rotation was introduced in CL 9072, we've
been including a prefix in every ticket to identify what key it's
encrypted with. It's a small privacy gain, but the cost of trial
decryptions is also small, especially since the first key is probably
the most frequently used.

Also reissue tickets on every resumption so that the next connection
can't be linked to all the previous ones. Again the privacy gain is
small but the performance cost is small and it comes with a reduction in
complexity.

For #60105

Change-Id: I852f297162d2b79a3d9bf61f6171e8ce94b2537a
Reviewed-on: https://go-review.googlesource.com/c/go/+/496817
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocompress/flate, archive/zip: reduce memory allocations
Maksim Meshkov [Wed, 24 May 2023 21:18:15 +0000 (21:18 +0000)]
compress/flate, archive/zip: reduce memory allocations

The existing implementation allocates a new 4KB buffer each time it opens flate-encoded file in a zip archive. This commit allows the flate reader to reuse the buffer on call Reset instead of allocating a new one.

It is noticeable when a zip archive contains a huge amount of files, e.g. zip archive has 50_000 files, for each file 4KB buffer is allocated, so it is 200MB memory allocations. If files are read sequentially only one buffer is needed.

Fixes #59774

Change-Id: Ib16336b101ba58e8f0f30a45dc5fd4eeebc801a1
GitHub-Last-Rev: f3f395b2ad95b7ad7ce9df6f5e49c7b6a0627627
GitHub-Pull-Request: golang/go#59775
Reviewed-on: https://go-review.googlesource.com/c/go/+/487675
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@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>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>