]> Cypherpunks repositories - gostls13.git/log
gostls13.git
4 years agocmd/compile: remove now-redundant AuxCall.args
David Chase [Fri, 19 Mar 2021 19:21:14 +0000 (15:21 -0400)]
cmd/compile: remove now-redundant AuxCall.args

Cleanup, ABI information subsumes this.

Updates #40724

Change-Id: I6c69da44380f7b0d159b22acacbd68dc000e4725
Reviewed-on: https://go-review.googlesource.com/c/go/+/303432
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: fix WriteFuncMap for new ABI.
David Chase [Fri, 12 Mar 2021 18:37:24 +0000 (13:37 -0500)]
cmd/compile: fix WriteFuncMap for new ABI.

replaced old type-based logic with new abi-based logic;
earlier versions of this CL compared them for equality.
For not-in-a-register, they match everywhere tested.

also modified GetFrameOffset to make it more like the one it replaces;
the LocalsOffset is subtracted.

Change-Id: I65ce7f0646c493c277df6b6f46e4839a0d886ac9
Reviewed-on: https://go-review.googlesource.com/c/go/+/302072
Trust: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoos/exec: avoid flaky Wait in TestContextCancel
Shuhei Takahashi [Mon, 22 Mar 2021 04:35:49 +0000 (13:35 +0900)]
os/exec: avoid flaky Wait in TestContextCancel

This change just increases the timeout to 1 minute to avoid test
flakiness.

Fixes #42061

Change-Id: Id258488ee8f062cd5e68b68bb5cf11e15fdbb396
Reviewed-on: https://go-review.googlesource.com/c/go/+/303351
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Benny Siegert <bsiegert@gmail.com>

4 years agoruntime: fix bogus NtCurrentTeb()->TlsSlots[n] calculation on windows/arm64
Jason A. Donenfeld [Sat, 20 Mar 2021 02:19:33 +0000 (20:19 -0600)]
runtime: fix bogus NtCurrentTeb()->TlsSlots[n] calculation on windows/arm64

runtime.save_g adds X18 to runtime.tls_g in order to have a pointer to
thread local storage. X18 represents a pointer to the TEB on ARM64 and
runtime.tls_g is set in runtime.wintls at initialization time. This
function calls TlsAlloc to allocate a "TLS slot", which is supposed to
index into NtCurrentTeb()->TlsSlots. So the full calculation we want is:

    X18 + offsetof(TEB, TlsSlots) + 8*TlsAllocReturnValue

It makes sense to store the complete value of "offsetof(TEB,
TlsSlots) + TlsAllocReturnValue" into runtime.tls_g so that the
calculation can simplify to:

    X18 + runtime.tls_g

But, instead of computing that, we're currently doing something kind of
strange, in which we:

    - call TlsAlloc, which puts its return value into X0
    - make sure X0 is less than 64, so we don't overflow
    - set runtime.tls_g to 8*X1 + offsetof(TEB, TlsSlots)

The question is: why are we using X1 instead of X0? What is in X1?

Probably it was, by luck, zero before, and TlsAlloc returned zero, so
there was no problem. But on recent versions of Windows, X1 is some
other garbage value and not zero, so we eventually crash when trying to
dereference X18 + runtime.tls_g.

This commit fixes the problem by just computing:

   runtime.tls_g = 8*X0 + offsetof(TEB, TlsSlots)

Fixes #45138.

Change-Id: I560426bae7468217bd183ac6c6eb4b56a3815b09
Reviewed-on: https://go-review.googlesource.com/c/go/+/303273
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile/internal/ssa: correct sign extension for consts on riscv64
Joel Sing [Sat, 20 Mar 2021 13:58:18 +0000 (00:58 +1100)]
cmd/compile/internal/ssa: correct sign extension for consts on riscv64

Correct sign extension handling for consts on riscv64. This fixes a bug
in part exposed by CL 302609 - previously 64 bit consts were rewritten into
multiple 32 bit consts and the expansion would result in sign/zero extension
not being eliminated. With this change a MOVDconst with a 64 bit value can be
followed by a MOV{B,H,W}reg, which will be eliminated without actually
truncating to a smaller value.

Change-Id: I8d9cd380217466997b341e008a1f139bc11a0d51
Reviewed-on: https://go-review.googlesource.com/c/go/+/303350
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: disallow rewrite rules from declaring reserved names
Daniel Martí [Mon, 22 Mar 2021 10:35:02 +0000 (11:35 +0100)]
cmd/compile: disallow rewrite rules from declaring reserved names

If I change a rule in ARM64.rules to use the variable name "b" in a
conflicting way, rulegen would previously not complain, and the compiler
would later give a confusing error:

$ go run *.go && go build cmd/compile/internal/ssa
# cmd/compile/internal/ssa
../rewriteARM64.go:24236:10: b.NewValue0 undefined (type int64 has no field or method NewValue0)

Make rulegen complain early about those cases. Sometimes they might
happen to be harmless, but in general they can easily cause confusion or
unintended effect due to shadowing.

After the change, with the same conflicting rule:

$ go run *.go && go build cmd/compile/internal/ssa
2021/03/22 11:31:49 rule ARM64.rules:495 uses the reserved name b
exit status 1

Note that 24 existing rules were using reserved names. It seems like the
shadowing was harmless, as it wasn't causing typechecking issues nor did
it seem to cause unintended behavior when the rule rewrite code ran.

The bool values "b" were renamed "t", since that seems to have a
precedent in other rules and in the fmt package.

Sequential values like "a b c" were renamed to "x y z", since "b" is
reserved.

Finally, "typ" was renamed to "_typ", since there doesn't seem to be an
obviously better answer.

Passes all three of:

$ GOARCH=amd64 go build -toolexec 'toolstash -cmp' -a std
$ GOARCH=arm64 go build -toolexec 'toolstash -cmp' -a std
$ GOARCH=mips64 go build -toolexec 'toolstash -cmp' -a std

Fixes #45154.

Change-Id: I1cce194dc7b477886a9c218c17973e996bcedccf
Reviewed-on: https://go-review.googlesource.com/c/go/+/303549
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: make no-op rewrite funcs smaller
Daniel Martí [Thu, 31 Dec 2020 12:41:53 +0000 (12:41 +0000)]
cmd/compile: make no-op rewrite funcs smaller

This doesn't change any behavior, but should help the compiler realise
that these funcs really do nothing at all.

Change-Id: Ib26c02ef264691acac983538ec300f91d6ff98db
Reviewed-on: https://go-review.googlesource.com/c/go/+/280314
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/go/internal/modload: remove go116EnableNarrowAll constant
Bryan C. Mills [Fri, 19 Mar 2021 19:55:30 +0000 (15:55 -0400)]
cmd/go/internal/modload: remove go116EnableNarrowAll constant

This constant existed in case there was a serious problem with the
change to the "all" pattern in Go 1.16 (CL 240623), so that we could
roll back the change in behavior by just flipping the constant without
introducing merge conflicts elsewhere.

Go 1.16 has been out for a while and the new "all" behavior seems fine,
so we can jettison this feature flag.

For #36460

Change-Id: Ic2730edcee81514d56c7086e11542468eb63c84a
Reviewed-on: https://go-review.googlesource.com/c/go/+/303431
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd/internal/obj/arm64: mark functions with small stacks NOSPLIT
eric fang [Mon, 15 Mar 2021 06:55:37 +0000 (06:55 +0000)]
cmd/internal/obj/arm64: mark functions with small stacks NOSPLIT

This change omits the stack check on arm64 when the size of a stack
frame is less than obj.StackSmall.

The effect is not very significant, because CL 92040 has set the leaf
function with a framesize of 0 to NOFRAME, which makes the code
prologue on arm64 much closer to other architectures. But it is not
without effect, for example, it is effective for std library functions
such as runtime.usleep, fmt.isSpace, etc. Since this CL is very simple,
I think this optimization is worthwhile.

compilecmp results on linux/arm64:
name                      old time/op       new time/op       delta
Template                        284ms ± 1%        283ms ± 1%  -0.29%  (p=0.000 n=50+50)
Unicode                         125ms ± 2%        125ms ± 1%    ~     (p=0.445 n=49+49)
GoTypes                         1.70s ± 1%        1.69s ± 1%  -0.36%  (p=0.000 n=50+50)
Compiler                        124ms ± 1%        124ms ± 1%  -0.31%  (p=0.003 n=48+48)
SSA                             12.7s ± 1%        12.7s ± 1%    ~     (p=0.117 n=50+50)
Flate                           172ms ± 1%        171ms ± 1%  -0.55%  (p=0.000 n=50+50)
GoParser                        265ms ± 1%        264ms ± 1%  -0.23%  (p=0.000 n=47+48)
Reflect                         653ms ± 1%        646ms ± 1%  -1.12%  (p=0.000 n=48+50)
Tar                             246ms ± 1%        245ms ± 1%  -0.41%  (p=0.000 n=46+47)
XML                             328ms ± 1%        327ms ± 1%  -0.18%  (p=0.020 n=46+50)
LinkCompiler                    599ms ± 1%        598ms ± 1%    ~     (p=0.237 n=50+49)
ExternalLinkCompiler            1.87s ± 1%        1.87s ± 1%  -0.18%  (p=0.000 n=50+50)
LinkWithoutDebugCompiler        365ms ± 1%        364ms ± 2%    ~     (p=0.131 n=50+50)
[Geo mean]                      490ms             488ms       -0.32%

name                      old alloc/op      new alloc/op      delta
Template                       38.8MB ± 1%       38.8MB ± 1%  +0.16%  (p=0.013 n=47+49)
Unicode                        28.4MB ± 0%       28.4MB ± 0%    ~     (p=0.512 n=46+44)
GoTypes                         169MB ± 1%        169MB ± 1%    ~     (p=0.628 n=50+50)
Compiler                       23.2MB ± 1%       23.2MB ± 1%    ~     (p=0.424 n=46+44)
SSA                            1.55GB ± 0%       1.55GB ± 0%    ~     (p=0.603 n=48+50)
Flate                          23.7MB ± 1%       23.8MB ± 1%    ~     (p=0.797 n=50+50)
GoParser                       35.3MB ± 1%       35.3MB ± 1%    ~     (p=0.932 n=49+49)
Reflect                        85.0MB ± 0%       84.9MB ± 0%  -0.05%  (p=0.038 n=45+40)
Tar                            34.4MB ± 1%       34.5MB ± 1%    ~     (p=0.288 n=50+50)
XML                            43.8MB ± 2%       43.9MB ± 2%    ~     (p=0.798 n=46+49)
LinkCompiler                    136MB ± 0%        136MB ± 0%    ~     (p=0.750 n=50+50)
ExternalLinkCompiler            127MB ± 0%        127MB ± 0%    ~     (p=0.852 n=50+50)
LinkWithoutDebugCompiler       84.1MB ± 0%       84.1MB ± 0%    ~     (p=0.890 n=50+50)
[Geo mean]                     70.4MB            70.4MB       +0.01%

file      before    after     Δ       %
addr2line 4006004   4006012   +8      +0.000%
asm       4936863   4936919   +56     +0.001%
buildid   2594947   2594859   -88     -0.003%
cgo       4399702   4399806   +104    +0.002%
compile   22233139  22233107  -32     -0.000%
cover     4443681   4443785   +104    +0.002%
dist      3365902   3365806   -96     -0.003%
doc       3776175   3776231   +56     +0.001%
fix       3218624   3218552   -72     -0.002%
nm        3923345   3923329   -16     -0.000%
objdump   4295473   4295673   +200    +0.005%
pack      2390561   2390497   -64     -0.003%
pprof     12866419  12866275  -144    -0.001%
test2json 2587113   2587129   +16     +0.001%
trace     9609814   9609710   -104    -0.001%
vet       6790272   6791048   +776    +0.011%
total     106832751 106833455 +704    +0.001%

Updates #13379 (for arm64)

Change-Id: I07664ab0b978c66c0b18b8482222e9ba3772290d
Reviewed-on: https://go-review.googlesource.com/c/go/+/302853
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: eric fang <eric.fang@arm.com>
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoruntime: fix stack alignment for Windows amd64 lib entry
Youfu Zhang [Tue, 23 Feb 2021 03:52:43 +0000 (03:52 +0000)]
runtime: fix stack alignment for Windows amd64 lib entry

Windows amd64 calling convention requires 16-bytes aligned
stack pointer. Before this patch, the real frame size is
0x48 (frame size) + 0x10 (frame pointer & return address),
which does not satisfy the alignment requirement.

