1
0
mirror of https://github.com/golang/go synced 2024-11-27 04:31:21 -07:00
Commit Graph

39838 Commits

Author SHA1 Message Date
Agniva De Sarker
b6544a2a87 testing/cover: improve message when a package has no statements
Fixes #25492

Change-Id: Ic1496857524dad0c0a77f3bb80fa084c9bf00aa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/155777
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2019-03-13 04:11:58 +00:00
Clément Chigot
0ff9df6b53 cmd: disable DWARF with old ld on aix/ppc64
DWARF relocations isn't working with some older ld, because of
-Wl,-bnoobjreorder which is needed on Go.
This commit checks ld's version and disable DWARF generation in cmd/link
if it's too old. Some tests must therefore be skipped.

Change-Id: I2e794c263eb0dfe0b42e7062fb80c26f086b44d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/164007
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-13 02:33:58 +00:00
Robert Griesemer
bea58ef352 cmd/compile: don't report redundant error for invalid integer literals
Fixes #30722.

Change-Id: Ia4c6e37282edc44788cd8af3f6cfa10895a19e4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/166519
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-03-12 22:59:12 +00:00
Robert Griesemer
fbc5acbd70 cmd/compile: remove work-arounds for handling underscores in numbers
With math/big supporting underscores directly, there is no need to
manually remove them before calling the math/big conversion routines.

Updates #28493.

Change-Id: I6f865c8f87c3469ffd6c33f960ed540135055226
Reviewed-on: https://go-review.googlesource.com/c/go/+/166417
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-12 22:59:06 +00:00
Robert Griesemer
cfa93ba51f math/big: add support for underscores '_' in numbers
The primary change is in nat.scan which now accepts underscores for base 0.
While at it, streamlined error handling in that function as well.
Also, improved the corresponding test significantly by checking the
expected result values also in case of scan errors.

The second major change is in scanExponent which now accepts underscores when
the new sepOk argument is set. While at it, essentially rewrote that
function to match error and underscore handling of nat.scan more closely.
Added a new test for scanExponent which until now was only tested
indirectly.

Finally, updated the documentation for several functions and added many
new test cases to clients of nat.scan.

A major portion of this CL is due to much better test coverage.

Updates #28493.

Change-Id: I7f17b361b633fbe6c798619d891bd5e0a045b5c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/166157
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-03-12 22:58:58 +00:00
Daniel Martí
c4078a1998 text/tabwriter: use a single defer per Write call
Lines with single cells prompt a flush. Unfortunately, a call to
Writer.Flush also means two defers, which is an expensive operation to
do if many lines consist of single cells.

This is common when formatting code with aligned comments. Most lines
aren't going to have any comments at all, so the performance hit is
going to be noticeable.

The Write method already has a "defer handlePanic" of its own, so we
don't need to worry about panics leaking out. The error will now mention
"Write" instead of "Flush" if a panic is encountered during that nested
flush, but arguably that's a good thing; the user called Write, not
Flush.

For the reset call, add a non-deferred call as part of flushNoDefers, as
that's still necessary. Otherwise, the exported Flush method still does
a "defer b.reset".

The current tabwriter benchmarks are unaffected, since they don't
contain many single-cell lines, and because lines are written one at a
time. For that reason, we add a benchmark which has both of these
characteristics.

name    old time/op    new time/op    delta
Code-8    2.72µs ± 0%    1.77µs ± 0%  -34.88%  (p=0.000 n=6+5)

name    old alloc/op   new alloc/op   delta
Code-8      648B ± 0%      648B ± 0%     ~     (all equal)

name    old allocs/op  new allocs/op  delta
Code-8      13.0 ± 0%      13.0 ± 0%     ~     (all equal)

Perhaps unsurprisingly, go/printer also gets a bit faster, as it too
buffers its output before writing it to tabwriter.

name     old time/op  new time/op  delta
Print-8  6.53ms ± 0%  6.39ms ± 0%  -2.22%  (p=0.008 n=5+5)

Change-Id: Ie01fea5ced43886a9eb796cb1e6c810f7a810853
Reviewed-on: https://go-review.googlesource.com/c/go/+/166797
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-03-12 22:34:30 +00:00
Bryan C. Mills
01d1dc4172 cmd/go: fix typo in GoGetInsecure to actually set GOPROXY
I typo'd this variable in CL 165745, and neither I, the reviewer, nor the TryBots noticed.
But the longtest builder noticed, and it's not happy about it.

Updates #30571

Change-Id: I5e3d267346407855ec0d1f340a72dc2c521ecc63
Reviewed-on: https://go-review.googlesource.com/c/go/+/167086
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-12 21:08:33 +00:00
Bryan C. Mills
af13cfc3a2 ../test: set GOPATH in nosplit.go
This test invokes 'go build', so in module mode it needs a module
cache to guard edits to go.mod.

Fixes #30776

Change-Id: I89ebef1fad718247e7f972cd830e31d6f4a83e4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/167085
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-12 20:46:29 +00:00
Josh Bleecher Snyder
53948127d3 cmd/compile: make rulegen magic variable prediction more precise
The sheer length of the generated rules files makes my
editor and git client unhappy.
This change is a small step towards shortening them.

We recognize a few magic variables during rulegen: b, config, fe, typ.
Of these, only b appears prone to false positives.
By tightening the heuristic and fixing one case in MIPS.rules,
we can make the heuristic enough that it has no failures.
That allows us to remove the hedge assignments to _,
removing 3000 pointless lines of code.

Change-Id: I080cde5db28c8277cb3fd9ddcd829306c9a27785
Reviewed-on: https://go-review.googlesource.com/c/go/+/166979
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-03-12 20:13:46 +00:00
Bryan C. Mills
f54b8909ac cmd/go/internal/modload: treat a 'std' module outside GOROOT/src as an ordinary module
Fixes #30756

