1
0
mirror of https://github.com/golang/go synced 2024-09-29 19:24:33 -06:00
Commit Graph

42809 Commits

Author SHA1 Message Date
Diogo Pinela
19ed0d993c cmd/compile: use staticuint64s instead of staticbytes
There are still two places in src/runtime/string.go that use
staticbytes, so we cannot delete it just yet.

There is a new codegen test to verify that the index calculation
is constant-folded, at least on amd64. ppc64, mips[64] and s390x
cannot currently do that.

There is also a new runtime benchmark to ensure that this does not
slow down performance (tested against parent commit):

name                      old time/op  new time/op  delta
ConvT2EByteSized/bool-4   1.07ns ± 1%  1.07ns ± 1%   ~     (p=0.060 n=14+15)
ConvT2EByteSized/uint8-4  1.06ns ± 1%  1.07ns ± 1%   ~     (p=0.095 n=14+15)

Updates #37612

Change-Id: I5ec30738edaa48cda78dfab4a78e24a32fa7fd6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/221957
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2020-03-04 21:43:01 +00:00
Bryan C. Mills
c55a50edb9 cmd/go: invalidate cached test results when the -timeout flag changes
Fixes #36134

Change-Id: Icc5e1269696db778ba5c1e6bebed9969b8841c81
Reviewed-on: https://go-review.googlesource.com/c/go/+/220365
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-03-04 20:52:43 +00:00
Meng Zhuo
68fea523fd cmd/asm: add MIPS MSA LD/ST/LDI support for mips64x
This CL adding primitive asm support of MIPS MSA by introducing
new sets of register W0-W31 (C_WREG) and 12 new instructions:

* VMOV{B,H,W,D} ADDCONST, WREG  (Vector load immediate)
* VMOV{B,H,W,D} SOREG, WREG     (Vector load)
* VMOV{B,H,W,D} WREG, SOREG     (Vector store)

Ref: MIPS Architecture for Programmers Volume IV-j: The MIPS64 SIMD Architecture Module

Change-Id: I3362c59a73c82c94769c18a19a0bee7e5029217d
Reviewed-on: https://go-review.googlesource.com/c/go/+/215723
Run-TryBot: Meng Zhuo <mengzhuo1203@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-04 19:06:44 +00:00
Cherry Zhang
588ee7987d runtime: don't save/restore FP registers in softfloat mode on MIPS(64)
Fixes #37653.

Change-Id: I6188e44b4bc4aba7b56f29d9ce9de4618c70fd7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/222057
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-04 18:09:01 +00:00
erifan01
18a6fd44bb bytes, strings: moves indexRabinKarp function to internal/bytealg
In order to facilitate optimization of IndexAny and LastIndexAny, this patch moves
three Rabin-Karp related functions indexRabinKarp, hashStr and hashStrRev in strings
package to initernal/bytealg. There are also three functions in the bytes package with
the same names and functions but different parameter types. To highlight this, this
patch also moves them to internal/bytealg and gives them slightly different names.

Related benchmark changes on amd64 and arm64:

name          old time/op    new time/op    delta
pkg:strings goos:linux goarch:amd64
Index-16        14.0ns ± 1%    14.1ns ± 2%    ~     (p=0.738 n=5+5)
LastIndex-16    15.5ns ± 1%    15.7ns ± 4%    ~     (p=0.897 n=5+5)
pkg:bytes goos:linux goarch:amd64
Index/10-16     26.5ns ± 1%    26.5ns ± 0%    ~     (p=0.873 n=5+5)
Index/32-16     26.2ns ± 0%    25.7ns ± 0%  -1.68%  (p=0.008 n=5+5)
Index/4K-16     5.12µs ± 4%    5.14µs ± 2%    ~     (p=0.841 n=5+5)
Index/4M-16     5.44ms ± 3%    5.34ms ± 2%    ~     (p=0.056 n=5+5)
Index/64M-16    85.8ms ± 3%    84.6ms ± 0%  -1.37%  (p=0.016 n=5+5)

name          old speed      new speed      delta
pkg:bytes goos:linux goarch:amd64
Index/10-16    377MB/s ± 1%   377MB/s ± 0%    ~     (p=1.000 n=5+5)
Index/32-16   1.22GB/s ± 1%  1.24GB/s ± 0%  +1.66%  (p=0.008 n=5+5)
Index/4K-16    800MB/s ± 4%   797MB/s ± 2%    ~     (p=0.841 n=5+5)
Index/4M-16    771MB/s ± 3%   786MB/s ± 2%    ~     (p=0.056 n=5+5)
Index/64M-16   783MB/s ± 3%   793MB/s ± 0%  +1.36%  (p=0.016 n=5+5)

name         old time/op   new time/op   delta
pkg:strings goos:linux goarch:arm64
Index-8       22.6ns ± 0%   22.5ns ± 0%    ~     (p=0.167 n=5+5)
LastIndex-8   17.5ns ± 0%   17.5ns ± 0%    ~     (all equal)
pkg:bytes goos:linux goarch:arm64
Index/10-8    25.0ns ± 0%   25.0ns ± 0%    ~     (all equal)
Index/32-8     160ns ± 0%    160ns ± 0%    ~     (all equal)
Index/4K-8    6.26µs ± 0%   6.26µs ± 0%    ~     (p=0.167 n=5+5)
Index/4M-8    6.30ms ± 0%   6.31ms ± 0%    ~     (p=1.000 n=5+5)
Index/64M-8    101ms ± 0%    101ms ± 0%    ~     (p=0.690 n=5+5)

name         old speed     new speed     delta
pkg:bytes goos:linux goarch:arm64
Index/10-8   399MB/s ± 0%  400MB/s ± 0%  +0.08%  (p=0.008 n=5+5)
Index/32-8   200MB/s ± 0%  200MB/s ± 0%    ~     (p=0.127 n=4+5)
Index/4K-8   654MB/s ± 0%  654MB/s ± 0%  +0.01%  (p=0.016 n=5+5)
Index/4M-8   665MB/s ± 0%  665MB/s ± 0%    ~     (p=0.833 n=5+5)
Index/64M-8  665MB/s ± 0%  665MB/s ± 0%    ~     (p=0.913 n=5+5)

Change-Id: Icce3bc162bb8613ac36dc963a46c51f8e82ab842
Reviewed-on: https://go-review.googlesource.com/c/go/+/208638
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-03-04 17:36:05 +00:00
Clément Chigot
cec08794ef misc/cgo/test: fix sigaltstack test on AIX
Increase the size of the signal stack as the value given by SIGSTKSZ
is too small for the Go signal handler.

