]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
2 years ago[dev.boringcrypto] all: merge master into dev.boringcrypto
Roland Shoemaker [Fri, 5 Nov 2021 18:08:36 +0000 (11:08 -0700)]
[dev.boringcrypto] all: merge master into dev.boringcrypto

Change-Id: I1aa33cabd0c55fe64994b08f8a3f7b6bbfb3282c

2 years ago[dev.boringcrypto] misc/boring: add new releases to RELEASES file
Heschi Kreinick [Thu, 4 Nov 2021 20:50:52 +0000 (16:50 -0400)]
[dev.boringcrypto] misc/boring: add new releases to RELEASES file

Change-Id: I85bc353978902238160a73d7cebd3025912189ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/361434
Trust: Heschi Kreinick <heschi@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2 years agocrypto/ecdsa: draw a fixed amount of entropy while signing
Filippo Valsorda [Mon, 27 Sep 2021 18:40:06 +0000 (14:40 -0400)]
crypto/ecdsa: draw a fixed amount of entropy while signing

The current code, introduced in CL 2422, mixes K bits of entropy with
the private key and message digest to generate the signature nonce,
where K is half the bit size of the curve. While the ECDLP complexity
(and hence security level) of a curve is half its bit size, the birthday
bound on K bits is only K/2. For P-224, this means we should expect a
collision after 2^56 signatures over the same message with the same key.

A collision, which is unlikely, would still not be a major practical
concern, because the scheme would fall back to a secure deterministic
signature scheme, and simply leak the fact that the two signed messages
are the same (which is presumably already public).

Still, we can simplify the code and remove the eventuality by always
drawing 256 bits of entropy.

Change-Id: I58097bd3cfc9283503e38751c924c53d271af92b
Reviewed-on: https://go-review.googlesource.com/c/go/+/352530
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2 years agoruntime: add a maymorestack hook that moves the stack
Austin Clements [Mon, 27 Sep 2021 14:05:13 +0000 (10:05 -0400)]
runtime: add a maymorestack hook that moves the stack

This adds a maymorestack hook that moves the stack at every
cooperative preemption point.

For #48297.

Change-Id: Ic15f9bcbc163345e6422586302d57fda4744caec
Reviewed-on: https://go-review.googlesource.com/c/go/+/359797
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: David Chase <drchase@google.com>
2 years agoruntime: add always-preempt maymorestack hook
Austin Clements [Wed, 15 Sep 2021 21:14:21 +0000 (17:14 -0400)]
runtime: add always-preempt maymorestack hook

This adds a maymorestack hook that forces a preemption at every
possible cooperative preemption point. This would have helped us catch
several recent preemption-related bugs earlier, including #47302,
 #47304, and #47441.

For #48297.

Change-Id: Ib82c973589c8a7223900e1842913b8591938fb9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/359796
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: David Chase <drchase@google.com>
2 years agocmd/{asm,compile,internal/obj}: add "maymorestack" support
Austin Clements [Tue, 20 Aug 2019 21:39:09 +0000 (17:39 -0400)]
cmd/{asm,compile,internal/obj}: add "maymorestack" support

This adds a debugging hook for optionally calling a "maymorestack"
function in the prologue of any function that might call morestack
(whether it does at run time or not). The maymorestack function will
let us improve lock checking and add debugging modes that stress
function preemption and stack growth.

Passes toolstash-check -all (except on js/wasm, where toolstash
appears to be broken)

Fixes #48297.

Change-Id: I27197947482b329af75dafb9971fc0d3a52eaf31
Reviewed-on: https://go-review.googlesource.com/c/go/+/359795
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agocmd/compile,cmd/internal/objabi: move -d flag parser to objabi
Austin Clements [Fri, 17 Sep 2021 14:07:41 +0000 (10:07 -0400)]
cmd/compile,cmd/internal/objabi: move -d flag parser to objabi

This moves and slightly generalizes the -d debug flag parser from
cmd/compile/internal/base to cmd/internal/objabi so that we can use
the same debug flag syntax in other tools.

This makes a few minor tweaks to implementation details. The flag
itself is now just a flag.Value that gets constructed explicitly,
rather than at init time, and we've cleaned up the implementation a
little (e.g., using a map instead of a linear search of a slice). The
help text is now automatically alphabetized. Rather than describing
the values of some flags in the help text footer, we simply include it
in the flags' help text and make sure multi-line help text renders
sensibly.

For #48297.

Change-Id: Id373ee3b767e456be483fb28c110d025149be532
Reviewed-on: https://go-review.googlesource.com/c/go/+/359956
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agoruntime: use correct constant when computing nsec remainder
Jason A. Donenfeld [Thu, 4 Nov 2021 23:10:31 +0000 (00:10 +0100)]
runtime: use correct constant when computing nsec remainder

A code comment on amd64 for windows and plan9 contained a snippet for
splitting apart the sec and nsec components of a unix timestamp, with
produced assembly below, which was then cleaned up by hand. When arm64
was ported, that code snippet in the comment went through the compiler
to produce some code that was then pasted and cleaned up. Unfortunately,
the comment had a typo in it, containing 8 zeros instead of 9.

This resulted in the constant used in the assembly being wrong, spotted
by @bufflig's eagle eyes. So, this commit fixes the comment on all three
platforms, and the assembly on windows/arm64.

Fixes #48072.

Change-Id: I786fe89147328b0d25544f52c927ddfdb9f6f1cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/361474
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

2 years agosync/atomic: disable GC during TestHammerStoreLoad
Michael Anthony Knyszek [Thu, 4 Nov 2021 23:13:12 +0000 (23:13 +0000)]
sync/atomic: disable GC during TestHammerStoreLoad

TestHammerStoreLoad involves a stress test of StorePointer, which has a
write barrier. The "pointer" that is being written is not a real value,
which is generally fine (though not *really* safe) on 64-bit systems
because they never point to an actual object.

On 32-bit systems, however, this is much more likely. Because I can't
figure out how to rewrite the test such that it still is testing the
same conditions but is also using real pointers, just disable the GC
during the test, and make sure there isn't one currently in progress.

Fixes #49362.

Change-Id: If81883fedf06568132e6484f40c820aa69027a9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/361455
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

2 years agonet: add UDP allocs test
Josh Bleecher Snyder [Thu, 4 Nov 2021 18:33:39 +0000 (11:33 -0700)]
net: add UDP allocs test

Change-Id: Ibefd1ca0236d17d57fc5aa5938a56ae92272ca60
Reviewed-on: https://go-review.googlesource.com/c/go/+/361396
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agointernal/poll: re-use RawSockaddrAny buffers across requests on windows
Josh Bleecher Snyder [Thu, 4 Nov 2021 19:19:04 +0000 (12:19 -0700)]
internal/poll: re-use RawSockaddrAny buffers across requests on windows

We were re-allocating a new RawSockaddrAny on every UDP read/write.
We can re-use them instead.

This reduces the number of allocs for UDP read/write on windows to zero.

Co-authored-by: David Crawshaw <crawshaw@golang.org>
Change-Id: I2f05c974e2e7b4f67937ae4e1c99583e81d140af
Reviewed-on: https://go-review.googlesource.com/c/go/+/361404
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agonet: pass around pointers to SockaddrInetN
Josh Bleecher Snyder [Wed, 3 Nov 2021 23:28:47 +0000 (16:28 -0700)]
net: pass around pointers to SockaddrInetN

...instead of the structs themselves.
Escape analysis can handle this,
and it'll avoid a bunch of large struct copies.

Change-Id: Ia9c6064ed32a4c26d5a96dae2ed7d7ece6d38704
Reviewed-on: https://go-review.googlesource.com/c/go/+/361264
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agonet: remove the alloc from ReadMsgUDPAddrPort
Josh Bleecher Snyder [Wed, 3 Nov 2021 21:42:52 +0000 (14:42 -0700)]
net: remove the alloc from ReadMsgUDPAddrPort

