1
0
mirror of https://github.com/golang/go synced 2024-11-06 04:36:15 -07:00
Commit Graph

37597 Commits

Author SHA1 Message Date
Andreas Auernhammer
30eda6715c crypto/rc4: remove assembler implementations
This CL removes the RC4 assembler implementations.
RC4 is broken and should not be used for encryption
anymore. Therefore it's not worth maintaining
platform-specific assembler implementations.

The native Go implementation may be slower
or faster depending on the CPU:

name       old time/op   new time/op   delta
RC4_128-4    256ns ± 0%    196ns ± 0%  -23.78%  (p=0.029 n=4+4)
RC4_1K-4    2.38µs ± 0%   1.54µs ± 0%  -35.22%  (p=0.029 n=4+4)
RC4_8K-4    19.4µs ± 1%   12.0µs ± 0%  -38.35%  (p=0.029 n=4+4)

name       old speed     new speed     delta
RC4_128-4  498MB/s ± 0%  654MB/s ± 0%  +31.12%  (p=0.029 n=4+4)
RC4_1K-4   431MB/s ± 0%  665MB/s ± 0%  +54.34%  (p=0.029 n=4+4)
RC4_8K-4   418MB/s ± 1%  677MB/s ± 0%  +62.18%  (p=0.029 n=4+4)

vendor_id	: GenuineIntel
cpu family	: 6
model		: 142
model name	: Intel(R) Core(TM) i5-7Y54 CPU @ 1.20GHz
stepping	: 9
microcode	: 0x84
cpu MHz		: 800.036
cache size	: 4096 KB

name       old time/op   new time/op   delta
RC4_128-4    235ns ± 1%    431ns ± 0%  +83.00%  (p=0.000 n=10+10)
RC4_1K-4    1.74µs ± 0%   3.41µs ± 0%  +96.74%  (p=0.000 n=10+10)
RC4_8K-4    13.6µs ± 1%   26.8µs ± 0%  +97.58%   (p=0.000 n=10+9)

name       old speed     new speed     delta
RC4_128-4  543MB/s ± 0%  297MB/s ± 1%  -45.29%  (p=0.000 n=10+10)
RC4_1K-4   590MB/s ± 0%  300MB/s ± 0%  -49.16%  (p=0.000 n=10+10)
RC4_8K-4   596MB/s ± 1%  302MB/s ± 0%  -49.39%   (p=0.000 n=10+9)

vendor_id       : GenuineIntel
cpu family      : 6
model           : 63
model name      : Intel(R) Xeon(R) CPU @ 2.30GHz
stepping        : 0
microcode       : 0x1
cpu MHz         : 2300.000
cache size      : 46080 KB

Fixes #25417

Change-Id: I4124037154aaaa8e48d300c23974f125b6055a1c
Reviewed-on: https://go-review.googlesource.com/130397
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-21 19:49:06 +00:00
Daniel Martí
6d4787aff2 encoding/json: various minor decoder speed-ups
Reuse v.Type() and cachedTypeFields(t) when decoding maps and structs.

Always use the same data slices when in hot loops, to ensure that the
compiler generates good code. "for i < len(data) { use(d.data[i]) }"
makes it harder for the compiler.

Finally, do other minor clean-ups, such as deduplicating switch cases,
and using a switch instead of three chained ifs.

The decoder sees a noticeable speed-up, in particular when decoding
structs.

name           old time/op    new time/op    delta
CodeDecoder-4    29.8ms ± 1%    27.5ms ± 0%  -7.83%  (p=0.002 n=6+6)

name           old speed      new speed      delta
CodeDecoder-4  65.0MB/s ± 1%  70.6MB/s ± 0%  +8.49%  (p=0.002 n=6+6)

Updates #5683.

Change-Id: I9d751e22502221962da696e48996ffdeb777277d
Reviewed-on: https://go-review.googlesource.com/122468
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 19:00:08 +00:00
Daniel Martí
9a2a34e1c1 encoding/json: defer error context work until necessary
Calling Name on a reflect.Type is somewhat expensive, as it involves a
number of nested calls and string handling.