_cgo_sys_thread_create eventually calls NtCreateThread,
which receives a pointer to a ThreadContext structure
allocated from (mis-aligned) stack, and may fail with
STATUS_DATATYPE_MISALIGNMENT on some implementations.

BP is saved/restored by prolog/epilog.
AX, CX, DX are volatile, no need to save and restore.

Fixes #41075

Change-Id: I01c0a22b4bf3b4cfdebf4df587445aa46c667973
GitHub-Last-Rev: 15d2bd740e3e61c9753b3e1b574fdb5da538459c
GitHub-Pull-Request: golang/go#44524
Reviewed-on: https://go-review.googlesource.com/c/go/+/295329
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Christopher Nelson <nadiasvertex@gmail.com>
4 years agocmd/compile: add clobberdeadreg mode
Cherry Zhang [Wed, 17 Mar 2021 23:15:38 +0000 (19:15 -0400)]
cmd/compile: add clobberdeadreg mode

When -clobberdeadreg flag is set, the compiler inserts code that
clobbers integer registers at call sites. This may be helpful for
debugging register ABI.

Only implemented on AMD64 for now.

Change-Id: Ia203d3f891c30fd95d0103489056fe01d63a2899
Reviewed-on: https://go-review.googlesource.com/c/go/+/302809
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agomake.bash: this change modifies Go to correctly select a dyamic linker
Dilyn Corner [Fri, 19 Mar 2021 18:18:18 +0000 (18:18 +0000)]
make.bash: this change modifies Go to correctly select a dyamic linker

Alpine Linux is not the only musl-based Linux distribution. Checking for
/etc/alpine-release excludes many other distributions (Oasis, KISS,
Sabotage, sta.li). Not having the correct GO_LDSO set during go builds will
result in the wrong linker/loader on nonalpine musl systems for pie builds.
Instead, the dynamic loader should be checked for every system and set. This
results in the correct dynamic linker being found on glibc systems
(/lib/ld-linux-x86-64.so.2) and musl systems (/lib/ld-musl-x84_64.so.1).

Fixes #45034

Change-Id: I4c9389abc759aa34431dc6c781022636b81d6910
GitHub-Last-Rev: e17b9eb10693bfce7c9ce03af3b15bd0e56e8dbe
GitHub-Pull-Request: golang/go#45036
Reviewed-on: https://go-review.googlesource.com/c/go/+/301989
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Zhang <cherryyz@google.com>

4 years agocmd/go: assume Go 1.16 instead of Go 1.11 for dependencies that lack explicit 'go...
Bryan C. Mills [Fri, 19 Mar 2021 01:01:37 +0000 (21:01 -0400)]
cmd/go: assume Go 1.16 instead of Go 1.11 for dependencies that lack explicit 'go' directives

Fixes #45109
Updates #44976
Updates #36876

Change-Id: Icb00f8b6e0d4e076d82da1697e7058b9e7603916
Reviewed-on: https://go-review.googlesource.com/c/go/+/303229
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agotesting: allow parallel-subtest goroutines to exit when the subtest is complete
Bryan C. Mills [Fri, 19 Mar 2021 15:48:22 +0000 (11:48 -0400)]
testing: allow parallel-subtest goroutines to exit when the subtest is complete

Fixes #45127
Updates #38768

Change-Id: I7f41901d5bcc07741ac9f5f2a24d2b07ef633cb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/303330
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>
4 years agosyscall: fix typo in exec_windows_test.go
Antonio Garcia [Fri, 19 Mar 2021 15:29:09 +0000 (15:29 +0000)]
syscall: fix typo in exec_windows_test.go

nothign -> nothing

Change-Id: I3f5cf20cc094d280f6cafa179eaefd745874dec1
GitHub-Last-Rev: a4cf42f27574ab8567d0f45bcd4dfbe018587214
GitHub-Pull-Request: golang/go#45118
Reviewed-on: https://go-review.googlesource.com/c/go/+/303269
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoruntime: mark Windows' address-taken asm routines as ABIInternal
Michael Anthony Knyszek [Mon, 15 Mar 2021 21:48:58 +0000 (21:48 +0000)]
runtime: mark Windows' address-taken asm routines as ABIInternal

In the runtime there are Windows-specific assembly routines that are
address-taken via funcPC and are not intended to be called through a
wrapper. Mark them as ABIInternal so that we don't grab the wrapper,
because that will break in all sorts of contexts.

For #40724.
For #44065.

Change-Id: I12a728786786f423e5b229f8622e4a80ec27a31c
Reviewed-on: https://go-review.googlesource.com/c/go/+/302109
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: call nanotimeQPC from nanotime1 without a wrapper
Michael Anthony Knyszek [Thu, 18 Mar 2021 16:01:23 +0000 (16:01 +0000)]
runtime: call nanotimeQPC from nanotime1 without a wrapper

This changes makes it so that nanotimeQPC calls nanotime1 without an ABI
wrapper by specifying the ABIInternal version directly. The reason why
this is necessary is because ABI wrappers typically require additional
stack space, and nanotimeQPC is used deep within nosplit contexts,
and with the ABI wrappers now enabled, this exhausts the stack guard
space held for nosplit functions. Rather than increase the stack guard,
we choose to do this.

For #40724.

Change-Id: Ia9173ca903335a9d6f380f57f4a45e49b58da6bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/303069
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agonet/http: make ExampleGet show StatusCode checks for non-1XX,2XX responses
Emmanuel T Odeke [Sun, 7 Mar 2021 22:56:52 +0000 (14:56 -0800)]
net/http: make ExampleGet show StatusCode checks for non-1XX,2XX responses

Updates ExampleGet to show how to handle bad responses with non-1XX,2XX
status codes. Given that the canonical examples are copied, we need
to have them properly check against failures. This is a bug I've seen
often in the wild, that's exacerbated when for example unmarshalling
JSON or even protobufs, and no errors are returned by the decoders,
so code fails silently after making a request for example to a gateway
that they were unauthorized to access.

Fixes #39778

Change-Id: I1cd688f2fab47581c8cf228235d3662b4c8e4315
Reviewed-on: https://go-review.googlesource.com/c/go/+/299609
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
4 years agonet/http: mention NewRequestWithContext+Client.Do for custom contexts
Emmanuel T Odeke [Sun, 7 Mar 2021 23:30:47 +0000 (15:30 -0800)]
net/http: mention NewRequestWithContext+Client.Do for custom contexts

Adds mentions of NewRequestWithContext and *Client.Do as prescriptions
for how to use a specified context.Context, to the docs of:
* (*Client).Get
* (*Client).Head
* (*Client).Post
* (*Client).PostForm
* Get
* Head
* Post
* PostForm

given that we can't remove those convenience functions, nor
change the method signatures, except for Go2.

Fixes #35562

Change-Id: I4859e6757e7f958c9067ac4ef15881cfba7d1f8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/299610
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
4 years agocmd/internal/obj/ppc64: consolidate memory classifications
Paul E. Murphy [Tue, 9 Mar 2021 22:55:03 +0000 (16:55 -0600)]
cmd/internal/obj/ppc64: consolidate memory classifications

Several classifications exist only to help disambiguate an
implied register (i.e $0/R0 as the implied second register
argument when loading constants, or pseudo-registers used
exclusively by the assembler front-end).

The register determination is folded into getimpliedreg. The
classifications and their related optab entries are removed
or updated.

Change-Id: Iffb167aa9fa57fbc1a537c79fbdfb36cb38f9d95
Reviewed-on: https://go-review.googlesource.com/c/go/+/301789
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Zhang <cherryyz@google.com>

4 years agocmd/doc: properly display interface methods
Agniva De Sarker [Thu, 17 Dec 2020 07:13:19 +0000 (12:43 +0530)]
cmd/doc: properly display interface methods

Previously, we used to call doc.ToText to print each comment
in a comment group attached to an interface method. This broke any
preformatted code block attached to the comment, and displayed everything
aligned to a single column. Additionally, the name of the interface
also wasn't displayed which didn't show which interface
the method belonged to.

To fix this, we print the entire interface node using format.Node
which takes care of displaying the comments correctly, and we also
filter out the methods that don't match, so that the method can be
displayed as belonging to an interface.

As an example, previously it would show:

// Comment before exported method.
//
// // Code block showing how to use ExportedMethod
// func DoSomething() error {
// ExportedMethod()
// return nil
// }
func ExportedMethod()  // Comment on line with exported method.

Now, it shows:

type ExportedInterface interface {
// Comment before exported method.
//
// // Code block showing how to use ExportedMethod
// func DoSomething() error {
// ExportedMethod()
// return nil
// }
ExportedMethod() // Comment on line with exported method.

}

Fixes #43188

Change-Id: I28099fe4aab35e08049b2616a3506240f57133cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/279433
Trust: Agniva De Sarker <agniva.quicksilver@gmail.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Rob Pike <r@golang.org>
4 years agocmd/asm: complete the support for VDUP on arm64
fanzha02 [Fri, 4 Dec 2020 06:02:55 +0000 (14:02 +0800)]
cmd/asm: complete the support for VDUP on arm64

"VMOV Vn.<T>[index], Vn" is equivalent to "VDUP Vn.<T>[index], Vn", and
the latter has a higher priority in the disassembler than the former.
But the assembler doesn't support to encode this combination of VDUP,
this leads to an inconsistency between assembler and disassembler.

For example, if we assemble "VMOV V20.S[0], V20" to hex then decode it,
we'll get "VDUP V20.S[0], V20".

  VMOV V20.S[0], V20 -> 9406045e -> VDUP V20.S[0], V20 -> error

But we cannot assemble this VDUP again.

Similar reason for "VDUP Rn, Vd.<T>". This CL completes the support for
VDUP.

This patch is a copy of CL 276092. Co-authored-by: JunchenLi
<junchen.li@arm.com>

Change-Id: I8f8d86cf1911d5b16bb40d189f1dc34b24416aaf
Reviewed-on: https://go-review.googlesource.com/c/go/+/302929
Trust: fannie zhang <Fannie.Zhang@arm.com>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agotesting: update helperNames just before checking it
Tao Qingyun [Thu, 18 Mar 2021 00:10:38 +0000 (00:10 +0000)]
testing: update helperNames just before checking it

parent's helperNames has not been set when frameSkip called, moving
helperNames initilazing to frameSkip.

Fixes #44887

Change-Id: I5107c5951033e5e47d1ac441eac3ba5344a7bdc0
GitHub-Last-Rev: 44b90b2e2eeca8e2bb4a2084ec6fdd279c88f76d
GitHub-Pull-Request: golang/go#45071
Reviewed-on: https://go-review.googlesource.com/c/go/+/302469
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoio/ioutil: use correct Go version in redirection comments
Ian Lance Taylor [Thu, 18 Mar 2021 01:02:26 +0000 (18:02 -0700)]
io/ioutil: use correct Go version in redirection comments

Change-Id: I282f428137ca3360a58167c94e26f3dfdf59fb63
Reviewed-on: https://go-review.googlesource.com/c/go/+/302756
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
4 years agocmd/compile: get untyped constants working in generic functions
Dan Scales [Thu, 18 Mar 2021 18:56:46 +0000 (11:56 -0700)]
cmd/compile: get untyped constants working in generic functions

types2 will give us a constant with a type T, if an untyped constant is
used with another operand of type T (in a provably correct way). When we
substitute in the type args during stenciling, we now know the real type
of the constant. We may then need to change the BasicLit.val to be the
correct type (e.g. convert an int64Val constant to a floatVal constant).
Otherwise, later parts of the compiler will be confused.

Updated tests list.go and double.go with uses of untyped constants.

Change-Id: I9966bbb0dea3a7de1c5a6420f8ad8af9ca84a33e
Reviewed-on: https://go-review.googlesource.com/c/go/+/303089
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/internal/objabi,runtime: simplify sys.GOEXPERIMENT parsing
Austin Clements [Wed, 17 Mar 2021 16:22:58 +0000 (12:22 -0400)]
cmd/internal/objabi,runtime: simplify sys.GOEXPERIMENT parsing

Previously, the runtime had to understand the full syntax of the
GOEXPERIMENT environment variable. Now, sys.GOEXPERIMENT is the
pre-processed experiment list produced by objabi, so we can simplify
the runtime parser.

Change-Id: I0d113a4347dde50a35b8b1f2b0110c88fe802921
Reviewed-on: https://go-review.googlesource.com/c/go/+/303049
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd: move experiment flags into objabi.Experiment
Austin Clements [Tue, 16 Mar 2021 21:06:25 +0000 (17:06 -0400)]
cmd: move experiment flags into objabi.Experiment

