1
0
mirror of https://github.com/golang/go synced 2024-11-17 18:34:44 -07:00
Commit Graph

40041 Commits

Author SHA1 Message Date
Jay Conrod
6997671d2e cmd/go: handle wildcards for unknown modules in "go get"
For example, "go get golang.org/x/tools/cmd/..." will add a
requirement for "golang.org/x/tools" to go.mod and will install
executables from the "cmd" subdirectory.

Fixes #29363

Change-Id: Id53f051710708d7760ffe831d4274fd54533d2b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/171138
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-04-16 18:49:50 +00:00
Constantin Konstantinidis
75308c98e3 cmd/go: remove auto-deriving module path for github.com
This fix removes the special case of auto-deriving the module path
only for VCS github.com. Error message now explicitly requests
the module path. Documentation and its FAQ do not need an update
as only the beginning of the message is mentioned and is not modified.

Fixes #27951

Change-Id: Icaf87a38b5c58451edba9beaa12ae9a68e288ca1
Reviewed-on: https://go-review.googlesource.com/c/go/+/172019
Reviewed-by: Daniel Lublin <daniel@lublin.se>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-16 18:31:01 +00:00
Matthew Dempsky
996a687ebb cmd/compile: enable -newescape by default
RELNOTE=yes

The new escape analysis pass is more precise, which for most Go code
should be an improvement. However, it may also break code that
happened to work before (e.g., code that violated the unsafe.Pointer
safety rules).

The old escape analysis pass can be re-enabled with "go build
-gcflags=all=-newescape=false". N.B., it's NOT recommended to mix the
old and new escape analysis passes such as by omitting "all=". While
the old and new escape analysis passes use similar and mostly
compatible metadata, there are cases (e.g., closure handling) where
they semantically differ and could lead to memory corruption errors in
compiled programs.

Fixes #23109.

Change-Id: I0b1b6a6de5e240cb30c87a165f47bb8795491158
Reviewed-on: https://go-review.googlesource.com/c/go/+/170448
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2019-04-16 18:25:24 +00:00
Gergely Brautigam
a16dcc0052 cmd/go: report non-Go files as package error
This change modifies cmd/go/list to format the error correctly in case
-e flag is set. It also fixes a bug where the package loader was only
ever checking the first pattern if it had the go extension. This caused
and error when a file without .go extension was not the first argument.

Fixes #29899

Change-Id: I029bf4465ad4ad054434b8337c1d2a59369783da
Reviewed-on: https://go-review.googlesource.com/c/go/+/166398
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-04-16 18:20:43 +00:00
Bryan C. Mills
56b8ee2398 cmd/go: retry RemoveAll(workdir) for up to 500ms
On some configurations of Windows, directories containing executable
files may be locked for a while after the executable exits (perhaps
due to antivirus scans?). It's probably worth a little extra latency
on exit to avoid filling up the user's temporary directory with leaked
files.

Updates #30789

Change-Id: Iae7fcdd07fb9ecfb05967cfe0c8833db646d2f85
Reviewed-on: https://go-review.googlesource.com/c/go/+/172337
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-16 17:44:16 +00:00
ShiKaiWi
518ee55d78 expvar: improve Map.addKey for large number of keys
The existing implementation has poor performance for inserting large
number of keys because it chooses to append the new key to the sorted
keys array and then sort the new array again (time complexity is
O(nlogn)).

The improvement tries to utilize the sorted keys array by searching the
index and doing an insertion if any (time complexity is O(logn)).

Benchmarked on 4-core machine with `go test -cpu 1,2,4,8 -count 5
-benchmem -bench=.`(the equal results are omitted):