name                          old time/op    new time/op    delta
ReadWriteMsgUDPAddrPort-8       4.95µs ± 5%    4.55µs ± 1%    -7.96%  (p=0.016 n=5+4)

name                          old alloc/op   new alloc/op   delta
ReadWriteMsgUDPAddrPort-8        32.0B ± 0%      0.0B       -100.00%  (p=0.008 n=5+5)

name                          old allocs/op  new allocs/op  delta
ReadWriteMsgUDPAddrPort-8         1.00 ± 0%      0.00       -100.00%  (p=0.008 n=5+5)

Change-Id: Ib968c6f2968926ec9a364dd52063cd0d7c29b10c
Reviewed-on: https://go-review.googlesource.com/c/go/+/360862
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agonet: remove the alloc from WriteMsgUDPAddrPort
Josh Bleecher Snyder [Wed, 3 Nov 2021 21:08:43 +0000 (14:08 -0700)]
net: remove the alloc from WriteMsgUDPAddrPort

name                       old time/op    new time/op    delta
ReadWriteMsgUDPAddrPort-8    5.12µs ± 8%    4.59µs ± 3%  -10.19%  (p=0.000 n=10+9)

name                       old alloc/op   new alloc/op   delta
ReadWriteMsgUDPAddrPort-8     64.0B ± 0%     32.0B ± 0%  -50.00%  (p=0.000 n=10+10)

name                       old allocs/op  new allocs/op  delta
ReadWriteMsgUDPAddrPort-8      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=10+10)

Change-Id: Idf540b2f9f8035660305a0ab1cfc3e162569db63
Reviewed-on: https://go-review.googlesource.com/c/go/+/361257
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agoruntime: fix hard goal calculation
Michael Anthony Knyszek [Thu, 4 Nov 2021 21:09:34 +0000 (21:09 +0000)]
runtime: fix hard goal calculation

The new GC pacer has a bug where the hard goal isn't set in relation to
the original heap goal, but rather to the one already extrapolated for
overshoot.

In practice, I have never once seen this case arise because the
extrapolated goal used for overshoot is conservative. No test because
writing a test for this case is impossible in the idealized model the
pacer tests create. It is possible to simulate but will take more work.
For now, just leave a TODO.

Change-Id: I24ff710016cd8100fad54f71b2c8cdea0f7dfa79
Reviewed-on: https://go-review.googlesource.com/c/go/+/361435
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

2 years agocmd/go: clarify errors for pseudo-version commit length
Matthias Dötsch [Fri, 29 Oct 2021 03:23:15 +0000 (03:23 +0000)]
cmd/go: clarify errors for pseudo-version commit length

These error messages contain the expected shortened revision in braces,
but don't explicitly tell the user that this is the expected one.

Just unified it with the "does not match version-control timestamp" error which does the same...

Change-Id: I8e07df7bd776fd1b39c4c90c4788cb3d626ea00b
GitHub-Last-Rev: d14681ad086790f4e43c312c8a328d588acc6ec4
GitHub-Pull-Request: golang/go#42578
Reviewed-on: https://go-review.googlesource.com/c/go/+/269877
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2 years agocmd/go: ensure that 'go test' prints the FAIL line for a package on a new line
Bryan C. Mills [Wed, 3 Nov 2021 14:39:54 +0000 (10:39 -0400)]
cmd/go: ensure that 'go test' prints the FAIL line for a package on a new line

Fixes #49317

Change-Id: I4038fd4c1d845d54ecbbf82bf73060db1b44c9bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/361095
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agotest: fix indentation for -shuffle help text
Simon Law [Thu, 4 Nov 2021 18:14:59 +0000 (11:14 -0700)]
test: fix indentation for -shuffle help text

The help text for the go test -shuffle flag is not indented like the
other flags. This patch brings it into alignment.

Fixes #49357

Change-Id: I3f18dc7cd84d5f23099262acf6e2fedccb11379c
Reviewed-on: https://go-review.googlesource.com/c/go/+/361395
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

2 years agocmd/go: download fewer dependencies in 'go mod download'
Bryan C. Mills [Wed, 20 Oct 2021 18:02:24 +0000 (14:02 -0400)]
cmd/go: download fewer dependencies in 'go mod download'

In modules that specify 'go 1.17' or higher, the go.mod file
explicitly requires modules for all packages transitively imported by
the main module. Users tend to use 'go mod download' to prepare for
testing the main module itself, so we should only download those
relevant modules.

In 'go 1.16' and earlier modules, we continue to download all modules
in the module graph (because we cannot in general tell which ones are
relevant without loading the full package import graph).

'go mod download all' continues to download every module in
'go list all', as it did before.

Fixes #44435

Change-Id: I3f286c0e2549d6688b3832ff116e6cd77a19401c
Reviewed-on: https://go-review.googlesource.com/c/go/+/357310
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 years agocrypto/elliptic: tolerate large inputs to IsOnCurve methods
Filippo Valsorda [Thu, 4 Nov 2021 20:08:08 +0000 (16:08 -0400)]
crypto/elliptic: tolerate large inputs to IsOnCurve methods

The behavior of all Curve methods and package functions when provided an
off-curve point is undefined, except for IsOnCurve which should really
always return false, not panic.

Change-Id: I52f65df25c5af0314fef2c63d0778db72c0f1313
Reviewed-on: https://go-review.googlesource.com/c/go/+/361402
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

2 years agocmd/compile: fix TypeDefn to deal with node with no Ntype set
Dan Scales [Thu, 4 Nov 2021 18:59:17 +0000 (11:59 -0700)]
cmd/compile: fix TypeDefn to deal with node with no Ntype set

Adjust TypeDefn(), which is used by reportTypeLoop(), to work for nodes
with no Ntype set (which are all nodes in -G=3 mode). Normally,
reportTypeLoop() would not be called, because the types2 typechecker
would have already caught it. This is a possible way to report an
unusual type loop involving type params, which is not being caught by
the types2 type checker.

Updates #48962

Change-Id: I55edee46026eece2e8647c5b5b4d8dfb39eeb5f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/361398
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agoruntime: set and clear only the relevant bits in allocToCache
Michael Anthony Knyszek [Mon, 18 Oct 2021 18:22:02 +0000 (18:22 +0000)]
runtime: set and clear only the relevant bits in allocToCache

Currently allocToCache ham-handedly calls pageAlloc.allocRange on the
full size of the cache. This is fine as long as scavenged bits are never
set when alloc bits are set. This is true right now, but won't be true
as of the next CL.

This change makes allocToCache more carefully set the bits. Note that in
the allocToCache path, we were also calling update *twice*, erroneously.
The first time, with contig=true! Luckily today there's no correctness
error there because the page cache is small enough that the contig=true
logic doesn't matter, but this should at least improve allocation
performance a little bit.

Change-Id: I3ff9590ac86d251e4c5063cfd633570238b0cdbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/356609
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agoruntime: update and access scavengeGoal atomically
Michael Anthony Knyszek [Mon, 4 Oct 2021 19:52:48 +0000 (19:52 +0000)]
runtime: update and access scavengeGoal atomically

The first step toward acquiring the heap lock less frequently in the
scavenger.

Change-Id: Idc69fd8602be2c83268c155951230d60e20b42fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/353973
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agointernal/fuzz: fix internal error handling
Katie Hockman [Wed, 3 Nov 2021 18:44:16 +0000 (14:44 -0400)]
internal/fuzz: fix internal error handling

This doesn't handle every possible scenario,
but improves the one we can control. For example,
if the worker panics for some reason, we have no
way of knowing whether the panic occurred in an
expected way (while executing the fuzz target) or
due to an internal error in the worker. So any
panic will still be treated as a crash.

However, if it fails due to some internal bug that
we know how to catch, then the error should be
reported to the user without a new crasher being
written to testdata.

This is very difficult to test. The reasons an
internal error would occur is because something went
very wrong, and we have a bug in our code (which is
why they were previously panics). So simulating
a problem like this in a test is not really feasible.