This moves all remaining GOEXPERIMENT flags into the objabi.Experiment
struct, drops the "_enabled" from their name, and makes them all bool
typed.

We also drop DebugFlags.Fieldtrack because the previous CL shifted the
one test that used it to use GOEXPERIMENT instead.

Change-Id: I3406fe62b1c300bb4caeaffa6ca5ce56a70497fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/302389
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agotest: switch fieldtrack test to use GOEXPERIMENT
Austin Clements [Thu, 18 Mar 2021 15:35:45 +0000 (11:35 -0400)]
test: switch fieldtrack test to use GOEXPERIMENT

Now that we can set GOEXPERIMENT at build time, we no longer need
-d=fieldtrack in the compiler to enabled field tracking at build time.
Switch the one test that uses -d=fieldtrack to use GOEXPERIMENT
instead so we can eliminate this debug flag and centralize on
GOEXPERIMENT.

Updates #42681.

Change-Id: I14c352c9a97187b9c5ec8027ff672d685f22f543
Reviewed-on: https://go-review.googlesource.com/c/go/+/302969
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agoreflect: add tests for reflect.Value.Call for the new ABI
Michael Anthony Knyszek [Fri, 5 Mar 2021 19:47:34 +0000 (19:47 +0000)]
reflect: add tests for reflect.Value.Call for the new ABI

This change adds tests for reflect.Value.Call for calling functions
using the new register-based ABI.

For #40724.

Change-Id: Ia9afd43e26dd80c7e36dd135a5b71acce8074801
Reviewed-on: https://go-review.googlesource.com/c/go/+/299269
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime/pprof: move common code to writeProfileInternal function
Elvina Yakubova [Thu, 24 Dec 2020 19:38:06 +0000 (22:38 +0300)]
runtime/pprof: move common code to writeProfileInternal function

This patch provides changes according to TODO. Since writeMutex and
writeBlock functions have a lot of code in common, it is better to
move this code to one function.

Change-Id: I81aaad067b0cb1647824909f3b5f6861add3a7ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/280152
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>

4 years agocmd/link: Add section data slice to Archrelocvariant
Paul E. Murphy [Wed, 10 Mar 2021 21:10:05 +0000 (15:10 -0600)]
cmd/link: Add section data slice to Archrelocvariant

PPC64 needs to preserve bits when applying some relocations. DS form
relocations must preserve the lower two bits, and thus needs to inspect
the section data as it streams out.

Similarly, the overflow checking requires inspecting the primary
opcode to see if the value is sign or zero extended.

The existing PPC64 code no longer works as the slice returned by
(loader*).Data is cleared as we layout the symbol and process
relocations.  This data is always the section undergoing relocation,
thus we can directly inspect the contents to preserve bits or
check for overflows.

Change-Id: I239211f7e5e96208673663b6553b3017adae7e01
Reviewed-on: https://go-review.googlesource.com/c/go/+/300555
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agogo/types: minor simplification in assignableTo (cleanup)
Robert Griesemer [Thu, 18 Mar 2021 05:44:16 +0000 (22:44 -0700)]
go/types: minor simplification in assignableTo (cleanup)

Also, clarify doc string.

Change-Id: If1c5f8e29e2c2080dd899ef76196e97b7b992389
Reviewed-on: https://go-review.googlesource.com/c/go/+/302758
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile: remove unneeded calls to typecheck in noder2
Dan Scales [Thu, 18 Mar 2021 00:54:41 +0000 (17:54 -0700)]
cmd/compile: remove unneeded calls to typecheck in noder2

Remove unneeded calls to typecheck in noder2 associated with g.use() and
g.obj(). These routines are already setting the types2-derived type
correctly for ONAME nodes, and there is no typechecker1-related
transformations related to ONAME nodes, other than making sure that
newly created closure variables have their type set.

Tested through normal -G=3 testing in all.bash (all of go/tests).

Change-Id: I1b790ab9948959685fca3a768401458201833671
Reviewed-on: https://go-review.googlesource.com/c/go/+/303029
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>

4 years agoall: explode GOEXPERIMENT=regabi into 5 sub-experiments
Austin Clements [Mon, 15 Mar 2021 20:48:54 +0000 (16:48 -0400)]
all: explode GOEXPERIMENT=regabi into 5 sub-experiments

This separates GOEXPERIMENT=regabi into five sub-experiments:
regabiwrappers, regabig, regabireflect, regabidefer, and regabiargs.
Setting GOEXPERIMENT=regabi now implies the working subset of these
(currently, regabiwrappers, regabig, and regabireflect).

This simplifies testing, helps derisk the register ABI project,
and will also help with performance comparisons.

This replaces the -abiwrap flag to the compiler and linker with
the regabiwrappers experiment.

As part of this, regabiargs now enables registers for all calls
in the compiler. Previously, this was statically disabled in
regabiEnabledForAllCompilation, but now that we can control it
independently, this isn't necessary.

For #40724.

Change-Id: I5171e60cda6789031f2ef034cc2e7c5d62459122
Reviewed-on: https://go-review.googlesource.com/c/go/+/302070
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
4 years agotest: make nosplit test invariant to ABI wrappers
Austin Clements [Wed, 17 Mar 2021 22:28:38 +0000 (18:28 -0400)]
test: make nosplit test invariant to ABI wrappers

Currently, the nosplit test disables ABI wrapper generation because it
generates a main.main in assembly, and so the ABI wrapper for calling
from runtime.main to main.main counts against the nosplit limit, which
cases some of the tests to fail.

Fix this by first entering ABI0 in a splittable context and then
calling from there into the test entry point, since this doesn't
introduce an ABI wrapper.

While we're here, this CL removes the test's check for the
framepointer experiment. That's now statically enabled, so it doesn't
appear in the experiment line, and enabling any other experiment
causes the test to think that the framepointer experiment *isn't*
enabled.

For #40724.

Change-Id: I6291eb9391f129779e726c5fc8c41b7b4a14eeb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/302772
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/internal/objabi: support boolean GOEXPERIMENTs
Austin Clements [Mon, 15 Mar 2021 20:23:21 +0000 (16:23 -0400)]
cmd/internal/objabi: support boolean GOEXPERIMENTs

Currently, objabi exports GOEXPERIMENT flags as ints that are either 0
or 1. Since the dawn of time, there's been a comment saying that we
*could* support general integers here, but it's never happened and all
the "== 0" and "!= 0" and "== 1" are driving me crazy and are making
the code harder to read and maintain. Hence, this CL adds support for
boolean GOEXPERIMENT flags. We'll introduce some bool-typed flags in
the next CL.

Change-Id: I7813400db130a9b8f71a644fe7912808dbe645bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/302069
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/dist: build bootstrap without GOEXPERIMENT
Austin Clements [Mon, 15 Mar 2021 19:53:21 +0000 (15:53 -0400)]
cmd/dist: build bootstrap without GOEXPERIMENT

Currently, dist attempts to build the bootstrap with the GOEXPERIMENT
set in the environment. However, the logic is incomplete and notably
requires a hack to enable the appropriate build tags for
GOEXPERIMENT=regabi. Without this hack, the build becomes skewed
between a compiler that uses regabi and a runtime that doesn't when
building toolchain2.

We could try to improve the GOEXPERIMENT processing in cmd/dist, but
it will always chase cmd/internal/objabi and it's quite difficult to
share the logic with objabi because of the constraints on building
cmd/dist.

Instead, we switch to building go_bootstrap without any GOEXPERIMENT
and only start using GOEXPERIMENT once we have a working, modern
cmd/go (which has all the GOEXPERIMENT logic in it). We also build
toolchain1 without any GOEXPERIMENT set, in case the bootstrap
toolchain is recent enough to understand build-time GOEXPERIMENT
settings.

As part of this, we make GOEXPERIMENT=none mean "no experiments". This
is necessary since, now that we support setting GOEXPERIMENT at build
time, we need an explicit way to say "ignore all baked-in experiments".

For #40724.

Change-Id: I115399579b766a7a8b2f352f7e5efea5305666cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/302050
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/internal/objabi: centralize GOEXPERIMENT parsing
Austin Clements [Mon, 15 Mar 2021 19:43:45 +0000 (15:43 -0400)]
cmd/internal/objabi: centralize GOEXPERIMENT parsing

objabi parses GOEXPERIMENT, but most of the consumers look at the raw
GOEXPERIMENT string that objabi gets from the environment. Centralize
this logic by only exposing the parsed GOEXPERIMENT value from objabi.
This sets us up for the next few changes. It also has the nice but
mostly useless property that the order of experiment names will be
canonicalized in build cache hashes.

After this, the only remaining place that looks at raw GOEXPERIMENT is
cmd/dist, which we'll fix in the next CL.

For #40724.

Change-Id: Idb150f848e17c184fae91372ca8b361591472f51
Reviewed-on: https://go-review.googlesource.com/c/go/+/302049
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/go: remove renameio package and its last usage
Michael Matloob [Mon, 15 Mar 2021 17:59:24 +0000 (13:59 -0400)]
cmd/go: remove renameio package and its last usage

The last primary usage of renameio was the WriteFile in
modfetch.WriteDiskCache. Because it's not guaranteed that the fsync in
WriteDiskCache will eliminate file corruption, and it slows down tests
on Macs significantly, inline that last usage, removing the fsync.

Also, remove the uses of renameio.Pattern. The ziphash file is no
longer written to a temporary location before being copied to its
final location, so that usage can just be cut. The remaining use is
for the zipfile . Remove the first because the files are no longer
written using the pattern anyway, so that the pattern variable has no
effect. Replace it with a local pattern variable that is also passed
to os.CreateTemp.

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

4 years agocmd/go: suppress errors for 'go get' of module paths that are also constrained-out...
Bryan C. Mills [Fri, 26 Feb 2021 18:28:23 +0000 (13:28 -0500)]
cmd/go: suppress errors for 'go get' of module paths that are also constrained-out packages

Fixes #33526

Change-Id: Iedd2d6dbe440499bf074ac632513319a22f2d648
Reviewed-on: https://go-review.googlesource.com/c/go/+/297009
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/go: use the global rooted path name
Andy Pan [Thu, 18 Mar 2021 02:45:04 +0000 (10:45 +0800)]
cmd/go: use the global rooted path name

Change-Id: I4a450af5f35f0ad4e4652789f1eda4d3171610e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/302852
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>

4 years agocmd/link: print symbol versions in stack bound check
Cherry Zhang [Thu, 18 Mar 2021 03:55:07 +0000 (23:55 -0400)]
cmd/link: print symbol versions in stack bound check

When the stack bound check fails, print the call chain with
symbol versions (along with the names). Now that we have ABI
wrappers and wrappers do consume stack space, it is clearer to
distinguish the wrappers vs. the underlying functions.

Change-Id: Id1d922e3e7934b31317f233aff3d9667b6ac90c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/302869
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocrypto/rsa: correct EncryptOAEP doc comment
Richard Pickering [Mon, 15 Mar 2021 18:16:05 +0000 (18:16 +0000)]
crypto/rsa: correct EncryptOAEP doc comment

Fixes #44777

Corrected the documentation comment on the EncryptOAEP function from
'if a given public key is used to decrypt two types of messages' to
'if a given public key is used to encrypt two types of messages'.

Change-Id: I02aff90d0414960eae72352c0e4d8ba2e8f8eca6
GitHub-Last-Rev: ea28663f8719e8fd0dcb10cf97ffbdcf4bd9674f
GitHub-Pull-Request: golang/go#45032
Reviewed-on: https://go-review.googlesource.com/c/go/+/301714
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>

4 years agosort: add example tests for SearchFloat64s and SearchInts
Rabin Gaire [Sun, 6 Dec 2020 17:32:20 +0000 (23:17 +0545)]
sort: add example tests for SearchFloat64s and SearchInts

Change-Id: I5fa4773467e3f515250deead72fdce3e4bd0973b
Reviewed-on: https://go-review.googlesource.com/c/go/+/275457
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Griesemer <gri@golang.org>

4 years agocmd/compile,cmd/internal/obj/riscv: load >32-bit constants from memory for riscv64
Joel Sing [Wed, 17 Mar 2021 16:32:32 +0000 (03:32 +1100)]
cmd/compile,cmd/internal/obj/riscv: load >32-bit constants from memory for riscv64

Follow what MIPS does and load >32-bit constants from memory using two instructions,
rather than generating a four to six instruction sequence. This removes more than 2,500
instructions from the Go binary. This also makes it possible to load >32-bit constants
via a single assembly instruction, if required.