name                          old time/op    new time/op    delta
MapAddDifferentRandom-8          408µs ±11%      69µs ± 3%  -82.95%  (p=0.008 n=5+5)
MapAddDifferentRandom-4          389µs ±19%      69µs ± 2%  -82.28%  (p=0.008 n=5+5)
MapAddDifferentRandom-2          365µs ± 4%      75µs ± 6%  -79.51%  (p=0.008 n=5+5)
MapSetDifferentRandom-8          365µs ± 4%      76µs ±40%  -79.07%  (p=0.008 n=5+5)
MapAddDifferentRandom            366µs ± 3%      78µs ± 6%  -78.66%  (p=0.008 n=5+5)
MapSetDifferentRandom            369µs ± 2%      81µs ±34%  -77.99%  (p=0.008 n=5+5)
MapSetDifferentRandom-2          378µs ±10%     100µs ±32%  -73.47%  (p=0.008 n=5+5)
MapSetDifferentRandom-4          352µs ± 4%     108µs ± 7%  -69.40%  (p=0.008 n=5+5)
IntAdd-2                        23.1ns ±21%    15.5ns ±23%  -32.79%  (p=0.032 n=5+5)
IntSet-2                        21.4ns ±14%    16.7ns ±17%  -22.00%  (p=0.016 n=5+5)
FloatAdd-8                      88.8ns ± 9%    70.8ns ±25%  -20.23%  (p=0.024 n=5+5)
FloatSet-2                      22.3ns ±15%    17.8ns ±14%  -20.14%  (p=0.008 n=5+5)
IntAdd-8                        21.7ns ± 3%    18.7ns ± 4%  -14.00%  (p=0.008 n=5+5)
MapAddDifferent-8               1.58µs ± 7%    1.42µs ± 6%  -10.06%  (p=0.016 n=5+5)
StringSet-2                     42.4ns ± 1%    43.7ns ± 5%   +3.07%  (p=0.048 n=4+5)
FloatSet                        8.27ns ± 2%    8.60ns ± 1%   +3.94%  (p=0.008 n=5+5)
FloatAdd                        12.5ns ± 2%    13.0ns ± 4%   +4.33%  (p=0.032 n=5+5)
MapSetString-4                  94.6ns ± 0%   101.7ns ± 4%   +7.55%  (p=0.016 n=4+5)
MapAddSameSteadyState-2         34.9ns ± 3%    37.7ns ± 5%   +8.14%  (p=0.008 n=5+5)
StringSet-4                     34.5ns ± 0%    37.6ns ± 9%   +9.02%  (p=0.016 n=4+5)
MapSetDifferent-8                377ns ± 3%     411ns ± 7%   +9.07%  (p=0.008 n=5+5)
MapAddSameSteadyState           39.1ns ± 2%    42.8ns ± 6%   +9.36%  (p=0.008 n=5+5)
MapAddDifferentSteadyState       172ns ± 4%     190ns ± 9%  +10.96%  (p=0.016 n=5+5)
MapSet                           143ns ± 4%     159ns ± 2%  +11.06%  (p=0.008 n=5+5)
MapSet-4                        96.9ns ± 5%   107.8ns ± 6%  +11.25%  (p=0.008 n=5+5)
MapSet-2                         102ns ± 6%     114ns ± 8%  +11.94%  (p=0.008 n=5+5)
IntSet                          8.18ns ± 1%   12.78ns ±13%  +56.31%  (p=0.008 n=5+5)

name                          old alloc/op   new alloc/op   delta
MapSetDifferentRandom-4         19.8kB ± 0%    16.6kB ± 0%  -16.21%  (p=0.008 n=5+5)
MapSetDifferentRandom           19.8kB ± 0%    16.6kB ± 0%  -16.21%  (p=0.008 n=5+5)
MapSetDifferentRandom-8         19.8kB ± 0%    16.6kB ± 0%  -16.20%  (p=0.008 n=5+5)
MapSetDifferentRandom-2         19.8kB ± 0%    16.6kB ± 0%  -16.20%  (p=0.008 n=5+5)
MapAddDifferentRandom           20.6kB ± 0%    17.4kB ± 0%  -15.57%  (p=0.008 n=5+5)
MapAddDifferentRandom-8         20.6kB ± 0%    17.4kB ± 0%  -15.57%  (p=0.008 n=5+5)
MapAddDifferentRandom-2         20.6kB ± 0%    17.4kB ± 0%  -15.56%  (p=0.008 n=5+5)
MapAddDifferentRandom-4         20.6kB ± 0%    17.4kB ± 0%  -15.56%  (p=0.008 n=5+5)
MapAddDifferent                 1.09kB ± 0%    0.96kB ± 0%  -11.76%  (p=0.008 n=5+5)
MapAddDifferent-2               1.09kB ± 0%    0.96kB ± 0%  -11.76%  (p=0.008 n=5+5)
MapAddDifferent-4               1.09kB ± 0%    0.96kB ± 0%  -11.76%  (p=0.008 n=5+5)
MapAddDifferent-8               1.09kB ± 0%    0.96kB ± 0%  -11.76%  (p=0.008 n=5+5)
MapAddSame                        480B ± 0%      448B ± 0%   -6.67%  (p=0.008 n=5+5)
MapAddSame-2                      480B ± 0%      448B ± 0%   -6.67%  (p=0.008 n=5+5)
MapAddSame-4                      480B ± 0%      448B ± 0%   -6.67%  (p=0.008 n=5+5)
MapAddSame-8                      480B ± 0%      448B ± 0%   -6.67%  (p=0.008 n=5+5)