This cost was showing up when decoding structs, as we were calling it to
set up an error context.

We can avoid the extra work unless we do encounter an error, which makes
decoding via struct types faster.

name           old time/op    new time/op    delta
CodeDecoder-4    31.0ms ± 1%    29.9ms ± 1%  -3.69%  (p=0.002 n=6+6)

name           old speed      new speed      delta
CodeDecoder-4  62.6MB/s ± 1%  65.0MB/s ± 1%  +3.83%  (p=0.002 n=6+6)

Updates #5683.

Change-Id: I48a3a85ef0ba96f524b7c3e9096cb2c4589e077a
Reviewed-on: https://go-review.googlesource.com/122467
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 18:18:59 +00:00
Michael Munday
4a842f2559 crypto/{aes,cipher,rand}: use binary.{Big,Little}Endian methods
Use the binary.{Big,Little}Endian integer encoding methods rather
than unsafe or local implementations. These methods are tested to
ensure they inline correctly and don't add unnecessary bounds checks,
so it seems better to use them wherever possible.

This introduces a dependency on encoding/binary to crypto/cipher. I
think this is OK because other "L3" packages already import
encoding/binary.

Change-Id: I5cf01800d08554ca364e46cfc1d9445cf3c711a0
Reviewed-on: https://go-review.googlesource.com/115555
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 16:15:16 +00:00
Alberto Donizetti
3649fe299d cmd/gofmt: skip gofmt idempotency check on known issue
gofmt's TestAll runs gofmt on all the go files in the tree and checks,
among other things, that gofmt is idempotent (i.e. that a second
invocation does not change the input again).

There's a known bug of gofmt not being idempotent (Issue #24472), and
unfortunately the fixedbugs/issue22662.go file triggers it. We can't
just gofmt the file, because it tests the effect of various line
directives inside weirdly-placed comments, and gofmt moves those
comments, making the test useless.

Instead, just skip the idempotency check when gofmt-ing the
problematic file.

This fixes go test on the cmd/gofmt package, and a failure seen on the
longtest builder.

Updates #24472

Change-Id: Ib06300977cd8fce6c609e688b222e9b2186f5aa7
Reviewed-on: https://go-review.googlesource.com/130377
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-21 16:01:43 +00:00
Ian Lance Taylor
0829e1b757 misc/cgo/testcarchive: make the tests work when using gccgo
Change-Id: I62a7a8ebbbc1f1a266234b53680768da157b2df5
Reviewed-on: https://go-review.googlesource.com/130416
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-21 15:03:10 +00:00
Ian Lance Taylor
cd7cb86d8e runtime: don't use linkname to refer to internal/cpu
The runtime package already imports the internal/cpu package, so there
is no reason for it to use go:linkname comments to refer to
internal/cpu functions and variables. Since internal/cpu is internal,
we can just export those names. Removing the obscurity of go:linkname
outweighs the minor additional complexity added to the internal/cpu API.

Change-Id: Id89951b7f3fc67cd9bce67ac6d01d44a647a10ad
Reviewed-on: https://go-review.googlesource.com/128755
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
2018-08-21 14:36:09 +00:00
Tobias Klauser
4e1b11e2c9 syscall: add S_IRWXG and S_IRWXO on Solaris
As discussed in CL 126621, these constants are already defined on Linux,
Darwin, FreeBSD and NetBSD. In order to ensure portability of existing
code using the syscall package, provide them for Solaris as well.

Change-Id: Id49f6991f36775b152b9c47b9923cd0a08053bcb
Reviewed-on: https://go-review.googlesource.com/130356
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 14:08:55 +00:00
Tobias Klauser
d865e1fa48 syscall: add S_IRWXG and S_IRWXO on OpenBSD
As discussed in CL 126621, these constants are already defined on Linux,
Darwin, FreeBSD and NetBSD. In order to ensure portability of existing
code using the syscall package, provide them for OpenBSD (and
DragonflyBSD, in a separate CL) as well.