Change-Id: I046d43df56faac8fc09d53dc1e87a014dd6d530b
Reviewed-on: https://go-review.googlesource.com/c/go/+/167080
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-12 20:10:13 +00:00
Bryan C. Mills
718fdd7b48 cmd/go/internal/cfg: remove unused Gopath variable
Change-Id: Ib268157674824fd7552d3c36a61eccf8c720eaeb
Reviewed-on: https://go-review.googlesource.com/c/go/+/167083
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-12 20:09:48 +00:00
Shubham Sharma
fda1dc2939 cmd/go: document GOGCCFLAGS
Fixes #30123

Change-Id: I310b89a344a262bb758d39dfdd485ed2940cc6aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/166577
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-12 19:38:53 +00:00
Bryan C. Mills
334e750917 cmd: ensure that GOPATH is always valid in subprocesses that execute 'go build'
GOPATH/pkg contains, among other things, the module cache (and associated lockfiles).

Fixes #30776

Change-Id: I305cb3c0daab8cedd2e6ad235d4733f66af18723
Reviewed-on: https://go-review.googlesource.com/c/go/+/167082
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-12 18:58:04 +00:00
Bryan C. Mills
49448badb6 cmd/internal/obj/x86: avoid os.Chdir in issue19518_test.go
Chdir leaves the test in the wrong working directory if objdumpOutput
calls t.Fatalf (or panics), and it isn't necessary here anyway. Set
the Dir field on the commands instead.

Change-Id: I9f0eb0d4f8d15043f1e13472126ca1a1ce4b7cb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/167081
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-12 18:55:20 +00:00
Robert Griesemer
a083648165 spec: document new Go2 number literals
This CL documents the new binary and octal integer literals,
hexadecimal floats, generalized imaginary literals and digit
separators for all number literals in the spec.

Added empty lines between abutting paragraphs in some places
(a more thorough cleanup can be done in a separate CL).

A minor detail: A single 0 was considered an octal zero per the
syntax (decimal integer literals always started with a non-zero
digit). The new octal literal syntax allows 0o and 0O prefixes
and when keeping the respective octal_lit syntax symmetric with
all the others (binary_lit, hex_lit), a single 0 is not automatically
part of it anymore. Rather than complicating the new octal_lit syntax
to include 0 as before, it is simpler (and more natural) to accept
a single 0 as part of a decimal_lit. This is purely a notational
change.

R=Go1.13

Updates #12711.
Updates #19308.
Updates #28493.
Updates #29008.

Change-Id: Ib9fdc6e781f6031cceeed37aaed9d05c7141adec
Reviewed-on: https://go-review.googlesource.com/c/go/+/161098
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-12 16:13:39 +00:00
Ben Hoyt
4b4f222a0d bytes, strings: speed up TrimSpace 4-5x for common ASCII cases
This change adds a fast path for ASCII strings to both
strings.TrimSpace and bytes.TrimSpace. It doesn't slow down the
non-ASCII path much, if at all.

I added benchmarks for strings.TrimSpace as it didn't have any, and
I fleshed out the benchmarks for bytes.TrimSpace as it just had one
case (for ASCII). The benchmarks (and the code!) are now the same
between the two versions. Below are the benchmark results:

strings.TrimSpace:

name                      old time/op  new time/op  delta
TrimSpace/NoTrim-8        18.6ns ± 0%   3.8ns ± 0%  -79.53%  (p=0.000 n=5+4)
TrimSpace/ASCII-8         33.5ns ± 2%   6.0ns ± 3%  -82.05%  (p=0.008 n=5+5)
TrimSpace/SomeNonASCII-8  97.1ns ± 1%  88.6ns ± 1%   -8.68%  (p=0.008 n=5+5)
TrimSpace/JustNonASCII-8   144ns ± 0%   143ns ± 0%     ~     (p=0.079 n=4+5)

bytes.TrimSpace:

name                      old time/op  new time/op  delta
TrimSpace/NoTrim-8        18.9ns ± 1%   4.1ns ± 1%  -78.34%  (p=0.008 n=5+5)
TrimSpace/ASCII-8         29.9ns ± 0%   6.3ns ± 1%  -79.06%  (p=0.008 n=5+5)
TrimSpace/SomeNonASCII-8  91.5ns ± 0%  82.3ns ± 0%  -10.03%  (p=0.008 n=5+5)
TrimSpace/JustNonASCII-8   150ns ± 0%   150ns ± 0%     ~     (all equal)

Fixes #29122

Change-Id: Ica45cd86a219cadf60173ec9db260133cd1d7951
Reviewed-on: https://go-review.googlesource.com/c/go/+/152917
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-12 15:52:17 +00:00
Elias Naur
10aede26d0 misc/android: fix detection of GOROOT tests
strings.HasPrefix is not good enough to determine whether a path
is a subdirectory of another because it does not respect path
boundaries. filepath.Rel is good eonugh as long as we filter out results
that use parent directories, "..".

Hopefully fix the android emulator builders on the subrepositories.

Change-Id: I17ee7e0028c0b0b26a6c5f67629f53c9a660c6e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/167117
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-12 15:47:18 +00:00
Bryan C. Mills
d6891bd480 cmd/go: search the target for patterns when -mod=vendor is set
This fixes the root cause of the bootstrap failure reported in
https://groups.google.com/d/msg/golang-dev/xcVJDj5GJ84/U0pVnUOnBwAJ.

Updates #30228

Change-Id: I9ce0898922a5aac1f61ceff30319cf88031676c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/167079
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-12 15:44:29 +00:00
Bryan C. Mills
781da44091 cmd/dist: write and use a go.mod file in the bootstrap directory
Updates #30228