Fixes #37609

Change-Id: I56f1006bc69a2a9fb43f9e0da00061964290a690
Reviewed-on: https://go-review.googlesource.com/c/go/+/221804
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-03-04 17:33:06 +00:00
Keith Randall
cd9fd640db cmd/compile: don't allow NaNs in floating-point constant ops
Trying this CL again, with a fixed test that allows platforms
to disagree on the exact behavior of converting NaNs.

We store 32-bit floating point constants in a 64-bit field, by
converting that 32-bit float to 64-bit float to store it, and convert
it back to use it.

That works for *almost* all floating-point constants. The exception is
signaling NaNs. The round trip described above means we can't represent
a 32-bit signaling NaN, because conversions strip the signaling bit.

To fix this issue, just forbid NaNs as floating-point constants in SSA
form. This shouldn't affect any real-world code, as people seldom
constant-propagate NaNs (except in test code).

Additionally, NaNs are somewhat underspecified (which of the many NaNs
do you get when dividing 0/0?), so when cross-compiling there's a
danger of using the compiler machine's NaN regime for some math, and
the target machine's NaN regime for other math. Better to use the
target machine's NaN regime always.

Update #36400

Change-Id: Idf203b688a15abceabbd66ba290d4e9f63619ecb
Reviewed-on: https://go-review.googlesource.com/c/go/+/221790
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2020-03-04 04:49:54 +00:00
Michael Munday
24343cb886 cmd/compile: remove walkinrange optimization
The walkinrange optimization has been superseded by CL 165998.

Has a small positive impact on binary sizes:

compilecmp master -> HEAD
master (e37cc29863): cmd/compile: optimize integer-in-range checks
HEAD (1a70680a34): cmd/compile: remove walkinrange optimization
platform: linux/amd64

file      before    after     Δ       %
addr2line 4329144   4325048   -4096   -0.095%
api       6060970   6056874   -4096   -0.068%
asm       5196905   5192809   -4096   -0.079%
cgo       4898769   4890577   -8192   -0.167%
compile   20222193  20209713  -12480  -0.062%
cover     5331580   5323388   -8192   -0.154%
dist      3732778   3728682   -4096   -0.110%
doc       4748488   4740296   -8192   -0.173%
link      6707380   6695092   -12288  -0.183%
nm        4278685   4274589   -4096   -0.096%
pack      2305038   2300942   -4096   -0.178%
pprof     14874834  14870738  -4096   -0.028%
test2json 2849221   2845125   -4096   -0.144%
vet       8393173   8384981   -8192   -0.098%
go        15205572  15193284  -12288  -0.081%
total     131812292 131709700 -102592 -0.078%

Updates #30645.

Change-Id: I42d74481652c90fef1a9bc58c70836e42c9b1c4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/221802
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2020-03-03 19:53:02 +00:00
Josh Bleecher Snyder
7b0b6c2f7e cmd/compile: simplify converted SSA form for 'if false'
The goal here is to make it easier for a human to
examine the SSA when a function contains lots of dead code.

No significant compiler metric or generated code differences.

Change-Id: I81915fa4639bc8820cc9a5e45e526687d0d1f57a
Reviewed-on: https://go-review.googlesource.com/c/go/+/221791
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-03 18:42:30 +00:00
Josh Bleecher Snyder
b49d8ce2fa all: fix two minor typos in comments
Change-Id: Iec6cd81c9787d3419850aa97e75052956ad139bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/221789
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-03 17:44:05 +00:00
Russ Cox
ea1437a8cd net/http: fix handling of HTTP/2 upgrade failures
If an error occurs during the HTTP/2 upgrade phase, originally this
resulted in a pconn with pconn.alt set to an http2erringRoundTripper,
which always fails. This is not wanted - we want to retry in this case.

CL 202078 added a check for the http2erringRoundTripper to treat it
as a failed pconn, but the handling of the failure was wrong in the case
where the pconn is not in the idle list at all (common in HTTP/2).
This made the added test TestDontCacheBrokenHTTP2Conn flaky.

CL 218097 (unsubmitted) proposed to expand the handling of the
http2erringRoundTripper after the new check, to dispose of the pconn
more thoroughly. Bryan Mills pointed out in that review that we probably
shouldn't make the never-going-to-work pconn in the first place.

This CL changes the upgrade phase look for the http2erringRoundTripper
and return the underlying error instead of claiming to have a working
connection. Having done that, the CL undoes the change in CL 202078
and with it the need for CL 218097, but it keeps the new test added
by CL 202078.

On my laptop, before this commit, TestDontCacheBrokenHTTP2Conn
failed 66 times out of 20,000. With this commit, I see 0 out of 20,000.

Fixes #34978.
Fixes #35113.

Change-Id: Ibd908b63c2ae96e159e8e604213d8373afb350e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/220905
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-03 16:04:34 +00:00
Tim Cooper
96acb74655 encoding/hex: remove unused variable from BenchmarkDump
Change-Id: I1fd47e5eab27346cec488098d4f6102a0749bd28
Reviewed-on: https://go-review.googlesource.com/c/go/+/221788
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-03-03 14:53:52 +00:00
Michael Munday
e37cc29863 cmd/compile: optimize integer-in-range checks
This CL incorporates code from CL 201206 by Josh Bleecher Snyder
(thanks Josh).

This CL restores the integer-in-range optimizations in the SSA
backend. The fuse pass is enhanced to detect inequalities that
could be merged and fuse their associated blocks while the generic
rules optimize them into a single unsigned comparison.

For example, the inequality `x >= 0 && x < 10` will now be optimized
to `unsigned(x) < 10`.

Overall has a fairly positive impact on binary sizes.