Change-Id: Ia9e07cb01f989d144a620d268daa8ec946788861
Reviewed-on: https://go-review.googlesource.com/130336
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 14:08:25 +00:00
Tobias Klauser
e8daca4c48 syscall: add S_IRWXG and S_IRWXO on DragonflyBSD
As discussed in CL 126621, these constants are already defined on Linux,
Darwin, FreeBSD and NetBSD. In order to ensure portability of existing
code using the syscall package, provide them for DragonflyBSD (and
OpenBSD, in a separate CL) as well.

Change-Id: I708c60f75f787a410bdfa4ceebd2825874e92511
Reviewed-on: https://go-review.googlesource.com/130335
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 14:08:12 +00:00
Florian Forster
1040626c0c net/url: escape URL.RawQuery on Parse if it contains invalid characters
Fixes #22907

Change-Id: I7abcf53ab92768514e13ce2554a6c25dcde8218e
Reviewed-on: https://go-review.googlesource.com/99135
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 14:05:03 +00:00
Michael Munday
1d1a0277de go/build: format with latest gofmt
Change-Id: I172af5c83a0d4d79ad627ba9dfe02dead23bf3a6
Reviewed-on: https://go-review.googlesource.com/130376
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2018-08-21 13:23:02 +00:00
Giovanni Bajo
94e4aca3e6 doc: remove mentions of cloning from GitHub
Complete CL117178 removing all references to GitHub, and leaving
a small note to make sure we remember that it's not supported.

Change-Id: Id4257515a864875808fa7a67f002ed52cfd635a3
Reviewed-on: https://go-review.googlesource.com/130395
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2018-08-21 13:20:11 +00:00
Daniel Martí
c180798956 cmd/compile: fix racy setting of gc's Config.Race
ssaConfig.Race was being set by many goroutines concurrently, resulting
in a data race seen below. This was very likely introduced by CL 121235.

	WARNING: DATA RACE
	Write at 0x00c000344408 by goroutine 12:
	  cmd/compile/internal/gc.buildssa()
	      /workdir/go/src/cmd/compile/internal/gc/ssa.go:134 +0x7a8
	  cmd/compile/internal/gc.compileSSA()
	      /workdir/go/src/cmd/compile/internal/gc/pgen.go:259 +0x5d
	  cmd/compile/internal/gc.compileFunctions.func2()
	      /workdir/go/src/cmd/compile/internal/gc/pgen.go:323 +0x5a

	Previous write at 0x00c000344408 by goroutine 11:
	  cmd/compile/internal/gc.buildssa()
	      /workdir/go/src/cmd/compile/internal/gc/ssa.go:134 +0x7a8
	  cmd/compile/internal/gc.compileSSA()
	      /workdir/go/src/cmd/compile/internal/gc/pgen.go:259 +0x5d
	  cmd/compile/internal/gc.compileFunctions.func2()
	      /workdir/go/src/cmd/compile/internal/gc/pgen.go:323 +0x5a

	Goroutine 12 (running) created at:
	  cmd/compile/internal/gc.compileFunctions()
	      /workdir/go/src/cmd/compile/internal/gc/pgen.go:321 +0x39b
	  cmd/compile/internal/gc.Main()
	      /workdir/go/src/cmd/compile/internal/gc/main.go:651 +0x437d
	  main.main()
	      /workdir/go/src/cmd/compile/main.go:51 +0x100

	Goroutine 11 (running) created at:
	  cmd/compile/internal/gc.compileFunctions()
	      /workdir/go/src/cmd/compile/internal/gc/pgen.go:321 +0x39b
	  cmd/compile/internal/gc.Main()
	      /workdir/go/src/cmd/compile/internal/gc/main.go:651 +0x437d
	  main.main()
	      /workdir/go/src/cmd/compile/main.go:51 +0x100

Instead, set up the field exactly once as part of initssaconfig.