Change-Id: Ica28525b31a8a787875c147e16274eba8f4dbffc
Reviewed-on: https://go-review.googlesource.com/c/go/+/167078
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-12 15:43:46 +00:00
Bryan C. Mills
6c527aa583 cmd/dist: revert mod=vendor change accidentally included in CL 164623
I thought I had removed all of the 'mod=vendor' hacks I had inserted
previously, but apparently missed this one in a bad merge or rebase.

Updates #30228

Change-Id: Ia5aea754bf986458373fefd08fa9dd3941e31e43
Reviewed-on: https://go-review.googlesource.com/c/go/+/167077
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-12 14:57:47 +00:00
fanzha02
a85afef277 cmd/compile: add handling for new floating-point comparisons flags
The CL 164718 adds new condition flags for floating-point comparisons
in arm64 backend, but dose not add the handling in rewrite.go for
corresponding Ops, which causes issue 30679. And this CL fixes this
issue.

Fixes #30679

Change-Id: I8acc749f78227c3e9e74fa7938f05fb442fb62c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/166579
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-12 14:01:26 +00:00
Brian Kessler
ef891e1c83 math/big: implement Int.TrailingZeroBits
Implemented via the underlying nat.trailingZeroBits.

Fixes #29578

Change-Id: If9876c5a74b107cbabceb7547bef4e44501f6745
Reviewed-on: https://go-review.googlesource.com/c/go/+/160681
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-12 13:18:27 +00:00
Tobias Klauser
14a58d65e3 internal/bytealg: share code for equal functions on arm
Move the shared code into byteal.memeqbody. This will allow to implement
optimizations (e.g. for #29001) in a single function.

Change-Id: Iaa34ddeb7068d92c35a8b4e581b7fd92da56535c
Reviewed-on: https://go-review.googlesource.com/c/go/+/166677
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-03-12 07:27:56 +00:00
Tobias Klauser
21a634e2e9 os: drop special case for FreeBSD 10.4 in newFile
Support for FreeBSD 10 will be dropped with Go 1.13, so revert the
workaround introduced in CL 157099.

Updates #29633
Updates #27619

Change-Id: I1a2e50d3f807a411389f3db07c0f4535a590da02
Reviewed-on: https://go-review.googlesource.com/c/go/+/165801
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-12 06:33:01 +00:00
Bryan C. Mills
9fedec79ed go/build: bypass importGo if srcDir is in GOROOT/src
This fixes the builder flake observed in
https://build.golang.org/log/84fe80f8f091b9cef639b3ae2422a673f1462810,
which could be replicated by running

	GOPROXY=off GOPATH=$(mktemp -d) go test go/internal/srcimporter

Updates #30228
Fixes #30760

Change-Id: Ibf8b7a2e211611960b074b74af91acd4f0196edb
Reviewed-on: https://go-review.googlesource.com/c/go/+/166977
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-12 05:00:20 +00:00
Bryan C. Mills
8b2a2d0394 Revert "cmd/go: change the default value of GO111MODULE to 'on'"
This reverts commit cf4691650c
(CL 162698).

Reason for revert: broke make.bash bootstrapping from head.

Change-Id: I3de6d26b1af9038c6b92dec88667bfa734060a41
Reviewed-on: https://go-review.googlesource.com/c/go/+/166985
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-12 02:07:34 +00:00
Michael Stapelberg
2bd28cee23 syscall: correctly set up uid/gid mappings in user namespaces
Before this CL, uid/gid mapping was always set up from the parent
process, which is a privileged operation.

When using unprivileged user namespaces, a process can modify its
uid/gid mapping after the unshare(2) call (but setting the uid/gid
mapping from another process is NOT possible).

Fixes #29789

Change-Id: I8c96a03f5da23fe80bbb83ef051ad89cf185d750
Reviewed-on: https://go-review.googlesource.com/c/go/+/158298
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-12 00:40:34 +00:00
Than McIntosh
30cc8a46c4 test: add new test for gccgo compilation problem
New test for issue 30659 (compilation error due to bad
export data).

Updates #30659.

Change-Id: I2541ee3c379e5b22033fea66bb4ebaf720cc5e1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/166917
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-12 00:04:59 +00:00
Leon Klingele
62bfa69e6e net/http: add missing error checks in tests
Change-Id: I73441ba2eb349f0e0f25068e6b24c74dd33f1456
GitHub-Last-Rev: b9e6705962
GitHub-Pull-Request: golang/go#30017
Reviewed-on: https://go-review.googlesource.com/c/go/+/160441
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-11 21:40:21 +00:00
Josh Bleecher Snyder
c9ccdf1f8c cmd/compile: make deadcode pass cheaper
The deadcode pass runs a lot.
I'd like it to run even more.

This change adds dedicated storage for deadcode to ssa.Cache.
In addition to being a nice win now, it makes
deadcode easier to add other places in the future.

name        old time/op       new time/op       delta
Template          210ms ± 3%        209ms ± 2%    ~     (p=0.951 n=93+95)
Unicode          92.2ms ± 3%       93.0ms ± 3%  +0.87%  (p=0.000 n=94+94)
GoTypes           739ms ± 2%        733ms ± 2%  -0.84%  (p=0.000 n=92+94)
Compiler          3.51s ± 2%        3.49s ± 2%  -0.57%  (p=0.000 n=94+91)
SSA               9.80s ± 2%        9.75s ± 2%  -0.57%  (p=0.000 n=95+92)
Flate             132ms ± 2%        132ms ± 3%    ~     (p=0.165 n=94+98)
GoParser          160ms ± 3%        159ms ± 3%  -0.42%  (p=0.005 n=96+94)
Reflect           446ms ± 4%        442ms ± 4%  -0.91%  (p=0.000 n=95+98)
Tar               186ms ± 3%        186ms ± 2%    ~     (p=0.221 n=94+97)
XML               252ms ± 2%        250ms ± 2%  -0.55%  (p=0.000 n=95+94)
[Geo mean]        430ms             429ms       -0.34%

name        old user-time/op  new user-time/op  delta
Template          256ms ± 3%        257ms ± 3%    ~     (p=0.521 n=94+98)
Unicode           120ms ± 9%        121ms ± 9%    ~     (p=0.074 n=99+100)
GoTypes           935ms ± 3%        935ms ± 2%    ~     (p=0.574 n=82+96)
Compiler          4.56s ± 1%        4.55s ± 2%    ~     (p=0.247 n=88+90)
SSA               13.6s ± 2%        13.6s ± 1%    ~     (p=0.277 n=94+95)
Flate             155ms ± 3%        156ms ± 3%    ~     (p=0.181 n=95+100)
GoParser          193ms ± 8%        184ms ± 6%  -4.39%  (p=0.000 n=100+89)
Reflect           549ms ± 3%        552ms ± 3%  +0.45%  (p=0.036 n=94+96)
Tar               230ms ± 4%        230ms ± 4%    ~     (p=0.670 n=97+99)
XML               315ms ± 5%        309ms ±12%  -2.05%  (p=0.000 n=99+99)
[Geo mean]        540ms             538ms       -0.47%

name        old alloc/op      new alloc/op      delta
Template         40.3MB ± 0%       38.9MB ± 0%  -3.36%  (p=0.008 n=5+5)
Unicode          28.6MB ± 0%       28.4MB ± 0%  -0.90%  (p=0.008 n=5+5)
GoTypes           137MB ± 0%        132MB ± 0%  -3.65%  (p=0.008 n=5+5)
Compiler          637MB ± 0%        609MB ± 0%  -4.40%  (p=0.008 n=5+5)
SSA              2.19GB ± 0%       2.07GB ± 0%  -5.63%  (p=0.008 n=5+5)
Flate            25.0MB ± 0%       24.1MB ± 0%  -3.80%  (p=0.008 n=5+5)
GoParser         30.0MB ± 0%       29.1MB ± 0%  -3.17%  (p=0.008 n=5+5)
Reflect          87.1MB ± 0%       84.4MB ± 0%  -3.05%  (p=0.008 n=5+5)
Tar              37.3MB ± 0%       36.0MB ± 0%  -3.31%  (p=0.008 n=5+5)
XML              49.8MB ± 0%       48.0MB ± 0%  -3.69%  (p=0.008 n=5+5)
[Geo mean]       87.6MB            84.6MB       -3.50%

name        old allocs/op     new allocs/op     delta
Template           387k ± 0%         380k ± 0%  -1.76%  (p=0.008 n=5+5)
Unicode            342k ± 0%         341k ± 0%  -0.31%  (p=0.008 n=5+5)
GoTypes           1.39M ± 0%        1.37M ± 0%  -1.64%  (p=0.008 n=5+5)
Compiler          5.68M ± 0%        5.60M ± 0%  -1.41%  (p=0.008 n=5+5)
SSA               17.1M ± 0%        16.8M ± 0%  -1.49%  (p=0.008 n=5+5)
Flate              240k ± 0%         236k ± 0%  -1.99%  (p=0.008 n=5+5)
GoParser           309k ± 0%         304k ± 0%  -1.57%  (p=0.008 n=5+5)
Reflect           1.01M ± 0%        0.99M ± 0%  -2.69%  (p=0.008 n=5+5)
Tar                360k ± 0%         353k ± 0%  -1.91%  (p=0.008 n=5+5)
XML                447k ± 0%         441k ± 0%  -1.26%  (p=0.008 n=5+5)
[Geo mean]         858k              844k       -1.60%

Fixes #15306

Change-Id: I9f558adb911efddead3865542fe2ca71f66fe1da
Reviewed-on: https://go-review.googlesource.com/c/go/+/166718
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-03-11 21:20:01 +00:00
Elias Naur
810809ebc2 misc/android: copy less from GOROOT to the device
The android emulator builders is running out of space after CL 165797
copied most of GOROOT to the device.
The pkg directory is by far the largest, so only include what seems
necessary to build the x/ repositories: pkg/android_$GOARCH and
pkg/tool/android_$GOARCH.

While here, rename the device root directory to match the exec
wrapper name and make sure the deferred cleanups actually run before
os.Exit.

Hopefully fixes the emulator builders.

Updates #23824

Change-Id: I4d1e3ab2c89fd1e5818503d323ddb87f073094da
Reviewed-on: https://go-review.googlesource.com/c/go/+/166397
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-11 21:03:01 +00:00
Bryan C. Mills
cf4691650c cmd/go: change the default value of GO111MODULE to 'on'
Fixes #30228

Change-Id: Ie45ba6483849b843eb6605272f686b9deffe5e48
Reviewed-on: https://go-review.googlesource.com/c/go/+/162698
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-11 20:29:07 +00:00
Bryan C. Mills
c5cf662407 all: move internal/x to vendor/golang.org/x and revendor using 'go mod vendor'
This also updates the vendored-in versions of several packages: 'go
mod vendor' selects a consistent version of each module, but we had
previously vendored an ad-hoc selection of packages.

Notably, x/crypto/hkdf was previously vendored in at a much newer
commit than the rest of x/crypto. Bringing the rest of x/crypto up to
that commit introduced an import of golang.org/x/sys/cpu, which broke
the js/wasm build, requiring an upgrade of x/sys to pick up CL 165749.

Updates #30228
Updates #30241
Updates #25822

Change-Id: I5b3dbc232b7e6a048a158cbd8d36137af1efb711
Reviewed-on: https://go-review.googlesource.com/c/go/+/164623
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2019-03-11 20:28:54 +00:00
Bryan C. Mills
0fc89a72ed cmd,std: add go.mod files
Updates #30241
Updates #30228

Change-Id: Ida0fe8263bf44e0498fed2048e22283ba5716835
Reviewed-on: https://go-review.googlesource.com/c/go/+/164622
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-11 20:27:41 +00:00
Bryan C. Mills
756a69c6c9 cmd: refresh cmd/vendor to match 'go mod vendor'
This change preserves the maximum versions from cmd/vendor/vendor.json
where feasible, but bumps the versions of x/sys (for CL 162987) and
x/tools (for CL 162989 and CL 160837) so that 'go test all' passes in
module mode when run from a working directory in src/cmd.

A small change to cmd/vet (not vendored) was necessary to preserve its
flag behavior given a pristine copy of x/tools; see CL 162989 for more
detail.

This change was generated by running 'go mod vendor' at CL 164622.
(Welcoooome to the fuuuuuture!)

Updates #30228
Updates #30241

Change-Id: I889590318dc857d4a6e20c3023d09a27128d8255
Reviewed-on: https://go-review.googlesource.com/c/go/+/164618
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-11 20:27:03 +00:00
Keith Randall
486ca37b14 test: fix memcombine tests
Two tests (load_le_byte8_uint64_inv and load_be_byte8_uint64)
pass but the generated code isn't actually correct.

The test regexp provides a false negative, as it matches the
MOVQ (SP), BP instruction in the epilogue.

Combined loads never worked for these cases - the test was added in error
as part of a batch and not noticed because of the above false match.

Normalize the amd64/386 tests to always negative match on narrower
loads and OR.

Change-Id: I256861924774d39db0e65723866c81df5ab5076f
Reviewed-on: https://go-review.googlesource.com/c/go/+/166837
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-11 19:18:03 +00:00
Emmanuel T Odeke
ac56baa09f testing: enable examples on js/wasm with non os.Pipe runExample
os.Pipe is not implemented on wasm/js so for that purpose use
a temporary file for js/wasm. This change creates two versions
of runExample:

* runExample verbatim that still uses os.Pipe for non js/wasm
* runExample that uses a temporary file

Also added a TODO to re-unify these function versions back into
example.go wasm/js gets an os.Pipe implementation.

Change-Id: I9f418a49b2c397e1667724c7442b7bbe8942225e
Reviewed-on: https://go-review.googlesource.com/c/go/+/165357
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-11 18:59:53 +00:00
Josh Bleecher Snyder
48d3c32ba9 cmd/compile: teach rulegen to |-expand multiple |s in a single op
I want to be able to write

MOV(Q|Q|L|L|L|W|W|B)loadidx(1|8|1|4|8|1|2|1)

instead of

MOV(Qloadidx1|Qloadidx8|Lloadidx1|Lloadidx4|Lloadidx8|Wloadidx1|Wloadidx2|Bloadidx1)

in rewrite rules.

Both are fairly cryptic and hard to review, but the former
is at least compact, which helps to not obscure the structure
of the rest of the rule.

Support that by adjusting rulegen's expansion.

Instead of looking for an op that begins with "(", ends with " ",
and has exactly one set of parens in it, look for everything of the
form "(...|...)".

That has false positives: Go code in the && conditions and AuxInt expressions.
Those are easily checked for syntactically: && conditions are between && and ->,
and AuxInt expressions are inside square brackets.
After ruling out those false positives, we can keep everything else,
regardless of where it is.

No change to the generated code for existing rules.

Change-Id: I5b70a190e268989504f53cb2cce2f9a50170d8a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/166737
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-03-11 17:40:52 +00:00
Josh Bleecher Snyder
07b4b4a1a8 cmd/compile: add scale field to SSA Ops
Refactoring only.

This makes it easier to add ops
that do indexed memory loads/stores.

Passes toolstash-check.

Change-Id: I82df0d4154718577ec42106fa1bc76571bf65096
Reviewed-on: https://go-review.googlesource.com/c/go/+/166425
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-03-11 17:40:30 +00:00
Josh Bleecher Snyder
b4fbd291b3 cmd/compile: normalize more whitespace in rewrite rules
If you write a rewrite rule:

(something) && noteRule("X")-> (something)

then rulegen will panic with an error message about commutativity.
The real problem is the lack of a space between the ) and the ->.
Normalize that bit of whitespace too.