name                          old allocs/op  new allocs/op  delta
MapSetDifferentRandom              423 ± 0%       323 ± 0%  -23.64%  (p=0.008 n=5+5)
MapSetDifferentRandom-2            423 ± 0%       323 ± 0%  -23.64%  (p=0.008 n=5+5)
MapSetDifferentRandom-4            423 ± 0%       323 ± 0%  -23.64%  (p=0.008 n=5+5)
MapSetDifferentRandom-8            423 ± 0%       323 ± 0%  -23.64%  (p=0.008 n=5+5)
MapAddDifferentRandom              523 ± 0%       423 ± 0%  -19.12%  (p=0.008 n=5+5)
MapAddDifferentRandom-2            523 ± 0%       423 ± 0%  -19.12%  (p=0.008 n=5+5)
MapAddDifferentRandom-4            523 ± 0%       423 ± 0%  -19.12%  (p=0.008 n=5+5)
MapAddDifferentRandom-8            523 ± 0%       423 ± 0%  -19.12%  (p=0.008 n=5+5)
MapAddDifferent                   31.0 ± 0%      27.0 ± 0%  -12.90%  (p=0.008 n=5+5)
MapAddDifferent-2                 31.0 ± 0%      27.0 ± 0%  -12.90%  (p=0.008 n=5+5)
MapAddDifferent-4                 31.0 ± 0%      27.0 ± 0%  -12.90%  (p=0.008 n=5+5)
MapAddDifferent-8                 31.0 ± 0%      27.0 ± 0%  -12.90%  (p=0.008 n=5+5)
MapAddSame                        11.0 ± 0%      10.0 ± 0%   -9.09%  (p=0.008 n=5+5)
MapAddSame-2                      11.0 ± 0%      10.0 ± 0%   -9.09%  (p=0.008 n=5+5)
MapAddSame-4                      11.0 ± 0%      10.0 ± 0%   -9.09%  (p=0.008 n=5+5)
MapAddSame-8                      11.0 ± 0%      10.0 ± 0%   -9.09%  (p=0.008 n=5+5)

Fixes #31414

Change-Id: I2dd655dec9dbbf8d7881a0f3f8edcb3d29199a48
GitHub-Last-Rev: a816fe3f62
GitHub-Pull-Request: golang/go#31418
Reviewed-on: https://go-review.googlesource.com/c/go/+/171718
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-16 17:18:01 +00:00
Kunpei Sakai
2a931bad4e net/http: rename DialerAndTLSConfigSupportsHTTP2 to ForceAttemptHTTP2
Transport.DialerAndTLSConfigSupportsHTTP2 was added just earlier
in CL 130256 but we thought of a better name moments after submitting.
ForceAttemptHTTP2 is shorter, more direct, and doesn't constrain what
we can use it with in the future.

Updates #14391
Updates #27011

Change-Id: Ie5fc71bafcbcaa1941b5d49f748b6d710503d477
Reviewed-on: https://go-review.googlesource.com/c/go/+/172299
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-16 17:15:01 +00:00
Keith Randall
8285c85fe3 syscall: skip DirentRepeat test on freebsd
Dirent doesn't work properly. Diable the test for now.

Update #31416

Change-Id: I34a8045598a9c303dcc754ce04da3c124f122d1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/171818
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-16 17:14:50 +00:00
Matthew Dempsky
a9831633be cmd/compile: update escape analysis tests for newescape
The new escape analysis implementation tries to emit debugging
diagnostics that are compatible with the existing implementation, but
there's a handful of cases that are easier to handle by updating the
test expectations instead.

For regress tests that need updating, the original file is copied to
oldescapeXXX.go.go with -newescape=false added to the //errorcheck
line, while the file is updated in place with -newescape=true and new
test requirements.

Notable test changes:

1) escape_because.go looks for a lot of detailed internal debugging
messages that are fairly particular to how esc.go works and that I
haven't attempted to port over to escape.go yet.

2) There are a lot of "leaking param: x to result ~r1 level=-1"
messages for code like

    func(p *int) *T { return &T{p} }

that were simply wrong. Here &T must be heap allocated unconditionally
(because it's being returned); and since p is stored into it, p
escapes unconditionally too. esc.go incorrectly reports that p escapes
conditionally only if the returned pointer escaped.

3) esc.go used to print each "leaking param" analysis result as it
discovered them, which could lead to redundant messages (e.g., that a
param leaks at level=0 and level=1). escape.go instead prints
everything at the end, once it knows the shortest path to each sink.

4) esc.go didn't precisely model direct-interface types, resulting in
some values unnecessarily escaping to the heap when stored into
non-escaping interface values.

5) For functions written in assembly, esc.go only printed "does not
escape" messages, whereas escape.go prints "does not escape" or
"leaking param" as appropriate, consistent with the behavior for
functions written in Go.

6) 12 tests included "BAD" annotations identifying cases where esc.go
was unnecessarily heap allocating something. These are all fixed by
escape.go.

Updates #23109.

Change-Id: Iabc9eb14c94c9cadde3b183478d1fd54f013502f
Reviewed-on: https://go-review.googlesource.com/c/go/+/170447
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2019-04-16 16:20:39 +00:00
Kunpei Sakai
94e720059f net/http: introduce DialerAndTLSConfigSupportsHTTP2 in Transport
Even when a custom TLS config or custom dialer is specified,
enables HTTP/2 if DialerAndTLSConfigSupportsHTTP2 is true.
By this change, avoid automatically enabling HTTP/2 if DialContext is set.

This change also ensures that DefaultTransport still automatically
enable HTTP/2 as discussed in #14391.

Updates #14391
Fixes #27011