Change-Id: Ie679a0754071e6d8c52fe0d027f00eb241b3a758
Reviewed-on: https://go-review.googlesource.com/c/go/+/302609
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: actually intrinsify runtime/internal/atomic.{And,Or}{8,} on RISCV64
Joel Sing [Tue, 16 Mar 2021 14:39:11 +0000 (01:39 +1100)]
cmd/compile: actually intrinsify runtime/internal/atomic.{And,Or}{8,} on RISCV64

Actually enable intrinsics for runtime/internal/atomic.{And,Or}{8,} on RISCV64.
This seems to have been lost when CL 268098 was rebased.

Change-Id: If072daa79c8964b186c127d5e065a7cc9e23ba27
Reviewed-on: https://go-review.googlesource.com/c/go/+/302229
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: use a single const MOV operand for riscv64
Joel Sing [Wed, 17 Mar 2021 16:37:58 +0000 (03:37 +1100)]
cmd/compile: use a single const MOV operand for riscv64

Most platforms only use a single MOV const operand - remove the MOV{B,H,W}const
operands from riscv64 and consistently use MOVDconst instead. The implementation
of all four is the same and there is no benefit gained from having multiple const
operands (in fact it requires a lot more rewrite rules).

Change-Id: I0ba7d7554e371a1de762ef5f3745e9c0c30d41ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/302610
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/compile: add rewrite rules for conditional instructions on arm64
fanzha02 [Mon, 18 Jan 2021 06:32:49 +0000 (14:32 +0800)]
cmd/compile: add rewrite rules for conditional instructions on arm64

This CL adds rewrite rules for CSETM, CSINC, CSINV, and CSNEG. By adding
these rules, we can save one instruction.

For example,

  func test(cond bool, a int) int {
    if cond {
      a++
    }
    return a
  }

Before:

  MOVD "".a+8(RSP), R0
  ADD $1, R0, R1
  MOVBU "".cond(RSP), R2
  CMPW $0, R2
  CSEL NE, R1, R0, R0

After:

  MOVBU "".cond(RSP), R0
  CMPW $0, R0
  MOVD "".a+8(RSP), R0
  CSINC EQ, R0, R0, R0

This patch is a copy of CL 285694. Co-authored-by: JunchenLi
<junchen.li@arm.com>

Change-Id: Ic1a79e8b8ece409b533becfcb7950f11e7b76f24
Reviewed-on: https://go-review.googlesource.com/c/go/+/302231
Trust: fannie zhang <Fannie.Zhang@arm.com>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile/internal/types2: delay recording types of untyped operands when checking...
Robert Griesemer [Wed, 17 Mar 2021 23:59:47 +0000 (16:59 -0700)]
cmd/compile/internal/types2: delay recording types of untyped operands when checking against type parameters

Don't eagerly record the target type for an untyped operand if the
target type is just one of possibly many types in the type list of
a type parameter. Instead, record expression type only after we
checked that all types in the type list are ok.

Also, update assertion in Checker.recordTypeAndValue since (currently),
a type parameter is not considered a const type. We may change that,
eventually.

This is a temporary (but working) solution. Eventually we should
copy the approach taken in go/types.

Fixes #45096.

Change-Id: Icf61ee893aca6ead32bfc45ee5831572e672357b
Reviewed-on: https://go-review.googlesource.com/c/go/+/302755
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agogo/types: add test case for issue #45096
Robert Griesemer [Wed, 17 Mar 2021 23:49:02 +0000 (16:49 -0700)]
go/types: add test case for issue #45096

This verifies that issue #45096 is not an issue for go/types.

Updates #45096.

Change-Id: I4e987b5d4928f0c864d0d2c0379149443beb4d5c
Reviewed-on: https://go-review.googlesource.com/c/go/+/302754
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocrypto/rand, internal/syscall/unix: add support for getentropy syscall on darwin
Tobias Klauser [Wed, 17 Mar 2021 10:17:02 +0000 (11:17 +0100)]
crypto/rand, internal/syscall/unix: add support for getentropy syscall on darwin

The getentropy syscall is available on macOS since version 10.12, which
is the minimum required version since Go 1.15.

Change-Id: I294259af0b11df9669e4dc5fa891d2f2f039d91a
Reviewed-on: https://go-review.googlesource.com/c/go/+/302489
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/link: improve nonexistent package error message
Ian Lance Taylor [Wed, 17 Mar 2021 21:15:28 +0000 (14:15 -0700)]
cmd/link: improve nonexistent package error message

Change-Id: I207541efa6a34bc21e7a00584376622b59e2bf6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/302749
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/go: only add a 'go' directive to the main module when the go.mod file will be...
Bryan C. Mills [Mon, 15 Mar 2021 16:40:34 +0000 (12:40 -0400)]
cmd/go: only add a 'go' directive to the main module when the go.mod file will be written

Then, write the 'go.mod' file with that version before further
processing. That way, if the command errors out due to a change in
behavior, the reason for the change in behavior will be visible in the
file diffs.

If the 'go.mod' file cannot be written (due to -mod=readonly or
-mod=vendor), assume Go 1.11 instead of the current Go release.
(cmd/go has added 'go' directives automatically, including in 'go mod
init', since Go 1.12.)

For #44976

Change-Id: If9d4af557366f134f40ce4c5638688ba3bab8380
Reviewed-on: https://go-review.googlesource.com/c/go/+/302051
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd/cgo: check whether C compiler exists
Andrey Bokhanko [Fri, 12 Mar 2021 16:21:18 +0000 (00:21 +0800)]
cmd/cgo: check whether C compiler exists

Currently we print a cryptic message if a C compiler doesn't exist.
This patch adds more graceful handling.

Fixes #44271

Change-Id: I44f16ef6eb2853fee22fa1d996e41ec6c9ee82f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/301249
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agotime: check int64 overflow in Time.addSec
Andy Pan [Fri, 12 Mar 2021 11:40:46 +0000 (19:40 +0800)]
time: check int64 overflow in Time.addSec

Change-Id: Ibbed54239228e7ea31ef5978d427425899c3b943
Reviewed-on: https://go-review.googlesource.com/c/go/+/300890
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Baokun Lee <bk@golangcn.org>

4 years agotest: add bug that failed when run with gccgo
Ian Lance Taylor [Wed, 17 Mar 2021 04:24:09 +0000 (21:24 -0700)]
test: add bug that failed when run with gccgo

Change-Id: Ie52d70d2ae8a21acacf0745a4093650b03ac43f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/302371
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: resurrect clobberdead mode
Cherry Zhang [Fri, 12 Mar 2021 23:38:02 +0000 (18:38 -0500)]
cmd/compile: resurrect clobberdead mode

This CL resurrects the clobberdead debugging mode (CL 23924).
When -clobberdead flag is set (TODO: make it GOEXPERIMENT?), the
compiler inserts code that clobbers all dead stack slots that
contains pointers.

Mark windows syscall functions cgo_unsafe_args, as the code
actually does that, by taking the address of one argument and
passing it to cgocall.

Change-Id: Ie09a015f4bd14ae6053cc707866e30ae509b9d6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/301791
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agogo/parser: avoid formatting a panic message if an assertion succeeds
Rob Findley [Wed, 17 Mar 2021 16:42:19 +0000 (12:42 -0400)]
go/parser: avoid formatting a panic message if an assertion succeeds

tryResolve is an extremely hot method on the parser. Eliminating this
formatting led to a 20% performance improvement in BenchmarkParse.

Change-Id: Idf8850404bd72d45d1351356427a85086422ea68
Reviewed-on: https://go-review.googlesource.com/c/go/+/302629
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/compile: getting more built-ins to work with generics
Dan Scales [Fri, 12 Mar 2021 19:36:02 +0000 (11:36 -0800)]
cmd/compile:  getting more built-ins to work with generics

For Builtin ops, we currently stay with using the old
typechecker to transform the call to a more specific expression
and possibly use more specific ops. However, for a bunch of the
ops, we delay calling the old typechecker if any of the args have
type params, for a variety of reasons.

In the near future, we will start creating separate functions that do
the same transformations as the old typechecker for calls, builtins,
indexing, comparisons, etc. These functions can then be called at noder
time for nodes with no type params, and at stenciling time for nodes
with type params.

Remove unnecessary calls to types1 typechecker for most kinds of
statements (still need it for SendStmt, AssignStmt, ReturnStmt, and
SelectStmt). In particular, we don't need it for RangeStmt, and this
avoids some complaints by the types1 typechecker on generic code.

Other small changes:
 - Fix check on whether to delay calling types1-typechecker on type
   conversions. Should check if HasTParam is true, rather than if the
   type is directly a TYPEPARAM.

 - Don't call types1-typechecker on an indexing operation if the left
   operand has a typeparam in its type and is not obviously a TMAP,
   TSLICE, or TARRAY. As above, we will eventually have to create a new
   function that can do the required transformations (for complicated
   cases) at noder time or stenciling time.

 - Copy n.BuiltinOp in subster.node()

 - The complex arithmetic example in absdiff.go now works.

 - Added new tests double.go and append.go

 - Added new example with a new() call in settable.go

Change-Id: I8f377afb6126cab1826bd3c2732aa8cdf1f7e0b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/301951
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocrypto/tls: remove flaky cancellation test
Johan Brandhorst [Wed, 17 Mar 2021 14:13:35 +0000 (14:13 +0000)]
crypto/tls: remove flaky cancellation test

This will be reintroduced again once the source of the
flakiness has been determined and fixed.

Fixes #45084

Change-Id: I6677b27fcd71e8c9bb8edbe8e3be70e5a271ebd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/302569
Trust: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocompress/lzw: add Reset method to Reader and Writer
Agniva De Sarker [Fri, 27 Nov 2020 05:55:00 +0000 (11:25 +0530)]
compress/lzw: add Reset method to Reader and Writer

We add a Reset method which clears any internal state of an encoder
or a decoder to let it be reused again as a new Writer or Reader respectively.

We also export the encoder and decoder structs, renaming them
to be Reader and Writer, and we guarantee that the underlying types
from the constructors will always be Reader and Writer respectively.

Benchmark results by reusing the encoder:
on cpu: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz

name                 time/op
Decoder/1e4-8          93.6µs ± 1%
Decoder/1e-Reuse4-8    87.7µs ± 1%
Decoder/1e5-8           877µs ± 1%
Decoder/1e-Reuse5-8     860µs ± 3%
Decoder/1e6-8          8.79ms ± 1%
Decoder/1e-Reuse6-8    8.82ms ± 4%
Encoder/1e4-8           168µs ± 2%
Encoder/1e-Reuse4-8     160µs ± 1%
Encoder/1e5-8          1.64ms ± 1%
Encoder/1e-Reuse5-8    1.61ms ± 2%
Encoder/1e6-8          16.2ms ± 6%
Encoder/1e-Reuse6-8    15.8ms ± 2%

name                 speed
Decoder/1e4-8         107MB/s ± 1%
Decoder/1e-Reuse4-8   114MB/s ± 1%
Decoder/1e5-8         114MB/s ± 1%
Decoder/1e-Reuse5-8   116MB/s ± 3%
Decoder/1e6-8         114MB/s ± 1%
Decoder/1e-Reuse6-8   113MB/s ± 5%
Encoder/1e4-8        59.7MB/s ± 2%
Encoder/1e-Reuse4-8  62.4MB/s ± 1%
Encoder/1e5-8        61.1MB/s ± 1%
Encoder/1e-Reuse5-8  62.0MB/s ± 2%
Encoder/1e6-8        61.7MB/s ± 5%
Encoder/1e-Reuse6-8  63.4MB/s ± 2%

name                 alloc/op
Decoder/1e4-8          21.8kB ± 0%
Decoder/1e-Reuse4-8     50.0B ± 0%
Decoder/1e5-8          21.8kB ± 0%
Decoder/1e-Reuse5-8     70.4B ± 2%
Decoder/1e6-8          21.9kB ± 0%
Decoder/1e-Reuse6-8      271B ± 3%
Encoder/1e4-8          77.9kB ± 0%
Encoder/1e-Reuse4-8    4.17kB ± 0%
Encoder/1e5-8          77.9kB ± 0%
Encoder/1e-Reuse5-8    4.27kB ± 0%
Encoder/1e6-8          77.9kB ± 0%
Encoder/1e-Reuse6-8    5.22kB ± 0%

name                 allocs/op
Decoder/1e4-8            2.00 ± 0%
Decoder/1e-Reuse4-8      1.00 ± 0%
Decoder/1e5-8            2.00 ± 0%
Decoder/1e-Reuse5-8      1.00 ± 0%
Decoder/1e6-8            2.00 ± 0%
Decoder/1e-Reuse6-8      1.00 ± 0%
Encoder/1e4-8            3.00 ± 0%
Encoder/1e-Reuse4-8      2.00 ± 0%
Encoder/1e5-8            3.00 ± 0%
Encoder/1e-Reuse5-8      2.00 ± 0%
Encoder/1e6-8            3.00 ± 0%
Encoder/1e-Reuse6-8      2.00 ± 0%

Fixes #26535

Change-Id: Icde613fea6234a5bdce95f1e49910f5687e30b22
Reviewed-on: https://go-review.googlesource.com/c/go/+/273667
Trust: Agniva De Sarker <agniva.quicksilver@gmail.com>
Trust: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
4 years agomath/bits: folded reverse tables by using const string
Meng Zhuo [Tue, 16 Mar 2021 08:31:08 +0000 (16:31 +0800)]
math/bits: folded reverse tables by using const string

linux/mips64le

name            old time/op  new time/op  delta
Reverse         2.31ns ± 1%  2.27ns ± 1%  -1.53%  (p=0.001 n=10+10)
Reverse8        0.65ns ± 1%  0.65ns ± 1%  -1.19%  (p=0.000 n=9+10)
Reverse16       1.15ns ± 2%  1.14ns ± 2%    ~     (p=0.062 n=9+10)
Reverse32       1.96ns ± 1%  1.94ns ± 1%  -1.16%  (p=0.000 n=10+9)
Reverse64       2.29ns ± 1%  2.26ns ± 0%  -0.94%  (p=0.000 n=9+9)
ReverseBytes    0.66ns ± 3%  0.65ns ± 1%  -1.58%  (p=0.006 n=9+10)
ReverseBytes16  0.66ns ± 2%  0.65ns ± 1%  -2.05%  (p=0.000 n=10+9)
ReverseBytes32  0.41ns ± 1%  0.40ns ± 0%  -1.68%  (p=0.000 n=10+10)
ReverseBytes64  0.66ns ± 1%  0.65ns ± 1%  -1.50%  (p=0.000 n=10+9)

cpu=1 benchtime=100ms count=100

name            old time/op  new time/op  delta
Reverse         28.0ns ± 3%  27.7ns ± 3%   -0.80%  (p=0.000 n=100+98)
Reverse8        2.24ns ± 1%  2.24ns ± 1%     ~     (p=0.142 n=98+100)
Reverse16       4.07ns ± 3%  4.05ns ± 3%   -0.66%  (p=0.000 n=99+99)
Reverse32       11.3ns ± 0%  11.3ns ± 0%     ~     (p=0.283 n=94+97)
Reverse64       12.6ns ± 0%  12.6ns ± 0%   +0.60%  (p=0.000 n=100+98)
ReverseBytes    5.25ns ± 1%  5.24ns ± 1%   -0.18%  (p=0.000 n=100+100)
ReverseBytes16  2.00ns ± 0%  2.21ns ± 3%  +10.07%  (p=0.000 n=88+100)
ReverseBytes32  4.08ns ± 2%  4.13ns ± 2%   +1.39%  (p=0.000 n=99+99)
ReverseBytes64  5.48ns ± 1%  5.45ns ± 1%   -0.50%  (p=0.000 n=98+99)

Update #43403

Change-Id: I7e7e00bb17608739d9f6b927c6dfef2580493a0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/280645
Trust: Meng Zhuo <mzh@golangcn.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoos/user: make user.LookupGroupId function work for large entries
Andrey Bokhanko [Thu, 14 Jan 2021 15:30:14 +0000 (15:30 +0000)]
os/user: make user.LookupGroupId function work for large entries

The existing implementation of user.LookupGroupId function works
incorrectly with very large (>64K symbols) entries in /etc/group file.
This patch fixes this.

Fixes #43636

Change-Id: I453321f1ab15fd4d0002f97fcec7d0789e1e0da5
Reviewed-on: https://go-review.googlesource.com/c/go/+/283601
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agodebug/dwarf: support DW_FORM_rnglistx aka formRnglistx
Ian Lance Taylor [Tue, 16 Mar 2021 20:31:20 +0000 (13:31 -0700)]
debug/dwarf: support DW_FORM_rnglistx aka formRnglistx

Change-Id: I7df915978af3488f46a27595a1b04d0d33f81f7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/302369
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agospec: fix rendering of >=
Robert Griesemer [Wed, 17 Mar 2021 00:09:23 +0000 (17:09 -0700)]
spec: fix rendering of >=

Follow-up on https://golang.org/cl/297249.

Change-Id: Ib4df91df530e4e7d7dd8c54d89c834cee55031f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/302370
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
4 years agocmd/compile/internal/types2: review of call.go
Robert Griesemer [Fri, 12 Mar 2021 02:23:30 +0000 (18:23 -0800)]
cmd/compile/internal/types2: review of call.go

The changes between (equivalent, and reviewed) go/types/call.go
and call.go can be seen by comparing patchset 1 and 2. The actual
changes are removing the "// UNREVIEWED" marker, renaming of
sig_params to sigParams, and a couple of comment adjustments.
These additional changes reduce the difference between this
file and the go/types version.

Note that the verification pass using a MethodSet doesn't
exist because there's no MethodSet in types2.

Change-Id: I4d49460e0457401ed705dff5cfd17c9ff259d89f
Reviewed-on: https://go-review.googlesource.com/c/go/+/300998
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years agocmd/compile, cmd/link: dynamically export writable static tmps
Cherry Zhang [Sat, 13 Mar 2021 04:21:09 +0000 (23:21 -0500)]
cmd/compile, cmd/link: dynamically export writable static tmps

Static tmps are private to a package, but with plugins a package
can be shared among multiple DSOs. They need to have a consistent
view of the static tmps, especially for writable ones. So export
them. (Read-only static tmps have the same values anyway, so it
doesn't matter. Also Mach-O doesn't support dynamically exporting
read-only symbols anyway.)

Fixes #44956.

Change-Id: I921e25b7ab73cd5d5347800eccdb7931e3448779
Reviewed-on: https://go-review.googlesource.com/c/go/+/301793
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile: update some comments
Cherry Zhang [Thu, 11 Mar 2021 20:00:50 +0000 (15:00 -0500)]
cmd/compile: update some comments

Update some symbol references after refactoring.

Change-Id: I134eec453b69efae97eb8a13e52ff8c14d38442a
Reviewed-on: https://go-review.googlesource.com/c/go/+/301790
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/asm: when dynamic linking, reject code that uses a clobbered R15
Keith Randall [Wed, 13 Jan 2021 23:45:28 +0000 (15:45 -0800)]
cmd/asm: when dynamic linking, reject code that uses a clobbered R15

The assember uses R15 as scratch space when assembling global variable
references in dynamically linked code. If the assembly code uses the
clobbered value of R15, report an error. The user is probably expecting
some other value in that register.

Getting rid of the R15 use isn't very practical (we could save a
register to a field in the G maybe, but that gets cumbersome).