name                      old time/op       new time/op       delta
Template                        192ms ± 1%        192ms ± 1%    ~     (p=0.757 n=17+18)
Unicode                        76.6ms ± 2%       76.5ms ± 2%    ~     (p=0.603 n=19+19)
GoTypes                         694ms ± 1%        693ms ± 1%    ~     (p=0.569 n=19+20)
Compiler                        3.26s ± 0%        3.27s ± 0%  +0.25%  (p=0.000 n=20+20)
SSA                             7.41s ± 0%        7.49s ± 0%  +1.10%  (p=0.000 n=17+19)
Flate                           120ms ± 1%        120ms ± 1%  +0.38%  (p=0.003 n=19+19)
GoParser                        152ms ± 1%        152ms ± 1%    ~     (p=0.061 n=17+19)
Reflect                         422ms ± 1%        425ms ± 2%  +0.76%  (p=0.001 n=18+20)
Tar                             167ms ± 1%        167ms ± 0%    ~     (p=0.730 n=18+19)
XML                             233ms ± 4%        231ms ± 1%    ~     (p=0.752 n=20+17)
LinkCompiler                    927ms ± 8%        928ms ± 8%    ~     (p=0.857 n=19+20)
ExternalLinkCompiler            1.81s ± 2%        1.81s ± 2%    ~     (p=0.513 n=19+20)
LinkWithoutDebugCompiler        556ms ±10%        583ms ±13%  +4.95%  (p=0.007 n=20+20)
[Geo mean]                      478ms             481ms       +0.52%

name                      old user-time/op  new user-time/op  delta
Template                        270ms ± 5%        269ms ± 7%    ~     (p=0.925 n=20+20)
Unicode                         134ms ± 7%        131ms ±14%    ~     (p=0.593 n=18+20)
GoTypes                         981ms ± 3%        987ms ± 2%  +0.63%  (p=0.049 n=19+18)
Compiler                        4.50s ± 2%        4.50s ± 1%    ~     (p=0.588 n=19+20)
SSA                             10.6s ± 2%        10.6s ± 1%    ~     (p=0.141 n=20+19)
Flate                           164ms ± 8%        165ms ±10%    ~     (p=0.738 n=20+20)
GoParser                        202ms ± 5%        203ms ± 6%    ~     (p=0.820 n=20+20)
Reflect                         587ms ± 6%        597ms ± 3%    ~     (p=0.087 n=20+18)
Tar                             230ms ± 6%        228ms ± 8%    ~     (p=0.569 n=19+20)
XML                             311ms ± 6%        314ms ± 5%    ~     (p=0.369 n=20+20)
LinkCompiler                    878ms ± 8%        887ms ± 7%    ~     (p=0.289 n=20+20)
ExternalLinkCompiler            1.60s ± 7%        1.60s ± 7%    ~     (p=0.820 n=20+20)
LinkWithoutDebugCompiler        498ms ±12%        489ms ±11%    ~     (p=0.398 n=20+20)
[Geo mean]                      611ms             611ms       +0.05%

name                      old alloc/op      new alloc/op      delta
Template                       36.1MB ± 0%       36.0MB ± 0%  -0.32%  (p=0.000 n=20+20)
Unicode                        28.3MB ± 0%       28.3MB ± 0%  -0.03%  (p=0.000 n=19+20)
GoTypes                         121MB ± 0%        121MB ± 0%    ~     (p=0.226 n=16+20)
Compiler                        563MB ± 0%        563MB ± 0%    ~     (p=0.166 n=20+19)
SSA                            1.32GB ± 0%       1.33GB ± 0%  +0.88%  (p=0.000 n=20+19)
Flate                          22.7MB ± 0%       22.7MB ± 0%  -0.02%  (p=0.033 n=19+20)
GoParser                       27.9MB ± 0%       27.9MB ± 0%  -0.02%  (p=0.001 n=20+20)
Reflect                        78.3MB ± 0%       78.2MB ± 0%  -0.01%  (p=0.019 n=20+20)
Tar                            34.0MB ± 0%       34.0MB ± 0%  -0.04%  (p=0.000 n=20+20)
XML                            43.9MB ± 0%       43.9MB ± 0%  -0.07%  (p=0.000 n=20+19)
LinkCompiler                    205MB ± 0%        205MB ± 0%  +0.44%  (p=0.000 n=20+18)
ExternalLinkCompiler            223MB ± 0%        223MB ± 0%  +0.03%  (p=0.000 n=20+20)
LinkWithoutDebugCompiler        139MB ± 0%        142MB ± 0%  +1.75%  (p=0.000 n=20+20)
[Geo mean]                     93.7MB            93.9MB       +0.20%

name                      old allocs/op     new allocs/op     delta
Template                         363k ± 0%         361k ± 0%  -0.58%  (p=0.000 n=20+19)
Unicode                          329k ± 0%         329k ± 0%  -0.06%  (p=0.000 n=19+20)
GoTypes                         1.28M ± 0%        1.28M ± 0%  -0.01%  (p=0.000 n=20+20)
Compiler                        5.40M ± 0%        5.40M ± 0%  -0.01%  (p=0.000 n=20+20)
SSA                             12.7M ± 0%        12.8M ± 0%  +0.80%  (p=0.000 n=20+20)
Flate                            228k ± 0%         228k ± 0%    ~     (p=0.194 n=20+20)
GoParser                         295k ± 0%         295k ± 0%  -0.04%  (p=0.000 n=20+20)
Reflect                          949k ± 0%         949k ± 0%  -0.01%  (p=0.000 n=20+20)
Tar                              337k ± 0%         337k ± 0%  -0.06%  (p=0.000 n=20+20)
XML                              418k ± 0%         417k ± 0%  -0.17%  (p=0.000 n=20+20)
LinkCompiler                     553k ± 0%         554k ± 0%  +0.22%  (p=0.000 n=20+19)
ExternalLinkCompiler            1.52M ± 0%        1.52M ± 0%  +0.27%  (p=0.000 n=20+20)
LinkWithoutDebugCompiler         186k ± 0%         186k ± 0%  +0.06%  (p=0.000 n=20+20)
[Geo mean]                       723k              723k       +0.03%

name                      old text-bytes    new text-bytes    delta
HelloSize                       828kB ± 0%        828kB ± 0%  -0.01%  (p=0.000 n=20+20)

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

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

name                      old exe-bytes     new exe-bytes     delta
HelloSize                      1.23MB ± 0%       1.23MB ± 0%  -0.33%  (p=0.000 n=20+20)

file      before    after     Δ       %
addr2line 4320075   4311883   -8192   -0.190%
asm       5191932   5187836   -4096   -0.079%
buildid   2835338   2831242   -4096   -0.144%
compile   20531717  20569099  +37382  +0.182%
cover     5322511   5318415   -4096   -0.077%
dist      3723749   3719653   -4096   -0.110%
doc       4743515   4739419   -4096   -0.086%
fix       3413960   3409864   -4096   -0.120%
link      6690119   6686023   -4096   -0.061%
nm        4269616   4265520   -4096   -0.096%
pprof     14942189  14929901  -12288  -0.082%
trace     11807164  11790780  -16384  -0.139%
vet       8384104   8388200   +4096   +0.049%
go        15339076  15334980  -4096   -0.027%
total     132258257 132226007 -32250  -0.024%