Change-Id: Icc46416810bee61dbd65ebc96468335030b80573
Reviewed-on: https://go-review.googlesource.com/c/go/+/130256
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Kunpei Sakai <namusyaka@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-16 16:12:22 +00:00
Fedor Korotkiy
1eed2a5ab2 cmd/go: PackageVetx in vet.cfg should list only immediate dependencies.
Updates #30296

Change-Id: Ifea1a4c82c1c5b31fdc2e96fdbb1274748c8f50e
Reviewed-on: https://go-review.googlesource.com/c/go/+/164459
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-04-16 16:05:30 +00:00
Michael Munday
64dc4ba73f math: use new mnemonics for 'rotate then insert' on s390x
Mnemonics for these instructions were added to the assembler in
CL 159357.

Change-Id: Ie11c45ecc9cead9a8850fcc929b0211cfd980fe5
Reviewed-on: https://go-review.googlesource.com/c/go/+/160157
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-16 15:34:41 +00:00
喜欢兰花山丘
c4953a62f9 context: simplify stringify with a type switch
Minor style change.

Change-Id: Ib30243a71a83de1a67d3d005bfdd1e04265fca1e
GitHub-Last-Rev: 9d654de10e
GitHub-Pull-Request: golang/go#31479
Reviewed-on: https://go-review.googlesource.com/c/go/+/172199
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Sameer Ajmani <sameer@golang.org>
2019-04-16 15:33:18 +00:00
Elias Naur
4ee85e67e1 misc/cgo/testcshared: support testing on self-hosted android
Only invoke adb for android if we're not running on android already.

Change-Id: I4eb94286a5bf09b382716a0474f3aebec40f5d74
Reviewed-on: https://go-review.googlesource.com/c/go/+/170953
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-16 15:10:00 +00:00
Elias Naur
ae85ae5db2 runtime: avoid getg in preinit on Android
sigaction is called as part of library mode initializers
(_rt0_*_lib). Sigaction in turn calls getg, but on Android the TLS
offset for g has not been initialized and getg might return garbage.

Add a check for initialization before calling getg.

Fixes the golang.org/x/mobile/bind/java tests on amd64 and 386.

Fixes #31476

Change-Id: Id2c41fdc983239eca039b49a54b8853c5669d127
Reviewed-on: https://go-review.googlesource.com/c/go/+/172158
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-16 15:09:25 +00:00
Richard Musiol
460f9c6068 runtime, cmd/link: optimize memory allocation on wasm
WebAssembly's memory is contiguous. Allocating memory at a high address
also allocates all memory up to that address. This change reduces
the initial memory allocated on wasm from 1GB to 16MB by using multiple
heap arenas and reducing the size of a heap arena.

Fixes #27462.

Change-Id: Ic941e6edcadd411e65a14cb2f9fd6c8eae02fc7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/170950
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-16 15:03:34 +00:00
Dmitry Savintsev
e47090ab40 doc: fix typo in go1.12 release notes
Change-Id: I3cb4fb7cacba51bfd611ade918f16c618e2569fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/172159
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-16 14:47:58 +00:00
Daniel Martí
9b968df177 all: clean up code with token.IsExported
A handful of packages were reimplementing IsExported, so use
token.IsExported instead. This caused the deps test to fail for net/rpc.
However, net/rpc deals with Go types, and go/token is light and fairly
low-level in terms of Go tooling packages, so that's okay.

While at it, replace all uses of ast.IsExported with token.IsExported.
This is more consistent, and also means that the import graphs are
leaner. A couple of files no longer need to import go/ast, for example.

We can't get rid of cmd/compile/internal/types.IsExported, as the
compiler can only depend on go/token as of Go 1.4. However, gc used
different implementations in a couple of places, so consolidate the use
of types.IsExported there.

Finally, we can't get rid of the copied IsExported implementation in
encoding/gob, as go/token depends on it as part of a test. That test
can't be an external test either, so there's no easy way to break the
import cycle.

Overall, this removes about forty lines of unnecessary code.

Change-Id: I86a475b7614261e6a7b0b153d5ca02b9f64a7b2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/172037
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-16 14:43:48 +00:00
Clément Chigot
b39d0eab90 syscall: move helper handler before AIX handler in TestPassFD
The AIX special handler which skips this test if unix network isn't
supported, doesn't need to be called inside the helper process.

Change-Id: I7ff2c4e6b20eceb977380294858cae63034ffe0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/172160
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-04-16 13:25:16 +00:00
Ivan Osadchiy
36b0593f79 crypto/sha256: Use bits.RotateLeft32 instead of ad-hoc implementation
Improves readability of the generic implementation.

Updates #31456.

Benchmarks (i7-4980HQ CPU)

name          old time/op    new time/op    delta
Hash8Bytes-8     339ns ± 3%     337ns ± 2%   ~     (p=0.595 n=5+5)
Hash1K-8        5.12µs ± 6%    4.97µs ± 6%   ~     (p=0.310 n=5+5)
Hash8K-8        37.6µs ± 5%    38.1µs ± 6%   ~     (p=0.841 n=5+5)