Fixes #43661

Change-Id: I43f848a3d8b8a28931ec733386b85e6e9a42d8ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/283474
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/go: bail out from script tests earlier when a timeout occurs
Bryan C. Mills [Mon, 15 Mar 2021 20:48:51 +0000 (16:48 -0400)]
cmd/go: bail out from script tests earlier when a timeout occurs

(I needed this to debug an accidental infinite-recursion I introduced
while revising CL 293689.)

Fixes #38768

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

4 years agocmd/compile/internal/ssa: delete unused files
cui [Sun, 14 Mar 2021 18:55:59 +0000 (18:55 +0000)]
cmd/compile/internal/ssa: delete unused files

Change-Id: I5d640091375feb873517368ce05f0ba46c35714f
GitHub-Last-Rev: cdaf6ba33664f3602e563aa93009e0f4f4865b32
GitHub-Pull-Request: golang/go#44997
Reviewed-on: https://go-review.googlesource.com/c/go/+/301630
Reviewed-by: David Chase <drchase@google.com>
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agospec: clarify that signed integers>=0 are permitted as shift counts
nobishino [Tue, 16 Mar 2021 19:49:13 +0000 (19:49 +0000)]
spec: clarify that signed integers>=0 are permitted as shift counts

In Go1.13 and above, signed integers are permitted as shift counts as long as they are >=0.
However, the comments in the "Arithmetic operators" section says shift operators accept "unsigned integer" as of right operands. Replacing this with "integer>=0" resolves the misunderstanding that shift
operators permit only unsigned integers.

Reference: Go1.13 Release Notes: https://golang.org/doc/go1.13

Change-Id: Icd3c7734d539ab702590e992a618c9251c653c37
GitHub-Last-Rev: 4f263a48d3b19ca06a277c5fef78df55e9a92b10
GitHub-Pull-Request: golang/go#44664
Reviewed-on: https://go-review.googlesource.com/c/go/+/297249
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Robert Griesemer <gri@golang.org>

4 years agocmd/compile: fix open defer of method call
David Chase [Tue, 16 Mar 2021 16:03:08 +0000 (12:03 -0400)]
cmd/compile: fix open defer of method call

Code generation for open defers failed to account for
presence of method receiver and thus was OFF BY ONE.

Fixes #45062.
Updates #44816.
Updates #40724.

Change-Id: Ia90ea8fd0f7d823e1f757c406f9127136c2ffdd2
Reviewed-on: https://go-review.googlesource.com/c/go/+/302249
Trust: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: (fixed) spill output parameters passed in registers as autos
David Chase [Thu, 11 Mar 2021 01:54:11 +0000 (20:54 -0500)]
cmd/compile: (fixed) spill output parameters passed in registers as autos

Repair of CL 300749.

ALSO:
found evidence that stack maps for bodyless methods are wrong.
gofmt in test/abi
removed never-executed code in types/size.go

Updates #44816.
Updates #40724.

Change-Id: Ifeb5fee60f60e7c7b58ee0457f58a3265d6cf3f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/302071
Trust: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: deal with comparable embedded in a constraint
Dan Scales [Mon, 15 Mar 2021 17:27:06 +0000 (10:27 -0700)]
cmd/compile:  deal with comparable embedded in a constraint

Ignore an embedded type in an interface which is the predeclared
interface "comparable" (which currently can only be in a type
constraint), since the name doesn't resolve and the "comparable" type
doesn't have any relevant methods (for the purposes of the compiler).

Added new test case graph.go that needs this fix.

Change-Id: I2443d2c3dfeb9d0a78aaaaf91a2808ae2759d247
Reviewed-on: https://go-review.googlesource.com/c/go/+/301831
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/asm: add rotr/drotr for mips64
Meng Zhuo [Tue, 16 Mar 2021 10:51:41 +0000 (18:51 +0800)]
cmd/asm: add rotr/drotr for mips64

This CL encodes:

ROTR rd, rt, sa
ROTRV rd, rt, rs

=> ROTR (SCON|REG), (REG,)? REG

DROTR rd, rt, sa
DROTR32 rd, rt, sa
DROTRV rd, rt, rs

=> ROTRV (SCON|REG), (REG,)? REG

Note: ROTRV will handle const over 32
Ref: The MIPS64® Instruction Set Reference Manual Revision 6.05
Change-Id: Ibe69f999b83eb43843d088cf1ac5a13c995269a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/280114
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/link: preserve elf phdr flags when loading external objects
Paul E. Murphy [Wed, 10 Mar 2021 20:41:38 +0000 (14:41 -0600)]
cmd/link: preserve elf phdr flags when loading external objects

Preserve program header flags when passing them through loadelf.Load.
They shouldn't be coerced to 0 on non-ARM platforms which set them
such as ppc64le.

Change-Id: I022613356f910d812de2fc22eac949960eeb53b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/300950
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agocrypto/tls: add HandshakeContext method to Conn
Johan Brandhorst [Sat, 1 Aug 2020 11:18:31 +0000 (12:18 +0100)]
crypto/tls: add HandshakeContext method to Conn

Adds the (*tls.Conn).HandshakeContext method. This allows
us to pass the context provided down the call stack to
eventually reach the tls.ClientHelloInfo and
tls.CertificateRequestInfo structs.
These contexts are exposed to the user as read-only via Context()
methods.

This allows users of (*tls.Config).GetCertificate and
(*tls.Config).GetClientCertificate to use the context for
request scoped parameters and cancellation.