Change-Id: Idbd53687cd0398fe275ff2702667688cad05b4ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/166427
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2019-03-11 17:18:40 +00:00
Bryan C. Mills
65a54aef5b cmd/go: set GO111MODULE=off explicitly in TestScript/list_test_err
This test was added after CL 162697.

Updates #30228

Change-Id: Ia33ad3adc99e53b0b03e68906dc1f2e39234e2cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/166697
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-11 15:14:38 +00:00
Bryan C. Mills
fd080ea3bc cmd/go: resolve non-standard imports from within GOROOT/src using vendor directories
Updates #30228
Fixes #26924

Change-Id: Ie625c64721559c7633396342320536396cd1fcf5
Reviewed-on: https://go-review.googlesource.com/c/go/+/164621
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2019-03-11 14:22:02 +00:00
Alberto Donizetti
1c2d4da10f syscall: skip non-root user namespace test if kernel forbids
The unprivileged_userns_clone sysctl prevents unpriviledged users from
creating namespaces, which the AmbientCaps test does. It's set to 0 by
default in a few Linux distributions (Debian and Arch, possibly
others), so we need to check it before running the test.

I've verified that setting

  echo 1 > /proc/sys/kernel/unprivileged_userns_clone

and then running the test *without this patch* makes it pass, which
proves that checking unprivileged_userns_clone is indeed sufficient.

