]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
4 years ago[dev.link] all: merge branch 'master' into dev.link
Cherry Zhang [Thu, 30 Apr 2020 16:32:09 +0000 (12:32 -0400)]
[dev.link] all: merge branch 'master' into dev.link

Clean merge.

Change-Id: I9a30645ca0ceb52e45bc6b301f9f15f2f42998e8

4 years ago[dev.link] cmd/link: minor performance tweaks in dodata
Than McIntosh [Wed, 29 Apr 2020 22:46:44 +0000 (18:46 -0400)]
[dev.link] cmd/link: minor performance tweaks in dodata

Tweak doDataSect to reduce symbol sorting overhead, and calculate size
ahead of allocating the ctxt.datap slice. Yields a small speedup
(2-3%) linking kubelet.

Change-Id: I82869f5276caa4bee9f6e6f41da2b240e601ce50
Reviewed-on: https://go-review.googlesource.com/c/go/+/231047
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years ago[dev.link] cmd/link: fold zero symbol check into ResolveABIAlias
Cherry Zhang [Thu, 30 Apr 2020 05:39:18 +0000 (01:39 -0400)]
[dev.link] cmd/link: fold zero symbol check into ResolveABIAlias

We call (or will call) ResolveABIAlias in many places. Doing zero
symbol check everytime is annoying. Fold the condition into
ResolveABIAlias.

Change-Id: I10485fe83b9cce2d19b6bd17dc42176f72dae48b
Reviewed-on: https://go-review.googlesource.com/c/go/+/231046
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years ago[dev.link] cmd/link: pass reloc by value to Adddynrel2
Cherry Zhang [Thu, 30 Apr 2020 05:32:48 +0000 (01:32 -0400)]
[dev.link] cmd/link: pass reloc by value to Adddynrel2

Adddynrel2 is a function pointer. In dynrelocsym we pass &r to
it, which will cause r to escape. Pass it by value instead.

Linking cmd/compile,

name           old alloc/op   new alloc/op   delta
Dodata_GC        15.8MB ± 0%     5.9MB ± 0%  -62.55%  (p=0.008 n=5+5)

Change-Id: Ib86005d1026ebaca57777b27ead037e613585f44
Reviewed-on: https://go-review.googlesource.com/c/go/+/231045
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years ago[dev.link] cmd/link: unescape relocs passed to Archreloc2
Cherry Zhang [Thu, 30 Apr 2020 03:53:33 +0000 (23:53 -0400)]
[dev.link] cmd/link: unescape relocs passed to Archreloc2

Archreloc2 is a function pointer. It will escape its pointer
arguments. In relocsym, as we pass &r and &rr to Archreloc2, it
causes them to escape, even if Archreloc2 is not actually called.

Instead, pass r by value. loader.Reloc2 is a small structure
which is intended to be passed by value.

For rr, as Archreloc2 will likely return true, we speculatively
add it to extRelocs slice and use that space to pass to
Archreloc2.

Linking cmd/compile,

name              old alloc/op   new alloc/op   delta
Dwarfcompress_GC     110MB ± 0%      24MB ± 0%   -78.34%  (p=0.008 n=5+5)
Reloc_GC            24.6MB ± 0%     0.0MB ± 0%  -100.00%  (p=0.029 n=4+4)

Linking cmd/compile using external linking

name              old alloc/op   new alloc/op   delta
Reloc_GC             152MB ± 0%      36MB ± 0%   -76.07%  (p=0.008 n=5+5)

Change-Id: I1415479e0c17ea9787f9a62453dce00ad9ea792f
Reviewed-on: https://go-review.googlesource.com/c/go/+/231077
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years agonet/http/httputil: don't append to X-Forwarded-For in ReverseProxy when nil
Brad Fitzpatrick [Wed, 29 Apr 2020 18:00:23 +0000 (11:00 -0700)]
net/http/httputil: don't append to X-Forwarded-For in ReverseProxy when nil

Fixes #38079

Change-Id: Iac02d7f9574061bb26d1d9a41bb6ee6cc38934e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/230937
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: adopt strong aux typing for some s390x rules
Ruixin Bao [Wed, 29 Apr 2020 23:09:12 +0000 (16:09 -0700)]
cmd/compile: adopt strong aux typing for some s390x rules

Convert the remaining lowering rules to strongly-typed versions.

Passes toolstash-check.
Change-Id: I583786806d55376f5463addab8fec32cb59fa7a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/230939
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/go: use -buildmode=pie as default on window
Alex Brainman [Sun, 26 Apr 2020 00:40:38 +0000 (10:40 +1000)]
cmd/go: use -buildmode=pie as default on window

This change adjusts go command to pass -buildmode=pie to cmd/link,
if -buildmode is not explicitly provided.

Fixes #35192

Change-Id: Iec020131e676eb3e9a2df9eea1929b2af2b6df04
Reviewed-on: https://go-review.googlesource.com/c/go/+/230217
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agolib/time, time/tzdata: update tz data to 2020a
Tobias Klauser [Tue, 28 Apr 2020 06:58:55 +0000 (08:58 +0200)]
lib/time, time/tzdata: update tz data to 2020a

Updates #22487

Change-Id: I691b4c8ced7bfb368f46ade0be46b2ab3f1820dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/230360
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/go: make 'mod verify' use multiple CPUs
Daniel Martí [Fri, 24 Apr 2020 09:53:17 +0000 (10:53 +0100)]
cmd/go: make 'mod verify' use multiple CPUs

'go mod verify' checksums one module zip at a time, which is
CPU-intensive on most modern machines with fast disks. As a result, one
can see a CPU bottleneck when running the command on, for example, a
module where 'go list -m all' lists ~440 modules:

$ /usr/bin/time go mod verify
all modules verified
11.47user 0.77system 0:09.41elapsed 130%CPU (0avgtext+0avgdata 24284maxresident)k
0inputs+0outputs (0major+4156minor)pagefaults 0swaps

Instead, verify up to GOMAXPROCS zips at once, which should line up
pretty well with the amount of processors we can use on a machine. The
results below are obtained via 'benchcmd -n 5 GoModVerify go mod verify'
on the same large module.

name         old time/op         new time/op         delta
GoModVerify          9.35s ± 1%          3.03s ± 2%  -67.60%  (p=0.008 n=5+5)

name         old user-time/op    new user-time/op    delta
GoModVerify          11.2s ± 1%          16.3s ± 3%  +45.38%  (p=0.008 n=5+5)

name         old sys-time/op     new sys-time/op     delta
GoModVerify          841ms ± 9%          865ms ± 8%     ~     (p=0.548 n=5+5)

name         old peak-RSS-bytes  new peak-RSS-bytes  delta
GoModVerify         27.8MB ±13%         50.7MB ±27%  +82.01%  (p=0.008 n=5+5)

The peak memory usage nearly doubles, and there is some extra overhead,
but it seems clearly worth the tradeoff given that we see a ~3x speedup
on my laptop with 4 physical cores. The vast majority of developer
machines nowadays should have 2-4 cores at least.

No test or benchmark is included; one can benchmark 'go mod verify'
directly, as I did above. The existing tests also cover correctness,
including any data races via -race.

Fixes #38623.

Change-Id: I45d8154687a6f3a6a9fb0e2b13da4190f321246c
Reviewed-on: https://go-review.googlesource.com/c/go/+/229817
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: add error for cross-compiled -race builds
Keyan Pishdadian [Tue, 28 Apr 2020 20:06:29 +0000 (20:06 +0000)]
cmd/go: add error for cross-compiled -race builds

Race builds require C dependencies, but cross-compiled cgo builds are
not always possible, so don't suggest enabling CGO in those cases.

Fixes #37021

Change-Id: I1fd675efc9cef958a926bd63eac8e6858bc59d0a
GitHub-Last-Rev: cbf43c1bbb0f209474cc323b3813cf270a2ba0a8
GitHub-Pull-Request: golang/go#38670
Reviewed-on: https://go-review.googlesource.com/c/go/+/230202
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/cover: include a package name in the HTML title
Rob Pike [Tue, 28 Apr 2020 15:45:59 +0000 (01:45 +1000)]
cmd/cover: include a package name in the HTML title

A recent change added a title to the HTML coverage report but
neglected to include the package name. Add the package name here.
It's a little trickier than you'd think because there may be multiple
packages and we don't want to parse the files, so we just extract
a directory name from the path of the first file.  This will almost
always be right, and has the advantage that it gives a better result
for package main. There are rare cases it will get wrong, but that
will be no hardship.

If this turns out not to be good enough, we can refine it.

Fixes #38609

Change-Id: I2201f6caef906e0b0258b90d7de518879041fe72
Reviewed-on: https://go-review.googlesource.com/c/go/+/230517
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agostrconv: implement parseFloatPrefix returning no. of bytes consumed
Robert Griesemer [Tue, 28 Apr 2020 23:54:44 +0000 (16:54 -0700)]
strconv: implement parseFloatPrefix returning no. of bytes consumed

parseFloatPrefix will make it easier to implement ParseComplex.

Verified that there's no relevant performance impact:
Benchmarks run on a "quiet" MacBook Pro, 3.3GHz Dual-Core Intel Core i7,
with 16GB 2133MHz LPDDR3 RAM running macOS 10.15.4.