Replace uses of (*tls.Conn).Handshake with (*tls.Conn).HandshakeContext
where appropriate, to propagate existing contexts.

Fixes #32406

Change-Id: I259939c744bdc9b805bf51a845a8bc462c042483
Reviewed-on: https://go-review.googlesource.com/c/go/+/295370
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
4 years agocmd/go: test that 'go mod tidy' retains upgraded indirect dependencies
Bryan C. Mills [Fri, 5 Mar 2021 16:30:23 +0000 (11:30 -0500)]
cmd/go: test that 'go mod tidy' retains upgraded indirect dependencies

For #36460

Change-Id: I63596e1c95d0c702073cdb016579598d79cc95ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/300158
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>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/go/internal/modload: in readonly mode, do not read go.mod files missing checksums
Bryan C. Mills [Fri, 12 Mar 2021 16:28:05 +0000 (11:28 -0500)]
cmd/go/internal/modload: in readonly mode, do not read go.mod files missing checksums

This was causing test failures while revising CL 293689: splitting the
roots out from the rest of the module graph may allow 'go list -e' to
proceed even when the rest of the module graph can't be loaded (e.g.
due to missing go.mod checksums). If that occurs, it becomes more
important that the moduleInfo helper function itself avoid fetching
unchecked files.

For #36460

Change-Id: I088509eeb3008cc6e8bfe85a00ec2bf500bf9423
Reviewed-on: https://go-review.googlesource.com/c/go/+/301371
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>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/go/internal/modcmd: in 'go mod tidy', suspend go.mod writes until tidy
Bryan C. Mills [Fri, 12 Mar 2021 16:26:51 +0000 (11:26 -0500)]
cmd/go/internal/modcmd: in 'go mod tidy', suspend go.mod writes until tidy

For #36460

Change-Id: Ia8633f37aec8c7ed532bf7278867251e5e2a4285
Reviewed-on: https://go-review.googlesource.com/c/go/+/301370
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>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/compile: loads from readonly globals into const for mips64x
Meng Zhuo [Tue, 16 Mar 2021 09:04:31 +0000 (17:04 +0800)]
cmd/compile: loads from readonly globals into const for mips64x

Ref: CL 141118
Update #26498

Change-Id: If4ea55c080b9aa10183eefe81fefbd4072deaf3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/280646
Trust: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: use depth first topological sort algorithm for layout
erifan01 [Thu, 23 Jul 2020 02:24:56 +0000 (10:24 +0800)]
cmd/compile: use depth first topological sort algorithm for layout

The current layout algorithm tries to put consecutive blocks together,
so the priority of the successor block is higher than the priority of
the zero indegree block. This algorithm is beneficial for subsequent
register allocation, but will result in more branch instructions.
The depth-first topological sorting algorithm is a well-known layout
algorithm, which has applications in many languages, and it helps to
reduce branch instructions. This CL applies it to the layout pass.
The test results show that it helps to reduce the code size.

This CL also includes the following changes:
1, Removed the primary predecessor mechanism. The new layout algorithm is
  not very friendly to register allocator in some cases, in order to adapt
  to the new layout algorithm, a new primary predecessor selection strategy
  is introduced.
2, Since the new layout implementation may place non-loop blocks between
  loop blocks, some adaptive modifications have also been made to looprotate
  pass.
3, The layout also affects the results of codegen, so this CL also adjusted
  several codegen tests accordingly.

It is inevitable that this CL will cause the code size or performance of a
few functions to decrease, but the number of cases it improves is much larger
than the number of cases it drops.

Statistical data from compilecmp on linux/amd64 is as follow:
name                      old time/op       new time/op       delta
Template                        382ms ± 4%        382ms ± 4%    ~     (p=0.497 n=49+50)
Unicode                         170ms ± 9%        169ms ± 8%    ~     (p=0.344 n=48+50)
GoTypes                         2.01s ± 4%        2.01s ± 4%    ~     (p=0.628 n=50+48)
Compiler                        190ms ±10%        189ms ± 9%    ~     (p=0.734 n=50+50)
SSA                             11.8s ± 2%        11.8s ± 3%    ~     (p=0.877 n=50+50)
Flate                           241ms ± 9%        241ms ± 8%    ~     (p=0.897 n=50+49)
GoParser                        366ms ± 3%        361ms ± 4%  -1.21%  (p=0.004 n=47+50)
Reflect                         835ms ± 3%        838ms ± 3%    ~     (p=0.275 n=50+49)
Tar                             336ms ± 4%        335ms ± 3%    ~     (p=0.454 n=48+48)
XML                             433ms ± 4%        431ms ± 3%    ~     (p=0.071 n=49+48)
LinkCompiler                    706ms ± 4%        705ms ± 4%    ~     (p=0.608 n=50+49)
ExternalLinkCompiler            1.85s ± 3%        1.83s ± 2%  -1.47%  (p=0.000 n=49+48)
LinkWithoutDebugCompiler        437ms ± 5%        437ms ± 6%    ~     (p=0.953 n=49+50)
[Geo mean]                      615ms             613ms       -0.37%

name                      old alloc/op      new alloc/op      delta
Template                       38.7MB ± 1%       38.7MB ± 1%    ~     (p=0.834 n=50+50)
Unicode                        28.1MB ± 0%       28.1MB ± 0%  -0.22%  (p=0.000 n=49+50)
GoTypes                         168MB ± 1%        168MB ± 1%    ~     (p=0.054 n=47+47)
Compiler                       23.0MB ± 1%       23.0MB ± 1%    ~     (p=0.432 n=50+50)
SSA                            1.54GB ± 0%       1.54GB ± 0%  +0.21%  (p=0.000 n=50+50)
Flate                          23.6MB ± 1%       23.6MB ± 1%    ~     (p=0.153 n=43+46)
GoParser                       35.1MB ± 1%       35.1MB ± 2%    ~     (p=0.202 n=50+50)
Reflect                        84.7MB ± 1%       84.7MB ± 1%    ~     (p=0.333 n=48+49)
Tar                            34.5MB ± 1%       34.5MB ± 1%    ~     (p=0.406 n=46+49)
XML                            44.3MB ± 2%       44.2MB ± 3%    ~     (p=0.981 n=50+50)
LinkCompiler                    131MB ± 0%        128MB ± 0%  -2.74%  (p=0.000 n=50+50)
ExternalLinkCompiler            120MB ± 0%        120MB ± 0%  +0.01%  (p=0.007 n=50+50)
LinkWithoutDebugCompiler       77.3MB ± 0%       77.3MB ± 0%  -0.02%  (p=0.000 n=50+50)
[Geo mean]                     69.3MB            69.1MB       -0.22%

file      before    after     Δ        %
addr2line 4104220   4043684   -60536   -1.475%
api       5342502   5249678   -92824   -1.737%
asm       4973785   4858257   -115528  -2.323%
buildid   2667844   2625660   -42184   -1.581%
cgo       4686849   4616313   -70536   -1.505%
compile   23667431  23268406  -399025  -1.686%
cover     4959676   4874108   -85568   -1.725%
dist      3515934   3450422   -65512   -1.863%
doc       3995581   3925469   -70112   -1.755%
fix       3379202   3318522   -60680   -1.796%
link      6743249   6629913   -113336  -1.681%
nm        4047529   3991777   -55752   -1.377%
objdump   4456151   4388151   -68000   -1.526%
pack      2435040   2398072   -36968   -1.518%
pprof     13804080  13565808  -238272  -1.726%
test2json 2690043   2645987   -44056   -1.638%
trace     10418492  10232716  -185776  -1.783%
vet       7258259   7121259   -137000  -1.888%
total     113145867 111204202 -1941665 -1.716%

The situation on linux/arm64 is as follow:
name                      old time/op       new time/op       delta
Template                        280ms ± 1%        282ms ± 1%  +0.75%  (p=0.000 n=46+48)
Unicode                         124ms ± 2%        124ms ± 2%  +0.37%  (p=0.045 n=50+50)
GoTypes                         1.69s ± 1%        1.70s ± 1%  +0.56%  (p=0.000 n=49+50)
Compiler                        122ms ± 1%        123ms ± 1%  +0.93%  (p=0.000 n=50+50)
SSA                             12.6s ± 1%        12.7s ± 0%  +0.72%  (p=0.000 n=50+50)
Flate                           170ms ± 1%        172ms ± 1%  +0.97%  (p=0.000 n=49+49)
GoParser                        262ms ± 1%        263ms ± 1%  +0.39%  (p=0.000 n=49+48)
Reflect                         639ms ± 1%        650ms ± 1%  +1.63%  (p=0.000 n=49+49)
Tar                             243ms ± 1%        245ms ± 1%  +0.82%  (p=0.000 n=50+50)
XML                             324ms ± 1%        327ms ± 1%  +0.72%  (p=0.000 n=50+49)
LinkCompiler                    597ms ± 1%        596ms ± 1%  -0.27%  (p=0.001 n=48+47)
ExternalLinkCompiler            1.90s ± 1%        1.88s ± 1%  -1.00%  (p=0.000 n=50+50)
LinkWithoutDebugCompiler        364ms ± 1%        363ms ± 1%    ~     (p=0.220 n=49+50)
[Geo mean]                      485ms             488ms       +0.49%

name                      old alloc/op      new alloc/op      delta
Template                       38.7MB ± 0%       38.8MB ± 1%    ~     (p=0.093 n=43+49)
Unicode                        28.4MB ± 0%       28.4MB ± 0%  +0.03%  (p=0.000 n=49+45)
GoTypes                         169MB ± 1%        169MB ± 1%  +0.23%  (p=0.010 n=50+50)
Compiler                       23.2MB ± 1%       23.2MB ± 1%  +0.11%  (p=0.000 n=40+44)
SSA                            1.54GB ± 0%       1.55GB ± 0%  +0.45%  (p=0.000 n=47+49)
Flate                          23.8MB ± 2%       23.8MB ± 1%    ~     (p=0.543 n=50+50)
GoParser                       35.3MB ± 1%       35.4MB ± 1%    ~     (p=0.792 n=50+50)
Reflect                        85.2MB ± 1%       85.2MB ± 0%    ~     (p=0.055 n=50+47)
Tar                            34.5MB ± 1%       34.5MB ± 1%  +0.06%  (p=0.015 n=50+50)
XML                            43.8MB ± 2%       43.9MB ± 2%  +0.19%  (p=0.000 n=48+48)
LinkCompiler                    137MB ± 0%        136MB ± 0%  -0.92%  (p=0.000 n=50+50)
ExternalLinkCompiler            127MB ± 0%        127MB ± 0%    ~     (p=0.516 n=50+50)
LinkWithoutDebugCompiler       84.0MB ± 0%       84.0MB ± 0%    ~     (p=0.057 n=50+50)
[Geo mean]                     70.4MB            70.4MB       +0.01%

file      before    after     Δ        %
addr2line 4021557   4002933   -18624   -0.463%
api       5127847   5028503   -99344   -1.937%
asm       5034716   4936836   -97880   -1.944%
buildid   2608118   2594094   -14024   -0.538%
cgo       4488592   4398320   -90272   -2.011%
compile   22501129  22213592  -287537  -1.278%
cover     4742301   4713573   -28728   -0.606%
dist      3388071   3365311   -22760   -0.672%
doc       3802250   3776082   -26168   -0.688%
fix       3306147   3216939   -89208   -2.698%
link      6404483   6363699   -40784   -0.637%
nm        3941026   3921930   -19096   -0.485%
objdump   4383330   4295122   -88208   -2.012%
pack      2404547   2389515   -15032   -0.625%
pprof     12996234  12856818  -139416  -1.073%
test2json 2668500   2586788   -81712   -3.062%
trace     9816276   9609580   -206696  -2.106%
vet       6900682   6787338   -113344  -1.643%
total     108535806 107056973 -1478833 -1.363%

Change-Id: Iaec1cdcaacca8025e9babb0fb8a532fddb70c87d
Reviewed-on: https://go-review.googlesource.com/c/go/+/255239
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: eric fang <eric.fang@arm.com>

4 years agocmd/compile/internal/ssa: handle more cases in fuse pass
eric fang [Thu, 11 Jun 2020 09:35:24 +0000 (09:35 +0000)]
cmd/compile/internal/ssa: handle more cases in fuse pass

Currently fuseBlockIf handls four cases where s0 and s1 have only one predecessor
node. In fact, even if s0 and s1 have multiple predecessor nodes, it can be optimized
as well. This patch handles these cases.

