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

23557 Commits

Author SHA1 Message Date
Ian Lance Taylor
0b5f2f0d11 net/http: if context is canceled, return its error
This permits the error message to distinguish between a context that was
canceled and a context that timed out.

Updates #16381.

Change-Id: I3994b98e32952abcd7ddb5fee08fa1535999be6d
Reviewed-on: https://go-review.googlesource.com/24978
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-23 05:31:45 +00:00
Josh Bleecher Snyder
643b9ec07c cmd/compile: tidy up switch case expansion
No functional changes.

Change-Id: I0961227e8a7be2d7c611452896843b6955303fa6
Reviewed-on: https://go-review.googlesource.com/26768
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-23 05:29:10 +00:00
Josh Bleecher Snyder
a9266eef93 cmd/compile: simplify constant switch case sorting
This sort is now only reachable for constant clauses
for a non-interface switch expression value.

Refactor a bit so that the few tests that remain
are concise and easy to read.

Add a test that string length takes priority
over built-in string order.

Change-Id: Iedaa11ff77049d5ad1bf14f54cbb8c3411d589a7
Reviewed-on: https://go-review.googlesource.com/26767
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-23 05:28:50 +00:00
Josh Bleecher Snyder
e26499153e cmd/compile: use a map to track const switch cases
This is simpler than the sorting technique.
It also allows us to simplify or eliminate
some of the sorting decisions.

Most important, sorting will not work when case clauses
represent ranges of integers: There is no correct
sort order that allows overlap detection by comparing
neighbors. Using a map allows of a cheap, simple
approach to ranges, namely to insert every int
in the map. The equivalent approach for sorting
means juggling temporary Nodes for every int,
which is a lot more expensive.

Change-Id: I84df3cb805992a1b04d14e0e4b2334f943e0ce05
Reviewed-on: https://go-review.googlesource.com/26766
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-23 05:28:33 +00:00
Josh Bleecher Snyder
b7ac426ee3 cmd/compile: split genCaseClauses by switch type
The implementations are going to start diverging more.
Instead of more if clauses and empty parameters,
specialize.

Change-Id: I44584450592e8c9f72a10d8ada859c07e9d9aa19
Reviewed-on: https://go-review.googlesource.com/26764
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-23 05:27:27 +00:00
Josh Bleecher Snyder
b046786528 cmd/compile: eliminate switch case kinds
We used to have separate kinds for the default
case and the nil type case. Now that those are
gone, we can use a simple bool instead.

Change-Id: I65488e945df68178e893cddd2e091ebb6e32ef4d
Reviewed-on: https://go-review.googlesource.com/26763
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-23 05:26:57 +00:00
Josh Bleecher Snyder
4739dcf7fb cmd/compile: fix printing of OCASE nodes
Switch lowering splits each case expression out
into its own OCASE node.

Change-Id: Ifcb72b99975ed36da8540f6e43343e9aa2058572
Reviewed-on: https://go-review.googlesource.com/26769
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-23 05:26:45 +00:00
Josh Bleecher Snyder
bd2838be77 cmd/compile: use a map to detect duplicate type switch cases
This is a bit simpler than playing sorting games,
and it is clearer that it generates errors
in the correct (source) order.

It also allows us to simplify sorting.

It also prevents quadratic error messages for
(pathological) inputs with many duplicate type cases.

While we’re here, refactoring deduping into separate functions.

Negligible compilebench impact.

Fixes #15912.

Change-Id: I6cc19edd38875389a70ccbdbdf0d9b7d5ac5946f
Reviewed-on: https://go-review.googlesource.com/26762
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-23 05:17:05 +00:00
Dhaivat Pandit
cd5ab97986 net/http/httptest: updated example to use Result()
example for httptest.Recorder was inspecting Recoder directly.
Using Result() to convert Recorder into a http.Response yields a much
better user experience.

Closes #16837

Change-Id: Id0e636c12cd6adb1ba11f89953ff2b0f43758cf3
Reviewed-on: https://go-review.googlesource.com/27495
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-23 05:12:10 +00:00
Ian Lance Taylor
93b753f525 cmd/link: fix handling of cgo_dynamic_interpreter
CL 27473 accidentally changed `!Debug['I']` to `*flagInterpreter != ""`.
Since the old `Debug['I']` was set when the new *flagInterpreter was
set, this inverted the sense of the condition. The effect was to always
ignore the cgo_dynamic_interpreter setting from runtime/cgo. This worked
OK when the default interpreter was the correct one, but failed when it
was not, as is currently the case on, at least, PPC64 and ARM.

This CL restores the old behavior by using a separate variable to track
whether the -I flag was used, just as we used to.

Change-Id: Icf9b65fa41349ed2e4de477fec0a557ef1eb8189
Reviewed-on: https://go-review.googlesource.com/27562
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-23 05:08:46 +00:00
Michael Matloob
550caa1c87 cmd/link/internal/mips64: fix use of -s flags
My flags change reversed the meaning of -s within mips64's
linker code. This should fix that.

Change-Id: Ia24002469e557fb29badfd830134e61c1dd7e16e
Reviewed-on: https://go-review.googlesource.com/27555
Reviewed-by: Minux Ma <minux@golang.org>
2016-08-22 22:59:20 +00:00
Robert Griesemer
c043e90e55 cmd/compile: clean up encoding of export version info
Replace ad-hoc encoding of export version info with a
more systematic approach.

Continue to read (but not write) the Go1.7 format for backward-
compatibility. This will avoid spurious errors with old installed
packages.

Fixes #16244.

Change-Id: I945e79ffd5e22b883250f6f9fac218370c2505a2
Reviewed-on: https://go-review.googlesource.com/27452
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-22 22:28:52 +00:00
Brad Fitzpatrick
e8ba80fbf6 io: fix comment in test
Updates #16795

Change-Id: I0bcc34bb5a92a2c480aebfb0eb6ba57bcc7f7cfd
Reviewed-on: https://go-review.googlesource.com/27551
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-22 22:27:59 +00:00
Lynn Boger
a1dc9465a1 cmd/compile: PPC64.rules for load/store address folding
This adds some additional rules to improve loads and
stores for ppc64x.

Change-Id: I96b99c3a0019e6ac5393910c086f58330a04fc5a
Reviewed-on: https://go-review.googlesource.com/27354
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-08-22 20:04:03 +00:00
Josh Bleecher Snyder
726190daf3 cmd/compile: explicitly manage default and nil switch cases
Rather than juggle default and nil cases as part
of a slice, handle them explicitly.

Change-Id: I97b200c9d3f23fe1a438acdbf3d13b0cf7e0851e
Reviewed-on: https://go-review.googlesource.com/26761
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-22 19:56:21 +00:00
Josh Bleecher Snyder
cf20525bf4 cmd/compile: set correct line number for multiple defaults in switch error
Fixes #15911.