name          old speed      new speed      delta
Hash8Bytes-8  23.6MB/s ± 3%  23.8MB/s ± 3%   ~     (p=0.690 n=5+5)
Hash1K-8       200MB/s ± 6%   206MB/s ± 5%   ~     (p=0.310 n=5+5)
Hash8K-8       218MB/s ± 5%   215MB/s ± 6%   ~     (p=0.841 n=5+5)

Change-Id: Ic488841699138efde76e900bce1dd38fdbc88ec6
Reviewed-on: https://go-review.googlesource.com/c/go/+/171731
Reviewed-by: Ilya Tokar <tocarip@gmail.com>
Run-TryBot: Ilya Tokar <tocarip@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-16 10:53:44 +00:00
Michael Munday
0f79510dc5 cmd/asm: add s390x 'rotate then ... selected bits' instructions
This CL adds the following instructions, useful for shifting/rotating
and masking operations:

 * RNSBG - rotate then and selected bits
 * ROSBG - rotate then or selected bits
 * RXSBG - rotate then exclusive or selected bits
 * RISBG - rotate then insert selected bits

It also adds the 'T' (test), 'Z' (zero), 'H' (high), 'L' (low) and
'N' (no test) variants of these instructions as appropriate.

Operands are ordered as: I₃, I₄, I₅, R₂, R₁.

Key: I₃=start, I₄=end, I₅=amount, R₂=source, R₁=destination

Change-Id: I200d12287e1df7447f37f4919da5e9a93d27c792
Reviewed-on: https://go-review.googlesource.com/c/go/+/159357
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-16 09:17:24 +00:00
Michael Munday
9c843f031d cmd/internal/obj/s390x: handle RestArgs in s390x assembler
Allow up to 3 RestArgs arguments to be specified. This is needed to
for us to add the 'rotate and ... bits' instructions, which require
5 arguments, cleanly.

Change-Id: I76b89adfb5e3cd85a43023e412f0cc202d489e0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/171726
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-16 09:17:14 +00:00
Michael Munday
e61985427e cmd/internal/obj/s390x: remove param field from optab
The param field isn't useful, we can just use REGSP instead.

Change-Id: I2ac68131c390209cc84e43aa7620ccbf5ae69120
Reviewed-on: https://go-review.googlesource.com/c/go/+/171725
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-16 09:17:06 +00:00
Josh Bleecher Snyder
f248cd3a07 runtime: print more information when testCgoPprof fails
Change-Id: I820dae0303959096f0c434b7e69ecb3bf070df09
Reviewed-on: https://go-review.googlesource.com/c/go/+/172197
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-16 03:10:17 +00:00
Ross Light
a337cb2bf0 cmd/go/internal/modget: s/prerelease/pre-release/
For prose consistency with other documentation.

Change-Id: I1588fbe1feace2a97b02b20bba730ed730b84fa3
Reviewed-on: https://go-review.googlesource.com/c/go/+/171772
Run-TryBot: Ross Light <light@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-04-15 21:28:13 +00:00
bronze1man
09b2b6e9dd net/http: remove unnecessary string replace operation in Cookie.String
Fixes #29135

Change-Id: I4c10b0395047775e8488b8b0f00f74a7fa01b86c
GitHub-Last-Rev: 1209770405
GitHub-Pull-Request: golang/go#29728
Reviewed-on: https://go-review.googlesource.com/c/go/+/157777
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-15 19:51:36 +00:00
sergey
6b7114b9e5 net/http: speed up parsing of Cookie headers
Parse the headers without splitting them upfront to reduce
memory allocations.

For non-pathological Cookie headers we can make
a good estimate of the number of cookies in there and preallocate
the slice of cookies

name              old time/op    new time/op    delta
CookieString-4      1.73µs ± 2%    1.70µs ± 5%     ~     (p=0.841 n=5+5)
ReadSetCookies-4    6.09µs ± 3%    5.93µs ± 3%     ~     (p=0.095 n=5+5)
ReadCookies-4       7.63µs ± 1%    6.41µs ± 4%  -15.99%  (p=0.008 n=5+5)

name              old alloc/op   new alloc/op   delta
CookieString-4        360B ± 0%      360B ± 0%     ~     (all equal)
ReadSetCookies-4      976B ± 0%      976B ± 0%     ~     (all equal)
ReadCookies-4       2.17kB ± 0%    1.84kB ± 0%  -15.13%  (p=0.008 n=5+5)

name              old allocs/op  new allocs/op  delta
CookieString-4        5.00 ± 0%      5.00 ± 0%     ~     (all equal)
ReadSetCookies-4      15.0 ± 0%      15.0 ± 0%     ~     (all equal)
ReadCookies-4         16.0 ± 0%      11.0 ± 0%  -31.25%  (p=0.008 n=5+5)