This CL does not bring significant performance changes, it is more like an optimization
of dead code elimination. So it detects a lot of benchmarks whose functions are
completely optimized, such as BenchmarkNeIfaceConcrete, BenchmarkEqIfaceConcrete,
BenchmarkFullJapaneseRune, BenchmarkClearFat{8, 12, 16,...1024}, Benchmark{En|De}codeRune,
and BenchmarkCopyFat{8, 12, 16,...1024} and many others that I didn't check.

Test result of compilecmp on linux amd64, the data on linux arm64 is similar.
name                      old time/op                 new time/op                 delta
Template                    466131893.640000ns +-16%    455546571.480000ns +-12%    ~     (p=0.066 n=50+50)
Unicode                     195858206.980000ns +- 9%    197387526.224490ns +- 9%    ~     (p=0.231 n=50+49)
GoTypes                    1581961264.260000ns +- 7%   1581828319.640000ns +- 5%    ~     (p=0.964 n=50+50)
Compiler                   7425890449.259998ns +- 2%   7424138343.632654ns +- 2%    ~     (p=0.815 n=50+49)
SSA                       17392652203.380009ns +- 1%  17248314507.854172ns +- 1%  -0.83%  (p=0.000 n=50+48)
Flate                       298061504.940000ns +-12%    292773080.632653ns +-12%    ~     (p=0.165 n=50+49)
GoParser                    376046929.420000ns +- 9%    370746254.693878ns +- 9%    ~     (p=0.231 n=50+49)
Reflect                     995721330.160000ns +- 7%    985916024.620000ns +- 7%    ~     (p=0.103 n=50+50)
Tar                         398878287.040000ns +-10%    399186737.000000ns +-11%    ~     (p=0.883 n=50+50)
XML                         555898064.200000ns +- 8%    554877077.100000ns +-10%    ~     (p=0.926 n=50+50)
LinkCompiler                757995424.632653ns +- 7%    758301900.420000ns +- 7%    ~     (p=0.437 n=49+50)
ExternalLinkCompiler       2399985741.270834ns +- 4%   2396112274.630435ns +- 4%    ~     (p=0.766 n=48+46)
LinkWithoutDebugCompiler    450472710.700000ns +- 9%    448935188.720000ns +- 7%    ~     (p=0.668 n=50+50)
[Geo mean]                   927951041.671984ns          922858781.007286ns       -0.55%

name                      old user-time/op            new user-time/op            delta
Template                    639484500.000000ns +-16%    630857140.000000ns +-13%    ~     (p=0.363 n=50+50)
Unicode                     370072081.632653ns +-11%    375108300.000000ns +-10%    ~     (p=0.248 n=49+50)
GoTypes                    2205838860.000000ns +- 5%   2206640900.000000ns +- 3%    ~     (p=0.915 n=50+50)
Compiler                  10337224272.727268ns +- 2%  10366187152.173916ns +- 2%    ~     (p=0.324 n=44+46)
SSA                       23843616104.166660ns +- 3%  23678281387.755112ns +- 3%  -0.69%  (p=0.002 n=48+49)
Flate                       396446760.000000ns +-15%    391245333.333333ns +-10%    ~     (p=0.313 n=50+48)
GoParser                    509121660.000000ns +-10%    505938620.000000ns +- 9%    ~     (p=0.436 n=50+50)
Reflect                    1328136212.765958ns +- 6%   1312627440.000000ns +- 8%    ~     (p=0.068 n=47+50)
Tar                         563039480.000000ns +-10%    563064360.000000ns +-10%    ~     (p=0.953 n=50+50)
XML                         775596380.000000ns +- 9%    774736920.000000ns +-11%    ~     (p=0.899 n=50+50)
LinkCompiler               1315155260.000000ns +- 9%   1312946860.000001ns +- 6%    ~     (p=0.861 n=50+50)
ExternalLinkCompiler       2739635480.000000ns +- 6%   2732580380.000000ns +- 6%    ~     (p=0.943 n=50+50)
LinkWithoutDebugCompiler    537418600.000000ns +-10%    535914620.000000ns +- 9%    ~     (p=0.734 n=50+50)
[Geo mean]                  1296231259.389525ns         1291929605.124197ns       -0.33%

name                      old alloc/op                new alloc/op                delta
Template                                35.0MB +- 0%                35.0MB +- 0%    ~     (p=0.586 n=50+50)
Unicode                                 29.3MB +- 0%                29.3MB +- 0%  +0.01%  (p=0.004 n=50+50)
GoTypes                                  116MB +- 0%                 116MB +- 0%    ~     (p=0.102 n=50+50)
Compiler                                 555MB +- 0%                 555MB +- 0%    ~     (p=0.285 n=50+50)
SSA                                     1.37GB +- 0%                1.36GB +- 0%  -0.98%  (p=0.000 n=49+49)
Flate                                   21.8MB +- 0%                21.8MB +- 0%    ~     (p=0.475 n=50+49)
GoParser                                26.7MB +- 0%                26.7MB +- 0%    ~     (p=0.385 n=50+50)
Reflect                                 74.2MB +- 0%                74.3MB +- 0%  +0.01%  (p=0.006 n=49+50)
Tar                                     32.7MB +- 0%                32.7MB +- 0%    ~     (p=0.125 n=50+50)
XML                                     41.8MB +- 0%                41.8MB +- 0%    ~     (p=0.649 n=49+50)
LinkCompiler                             105MB +- 0%                 105MB +- 0%  -0.05%  (p=0.000 n=50+48)
ExternalLinkCompiler                    92.6MB +- 0%                92.6MB +- 0%  -0.02%  (p=0.000 n=50+50)
LinkWithoutDebugCompiler                63.9MB +- 0%                63.9MB +- 0%  -0.05%  (p=0.000 n=50+50)
[Geo mean]                               77.0MB                      76.9MB       -0.08%

name                      old allocs/op               new allocs/op               delta
Template                                  344k +- 0%                  344k +- 0%    ~     (p=0.091 n=50+50)
Unicode                                   340k +- 0%                  340k +- 0%    ~     (p=0.084 n=50+50)
GoTypes                                  1.19M +- 0%                 1.19M +- 0%    ~     (p=0.634 n=50+50)
Compiler                                 5.05M +- 0%                 5.05M +- 0%    ~     (p=0.428 n=50+48)
SSA                                      12.9M +- 0%                 12.8M +- 0%  -0.94%  (p=0.000 n=48+50)
Flate                                     216k +- 0%                  216k +- 0%    ~     (p=0.959 n=50+50)
GoParser                                  275k +- 0%                  275k +- 0%    ~     (p=0.705 n=50+50)
Reflect                                   887k +- 0%                  887k +- 0%    ~     (p=0.136 n=50+50)
Tar                                       318k +- 0%                  318k +- 0%  +0.01%  (p=0.007 n=50+48)
XML                                       396k +- 0%                  396k +- 0%    ~     (p=0.577 n=48+50)
LinkCompiler                              457k +- 0%                  457k +- 0%  -0.02%  (p=0.000 n=50+48)
ExternalLinkCompiler                      459k +- 0%                  459k +- 0%  -0.02%  (p=0.000 n=50+49)
LinkWithoutDebugCompiler                  111k +- 0%                  111k +- 0%  -0.09%  (p=0.000 n=50+50)
[Geo mean]                                 603k                        603k       -0.08%

name                      old maxRSS/op               new maxRSS/op               delta
Template                                 33.7M +- 5%                 33.7M +- 3%    ~     (p=0.798 n=50+48)
Unicode                                  35.2M +- 5%                 35.3M +- 5%    ~     (p=0.586 n=50+50)
GoTypes                                  73.5M +- 5%                 73.2M +- 5%    ~     (p=0.436 n=50+50)
Compiler                                  315M +- 3%                  315M +- 3%    ~     (p=0.726 n=49+48)
SSA                                       705M +- 5%                  691M +- 5%  -2.01%  (p=0.000 n=50+50)
Flate                                    25.2M +- 3%                 25.0M +- 3%    ~     (p=0.122 n=49+49)
GoParser                                 27.7M +- 5%                 27.7M +- 3%    ~     (p=0.967 n=50+50)
Reflect                                  54.6M +- 4%                 54.8M +- 4%    ~     (p=0.418 n=50+50)
Tar                                      32.2M +- 4%                 32.1M +- 3%    ~     (p=0.644 n=50+49)
XML                                      38.7M +- 5%                 38.9M +- 5%    ~     (p=0.612 n=50+50)
LinkCompiler                              159M +- 1%                  159M +- 1%    ~     (p=0.302 n=49+50)
ExternalLinkCompiler                      171M +- 1%                  170M +- 1%  -0.33%  (p=0.000 n=50+50)
LinkWithoutDebugCompiler                  133M +- 1%                  132M +- 1%  -0.44%  (p=0.000 n=48+50)
[Geo mean]                                76.9M                       76.8M       -0.25%

name                      old text-bytes              new text-bytes              delta
HelloSize                                804kB +- 0%                 804kB +- 0%    ~     (all equal)

name                      old data-bytes              new data-bytes              delta
HelloSize                               13.2kB +- 0%                13.2kB +- 0%    ~     (all equal)

name                      old bss-bytes               new bss-bytes               delta
HelloSize                                206kB +- 0%                 206kB +- 0%    ~     (all equal)

name                      old exe-bytes               new exe-bytes               delta
HelloSize                               1.20MB +- 0%                1.20MB +- 0%    ~     (all equal)

file    before    after     Δ       %
api     4904729   4904881   +152    +0.003%
asm     4849768   4849696   -72     -0.001%
buildid 2604760   2604768   +8      +0.000%
cgo     4505984   4506000   +16     +0.000%
compile 18936732  18864939  -71793  -0.379%
cover   4787385   4787377   -8      -0.000%
dist    3451964   3451988   +24     +0.001%
doc     3794929   3794913   -16     -0.000%
fix     3201863   3201847   -16     -0.000%
link    6467231   6467327   +96     +0.001%
objdump 4400076   4400132   +56     +0.001%
pprof   13354395  13354507  +112    +0.001%
trace   10186673  10187273  +600    +0.006%
vet     6727213   6727277   +64     +0.001%
total   105284348 105213571 -70777  -0.067%

Change-Id: I5020d112021f165a4ae18aa56402d8690330d8fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/239457
Reviewed-by: eric fang <eric.fang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: eric fang <eric.fang@arm.com>
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agointernal/poll: eliminate the redundant type conversions of FD.Sysfd
Andy Pan [Sun, 14 Mar 2021 05:19:12 +0000 (13:19 +0800)]
internal/poll: eliminate the redundant type conversions of FD.Sysfd

Change-Id: Ib75662f717320510319c696520e645f54eec97f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/301569
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoruntime: using wyhash for memhashFallback on 32bit platform
Meng Zhuo [Mon, 15 Mar 2021 11:48:39 +0000 (19:48 +0800)]
runtime: using wyhash for memhashFallback on 32bit platform

wyhash is a general hash function that:

1. Default hash function of Zig, Nim
2. Passed Smhasher, BigCrush and PractRand
3. Less code
4. 3~26% faster than internal hashmap

name                  old time/op    new time/op    delta
Hash5                   67.8ns ± 0%    65.4ns ± 0%   -3.45%  (p=0.000 n=7+10)
Hash16                  82.5ns ± 0%    74.2ns ± 0%  -10.12%  (p=0.000 n=6+8)
Hash64                   121ns ± 0%     102ns ± 0%  -15.82%  (p=0.000 n=7+10)
Hash1024                1.13µs ± 0%    0.89µs ± 0%  -20.58%  (p=0.000 n=10+9)
Hash65536               68.9µs ± 0%    54.4µs ± 0%  -21.04%  (p=0.000 n=10+7)
HashStringSpeed          103ns ± 2%      93ns ± 3%  -10.24%  (p=0.000 n=9+10)
HashBytesSpeed           191ns ± 2%     180ns ± 1%   -5.40%  (p=0.000 n=10+8)
HashInt32Speed          59.0ns ± 2%    59.1ns ± 1%     ~     (p=0.655 n=9+8)
HashInt64Speed          72.7ns ± 3%    66.1ns ± 5%   -9.04%  (p=0.000 n=10+10)
HashStringArraySpeed     270ns ± 1%     222ns ± 2%  -17.91%  (p=0.000 n=10+10)
FastrandHashiter         108ns ± 0%     109ns ± 1%   +0.96%  (p=0.002 n=10+10)