Fixes #30698

Change-Id: Ib2079b5e714d7f2440ddf979c3e7cfda9a9c5005
Reviewed-on: https://go-review.googlesource.com/c/go/+/166460
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-10 21:01:02 +00:00
Tobias Klauser
e2dc41b490 strings: remove unnecessary strings.s
There are no empty function declarations in package strings anymore, so
strings.s is no longer needed.

Change-Id: I16fe161a9c06804811e98af0ca074f8f46e2f49d
Reviewed-on: https://go-review.googlesource.com/c/go/+/166458
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-10 15:52:22 +00:00
Jason A. Donenfeld
9b6e9f0c8c runtime: safely load DLLs
While many other call sites have been moved to using the proper
higher-level system loading, these areas were left out. This prevents
DLL directory injection attacks. This includes both the runtime load
calls (using LoadLibrary prior) and the implicitly linked ones via
cgo_import_dynamic, which we move to our LoadLibraryEx. The goal is to
only loosely load kernel32.dll and strictly load all others.

Meanwhile we make sure that we never fallback to insecure loading on
older or unpatched systems.

This is CVE-2019-9634.

Fixes #14959
Fixes #28978
Fixes #30642

Change-Id: I401a13ed8db248ab1bb5039bf2d31915cac72b93
Reviewed-on: https://go-review.googlesource.com/c/go/+/165798
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-03-10 05:40:13 +00:00
Josh Bleecher Snyder
243c8eb8c2 cmd/compile: add pure Go math/big functions to TestIntendedInlining
Change-Id: Id29a9e48a09965e457f923a0ff023722b38b27ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/165157
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-09 21:26:04 +00:00
Josh Bleecher Snyder
4d10aba35e math/big: add fast path for amd64 addVW for large z
This matches the pure Go fast path added in the previous commit.