name                  old time/op  new time/op  delta
Atof64Decimal-4       38.2ns ± 4%  38.4ns ± 3%    ~     (p=0.802 n=5+5)
Atof64Float-4         41.1ns ± 3%  43.0ns ± 1%  +4.77%  (p=0.008 n=5+5)
Atof64FloatExp-4      71.9ns ± 3%  70.1ns ± 1%    ~     (p=0.063 n=5+5)
Atof64Big-4            124ns ± 5%   119ns ± 0%    ~     (p=0.143 n=5+4)
Atof64RandomBits-4    57.2ns ± 1%  55.7ns ± 2%  -2.66%  (p=0.016 n=4+5)
Atof64RandomFloats-4  56.8ns ± 1%  56.9ns ± 4%    ~     (p=0.556 n=4+5)
Atof32Decimal-4       35.4ns ± 5%  35.9ns ± 0%    ~     (p=0.127 n=5+5)
Atof32Float-4         39.6ns ± 7%  40.3ns ± 1%    ~     (p=0.135 n=5+5)
Atof32FloatExp-4      73.7ns ± 7%  71.9ns ± 0%    ~     (p=0.175 n=5+4)
Atof32Random-4         103ns ± 6%    98ns ± 2%  -5.03%  (p=0.008 n=5+5)

Updates #36771.

Change-Id: I8ff66b582ae8b468d89c9ffc35c569c735cf0341
Reviewed-on: https://go-review.googlesource.com/c/go/+/230737
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agosyscall: on linux-arm64, prefer prlimit to {g,s}etrlimit
Ian Lance Taylor [Tue, 28 Apr 2020 00:43:35 +0000 (17:43 -0700)]
syscall: on linux-arm64, prefer prlimit to {g,s}etrlimit

Reportedly some Docker images accept the prlimit64 system call,
used by syscall.prlimit, but prohibit the getrlimit and setrlimit
system calls.

Fixes #38604

Change-Id: I91ff9370450b4869098cc8e335bbb7b863060508
Reviewed-on: https://go-review.googlesource.com/c/go/+/230339
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
4 years ago[dev.link] cmd/link: remove sym.Symbols.Newsym
Cherry Zhang [Wed, 29 Apr 2020 21:53:40 +0000 (17:53 -0400)]
[dev.link] cmd/link: remove sym.Symbols.Newsym

No longer needed.

Change-Id: If259a956bc8edb2eb94583b06840b52344cb84be
Reviewed-on: https://go-review.googlesource.com/c/go/+/231037
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years ago[dev.link] cmd/link: combine decodesym.go and decodesym2.go
Cherry Zhang [Wed, 29 Apr 2020 21:34:46 +0000 (17:34 -0400)]
[dev.link] cmd/link: combine decodesym.go and decodesym2.go

And remove "2" from some function names.

Change-Id: Ibf1089970d849a42f53976064ceb9ade20bf6eba
Reviewed-on: https://go-review.googlesource.com/c/go/+/231017
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years agodebug/gosym: correct comments for Table.{Files,Objs}
Ian Lance Taylor [Thu, 30 Apr 2020 02:47:34 +0000 (19:47 -0700)]
debug/gosym: correct comments for Table.{Files,Objs}

The fields aren't too useful for Go 1.2 and later, but they aren't
actually nil.

Fixes #38754

Change-Id: Ia13a224f623697a00dea8ba0225633e1b9308c9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/230940
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agoRevert "cmd/compile: omit file:pos for non-existent, permission errors"
Austin Clements [Thu, 30 Apr 2020 01:40:37 +0000 (01:40 +0000)]
Revert "cmd/compile: omit file:pos for non-existent, permission errors"

This reverts commit 4f7053c87f9ebf3acab7669d380f53bdfba0566b.

Reason for revert: Newly added test is failing on several builders.

Change-Id: I22dcbfebf2f57735b2f479886bbeb623f95b132f
Reviewed-on: https://go-review.googlesource.com/c/go/+/231043
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: omit file:pos for non-existent, permission errors
Emmanuel T Odeke [Wed, 22 Apr 2020 06:31:59 +0000 (23:31 -0700)]
cmd/compile: omit file:pos for non-existent, permission errors

Omits printing the file:line:column when trying to open either
* non-existent files
* files without permission

Given:
    go tool compile x.go

For either of x.go not existing, or if no read permissions:

* Before:
    x.go:0: open x.go: no such file or directory
    x.go:0: open x.go: permission denied

* After:
    open x.go: no such file or directory
    open x.go: permission denied

While here, noticed an oddity with the Linux builders, that appear
to always be running under root, hence the test for permission errors
with 0222 -W-*-W-*-W- can't pass on linux-amd64 builders.
The filed bug is #38608.

Fixes #36437

Change-Id: I9645ef73177c286c99547e3a0f3719fa07b35cb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/229357
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agoruntime: move condition into wakep
Austin Clements [Wed, 29 Apr 2020 00:54:31 +0000 (20:54 -0400)]
runtime: move condition into wakep

All five calls to wakep are protected by the same check of nmidle and
nmspinning. Move this check into wakep.

Change-Id: I2094eec211ce551e462e87614578f37f1896ba38
Reviewed-on: https://go-review.googlesource.com/c/go/+/230757
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agomath: Add a function example
kakulisen [Wed, 29 Apr 2020 07:43:11 +0000 (15:43 +0800)]
math: Add a function example

When I browsed the source code, I saw that there is no corresponding example of this function. I am not sure if there is a need for an increase, this is my first time to submit CL.

Change-Id: Idbf4e1e1ed2995176a76959d561e152263a2fd26
Reviewed-on: https://go-review.googlesource.com/c/go/+/230741
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agonet/http/cgi: replace constant map with switch statement
Matthew Dempsky [Wed, 29 Apr 2020 23:45:05 +0000 (16:45 -0700)]
net/http/cgi: replace constant map with switch statement

The switch statement can be statically optimized by the compiler,
whereas similarly optimizing the map index expression would require
additional compiler analysis to detect the map is never mutated.

Updates #10848.

Change-Id: I2fc70d4a34dc545677b99f218b51023c7891bbbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/231041
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: move last of the generic rules to typed aux
Keith Randall [Wed, 29 Apr 2020 22:15:37 +0000 (15:15 -0700)]
cmd/compile: move last of the generic rules to typed aux

Change-Id: I1193fff570ff2917979e5cb610fb14c3b347aa92
Reviewed-on: https://go-review.googlesource.com/c/go/+/230938
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile,runtime: stack maps only at calls, remove register maps
Austin Clements [Thu, 16 Apr 2020 12:13:58 +0000 (08:13 -0400)]
cmd/compile,runtime: stack maps only at calls, remove register maps

Currently, we emit stack maps and register maps at almost every
instruction. This was originally intended to support non-cooperative
preemption, but was only ever used for debug call injection. Now debug
call injection also uses conservative frame scanning. As a result,
stack maps are only needed at call sites and register maps aren't
needed at all except that we happen to also encode unsafe-point
information in the register map PCDATA stream.

This CL reduces stack maps to only appear at calls, and replace full
register maps with just safe/unsafe-point information.

This is all protected by the go115ReduceLiveness feature flag, which
is defined in both runtime and cmd/compile.

This CL significantly reduces binary sizes and also speeds up compiles
and links:

name                      old exe-bytes     new exe-bytes     delta
BinGoSize                      15.0MB ± 0%       14.1MB ± 0%   -5.72%

name                      old pcln-bytes    new pcln-bytes    delta
BinGoSize                      3.14MB ± 0%       2.48MB ± 0%  -21.08%

name                      old time/op       new time/op       delta
Template                        178ms ± 7%        172ms ±14%  -3.59%  (p=0.005 n=19+19)
Unicode                        71.0ms ±12%       69.8ms ±10%    ~     (p=0.126 n=18+18)
GoTypes                         655ms ± 8%        615ms ± 8%  -6.11%  (p=0.000 n=19+19)
Compiler                        3.27s ± 6%        3.15s ± 7%  -3.69%  (p=0.001 n=20+20)
SSA                             7.10s ± 5%        6.85s ± 8%  -3.53%  (p=0.001 n=19+20)
Flate                           124ms ±15%        116ms ±22%  -6.57%  (p=0.024 n=18+19)
GoParser                        156ms ±26%        147ms ±34%    ~     (p=0.070 n=19+19)
Reflect                         406ms ± 9%        387ms ±21%  -4.69%  (p=0.028 n=19+20)
Tar                             163ms ±15%        162ms ±27%    ~     (p=0.370 n=19+19)
XML                             223ms ±13%        218ms ±14%    ~     (p=0.157 n=20+20)
LinkCompiler                    503ms ±21%        484ms ±23%    ~     (p=0.072 n=20+20)
ExternalLinkCompiler            1.27s ± 7%        1.22s ± 8%  -3.85%  (p=0.005 n=20+19)
LinkWithoutDebugCompiler        294ms ±17%        273ms ±11%  -7.16%  (p=0.001 n=19+18)