Change-Id: I500533484de61aa09abe4cecb010445e3176324e
Reviewed-on: https://go-review.googlesource.com/26760
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-22 19:56:06 +00:00
Josh Bleecher Snyder
4109744973 syscall: delete unreachable code
Change-Id: Iacedb792c73591b7fd75e836aab8e0e117c8e738
Reviewed-on: https://go-review.googlesource.com/27494
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-22 19:50:49 +00:00
Josh Bleecher Snyder
e2103adb6c crypto/*, runtime: nacl asm fixes
Found by vet.

Updates #11041

Change-Id: I5217b3e20c6af435d7500d6bb487b9895efe6605
Reviewed-on: https://go-review.googlesource.com/27493
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-22 19:50:41 +00:00
Josh Bleecher Snyder
5abfc97e84 runtime: use correct MOV for plan9 brk_ ret value
Updates #11041

Change-Id: I78f8d48f00cfbb451e37c868cc472ef06ea0fd95
Reviewed-on: https://go-review.googlesource.com/27491
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-22 19:49:08 +00:00
Josh Bleecher Snyder
e80376ca6b runtime: ignore closeonexec ret val on openbsd/arm
Fixes #16641
Updates #11041

Change-Id: I087208a486f535d74135591b2c9a73168cf80e1a
Reviewed-on: https://go-review.googlesource.com/27490
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-22 19:40:09 +00:00
Brad Fitzpatrick
355d7fa8a8 net/http: make Transport.CancelRequest doc recommend Request.WithContext
The old deprecation docs were referencing another deprecated field.

Fixes #16752

Change-Id: I44a690048e00ddc790a80214ecb7f5bb0a5b7b34
Reviewed-on: https://go-review.googlesource.com/27510
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-22 19:03:57 +00:00
Billy Lynch
4187e1f49f net/http/httptrace: add simple example and fix copyright header
Partially addresses #16360

Change-Id: I67a328302d7d91231f348d934e4232fcb844830a
Reviewed-on: https://go-review.googlesource.com/27398
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-22 18:57:04 +00:00
Eric Lagergren
2c58cb36f9 encoding/xml: do not ignore error return from copyValue
The error return from copyValue was ignored causing some XML attribute
parsing to swallow an error.

Additionally, type MyMarshalerAttrTest had no UnmarshalXMLAttr method
causing marshalTests not to be symmetrical and the test suite to fail
for test case 101.

Fixes #16158

Change-Id: Icebc505295a2c656ca4b42ba37bb0957dd7260c6
Reviewed-on: https://go-review.googlesource.com/27455
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-22 18:01:47 +00:00
Dmitry Vyukov
747a158ef3 runtime: speed up StartTrace with lots of blocked goroutines
In StartTrace we emit EvGoCreate for all existing goroutines.
This includes stack unwind to obtain current stack.
Real Go programs can contain hundreds of thousands of blocked goroutines.
For such programs StartTrace can take up to a second (few ms per goroutine).

Obtain current stack ID once and use it for all EvGoCreate events.

This speeds up StartTrace with 10K blocked goroutines from 20ms to 4 ms
(win for StartTrace called from net/http/pprof hander will be bigger
as stack is deeper).

Change-Id: I9e5ff9468331a840f8fdcdd56c5018c2cfde61fc
Reviewed-on: https://go-review.googlesource.com/25573
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2016-08-22 17:40:10 +00:00
Josh Bleecher Snyder
7c5f33b173 runtime: cull dead code
They are unused, and vet wants them to have
a function prototype.

Updates #11041

Change-Id: Idedc96ddd3c3cf1b1d2ab6d98796367eab29f032
Reviewed-on: https://go-review.googlesource.com/27492
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-22 16:41:34 +00:00
Cherry Zhang
310a40b4f2 cmd/compile: start MIPS64 port of SSA backend
Fib with all int and float types run correctly.
*, /, shifts, Zero, Move not implemented yet. No optimization yet.

Updates #16359.

Change-Id: I4b0412954d5fd4c13a5fcddd8689ed8ac701d345
Reviewed-on: https://go-review.googlesource.com/27404
Reviewed-by: David Chase <drchase@google.com>
2016-08-22 16:30:38 +00:00
Josh Bleecher Snyder
e4cae432d6 cmd/compile: add inline explainer
When compiling with -m -m, this adds output
for every non-inlined function explaining why
it was not inlined.

Change-Id: Icb59ae912a835c996e6b3475b163ee5125113001
Reviewed-on: https://go-review.googlesource.com/22782
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-22 16:16:35 +00:00
Josh Bleecher Snyder
ef6fde26e5 cmd/vet: handle multiple arches in asm build directives
If a build directive contains multiple arches,
try to match the build context.

Updates #11041

Change-Id: I03b5d7bfb29d1ff6c7d36a9d7c7fabfcc1d871c1
Reviewed-on: https://go-review.googlesource.com/27158
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:43:16 +00:00
Josh Bleecher Snyder
863ca99415 cmd/vet: fix mips64le arch name in asmdecl check
Updates #11041

Change-Id: Ic6df8ef25b7cf280db523950cd3640b060ad1a9b
Reviewed-on: https://go-review.googlesource.com/27157
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:42:59 +00:00
Josh Bleecher Snyder
f410a668ee cmd/vet: improve error message for cross-package assembly
bytes.Compare has its go prototype in package bytes,
but its implementation in package runtime.
vet used to complain that the prototype was missing.
Now instead:

runtime/asm_amd64.s:1483: [amd64] cannot check cross-package assembly function: Compare is in package bytes

Updates #11041

Change-Id: Ied44fac10d0916d7a34e552c02d052e16fca0c8c
Reviewed-on: https://go-review.googlesource.com/27153
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:42:45 +00:00
Josh Bleecher Snyder
0952a15cd1 cmd/vet: clean up printing errors with no position
Before:

: runtime/asm_amd64.s:345: [amd64] morestack: use of 8(SP) points beyond argument frame

After:

runtime/asm_amd64.s:345: [amd64] morestack: use of 8(SP) points beyond argument frame

Updates #11041

Change-Id: Ic87a6d1a2a7b2a8bf737407bc981b159825c84f2
Reviewed-on: https://go-review.googlesource.com/27152
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:42:30 +00:00
Josh Bleecher Snyder
4af1148079 cmd/vet: improve asmdecl parameter handling
The asmdecl check had hand-rolled code that
calculated the size and offset of parameters
based only on the AST.
It included a list of known named types.

This CL changes asmdecl to use go/types instead.
This allows us to easily handle named types.
It also adds support for structs, arrays,
and complex parameters.

It improves the default names given to unnamed
parameters. Previously, all anonymous arguments were
called "unnamed", and the first anonymous return
argument was called "ret".
Anonymous arguments are now called arg, arg1, arg2,
etc., depending on the index in the argument list.
Return arguments are ret, ret1, ret2.

This CL also fixes a bug in the printing of
composite data type sizes.

Updates #11041

Change-Id: I1085116a26fe6199480b680eff659eb9ab31769b
Reviewed-on: https://go-review.googlesource.com/27150
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-22 15:42:06 +00:00
Josh Bleecher Snyder
880c967ccd runtime: minor string/rune optimizations
Eliminate a spill in concatstrings.
Provide bounds elim hints in runetochar.
No significant benchmark movement.

Before:
"".runetochar t=1 size=412 args=0x28 locals=0x0
"".concatstrings t=1 size=736 args=0x30 locals=0x98

After:
"".runetochar t=1 size=337 args=0x28 locals=0x0
"".concatstrings t=1 size=711 args=0x30 locals=0x90

Change-Id: Icce646976cb20a223163b7e72a54761193ac17e3
Reviewed-on: https://go-review.googlesource.com/27460
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-22 15:19:31 +00:00
Michael Matloob
fa8a28d559 cmd/link: turn some globals into flag pointer variables
This moves many of the flag globals into main and assigns them
to their flag.String/Int64/... directly.

Updates #16818

Change-Id: Ibbff44a273bbc5cb7228e43f147900ee8848517f
Reviewed-on: https://go-review.googlesource.com/27473
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-22 14:09:05 +00:00
Brad Fitzpatrick
236901384d net/http: fix unwanted HTTP/2 conn Transport crash after IdleConnTimeout
Go 1.7 crashed after Transport.IdleConnTimeout if an HTTP/2 connection
was established but but its caller no longer wanted it. (Assuming the
connection cache was enabled, which it is by default)

Fixes #16208

Change-Id: I9628757f7669e344f416927c77f00ed3864839e3
Reviewed-on: https://go-review.googlesource.com/27450
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-22 02:03:29 +00:00
Michael Hudson-Doyle
82c1e22e13 cmd/link: make listsort less generic
It's always called with the same arguments now.

Maybe the real fix is to make Symbol.Sub a slice but that requires a bit more
brain.

Change-Id: I1326d34a0a327554be6d54f9bd402ea328224766
Reviewed-on: https://go-review.googlesource.com/27416
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-08-22 01:55:12 +00:00
Brad Fitzpatrick
ec8d49c139 net/http: update bundled http2 for Transport double STREAM_ENDED error
Updates bundled http2 to x/net/http2 git rev 7394c11 for:

http2: fix protocol violation regression when writing certain request bodies
https://golang.org/cl/27406

Fixes #16788

Change-Id: I0efcd36e2b4b34a1df79f763d35bf7a3a1858506
Reviewed-on: https://go-review.googlesource.com/27451
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-08-22 00:55:53 +00:00
Josh Bleecher Snyder
a3765723c6 cmd/compile: remove inl escape analysis hack
Relevant issues: #5056, #9537, and #11053.
Their tests all pass.

Change-Id: Ibbe05982ed5f332149ffd2cb6a232b8d677c4454
Reviewed-on: https://go-review.googlesource.com/27464
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 23:19:23 +00:00
Josh Bleecher Snyder
3c55ee6420 cmd/compile: refactor out method-called-as-function check
Change-Id: I417aae8622d7d363863704594680bd2502a09049
Reviewed-on: https://go-review.googlesource.com/27463
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 23:19:16 +00:00
Josh Bleecher Snyder
376d9665a8 cmd/compile: don’t consider recursive calls for inlining
We will never inline recursive calls.
Rather than simulate the recursion until we hit
the complexity ceiling, just bail early.

Also, remove a pointless n.Op check.
visitBottomUp guarantees that n will be an
ODCLFUNC, and caninl double-checks it.

Change-Id: Ifa48331686b24289d34e68cf5bef385f464b6b92
Reviewed-on: https://go-review.googlesource.com/27462
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 23:18:50 +00:00
Josh Bleecher Snyder
d1faf3879e cmd/compile: don’t generate pointless gotos during inlining
Their only purpose in life was to suppress an error.
Suppress that error explicitly instead by reusing
an existing, aptly named Node field.

This generates fewer blocks during ssa construction.

name       old alloc/op     new alloc/op     delta
Template       47.5MB ± 0%      47.2MB ± 0%  -0.72%        (p=0.000 n=15+15)
Unicode        36.8MB ± 0%      36.8MB ± 0%    ~           (p=0.775 n=15+15)
GoTypes         143MB ± 0%       142MB ± 0%  -1.03%        (p=0.000 n=15+14)
Compiler        686MB ± 0%       674MB ± 0%  -1.75%        (p=0.000 n=15+15)

name       old allocs/op    new allocs/op    delta
Template         446k ± 0%        445k ± 0%  -0.20%        (p=0.000 n=15+15)
Unicode          355k ± 0%        355k ± 0%    ~           (p=0.235 n=13+15)
GoTypes         1.36M ± 0%       1.36M ± 0%  -0.41%        (p=0.000 n=13+15)
Compiler        5.77M ± 0%       5.70M ± 0%  -1.16%        (p=0.000 n=15+15)


Change-Id: I5f14afb833c9d355688d9a229eb820e95c7657bf
Reviewed-on: https://go-review.googlesource.com/27461
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 23:18:33 +00:00
Michael Matloob
16e3ce2785 cmd/link/internal/ld: rename pobj.go to main.go
The only thing pobj contains is the Ldmain function.

Updates #16818

Change-Id: Id114bdb264cb5ea2f372eb2166201f1f8eb99445
Reviewed-on: https://go-review.googlesource.com/27472
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-21 23:00:44 +00:00
Michael Matloob
0a15d95091 cmd/link: use standard library flag package where possible
The obj library's flag functions are (mostly) light wrappers
around the standard library flag package. Use the flag package
directly where possible.

Most uses of the 'count'-type flags (except for -v) only check
against 0, so they can safely be replaced by bools. Only -v
and the flagfns haven't been replaced.

Debug has been turned into a slice of bools rather than ints.
There was a copy of the -v verbosity in ctxt.Debugvlog, so don't use
Debug['v'] and just use ctxt.Debugvlog.

Updates #16818

Change-Id: Icf6473a4823c9d35513bbd0c34ea02d5676d782a
Reviewed-on: https://go-review.googlesource.com/27471
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-21 23:00:27 +00:00
Josh Bleecher Snyder
65c5d62420 cmd/vet: re-quote struct tags when printing errors
cmd/link/link_test.go contains several multi-line
struct tags. Going through an unquote/quote cycle
converts `a
b
c` to "a\nb\nc\n".

This keeps all vet error messages for the standard
library on a single line.

Updates #11041

Change-Id: Ifba1e87297a5174294d1fbf73463fd3db357464f
Reviewed-on: https://go-review.googlesource.com/27129
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-21 22:47:03 +00:00
Josh Bleecher Snyder
6ad76718cf cmd/vet: don't treat trailing % as possible formatting directive
Eliminates the following false positive:

cmd/go/go_test.go:1916: possible formatting directive in Error call

The line in question:

tg.t.Error("some coverage results are 0.0%")

Updates #11041

Change-Id: I3b7611fa3e0245714a19bd5388f21e39944f5296
Reviewed-on: https://go-review.googlesource.com/27128
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-21 22:45:38 +00:00
Michael Hudson-Doyle
8e90b9026b cmd/link: remove references to LSym (now Symbol)
Mostly comments but some derived names too.

Change-Id: I1e01dccca98de6688e1426c7a9309f6fd6a1e368
Reviewed-on: https://go-review.googlesource.com/27415
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 22:43:20 +00:00
Michael Hudson-Doyle
85072d5f75 cmd/link: remove Symbol.Next
Bye bye one more class of linked list manipulation!

Change-Id: I2412b224c847dd640f9253125d30cd5f911ce00c
Reviewed-on: https://go-review.googlesource.com/27414
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2016-08-21 22:17:24 +00:00
Michael Matloob
64f5023e6f cmd/link: remove global Bso variable
Bso is already a member on ld.Link. Use that instead of
the global.

Updates #16818

Change-Id: Icfc0f6cb1ff551e8129253fb6b5e0d6a94479f51
Reviewed-on: https://go-review.googlesource.com/27470
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 18:51:21 +00:00
LE Manh Cuong
1756b66598 os: make ExpandEnv recognize '-' as a special shell parameter
'-' is one of shell special parameters.

The existing implementation of isShellSpecialVar missed '-'
from the list, causing "$-" and "${-}" expand differently.

Fixes #16554

Change-Id: Iafc7984692cc83cff58f7c1e01267bf78b3a20a9
Reviewed-on: https://go-review.googlesource.com/25352
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-21 18:32:57 +00:00
Michael Matloob
4338e5a891 cmd/link/internal: remove global Ctxt variable
This change threads the *ld.Link Ctxt variable through
code in arch-specific packages. This removes all remaining
uses of Ctxt, so remove the global variable too.

This CL continues the work in golang.org/cl/27408

Updates #16818

Change-Id: I5f4536847a1825fd0b944824e8ae4e122ec0fb78
Reviewed-on: https://go-review.googlesource.com/27459
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 18:18:39 +00:00
Salman Aljammaz
e2b30e9000 net/http: prepend ./ to directory list hrefs in FileServer
Certain browsers (Chrome 53, Safari 9.1.2, Firefox 46) won't correctly
follow a directory listing's links if the file name begins with a run
of characters then a colon, e.g. "foo:bar". Probably mistaking it for
a URI. However, they are happy to follow "./foo:bar", so this change
prepends "./" to all link hrefs in the directory listing of
FileServer.

Change-Id: I60ee8e1ebac73cbd3a3ac0f23e80fdf52e3dc352
Reviewed-on: https://go-review.googlesource.com/27440
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 18:14:05 +00:00
Martin Möhrmann
6a393dc64f cmd/compile: fix compilation of math.Sqrt when used as a statement
Fixes #16804

Change-Id: I669c2c24d3135cd35e15a464894ac66945847d0c
Reviewed-on: https://go-review.googlesource.com/27437
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 16:49:48 +00:00
Michael Matloob
2f783c3458 cmd/link/internal: thread *ld.Link through calls
Ctxt is a global defined in cmd/link/internal/ld of type *ld.Link.
Start threading a *ld.Link through function calls instead of
relying on the global variable.

Ctxt is still used as a global by the architecture-specific packages,
but I plan to fix that in a subsequent CL.

Change-Id: I77a3a58bd396fafd959fa1d8b1c83008a9f5a7fb
Reviewed-on: https://go-review.googlesource.com/27408
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-08-21 15:56:43 +00:00
Michael Munday
4b17b152a3 hash/crc32: fix optimized s390x implementation
The code wasn't checking to see if the data was still >= 64 bytes
long after aligning it.

Aligning the data is an optimization and we don't actually need
to do it. In fact for smaller sizes it slows things down due to
the overhead of calling the generic function. Therefore for now
I have simply removed the alignment stage. I have also added a
check into the assembly to deliberately trigger a segmentation
fault if the data is too short.

Fixes #16779.

Change-Id: Ic01636d775efc5ec97689f050991cee04ce8fe73
Reviewed-on: https://go-review.googlesource.com/27409
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-21 02:04:43 +00:00
Konstantin Shaposhnikov
94d9cc7741 index/suffixarray: add Lookup example
Updates #16360

Change-Id: Idd8523b5a9a496ebd9c6e3b89c30df539842a139
Reviewed-on: https://go-review.googlesource.com/27433
Reviewed-by: C Cirello <uldericofilho@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-21 01:10:22 +00:00
Ian Gudger
7995cb86e5 syscall: validate ParseUnixCredentials inputs
Don't panic, crash, or return references to uninitialized memory when
ParseUnixCredentials is passed invalid input.

Fixes #16475

Change-Id: I140d41612e8cd8caaa94be829a415159659c217b
Reviewed-on: https://go-review.googlesource.com/25154
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-20 21:12:07 +00:00
Michael Munday
fa897643a1 runtime: remove unnecessary calls to memclr
Go will have already cleared the structs (the original C wouldn't
have).

Change-Id: I4a5a0cfd73953181affc158d188aae2ce281bb33
Reviewed-on: https://go-review.googlesource.com/27435
Run-TryBot: Michael Munday <munday@ca.ibm.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-20 18:00:09 +00:00
Joe Tsai
8cd04da762 compress/flate: make huffmanBitWriter errors persistent
For persistent error handling, the methods of huffmanBitWriter have to be
consistent about how they check errors. It must either consistently
check error *before* every operation OR immediately *after* every
operation. Since most of the current logic uses the previous approach,
we apply the same style of error checking to writeBits and all calls
to Write such that they only operate if w.err is already nil going
into them.

The error handling approach is brittle and easily broken by future commits to
the code. In the near future, we should switch the logic to use panic at the
lowest levels and a recover at the edge of the public API to ensure
that errors are always persistent.

Fixes #16749

Change-Id: Ie1d83e4ed8842f6911a31e23311cd3cbf38abe8c
Reviewed-on: https://go-review.googlesource.com/27200
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-20 00:36:40 +00:00
Jaana Burcu Dogan
c10f8700e0 net/http/httptrace: test the order of hooks when ctx has multi ClientTraces
Change-Id: I95cae14bb5561947ada9577fb05053f93321a4a8
Reviewed-on: https://go-review.googlesource.com/27400
Run-TryBot: Jaana Burcu Dogan <jbd@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-19 23:40:55 +00:00
Michael Matloob
a072fc2e67 cmd/link/internal: rename LSym to Symbol, and add a doc comment.
I'd also like to document some of its fields, but I don't know
what they are.

Change-Id: I87d341e255f785d351a8a73e645be668e02b2689
Reviewed-on: https://go-review.googlesource.com/27399
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-19 22:10:04 +00:00
Emmanuel Odeke
0a2a64d85d encoding/gob: error out instead of panicking on nil dereference
Do not panic when we encounter nil interface values which are
invalid values for gob. Previously this wasn't caught yet
we were calling reflect.*.Type() on reflect.Invalid values
thereby causing panic:
  `panic: reflect: call of reflect.Value.Type on zero Value.`
which is a panic not enforced by encoding/gob itself.
We can catch this and send back an error to the caller.

Fixes #16204

Change-Id: Ie646796db297759a74a02eee5267713adbe0c3a0
Reviewed-on: https://go-review.googlesource.com/24989
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
2016-08-19 21:54:39 +00:00
Dmitry Vyukov
14e5951166 runtime: increase malloc size classes
When we calculate class sizes, in some cases we discard considerable
amounts of memory without an apparent reason. For example, we choose
size 8448 with 6 objects in 7 pages. But we can well use object
size 9472, which is also 6 objects in 7 pages but +1024 bytes (+12.12%).

Increase class sizes to the max value that leads to the same
page count/number of objects. Full list of affected size classes:

class 36: pages: 2 size: 1664->1792 +128 (7.69%)
class 39: pages: 1 size: 2560->2688 +128 (5.0%)
class 40: pages: 3 size: 2816->3072 +256 (9.9%)
class 41: pages: 2 size: 3072->3200 +128 (4.16%)
class 42: pages: 3 size: 3328->3456 +128 (3.84%)
class 44: pages: 3 size: 4608->4864 +256 (5.55%)
class 47: pages: 4 size: 6400->6528 +128 (2.0%)
class 48: pages: 5 size: 6656->6784 +128 (1.92%)
class 51: pages: 7 size: 8448->9472 +1024 (12.12%)
class 52: pages: 6 size: 8704->9728 +1024 (11.76%)
class 53: pages: 5 size: 9472->10240 +768 (8.10%)
class 54: pages: 4 size: 10496->10880 +384 (3.65%)
class 57: pages: 7 size: 14080->14336 +256 (1.81%)
class 59: pages: 9 size: 16640->18432 +1792 (10.76%)
class 60: pages: 7 size: 17664->19072 +1408 (7.97%)
class 62: pages: 8 size: 21248->21760 +512 (2.40%)
class 64: pages: 10 size: 24832->27264 +2432 (9.79%)
class 65: pages: 7 size: 28416->28672 +256 (0.90%)

name                      old time/op    new time/op    delta
BinaryTree17-12              2.59s ± 5%     2.52s ± 4%    ~     (p=0.132 n=6+6)
Fannkuch11-12                2.13s ± 3%     2.17s ± 3%    ~     (p=0.180 n=6+6)
FmtFprintfEmpty-12          47.0ns ± 3%    46.6ns ± 1%    ~     (p=0.355 n=6+5)
FmtFprintfString-12          131ns ± 0%     131ns ± 1%    ~     (p=0.476 n=4+6)
FmtFprintfInt-12             121ns ± 6%     122ns ± 2%    ~     (p=0.511 n=6+6)
FmtFprintfIntInt-12          182ns ± 2%     186ns ± 1%  +2.20%  (p=0.015 n=6+6)
FmtFprintfPrefixedInt-12     184ns ± 5%     181ns ± 2%    ~     (p=0.645 n=6+6)
FmtFprintfFloat-12           272ns ± 7%     265ns ± 1%    ~     (p=1.000 n=6+5)
FmtManyArgs-12               783ns ± 2%     802ns ± 2%  +2.38%  (p=0.017 n=6+6)
GobDecode-12                7.04ms ± 4%    7.00ms ± 2%    ~     (p=1.000 n=6+6)
GobEncode-12                6.36ms ± 6%    6.17ms ± 6%    ~     (p=0.240 n=6+6)
Gzip-12                      242ms ±14%     233ms ± 7%    ~     (p=0.310 n=6+6)
Gunzip-12                   36.6ms ±22%    36.0ms ± 9%    ~     (p=0.841 n=5+5)
HTTPClientServer-12         93.1µs ±29%    88.0µs ±32%    ~     (p=0.240 n=6+6)
JSONEncode-12               27.1ms ±39%    26.2ms ±35%    ~     (p=0.589 n=6+6)
JSONDecode-12               71.7ms ±36%    71.5ms ±36%    ~     (p=0.937 n=6+6)
Mandelbrot200-12            4.78ms ±10%    4.70ms ±16%    ~     (p=0.394 n=6+6)
GoParse-12                  4.86ms ±34%    4.95ms ±36%    ~     (p=1.000 n=6+6)
RegexpMatchEasy0_32-12       110ns ±37%     110ns ±36%    ~     (p=0.660 n=6+6)
RegexpMatchEasy0_1K-12       240ns ±38%     234ns ±47%    ~     (p=0.554 n=6+6)
RegexpMatchEasy1_32-12      77.2ns ± 2%    77.2ns ±10%    ~     (p=0.699 n=6+6)
RegexpMatchEasy1_1K-12       337ns ± 5%     331ns ± 4%    ~     (p=0.552 n=6+6)
RegexpMatchMedium_32-12      125ns ±13%     132ns ±26%    ~     (p=0.561 n=6+6)
RegexpMatchMedium_1K-12     35.9µs ± 3%    36.1µs ± 5%    ~     (p=0.818 n=6+6)
RegexpMatchHard_32-12       1.81µs ± 4%    1.82µs ± 5%    ~     (p=0.452 n=5+5)
RegexpMatchHard_1K-12       52.4µs ± 2%    54.4µs ± 3%  +3.84%  (p=0.002 n=6+6)
Revcomp-12                   401ms ± 2%     390ms ± 1%  -2.82%  (p=0.002 n=6+6)
Template-12                 54.5ms ± 3%    54.6ms ± 1%    ~     (p=0.589 n=6+6)
TimeParse-12                 294ns ± 1%     298ns ± 2%    ~     (p=0.160 n=6+6)
TimeFormat-12                323ns ± 4%     318ns ± 5%    ~     (p=0.297 n=6+6)

name                      old speed      new speed      delta
GobDecode-12               109MB/s ± 4%   110MB/s ± 2%    ~     (p=1.000 n=6+6)
GobEncode-12               121MB/s ± 6%   125MB/s ± 6%    ~     (p=0.240 n=6+6)
Gzip-12                   80.4MB/s ±12%  83.3MB/s ± 7%    ~     (p=0.310 n=6+6)
Gunzip-12                  495MB/s ±41%   541MB/s ± 9%    ~     (p=0.931 n=6+5)
JSONEncode-12             80.7MB/s ±39%  82.8MB/s ±34%    ~     (p=0.589 n=6+6)
JSONDecode-12             30.4MB/s ±40%  31.0MB/s ±37%    ~     (p=0.937 n=6+6)
GoParse-12                13.2MB/s ±33%  13.2MB/s ±35%    ~     (p=1.000 n=6+6)
RegexpMatchEasy0_32-12     321MB/s ±34%   326MB/s ±34%    ~     (p=0.699 n=6+6)
RegexpMatchEasy0_1K-12    4.49GB/s ±31%  4.74GB/s ±37%    ~     (p=0.589 n=6+6)
RegexpMatchEasy1_32-12     414MB/s ± 2%   415MB/s ± 9%    ~     (p=0.699 n=6+6)
RegexpMatchEasy1_1K-12    3.03GB/s ± 5%  3.09GB/s ± 4%    ~     (p=0.699 n=6+6)
RegexpMatchMedium_32-12   7.99MB/s ±12%  7.68MB/s ±22%    ~     (p=0.589 n=6+6)
RegexpMatchMedium_1K-12   28.5MB/s ± 3%  28.4MB/s ± 5%    ~     (p=0.818 n=6+6)
RegexpMatchHard_32-12     17.7MB/s ± 4%  17.0MB/s ±15%    ~     (p=0.351 n=5+6)
RegexpMatchHard_1K-12     19.6MB/s ± 2%  18.8MB/s ± 3%  -3.67%  (p=0.002 n=6+6)
Revcomp-12                 634MB/s ± 2%   653MB/s ± 1%  +2.89%  (p=0.002 n=6+6)
Template-12               35.6MB/s ± 3%  35.5MB/s ± 1%    ~     (p=0.615 n=6+6)

Change-Id: I465a47f74227f316e3abea231444f48c7a30ef85
Reviewed-on: https://go-review.googlesource.com/24493
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2016-08-19 21:24:28 +00:00
Jaana Burcu Dogan
ab9137dd24 context: test WithCancel with canceled parent
Change-Id: I32079cc12cfffb8520f0073a8b5119705dc0cd1b
Reviewed-on: https://go-review.googlesource.com/27401
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-19 20:25:12 +00:00
Austin Clements
3de7dbb191 runtime: fix check for vacuous page boundary rounding again
The previous fix for this, commit 336dad2a, had everything right in
the commit message, but reversed the test in the code. Fix the test in
the code.

This reversal effectively disabled the scavenger on large page systems
*except* in the rare cases where this code was originally wrong, which
is why it didn't obviously show up in testing.

Fixes #16644. Again. :(

Change-Id: I27cce4aea13de217197db4b628f17860f27ce83e
Reviewed-on: https://go-review.googlesource.com/27402
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-19 20:16:43 +00:00
Dmitry Vyukov
a50f9859bd internal/trace: fix analysis of EvGoWaiting/EvGoInSyscall events
When tracing is started in the middle of program execution,
we already have a number of runnable goroutines and a number
of blocked/in syscall goroutines. In order to reflect these
goroutines in the trace, we emit EvGoCreate for all existing
goroutines. Then for blocked/in syscall goroutines we additionally
emit EvGoWaiting/EvGoInSyscall events. These events don't reset g.ev
during trace analysis. So next EvGoStart finds g.ev set to the
previous EvGoCreate. As the result time between EvGoCreate and
EvGoStart is accounted as scheduler latency. While in reality
it is blocking/syscall time.

Properly reset g.ev for EvGoWaiting/EvGoInSyscall events.

Change-Id: I0615ba31ed7567600a0667ebb27458481da73adb
Reviewed-on: https://go-review.googlesource.com/25572
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2016-08-19 19:22:17 +00:00
Brad Fitzpatrick
93372673ce io: fix infinite loop bug in MultiReader
If an io.Reader returned (non-zero, EOF), MultiReader would yield
bytes forever.

This bug has existed before Go 1 (!!), introduced in the original
MultiReader implementation in https://golang.org/cl/1764043 and also
survived basically the only update to this code since then
(https://golang.org/cl/17873, git rev ccdca832c), which was added in
Go 1.7.

This just bit me when writing a test for some unrelated code.

Fixes #16795

Change-Id: I36e6a701269793935d19a47ac12f67b07179fbff
Reviewed-on: https://go-review.googlesource.com/27397
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2016-08-19 19:14:02 +00:00
Austin Clements
244efebe7f runtime: fix out of date comments
The transition from mark 1 to mark 2 no longer enqueues new root
marking jobs, but some of the comments still refer to this. Fix these
comments.

Change-Id: I3f98628dba32c5afe30495ab495da42b32291e9e
Reviewed-on: https://go-review.googlesource.com/24965
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-08-19 18:15:54 +00:00
Adam Langley
8ad70a5493 crypto/x509: allow a leaf certificate to be specified directly as root.
In other systems, putting a leaf certificate in the root store works to
express that exactly that certificate is acceptable. This change makes
that work in Go too.

Fixes #16763.

Change-Id: I5c0a8dbc47aa631b23dd49061fb217ed8b0c719c
Reviewed-on: https://go-review.googlesource.com/27393
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-19 16:56:23 +00:00
Adam Langley
bcd54f6ca5 crypto/x509: recognise ISO OID for RSA+SHA1
For some reason, ISO decided to duplicate the OID for RSA+SHA1. Most
pertinantly, the makecert.exe utility on Windows is known to have used
this OID.

This change makes the ISO OID an alias for the normal one.

Change-Id: I60b76265bf1721282bdb0d5c99c98d227c18a878
Reviewed-on: https://go-review.googlesource.com/27394
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-19 16:29:58 +00:00
Adam Langley
0da545d128 encoding/pem: be stricter about the ending line.
Previously the code didn't check the type and final five dashes of the
ending line of a PEM block.

Fixes #16335.

Change-Id: Ia544e8739ea738d767cfe56c8d46204214ec0b5a
Reviewed-on: https://go-review.googlesource.com/27391
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-19 16:29:44 +00:00
Brad Fitzpatrick
a25a7ad703 cmd/internal/obj: update Bool2int to the form optimized by the compiler
As of https://golang.org/cl/22711 the compiler optimizes this form.

Updates #6011

Change-Id: Ibc6c529dfa24d42f4aab78ebd6722e1d72cb6038
Reviewed-on: https://go-review.googlesource.com/27395
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-19 03:33:36 +00:00
Matthew Dempsky
70544c91ff cmd/compile/internal/syntax: match old parser errors and line numbers
This makes a bunch of changes to package syntax to tweak line numbers
for AST nodes. For example, short variable declaration statements are
now associated with the location of the ":=" token, and function calls
are associated with the location of the final ")" token. These help
satisfy many unit tests that assume the old parser's behavior.

Because many of these changes are questionable, they're guarded behind
a new "gcCompat" const to make them easy to identify and revisit in
the future.

A handful of remaining tests are too difficult to make behave
identically. These have been updated to execute with -newparser=0 and
comments explaining why they need to be fixed.

all.bash now passes with both the old and new parsers.

Change-Id: Iab834b71ca8698d39269f261eb5c92a0d55a3bf4
Reviewed-on: https://go-review.googlesource.com/27199
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-19 01:10:21 +00:00
Matthew Dempsky
2ff463948c cmd/compile/internal/gc: use new AST parser
Introduce a new noder type to transform package syntax's AST into gc's
Node tree. Hidden behind a new -newparser flag.

Change-Id: Id0e862ef6196c41533876afc4ec289e21d422d18
Reviewed-on: https://go-review.googlesource.com/27198
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-19 01:10:12 +00:00
Matthew Dempsky
117793624b cmd/compile/internal/syntax: expose additional information for gc
gc needs access to line offsets for Nodes. It also needs access to the
end line offset for function bodies so it knows what line number to
use for things like implicit returns and defer executions.

Lastly, include an extra bool to distinguish between simple and full
slice expressions. This is redundant in valid parse trees, but needed
by gc for producing complete warnings in invalid inputs.

Change-Id: I64baf334a35c72336d26fa6755c67eb9d6f4e93c
Reviewed-on: https://go-review.googlesource.com/27196
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-19 01:09:52 +00:00
Brad Fitzpatrick
4e8c113793 log/syslog: document that Dial uses net.Dial parameters, add example
Fixes #16761

Change-Id: I709daa87926a31e5f8fd46a4c5ef69718ae349b1
Reviewed-on: https://go-review.googlesource.com/27209
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2016-08-19 01:01:47 +00:00
Brad Fitzpatrick
55ea153b78 os: reference LookupEnv from the Getenv docs
Fixes #16782

Change-Id: If54917bf5ca1588d8a6d443c3aa6e1d4ada6b620
Reviewed-on: https://go-review.googlesource.com/27322
Reviewed-by: anatoly techtonik <techtonik@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-19 00:30:37 +00:00
Josh Bleecher Snyder
794442375d cmd/vet: allow large shifts of constants
Large shifts of constants are frequently
used for fancy 32/64 bit detection.

This removes 14 false positives from the
standard library.

Updates #11041

Change-Id: Ib39346e5c161da04c38a6a3067932ef43bf74f2d
Reviewed-on: https://go-review.googlesource.com/27155
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-18 23:39:37 +00:00
Adam Langley
4e79c152b1 crypto/tls: don't generate random ticket keys if already set.
If SetSessionTicketKeys was called on a fresh tls.Config, the configured
keys would be overridden with a random key by serverInit.

Fixes #15421.

Change-Id: I5d6cc81fc3e5de4dfa15eb614d102fb886150d1b
Reviewed-on: https://go-review.googlesource.com/27317
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-18 22:48:53 +00:00
Robert Griesemer
89d085de9f go/types: better doc string for Object.Parent and test
Fixes #14647.

Change-Id: Ib9012a9141e815f5b95f8ca2307e65ffc4587a5b
Reviewed-on: https://go-review.googlesource.com/27370
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-18 22:47:45 +00:00
Adam Langley
da2a938910 crypto/tls: fix comment typo.
This was pointed out in https://go-review.googlesource.com/#/c/27315/1
but I changed and uploaded the wrong branch. This actually makes the
fix.

Change-Id: Ib615b06c9141b914648b6abbeeb688c5ffa0d2e3
Reviewed-on: https://go-review.googlesource.com/27360
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-18 21:52:31 +00:00
Adam Langley
8741504888 crypto/tls: support AES-128-CBC cipher suites with SHA-256.
These were new with TLS 1.2 and, reportedly, some servers require it.
Since it's easy, this change adds suport for three flavours of
AES-128-CBC with SHA-256 MACs.

Other testdata/ files have to be updated because this changes the list
of cipher suites offered by default by the client.

Fixes #15487.

Change-Id: I1b14330c31eeda20185409a37072343552c3464f
Reviewed-on: https://go-review.googlesource.com/27315
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Jonathan Rudenberg <jonathan@titanous.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-18 21:46:46 +00:00
Matthew Dempsky
36f61ed7ed cmd/dist: build cmd/compile/internal/syntax
Change-Id: Ie6dd2318e031be445c0b1ae65d4c78723d5a1167
Reviewed-on: https://go-review.googlesource.com/27197
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-18 21:33:53 +00:00
Robert Griesemer
c8683ff797 cmd/compile/internal/syntax: fast Go syntax trees, initial commit.
Syntax tree nodes, scanner, parser, basic printers.

Builds syntax trees for entire Go std lib at a rate of ~1.8M lines/s
in warmed up state (MacMini, 2.3 GHz Intel Core i7, 8GB RAM):

$ go test -run StdLib -fast
parsed 1074617 lines (2832 files) in 579.66364ms (1853863 lines/s)
allocated 282.212Mb (486.854Mb/s)
PASS

Change-Id: Ie26d9a7bf4e5ff07457aedfcc9b89f0eba72ae3f
Reviewed-on: https://go-review.googlesource.com/27195
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-08-18 21:33:38 +00:00
Robert Griesemer
fd8028dec9 go/types: fix scope extents for range and type switch variables
The changes match the existing compilers, and assume an adjusted
spec (per issue #16794).

Fixes #15686.

Change-Id: I72677ce75888c41a8f3c2963117a2f2d5501c42b
Reviewed-on: https://go-review.googlesource.com/27290
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-18 20:07:05 +00:00
Josh Bleecher Snyder
604efe1281 runtime: disable TestCgoCallbackGC on FreeBSD
The trybot flakes are a nuisance.

Updates #16396

Change-Id: I8202adb554391676ba82bca44d784c6a81bf2085
Reviewed-on: https://go-review.googlesource.com/27313
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-18 17:13:39 +00:00
Robert Griesemer
021f243213 go/types: set Info.Types.Type for array composite literals of the form [...]T
Fixes #14092.

Change-Id: I00692f60a416348e38cab256b94fda07e334d258
Reviewed-on: https://go-review.googlesource.com/27316
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-18 17:11:03 +00:00
Josh Bleecher Snyder
29df4c8f00 unsafe: document use of &^ to round/align pointers
Follow-up to CL 27156

Change-Id: I4f1cfced2dced9c9fc8a05bbc00ec4229e85c5c9
Reviewed-on: https://go-review.googlesource.com/27314
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-18 16:45:17 +00:00
Cherry Zhang
a7277e5494 cmd/compile: compare size in dead store elimination
Only remove stores that is shadowed by another store with same or
larger size. Normally we don't need this check because we did check
the types, but unsafe pointer casting can get around it.

Fixes #16769.

Change-Id: I3f7c6c57807b590a2f735007dec6c65a4fa01a34
Reviewed-on: https://go-review.googlesource.com/27320
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-08-18 16:38:56 +00:00
David Chase
5b9ff11c3d cmd/compile: ppc64le working, not optimized enough
This time with the cherry-pick from the proper patch of
the old CL.

Stack size increased.
Corrected NaN-comparison glitches.
Marked g register as clobbered by calls.
Fixed shared libraries.

live_ssa.go still disabled because of differences.
Presumably turning on more optimization will fix
both the stack size and the live_ssa.go glitches.

Enhanced debugging output for shared libs test.

Rebased onto master.

Updates #16010.

Change-Id: I40864faf1ef32c118fb141b7ef8e854498e6b2c4
Reviewed-on: https://go-review.googlesource.com/27159
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-08-18 16:34:47 +00:00
Brad Fitzpatrick
dea6dab40c cmd/yacc: remove go tool yacc
It is no longer used by Go.

It's now moved to golang.org/x/tools/cmd/goyacc for anybody who needs it.

Fixes #11229

Change-Id: Ia431d5a380c7ff784a2050dee2f5bc8acee015da
Reviewed-on: https://go-review.googlesource.com/27325
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-08-18 16:15:23 +00:00
Michael Matloob
795ad07b3b cmd: generate DWARF for functions in compile instead of link.
This is a copy of golang.org/cl/22092 by Ryan Brown.

Here's his original comment:
On my machine this increases the average time for 'go build cmd/go' from
2.25s to 2.36s. I tried to measure compile and link separately but saw
no significant change.

Change-Id: If0d2b756d52a0d30d4eda526929c82794d89dd7b
Reviewed-on: https://go-review.googlesource.com/25311
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-18 15:06:27 +00:00
Josh Bleecher Snyder
11e93aa24a cmd/vet: allow any printf verb with any interface
fmt treats interfaces as being transparent.
As a result, we cannot say with confidence
that any particular verb is wrong.

This fixes the following vet false positives
in the standard library:

database/sql/sql_test.go:210: arg dep for printf verb %p of wrong type: sql.finalCloser
fmt/fmt_test.go:1663: arg nil for printf verb %s of wrong type: untyped nil
go/ast/commentmap.go:328: arg node for printf verb %p of wrong type: ast.Node
net/http/transport_test.go:120: arg c for printf verb %p of wrong type: net.Conn
net/http/httptest/server.go:198: arg c for printf verb %p of wrong type: net.Conn
net/http/httputil/dump_test.go:258: arg body for printf verb %p of wrong type: io.Reader
reflect/set_test.go:81: arg x for printf verb %p of wrong type: io.Writer
reflect/set_test.go:141: arg bb for printf verb %p of wrong type: io.Reader

Updates #11041
Updates #16314

Change-Id: I76df01abb3c34a97b6960f551bed9c1c91377cfc
Reviewed-on: https://go-review.googlesource.com/27127
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-08-18 02:01:25 +00:00
Alex Brainman
0ece9c4b59 debug/pe: revert CL 22720
CL 22720 hid all recently added functionality for go1.7.
Make everything exported again, so we could use it now.

Updates #15345

Change-Id: Id8ccba7199422b554407ec14c343d2c28fbb8f72
Reviewed-on: https://go-review.googlesource.com/27212
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-08-18 01:19:29 +00:00
Adam Langley
e41b0e2bcb crypto/x509: support PSS signatures.
Although the term “RSA” is almost synonymous with PKCS#1 v1.5, that
standard is quite flawed, cryptographically speaking. Bellare and
Rogaway fixed PKCS#1 v1.5 with OAEP (for encryption) and PSS (for
signatures) but they only see a fraction of the use of v1.5.

This change adds support for creating and verifying X.509 certificates
that use PSS signatures. Sadly, every possible dimension of flexibility
seems to have been reflected in the integration of X.509 and PSS
resulting in a huge amount of excess complexity. This change only
supports one “sane” configuration for each of SHA-{256, 384, 512}.
Hopefully this is sufficient because it saves a lot of complexity in the
code.

Although X.509 certificates with PSS signatures are rare, I'm inclined
to look favourably on them because they are sufficiently superior.

Fixes #15958.

Change-Id: I7282e0b68ad0177209f8b2add473b94aa5224c07
Reviewed-on: https://go-review.googlesource.com/24743
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-18 00:40:17 +00:00
Adam Langley
59aeac20c0 crypto/x509: require a NULL parameters for RSA public keys.
The RFC is clear that the Parameters in an AlgorithmIdentifer for an RSA
public key must be NULL. BoringSSL enforces this so we have strong
evidence that this is a widely compatible change.

Embarrassingly enough, the major source of violations of this is us. Go
used to get this correct in only one of two places. This was only fixed
in 2013 (with 4874bc9b). That's why lots of test certificates are
updated in this change.

Fixes #16166.

Change-Id: Ib9a4551349354c66e730d44eb8cee4ec402ea8ab
Reviewed-on: https://go-review.googlesource.com/27312
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-17 23:47:18 +00:00
Alberto Donizetti
57370a87d8 encoding/hex: change lookup table from string to array
name            old time/op  new time/op  delta
Encode/256-4     431ns ± 2%   391ns ± 2%   -9.36%  (p=0.000 n=8+8)
Encode/1024-4   1.68µs ± 0%  1.51µs ± 0%   -9.91%  (p=0.001 n=7+7)
Encode/4096-4   6.68µs ± 0%  6.03µs ± 1%   -9.69%  (p=0.000 n=8+8)
Encode/16384-4  27.0µs ± 1%  24.0µs ± 0%  -11.03%  (p=0.000 n=8+7)

Change-Id: I6994e02f77797349c4e188377d84f97dffe98399
Reviewed-on: https://go-review.googlesource.com/27254
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-17 23:35:32 +00:00
Robert Griesemer
17eee31020 go/types: enable disabled test for comma-ok expressions
This was fixed long ago but the test was not enabled.

For #8189.

Change-Id: Ia44ef752b6bf076f3e243d2d0db326a392a20193
Reviewed-on: https://go-review.googlesource.com/27310
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-17 23:28:20 +00:00
Adam Langley
69371671c7 crypto/hmac: don't test for length equality in Equal.
subtle.ConstantTimeCompare now tests the length of the inputs (although
it didn't when this code was written) so this test in crypto/hmac is now
superfluous.

Fixes #16336.

Change-Id: Ic02d8537e776fa1dd5694d3af07a28c4d840d14b
Reviewed-on: https://go-review.googlesource.com/27239
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-17 23:23:28 +00:00
Adam Langley
b23b9a762c crypto/x509: return error for missing SerialNumber.
If the SerialNumber is nil in the template then the resulting panic is
rather deep in encoding/asn1 and it's not obvious what went wrong.

This change tests and returns a more helpful error in this case.

Fixes #16603.

Change-Id: Ib30d652555191eb78f705dff8d909e4b5808f9ca
Reviewed-on: https://go-review.googlesource.com/27238
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-17 23:23:18 +00:00
Jaana Burcu Dogan
c2322b7ea6 runtime: fix the absolute URL to pprof tools
Change-Id: I82eaf5c14a5b8b9ec088409f946adf7b5fd5dbe3
Reviewed-on: https://go-review.googlesource.com/27311
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-08-17 23:22:53 +00:00