I will leave other architectures to those with ready access to hardware.

name            old time/op    new time/op    delta
AddVW/1-8         3.60ns ± 3%    3.59ns ± 1%      ~     (p=0.147 n=91+86)
AddVW/2-8         3.92ns ± 1%    3.91ns ± 2%    -0.36%  (p=0.000 n=86+92)
AddVW/3-8         4.33ns ± 5%    4.46ns ± 5%    +2.94%  (p=0.000 n=96+97)
AddVW/4-8         4.76ns ± 5%    4.82ns ± 5%    +1.28%  (p=0.000 n=95+92)
AddVW/5-8         5.40ns ± 1%    5.42ns ± 0%    +0.47%  (p=0.000 n=76+71)
AddVW/10-8        8.03ns ± 1%    7.80ns ± 5%    -2.90%  (p=0.000 n=73+96)
AddVW/100-8       43.8ns ± 5%    17.9ns ± 1%   -59.12%  (p=0.000 n=94+81)
AddVW/1000-8       428ns ± 4%      85ns ± 6%   -80.20%  (p=0.000 n=96+99)
AddVW/10000-8     4.22µs ± 2%    1.80µs ± 3%   -57.32%  (p=0.000 n=69+92)
AddVW/100000-8    44.8µs ± 8%    31.5µs ± 3%   -29.76%  (p=0.000 n=99+90)

name            old time/op    new time/op    delta
SubVW/1-8         3.53ns ± 2%    3.63ns ± 5%    +2.97%  (p=0.000 n=94+93)
SubVW/2-8         4.33ns ± 5%    4.01ns ± 2%    -7.36%  (p=0.000 n=90+85)
SubVW/3-8         4.32ns ± 2%    4.32ns ± 5%      ~     (p=0.084 n=87+97)
SubVW/4-8         4.70ns ± 2%    4.83ns ± 6%    +2.77%  (p=0.000 n=85+96)
SubVW/5-8         5.84ns ± 1%    5.35ns ± 1%    -8.35%  (p=0.000 n=87+87)
SubVW/10-8        8.01ns ± 4%    7.54ns ± 4%    -5.84%  (p=0.000 n=98+97)
SubVW/100-8       43.9ns ± 5%    17.9ns ± 1%   -59.20%  (p=0.000 n=98+76)
SubVW/1000-8       426ns ± 2%      85ns ± 3%   -80.13%  (p=0.000 n=90+98)
SubVW/10000-8     4.24µs ± 2%    1.81µs ± 3%   -57.28%  (p=0.000 n=74+91)
SubVW/100000-8    44.5µs ± 4%    31.5µs ± 2%   -29.33%  (p=0.000 n=84+91)

Change-Id: I10dd361cbaca22197c27e7734c0f50065292afbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/164969
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-03-09 20:34:40 +00:00
Josh Bleecher Snyder
fe24837c4d math/big: add fast path for pure Go addVW for large z
In the normal case, only a few words have to be updated when adding a word to a vector.
When that happens, we can simply copy the rest of the words, which is much faster.
However, the overhead of that makes it prohibitive for small vectors,
so we check the size at the beginning.

The implementation is a bit weird to allow addVW to continued to be inlined; see #30548.

The AddVW benchmarks are surprising, but fully repeatable.
The SubVW benchmarks are more or less as expected.
I expect that removing the indirect function call will
help both and make them a bit more normal.