Change-Id: I2c30c6b1cf92b8fd98e7cb5c2e10c526467d0b0a
Reviewed-on: https://go-review.googlesource.com/130375
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2018-08-21 12:29:21 +00:00
Daniel Martí
30d3ebe367 encoding/json: remove alloc when encoding short byte slices
If the encoded bytes fit in the bootstrap array encodeState.scratch, use
that instead of allocating a new byte slice.

Also tweaked the Encoding vs Encoder heuristic to use the length of the
encoded bytes, not the length of the input bytes. Encoding is used for
allocations of up to 1024 bytes, as we measured 2048 to be the point
where it no longer provides a noticeable advantage.

Also added some benchmarks. Only the first case changes in behavior.

name                 old time/op    new time/op    delta
MarshalBytes/32-4       420ns ± 1%     383ns ± 1%   -8.69%  (p=0.002 n=6+6)
MarshalBytes/256-4      913ns ± 1%     915ns ± 0%     ~     (p=0.580 n=5+6)
MarshalBytes/4096-4    7.72µs ± 0%    7.74µs ± 0%     ~     (p=0.340 n=5+6)

name                 old alloc/op   new alloc/op   delta
MarshalBytes/32-4        112B ± 0%       64B ± 0%  -42.86%  (p=0.002 n=6+6)
MarshalBytes/256-4       736B ± 0%      736B ± 0%     ~     (all equal)
MarshalBytes/4096-4    7.30kB ± 0%    7.30kB ± 0%     ~     (all equal)

name                 old allocs/op  new allocs/op  delta
MarshalBytes/32-4        2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.002 n=6+6)
MarshalBytes/256-4       2.00 ± 0%      2.00 ± 0%     ~     (all equal)
MarshalBytes/4096-4      2.00 ± 0%      2.00 ± 0%     ~     (all equal)

Updates #5683.

Change-Id: I5fa55c27bd7728338d770ae7c0756885ba9a5724
Reviewed-on: https://go-review.googlesource.com/122462
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 09:05:51 +00:00
Daniel Martí
2d3599e57d encoding/json: encode struct field names ahead of time
Struct field names are static, so we can run HTMLEscape on them when
building each struct type encoder. Then, when running the struct
encoder, we can select either the original or the escaped field name to
write directly.

When the encoder is not escaping HTML, using the original string works
because neither Go struct field names nor JSON tags allow any characters
that would need to be escaped, like '"', '\\', or '\n'.

When the encoder is escaping HTML, the only difference is that '<', '>',
and '&' are allowed via JSON struct field tags, hence why we use
HTMLEscape to properly escape them.

All of the above lets us encode field names with a simple if/else and
WriteString calls, which are considerably simpler and faster than
encoding an arbitrary string.

While at it, also include the quotes and colon in these strings, to
avoid three WriteByte calls in the loop hot path.

Also added a few tests, to ensure that the behavior in these edge cases
is not broken. The output of the tests is the same if this optimization
is reverted.

name           old time/op    new time/op    delta
CodeEncoder-4    7.12ms ± 0%    6.14ms ± 0%  -13.85%  (p=0.004 n=6+5)

name           old speed      new speed      delta
CodeEncoder-4   272MB/s ± 0%   316MB/s ± 0%  +16.08%  (p=0.004 n=6+5)

name           old alloc/op   new alloc/op   delta
CodeEncoder-4    91.9kB ± 0%    93.2kB ± 0%   +1.43%  (p=0.002 n=6+6)

name           old allocs/op  new allocs/op  delta
CodeEncoder-4      0.00           0.00          ~     (all equal)

Updates #5683.

Change-Id: I6f6a340d0de4670799ce38cf95b2092822d2e3ef
Reviewed-on: https://go-review.googlesource.com/122460
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 09:05:48 +00:00
Tobias Klauser
e7f59f0284 cmd/compile/internal/gc: unexport Deferproc and Newproc
They are no longer used outside the package since CL 38080.

Passes toolstash-check -all

Change-Id: I30977ed2b233b7c8c53632cc420938bc3b0e37c6
Reviewed-on: https://go-review.googlesource.com/129781
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 08:12:06 +00:00
Daniel Martí
d7ab57efda cmd/go: fix 'go vet -h' to print the right text
For the last two releases, its output has been the same as 'go -h'.