Change-Id: Ica1ca0d40c0d8d275134d1dfafb73f1082115826
Reviewed-on: https://go-review.googlesource.com/c/go/+/163617
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-15 19:30:44 +00:00
Brad Fitzpatrick
2c802e9980 net/http: add Server BaseContext & ConnContext fields to control early context
Fixes golang/go#30694

Change-Id: I12a0a870e4aee6576e879d88a4868666ef448298
Reviewed-on: https://go-review.googlesource.com/c/go/+/167681
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: JP Sugarbroad <jpsugar@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-15 19:15:11 +00:00
LE Manh Cuong
dec5d99b71 cmd/compile: remove outdate comment of treecopy
Since golang.org/cl/32487, treecopy does not handle non-iota ONONAME and
iota ONONAME anymore.

Change-Id: Icd5a81333a0d4d04adef2dbc58db92ce67aa0860
Reviewed-on: https://go-review.googlesource.com/c/go/+/172038
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-04-15 18:58:17 +00:00
Austin Clements
ad832284c7 runtime: remove some unused fields in m and p
Change-Id: Ie0171f48aaf48d8399ef578f95352445741d83a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/171773
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-15 18:58:15 +00:00
Josh Bleecher Snyder
d79aea6b96 cmd/link: deduplicate pctab info in pclntab
The existing pclntab construction took care to re-use strings:
filenames and fully qualified function names.

It did not try to deduplicate pctab information,
perhaps because the author assumed that there
wouldn't be much duplication.

This change introduces that deduplication.
The cache gets a 33% hit rate during make.bash.

This doesn't require any changes to the file format,
and shrinks binaries by about 1%.

Updates #6853

file      before    after     Δ        %       
go        14659236  14515876  -143360  -0.978% 
addr2line 4272424   4223272   -49152   -1.150% 
api       6050808   5993464   -57344   -0.948% 
asm       4906416   4869552   -36864   -0.751% 
buildid   2861104   2824240   -36864   -1.288% 
cgo       4859784   4810632   -49152   -1.011% 
compile   25749656  25213080  -536576  -2.084% 
cover     5286952   5229608   -57344   -1.085% 
dist      3634192   3597328   -36864   -1.014% 
doc       4691080   4641928   -49152   -1.048% 
fix       3397960   3361096   -36864   -1.085% 
link      6113568   6064432   -49136   -0.804% 
nm        4221928   4172776   -49152   -1.164% 
objdump   4636600   4587448   -49152   -1.060% 
pack      2281184   2256608   -24576   -1.077% 
pprof     14641204  14485556  -155648  -1.063% 
test2json 2814536   2785864   -28672   -1.019% 
trace     11602204  11487516  -114688  -0.989% 
vet       8399528   8313512   -86016   -1.024% 

Change-Id: I59c6aae522700a0d36ddd2cbca6e22ecdf17eea2
Reviewed-on: https://go-review.googlesource.com/c/go/+/172079
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-15 18:48:21 +00:00
Josh Bleecher Snyder
d3a23874af cmd/link: clean up pclntab
More minor cleanup:

* Code simplification
* Move variable declaration closer to use
* Add docs
* Refactor loop

Change-Id: I6f662cb65038b6ad927eb83757b241ac1ef58943
Reviewed-on: https://go-review.googlesource.com/c/go/+/172078
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-15 18:47:24 +00:00
Ian Lance Taylor
3ebd9523bb os: don't treat RemoveAll("/x") as RemoveAll("x")
Fixes #31468

Change-Id: I5c4e61631b8af35bfc14b0cb9bc77feec100e340
Reviewed-on: https://go-review.googlesource.com/c/go/+/172058
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-15 18:28:49 +00:00
Udalov Max
827044e7a6 crypto/sha512: use math/bits.RotateLeft64 instead of ad-hoc implementation
This makes code more readable and idiomatic and slightly increase performance.

Updates #31456

Benchstat:
name          old time/op    new time/op    delta
Hash8Bytes-8     281ns ± 4%     280ns ± 3%    ~     (p=0.640 n=10+10)
Hash1K-8        2.01µs ± 6%    2.02µs ± 3%    ~     (p=0.481 n=10+10)
Hash8K-8        14.2µs ± 6%    13.5µs ± 1%  -4.90%  (p=0.001 n=10+10)

name          old speed      new speed      delta
Hash8Bytes-8  28.5MB/s ± 4%  28.5MB/s ± 3%    ~     (p=0.516 n=10+10)
Hash1K-8       510MB/s ± 6%   507MB/s ± 4%    ~     (p=0.481 n=10+10)
Hash8K-8       576MB/s ± 6%   605MB/s ± 1%  +5.02%  (p=0.001 n=10+10)

Tested on macbook pro 2018 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz

Change-Id: I1f5b78096dd49d14ffcb9129142c4a4e05b81ff9
Reviewed-on: https://go-review.googlesource.com/c/go/+/171736
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2019-04-15 18:01:30 +00:00
Robert Griesemer
f8c6f986fd math/big: don't clobber shared underlying array in pow5 computation
Rearranged code slightly to make lifetime of underlying array of
pow5 more explicit in code.