name            old time/op    new time/op     delta
AddVW/1-8         4.27ns ± 2%     3.81ns ± 3%   -10.83%  (p=0.000 n=89+90)
AddVW/2-8         4.91ns ± 2%     4.34ns ± 1%   -11.60%  (p=0.000 n=83+90)
AddVW/3-8         5.77ns ± 4%     5.76ns ± 2%      ~     (p=0.365 n=91+87)
AddVW/4-8         6.03ns ± 1%     6.03ns ± 1%      ~     (p=0.392 n=80+76)
AddVW/5-8         6.48ns ± 2%     6.63ns ± 1%    +2.27%  (p=0.000 n=76+74)
AddVW/10-8        9.56ns ± 2%     9.56ns ± 1%    -0.02%  (p=0.002 n=69+76)
AddVW/100-8       90.6ns ± 0%     18.1ns ± 4%   -79.99%  (p=0.000 n=72+94)
AddVW/1000-8       865ns ± 0%       85ns ± 6%   -90.14%  (p=0.000 n=66+96)
AddVW/10000-8     8.57µs ± 2%     1.82µs ± 3%   -78.73%  (p=0.000 n=99+94)
AddVW/100000-8    84.4µs ± 2%     31.8µs ± 4%   -62.29%  (p=0.000 n=93+98)

name            old time/op    new time/op     delta
SubVW/1-8         3.90ns ± 2%     4.13ns ± 4%    +6.02%  (p=0.000 n=92+95)
SubVW/2-8         4.15ns ± 1%     5.20ns ± 1%   +25.22%  (p=0.000 n=83+85)
SubVW/3-8         5.50ns ± 2%     6.22ns ± 6%   +13.21%  (p=0.000 n=91+97)
SubVW/4-8         5.99ns ± 1%     6.63ns ± 1%   +10.63%  (p=0.000 n=79+61)
SubVW/5-8         6.75ns ± 4%     6.88ns ± 2%    +1.82%  (p=0.000 n=98+73)
SubVW/10-8        9.57ns ± 1%     9.56ns ± 1%    -0.13%  (p=0.000 n=77+64)
SubVW/100-8       90.3ns ± 1%     18.1ns ± 2%   -80.00%  (p=0.000 n=75+94)
SubVW/1000-8       860ns ± 4%       85ns ± 7%   -90.14%  (p=0.000 n=97+99)
SubVW/10000-8     8.51µs ± 3%     1.77µs ± 6%   -79.21%  (p=0.000 n=100+97)
SubVW/100000-8    84.4µs ± 3%     31.5µs ± 3%   -62.66%  (p=0.000 n=92+92)

Change-Id: I721d7031d40f245b4a284f5bdd93e7bb85e7e937
Reviewed-on: https://go-review.googlesource.com/c/go/+/164968
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-03-09 20:33:46 +00:00
Josh Bleecher Snyder
4c227a091e math/big: remove bounds checks in pure Go implementations
These routines are quite sensitive to BCE.

This change eliminates bounds checks from loops.
It does so at the cost of a bit of safety:
malformed input will now return incorrect answers
instead of panicking.

This isn't as bad as it sounds: math/big has very good
test coverage, and the alternative implementations are in
assembly, which could do much worse things with malformed input.

If the compiler's BCE improves, so could these routines.

Notable BCE improvements for these routines would be:

* Allowing and propagating more cross-slice length hints.
  Then hints like _ = y[:len(z)] would eliminate bounds checks for y[i].

* Propagating enough information so that we could do
  n := len(x)
  if len(z) < n {
    n = len(z)
  }
  and then have i < n eliminate the same bounds checks as
  i < len(x) && i < len(z) currently does.

* Providing some way to do BCE for unrolled loops.
  Now that we have math/bits implementations,
  it is possible to write things like ADC chains in
  pure Go, if you can reasonably unroll loops.

Benchmarks below are for amd64, using -tags=math_big_pure_go.

name            old time/op    new time/op    delta
AddVV/1-8         5.15ns ± 3%    4.65ns ± 4%   -9.81%  (p=0.000 n=93+86)
AddVV/2-8         6.40ns ± 2%    5.58ns ± 4%  -12.78%  (p=0.000 n=90+95)
AddVV/3-8         7.07ns ± 2%    6.66ns ± 2%   -5.88%  (p=0.000 n=87+83)
AddVV/4-8         7.94ns ± 5%    7.41ns ± 4%   -6.65%  (p=0.000 n=94+98)
AddVV/5-8         8.55ns ± 1%    8.80ns ± 0%   +2.92%  (p=0.000 n=87+92)
AddVV/10-8        12.7ns ± 1%    12.3ns ± 1%   -3.12%  (p=0.000 n=83+71)
AddVV/100-8        119ns ± 5%     117ns ± 4%   -1.60%  (p=0.000 n=93+90)
AddVV/1000-8      1.14µs ± 4%    1.14µs ± 5%     ~     (p=0.812 n=95+91)
AddVV/10000-8     11.4µs ± 5%    11.3µs ± 5%     ~     (p=0.503 n=97+96)
AddVV/100000-8     114µs ± 4%     113µs ± 5%   -0.98%  (p=0.002 n=97+90)

name            old time/op    new time/op    delta
SubVV/1-8         5.23ns ± 5%    4.65ns ± 3%  -11.18%  (p=0.000 n=89+91)
SubVV/2-8         6.49ns ± 5%    5.58ns ± 3%  -14.04%  (p=0.000 n=92+94)
SubVV/3-8         7.10ns ± 3%    6.65ns ± 2%   -6.28%  (p=0.000 n=87+80)
SubVV/4-8         8.04ns ± 1%    7.44ns ± 5%   -7.49%  (p=0.000 n=83+98)
SubVV/5-8         8.55ns ± 2%    8.32ns ± 1%   -2.75%  (p=0.000 n=84+92)
SubVV/10-8        12.7ns ± 1%    12.3ns ± 1%   -3.09%  (p=0.000 n=80+75)
SubVV/100-8        119ns ± 0%     116ns ± 3%   -1.83%  (p=0.000 n=87+98)
SubVV/1000-8      1.13µs ± 5%    1.13µs ± 3%     ~     (p=0.082 n=96+98)
SubVV/10000-8     11.2µs ± 1%    11.3µs ± 3%   +0.76%  (p=0.000 n=87+97)
SubVV/100000-8     112µs ± 2%     113µs ± 3%   +0.55%  (p=0.000 n=76+88)