The test and vet sub-commands share their flag logic via the cmdflag
package, so fixing it there would mean a larger refactor. Moreover, the
test subcommand handles its '-h' flag in a special way; that's #26999.

For now, use a much less invasive fix, mirroring the special-casing of
'test -h' to simply print vet's short usage text.

Also add a regression test via a cmd/go test script.

Fixes #26998.

Change-Id: Ie6b866d98116a1bc5f84a204e1c9f1c2f6b48bff
Reviewed-on: https://go-review.googlesource.com/129318
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2018-08-21 07:36:54 +00:00
Marcus Willock
187a41dbf7 net/http: add an example of creating a custom FileSystem
The existing documentation of http.Dir is clear in that, if you want to hide
your files and directories that start with a period, you must create
a custom FileSystem. However, there are currently no example on how
to create a custom FileSystem. This commit provides an example.

Fixes #20759

Change-Id: I5a350675536f81412af384d1a316fd6cd6241563
GitHub-Last-Rev: 8b0b644cd0
GitHub-Pull-Request: golang/go#26768
Reviewed-on: https://go-review.googlesource.com/127576
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-21 04:55:04 +00:00
Cholerae Hu
2a5df06765 hash/crc64: lazily initialize slice8Tables
Saves 36KB of memory in stdlib packages.

Updates #26775

Change-Id: I0f9d7b17d9768f6fb980d5fbba7c45920215a5fc
Reviewed-on: https://go-review.googlesource.com/127735
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 04:50:21 +00:00
Brad Fitzpatrick
80fe2e6e37 net: lazily look up the listenerBacklog value on first use
Don't open files or do sysctls in init.

Updates #26775

Change-Id: I017bed6c24ef1e4bc30040120349fb779f203225
Reviewed-on: https://go-review.googlesource.com/127655
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-21 04:39:22 +00:00
Kevin Zita
8272484840 strings: revise ToUpperSpecial and ToLowerSpecial wording
Fixes #26654

Change-Id: I4832c45cad40607b83e1a8a9b562fa12e639b7d9
GitHub-Last-Rev: c9ceedb7d4
GitHub-Pull-Request: golang/go#26781
Reviewed-on: https://go-review.googlesource.com/127716
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 04:38:58 +00:00
Sandy
15c362a260 time: use secondsPerMinute instead of 60
It's maybe better.

Change-Id: I7929e93a95c96676915bc24f2f7cce4e73b08c59
GitHub-Last-Rev: a8c2bb6caf
GitHub-Pull-Request: golang/go#26685
Reviewed-on: https://go-review.googlesource.com/126623
Reviewed-by: Ralph Corderoy <ralph@inputplus.co.uk>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 04:38:18 +00:00
Peter Collingbourne
6417e91962 cmd/link: pass provided ldflags when testing whether an ldflag is supported
It's possible for one of the ldflags to cause the compiler driver to
use a different linker than the default, so we need to make sure that
the flag is supported by whichever linker is specified.

Fixes #27110.

Change-Id: Ic0c51b886e34344d324e68cbf6673b168c14992f
Reviewed-on: https://go-review.googlesource.com/130316
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-21 03:53:55 +00:00
Brad Fitzpatrick
247b034ac0 cmd/go: run mkalldocs.sh after earlier revert
Change-Id: Ie4ed8b3e7d26ae53b2290a7a6e7d9888eb963edc
Reviewed-on: https://go-review.googlesource.com/130318
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 03:47:22 +00:00
Ian Lance Taylor
e8e074d1ba cmd/vet: implement old TODO from testdata/print.go
The code was fixed in CL 108559 but the testing TODO was not implemented.

Updates #22936