Fixes #48804

Change-Id: I334618f84eb4a994a8d17419551a510b1fdef071
Reviewed-on: https://go-review.googlesource.com/c/go/+/361115
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2 years agointernal/buildcfg: enable the pacer redesign by default
Michael Anthony Knyszek [Mon, 25 Oct 2021 21:43:27 +0000 (21:43 +0000)]
internal/buildcfg: enable the pacer redesign by default

Change-Id: Ifb90d5482cb0cedee6cb4d6297853ac7913d14ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/358674
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agoruntime: implement GC pacer redesign
Michael Anthony Knyszek [Tue, 13 Apr 2021 03:07:27 +0000 (03:07 +0000)]
runtime: implement GC pacer redesign

This change implements the GC pacer redesign outlined in #44167 and the
accompanying design document, behind a GOEXPERIMENT flag that is on by
default.

In addition to adding the new pacer, this CL also includes code to track
and account for stack and globals scan work in the pacer and in the
assist credit system.

The new pacer also deviates slightly from the document in that it
increases the bound on the minimum trigger ratio from 0.6 (scaled by
GOGC) to 0.7. The logic behind this change is that the new pacer much
more consistently hits the goal (good!) leading to slightly less
frequent GC cycles, but _longer_ ones (in this case, bad!). It turns out
that the cost of having the GC on hurts throughput significantly (per
byte of memory used), though tail latencies can improve by up to 10%! To
be conservative, this change moves the value to 0.7 where there is a
small improvement to both throughput and latency, given the memory use.

Because the new pacer accounts for the two most significant sources of
scan work after heap objects, it is now also safer to reduce the minimum
heap size without leading to very poor amortization. This change thus
decreases the minimum heap size to 512 KiB, which corresponds to the
fact that the runtime has around 200 KiB of scannable globals always
there, up-front, providing a baseline.

Benchmark results: https://perf.golang.org/search?q=upload:20211001.6

tile38's KNearest benchmark shows a memory increase, but throughput (and
latency) per byte of memory used is better.

gopher-lua showed an increase in both CPU time and memory usage, but
subsequent attempts to reproduce this behavior are inconsistent.
Sometimes the overall performance is better, sometimes it's worse. This
suggests that the benchmark is fairly noisy in a way not captured by the
benchmarking framework itself.

biogo-igor is the only benchmark to show a significant performance loss.
This benchmark exhibits a very high GC rate, with relatively little work
to do in each cycle. The idle mark workers are quite active. In the new
pacer, mark phases are longer, mark assists are fewer, and some of that
time in mark assists has shifted to idle workers. Linux perf indicates
that the difference in CPU time can be mostly attributed to write-barrier
slow path related calls, which in turn indicates that the write barrier
being on for longer is the primary culprit. This also explains the memory
increase, as a longer mark phase leads to more memory allocated black,
surviving an extra cycle and contributing to the heap goal.

For #44167.

Change-Id: I8ac7cfef7d593e4a642c9b2be43fb3591a8ec9c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/309869
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agocmd/link: don't use label symbol for absolute address relocations on ARM64 PE
Cherry Mui [Tue, 2 Nov 2021 22:30:08 +0000 (18:30 -0400)]
cmd/link: don't use label symbol for absolute address relocations on ARM64 PE

On ARM64 PE, when external linking, the PE relocation does not
have an explicit addend, and instead has the addend encoded in
the instruction or data. An instruction (e.g. ADRP, ADD) has
limited width for the addend, so when the addend is large we use
a label symbol, which points to the middle of the original target
symbol, and a smaller addend. But for an absolute address
relocation in the data section, we have the full width to encode
the addend and we should not use the label symbol. Also, since we
do not adjust the addend in the data, using the label symbol will
actually make it point to the wrong address. E.g for an R_ADDR
relocation targeting x+0x123456, we should emit 0x123456 in the
data with an IMAGE_REL_ARM64_ADDR64 relocation pointing to x,
whereas the current code emits  0x123456 in the data with an
IMAGE_REL_ARM64_ADDR64 relocation pointing to the label symbol
x+1MB, so it will actually be resolved to x+0x223456. This CL
fixes this.

Fixes #47557.

Change-Id: I64e02b56f1d792f8c20ca61b78623ef5c3e34d7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/360895
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years agointernal/fuzz: improve minimizing message
Katie Hockman [Thu, 4 Nov 2021 17:55:31 +0000 (13:55 -0400)]
internal/fuzz: improve minimizing message

In order to know the actual number of bytes
of the entire corpus entry, the coordinator
would likely need to unmarshal the bytes and
tally up the length. That's more work than it
is worth, so this change just clarifies that
the printed # of bytes is the length of the
entire file, not just the entry itself.

Fixes #48989

Change-Id: I6fa0c0206a249cefdf6335040c560ec0c5a55b4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/361414
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

2 years agonet/netip: fix various typos in comment
jiahua wang [Thu, 4 Nov 2021 02:13:11 +0000 (10:13 +0800)]
net/netip: fix various typos in comment

Change-Id: I02724dadacd9b3f23ca7e6bda581cba62ceff828
Reviewed-on: https://go-review.googlesource.com/c/go/+/361274
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

2 years agoruntime: clear upper half of sec in ARM walltime
Michael Pratt [Wed, 3 Nov 2021 20:28:51 +0000 (16:28 -0400)]
runtime: clear upper half of sec in ARM walltime

https://golang.org/cl/246763 accidentally changed this to assign the old
value of vdsoPC to the upper half of sec as that is the last value in
R1.

The old value of vdsoPC is usually zero, so this typically works.
However, the reentrant case will have a non-zero value, resulting in a
bogus returned time. I am unsure if walltime is reachable from a signal
handler, so this may never occur.

Change-Id: I8562d6ec2a845fcffee9618d994b8ea57fbd199e
Reviewed-on: https://go-review.googlesource.com/c/go/+/361159
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agocmd/pprof: update vendored github.com/google/pprof
Dmitri Shuralyov [Thu, 4 Nov 2021 12:46:07 +0000 (08:46 -0400)]
cmd/pprof: update vendored github.com/google/pprof

Pull in the latest published version of github.com/google/pprof
as part of #36905.

This adds the fmt.Println redundant newline fix from
google/pprof@f987b9c94b318d4bd026dcc7892f7f1fab6eadab.

Done with:

go get -d github.com/google/pprof@latest
go mod tidy
go mod vendor

For #36905.
Fixes #49322.

Change-Id: Ia832766bba65a30c68407b73b33fefbe81438e65
Reviewed-on: https://go-review.googlesource.com/c/go/+/361294
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2 years agocmd/compile/internal/types2: check non-generic conversions first
Robert Griesemer [Thu, 4 Nov 2021 03:42:44 +0000 (20:42 -0700)]
cmd/compile/internal/types2: check non-generic conversions first

This enables the elimination of convertibleToImpl again,
with the code structure close to the original non-generic
version, and closely matching the structure of assignableTo.

We also don't need the hasTerm tests; instead we can rely
directly on the mechanism of TypeParam.is which is feeding
a nil term if there are no specific types.

Change-Id: I0385acca779d75c3c961d06afb464714fe51705d
Reviewed-on: https://go-review.googlesource.com/c/go/+/361269
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agocmd/compile: don't inline fn with no shape params, but passed a shape arg
Dan Scales [Wed, 3 Nov 2021 21:47:04 +0000 (14:47 -0700)]
cmd/compile: don't inline fn with no shape params, but passed a shape arg

Don't inline a function fn that has no shape parameters, but is passed
at least one shape arg. This means we must be inlining a non-generic
function fn that was passed into a generic function, and can be called
with a shape arg because it matches an appropriate type parameter. But
fn may include an interface conversion (that may be applied to a shape
arg) that was not apparent when we first created the instantiation of
the generic function. We can't handle this if we actually do the
inlining, since we want to know all interface conversions immediately
after stenciling.  So, we avoid inlining in this case.