Fixes #30645.

Change-Id: If551ac5996097f3685870d083151b5843170aab0
Reviewed-on: https://go-review.googlesource.com/c/go/+/165998
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-03 14:30:26 +00:00
Joel Sing
c9ece81cc8 cmd/compile: absorb SNEZ into branch on riscv64
Change-Id: I55fd93843a7fb574a7dd66ebb87fdd96e944d555
Reviewed-on: https://go-review.googlesource.com/c/go/+/221682
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-03 12:04:46 +00:00
Joel Sing
d28b8524a4 cmd/compile: optimize subtraction of zero on riscv64
Change-Id: I9a994b01e9fecb13077c30df4b7677d40d179cce
Reviewed-on: https://go-review.googlesource.com/c/go/+/221681
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-03 12:03:48 +00:00
Joel Sing
bd6f4cd886 cmd/compile: improve subtraction of constants on riscv64
Convert subtraction of a constant into an ADDI with a negative immediate,
where possible.

Change-Id: Ie8d54b7538f0012e5f898abea233b2957fe31899
Reviewed-on: https://go-review.googlesource.com/c/go/+/221679
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-03 11:36:47 +00:00
Xiangdong Ji
52b457d6f3 runtime: use CBZ/CBNZ in linux/arm64 assembly code
Replace compare and branch on zero/non-zero instructions in linux/arm64
assembly files with CBZ/CBNZ.

Change-Id: I4dbf56678f85827e83b5863804368bc28a4603b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/209617
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2020-03-03 09:29:47 +00:00
Jingwei
34830beffa doc/mem: remove unnecessary pre tags within same snippet
currently the snippet is segmented but should be one code snippet.

Change-Id: Ic747faf9bb1b52f9d1786eca70616a05b71ee801
Reviewed-on: https://go-review.googlesource.com/c/go/+/211198
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-03 09:28:34 +00:00
Joel Sing
ed91661745 cmd/compile/internal/riscv64: correct ssa.BlockRetJmp
The obj.Prog needs to be an obj.ARET rather than an obj.AJMP, otherwise the
epilogue does not get correctly produced.

Change-Id: Ie1262f2028d3b51720eeb0364a627fbde8b14df9
Reviewed-on: https://go-review.googlesource.com/c/go/+/221683
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-03 07:33:49 +00:00
yuz
5b15941c61 flag: changed flag variable name in package doc, for clarity
Changed the flag variable name to nFlag instead of flagname,
because flagname was confusing.

Change-Id: I20dd4c4b4f605395d427a125ba4fd14580e5d766
Reviewed-on: https://go-review.googlesource.com/c/go/+/221678
Reviewed-by: Rob Pike <r@golang.org>
2020-03-03 04:56:11 +00:00
Emmanuel T Odeke
972df38445 runtime: during panic, print value instead of address, if kind is printable
Make panics more useful by printing values, if their
underlying kind is printable, instead of just their memory address.

Thus now given any custom type derived from any of:
    float*, int*, string, uint*

if we have panic with such a result, its value will be printed.

Thus given any of:
    type MyComplex128 complex128
    type MyFloat64 float64
    type MyString string
    type MyUintptr uintptr

    panic(MyComplex128(32.1 + 10i))
    panic(MyFloat64(-93.7))
    panic(MyString("This one"))
    panic(MyUintptr(93))

They will now print in the panic:

    panic: main.MyComplex64(+1.100000e-001+3.000000e+000i)
    panic: main.MyFloat64(-9.370000e+001)
    panic: main.MyString("This one")
    panic: main.MyUintptr(93)

instead of:

    panic: (main.MyComplex128) (0xe0100,0x138cc0)
    panic: (main.MyFloat64) (0xe0100,0x138068)
    panic: (main.MyString) (0x48aa00,0x4c0840)
    panic: (main.MyUintptr) (0xe0100,0x137e58)

and anything else will be printed as in the past with:

    panic: (main.MyStruct) (0xe4ee0,0x40a0e0)

Also while here, updated the Go1.15 release notes.

Fixes #37531

Change-Id: Ia486424344a386014f2869ab3483e42a9ef48ac4
Reviewed-on: https://go-review.googlesource.com/c/go/+/221779
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-03-03 02:34:32 +00:00
Robert Griesemer
2001685ec0 cmd/compile/internal/syntax: add -skip flag to exclude files from TestStdLib
TestStdLib reports parsed lines and lines/s information. To make
it easier to compare apples to apples when making changes in the
std lib, a regular expression provided via the -skip flag filters
files we don't want to process.

Change-Id: I27d9c32032eac4e78581205892e4f26947c91bd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/221600
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-03 01:01:45 +00:00
Josh Bleecher Snyder
9828c43288 runtime: prevent allocation when converting small ints to interfaces
Prior to this change, we avoid allocation when
converting 0 to an interface.

This change extends that optimization to larger value types
whose values happens to be in the range 0 to 255.
This is marginally more expensive in the case of a 0 value,
in that the address is computed rather than fixed.