Change-Id: I20a703260a181bbcf5f87609d6fb8221a182be1a
Reviewed-on: https://go-review.googlesource.com/125038
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2018-08-21 03:39:47 +00:00
Ian Lance Taylor
7e64377903 cmd/compile: only support -race and -msan where they work
Consolidate decision about whether -race and -msan options are
supported in cmd/internal/sys. Use consolidated functions in
cmd/compile and cmd/go. Use a copy of them in cmd/dist; cmd/dist can't
import cmd/internal/sys because Go 1.4 doesn't have it.

Fixes #24315

Change-Id: I9cecaed4895eb1a2a49379b4848db40de66d32a9
Reviewed-on: https://go-review.googlesource.com/121816
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 03:38:27 +00:00
Brad Fitzpatrick
d58f3e6fea net/http: add test showing that ReverseProxy HTTP/2 bidi streaming works
Change-Id: I8361ae33c785e45e3ccc7e9bc2732c887eeb41c4
Reviewed-on: https://go-review.googlesource.com/127015
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 03:26:03 +00:00
Iskander Sharipov
bce1f12225 cmd/compile/internal/ssa: use math/bits in countRegs and pickReg
Makes code simpler and faster (at least on x86).

	name               old time/op  new time/op  delta
	CountRegs-8        7.40ns ± 1%  0.59ns ± 0%  -92.02%  (p=0.000 n=9+9)
	PickReg/(1<<0)-8   2.07ns ± 0%  0.37ns ± 0%  -82.13%  (p=0.000 n=9+10)
	PickReg/(1<<16)-8  11.8ns ± 0%   0.4ns ± 0%  -96.86%  (p=0.002 n=8+10)

Change-Id: Ic780b615b75c25b6e7632a0de93b16a8e9ed0f8f
Reviewed-on: https://go-review.googlesource.com/120318
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-08-21 03:14:39 +00:00
Brad Fitzpatrick
fc5107c270 go/doc: compile regexps lazily
Compile go/doc's 4 regexps lazily, on demand.

Also, add a test for the one that had no test coverage.

This reduces init-time CPU as well as heap by ~20KB when they're not
used, which seems to be common enough. As an example, cmd/doc only
seems to use 1 of them. (as noted by temporary print statements)

Updates #26775

Change-Id: I85df89b836327a53fb8e1ace3f92480374270368
Reviewed-on: https://go-review.googlesource.com/127875
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-21 02:51:10 +00:00
Brad Fitzpatrick
c544e0fbdb strings: select Replacer algorithm and build machine lazily
Saves 22KB of memory in stdlib packages.

Updates #26775

Change-Id: Ia19fe7aff61f6e2ddd83cd35969d7ff94526591f
Reviewed-on: https://go-review.googlesource.com/127661
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-21 02:50:58 +00:00
Muhammad Falak R Wani
9087d13ec3 cmd/objdump: defer closing the file after opening
Remove the os.Exit(0) to honor the deferred closing of the file.

Change-Id: Iaa9304d8203c8fec0ec728af669a94eadd36905c
Reviewed-on: https://go-review.googlesource.com/118915
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 02:45:00 +00:00
Russ Cox
a0212aa627 cmd/go: revert "add graphviz output to graph command"
This reverts commit 723479bc30.

Reason for revert: other tools should convert the graph output to graphviz.

Change-Id: Ide5b8f0b061aaff74bb6ba4c2a8f8768d1fbc05a
Reviewed-on: https://go-review.googlesource.com/130295
Reviewed-by: Russ Cox <rsc@golang.org>
2018-08-21 02:44:04 +00:00
Russ Cox
27ed675b4b cmd/go: fix 'go help go.mod' example
Dropped the example referred to in the text
when copying this text out of 'go help mod fix'.

Fixes #27083.

Change-Id: I63dfa3033fa2b2408019eef9d8b5a055aa803c57
Reviewed-on: https://go-review.googlesource.com/130140
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-21 02:41:59 +00:00
Russ Cox
df6aedb630 cmd/go: fix list -compiled of package with only tests
Fixes #27097.