(https://perf.golang.org/search?q=upload:20200428.8)

The binary size improvement is even slightly better when you include
the CLs leading up to this. Relative to the parent of "cmd/compile:
mark PanicBounds/Extend as calls":

name                      old exe-bytes     new exe-bytes     delta
BinGoSize                      15.0MB ± 0%       14.1MB ± 0%   -6.18%

name                      old pcln-bytes    new pcln-bytes    delta
BinGoSize                      3.22MB ± 0%       2.48MB ± 0%  -22.92%

(https://perf.golang.org/search?q=upload:20200428.9)

For #36365.

Change-Id: I69448e714f2a44430067ca97f6b78e08c0abed27
Reviewed-on: https://go-review.googlesource.com/c/go/+/230544
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: make LivenessMap sparse
Austin Clements [Mon, 27 Apr 2020 23:18:48 +0000 (19:18 -0400)]
cmd/compile: make LivenessMap sparse

We're about to switch to having significantly fewer maps in the
liveness map, so switch from a dense representation to a sparse
representation.

Passes toolstash-check.

For #36365.

Change-Id: Icb17bd6ace17667a280bc5fba4039cae3020a8d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/230543
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agocmd/compile: don't emit stack maps for write barrier calls
Austin Clements [Tue, 28 Apr 2020 00:42:00 +0000 (20:42 -0400)]
cmd/compile: don't emit stack maps for write barrier calls

These are necessarily deeply non-preemptible, so there's no point in
emitting stack maps for them. We already mark them as unsafe points,
so this only affects the runtime, since user code does not emit stack
maps at unsafe points. SSAGenState.PrepareCall also excludes them when
it's sanity checking call stack maps.

Right now this only drops a handful of unnecessary stack maps from the
runtime, but we're about to start emitting stack maps only at calls
for user code, too. At that point, this will matter much more.

For #36365.

Change-Id: Ib3abfedfddc8e724d933a064fa4d573500627990
Reviewed-on: https://go-review.googlesource.com/c/go/+/230542
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: fix unsafe-points with stack maps
Austin Clements [Tue, 21 Apr 2020 18:23:04 +0000 (14:23 -0400)]
cmd/compile: fix unsafe-points with stack maps

The compiler currently conflates whether a Value has a stack map with
whether it's an unsafe point. For the most part, unsafe-points don't
have stack maps, so this is mostly fine, but call instructions can be
both an unsafe-point *and* have a stack map. For example, none of the
instructions in a nosplit function should be preemptible, but calls
must still have stack maps in case the called function grows the stack
or get preempted.

Currently, the compiler can't distinguish this case, so calls in
nosplit functions are marked as safe-points just because they have
stack maps. This is particularly problematic if a nosplit function
calls another nosplit function, since this can introduce a preemption
point where there should be none.

We realized this was a problem for split-stack prologues a while back,
and CL 207349 changed the encoding of unsafe-points to use the
register map index instead of the stack map index so we could record
both a stack map and an unsafe-point at the same instruction. But this
was never extended into the compiler.

This CL fixes this problem in the compiler. We make LivenessIndex
slightly more abstract by separating unsafe-point marks from stack and
register map indexes. We map this to the PCDATA encoding later when
producing Progs. This isn't enough to fix the whole problem for
nosplit functions, because obj still adds prologues and marks those as
preemptible, but it's a step in the right direction.

I checked this CL by comparing maps before and after this change in
the runtime and net/http. In net/http, unsafe-points match exactly; at
anything that isn't an unsafe-point, both the stack and register maps
are unchanged by this CL. In the runtime, at every point that was a
safe-point before this change, the stack maps agree (and mostly the
runtime doesn't have register maps at all now). In both, all CALLs
(except write barrier calls) have stack maps.

For #36365.

Change-Id: I066628938b02e78be5c81a6614295bcf7cc566c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/230541
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: rename issafepoint -> hasStackMap
Austin Clements [Fri, 17 Apr 2020 21:14:33 +0000 (17:14 -0400)]
cmd/compile: rename issafepoint -> hasStackMap

Currently, this function conflates two (easily conflated!) concepts:
whether a Value is a safe-point and whether it has a stack map. In
particular, call Values may not be a safe-point, but may need a stack
map anyway in case the called function grows the stack.

Hence, rename this function to "hasStackMap", since that's really what
it represents.

For #36365.

Change-Id: I89839de0be8db3be3f0d3a7fb5fcf0b0b6ebc98a
Reviewed-on: https://go-review.googlesource.com/c/go/+/230540
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: mark PanicBounds/Extend as calls
Austin Clements [Mon, 27 Apr 2020 19:58:16 +0000 (15:58 -0400)]
cmd/compile: mark PanicBounds/Extend as calls

PanicBounds and PanicExtend are lowered to runtime calls (with a
non-Go ABI), but are not currently marked as calls. Since liveness
analysis only emits stack maps at calls in the runtime, this means
these panic call sites in the runtime won't get a stack map. These
almost immediately turn into throws in the runtime, but there's still
a chance they'll try to grow the stack first, which would lead to a
different panic.

To fix this, mark these operations as calls.

Outside the runtime, we currently emit stack maps for everything that
isn't an unsafe-point, so these panic calls get stack maps by default.
However, we're about to move to emitting stack maps only at call
sites, at which point this will start to matter outside the runtime as
well.

I confirmed that this has no effect on anything but PCDATA/FUNCDATA in
runtime and net/http.

For #36365.

Change-Id: Ic5bb463fd152cc320c815dc04cf62005261ae169
Reviewed-on: https://go-review.googlesource.com/c/go/+/230539
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: use conservative scanning for debug calls
Austin Clements [Wed, 15 Apr 2020 19:44:57 +0000 (15:44 -0400)]
runtime: use conservative scanning for debug calls

A debugger can inject a call at almost any PC, which causes
significant complications with stack scanning and growth. Currently,
the runtime solves this using precise stack maps and register maps at
nearly all PCs, but these extra maps require roughly 5% of the binary.
These extra maps were originally considered worth this space because
they were intended to be used for non-cooperative preemption, but are
now used only for debug call injection.

This CL switches from using precise maps to instead using conservative
frame scanning, much like how non-cooperative preemption works. When a
call is injected, the runtime flushes all potential pointer registers
to the stack, and then treats that frame as well as the interrupted
frame conservatively.

The limitation of conservative frame scanning is that we cannot grow
the goroutine stack. That's doable because the previous CL switched to
performing debug calls on a new goroutine, where they are free to grow
the stack.

With this CL, there are no remaining uses of precise register maps
(though we still use the unsafe-point information that's encoded in
the register map PCDATA stream), and stack maps are only used at call
sites.

For #36365.

Change-Id: Ie217b6711f3741ccc437552d8ff88f961a73cee0
Reviewed-on: https://go-review.googlesource.com/c/go/+/229300
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: perform debug call injection on a new goroutine
Austin Clements [Wed, 15 Apr 2020 19:38:00 +0000 (15:38 -0400)]
runtime: perform debug call injection on a new goroutine

Currently, when a debugger injects a call, that call happens on the
goroutine where the debugger injected it. However, this requires
significant runtime complexity that we're about to remove.

To prepare for this, this CL switches to a different approach that
leaves the interrupted goroutine parked and runs the debug call on a
new goroutine. When the debug call returns, it resumes the original
goroutine.

This should be essentially transparent to debuggers. It follows the
exact same call injection protocol and ensures the whole protocol
executes indivisibly on a single OS thread. The only difference is
that the current G and stack now change part way through the protocol.

For #36365.

Change-Id: I68463bfd73cbee06cfc49999606410a59dd8f653
Reviewed-on: https://go-review.googlesource.com/c/go/+/229299
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: make newproc1 not start the goroutine
Austin Clements [Wed, 15 Apr 2020 17:56:05 +0000 (13:56 -0400)]
runtime: make newproc1 not start the goroutine

Currently, newproc1 allocates, initializes, and schedules a new
goroutine. We're about to change debug call injection in a way that
will need to create a new goroutine without immediately scheduling it.
To prepare for that, make scheduling the responsibility of newproc1's
caller. Currently, there's exactly one caller (newproc), so this
simply shifts that responsibility.

For #36365.

Change-Id: Idacd06b63e738982e840fe995d891bfd377ce23b
Reviewed-on: https://go-review.googlesource.com/c/go/+/229298
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime/pprof: fix units of MaxRSS on Linux
Austin Clements [Wed, 29 Apr 2020 19:06:21 +0000 (15:06 -0400)]
runtime/pprof: fix units of MaxRSS on Linux

Rusage.Maxrss is in bytes on Darwin but in KiB on Linux. Fix this
discrepancy so it's always in bytes.

Change-Id: Ic714abc3276566b8fe5e30565072092212610854
Reviewed-on: https://go-review.googlesource.com/c/go/+/230979
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years agoruntime: fix debuglog traceback printing off-by-one
Austin Clements [Wed, 7 Aug 2019 01:37:37 +0000 (21:37 -0400)]
runtime: fix debuglog traceback printing off-by-one

The debuglog traceback printer wasn't adjusting for call/return PCs.

Change-Id: I98dda1c0f22cd78651d88124ea51dc166dc91c7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/227646
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agocmd/compile: convert CCop arm64 rules to typed aux
Alberto Donizetti [Wed, 29 Apr 2020 12:43:39 +0000 (14:43 +0200)]
cmd/compile: convert CCop arm64 rules to typed aux

Passes

  GOARCH=arm64 gotip build -toolexec 'toolstash -cmp' -a std

Change-Id: Id88141dfc0dfb02c3e958e48ab4adfbac7ba1380
Reviewed-on: https://go-review.googlesource.com/c/go/+/230837
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agobytes, strings: align requirements for functions passed to FieldFuncs
Martin Möhrmann [Wed, 29 Apr 2020 10:23:32 +0000 (12:23 +0200)]
bytes, strings: align requirements for functions passed to FieldFuncs

golang.org/cl/229763 removed the documentation of requirements of
the function passed to FieldsFunc. The current implementation does
not require functions to return consistent results but this had not
been the case for previous implementations.

Add the requirement for consistent results back to the documentation
to allow for future implementations to be more allocation efficient
for an output with more than 32 fields. This is possible with a two
pass algorithm first determining the number of fields used to allocate
the output slice and then splitting the input into fields.

While at it align the documentation of bytes.FieldsFunc with
strings.FieldFunc.

Fixes #38630

Change-Id: Iabbf9ca3dff0daa41f4ec930a21a3dd98e19f122
Reviewed-on: https://go-review.googlesource.com/c/go/+/230797
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/go: trim source paths when compiling C with -trimpath
Jay Conrod [Thu, 19 Dec 2019 18:43:24 +0000 (13:43 -0500)]
cmd/go: trim source paths when compiling C with -trimpath

When then go command is run with -trimpath, it will now use
-fdebug-prefix-map when invoking the C compiler (if supported) to
replace the source root directory with a dummy root directory.

This should prevent source directories from appearing either literally
or in compressed DWARF in linked binaries.

Updates #36072

Change-Id: Iedd08d5e886f81e981f11248a1be4ed4f58bdd29
Reviewed-on: https://go-review.googlesource.com/c/go/+/212101
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agogo/ast: drop //directive comments from doc.Text
Russ Cox [Sat, 21 Mar 2020 12:23:13 +0000 (08:23 -0400)]
go/ast: drop //directive comments from doc.Text

This allows writing

// F does a thing.
//go:noinline
func F()

without the //go:noinline or other directive (such as //line)
ending up looking like extra words in the doc comment.

Fixes #37974.

Change-Id: Ic738d72802cc2fa448f7633915e7126d2f76d8ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/224737
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/go/internal/modload: use lockedfile to read path-replacement go.mod files
Richard Miller [Wed, 29 Apr 2020 10:20:28 +0000 (11:20 +0100)]
cmd/go/internal/modload: use lockedfile to read path-replacement go.mod files

When parsing go.mod files found via file-path replacements, it's safer to
use lockedfile.Read instead of ioutil.ReadFile, in case of overwriting by
other concurrent go commands.

Change-Id: I7dcac3bb5ada84bee1eb634b39f813c461ef103a
Reviewed-on: https://go-review.googlesource.com/c/go/+/230838
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>

4 years agocrypto/x509/pkix: improve docs and Name.String()
Katie Hockman [Fri, 24 Apr 2020 15:55:21 +0000 (11:55 -0400)]
crypto/x509/pkix: improve docs and Name.String()

Previously, non-standard attributes in Name.Names were being
omitted when printed using Name.String(). Now, any non-standard
attributes that would not already be printed in Name.String()
are being added temporarily to Name.ExtraNames to be printed.

Fixes #33094
Fixes #23069

Change-Id: Id9829c20968e16db7194549f69c0eb5985044944
Reviewed-on: https://go-review.googlesource.com/c/go/+/229864
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
4 years ago[dev.link] cmd/link: use new reloc on Wasm
Cherry Zhang [Wed, 29 Apr 2020 18:24:30 +0000 (14:24 -0400)]
[dev.link] cmd/link: use new reloc on Wasm

Change-Id: Icf4d075b64340964068ed038911a14194d241960
Reviewed-on: https://go-review.googlesource.com/c/go/+/230977
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocrypto/ed25519: drop the purego build tag
Ruixin Bao [Tue, 28 Apr 2020 21:06:48 +0000 (17:06 -0400)]
crypto/ed25519: drop the purego build tag

Per suggestion in CL 202578, this CL drops the purego build tag used
within this package.

Change-Id: I33626c73d6602e321528544ee601741f7e634c1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/230677
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Michael Munday <mike.munday@ibm.com>

4 years agocmd/asm: update ppc64enc.s testcase
Lynn Boger [Tue, 28 Apr 2020 12:03:47 +0000 (08:03 -0400)]
cmd/asm: update ppc64enc.s testcase

Adds a few instructions to ppc64enc.s that were missing from the
previous update.

Change-Id: Ieafce39e905cdf4da3bfb00fdd5a39ab28089cb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/230437
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years ago[dev.link] cmd/link: free compressed symbols after dwarfcompress
Cherry Zhang [Tue, 28 Apr 2020 05:08:12 +0000 (01:08 -0400)]
[dev.link] cmd/link: free compressed symbols after dwarfcompress

Once the symbol is compressed, we will not need the uncompressed
symbol content. Free its memory.

Linking cmd/compile,

name               old live-B     new live-B     delta
Dwarfcompress_GC      42.7M ± 0%     37.9M ± 0%   -11.31%  (p=0.008 n=5+5)

Change-Id: Ib6cc73832946d158ff4f5b4f31be9c35ba7cf103
Reviewed-on: https://go-review.googlesource.com/c/go/+/230859
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years ago[dev.link] cmd/link: add loader.ExtReloc to Archreloc2
Jeremy Faller [Wed, 29 Apr 2020 16:20:38 +0000 (12:20 -0400)]
[dev.link] cmd/link: add loader.ExtReloc to Archreloc2

Non functional, but required by the majority of the architectures.

Change-Id: I57601016c28ce665a9d434e283a1db8bded9b133
Reviewed-on: https://go-review.googlesource.com/c/go/+/230858
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: convert constant divide strength reduction rules to typed aux
Keith Randall [Wed, 29 Apr 2020 02:28:43 +0000 (19:28 -0700)]
cmd/compile: convert constant divide strength reduction rules to typed aux

Passes toolstash-check.

Change-Id: Ia5d11c099b8c6c0ed670960b2af808200e3b1ca1
Reviewed-on: https://go-review.googlesource.com/c/go/+/230739
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years ago[dev.link] cmd/link: free loader memory after LoadFull
Cherry Zhang [Tue, 28 Apr 2020 22:59:57 +0000 (18:59 -0400)]
[dev.link] cmd/link: free loader memory after LoadFull

After LoadFull, we'll be using sym.Symbols mostly. We still need
the loader information for symbol index mappings and name
lookups, but not much else. Free some memory.

Linking cmd/compile,

name           old time/op    new time/op    delta
Loadlibfull_GC    44.5M ± 0%     35.8M ± 0%    -19.66%  (p=0.008 n=5+5)
Archive_GC        46.4M ± 0%     37.6M ± 0%    -18.89%  (p=0.008 n=5+5)

Linking cmd/compile with external linking,

name           old time/op    new time/op    delta
Loadlibfull_GC    82.5M ± 0%     57.4M ± 0%    -30.41%  (p=0.008 n=5+5)
Archive_GC        86.8M ± 0%     61.7M ± 0%    -28.90%  (p=0.008 n=5+5)

Change-Id: I6859d488172ef8968918b86de527fbfed6832ebf
Reviewed-on: https://go-review.googlesource.com/c/go/+/230300
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years ago[dev.link] cmd/link: fix R_GOTOFF handling
Cherry Zhang [Wed, 29 Apr 2020 14:07:07 +0000 (10:07 -0400)]
[dev.link] cmd/link: fix R_GOTOFF handling

When applying relocations, we need to resolve ABI aliases.
relocsym does that. Architecture-specific archreloc also needs to
do that. The old code doesn't do that since ABI aliases are
resolved in loadlibfull, or, in the old linker, in a much earlier
stage. We don't do this in the new linker, as we want to avoid
mutating relocations.

While here, move R_CONST and R_GOTOFF handling to generic code.
They appear on several architectures and the handling are same.

Should fix 386-clang and *bsd-386 builds.

Change-Id: I6681c94f0327555d6cf329d0a518c88848773671
Reviewed-on: https://go-review.googlesource.com/c/go/+/230857
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years ago[dev.link] cmd/link: support external linking in new reloc implementation
Cherry Zhang [Sun, 26 Apr 2020 05:42:55 +0000 (01:42 -0400)]
[dev.link] cmd/link: support external linking in new reloc implementation

Support external linking for the new reloc pass as well, and
enable it on AMD64 and 386.

Change-Id: Ia71aec3d7c14e9d661e0748d2e988f29f220d1e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/230308
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years ago[dev.link] cmd/link: remove Sub field from sym.Symbol
Than McIntosh [Tue, 28 Apr 2020 19:25:54 +0000 (15:25 -0400)]
[dev.link] cmd/link: remove Sub field from sym.Symbol

Remove 'Sub' field from sym.Symbol, replacing uses (those downstream of
loadlibfull) with loader method calls.

NB: removing the Outer field will have to wait for now; it is accessed
in archreloc methods that don't have access to link ctxt or loader
currently.

Change-Id: I2abe5906fc169c64b2ab7d5ad213619bea5a17c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/230617
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile,cmd/internal/obj/ppc64: use mod instructions on power9
Lynn Boger [Thu, 23 Apr 2020 19:36:28 +0000 (15:36 -0400)]
cmd/compile,cmd/internal/obj/ppc64: use mod instructions on power9

This updates the PPC64.rules file to use the MOD instructions
that are available in power9. Prior to power9 this is done
using a longer sequence with multiply and divide.

Included in this change is removal of the REM* opcode variations
that set the CC or OV bits since their settings are based
on the DIV and are not appropriate for the REM.

Change-Id: Iceed9ce33e128e1911c15592ee674276ce8ba3fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/229761
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoimage: guard against NewXxx integer overflow
Nigel Tao [Mon, 27 Apr 2020 23:32:00 +0000 (09:32 +1000)]
image: guard against NewXxx integer overflow

Prior to this commit, NewXxx could panic when passed an image.Rectangle
with one of width or height being negative. But it might not panic if
both were negative, because (bpp * w * h) could still be positive. After
this commit, it will panic if both are negative.

With overflow, NewXxx might not have panicked if (bpp * w * h), the
length passed to "make([]uint8, length)", was still non-negative (after
truncation), but even if w and h were valid (non-negative), the overall
byte slice wasn't long enough. Iterating over the pixels would possibly
panic later with index out of bounds. This change moves the panic
earlier, closer to where the mistake is.

Change-Id: I011feb2d53515fc3f0fe72bb6c23b3953772c577
Reviewed-on: https://go-review.googlesource.com/c/go/+/230220
Reviewed-by: Rob Pike <r@golang.org>
4 years ago[dev.link] all: merge branch 'master' into dev.link
Than McIntosh [Wed, 29 Apr 2020 11:40:05 +0000 (07:40 -0400)]
[dev.link] all: merge branch 'master' into dev.link

Change-Id: Ied39f4f701a2e64b87262f7cc34108a60b15e08c

4 years agoimage/jpeg: accept "\xff\x00" before a RST marker
Nigel Tao [Tue, 28 Apr 2020 12:33:02 +0000 (22:33 +1000)]
image/jpeg: accept "\xff\x00" before a RST marker

Fixes #28717

Change-Id: I0a1e4ef1583fff89b6f46ef647fb6e4499bdf999
Reviewed-on: https://go-review.googlesource.com/c/go/+/230122
Run-TryBot: Nigel Tao <nigeltao@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agoimage: add a NewUniform doc comment
Nigel Tao [Wed, 29 Apr 2020 04:55:07 +0000 (14:55 +1000)]
image: add a NewUniform doc comment

Fixes #38739

Change-Id: I42b9b601e63ab8df69a0e5ce9bcabf75bb98d83e
Reviewed-on: https://go-review.googlesource.com/c/go/+/230777
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: adopt strong aux typing for some s390x rules
Ruixin Bao [Wed, 29 Apr 2020 01:19:17 +0000 (18:19 -0700)]
cmd/compile: adopt strong aux typing for some s390x rules

Convert some optimizations rules to strongly-typed versions. Similar to
CL 230338, this CL only converts rules that need no additional changes
(i.e: only need to change '->' to '=>').

This CL covers the rules from line 800 - 1219.

Passes toolstash-check

Change-Id: I94181a809fa38918b78301f1c0c680b7a8ab552f
Reviewed-on: https://go-review.googlesource.com/c/go/+/230738
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: adjust MIPS64x rewrite rules to use typed aux fields
Meng Zhuo [Mon, 20 Apr 2020 10:43:29 +0000 (18:43 +0800)]
cmd/compile: adjust MIPS64x rewrite rules to use typed aux fields

Pass toolstash-check

Change-Id: I673c9a24bf69c09573be5aeddbd6072ef35d2d83
Reviewed-on: https://go-review.googlesource.com/c/go/+/228937
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years ago[dev.link] cmd/link: add archrelocsym x86 support for loader
Jeremy Faller [Tue, 28 Apr 2020 21:28:52 +0000 (17:28 -0400)]
[dev.link] cmd/link: add archrelocsym x86 support for loader

Change-Id: I34822e5610caf537d62203fb6e0023c382a1e60a
Reviewed-on: https://go-review.googlesource.com/c/go/+/230678
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years ago[dev.link] cmd/link: convert reloc pass to using the loader when internal linking
Cherry Zhang [Sun, 26 Apr 2020 02:08:50 +0000 (22:08 -0400)]
[dev.link] cmd/link: convert reloc pass to using the loader when internal linking

Only enabled for AMD64 when internal linking for now.

Change-Id: I2aa9ee47c0f7413ea7bbcdd31b8317c14220bba3
Reviewed-on: https://go-review.googlesource.com/c/go/+/230302
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agonet: add (*Resolver).LookupIP
Ian Gudger [Fri, 17 Apr 2020 11:04:23 +0000 (04:04 -0700)]
net: add (*Resolver).LookupIP

Previously, looking up only IPv4 or IPv6 addresses was only possible
with DefaultResolver via ResolveIPAddr. Add this functionality to the
Resolver type with a new method, LookupIP. This largely brings Resolver
functionally to parity with the global functions. The name LookupIP is
used over ResolveIPAddr to be consistent with the other Resolver
methods.

There are two main benefits to (*Resolver).LookupIP over
(*Resolver).LookupHost. First is an ergonomic benefit. Wanting a
specific family of address is common enough to justify a method, evident
by the existence of ResolveIPAddr. Second, this opens the possibility of
not performing unnecessary DNS requests when only a specific family of
addresses are needed. This optimization is left to follow up work.

Updates #30452

Change-Id: I241f61019588022a39738f8920b0ddba900cecdd
Reviewed-on: https://go-review.googlesource.com/c/go/+/228641
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agoreflect: reduce allocations for Select with up to 4 cases
Martin Möhrmann [Tue, 28 Apr 2020 19:58:46 +0000 (21:58 +0200)]
reflect: reduce allocations for Select with up to 4 cases

Allocate the runcases slice on the stack if the number
of select cases is small (up to 4).

Found while looking at production profiles of common
proto based RPC server framework code in Google which do
not have a large number of cases.

name      old time/op    new time/op    delta
Select/1     147ns ± 2%     120ns ± 6%  -18.32%  (p=0.000 n=7+10)
Select/4     316ns ± 5%     249ns ± 2%  -21.23%  (p=0.000 n=10+10)
Select/8     516ns ± 3%     515ns ± 3%     ~     (p=0.858 n=10+9)

name      old alloc/op   new alloc/op   delta
Select/1     96.0B ± 0%     64.0B ± 0%  -33.33%  (p=0.000 n=10+10)
Select/4      336B ± 0%      208B ± 0%  -38.10%  (p=0.000 n=10+10)
Select/8      672B ± 0%      672B ± 0%     ~     (all equal)

name      old allocs/op  new allocs/op  delta
Select/1      4.00 ± 0%      3.00 ± 0%  -25.00%  (p=0.000 n=10+10)
Select/4      7.00 ± 0%      6.00 ± 0%  -14.29%  (p=0.000 n=10+10)
Select/8      11.0 ± 0%      11.0 ± 0%     ~     (all equal)

Change-Id: I1687e74fc8e86606a27f03fa8a561bcfb68775d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/230657
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agodatabase/sql: document Connect and Close may need a timeout
Daniel Theophanes [Tue, 28 Apr 2020 14:31:12 +0000 (07:31 -0700)]
database/sql: document Connect and Close may need a timeout

Opening a connection with Connect should still create a derived
context with a timeout because some clients will not use a timeout
and the connection pool may open a connection asynchronously.

Likewise, if a connection close makes a network operation it should
provide some type of sane timeout for the operation.

Fixes #38185

Change-Id: I9b7ce2996c81c486170dcc84b12672a99610fa27
Reviewed-on: https://go-review.googlesource.com/c/go/+/230438
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agostrings: simpler and slightly faster implementation of FieldsFunc
Robert Griesemer [Fri, 24 Apr 2020 05:17:58 +0000 (22:17 -0700)]
strings: simpler and slightly faster implementation of FieldsFunc

Removed the need for maintaining an extra variable in one of the inner loops,
leading to a slight speed-up for short strings.

Benchmarks run on a "quiet" MacBook Pro, 3.3GHz Dual-Core Intel Core i7,
with 16GB 2133MHz LPDDR3 RAM running macOS 10.15.4.

name                        old time/op    new time/op    delta
FieldsFunc/ASCII/16-4          147ns ± 0%     144ns ± 1%  -2.04%  (p=0.000 n=4+5)
FieldsFunc/ASCII/256-4        1.63µs ± 0%    1.59µs ± 1%  -2.50%  (p=0.008 n=5+5)
FieldsFunc/ASCII/4096-4       30.0µs ± 0%    29.3µs ± 2%    ~     (p=0.190 n=4+5)
FieldsFunc/ASCII/65536-4       491µs ± 5%     473µs ± 2%    ~     (p=0.095 n=5+5)
FieldsFunc/ASCII/1048576-4    8.02ms ± 7%    7.85ms ± 4%    ~     (p=0.548 n=5+5)
FieldsFunc/Mixed/16-4          182ns ± 1%     181ns ± 4%    ~     (p=0.357 n=5+5)
FieldsFunc/Mixed/256-4        1.74µs ± 1%    1.74µs ± 1%    ~     (p=0.881 n=5+5)
FieldsFunc/Mixed/4096-4       34.9µs ± 2%    34.7µs ± 0%    ~     (p=0.310 n=5+5)
FieldsFunc/Mixed/65536-4       595µs ± 1%     589µs ± 2%    ~     (p=0.095 n=5+5)
FieldsFunc/Mixed/1048576-4    10.1ms ± 3%     9.8ms ± 2%    ~     (p=0.095 n=5+5)

name                        old speed      new speed      delta
FieldsFunc/ASCII/16-4        109MB/s ± 1%   111MB/s ± 1%  +2.33%  (p=0.008 n=5+5)
FieldsFunc/ASCII/256-4       157MB/s ± 0%   161MB/s ± 1%  +2.57%  (p=0.008 n=5+5)
FieldsFunc/ASCII/4096-4      137MB/s ± 0%   140MB/s ± 2%    ~     (p=0.190 n=4+5)
FieldsFunc/ASCII/65536-4     134MB/s ± 4%   139MB/s ± 2%    ~     (p=0.095 n=5+5)
FieldsFunc/ASCII/1048576-4   131MB/s ± 6%   134MB/s ± 4%    ~     (p=0.548 n=5+5)
FieldsFunc/Mixed/16-4       87.8MB/s ± 1%  88.3MB/s ± 4%    ~     (p=0.421 n=5+5)
FieldsFunc/Mixed/256-4       147MB/s ± 1%   147MB/s ± 1%    ~     (p=0.841 n=5+5)
FieldsFunc/Mixed/4096-4      117MB/s ± 2%   118MB/s ± 0%    ~     (p=0.310 n=5+5)
FieldsFunc/Mixed/65536-4     110MB/s ± 1%   111MB/s ± 2%    ~     (p=0.095 n=5+5)
FieldsFunc/Mixed/1048576-4   104MB/s ± 3%   107MB/s ± 2%    ~     (p=0.095 n=5+5)

name                        old alloc/op   new alloc/op   delta
FieldsFunc/ASCII/16-4          32.0B ± 0%     32.0B ± 0%    ~     (all equal)
FieldsFunc/ASCII/256-4          352B ± 0%      352B ± 0%    ~     (all equal)
FieldsFunc/ASCII/4096-4       21.9kB ± 0%    21.9kB ± 0%    ~     (all equal)
FieldsFunc/ASCII/65536-4       448kB ± 0%     448kB ± 0%    ~     (all equal)
FieldsFunc/ASCII/1048576-4    8.85MB ± 0%    8.85MB ± 0%    ~     (p=0.738 n=5+5)
FieldsFunc/Mixed/16-4          48.0B ± 0%     48.0B ± 0%    ~     (all equal)
FieldsFunc/Mixed/256-4          416B ± 0%      416B ± 0%    ~     (all equal)
FieldsFunc/Mixed/4096-4       21.5kB ± 0%    21.5kB ± 0%    ~     (all equal)
FieldsFunc/Mixed/65536-4       448kB ± 0%     448kB ± 0%    ~     (all equal)
FieldsFunc/Mixed/1048576-4    8.85MB ± 0%    8.85MB ± 0%    ~     (p=0.690 n=5+5)

name                        old allocs/op  new allocs/op  delta
FieldsFunc/ASCII/16-4           1.00 ± 0%      1.00 ± 0%    ~     (all equal)
FieldsFunc/ASCII/256-4          1.00 ± 0%      1.00 ± 0%    ~     (all equal)
FieldsFunc/ASCII/4096-4         5.00 ± 0%      5.00 ± 0%    ~     (all equal)
FieldsFunc/ASCII/65536-4        12.0 ± 0%      12.0 ± 0%    ~     (all equal)
FieldsFunc/ASCII/1048576-4      24.0 ± 0%      24.0 ± 0%    ~     (all equal)
FieldsFunc/Mixed/16-4           1.00 ± 0%      1.00 ± 0%    ~     (all equal)
FieldsFunc/Mixed/256-4          1.00 ± 0%      1.00 ± 0%    ~     (all equal)
FieldsFunc/Mixed/4096-4         5.00 ± 0%      5.00 ± 0%    ~     (all equal)
FieldsFunc/Mixed/65536-4        12.0 ± 0%      12.0 ± 0%    ~     (all equal)
FieldsFunc/Mixed/1048576-4      24.0 ± 0%      24.0 ± 0%    ~     (all equal)

Change-Id: I06828d798ca1a624a26edd7f7b68c3bf2fc28f84
Reviewed-on: https://go-review.googlesource.com/c/go/+/229765
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
4 years agocmd/compile: simplify readonly sym checks in writebarrier pass
Josh Bleecher Snyder [Tue, 28 Apr 2020 17:20:55 +0000 (10:20 -0700)]
cmd/compile: simplify readonly sym checks in writebarrier pass

CL 220499 started marking readonly syms as SRODATA earlier,
so we can use that in the writebarrier pass now.

Passes toolstash-check.

Change-Id: Ic4d49714b8bffbe03c8e9a75ca96df4475bae732
Reviewed-on: https://go-review.googlesource.com/c/go/+/230559
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.link] cmd/link: convert asmb pass to new style
Cherry Zhang [Sat, 25 Apr 2020 21:50:48 +0000 (17:50 -0400)]
[dev.link] cmd/link: convert asmb pass to new style

Change-Id: I8675f56a7f7f18653754eb87b95f5a7aec31ad74
Reviewed-on: https://go-review.googlesource.com/c/go/+/229860
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years ago[dev.link] cmd/link: remove elf sym fields from sym.Symbol
Than McIntosh [Tue, 28 Apr 2020 14:51:40 +0000 (10:51 -0400)]
[dev.link] cmd/link: remove elf sym fields from sym.Symbol

Remove the "ElfSym" and "LocalElfSym" fields from sym.Symbol,
replacing uses with loader method calls as needed.

Change-Id: I3828f13203ece2bdc03eeb09ab37a5c94e21a726
Reviewed-on: https://go-review.googlesource.com/c/go/+/230462
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years ago[dev.link] cmd/link: remove Unit field from sym.Symbol
Than McIntosh [Mon, 27 Apr 2020 17:21:48 +0000 (13:21 -0400)]
[dev.link] cmd/link: remove Unit field from sym.Symbol

Remove sym.Symbol 'Unit' field, replacing accesses to the field with
calls into the loader instead.

Change-Id: Ia1abd4c3d93036705dd624a49cb3d9cbe6a5188b
Reviewed-on: https://go-review.googlesource.com/c/go/+/230307
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years ago[dev.link] cmd/link/internal/loader: add elf symbol methods
Than McIntosh [Tue, 28 Apr 2020 14:37:33 +0000 (10:37 -0400)]
[dev.link] cmd/link/internal/loader: add elf symbol methods

Add new get/set methods to the loader for recording the ELF symbol
index for a given loader symbol. These are map-based, since it is
expected that many/most symbols will not need an ELF symbol table
entry.

Change-Id: I1102c3637775515ccc6650118e8b059468a2c3ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/230461
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years ago[dev.link] cmd/link/internal/sym: remove SortSub
Than McIntosh [Mon, 27 Apr 2020 18:02:06 +0000 (14:02 -0400)]
[dev.link] cmd/link/internal/sym: remove SortSub

Remove SortSub; this function no longer referenced.

Change-Id: Ie0c78f5cd048a8f465f84ceeab30db57be5c05a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/230457
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years ago[dev.link] cmd/link: remove Gotype and File fields from sym.Symbol
Than McIntosh [Mon, 27 Apr 2020 16:19:57 +0000 (12:19 -0400)]
[dev.link] cmd/link: remove Gotype and File fields from sym.Symbol

Remove the 'Gotype' field from sym.Symbol, as it is now no longer
used. Store the loader.Sym for a symbol as a field in sym.Symbol
("SymIdx"). Then remove sym.Symbol 'File' field, and replace the field
accesses in question with calls into the loader instead.

Change-Id: I01c5504425006b8d3fe77fac2b69a86e198c7a5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/230304
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years ago[dev.link] cmd/link: tweak genasmsym to eliminate Gotype ref
Than McIntosh [Tue, 28 Apr 2020 17:45:35 +0000 (13:45 -0400)]
[dev.link] cmd/link: tweak genasmsym to eliminate Gotype ref

None of the users of genasmsym are doing anything with the Gotype
field of sym.Symbol, so remove that param from the callback function.

Change-Id: Ie902c4cdbcc6b68d353daf5ce21a99012161a946
Reviewed-on: https://go-review.googlesource.com/c/go/+/230545
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: fix block leak due to race in span set
Michael Anthony Knyszek [Tue, 28 Apr 2020 15:14:56 +0000 (15:14 +0000)]
runtime: fix block leak due to race in span set

The span set data structure may leak blocks due to a race in the logic
to check whether it's safe to free a block. The simplest example of this
race is between two poppers:

1. Popper A claims slot spanSetEntries-2.
2. Popper B claims slot spanSetEntries-1.
3. Popper A gets descheduled before it subtracts from block.used.
4. Popper B subtracts from block.used, sees that claimed
   spanSetEntries-1, but also that block.used != 0, so it returns.
5. Popper A comes back and subtracts from block.used, but it didn't
   claim spanSetEntries-1 so it also returns.

The spine is left with a stale block pointer and the block later gets
overwritten by pushes, never to be re-used again.

The problem here is that we designate the claimer of slot
spanSetEntries-1 to be the one who frees the block, but that may not be
the thread that actually does the last subtraction from block.used.

Fixing this problem is tricky, and the fundamental problem there is that
block.used is not stable: it may be observed to be zero, but that
doesn't necessarily mean you're the last popper!

Do something simpler: keep a counter of how many pops have happened to a
given block instead of block.used. This counter monotonically increases
when a pop is _completely done_.  Because this counter is monotonically
increasing, and only increases when a popper is done, then we know for
sure whichever popper is the last to increase it (i.e. its value is
spanSetBlockEntries) is also the last popper in the block. Because the
race described above still exists, the last popper may not be the one
which claimed the last slot in the block, but we know for certain nobody
else is popping from that block anymore so we can safely free it.
Finally, because pops serialize with pushes to the same slot, we need
not worry about concurrent pushers at all.

Updates #37487.

Change-Id: I6697219372774c8ca7d8ee6895eaa230a64ce9e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/230497
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years ago[dev.link] cmd/link: write data sections to heap in Asmb on Wasm
Cherry Zhang [Tue, 28 Apr 2020 13:53:29 +0000 (09:53 -0400)]
[dev.link] cmd/link: write data sections to heap in Asmb on Wasm

Make Wasm more like other architectures, writing data sections to
heap in Asmb instead of Asmb2. Then we can remove the
copy-on-write logic in applying relocations.

Change-Id: I26d5315ea9fba032fe4bdb9b5c7fe483611c4373
Reviewed-on: https://go-review.googlesource.com/c/go/+/230465
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years ago[dev.link] cmd/link: convert dwarfcompress to using the loader
Cherry Zhang [Sat, 25 Apr 2020 18:17:10 +0000 (14:17 -0400)]
[dev.link] cmd/link: convert dwarfcompress to using the loader

Change-Id: I34f806b54e8e0985a30ef38ea4324352aabfc845
Reviewed-on: https://go-review.googlesource.com/c/go/+/229995
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
4 years agoruntime: flush mcaches to mcentral before reading memstats
Michael Anthony Knyszek [Tue, 28 Apr 2020 16:40:38 +0000 (16:40 +0000)]
runtime: flush mcaches to mcentral before reading memstats

Currently mcaches are flushed to mcentral after a bunch of memstats have
already been read. This is not safe (in the sense that it doesn't ensure
consisent memstats) since memstats may in general change when mcentral
data structures are manipulated.

Note that prior to the new mcentral implementation this was not a
problem because mcentral operations happened to never modify certain
memstats. As of the new mcentral implementation, we might for example
persistentalloc when uncaching a span, which would change memstats. This
can cause a skew between the value of sys (which currently is calculated
before mcaches are flushed) and the value of gc_sys and other_sys.

Fix this by moving mcache flushing to the very top of updatememstats.
Also leave a comment explaining that this must be done first, in
general, because mcentrals make no guarantee that they will not
influence memstats (and doing so would be unnecessarily restrictive).

Fixes #38712.

Change-Id: I15bacb313c54a46e380a945a71bb75db67169c1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/230498
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
4 years agocmd/compile: port first part of arm64 opt rules to typed aux
Alberto Donizetti [Tue, 28 Apr 2020 13:32:43 +0000 (15:32 +0200)]
cmd/compile: port first part of arm64 opt rules to typed aux

Fairly minimal changes.

Passes

  GOARCH=arm64 gotip build -toolexec 'toolstash -cmp' -a std

Change-Id: I14b2e3ad4933ef14b1b6993f427bf84fe85b1818
Reviewed-on: https://go-review.googlesource.com/c/go/+/229939
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agodoc/go1.15: add notes for GOMODCACHE, modcacheunzipinplace
Jay Conrod [Tue, 28 Apr 2020 15:58:33 +0000 (11:58 -0400)]
doc/go1.15: add notes for GOMODCACHE, modcacheunzipinplace

For #36568
For #34527

Change-Id: Ieea4b4a7644e9c957f48d08d2e172e39b571502f
Reviewed-on: https://go-review.googlesource.com/c/go/+/230537
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years ago[dev.link] cmd/link: move wavefront past address
Jeremy Faller [Thu, 23 Apr 2020 18:28:20 +0000 (14:28 -0400)]
[dev.link] cmd/link: move wavefront past address

This change is just the mechanical work of moving the wavefront past
address.

Change-Id: I519ec49fa8ba50760c7d23fc084fcd3bb0544546
Reviewed-on: https://go-review.googlesource.com/c/go/+/229700
Run-TryBot: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agointernal/goversion: update to 1.15
Bryan C. Mills [Tue, 28 Apr 2020 01:20:36 +0000 (01:20 +0000)]
internal/goversion: update to 1.15

This is a second attempt at CL 230024, with
cmd/go/testdata/script/mod_retention.txt updated to perform a
version-independent comparison on the 'go' version added to a go.mod
file that lacks one.

Fixes #38708

Change-Id: I15dcd83b51ed5ec57946b419bcbaec41e85a46f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/230382
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years agoRevert "[dev.link] cmd/link: stop overwriting symbol types in loadlibfull"
Cherry Zhang [Tue, 28 Apr 2020 14:05:20 +0000 (14:05 +0000)]
Revert "[dev.link] cmd/link: stop overwriting symbol types in loadlibfull"

This reverts CL 229994.

Reason for revert: break AIX build.

This is nice to have but isn't critical. We can revisit later.

Change-Id: Ifc56a0a4c0fb36859cf7666ab149e25e0e5d4cc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/230459
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years ago[dev.link] cmd/link: fix accidental shadowing
Cherry Zhang [Mon, 27 Apr 2020 22:47:03 +0000 (18:47 -0400)]
[dev.link] cmd/link: fix accidental shadowing

ctxt.Tlsg2 is supposed to be the embedded ArchSyms.Tlsg2.

Change-Id: I4f9711f83999d4a98bcf6d99c24fab756c580905
Reviewed-on: https://go-review.googlesource.com/c/go/+/230379
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agodatabase/sql: fix incorrect function name in example_test
Vivian Liang [Tue, 28 Apr 2020 00:36:41 +0000 (00:36 +0000)]
database/sql: fix incorrect function name in example_test

fixes incorrect function name prefix in `example_test.go`

Change-Id: I0cce8afc89f6ee6dab3e5152246d28deb597fe53
GitHub-Last-Rev: 4e9a6067c8307e049ace2e35414a838bf6c8a8a4
GitHub-Pull-Request: golang/go#38715
Reviewed-on: https://go-review.googlesource.com/c/go/+/230381
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
4 years agocmd/compile: adopt strong aux typing for some s390x rules
Ruixin Bao [Mon, 27 Apr 2020 23:20:45 +0000 (16:20 -0700)]
cmd/compile: adopt strong aux typing for some s390x rules

Convert some optimizations rules to strongly-typed versions. So far, I
have only converted the rules that need no additional changes (i.e: only
need to change '->' to "=>").

This CL covers the rules from line 478 - line 800 in S390X.rules file.
Some compare and branch rules also fall in this range, but they were
already done previously in another CL.

Passes toolstash-check.
Change-Id: I9167c5f1a32f4fd6c29bacc13fff95e83b0533e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/230338
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: rewrite some arm64 rules to use typed aux fields
fanzha02 [Wed, 22 Apr 2020 02:03:00 +0000 (10:03 +0800)]
cmd/compile: rewrite some arm64 rules to use typed aux fields

Passes toolstash-check -all.

Change-Id: Ibf8c2532b0de65901bf0dd9ef0d198dc54d56470
Reviewed-on: https://go-review.googlesource.com/c/go/+/229738
Reviewed-by: Keith Randall <khr@golang.org>
4 years agogo/types: improve errors for method calls with pointer receivers
Rebecca Stambler [Mon, 27 Apr 2020 23:41:14 +0000 (19:41 -0400)]
go/types: improve errors for method calls with pointer receivers

The compiler has better error messages for methods called without a
pointer receiver when one is expected. This change is similar to
CL 229801, but for method calls.

Also, added better error messages for functions called with the wrong
capitalization. I left the third TODO in this switch statement almost
as-is because I'm not sure that the extra complexity is worth it -
I adjusted the error to look like the one the compiler reports.

Fixes golang/go#38658

Change-Id: Ie0ca2503e12f3659f112f0135cc27db1b027fdcb
Reviewed-on: https://go-review.googlesource.com/c/go/+/230380
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agoos, internal/poll, internal/syscall/unix: use copy_file_range on Linux
Andrei Tudor Călin [Tue, 21 Apr 2020 23:08:33 +0000 (02:08 +0300)]
os, internal/poll, internal/syscall/unix: use copy_file_range on Linux

Linux 4.5 introduced (and Linux 5.3 refined) the copy_file_range
system call, which allows file systems the opportunity to implement
copy acceleration techniques. This commit adds support for
copy_file_range(2) to the os package.

Introduce a new ReadFrom method on *os.File, which makes *os.File
implement the io.ReaderFrom interface. If dst and src are both files,
this enables io.Copy(dst, src) to call dst.ReadFrom(src), which, in
turn, will call copy_file_range(2) if possible. If copy_file_range(2)
is not supported by the host kernel, or if either of dst or src
refers to a non-regular file, ReadFrom falls back to the regular
io.Copy code path.

Add internal/poll.CopyFileRange, which acquires locks on the
appropriate poll.FDs and performs the actual work, as well as
internal/syscall/unix.CopyFileRange, which wraps the copy_file_range
system call itself at the lowest level.

Rework file layout in internal/syscall/unix to accomodate the
additional system call numbers needed for copy_file_range.
Merge these definitions with the ones used by getrandom(2) into
sysnum_linux_$GOARCH.go files.

A note on additional optimizations: if dst and src both refer to pipes
in the invocation dst.ReadFrom(src), we could, in theory, use the
existing splice(2) code in package internal/poll to splice directly
from src to dst. Attempting this runs into trouble with the poller,
however. If we call splice(src, dst) and see EAGAIN, we cannot know
if it came from src not being ready for reading or dst not being
ready for writing. The write end of src and the read end of dst are
not under our control, so we cannot reliably use the poller to wait
for readiness. Therefore, it seems infeasible to use the new ReadFrom
method to splice between pipes directly. In conclusion, for now, the
only optimization enabled by the new ReadFrom method on *os.File is
the copy_file_range optimization.

Fixes #36817.

Change-Id: I696372639fa0cdf704e3f65414f7321fc7d30adb
Reviewed-on: https://go-review.googlesource.com/c/go/+/229101
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agobufio: optimize bufio.Reader.ReadString to avoid an allocation and copy
Alex Gaynor [Mon, 27 Apr 2020 23:10:23 +0000 (23:10 +0000)]
bufio: optimize bufio.Reader.ReadString to avoid an allocation and copy

name                old time/op    new time/op    delta
ReaderReadString-4     226ns ±12%     161ns ±11%  -28.76%  (p=0.008 n=5+5)

name                old alloc/op   new alloc/op   delta
ReaderReadString-4      288B ± 0%      144B ± 0%  -50.00%  (p=0.008 n=5+5)

name                old allocs/op  new allocs/op  delta
ReaderReadString-4      2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.008 n=5+5)

Change-Id: I77f330b8340c2bfbfff1f6f1000170b65953a200
GitHub-Last-Rev: 65d65302a7b80504b4d37b81a3843fe1439e638a
GitHub-Pull-Request: golang/go#34706
Reviewed-on: https://go-review.googlesource.com/c/go/+/199257
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoimage/draw: optimize paletted dst + uniform src
Nigel Tao [Sat, 25 Apr 2020 12:29:02 +0000 (22:29 +1000)]
image/draw: optimize paletted dst + uniform src

name            old time/op  new time/op  delta
PalettedFill-4  5.74ms ± 1%  0.01ms ± 1%  -99.78%  (p=0.008 n=5+5)
PalettedRGBA-4  3.34ms ± 3%  3.33ms ± 0%     ~     (p=0.690 n=5+5)

Fixes #35938

Thanks to pjbgtnj for the suggestion.

Change-Id: I07b494482cce918f556e196c5a4b481b4c16de3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/230118
Run-TryBot: Nigel Tao <nigeltao@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agostrconv: remove redundant conversions to int
smasher164 [Mon, 27 Apr 2020 17:23:24 +0000 (13:23 -0400)]
strconv: remove redundant conversions to int

IntSize is an untyped constant that does not need explicit conversion.
Annotating IntSize as an int and running github.com/mdempsky/unconvert
reveals these two cases.

Fixes #38682.

Change-Id: I014646b7457ddcde32474810153229dcf0c269c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/230306
Run-TryBot: Akhil Indurti <aindurti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agoruntime: ensure allocToCache updates searchAddr in a valid way
Michael Anthony Knyszek [Wed, 22 Apr 2020 21:36:11 +0000 (21:36 +0000)]
runtime: ensure allocToCache updates searchAddr in a valid way

Currently allocToCache assumes it can move the search address past the
block it allocated the cache from, which violates the property that
searchAddr should always point to mapped memory (i.e. memory represented
by pageAlloc.inUse).

This bug was already fixed once for pageAlloc.alloc in the Go 1.14
release via CL 216697, but that changed failed to take into account
allocToCache.

Fixes #38605.

Change-Id: Id08180aa10d19dc0f9f551a1d9e327a295560dff
Reviewed-on: https://go-review.googlesource.com/c/go/+/229577
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agohash/crc32: simplify hasVX checking on s390x
Ruixin(Peter) Bao [Mon, 27 Apr 2020 19:23:37 +0000 (15:23 -0400)]
hash/crc32: simplify hasVX checking on s390x

Originally, we use an assembly function that returns a boolean result to
tell whether the machine has vector facility or not. It is now no longer
needed when we can directly use cpu.S390X.HasVX variable. This CL
also removes the last occurence of hasVectorFacility function on s390x.

Change-Id: Id20cb746c21eacac5e13344b362e2d87adfe4317
Reviewed-on: https://go-review.googlesource.com/c/go/+/230337
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years ago[dev.link] cmd/link: stop overwriting symbol types in loadlibfull
Cherry Zhang [Sat, 25 Apr 2020 21:27:34 +0000 (17:27 -0400)]
[dev.link] cmd/link: stop overwriting symbol types in loadlibfull

symGroupType was needed for dodata. Now that we have converted
dodata to using the loader, stop overwriting it.

Change-Id: Ie94109c0b35dd2f71a19ebb38f8cf20b6a37c624
Reviewed-on: https://go-review.googlesource.com/c/go/+/229994
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years ago[dev.link] cmd/link: delete old dodata
Cherry Zhang [Mon, 27 Apr 2020 20:46:23 +0000 (16:46 -0400)]
[dev.link] cmd/link: delete old dodata

Change-Id: I569bbee235630baad3c35ca0c6598b8bd059307a
Reviewed-on: https://go-review.googlesource.com/c/go/+/230311
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years ago[dev.link] cmd/link: accept more types in Xcoffadddynrel
Cherry Zhang [Mon, 27 Apr 2020 20:01:24 +0000 (16:01 -0400)]
[dev.link] cmd/link: accept more types in Xcoffadddynrel

In dodata we overwrite symbol types to SDATA. Now we'll stop
doing that, so accept more symbol types here. This is basically
a list of all writeable types handled in dodata that could appear
in XCOFF.

Change-Id: Iee35369162f5acd59806a3f0e6c8d3682620067e
Reviewed-on: https://go-review.googlesource.com/c/go/+/230310
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agomath/big: simplify hasVX checking on s390x
Ruixin(Peter) Bao [Mon, 27 Apr 2020 13:51:01 +0000 (09:51 -0400)]
math/big: simplify hasVX checking on s390x

Originally, we use an assembly function that returns a boolean result to
tell whether the machine has vector facility or not. It is now no longer
needed when we can directly use cpu.S390X.HasVX variable.

Change-Id: Ic1dae851982532bcfd9a9453416c112347f21d87
Reviewed-on: https://go-review.googlesource.com/c/go/+/230318
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agomath: simplify hasVX checking on s390x
Ruixin Bao [Mon, 27 Apr 2020 19:02:52 +0000 (12:02 -0700)]
math: simplify hasVX checking on s390x

Originally, we use an assembly function that returns a boolean result to
tell whether the machine has vector facility or not. It is now no longer
needed when we can directly use cpu.S390X.HasVX variable.

Change-Id: Ic3ffeb9e63238ef41406d97cdc42502145ddb454
Reviewed-on: https://go-review.googlesource.com/c/go/+/230319
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocrypto/ecdsa: implement ecdsa on s390x for P256/P384/P521 using KDSA instruction
Ruixin Bao [Wed, 15 Apr 2020 20:50:50 +0000 (16:50 -0400)]
crypto/ecdsa: implement ecdsa on s390x for P256/P384/P521 using KDSA instruction

This CL revives CL 174437(also IBM CLA) and adds benchmarks and some simplifications.

The original commit message is as follows:

Utilize KDSA when available. This guarantees constant time operation on all three curves mentioned,
and is faster than conventional assembly.

Benchmarks:
name             old time/op    new time/op    delta
SignP256-8         15.2µs ±14%    14.1µs ±18%     ~     (p=0.356 n=9+10)
SignP384-8         4.28ms ±26%    0.02ms ±30%  -99.43%  (p=0.000 n=10+10)
VerifyP256-8       33.6µs ±13%    13.3µs ±38%  -60.32%  (p=0.000 n=9+10)

name             old alloc/op   new alloc/op   delta
SignP256-8         2.16kB ± 0%    1.60kB ± 0%  -25.63%  (p=0.000 n=9+10)
SignP384-8         1.75MB ± 0%    0.00MB ± 0%  -99.90%  (p=0.000 n=9+10)
VerifyP256-8       1.08kB ± 0%    0.18kB ± 0%  -83.70%  (p=0.000 n=9+10)

name             old allocs/op  new allocs/op  delta
SignP256-8           29.0 ± 0%      22.0 ± 0%  -24.14%  (p=0.000 n=10+10)
SignP384-8          14.4k ± 0%      0.0k ± 0%  -99.85%  (p=0.000 n=9+10)
VerifyP256-8         23.0 ± 0%       7.0 ± 0%  -69.57%  (p=0.000 n=10+10)

Change-Id: Ifa1fc5917fa7592dd592affa7549147dbc9b4169
Reviewed-on: https://go-review.googlesource.com/c/go/+/228580
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
4 years agocrypto/ed25519: implement ed25519 on s390x using KDSA instruction
Ruixin(Peter) Bao [Mon, 21 Oct 2019 17:18:31 +0000 (13:18 -0400)]
crypto/ed25519: implement ed25519 on s390x using KDSA instruction

This CL allows the usage of KDSA instruction when it is available.  The
instruction is designed to be resistant to side channel attacks and
offers performance improvement for ed25519.

Benchmarks:
name              old time/op    new time/op    delta
Signing-8            120µs ±20%      62µs ±12%   -48.40%  (p=0.000 n=10+10)
Verification-8       325µs ±17%      69µs ±10%   -78.80%  (p=0.000 n=10+10)

name              old alloc/op   new alloc/op   delta
Signing-8             448B ± 0%        0B       -100.00%  (p=0.000 n=10+10)
Verification-8        288B ± 0%        0B       -100.00%  (p=0.000 n=10+10)

name              old allocs/op  new allocs/op  delta
Signing-8             5.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
Verification-8        2.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)

Change-Id: I0330ce83d807370b419ce638bc2cae4cb3c250dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/202578
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
4 years agoRevert "go/types: add UsesCgo config to support _cgo_gotypes.go"
Andrew Bonventre [Mon, 27 Apr 2020 17:46:01 +0000 (17:46 +0000)]
Revert "go/types: add UsesCgo config to support _cgo_gotypes.go"

This reverts CL 33677.

Reason for revert: NetBSD is broken

Updates #38649

Change-Id: Id60e3c97d3cb4fb0053dea03b95dbbb0b850c883
Reviewed-on: https://go-review.googlesource.com/c/go/+/230038
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agoruntime: added several new lock-rank partial order edges
Dan Scales [Mon, 13 Apr 2020 15:37:03 +0000 (08:37 -0700)]
runtime: added several new lock-rank partial order edges

Several new ones came from my testing (long, repeated runs) and one (assistQueue ->
spine) came from the staticlockranking builder (filed as issue 38441).

Fixes #38441

Change-Id: I4268da0d8b8cc51251eba6bd936110c8ab4c4e61
Reviewed-on: https://go-review.googlesource.com/c/go/+/229480
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>