name            old time/op    new time/op    delta
AddVW/1-8         4.30ns ± 4%    3.96ns ± 6%  -8.02%  (p=0.000 n=89+97)
AddVW/2-8         5.15ns ± 2%    4.91ns ± 1%  -4.56%  (p=0.000 n=87+80)
AddVW/3-8         5.59ns ± 3%    5.75ns ± 2%  +2.91%  (p=0.000 n=91+88)
AddVW/4-8         6.20ns ± 1%    6.03ns ± 1%  -2.71%  (p=0.000 n=75+90)
AddVW/5-8         6.93ns ± 3%    6.49ns ± 2%  -6.35%  (p=0.000 n=100+82)
AddVW/10-8        10.0ns ± 7%     9.6ns ± 0%  -4.02%  (p=0.000 n=98+74)
AddVW/100-8       91.1ns ± 1%    90.6ns ± 1%  -0.55%  (p=0.000 n=84+80)
AddVW/1000-8       866ns ± 1%     856ns ± 4%  -1.06%  (p=0.000 n=69+96)
AddVW/10000-8     8.64µs ± 1%    8.53µs ± 4%  -1.25%  (p=0.000 n=67+99)
AddVW/100000-8    84.3µs ± 2%    85.4µs ± 4%  +1.22%  (p=0.000 n=89+99)

name            old time/op    new time/op    delta
SubVW/1-8         4.28ns ± 2%    3.82ns ± 3%  -10.63%  (p=0.000 n=91+89)
SubVW/2-8         4.61ns ± 1%    4.48ns ± 3%   -2.67%  (p=0.000 n=94+96)
SubVW/3-8         5.54ns ± 1%    5.81ns ± 4%   +4.87%  (p=0.000 n=92+97)
SubVW/4-8         6.20ns ± 1%    6.08ns ± 2%   -1.99%  (p=0.000 n=71+88)
SubVW/5-8         6.91ns ± 3%    6.64ns ± 1%   -3.90%  (p=0.000 n=97+70)
SubVW/10-8        9.85ns ± 2%    9.62ns ± 0%   -2.31%  (p=0.000 n=82+62)
SubVW/100-8       91.1ns ± 1%    90.9ns ± 3%   -0.14%  (p=0.010 n=71+93)
SubVW/1000-8       859ns ± 3%     867ns ± 1%   +0.98%  (p=0.000 n=99+78)
SubVW/10000-8     8.54µs ± 5%    8.57µs ± 2%   +0.38%  (p=0.007 n=98+92)
SubVW/100000-8    84.5µs ± 3%    84.6µs ± 3%     ~     (p=0.334 n=95+94)

name                old time/op    new time/op    delta
AddMulVVW/1-8         5.43ns ± 3%    4.36ns ± 2%  -19.67%  (p=0.000 n=95+94)
AddMulVVW/2-8         6.56ns ± 4%    6.11ns ± 1%   -6.90%  (p=0.000 n=91+91)
AddMulVVW/3-8         8.00ns ± 1%    7.80ns ± 4%   -2.52%  (p=0.000 n=83+95)
AddMulVVW/4-8         9.81ns ± 2%    9.53ns ± 1%   -2.86%  (p=0.000 n=77+64)
AddMulVVW/5-8         11.4ns ± 3%    11.3ns ± 5%   -0.89%  (p=0.000 n=95+97)
AddMulVVW/10-8        18.9ns ± 5%    19.1ns ± 5%   +0.89%  (p=0.000 n=91+94)
AddMulVVW/100-8        165ns ± 5%     165ns ± 4%     ~     (p=0.427 n=97+98)
AddMulVVW/1000-8      1.56µs ± 3%    1.56µs ± 4%     ~     (p=0.167 n=98+96)
AddMulVVW/10000-8     15.7µs ± 5%    15.6µs ± 5%   -0.31%  (p=0.044 n=95+97)
AddMulVVW/100000-8     156µs ± 3%     157µs ± 8%     ~     (p=0.373 n=72+99)

Change-Id: Ibc720785d5b95f6a797103b1363843205f4d56bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/164966
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2019-03-09 20:33:13 +00:00
Daniel Martí
788e038e5d reflect: make all flag.mustBe* methods inlinable
mustBe was barely over budget, so manually inlining the first flag.kind
call is enough. Add a TODO to reverse that in the future, once the
compiler gets better.

mustBeExported and mustBeAssignable were over budget by a larger amount,
so add slow path functions instead. This is the same strategy used in
the sync package for common methods like Once.Do, for example.

Lots of exported reflect.Value methods call these assert-like unexported
methods, so avoiding the function call overhead in the common case does
shave off a percent from most exported APIs.

Finally, add the methods to TestIntendedInlining.

While at it, replace a couple of uses of the 0 Kind with its descriptive
name, Invalid.

name     old time/op    new time/op    delta
Call-8     68.0ns ± 1%    66.8ns ± 1%  -1.81%  (p=0.000 n=10+9)
PtrTo-8    8.00ns ± 2%    7.83ns ± 0%  -2.19%  (p=0.000 n=10+9)

Updates #7818.

Change-Id: Ic1603b640519393f6b50dd91ec3767753eb9e761
Reviewed-on: https://go-review.googlesource.com/c/go/+/166462
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-03-09 19:50:24 +00:00