name                         old time/op  new time/op  delta
ConvT2ESmall-8               2.36ns ± 4%  2.65ns ± 4%  +12.23%  (p=0.000 n=87+91)
ConvT2EUintptr-8             2.36ns ± 4%  2.84ns ± 6%  +20.05%  (p=0.000 n=96+99)
ConvT2ELarge-8               23.8ns ± 2%  23.1ns ± 3%   -2.94%  (p=0.000 n=93+95)
ConvT2ISmall-8               2.67ns ± 5%  2.74ns ±27%     ~     (p=0.214 n=99+100)
ConvT2IUintptr-8             2.65ns ± 5%  2.46ns ± 5%   -7.19%  (p=0.000 n=98+98)
ConvT2ILarge-8               24.2ns ± 2%  23.5ns ± 4%   -3.16%  (p=0.000 n=91+97)
ConvT2Ezero/zero/16-8        2.79ns ± 6%  2.99ns ± 4%   +7.52%  (p=0.000 n=94+88)
ConvT2Ezero/zero/32-8        2.34ns ± 3%  2.65ns ± 3%  +13.06%  (p=0.000 n=92+98)
ConvT2Ezero/zero/64-8        2.35ns ± 4%  2.65ns ± 6%  +12.86%  (p=0.000 n=99+94)
ConvT2Ezero/zero/str-8       2.55ns ± 4%  2.54ns ± 4%     ~     (p=0.063 n=97+99)
ConvT2Ezero/zero/slice-8     2.82ns ± 4%  2.85ns ± 5%   +1.00%  (p=0.000 n=99+95)
ConvT2Ezero/zero/big-8       94.3ns ± 5%  93.4ns ± 4%   -0.94%  (p=0.000 n=88+90)
ConvT2Ezero/nonzero/str-8    29.6ns ± 3%  27.7ns ± 3%   -6.69%  (p=0.000 n=98+97)
ConvT2Ezero/nonzero/slice-8  36.6ns ± 2%  37.1ns ± 2%   +1.31%  (p=0.000 n=94+90)
ConvT2Ezero/nonzero/big-8    93.4ns ± 3%  92.7ns ± 3%   -0.74%  (p=0.000 n=88+84)
ConvT2Ezero/smallint/16-8    13.3ns ± 4%   2.7ns ± 6%  -79.82%  (p=0.000 n=100+97)
ConvT2Ezero/smallint/32-8    12.5ns ± 1%   2.9ns ± 5%  -77.17%  (p=0.000 n=85+96)
ConvT2Ezero/smallint/64-8    14.7ns ± 3%   2.6ns ± 3%  -82.05%  (p=0.000 n=94+94)
ConvT2Ezero/largeint/16-8    14.0ns ± 4%  13.2ns ± 7%   -5.44%  (p=0.000 n=95+99)
ConvT2Ezero/largeint/32-8    12.8ns ± 4%  12.9ns ± 3%     ~     (p=0.096 n=99+87)
ConvT2Ezero/largeint/64-8    15.5ns ± 2%  15.0ns ± 2%   -3.46%  (p=0.000 n=95+96)

An example of a program for which this makes a perceptible difference
is running the compiler with the -S flag:

name        old time/op       new time/op       delta
Template          349ms ± 2%        344ms ± 2%   -1.48%  (p=0.000 n=23+25)
Unicode           138ms ± 4%        136ms ± 3%   -1.67%  (p=0.003 n=25+25)
GoTypes           1.25s ± 2%        1.24s ± 2%   -1.11%  (p=0.001 n=24+25)
Compiler          5.73s ± 2%        5.67s ± 2%   -1.09%  (p=0.002 n=25+24)
SSA               20.2s ± 2%        19.9s ± 2%   -1.45%  (p=0.000 n=25+23)
Flate             216ms ± 4%        210ms ± 2%   -2.77%  (p=0.000 n=25+24)
GoParser          283ms ± 2%        278ms ± 3%   -1.58%  (p=0.000 n=23+23)
Reflect           757ms ± 2%        745ms ± 2%   -1.58%  (p=0.000 n=25+25)
Tar               303ms ± 4%        296ms ± 2%   -2.20%  (p=0.000 n=22+23)
XML               415ms ± 2%        411ms ± 3%   -0.94%  (p=0.002 n=25+22)
[Geo mean]        726ms             715ms        -1.59%

name        old user-time/op  new user-time/op  delta
Template          434ms ± 3%        427ms ± 2%   -1.66%  (p=0.000 n=23+24)
Unicode           204ms ±12%        198ms ±12%   -2.83%  (p=0.032 n=25+25)
GoTypes           1.59s ± 2%        1.56s ± 2%   -1.64%  (p=0.000 n=22+25)
Compiler          7.50s ± 1%        7.40s ± 2%   -1.32%  (p=0.000 n=25+25)
SSA               27.2s ± 2%        26.8s ± 2%   -1.50%  (p=0.000 n=24+23)
Flate             266ms ± 6%        254ms ± 3%   -4.38%  (p=0.000 n=25+25)
GoParser          357ms ± 2%        351ms ± 2%   -1.90%  (p=0.000 n=24+23)
Reflect           966ms ± 2%        947ms ± 2%   -1.94%  (p=0.000 n=24+25)
Tar               387ms ± 2%        380ms ± 3%   -1.83%  (p=0.000 n=22+24)
XML               538ms ± 1%        532ms ± 1%   -1.15%  (p=0.000 n=24+20)
[Geo mean]        942ms             923ms        -2.02%

name        old alloc/op      new alloc/op      delta
Template         54.1MB ± 0%       52.9MB ± 0%   -2.26%  (p=0.000 n=25+25)
Unicode          33.5MB ± 0%       33.1MB ± 0%   -1.03%  (p=0.000 n=25+24)
GoTypes           189MB ± 0%        185MB ± 0%   -2.27%  (p=0.000 n=25+25)
Compiler          875MB ± 0%        858MB ± 0%   -1.99%  (p=0.000 n=23+25)
SSA              3.19GB ± 0%       3.13GB ± 0%   -1.95%  (p=0.000 n=25+25)
Flate            32.9MB ± 0%       32.2MB ± 0%   -2.26%  (p=0.000 n=25+25)
GoParser         44.0MB ± 0%       42.9MB ± 0%   -2.33%  (p=0.000 n=25+25)
Reflect           117MB ± 0%        114MB ± 0%   -2.60%  (p=0.000 n=25+25)
Tar              48.6MB ± 0%       47.5MB ± 0%   -2.18%  (p=0.000 n=25+24)
XML              65.7MB ± 0%       64.4MB ± 0%   -1.96%  (p=0.000 n=23+25)
[Geo mean]        118MB             115MB        -2.08%

name        old allocs/op     new allocs/op     delta
Template          1.07M ± 0%        0.92M ± 0%  -14.29%  (p=0.000 n=25+25)
Unicode            539k ± 0%         494k ± 0%   -8.27%  (p=0.000 n=25+25)
GoTypes           3.97M ± 0%        3.43M ± 0%  -13.71%  (p=0.000 n=24+25)
Compiler          17.6M ± 0%        15.4M ± 0%  -12.69%  (p=0.000 n=25+24)
SSA               66.1M ± 0%        58.1M ± 0%  -12.17%  (p=0.000 n=25+25)
Flate              629k ± 0%         536k ± 0%  -14.73%  (p=0.000 n=24+24)
GoParser           929k ± 0%         799k ± 0%  -13.96%  (p=0.000 n=25+25)
Reflect           2.49M ± 0%        2.11M ± 0%  -15.28%  (p=0.000 n=25+25)
Tar                919k ± 0%         788k ± 0%  -14.30%  (p=0.000 n=25+25)
XML               1.28M ± 0%        1.11M ± 0%  -12.85%  (p=0.000 n=24+25)
[Geo mean]        2.32M             2.01M       -13.24%