name                  old speed      new speed      delta
Hash5                 73.8MB/s ± 0%  76.4MB/s ± 0%   +3.58%  (p=0.000 n=7+10)
Hash16                 194MB/s ± 0%   216MB/s ± 0%  +11.25%  (p=0.000 n=10+8)
Hash64                 530MB/s ± 0%   630MB/s ± 0%  +18.74%  (p=0.000 n=8+10)
Hash1024               910MB/s ± 0%  1145MB/s ± 0%  +25.88%  (p=0.000 n=10+9)
Hash65536              951MB/s ± 0%  1204MB/s ± 0%  +26.64%  (p=0.000 n=10+7)

Update #43130

Change-Id: Id00c54b116a2411fcf675e95896fffb85f0e25b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/280372
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agotime: support "," as separator for fractional seconds
Emmanuel T Odeke [Fri, 12 Mar 2021 01:34:09 +0000 (17:34 -0800)]
time: support "," as separator for fractional seconds

Accepts comma "," as a separator for fractional seconds
hence we now accept:
* 2006-01-02 15:04:05,999999999 -0700 MST
* Mon Jan _2 15:04:05,120007 2006
* Mon Jan 2 15:04:05,120007 2006

This change follows the recommendations of ISO 8601 per

   https://en.wikipedia.org/wiki/ISO_8601#cite_note-26

which states

   ISO 8601:2004(E), ISO, 2004-12-01, "4.2.2.4 ...
   the decimal fraction shall be divided from the integer
   part by the decimal sign specified in ISO 31-0, i.e.
   the comma [,] or full stop [.]. Of these, the comma
   is the preferred sign."

Unfortunately, I couldn't directly access the ISO 8601 document
because suddenly it is behind a paywall on the ISO website,
charging CHF 158 (USD 179) for 38 pages :-(

However, this follows publicly available cited literature, as well
as the recommendations from the proposal approval.

Fixes #6189
Updates #27746
Updates #26002
Updates #36145
Updates #43813
Fixes #43823

Change-Id: Ibe96064e8ee27c239be78c880fa561a1a41e190c
Reviewed-on: https://go-review.googlesource.com/c/go/+/300996
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agotime: add Time.IsDST() to check if its Location is in Daylight Savings Time
Joel Courtney [Mon, 15 Mar 2021 22:28:31 +0000 (22:28 +0000)]
time: add Time.IsDST() to check if its Location is in Daylight Savings Time

Fixes #42102

Change-Id: I2cd2fdf67c794c3e99ed1c24786f7f779da73962
GitHub-Last-Rev: bbfa92135734cbd55895012fa492e51686a7b58b
GitHub-Pull-Request: golang/go#42103
Reviewed-on: https://go-review.googlesource.com/c/go/+/264077
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Rob Pike <r@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agoreflect: panic if ArrayOf is called with negative length
Paschalis Tsilias [Fri, 15 Jan 2021 15:40:20 +0000 (17:40 +0200)]
reflect: panic if ArrayOf is called with negative length

Since we cannot change the signature of reflect.ArrayOf to return an
error, we panic instead of producing a wrong result.

Fixes #43603

Change-Id: I23915df8d190f35af4d00ab86768868cd621e839
Reviewed-on: https://go-review.googlesource.com/c/go/+/284136
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agonet: fix BenchmarkWriteToReadFromUDP on Windows
Filippo Valsorda [Mon, 15 Mar 2021 22:10:21 +0000 (23:10 +0100)]
net: fix BenchmarkWriteToReadFromUDP on Windows

Using 0.0.0.0 for ListenUDP listens on all addresses. Calling LocalAddr
on that Conn returns 0.0.0.0. Sending to 0.0.0.0 doesn't seem to work on
Windows. See #22827.

Change-Id: I4a48fbabe65a63e07600a65309977cec08a9c1e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/301850
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Trust: Filippo Valsorda <filippo@golang.org>

4 years agoall: run gofmt
Prajwal Koirala [Mon, 15 Mar 2021 06:13:23 +0000 (06:13 +0000)]
all: run gofmt

Fixes #44980

Change-Id: Icef35319d1582d8367c8911e15d11b0224957327
GitHub-Last-Rev: 2113e97e837c1ef5de9ba6a7bd62db92e644c500
GitHub-Pull-Request: golang/go#45005
Reviewed-on: https://go-review.googlesource.com/c/go/+/301632
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>

4 years agoRevert "cmd/compile: spill output parameters passed in registers as autos"
David Chase [Mon, 15 Mar 2021 21:12:08 +0000 (21:12 +0000)]
Revert "cmd/compile: spill output parameters passed in registers as autos"

This reverts commit 8ed438c077d82c4b4662c327dbbdb3c64e7547ca, CL 300749.

Reason for revert: Looks like it crashes on link-register architectures

Change-Id: I0c261df58900008cada3359889d2a87508158447
Reviewed-on: https://go-review.googlesource.com/c/go/+/302053
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: spill output parameters passed in registers as autos
David Chase [Thu, 11 Mar 2021 01:54:11 +0000 (20:54 -0500)]
cmd/compile: spill output parameters passed in registers as autos

ALSO:
found evidence that stack maps for bodyless methods are wrong.
gofmt in test/abi
removed never-executed code in types/size.go

Updates #44816.

Change-Id: I658c33f049337fb6f1e625f0c55430d25bfa877e
Reviewed-on: https://go-review.googlesource.com/c/go/+/300749
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: fix case where func-valued field of a generic type is called
Dan Scales [Sun, 14 Mar 2021 20:46:23 +0000 (13:46 -0700)]
cmd/compile: fix case where func-valued field of a generic type is called

Added test example orderedmap.go (binary search tree) that requires this
fix (calling function compare in _Map).

Also added new tests slices.go and metrics.go that just work.

Change-Id: Ifa5f42ab6eee9aa54c40f0eca19e00a87f8f608a
Reviewed-on: https://go-review.googlesource.com/c/go/+/301829
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/compile: add support for generic maps
Dan Scales [Mon, 15 Mar 2021 03:13:05 +0000 (20:13 -0700)]
cmd/compile: add support for generic maps

Add support for maps in subster.typ(). Add new test cases maps.go and set.go.

Change substitution of a TFUNC in subster.typ() to always create new
param and result structs if any of the receiver, param, or result
structs get substituted. All these func structs must be copied, because
they have offset fields that are dependent, and so must have an
independent copy for each new signature (else there will be an error
later when frame offsets are calculated).

Change-Id: I576942a62f06b46b6f005abc98f65533008de8dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/301670
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/compile: add support for generic channels and type conversion during calls
Dan Scales [Sun, 14 Mar 2021 06:41:51 +0000 (22:41 -0800)]
cmd/compile:  add support for generic channels and type conversion during calls

Add support for channels in subster.typ(). Add new test file chans.go.

To support assignability of bidirectional channel args to directional
channel params, I needed to type check generic calls after they are
instantiated. (Eventually, we will create separate functions to just do
the assignability logic, so we don't need to call the old typechecker in
this case.) So, for generic calls, we now leave the call as OCALL (as a
signal that the call still needs typechecking), and do typecheck.Call()
during stenciling.

Smaller changes:
 - Set the type of an instantiated OCLOSURE node (and not just the associated
   OFUNC node)

 - In instTypeName2, filter out the space that types2.TypeString inserts
   after a common in a typelist. Our standard naming requires no space
   after the comma.

 - With the assignability fix above, I no longer need the explicit
   conversions in cons.go.

Change-Id: I148858bfc6708c0aa3f50bad7debce2b8c8c091f
Reviewed-on: https://go-review.googlesource.com/c/go/+/301669
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agoruntime: prepare arenas for use incrementally
Michael Anthony Knyszek [Mon, 16 Nov 2020 21:57:32 +0000 (21:57 +0000)]
runtime: prepare arenas for use incrementally

This change moves the call of sysMap from (*mheap).sysAlloc into
(*mheap).grow, so we only sysMap what we're going to use in the near
future (thanks to the curArena mechanism). The purpose of this change is
to better support systems with strict overcommit rules which generally
accept reserved memory but not prepared memory (see malloc.go for exact
descriptions of these states).

This move requires changing linearAlloc to only optionally map memory.
In one case, with mheap.heapArenaAlloc, we do want it to map memory. But
now in the other case, with mheap.arena, we don't, because we want grow
to take care of it.

The risk with this change is we may make more syscalls than before on
systems with 64 MiB arenas, but because heap growth is relatively rare
this is unlikely to be a noticable issue. We also bound the amount of
syscalls made by only extending curArena (and thus mapping) by
pallocChunkPages*pageSize which is 4 MiB.

Fixes #42612.

Change-Id: I736df696afe78ddb1a747a896caa0db8726027e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/270537
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>
4 years agoencoding/xml: replace comments inside directives with a space
Filippo Valsorda [Mon, 26 Oct 2020 23:21:30 +0000 (00:21 +0100)]
encoding/xml: replace comments inside directives with a space

A Directive (like <!ENTITY xxx []>) can't have other nodes nested inside
it (in our data structure representation), so there is no way to
preserve comments. The previous behavior was to just elide them, which
however might change the semantic meaning of the surrounding markup.
Instead, replace them with a space which hopefully has the same semantic
effect of the comment.

Directives are not actually a node type in the XML spec, which instead
specifies each of them separately (<!ENTITY, <!DOCTYPE, etc.), each with
its own grammar. The rules for where and when the comments are allowed
are not straightforward, and can't be implemented without implementing
custom logic for each of the directives.

Simply preserving the comments in the body of the directive would be
problematic, as there can be unmatched quotes inside the comment.
Whether those quotes are considered meaningful semantically or not,
other parsers might disagree and interpret the output differently.

This issue was reported by Juho Nurminen of Mattermost as it leads to
round-trip mismatches. See #43168. It's not being fixed in a security
release because round-trip stability is not a currently supported
security property of encoding/xml, and we don't believe these fixes
would be sufficient to reliably guarantee it in the future.

Fixes CVE-2020-29510
Updates #43168

Change-Id: Icd86c75beff3e1e0689543efebdad10ed5178ce3
Reviewed-on: https://go-review.googlesource.com/c/go/+/277893
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
4 years agoencoding/xml: handle leading, trailing, or double colons in names
Filippo Valsorda [Mon, 26 Oct 2020 23:17:15 +0000 (00:17 +0100)]
encoding/xml: handle leading, trailing, or double colons in names

Before this change, <:name> would parse as <name>, which could cause
issues in applications that rely on the parse-encode cycle to
round-trip. Similarly, <x name:=""> would parse as expected but then
have the attribute dropped when serializing because its name was empty.
Finally, <a:b:c> would parse and get serialized incorrectly. All these
values are invalid XML, but to minimize the impact of this change, we
parse them whole into Name.Local.

This issue was reported by Juho Nurminen of Mattermost as it leads to
round-trip mismatches. See #43168. It's not being fixed in a security
release because round-trip stability is not a currently supported
security property of encoding/xml, and we don't believe these fixes
would be sufficient to reliably guarantee it in the future.

Fixes CVE-2020-29509
Fixes CVE-2020-29511
Updates #43168

Change-Id: I68321c4d867305046f664347192948a889af3c7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/277892
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
4 years agonet: use mid-stack inlining with ReadFromUDP to avoid an allocation
Josh Bleecher Snyder [Thu, 11 Feb 2021 18:49:55 +0000 (10:49 -0800)]
net: use mid-stack inlining with ReadFromUDP to avoid an allocation

This commit rewrites ReadFromUDP to be mid-stack inlined
and pass a UDPAddr for lower layers to fill in.

This lets performance-sensitive clients avoid an allocation.
It requires some care on their part to prevent the UDPAddr
from escaping, but it is now possible.
The UDPAddr trivially does not escape in the benchmark,
as it is immediately discarded.

name                  old time/op    new time/op    delta
WriteToReadFromUDP-8    17.2µs ± 6%    17.1µs ± 5%     ~     (p=0.387 n=9+9)

name                  old alloc/op   new alloc/op   delta
WriteToReadFromUDP-8      112B ± 0%       64B ± 0%  -42.86%  (p=0.000 n=10+10)

name                  old allocs/op  new allocs/op  delta
WriteToReadFromUDP-8      3.00 ± 0%      2.00 ± 0%  -33.33%  (p=0.000 n=10+10)

Updates #43451

Co-authored-by: Filippo Valsorda <filippo@golang.org>
Change-Id: I1f9d2ab66bd7e4eff07fe39000cfa0b45717bd13
Reviewed-on: https://go-review.googlesource.com/c/go/+/291509
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Filippo Valsorda <filippo@golang.org>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>