Fixes #49309.

Change-Id: I7b8ab7b13e58fdb0111db91bc92a91d313f7c2c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/361260
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2 years agocmd/doc, go/doc: add basic support for generic code
Robert Findley [Fri, 29 Oct 2021 21:41:41 +0000 (17:41 -0400)]
cmd/doc, go/doc: add basic support for generic code

Update cmd/doc and go/doc for the generics, by adding handling for type
parameters and the new embedded interface elements.

Specifically:
 - Format type parameters when summarizing type and function nodes.
 - Find the origin type name for instantiation expressions, so that
   methods are associated with generic type declarations.
 - Generalize the handling of embedding 'error' in interfaces to
   arbitrary predeclared types.
 - Keep embedded type literals.
 - Update filtering to descend into embedded type literals.

Also add "any" to the list of predeclared types.

Updates #49210

Change-Id: I6ea82869f19c3cdbc3c842f01581c8fc7e1c2ee7
Reviewed-on: https://go-review.googlesource.com/c/go/+/359778
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agoruntime: allow builtin write function to be redirected with function pointer
Jason A. Donenfeld [Thu, 3 Dec 2020 12:29:58 +0000 (13:29 +0100)]
runtime: allow builtin write function to be redirected with function pointer

The x/sys/windows package currently uses go:linkname for other facilities
inside of runtime that are not suitable to be exposed as a public API
due to their dangers but are still necessary for manipulating any
low-level plumbing that the runtime controls.

Logging, via the built-in println and panic handler, is one such
low-level plumbing feature. In this case, x/sys/windows/svc needs to be
able to redirect panics to the Windows event log. Because the event log
is a complicated interface, this requires a bit more fiddling than the
simple solution used on Android (baking it into runtime itself), and
because Windows services are very diverse, the event log might not even
always be a desirable destination.

This commit accomplishes this by exposing a function pointer called
"overrideWrite" that low-level runtime packages like x/sys/windows/svc
can use to redirect output logs toward the event log or otherwise.

It is not safe or acceptable to use as a generic mechanism, and for that
reason, we wouldn't want to expose this as a real stable API, similar to
the other instances of go:linkname in x/sys/windows. But for packages
that must interoperate with low-level Go runtime fundamentals, this is a
safety hatch for packages that are developed in tandem with the runtime.
x/sys/windows is one such package.

Updates #42888.

Change-Id: I77a32ff7e1494324e8cc38e792e007f86d32672d
Reviewed-on: https://go-review.googlesource.com/c/go/+/278792
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2 years agonet/http: reduce TestClientTimeout_h{1,2} latency
Bryan C. Mills [Thu, 4 Nov 2021 02:15:17 +0000 (22:15 -0400)]
net/http: reduce TestClientTimeout_h{1,2} latency

The test had been setting an arbitrary 200ms timeout to allow the
server's handler to set up before timing out. That is not only
potentially flaky on slow machines, but also typically much longer
than necessary. Replace the hard-coded timeout with a much shorter
initial timeout, and use exponential backoff to lengthen it if needed.

This allows the test to be run about 20x faster in the typical case,
which may make it easier to reproduce rare failure modes by running
with a higher -count flag.

For #43120

Change-Id: I1e0d0ec99d5a107fff56e3bcc7174d686ec582d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/361275
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2 years agoruntime: do not generate crash dump on Windows 7
Alex Brainman [Sun, 31 Oct 2021 06:58:34 +0000 (17:58 +1100)]
runtime: do not generate crash dump on Windows 7

It appears Windows 7 ignores WER_FAULT_REPORTING_NO_UI WerSetFlags
API flag.

And now after CL 307372, runtime will display WER GUI dialogue.

We don't want to introduce random GUI dialogues during Go program
execution. So disable dump crash creation on Windows 7 altogether.

Updates #20498

Change-Id: Ie268a7d4609f8a0eba4fe9ecf250856b0a61b331
Reviewed-on: https://go-review.googlesource.com/c/go/+/360617
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
2 years agocmd/compile/internal/types2: implement compiler helper functions without using under
Robert Griesemer [Wed, 3 Nov 2021 19:39:43 +0000 (12:39 -0700)]
cmd/compile/internal/types2: implement compiler helper functions without using under

These functions are exported for the compiler and are used after
type checking is finished. There is no need to call under() in
their implementations; they can rely entirely on the public API.
This opens the door to moving them into the compiler eventually.
They may also be slightly more efficient.

Change-Id: Ib4f83d2dcf82e3c319c3147e01ecaea684553ea5
Reviewed-on: https://go-review.googlesource.com/c/go/+/361214
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agocmd/compile/internal/types2: minor cleanups in predicates.go
Robert Griesemer [Wed, 3 Nov 2021 04:31:50 +0000 (21:31 -0700)]
cmd/compile/internal/types2: minor cleanups in predicates.go

- reordered some functions for better organization
- renamed single arguments typ to t for consistency
- updated some comments

No functional changes.

Change-Id: I4362ac48044595cdf5c3d9eb7b2f7b94e776d65b
Reviewed-on: https://go-review.googlesource.com/c/go/+/360956
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agocmd/compile/internal/types2: rename is_X predicates back to isX (step 2 of 2)
Robert Griesemer [Wed, 3 Nov 2021 15:39:41 +0000 (08:39 -0700)]
cmd/compile/internal/types2: rename is_X predicates back to isX (step 2 of 2)

This is s/is_/is/ throughout. No other changes.