There is a slight increase in binary size from this change:

file      before    after     Δ       %
addr2line 4307728   4307760   +32     +0.001%
api       5972680   5972728   +48     +0.001%
asm       5114200   5114232   +32     +0.001%
buildid   2843720   2847848   +4128   +0.145%
cgo       4823736   4827864   +4128   +0.086%
compile   24912056  24912104  +48     +0.000%
cover     5259800   5259832   +32     +0.001%
dist      3665080   3665128   +48     +0.001%
doc       4672712   4672744   +32     +0.001%
fix       3376952   3376984   +32     +0.001%
link      6618008   6622152   +4144   +0.063%
nm        4253280   4257424   +4144   +0.097%
objdump   4655376   4659504   +4128   +0.089%
pack      2294280   2294328   +48     +0.002%
pprof     14747476  14751620  +4144   +0.028%
test2json 2819320   2823448   +4128   +0.146%
trace     11665068  11669212  +4144   +0.036%
vet       8342360   8342408   +48     +0.001%

Change-Id: I38ef70244e23069bfd14334061d43ae22a294519
Reviewed-on: https://go-review.googlesource.com/c/go/+/216401
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-02 23:14:55 +00:00
Josh Bleecher Snyder
4f989323a5 cmd/compile: regenerate rules
CL 210897 went in concurrently with some rulegen.go changes.
Regenerate.

Change-Id: I39ffa8bdffdfcc7f60cc8158d188fb1a3e70fcb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/221787
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-02 23:14:42 +00:00
Robert Griesemer
117297cf42 go/types: simplify method set computation
After fixing #37081 we don't need to explicitly keep track of
field collisions in the method set computation anymore; we only
need to know which field (names) exists at each embedding level.
Simplify the code by removing the dedicated fieldSet data type
in favor of a simple string set.

Follow-up on https://golang.org/cl/218617; separate CL to make it
easier to identify a problem with these two changes, should there
be one.

Updates #37081.

Change-Id: I5c259c63c75a148a42d5c3e1e4860e1ffe5631bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/218618
Reviewed-by: Alan Donovan <adonovan@google.com>
2020-03-02 22:19:08 +00:00
Robert Griesemer
ca3dd1d36b go/types: fix method set computation
When computing method sets, any struct field that "shadows" a
method at a lower embedding level eliminates that method from
the method set. Treat any field at a given level as a "collision"
for any methods at lower embedding level.

Method sets are not directly used by go/types (except for self-
verification in debug mode); they are a functionality provided
by go/types. Thus, the method sets that go/types is using were
not affected by this bug.

Fixes #37081.

Change-Id: Ic1937e01891b3614a6f7965d4384aeb485f3fe3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/218617
Reviewed-by: Alan Donovan <adonovan@google.com>
2020-03-02 22:18:30 +00:00
Josh Bleecher Snyder
97a268624c cmd/compile: add -d=ssa/check/seed=SEED
This change adds the option to run the ssa checker with a random seed.
The current system uses a completely fixed seed,
which is good for reproducibility but bad for exploring the state space.

Preserve what we have, but also provide a way for the caller
to provide a seed. The caller can report the seed
alongside any failures.

Change-Id: I2676a8112d8260e6cac86d95d2e8db4d3221aeeb
Reviewed-on: https://go-review.googlesource.com/c/go/+/216418
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-02 22:11:29 +00:00
Josh Bleecher Snyder
37fc092be1 cmd/compile: remove duplicate ppc64 rules
Const64 gets lowered to MOVDconst.
Change rules using interior Const64 to use MOVDconst instead,
to be less dependent on rule application order.

As a result of doing this, some of the rules end up being
exact duplicates; remove those.

We had those exact duplicates because of the order dependency;
ppc64 had no way to optimize away shifts by a constant
if the initial lowering didn't catch it.

Add those optimizations as well.
The outcome is the same, but this makes the overall rules more robust.

Change-Id: Iadd97a9fe73d52358d571d022ace145e506d160b
Reviewed-on: https://go-review.googlesource.com/c/go/+/220877
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2020-03-02 21:59:19 +00:00
Keith Randall
63f1bc5992 runtime: print instruction bytes when reporting a SIGILL
Print the bytes of the instruction that generated a SIGILL.
This should help us respond to bug reports without having to
go back-and-forth with the reporter to get the instruction involved.
Might also help with SIGILL problems that are difficult to reproduce.

Update #37513

Change-Id: I33059b1dbfc97bce16142a843f32a88a6547e280
Reviewed-on: https://go-review.googlesource.com/c/go/+/221431
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-03-02 18:46:06 +00:00
Josh Bleecher Snyder
a2bff7c296 cmd/compile: make pre-elimination of rulegen bounds checks more precise
In cases in which we had a named value whose args were all _,
like this rule from ARM.rules:

(MOVBUreg x:(MOVBUload _ _)) -> (MOVWreg x)

We previously inserted

_ = x.Args[1]

even though it is unnecessary.
This change eliminates this pointless bounds check.
And in other cases, we now check bounds just as far as strictly necessary.

No significant movement on any compiler metrics.
Just nicer (and less) code.

Passes toolstash-check -all.

Change-Id: I075dfe9f926cc561cdc705e9ddaab563164bed3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/221781
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-02 17:40:11 +00:00
Josh Bleecher Snyder
5e4da0adac cmd/compile: add streamlined Block Reset+AddControl routines
For use in rewrite rules. Shrinks cmd/compile:

compile 20082104  19967416  -114688 -0.571%

Passes toolstash-check -all.

Change-Id: Ic856508b27ec5b7fb9b6ca63e955a7139ae7dc30
Reviewed-on: https://go-review.googlesource.com/c/go/+/221780
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-02 17:40:00 +00:00
Keith Randall
d8bf079751 runtime: use quiet NaNs in softfloat implementation
Update #37455

Change-Id: Ieac0823aa398d73187c009037be15ba34c84f3d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/221433
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-02 17:17:18 +00:00
Keith Randall
bef0b4ea8f hash/maphash: add more tests for seed generation
Test all the paths by which a Hash picks its seed.
Make sure they all behave identically to a preset seed.