Change-Id: I6aa48a1c58a21fd320b0e9dcd1f86c90172f0182
Reviewed-on: https://go-review.googlesource.com/130139
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-21 02:41:58 +00:00
Russ Cox
c652a1b9c0 cmd/go: fix modload response for std-vendored packages
This fixes a failure when using Go 1.11 to build App Engine code.

Change-Id: I008e8cf5ad4c568676d904deddff031a166f2d5d
Reviewed-on: https://go-review.googlesource.com/130138
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-21 02:41:56 +00:00
Russ Cox
46033d7639 cmd/go: add go.sum entries to go mod download -json output
Clients of 'go mod download', particularly proxies, may need
the hashes of the content they downloaded, for checking against
go.sum entries or recording elsewhere.

Change-Id: Ic36c882cefc540678e1bc5a3dae1e865d181aa69
Reviewed-on: https://go-review.googlesource.com/129802
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-08-21 02:41:55 +00:00
Tim Cooper
dc272a4393 encoding/json: call reflect.TypeOf with nil pointers rather than allocating
Updates #26775

Change-Id: I83c9eeda59769d2f35e0cc98f3a8579861d5978b
Reviewed-on: https://go-review.googlesource.com/119715
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-21 02:38:02 +00:00
Tim Cooper
3333b6407d net/http: use internal/race
Change-Id: Iaa5ded13e8ab4753e2e3d04c9fff203d854208ba
Reviewed-on: https://go-review.googlesource.com/119435
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 02:37:19 +00:00
isharipo
bc276c585b cmd/link/internal/ld: avoid Reloc copies in range loops
Copying sym.Reloc in loops hurts performance as
it has 48 byte size (on 64-bit platforms).