Change-Id: I1be77a209133edc68a6dec0677a4991a7683f116
Reviewed-on: https://go-review.googlesource.com/c/go/+/361134
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agocmd/compile/internal/types2: rename isX predicates to allX, add simple is_X (step...
Robert Griesemer [Wed, 3 Nov 2021 00:31:51 +0000 (17:31 -0700)]
cmd/compile/internal/types2: rename isX predicates to allX, add simple is_X (step 1 of 2)

Rename the isX predicates to allX to clearly identify that these
predicates are looking inside type parameters.

Introduce is_X as predicates that do not look
inside type parameters so we can see all call sites.
The next CL will rename them all back to isX.

Review all call sites and use correct predicate.

Replace the single helper function is with isBasic and allBasic.

Change-Id: I3430ccfc466fdedf4b58a6158f95d47b9020f7a5

Change-Id: I81116b87cf8f2e17526723c7440676d133057aca
Reviewed-on: https://go-review.googlesource.com/c/go/+/360955
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agocmd/compile/internal/types2: remove qualification from type parameter strings
Robert Griesemer [Thu, 4 Nov 2021 01:06:42 +0000 (18:06 -0700)]
cmd/compile/internal/types2: remove qualification from type parameter strings

This is a clean port of CL 360938 from go/types to types2.

For #49215.

Change-Id: If20779c862b71641cb6afe4c281fbad5488a8abe
Reviewed-on: https://go-review.googlesource.com/c/go/+/361266
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agocmd/compile: fix missing update source type in storeArgOrLoad
Cuong Manh Le [Mon, 1 Nov 2021 07:32:39 +0000 (14:32 +0700)]
cmd/compile: fix missing update source type in storeArgOrLoad

After removing trivial wrapper types, the source needs to be updated
with new type, otherwise, it leads to mismatch between field offset and
the source type for selecting struct/array.

Fixes #49249

Change-Id: I26f9440bcb2e78bcf0617afc21d9d40cdbe4aca6
Reviewed-on: https://go-review.googlesource.com/c/go/+/360057
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2 years agosyscall: fix and document uses of RegEnumKeyEx
Michael Anthony Knyszek [Wed, 3 Nov 2021 18:18:18 +0000 (18:18 +0000)]
syscall: fix and document uses of RegEnumKeyEx

RegEnumKeyEx has an undocumented requirement that subsequent calls need
to be made from the same thread. This change documents that requirement
and fixes uses of it in std.

Fixes #49320.

Change-Id: I6d182227e22dd437996a878b3a978943f01b2d61
Reviewed-on: https://go-review.googlesource.com/c/go/+/361154
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agocmd/compile: add extra test for the non-mono pass
Dan Scales [Wed, 3 Nov 2021 22:29:43 +0000 (15:29 -0700)]
cmd/compile: add extra test for the non-mono pass

Just add a test for another function that is not monomorphisable, which
comes from the Featherweight Go paper.

Updates #48018

Change-Id: I664e3f48412b02678e32b50204dc4befae90374c
Reviewed-on: https://go-review.googlesource.com/c/go/+/361262
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agogo/types: remove qualification from type parameter strings
Robert Findley [Tue, 2 Nov 2021 23:49:15 +0000 (19:49 -0400)]
go/types: remove qualification from type parameter strings

Type parameters only exist within the scope of a type or function
declaration, so there is really no reason to package-qualify them. It is
also confusing to do so, as it makes their type string look like a
defined type.

Fixes #49215

Change-Id: I986c527e78d45f3cadd75bc3b244e23dabe707ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/360938
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agocmd/trace: use fmt.Print for newline-ending fixed string
Zvonimir Pavlinovic [Wed, 3 Nov 2021 23:44:44 +0000 (16:44 -0700)]
cmd/trace: use fmt.Print for newline-ending fixed string

This redundancy is now caught by the improved printf vet checker.

Updates #49322

Change-Id: Ic7a931b8d4838be02ebb855b69624b95093bd114
Reviewed-on: https://go-review.googlesource.com/c/go/+/361265
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agocmd/compile/internal/syntax: better error message when type parameters are not permitted
Robert Griesemer [Wed, 3 Nov 2021 21:58:59 +0000 (14:58 -0700)]
cmd/compile/internal/syntax: better error message when type parameters are not permitted

Fixes #48382.

Change-Id: I215896a4429839c41c9136b6922b1b748ed47734
Reviewed-on: https://go-review.googlesource.com/c/go/+/361259
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agocmd/cover: use fmt.Print for newline-ending fixed string
Zvonimir Pavlinovic [Wed, 3 Nov 2021 23:31:11 +0000 (16:31 -0700)]
cmd/cover: use fmt.Print for newline-ending fixed string

This redundancy is now caught by the improved printf vet checker
(golang/go#30436).

Updates #49322

Change-Id: Id450247adc6fa28a9244c019be3c1b52c2d17f49
Reviewed-on: https://go-review.googlesource.com/c/go/+/361263
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2 years agosyscall: unify unix Recvmsg epilogues
Josh Bleecher Snyder [Tue, 2 Nov 2021 19:25:23 +0000 (12:25 -0700)]
syscall: unify unix Recvmsg epilogues

These were identical. This is a preliminary step
towards remove allocs per UDP receive.

Change-Id: I83106cd3f1fe4bc5bae2d1b0ebd23eedd820abed
Reviewed-on: https://go-review.googlesource.com/c/go/+/361258
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agosyscall: unify unix Sendmsg prologues
Josh Bleecher Snyder [Tue, 2 Nov 2021 18:59:56 +0000 (11:59 -0700)]
syscall: unify unix Sendmsg prologues

These were identical. This is a preliminary step
towards remove allocs per UDP send.

Change-Id: I21e1264c7d4747baa626ddb93afff4c1cf225d13
Reviewed-on: https://go-review.googlesource.com/c/go/+/361256
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agointernal/poll: remove alloc sending IPv6 UDP on Windows
Josh Bleecher Snyder [Wed, 3 Nov 2021 20:54:08 +0000 (13:54 -0700)]
internal/poll: remove alloc sending IPv6 UDP on Windows

This was an oversight in CL 331511.

Change-Id: Ibc20bf6ea80a8675d43d9691ed551dffab1d9215
Reviewed-on: https://go-review.googlesource.com/c/go/+/361254
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

2 years agonet/netip: fix various typos in comments
Jason A. Donenfeld [Wed, 3 Nov 2021 15:18:36 +0000 (16:18 +0100)]
net/netip: fix various typos in comments

Change-Id: I67998f70969ac6e6ff1b52a56e49a61ef167ed50
Reviewed-on: https://go-review.googlesource.com/c/go/+/361055
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agodatabase/sql: fix tx.Prepare documentation
Mostafa Solati [Tue, 3 Aug 2021 17:09:29 +0000 (21:39 +0430)]
database/sql: fix tx.Prepare documentation

Fixes: #45978
Change-Id: I3d5ccd621d670f97bb1a642b4e84b6629347a315
Reviewed-on: https://go-review.googlesource.com/c/go/+/339291
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Trust: Cherry Mui <cherryyz@google.com>

2 years agodatabase/sql: use errors.Is when checking ErrBadConn
Daniel Theophanes [Mon, 12 Jul 2021 14:25:04 +0000 (09:25 -0500)]
database/sql: use errors.Is when checking ErrBadConn

When drivers return driver.ErrBadConn, no meaningful
information about what the cause of the problem is
returned. Ideally the driver.ErrBadConn would be
always caught with the retry loop, but this is not
always the case. Drivers today must choose between
returning a useful error and use the rety logic.
This allows supporting both.

Fixes #47142

Change-Id: I454573028f041dfdf874eed6c254fb194ccf6d96
Reviewed-on: https://go-review.googlesource.com/c/go/+/333949
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agosyscall: migrate new UDP send/recv API to internal/syscall/unix
Josh Bleecher Snyder [Wed, 3 Nov 2021 20:43:12 +0000 (13:43 -0700)]
syscall: migrate new UDP send/recv API to internal/syscall/unix

CL 331490 and friends added new API to package syscall.
This was a mistake that we need to fix before Go 1.18 is released.

Change-Id: I697c9a4fa649d564822f585dc163df5ab9e5ae08
Reviewed-on: https://go-review.googlesource.com/c/go/+/361216
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2 years agocmd/compile: fix up shape type package
Keith Randall [Wed, 3 Nov 2021 18:26:37 +0000 (11:26 -0700)]
cmd/compile: fix up shape type package

Use go.shape instead of .shape as the package the compiler uses
to store shape types.

Prevent path escaping for compiler-internal types, so we don't
need to see %2e everywhere.

Change-Id: I98e39c3b6472560113bdea7e0ba6eb7b81cb35e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/361174
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2 years agodatabase/sql: Fix idle connection reuse
Steven Hartland [Tue, 9 Jun 2020 07:58:08 +0000 (08:58 +0100)]
database/sql: Fix idle connection reuse

Fix idle connection reuse so that ConnMaxIdleTime clears down excessive
idle connections.

This now ensures that db.freeConn is ordered by returnedAt and that
connections that have been idle for the shortest period are reused
first.

In addition connectionCleanerRunLocked updates the next check deadline
based on idle and maximum life time information so that we avoid waiting
up to double MaxIdleTime to close connections.

Corrected the calling timer of connectionCleaner.

Fixes #39471

Change-Id: I6d26b3542179ef35aa13e5265a89bc0f08ba7fa1
Reviewed-on: https://go-review.googlesource.com/c/go/+/237337
Reviewed-by: Tamás Gulácsi <tgulacsi78@gmail.com>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Trust: Ian Lance Taylor <iant@golang.org>

2 years agoruntime: on windows, read nanotime with one instruction or issue barrier
Jason A. Donenfeld [Wed, 3 Nov 2021 17:19:04 +0000 (18:19 +0100)]
runtime: on windows, read nanotime with one instruction or issue barrier

On 64-bit, this is more efficient, and on ARM64, this prevents the time
from moving backwards due to the weaker memory model. On ARM32 due to
the weaker memory model, we issue a memory barrier.

Updates #48072.

Change-Id: If4695716c3039d8af14e14808af217f5c99fc93a
Reviewed-on: https://go-review.googlesource.com/c/go/+/361057
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2 years agocmd/compile: make pointers to arrays their own shape
Keith Randall [Wed, 3 Nov 2021 16:40:32 +0000 (09:40 -0700)]
cmd/compile: make pointers to arrays their own shape

Pointers to arrays can be used to cast from a slice. We need
the shape of such type params to be different so we can compile
those casts correctly.

This is kind of a big hammer to fix #49295. It would be nice to
only do this when we know there's a []T->*[N]T conversion.

Fixes #49295

Change-Id: Ibda33057fab2dd28162537aab0f1244211d68e3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/361135
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2 years agointernal/fuzz: improve error for mismatched types
Katie Hockman [Wed, 3 Nov 2021 14:58:59 +0000 (10:58 -0400)]
internal/fuzz: improve error for mismatched types

Fixes #48635

Change-Id: Ia3cde119d5eb31bc771fe3a39acb2372dbd988ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/361114
Trust: Katie Hockman <katie@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2 years agoruntime/pprof: disable GC during calibration test
Rhys Hiltner [Sat, 30 Oct 2021 00:35:30 +0000 (17:35 -0700)]
runtime/pprof: disable GC during calibration test

TestCPUProfileMultithreadMagnitude compares Go's CPU profile against the
OS's accounting of the process's execution time, expecting them to be
near equal. Background work from the runtime (especially in the garbage
collector) can add significant noise to that measurement and flakiness
to the test. Disable automatic GC cycles during the test.

Updates #49065

Change-Id: Ie88895bfea17374278c5187f3a83e9f486bd37fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/359934
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

2 years agotest/typeparam: add test for indexing on typeparams with various constraints
Dan Scales [Wed, 3 Nov 2021 03:42:21 +0000 (20:42 -0700)]
test/typeparam: add test for indexing on typeparams with various constraints

Add test for indexing on variables whose types are constrained to
various kinds of types.

Change-Id: I991eecfe39dba5d817c0fbe259ba558d4881ea84
Reviewed-on: https://go-review.googlesource.com/c/go/+/360867
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agoall: add support for c-archive and c-shared on linux/riscv64
Joel Sing [Thu, 15 Jul 2021 17:06:18 +0000 (03:06 +1000)]
all: add support for c-archive and c-shared on linux/riscv64

This provides the runtime glue (_rt0_riscv64_linux_lib) for c-archive and c-shared
support, along with enabling both of these buildmodes on linux/riscv64.

Both misc/cgo/testcarchive and misc/cgo/testcshared now pass on this platform.

Fixes #47100

Change-Id: I7ad75b23ae1d592dbac60d15bba557668287711f
Reviewed-on: https://go-review.googlesource.com/c/go/+/334872
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agocmd/asm,cmd/compile,runtime: stop using X3 (aka GP) on riscv64
Joel Sing [Sun, 26 Sep 2021 09:21:29 +0000 (19:21 +1000)]
cmd/asm,cmd/compile,runtime: stop using X3 (aka GP) on riscv64

The X3 (aka GP) register will potentially be loaded with the __global_pointer$ symbol
during program start up (usually by the dynamic linker). As such, non-Go code may depend
on the contents of GP and calculate offsets based on it, including code called via cgo
and signal handlers installed by non-Go code. As such, stop using the X3 register so
that there are fewer issues interacting between Go and non-Go code.

While here remove the X4 (TP) name from the assembler such that any references must
use the 'TP' name. This should reduce the likelihood of accidental use (like we do
for the 'g' register). The same applies for X3 (GP) when the -shared flag is given.

Updates #47100

Change-Id: I72e82b5ca3f80c46a781781345ca0432a4111b74
Reviewed-on: https://go-review.googlesource.com/c/go/+/351859
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

2 years agocmd/compile/internal/types2: port nomono check from go/types
Matthew Dempsky [Tue, 2 Nov 2021 19:50:05 +0000 (12:50 -0700)]
cmd/compile/internal/types2: port nomono check from go/types

Same logic as CL 357449 (including CL 360815), just ported to types2.

Updates #48098.

Change-Id: I4578f7329bb4ffc42410025bb6cb97e24697ebfd
Reviewed-on: https://go-review.googlesource.com/c/go/+/360857
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agoruntime: install sigPreempt signal handler for c-archive/c-shared
Ian Lance Taylor [Tue, 2 Nov 2021 21:12:05 +0000 (14:12 -0700)]
runtime: install sigPreempt signal handler for c-archive/c-shared

Fixes #49288

Change-Id: I7bfcbecbefa68871a3e556935a73f241fff44c0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/360861
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agocmd/compile/internal/types2: report cause for failing const conversions
Robert Griesemer [Tue, 2 Nov 2021 16:58:12 +0000 (09:58 -0700)]
cmd/compile/internal/types2: report cause for failing const conversions

Follow-up on CL 360396.

Change-Id: Icd802baffb1fef91f8fef0070b6167a438ceda1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/360795
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types: report cause for failing const conversions
Robert Findley [Tue, 2 Nov 2021 22:42:51 +0000 (18:42 -0400)]
go/types: report cause for failing const conversions

This is a port of CL 360795 to go/types. Error messages were adjusted
accordingly, with a TODO to fix the discrepancy.

Change-Id: Ifd7d8248fa11a31fde391021f3c5f1840877892f
Reviewed-on: https://go-review.googlesource.com/c/go/+/360937
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agogo/types: fix indexing of generic types
Robert Findley [Tue, 2 Nov 2021 22:36:36 +0000 (18:36 -0400)]
go/types: fix indexing of generic types

This is a clean port of CL 360603 to go/types.

Change-Id: Iadb312f07e509ff83339d5525765b7b7987bf233
Reviewed-on: https://go-review.googlesource.com/c/go/+/360936
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agogo/types: adjust printing of type parameter in error
Robert Findley [Tue, 2 Nov 2021 22:29:27 +0000 (18:29 -0400)]
go/types: adjust printing of type parameter in error

This is a clean port of CL 360514 to go/types.

Change-Id: Ia13638b3758b3b8017867934d09136ac5f9a62ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/360935
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agogo/types: fix conversions of constants to type parameter
Robert Findley [Tue, 2 Nov 2021 22:25:21 +0000 (18:25 -0400)]
go/types: fix conversions of constants to type parameter

This is a port of both CL 360396 and CL 360796 to go/types. The latter
is added to avoid introducing an intermediate bug.

An error message was adjusted in issue49296.go2, with a TODO to switch
to the types2 error.

Change-Id: Iede294b69b4e097e53876498f039ee18667568c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/360934
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agoruntime/asan: declare asan reporting functions in C
Ian Lance Taylor [Tue, 2 Nov 2021 20:56:22 +0000 (13:56 -0700)]
runtime/asan: declare asan reporting functions in C

Fixes #49287

Change-Id: I3f970d6db0b1dee886df2f7bb6cbeb56a37c42c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/360860
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

2 years agocmd/compile: remove TODO that is no longer relevant
Dan Scales [Tue, 2 Nov 2021 19:30:37 +0000 (12:30 -0700)]
cmd/compile: remove TODO that is no longer relevant

types2 methods are now sorted in the same way as types1, so this TODO is
no longer needed.  (Comment change only).

Change-Id: Ic975ce001a5d54f15381a9cb7b6969dff795e3b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/360856
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2 years agodoc/go1.18: remove some redundancy from netip docs
Brad Fitzpatrick [Tue, 2 Nov 2021 14:59:16 +0000 (07:59 -0700)]
doc/go1.18: remove some redundancy from netip docs

Change-Id: I593862331add3366f6b337844588568301746b80
Reviewed-on: https://go-review.googlesource.com/c/go/+/360608
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>

2 years agogo/types: differently named types are not assignable
Robert Findley [Tue, 2 Nov 2021 15:46:25 +0000 (11:46 -0400)]
go/types: differently named types are not assignable

This is a clean port of CL 360274 to go/types.

Change-Id: Idfa584fab95f7226e10b1a7c5b06d56a0bf9d757
Reviewed-on: https://go-review.googlesource.com/c/go/+/360759
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agogo/types: disallow lone type parameter on RHS of type declaration
Robert Findley [Tue, 2 Nov 2021 15:42:54 +0000 (11:42 -0400)]
go/types: disallow lone type parameter on RHS of type declaration

This is a clean port of CL 359177 to go/types.

Change-Id: I6c1574e3a1c23ea326eb8d4aacea0e78415703ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/360758
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agogo/types: implement singleType and structure (type)
Robert Findley [Tue, 2 Nov 2021 15:34:11 +0000 (11:34 -0400)]
go/types: implement singleType and structure (type)

This is a clean port of CL 359015 to go/types.

Change-Id: Iea4e3bfe0a4ae0e5a9052cb6e66c01405bd57c3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/360756
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agogo/types: rename isNamed predicate to hasName
Robert Findley [Tue, 2 Nov 2021 15:23:19 +0000 (11:23 -0400)]
go/types: rename isNamed predicate to hasName

This is a clean port of CL 358621 to go/types.

Change-Id: I4e858b1b70cff69b6e0e76bb8a58a70ff54990c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/360755
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agogo/types: clean up asT converters (step 2 of 2)
Robert Findley [Tue, 2 Nov 2021 15:20:10 +0000 (11:20 -0400)]
go/types: clean up asT converters (step 2 of 2)

This is a clean port of CL 358774 to go/types.

Change-Id: Icba54336de2b8de7c2002d2a44cac856907178c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/360754
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agoerrors: improve wording in As doc comment
Josh Bleecher Snyder [Tue, 2 Nov 2021 18:05:03 +0000 (11:05 -0700)]
errors: improve wording in As doc comment

"so" didn't have an antecedent.

Change-Id: I27f7b334decea7bc34bfa3f3f2d3a79874c6fe90
Reviewed-on: https://go-review.googlesource.com/c/go/+/360797
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agoarchive/zip: don't panic on (*Reader).Open
Jason7602 [Tue, 14 Sep 2021 13:38:19 +0000 (21:38 +0800)]
archive/zip: don't panic on (*Reader).Open

Previously, opening a zip with (*Reader).Open could result in a panic if
the zip contained a file whose name was exclusively made up of slash
characters or ".." path elements.

Open could also panic if passed the empty string directly as an argument.

Now, any files in the zip whose name could not be made valid for
fs.FS.Open will be skipped, and no longer added to the fs.FS file list,
although they are still accessible through (*Reader).File.

Note that it was already the case that a file could be accessible from
(*Reader).Open with a name different from the one in (*Reader).File, as
the former is the cleaned name, while the latter is the original one.

Finally, made the actual panic site robust as a defense-in-depth measure.

Fixes CVE-2021-41772
Fixes #48085

Co-authored-by: Filippo Valsorda <filippo@golang.org>
Change-Id: I6271a3f2892e7746f52e213b8eba9a1bba974678
Reviewed-on: https://go-review.googlesource.com/c/go/+/349770
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Katie Hockman <katie@golang.org>
Trust: Julie Qiu <julie@golang.org>

2 years agogo/types: clean up asT converters (step 1 of 2)
Robert Findley [Mon, 1 Nov 2021 19:27:13 +0000 (15:27 -0400)]
go/types: clean up asT converters (step 1 of 2)

This is a port of CL 358597 to go/types. A comment was missing in the
base of applyTypeFunc, which had been there since the initial check-in
of types2; somehow it was not in go/types.

Change-Id: If08efd92d782dd3099b26254ae6e311c6cea8c3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/360477
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agosyscall: fix finalizer fd close bugs in TestFcntlFlock and TestPassFD
Michael Anthony Knyszek [Mon, 1 Nov 2021 22:35:29 +0000 (22:35 +0000)]
syscall: fix finalizer fd close bugs in TestFcntlFlock and TestPassFD

Currently, the syscall test suite takes very little time to run. It
stands to reason that pretty much every time, zero GCs execute.

With CL 309869, this changes because the minimum heap size is lowered,
triggering two bugs in the test suite.

One bug is in TestFcntlFlock, where a raw FD is wrapped in an os.File
whose last reference is passed into a Cmd. That FD is then closed by a
defer syscall.Close, instead of the os.File's Close, so the finalizer
may fire *after* that FD has already been reused by another test.

The second bug is in the child helper process of TestPassFD, where
there's a small window in which a temp file's FD is encoded for an
out-of-band unix domain socket message to the parent, but not yet sent.
The point of encoding is also the last reference that FD's os.File, so a
finalizer may run at any time. While it's safe for the finalizer to run
after the FD is sent, if it runs before, the send will fail, since unix
domain sockets require that any sent FDs are valid.

Change-Id: I2d1bd7e6db6efcc6763273217fd85cb5b9764274
Reviewed-on: https://go-review.googlesource.com/c/go/+/360575
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agogo/types: avoid closure allocations in mono check
Matthew Dempsky [Tue, 2 Nov 2021 18:23:34 +0000 (11:23 -0700)]
go/types: avoid closure allocations in mono check

This CL replaces monoEdge's "report" field with fields "pos" and
"typ", and pushes the logic for formatting them into the report
loop. This avoids needing to allocate a function closure for each
edge.

Also tweak a test case so the two type parameters involved in the
cycle aren't both "T" so they're easier to understand.

Change-Id: I9d392ad1d99a4c5e89da4613084e885149ebad07
Reviewed-on: https://go-review.googlesource.com/c/go/+/360815
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agonet/http: deflake TestServerKeepAlivesEnabled_h{1,2}
Damien Neil [Tue, 2 Nov 2021 18:52:36 +0000 (11:52 -0700)]
net/http: deflake TestServerKeepAlivesEnabled_h{1,2}

This test assumes that two successive TCP connections will use different
source ports. This does not appear to be a universally safe assumption.

Rewrite the test to use httptrace to detect connection reuse instead.

Fixes #46707

Change-Id: Iebfbdfdeb77a1e6663a0c654dc847cc270c5d54d
Reviewed-on: https://go-review.googlesource.com/c/go/+/360854
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2 years agocmd/compile/internal/abi: fix some typos in comments
Than McIntosh [Tue, 2 Nov 2021 17:44:05 +0000 (13:44 -0400)]
cmd/compile/internal/abi: fix some typos in comments

Fix a few types in the header comment for 'ComputePadding'.

Change-Id: If38911e6dcbec571845ae44eef30fd6c33f589cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/360814
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agonet: add ReadFromUDPAddrPort
Josh Bleecher Snyder [Mon, 1 Nov 2021 20:45:21 +0000 (13:45 -0700)]
net: add ReadFromUDPAddrPort

It is now possible to do completely allocation-free UDP.

This is implemented completely separately from ReadFromUDP
because ReadFromUDP exists in a delicate balance to allow
mid-stack inlining. After performance-sensitive callers have
migrated to ReadFromUDPAddrPort, we may be able to simplify
ReadFromUDP to call ReadFromUDPAddrPort.

name                          old time/op    new time/op    delta
WriteToReadFromUDPAddrPort-8    4.71µs ± 2%    4.81µs ± 5%    +2.18%  (p=0.000 n=14+14)

name                          old alloc/op   new alloc/op   delta
WriteToReadFromUDPAddrPort-8     4.00B ± 0%     0.00B       -100.00%  (p=0.000 n=15+15)

name                          old allocs/op  new allocs/op  delta
WriteToReadFromUDPAddrPort-8      1.00 ± 0%      0.00       -100.00%  (p=0.000 n=15+15)

Change-Id: I37f5ad9416a1d4333ed48d83474b2cf933b2a1be
Reviewed-on: https://go-review.googlesource.com/c/go/+/360600
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2 years agonet: optimize WriteToUDPAddrPort
Josh Bleecher Snyder [Mon, 1 Nov 2021 20:23:39 +0000 (13:23 -0700)]
net: optimize WriteToUDPAddrPort

See the recent change optimizing WriteMsgUDPAddrPort
for an explanation of why this change includes copy/paste/modify
instead of implementing WriteToUDP using WriteToUDPAddrPort.

name                          old time/op    new time/op    delta
WriteToReadFromUDPAddrPort-8    5.02µs ± 3%    4.71µs ± 2%   -6.31%  (p=0.000 n=15+14)

name                          old alloc/op   new alloc/op   delta
WriteToReadFromUDPAddrPort-8     68.0B ± 0%      4.0B ± 0%  -94.12%  (p=0.000 n=15+15)

name                          old allocs/op  new allocs/op  delta
WriteToReadFromUDPAddrPort-8      3.00 ± 0%      1.00 ± 0%  -66.67%  (p=0.000 n=15+15)

Change-Id: I301715e774de07eb6ccb4e329ccf2e554609abc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/360599
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2 years agonet: add BenchmarkWriteToReadFromUDPAddrPort
Josh Bleecher Snyder [Mon, 1 Nov 2021 21:07:30 +0000 (14:07 -0700)]
net: add BenchmarkWriteToReadFromUDPAddrPort

The main item of interest is the allocs.

BenchmarkWriteToReadFromUDPAddrPort-8      237735       5152 ns/op       68 B/op        3 allocs/op

Change-Id: I5cb3f2e1ebbb02acc51039c2266e99b90d388a99
Reviewed-on: https://go-review.googlesource.com/c/go/+/360598
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2 years agocmd/compile: mark type descriptors as always dupok
Keith Randall [Sat, 30 Oct 2021 21:39:29 +0000 (14:39 -0700)]
cmd/compile: mark type descriptors as always dupok

The types of the two interfaces should be equal, but they aren't.
We end up with multiple descriptors for a type when we need type
descriptors to be unique.

Fixes #49241

Change-Id: I8a6c70da541c6088a92a01392bc83b61cc130eba
Reviewed-on: https://go-review.googlesource.com/c/go/+/360134
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2 years agodebug/gosym: bulk allocate Syms
Josh Bleecher Snyder [Wed, 6 Oct 2021 19:40:35 +0000 (12:40 -0700)]
debug/gosym: bulk allocate Syms

name                old time/op    new time/op    delta
115/NewLineTable-8    80.7ns ± 1%    81.7ns ± 3%     ~     (p=0.408 n=10+8)
115/NewTable-8        76.3µs ± 2%    63.3µs ± 3%  -17.03%  (p=0.000 n=9+9)
115/LineToPC-8        56.8µs ± 2%    56.8µs ± 3%     ~     (p=0.905 n=10+9)
115/PCToLine-8         252ns ± 1%     256ns ± 5%     ~     (p=0.183 n=10+10)

name                old alloc/op   new alloc/op   delta
115/NewLineTable-8      384B ± 0%      384B ± 0%     ~     (all equal)
115/NewTable-8         164kB ± 0%     172kB ± 0%   +4.97%  (p=0.000 n=10+10)
115/LineToPC-8         0.00B          0.00B          ~     (all equal)
115/PCToLine-8         0.00B          0.00B          ~     (all equal)

name                old allocs/op  new allocs/op  delta
115/NewLineTable-8      3.00 ± 0%      3.00 ± 0%     ~     (all equal)
115/NewTable-8         1.04k ± 0%     0.01k ± 0%  -98.75%  (p=0.000 n=10+10)
115/LineToPC-8          0.00           0.00          ~     (all equal)
115/PCToLine-8          0.00           0.00          ~     (all equal)

Change-Id: Ibfe6c0cb86737dee8209cb1f58f5b796aa7b30aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/353134
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2 years agocmd/go: disallow profile flags when using -fuzz
Roland Shoemaker [Mon, 1 Nov 2021 17:28:52 +0000 (10:28 -0700)]
cmd/go: disallow profile flags when using -fuzz

Disallow the usage of coverprofile, blockprofile, cpuprofile, memprofile,
mutexprofile, and trace when fuzzing, since these currently do not work
as the user would expect.

Fixes #48178

Change-Id: Ibe6dfaef9b28a91c60c26fcad38c33a2a959d869
Reviewed-on: https://go-review.googlesource.com/c/go/+/360395
Trust: Roland Shoemaker <roland@golang.org>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

2 years agogo/types: add check that code is monomorphizable
Matthew Dempsky [Wed, 20 Oct 2021 20:17:07 +0000 (13:17 -0700)]
go/types: add check that code is monomorphizable

This CL adds a check to ensure that generic Go code doesn't involve
any unbounded recursive instantiation, which are incompatible with an
implementation that uses static instantiation (i.e., monomorphization
or compile-time dictionary construction).

Updates #48098.

Change-Id: I9d051f0f9369ab881592a361a5d0e2a716788a6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/357449
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>

2 years agocomd/compile/internal/types2: add missing nil check in const conversion
Robert Griesemer [Tue, 2 Nov 2021 17:14:29 +0000 (10:14 -0700)]
comd/compile/internal/types2: add missing nil check in const conversion

Follow-up on CL 360396.

Fixes #49296.

Change-Id: Ie08f86ae884da4cfd5db557cbf4f721a237dc39f
Reviewed-on: https://go-review.googlesource.com/c/go/+/360796
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agobytes: test for page boundary crosses on sep of Index
Paul E. Murphy [Tue, 19 Oct 2021 16:17:53 +0000 (11:17 -0500)]
bytes: test for page boundary crosses on sep of Index

Improve TestIndexNearPageBoundary to verify needles
ending on a page boundary don't cause a segfault.

Change-Id: I2edb13db63a71dc9955e266f6b97026ee13bf76e
Reviewed-on: https://go-review.googlesource.com/c/go/+/356889
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>

2 years agogo/types: generalize assignability to generic types
Robert Findley [Mon, 1 Nov 2021 19:11:31 +0000 (15:11 -0400)]
go/types: generalize assignability to generic types

This is a port of CL 357917 to go/types. Some error messages in
assignability.go2 had to be adjusted. I left a TODO to investigate
whether we should align error messages.

Change-Id: Ia323ffe18bc08e82de62044f35b8b0f3edd7dc08
Reviewed-on: https://go-review.googlesource.com/c/go/+/360476
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agogo/types: clarify is/underIs semantics and implementation
Robert Findley [Mon, 1 Nov 2021 19:03:53 +0000 (15:03 -0400)]
go/types: clarify is/underIs semantics and implementation

This is a port of CL 358594 to go/types. Some code in conversions.go had
to be trivially reorganized to align with types2 -- I'm not sure how
go/types diverged from the base.

Change-Id: I40ce247bbb3b9d0e87ce88c50e440c12774c0745
Reviewed-on: https://go-review.googlesource.com/c/go/+/360475
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agogo/types: better error messages for empty type sets
Robert Findley [Mon, 1 Nov 2021 18:46:35 +0000 (14:46 -0400)]
go/types: better error messages for empty type sets

This is a clean port of CL 358175 to go/types.

Change-Id: If1b4e51d1579fd168e651d79d031335ff09ca128
Reviewed-on: https://go-review.googlesource.com/c/go/+/360474
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agoruntime: check amd64 microarchitecture level at startup
vpachkov [Sun, 31 Oct 2021 11:06:27 +0000 (11:06 +0000)]
runtime: check amd64 microarchitecture level at startup

Make Go runtime throw if it's been compiled to assume instruction
set extensions that aren't available on the CPU.
Updates #48506

Change-Id: Ic4d6696e1cd6b28d389a86fe64e8175ea3ca135a
GitHub-Last-Rev: ba338377f549344b416fbd519576e95ce5d523be
GitHub-Pull-Request: golang/go#48514
Reviewed-on: https://go-review.googlesource.com/c/go/+/351191
Run-TryBot: Martin Möhrmann <martin@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <martin@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Martin Möhrmann <martin@golang.org>