Change-Id: I2f7950857697f2f07226b96655574c36931b2aae
Reviewed-on: https://go-review.googlesource.com/c/go/+/220686
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Vladimir Evgrafov <evgrafov.vladimir@gmail.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2020-03-02 17:15:20 +00:00
Josh Bleecher Snyder
d7c073ecbf cmd/compile: add specialized Value reset for OpCopy
This:

* Simplifies and shortens the generated code for rewrite rules.
* Shrinks cmd/compile by 86k (0.4%) and makes it easier to compile.
* Removes the stmt boundary code wrangling from Value.reset,
  in favor of doing it in the one place where it actually does some work,
  namely the writebarrier pass. (This was ascertained by inspecting the
  code for cases in which notStmtBoundary values were generated.)

Passes toolstash-check -all.

Change-Id: I25671d4c4bbd772f235195d11da090878ea2cc07
Reviewed-on: https://go-review.googlesource.com/c/go/+/221421
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2020-03-02 16:24:47 +00:00
Meng Zhuo
ab7ecea0c8 cmd/compile: add intrinsics for runtime/internal/math on MIPS64x
name              old time/op  new time/op  delta
MulUintptr/small  8.42ns ± 0%  5.93ns ± 0%  -29.66%  (p=0.000 n=9+10)
MulUintptr/large  11.1ns ± 0%   7.4ns ± 0%  -33.17%  (p=0.000 n=10+9)

Change-Id: I6659a886389660461fc2c90bd248243f6e7c29d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/210897
Run-TryBot: Meng Zhuo <mengzhuo1203@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-03-02 16:12:20 +00:00
Bryan C. Mills
12d02e7d8e net/http: verify RoundTripper invariants in the send function
Issue #37598 reports a nil-panic in *Client.send that can
only occur if one of the RoundTripper invariants is violated.
Unfortunately, that condition is currently difficult to diagnose: it
manifests as a panic during a Response field access, rather than
something the user can easily associate with an specific erroneous
RoundTripper implementation.

No test because the new code paths are supposed to be unreachable.

Updates #37598

Change-Id: If0451e9c6431f6fab7137de43727297a80def05b
Reviewed-on: https://go-review.googlesource.com/c/go/+/221818
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-03-02 15:39:23 +00:00
Changkun Ou
acac535c3c doc: race condition in unsynchronized send/close
This CL documents that unsynchronized send and close operations
on a channel are detected as a race condition.

Fixes #27769

Change-Id: I7495a2d0dd834c3f3b6339f8ca18ea21ae979aa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/219637
Reviewed-by: Rob Pike <r@golang.org>
2020-03-02 08:42:10 +00:00
Tobias Klauser
b79acf97c7 internal/cpu: use anonymous struct for CPU feature vars
Like in x/sys/cpu, use anonymous structs to declare the CPU feature vars
instead of defining single-use types. Also, order the vars
alphabetically.

Change-Id: Iedd3ca51916e3cbb852d2aeed18b3a4c6613e778
Reviewed-on: https://go-review.googlesource.com/c/go/+/221757
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2020-03-02 08:32:38 +00:00
Keith Randall
c7a59a99e3 os: plan9 seek() should invalidate cached directory info
Update #37161

Change-Id: Iee828bbcc8436af29ca6dd9ed897cb5265a57cf8
Reviewed-on: https://go-review.googlesource.com/c/go/+/221778
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-02 05:20:50 +00:00
Jean de Klerk
4978f5e6ea time: use values larger than 24 for day for time.Format examples
Currently, the time.Format docs use 7 Mar 2015 as the day/month/year. In numeric
form, that is either 7/3/2015 or 3/7/2015 depending on which part of the world
you're from. This is extremely confusing.

In fact, the reference time being defined in a very US-centric way is quite
confusing for the rest of the world, too [1].

We can't change that, but we can make the time.Format docs more comprehendable
to the rest of the world without sacrificing by simply choosing a day that is
not ambiguous (a value greater than 24 for day). This CL does makes the
necessary change.

Note: this CL moves some of the padding examples into their own example, since
those examples do need a <10 day to demonstrate padding.

1: Additional context: a very old golang-nuts thread in which Rob expresses some
regret about the format being the USA standard, rather than the alternative:
https://groups.google.com/forum/m/#!msg/golang-nuts/0nQbfyNzk9E/LWbMgpRQNOgJ.

Change-Id: If0a07c5e0dab86f8420cbf59543405eb857aa7f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/221612
Run-TryBot: Jean de Klerk <deklerk@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2020-03-02 04:25:41 +00:00
Keith Randall
529988d62c os: seek should invalidate any cached directory reads
When we seek on the underlying FD, discard any directory entries
we've already read and cached. This makes sure we won't return
the same entry twice.

We already fixed this for Darwin in CL 209961.

Fixes #37161

Change-Id: I20e1ac8d751443135e67fb4c43c18d69befb643b
Reviewed-on: https://go-review.googlesource.com/c/go/+/219143
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-03-01 22:26:33 +00:00
Torben Schinke
a4f7b0879c syscall/js: improve documentation of js.FuncOf
The existing documentation is improved to be more
explicit about the lifecycle and its consequences.

Fixes #34324

Change-Id: I9969afc69f6eeb7812c11fe821a842794df5aa5b
GitHub-Last-Rev: 246a499166
GitHub-Pull-Request: golang/go#34551
Reviewed-on: https://go-review.googlesource.com/c/go/+/197458
Reviewed-by: Richard Musiol <neelance@gmail.com>
2020-03-01 21:04:30 +00:00
Richard Musiol
e44cda3aa9 syscall: fix Fchdir on js/wasm
NodeJS does not support fchdir so it has to be emulated with chdir by
saving the path when opening a directory.

However, if the path opened is relative, saving this path is not
sufficient, because after changing the working directory the path
does not resolve correctly any more, thus a subsequent fd.Chdir() fails.

This change fixes the issue by resolving a relative path when
opening the directory and saving the absolute path instead.

Fixes #37448

Change-Id: Id6bc8c4232b0019fc11e850599a526336608ce54
Reviewed-on: https://go-review.googlesource.com/c/go/+/221717
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-01 21:02:40 +00:00
Josh Bleecher Snyder
7913f7dfcf cmd/compile: add specialized AddArgN functions for rewrite rules
This shrinks the compiler without impacting performance.
(The performance-sensitive part of rewrite rules is the non-match case.)
Passes toolstash-check -all.