There are quite many symbols and each of them has more than 1
relocation (so, it's possible to have more than 1kk relocs).
The're also traversed more than once in some code paths.

By using pointers to them, copies are avoided.

For linking "hello world" example from net/http:

	name      old time/op  new time/op  delta
	Linker-4   530ms ± 2%   521ms ± 3%  -1.80%  (p=0.000 n=17+20)

Change-Id: I6518aec69d6adcd137f84b5c089ceab4cb4ea2dd
Reviewed-on: https://go-review.googlesource.com/113636
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 02:29:51 +00:00
Philip Børgesen
97c7e0e0ad encoding/json: eliminate superfluous space in Decoder.Token error messages
The existing Decoder.tokenError implementation creates its error messages by
concatenating "invalid character " + quoteChar(c) + " " + context. All context
values however already start with a space leading to error messages containing
two spaces.

This change removes " " from the concatenation expression.

Fixes #26587

Change-Id: I93d14319396636b2a40d55053bda88c98e94a81a
GitHub-Last-Rev: 6db7e1991b
GitHub-Pull-Request: golang/go#26588
Reviewed-on: https://go-review.googlesource.com/125775
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-21 02:26:17 +00:00
Jan Lehnardt
0ca3203bec syscall: add S_IRWXG and S_IRWXO to FreeBSD types
Companion PR to https://github.com/golang/sys/pull/13

Change-Id: I097fc97912840eb69ca232eded6ba939de0fead9
GitHub-Last-Rev: f8a8f7d96c
GitHub-Pull-Request: golang/go#26675
Reviewed-on: https://go-review.googlesource.com/126621
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 02:18:19 +00:00
Tim Cooper
352583ff77 encoding/hex: pre-allocate Dump buffer
name          old time/op    new time/op    delta
Dump/256-4      7.76µs ± 2%    5.82µs ± 2%  -24.91%  (p=0.008 n=5+5)
Dump/1024-4     28.4µs ± 2%    22.6µs ± 3%  -20.58%  (p=0.008 n=5+5)
Dump/4096-4      112µs ± 2%      88µs ± 0%  -20.80%  (p=0.016 n=5+4)
Dump/16384-4     444µs ± 3%     361µs ± 7%  -18.73%  (p=0.008 n=5+5)

name          old alloc/op   new alloc/op   delta
Dump/256-4      4.00kB ± 0%    1.39kB ± 0%  -65.20%  (p=0.008 n=5+5)
Dump/1024-4     16.2kB ± 0%     5.5kB ± 0%  -66.04%  (p=0.008 n=5+5)
Dump/4096-4     63.9kB ± 0%    20.6kB ± 0%  -67.78%  (p=0.008 n=5+5)
Dump/16384-4     265kB ± 0%      82kB ± 0%  -69.00%  (p=0.008 n=5+5)

name          old allocs/op  new allocs/op  delta
Dump/256-4        7.00 ± 0%      3.00 ± 0%  -57.14%  (p=0.008 n=5+5)
Dump/1024-4       9.00 ± 0%      3.00 ± 0%  -66.67%  (p=0.008 n=5+5)
Dump/4096-4       11.0 ± 0%       3.0 ± 0%  -72.73%  (p=0.008 n=5+5)
Dump/16384-4      13.0 ± 0%       3.0 ± 0%  -76.92%  (p=0.008 n=5+5)

Change-Id: I0a0d6de315b979142b05e333880da8a5e52b12ef
Reviewed-on: https://go-review.googlesource.com/116495
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 02:10:52 +00:00
Alan Braithwaite
00379be17e net/http: fix cookie SameSite docs grammar
Change-Id: I76d878343c1cc14b53c700b0476ca050c1f9e6be
GitHub-Last-Rev: 148a45f4b6
GitHub-Pull-Request: golang/go#27107
Reviewed-on: https://go-review.googlesource.com/130235
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 02:08:43 +00:00
Tim Cooper
77c575d2e2 net/http: remove unnecessary return
Change-Id: I93bc5de6bcb23c2639d7c2f3f5252fb6f09ca6e4
Reviewed-on: https://go-review.googlesource.com/126797
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 01:59:04 +00:00
Iskander Sharipov
89d533e368 archive/tar: remore redundant parens in type expressions
Simplify `(T)` expressions to  `T` where possible.

Found using https://go-critic.github.io/overview.html#typeUnparen-ref

Change-Id: Ic5ef335e03898f9fea1ff90fd83956376657fe67
Reviewed-on: https://go-review.googlesource.com/123379
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2018-08-21 01:47:17 +00:00
Daniel Martí
692307aa83 cmd/go: fix modload infinite directory loop
It is possible to enter the parent-walking directory loop in a way that
it will loop forever - if mdir is empty, and d reaches ".". To avoid
this, make sure that the 'd = filepath.Dir(d)' step only happens if the
parent directory is actually different than the current directory.

This fixes some of the tests like TestImport/golang.org_x_net_context,
which were never finishing before.

While at it, also fix TestImport/golang.org_x_net, which seems to have
the wrong expected error. The root of the x/net repo doesn't have a
go.mod file, nor is part of a module itself, so it seems like the
expected error should reflect that.

After these two changes, 'go test cmd/go/internal/modload' passes on my
linux/amd64 machine.

Fixes #27080.

Change-Id: Ie8bab0f9fbc9f447844cbbc64117420d9087db1b
Reviewed-on: https://go-review.googlesource.com/129778
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-21 01:44:48 +00:00
Jeet Parekh
539ff607a7 archive/zip: return error from NewReader when negative size is passed
Fixes #26589

Change-Id: I180883a13cec229093654004b42c48d76ee20272
GitHub-Last-Rev: 2d9879de43
GitHub-Pull-Request: golang/go#26667
Reviewed-on: https://go-review.googlesource.com/126617
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-21 00:34:36 +00:00
Santhosh Kumar Tekuri
0b30cf534a archive/zip: makes receiver name consistent
Change-Id: I4d6f7440747d4f935acddc9a5c5928ed911a2fb0
Reviewed-on: https://go-review.googlesource.com/120515
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-08-20 23:12:45 +00:00
Brad Fitzpatrick
85a0192b59 net/http: add Client.CloseIdleConnections
Fixes #26563

Change-Id: I22b0c72d45fab9d3f31fda04da76a8c0b10cd8b6
Reviewed-on: https://go-review.googlesource.com/130115
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-08-20 23:12:01 +00:00