Fixes #31184.

Change-Id: I063081f0e54097c499988d268a23813746592654
Reviewed-on: https://go-review.googlesource.com/c/go/+/170641
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2019-04-15 17:48:21 +00:00
Matthew Dempsky
97c4ad4327 cmd/compile: add new escape analysis implementation
This CL adds a new escape analysis implementation, which can be
enabled through the -newescape compiler flag.

This implementation focuses on simplicity, but in the process ends up
using less memory, speeding up some compile-times, fixing memory
corruption issues, and overall significantly improving escape analysis
results.

Updates #23109.

Change-Id: I6176d9a7ae9d80adb0208d4112b8a1e1f4c9143a
Reviewed-on: https://go-review.googlesource.com/c/go/+/170322
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2019-04-15 17:35:57 +00:00
Michael Munday
d91f7e6637 runtime: fix GDB tests on s390x running Ubuntu 18.04
On Ubuntu 18.04 I am seeing GDB fail to restore the stack pointer
during this test because stack unwinding can't find the PC. This CL
is essentially a partial revert of CL 23940 and fixes the issue on
s390x.

Change-Id: Ib4c41162dc85dc882eb6e248330f4082c3fa94c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/169857
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-04-15 14:53:19 +00:00
Michael Munday
aafe257390 cmd/link, runtime: mark goexit as the top of the call stack
This CL adds a new attribute, TOPFRAME, which can be used to mark
functions that should be treated as being at the top of the call
stack. The function `runtime.goexit` has been marked this way on
architectures that use a link register.

This will stop programs that use DWARF to unwind the call stack
from unwinding past `runtime.goexit` on architectures that use a
link register. For example, it eliminates "corrupt stack?"
warnings when generating a backtrace that hits `runtime.goexit`
in GDB on s390x.

Similar code should be added for non-link-register architectures
(i.e. amd64, 386). They mark the top of the call stack slightly
differently to link register architectures so I haven't added
that code (they need to mark "rip" as undefined).

Fixes #24385.

Change-Id: I15b4c69ac75b491daa0acf0d981cb80eb06488de
Reviewed-on: https://go-review.googlesource.com/c/go/+/169726
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-04-15 13:17:28 +00:00
Yuval Pavel Zholkover
0bd101cecc cmd/dist: enable cgo for freebsd/arm
Change-Id: Icc1a54da848bf446919c0d5470d1e79fad339832
Reviewed-on: https://go-review.googlesource.com/c/go/+/171727
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-15 07:00:02 +00:00
Daniel Martí
60a8dbf3b4 go/token: add IsIdentifier, IsKeyword, and IsExported
Telling whether a string is a valid Go identifier can seem like an easy
task, but it's easy to forget about the edge cases. For example, some
implementations out there forget that an empty string or keywords like
"func" aren't valid identifiers.

Add a simple implementation with proper Unicode support, and start using
it in cmd/cover and cmd/doc. Other pieces of the standard library
reimplement part of this logic, but don't use a "func(string) bool"
signature, so we're leaving them untouched for now.

Add some tests too, to ensure that we actually got these edge cases
correctly.

Since telling whether a string is a valid identifier requires knowing
that it's not a valid keyword, add IsKeyword too. The internal map was
already accessible via Lookup, but "Lookup(str) != IDENT" isn't as easy
to understand as IsKeyword(str). And, as per Josh's suggestion, we could
have IsKeyword (and probably Lookup too) use a perfect hash function
instead of a global map.

Finally, for consistency with these new functions, add IsExported. That
makes go/ast.IsExported a bit redundant, so perhaps it can be deprecated
in favor of go/token.IsExported in the future. Clarify that
token.IsExported doesn't imply token.IsIdentifier, to avoid ambiguity.

Fixes #30064.

Change-Id: I0e0e49215fd7e47b603ebc2b5a44086c51ba57f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/169018
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2019-04-15 04:12:52 +00:00
Максадбек Ахмедов
a01d108e30 strings: remove "a copy of the string" from ToUpper/ToLower comments
When string letters are all in lower/upper cases, both functions respectively
return original string.

Fixes #30987

Change-Id: Ie8d664f7af5e087f82c1bc156933e9a995645bf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/171735
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-14 16:19:31 +00:00
Yuval Pavel Zholkover
a6e892d26d cmd/dist: enable VFPv3 on freebsd/arm
Since CL 165799 was merged, VFP detection should work properly on FreeBSD.

Updates #27619

Change-Id: I386e856ceb54f0bf6e6bf83bf2d1e19154ba53f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/171728
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-04-14 16:06:27 +00:00
Tobias Klauser
f125b32d19 cmd/compile/internal/arm: merge cases in ssaGenValue
Merge case statement for OpARMSLL, OpARMSRL and OpARMSRA into an
existing one using the same logic.