Executable size:

file    before    after     Δ       %       
compile 20356168  20163960  -192208 -0.944% 
total   115599376 115407168 -192208 -0.166% 

Text size:

file                       before   after    Δ       %       
cmd/compile/internal/ssa.s 3928309  3778774  -149535 -3.807% 
total                      18862943 18713408 -149535 -0.793% 

Memory allocated compiling package SSA:

SSA               12.7M ± 0%        12.5M ± 0%  -1.74%  (p=0.008 n=5+5)

Compiler speed impact:

name        old time/op       new time/op       delta
Template          211ms ± 1%        211ms ± 2%    ~     (p=0.832 n=49+49)
Unicode          82.8ms ± 2%       83.2ms ± 2%  +0.44%  (p=0.022 n=46+49)
GoTypes           726ms ± 1%        728ms ± 2%    ~     (p=0.076 n=46+48)
Compiler          3.39s ± 2%        3.40s ± 2%    ~     (p=0.633 n=48+49)
SSA               7.71s ± 1%        7.65s ± 1%  -0.78%  (p=0.000 n=45+44)
Flate             134ms ± 1%        134ms ± 1%    ~     (p=0.195 n=50+49)
GoParser          167ms ± 1%        167ms ± 1%    ~     (p=0.390 n=47+47)
Reflect           453ms ± 3%        452ms ± 2%    ~     (p=0.492 n=48+49)
Tar               184ms ± 3%        184ms ± 2%    ~     (p=0.862 n=50+48)
XML               248ms ± 2%        248ms ± 2%    ~     (p=0.096 n=49+47)
[Geo mean]        415ms             415ms       -0.03%

name        old user-time/op  new user-time/op  delta
Template          273ms ± 1%        273ms ± 2%    ~     (p=0.711 n=48+48)
Unicode           117ms ± 6%        117ms ± 5%    ~     (p=0.633 n=50+50)
GoTypes           972ms ± 2%        974ms ± 1%  +0.29%  (p=0.016 n=47+49)
Compiler          4.46s ± 6%        4.51s ± 6%    ~     (p=0.093 n=50+50)
SSA               10.4s ± 1%        10.3s ± 2%  -0.94%  (p=0.000 n=45+50)
Flate             166ms ± 2%        167ms ± 2%    ~     (p=0.148 n=49+48)
GoParser          202ms ± 1%        202ms ± 2%  -0.28%  (p=0.014 n=47+49)
Reflect           594ms ± 2%        594ms ± 2%    ~     (p=0.717 n=48+49)
Tar               224ms ± 2%        224ms ± 2%    ~     (p=0.805 n=50+49)
XML               311ms ± 1%        310ms ± 1%    ~     (p=0.177 n=49+48)
[Geo mean]        537ms             537ms       +0.01%


Change-Id: I562b9f349b34ddcff01771769e6dbbc80604da7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/221237
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-03-01 15:27:58 +00:00
Mark Pulford
a908e09a34 runtime: deflake CGO traceback tests
The CGO traceback function is called whenever CGO code is executing and
a signal is received. This occurs much more frequently now SIGURG
is used for preemption.

Disable signal preemption to significantly increase the likelihood that
a signal results in a profile sample during the test.

Updates #37201

Change-Id: Icb1a33ab0754d1a74882a4ee265b4026abe30bdc
Reviewed-on: https://go-review.googlesource.com/c/go/+/219417
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-03-01 14:57:24 +00:00
Bradford Lamson-Scribner
1e9665da8f cmd/compile: add a dark mode to ssa html generation which can be toggled
add a tag that when clicked, toggles a dark mode. It keeps intact
the grayed out dead values/blocks, all the highlight colors, and ensures
text is always readable.

Fixes #34325

Change-Id: I4af1e4b5f4a5b63e54c992e90f8474cc51c63465
Reviewed-on: https://go-review.googlesource.com/c/go/+/220260
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-01 05:45:39 +00:00
Alex Brainman
95f3821390 cmd/go, cmd/link: implement -buildmode=pie on windows
This CL implements windows version of -buildmode=pie code in both
cmd/go and cmd/link.

Windows executables built with -buildmode=pie set (unlike the one
built with -buildmode=exe) will have extra .reloc PE section, and
will have no IMAGE_FILE_RELOCS_STRIPPED flag set. They will also
have IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE flag set, and
IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA flag set for windows/amd64.

Both cgo and non-cgo versions are implemented. And TestBuildmodePIE
is extended to test both cgo and non-cgo versions on windows and
linux.

This CL used some code from CLs 152759 and 203602.

RELNOTE=yes

Fixes #27144
Updates #35192

Change-Id: I1249e4ffbd79bd4277efefb56db321c390c0f76f
Reviewed-on: https://go-review.googlesource.com/c/go/+/214397
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-03-01 05:00:10 +00:00
Shuo
91bc75b487 time: optimize Time.ISOWeek
name       old time/op  new time/op  delta
ISOWeek-4  57.7ns ± 5%  27.9ns ±10%  -51.54%  (p=0.000 n=48+49)

Fixes #37534

Change-Id: Ic4673ced44a4b0190018e87207743ed9500fb1e0
GitHub-Last-Rev: a376c57e83
GitHub-Pull-Request: golang/go#36316
Reviewed-on: https://go-review.googlesource.com/c/go/+/212837
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-03-01 02:56:31 +00:00
Ian Lance Taylor
2172b229b9 runtime/pprof/internal/profile: make error message readable
The error message for an unrecognized type in decodeField was using
string(i) for an int type i. It was recently changed (by  me) to
string(rune(i)), but that just avoided a vet warning without fixing
the problem. This CL fixes the problem by using fmt.Errorf.

We also change the message to "unknown wire type" to match the master
copy of this code in github.com/google/pprof/profile/proto.go.

Updates #32479

Change-Id: Ia91ea6d5edbd7cd946225d1ee96bb7623b52bb44
Reviewed-on: https://go-review.googlesource.com/c/go/+/221384
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-01 02:22:06 +00:00
Emmanuel T Odeke
c1abd5ab70 runtime: don't invoke t.Fatal* in goroutine in TestLibraryCtrlHandler
Change-Id: I8bb06c360cab3e5a74b0b0f98bb25cca4741d66d
Reviewed-on: https://go-review.googlesource.com/c/go/+/221605
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-03-01 02:18:27 +00:00