Change-Id: Ic4224668228902e5188fb0559b5f1949cfea1381
Reviewed-on: https://go-review.googlesource.com/c/go/+/171724
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-04-13 17:08:29 +00:00
Udalov Max
7cd39de2d9 crypto/sha1: use math/bits.RotateLeft32 instead of ad-hoc implementation.
This makes code more idiomatic and shows small performance gains of generic benchmarks.

Updates: #31456

name            old time/op    new time/op    delta
Hash8Bytes-8       275ns ± 4%     270ns ± 0%    ~     (p=0.213 n=9+8)
Hash320Bytes-8    1.46µs ± 5%    1.39µs ± 1%  -4.54%  (p=0.000 n=10+10)
Hash1K-8          3.99µs ± 5%    3.86µs ± 1%  -3.38%  (p=0.023 n=10+10)
Hash8K-8          28.9µs ± 0%    28.9µs ± 1%    ~     (p=0.315 n=10+10)

name            old speed      new speed      delta
Hash8Bytes-8    28.8MB/s ± 9%  29.6MB/s ± 0%    ~     (p=0.151 n=10+8)
Hash320Bytes-8   220MB/s ± 5%   230MB/s ± 1%  +4.65%  (p=0.000 n=10+10)
Hash1K-8         257MB/s ± 5%   265MB/s ± 1%  +3.38%  (p=0.023 n=10+10)
Hash8K-8         283MB/s ± 0%   284MB/s ± 1%    ~     (p=0.315 n=10+10)

Change-Id: Iee63aa042614e3bbeda9aaf5236180d4153f03c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/171729
Reviewed-by: Ilya Tokar <tocarip@gmail.com>
Run-TryBot: Ilya Tokar <tocarip@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-13 13:56:23 +00:00
Daniel Martí
ab2f83c387 encoding/json: remove a bounds check in readValue
readValue is a hot function, clocking in at ~13% flat CPU use in
CodeDecoder. In particular, looping over the bytes is slow. That's
partially because the code contains a bounds check at the start of the
loop.

The source of the problem is that scanp is a signed integer, and comes
from a field, so the compiler doesn't know that it's non-negative. Help
it with a simple and comparatively cheap hint.

While at it, use scanp as the index variable directly, removing the need
for a duplicate index variable which is later added back into scanp.

name           old time/op    new time/op    delta
CodeDecoder-8    11.3ms ± 1%    11.2ms ± 1%  -0.98%  (p=0.000 n=9+9)

name           old speed      new speed      delta
CodeDecoder-8   172MB/s ± 1%   174MB/s ± 1%  +0.99%  (p=0.000 n=9+9)

Updates #28923.

Change-Id: I138f83babdf316fc97697cc18f595c3403c1ddb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/170939
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-13 13:14:55 +00:00
OkamotoYuki
ee64b35531 cmd/go/internal/test: pass default timeout to test programs if not given from command line
Make 'go test' command to pass the default timeout (10m) to test programs if the value is not given from command line.

Fixes #28147

Change-Id: I7856e452224a51a92da03bab8e3a0f9d7c41d32a
GitHub-Last-Rev: 66f9a6f90e
GitHub-Pull-Request: golang/go#30545
Reviewed-on: https://go-review.googlesource.com/c/go/+/164963
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-04-13 02:39:29 +00:00
Romain Baugue
c40bffd905 reflect: add Value.IsZero
Fixes #7501

Change-Id: Iac7c79cd4b30a90b14ed84bf1eba758972232a6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/171337
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-13 00:04:07 +00:00
Josh Bleecher Snyder
6d64dd731b cmd/link: make Pciter more idiomatic
Rename it to PCIter and convert it to use methods.

Set pcscale once, during construction, to make call sites clearer.

Change some ints to bools.

Use a simple iteration termination condition,
instead of the cap comparison from the c2go translation.

Instead of requiring a Pcdata, which requires one caller
to synthesize a fake Pcdata, just ask for a byte slice.

Passes toolstash-check.

Change-Id: I811da0e929cf4a806bd6d70357ccf2911cd0c737
Reviewed-on: https://go-review.googlesource.com/c/go/+/171770
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-12 21:41:09 +00:00
Josh Bleecher Snyder
134ef176f0 cmd/link, cmd/internal/obj: use encoding/binary for varint
This code was written before the c2go toolchain conversion.
Replace the handwritten varint encoding routines
and the handwritten unsigned-to-signed conversions
with calls to encoding/binary.

Passes toolstash-check.

Change-Id: I30d7f408cde3772ee98a3825e83075c4e1ec96d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/171769
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-12 19:15:34 +00:00
Josh Bleecher Snyder
c70a7849af cmd/internal/obj: stop plist flushing early on error
If preprocessing or assembling has failed, we should not proceed.
First, there's no point.
Second, I will shortly add some sanity checks to linkpcln
that will fail on malformed input.

Change-Id: I055eeab1c2f3a66b4b2cadb551bbf4ab55d176f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/171886
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-04-12 19:13:31 +00:00