1
0
mirror of https://github.com/golang/go synced 2024-09-30 17:28:32 -06:00
Commit Graph

24412 Commits

Author SHA1 Message Date
Daniel Theophanes
707a83341b database/sql: add option to use named parameter in query arguments
Modify the new Context methods to take a name-value driver struct.
This will require more modifications to drivers to use, but will
reduce the overall number of structures that need to be maintained
over time.

Fixes #12381

Change-Id: I30747533ce418a1be5991a0c8767a26e8451adbd
Reviewed-on: https://go-review.googlesource.com/30166
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-17 07:56:35 +00:00
Martin Möhrmann
99df54f196 bytes: encode size of rune read by ReadRune into lastRead to speed up UnreadRune
In ReadRune store the size of the rune that was read into lastRead
to avoid the need to call DecodeRuneLast in UnreadRune.

fmt:
name        old time/op  new time/op  delta
ScanInts-4   481µs ± 4%   458µs ± 3%  -4.64%  (p=0.000 n=20+20)

Change-Id: I500848e663a975f426402a4b3d27a541e5cac06c
Reviewed-on: https://go-review.googlesource.com/28817
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-17 06:00:35 +00:00
Brad Fitzpatrick
1e775fe4a3 net/http: add more docs on ErrHijacked
Updates #16456

Change-Id: Ifea651ea3ece2267a6f0c1638181d6ddd9248a9f
Reviewed-on: https://go-review.googlesource.com/31181
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-17 05:56:43 +00:00
Brad Fitzpatrick
7a7ea01c65 syscall, net: make deadline changes affect blocked read/write calls on nacl
Flesh out nacl's fake network system to match how all the other
platforms work: all other systems' SetReadDeadline and
SetWriteDeadline affect currently-blocked read & write calls.
This was documented in golang.org/cl/30164 because it was the status
quo and existing packages relied on it. (notably the net/http package)

And add a test.

Change-Id: I074a1054dcabcedc97b173dad5e827f8babf7cfc
Reviewed-on: https://go-review.googlesource.com/31178
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-17 05:53:00 +00:00
Caleb Spare
cd2c9df761 html/template: fix Clone so that t.Lookup(t.Name()) yields t
Template.escape makes the assumption that t.Lookup(t.Name()) is t
(escapeTemplate looks up the associated template by name and sets
escapeErr appropriately).

This assumption did not hold for a Cloned template, because the template
associated with t.Name() was a second copy of the original.

Add a test for the assumption that t.Lookup(t.Name()) == t.

One effect of this broken assumption was #16101: parallel Executes
racily accessed the template namespace because each Execute call saw
t.escapeErr == nil and re-escaped the template concurrently with read
accesses occurring outside the namespace mutex.

Add a test for this race.

Related to #12996 and CL 16104.

Fixes #16101

Change-Id: I59831d0847abbabb4ef9135f2912c6ce982f9837
Reviewed-on: https://go-review.googlesource.com/31092
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-10-17 00:35:20 +00:00
Rob Pike
42f5ee4cbf testing: mention in docs for Logf that a final newline is added if needed
Fixes #16423

Change-Id: I9635db295be4d356d427adadd309084e16c4582f
Reviewed-on: https://go-review.googlesource.com/31255
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-16 22:29:55 +00:00
Rob Pike
ca28620db9 cmd/go: use normal code 2 for 'no such tool'
Exit code 3 is unprecedented and inconsistent with other failures here,
such as having no tool directory.

Fixes #17145

Change-Id: Ie7ed56494d4511a600214666ce3a726d63a8fd8e
Reviewed-on: https://go-review.googlesource.com/31253
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-16 22:29:39 +00:00
Brad Fitzpatrick
1bcfca0563 net: enable a test on nacl
No need to skip it. It passes.

Maybe it was fixed at some point.

Change-Id: I9848924aefda44f9b3a574a8705fa549d657f28d
Reviewed-on: https://go-review.googlesource.com/31177
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-10-16 17:18:47 +00:00
Hiroshi Ioka
ad50408fe7 path/filepath: simplify TestToNorm
Change-Id: I8a176ed9c7f59ebdfd39c1e2b88905f977179982
Reviewed-on: https://go-review.googlesource.com/31119
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-16 09:21:57 +00:00
Alex Carol
0cc400f0e7 net/rpc: add missing import to rpc server documentation
Change-Id: Idca6115181960eed7a955027ee77a02decb4e7f2
Reviewed-on: https://go-review.googlesource.com/31179
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-16 07:31:39 +00:00
Austin Clements
9897e40811 runtime: use more go:nowritebarrierrec in proc.go
Currently we use go:nowritebarrier in many places in proc.go.
go:notinheap and go:yeswritebarrierrec now let us use
go:nowritebarrierrec (the recursive form of the go:nowritebarrier
pragma) more liberally. Do so in proc.go

Change-Id: Ia7fcbc12ce6c51cb24730bf835fb7634ad53462f
Reviewed-on: https://go-review.googlesource.com/30942
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-15 17:58:23 +00:00
Austin Clements
1bc6be6423 runtime: mark several types go:notinheap
This covers basically all sysAlloc'd, persistentalloc'd, and
fixalloc'd types.

Change-Id: I0487c887c2a0ade5e33d4c4c12d837e97468e66b
Reviewed-on: https://go-review.googlesource.com/30941
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-15 17:58:20 +00:00
Austin Clements
991a85c889 runtime: make mSpanList more go:notinheap-friendly
Currently mspan links to its previous mspan using a **mspan field that
points to the previous span's next field. This simplifies some of the
list manipulation code, but is going to make it very hard to convince
the compiler that mspan list manipulations don't need write barriers.

Fix this by using a more traditional ("boring") linked list that uses
a simple *mspan pointer to the previous mspan. This complicates some
of the list manipulation slightly, but it will let us eliminate all
write barriers from the mspan list manipulation code by marking mspan
go:notinheap.

Change-Id: I0d0b212db5f20002435d2a0ed2efc8aa0364b905
Reviewed-on: https://go-review.googlesource.com/30940
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-15 17:58:17 +00:00
Austin Clements
77527a316b cmd/compile: add go:notinheap type pragma
This adds a //go:notinheap pragma for declarations of types that must
not be heap allocated. We ensure these rules by disallowing new(T),
make([]T), append([]T), or implicit allocation of T, by disallowing
conversions to notinheap types, and by propagating notinheap to any
struct or array that contains notinheap elements.

The utility of this pragma is that we can eliminate write barriers for
writes to pointers to go:notinheap types, since the write barrier is
guaranteed to be a no-op. This will let us mark several scheduler and
memory allocator structures as go:notinheap, which will let us
disallow write barriers in the scheduler and memory allocator much
more thoroughly and also eliminate some problematic hybrid write
barriers.

This also makes go:nowritebarrierrec and go:yeswritebarrierrec much
more powerful. Currently we use go:nowritebarrier all over the place,
but it's almost never what you actually want: when write barriers are
illegal, they're typically illegal for a whole dynamic scope. Partly
this is because go:nowritebarrier has been around longer, but it's
also because go:nowritebarrierrec couldn't be used in situations that
had no-op write barriers or where some nested scope did allow write
barriers. go:notinheap eliminates many no-op write barriers and
go:yeswritebarrierrec makes it possible to opt back in to write
barriers, so these two changes will let us use go:nowritebarrierrec
far more liberally.

This updates #13386, which is about controlling pointers from non-GC'd
memory to GC'd memory. That would require some additional pragma (or
pragmas), but could build on this pragma.

Change-Id: I6314f8f4181535dd166887c9ec239977b54940bd
Reviewed-on: https://go-review.googlesource.com/30939
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-10-15 17:58:14 +00:00
Austin Clements
a9e6cebde2 cmd/compile, runtime: add go:yeswritebarrierrec pragma
This pragma cancels the effect of go:nowritebarrierrec. This is useful
in the scheduler because there are places where we enter a function
without a valid P (and hence cannot have write barriers), but then
obtain a P. This allows us to annotate the function with
go:nowritebarrierrec and split out the part after we've obtained a P
into a go:yeswritebarrierrec function.

Change-Id: Ic8ce4b6d3c074a1ecd8280ad90eaf39f0ffbcc2a
Reviewed-on: https://go-review.googlesource.com/30938
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-10-15 17:58:11 +00:00
Ilya Tocar
6347367be3 strings: use Index in Count
This simplifies code and provides performance iprovments:
Similar to https://go-review.googlesource.com/#/c/28577

CountHard1-48               1.74ms ±14%  0.17ms ±14%  -90.16%  (p=0.000 n=19+19)
CountHard2-48               1.78ms ±15%  0.25ms ±13%  -86.10%  (p=0.000 n=19+20)
CountHard3-48               1.78ms ±12%  0.80ms ±11%  -55.19%  (p=0.000 n=17+20)
CountTorture-48             13.5µs ±14%  13.6µs ±11%     ~     (p=0.625 n=18+19)
CountTortureOverlapping-48  6.92ms ±13%  8.42ms ±11%  +21.72%  (p=0.000 n=19+17)

Change-Id: Ief120aee918a66487c76be56e0796871c8502f89
Reviewed-on: https://go-review.googlesource.com/28586
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-15 16:39:31 +00:00
Daniel Theophanes
86b2f29676 database/sql: add support for multiple result sets
Many database systems allow returning multiple result sets
in a single query. This can be useful when dealing with many
intermediate results on the server and there is a need
to return more then one arity of data to the client.

Fixes #12382

Change-Id: I480a9ac6dadfc8743e0ba8b6d868ccf8442a9ca1
Reviewed-on: https://go-review.googlesource.com/30592
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-15 07:13:17 +00:00
Rob Pike
be48aa3f3a cmd/cover: handle gotos
If a labeled statement is the target of a goto, we must treat it as the
boundary of a new basic block, but only if it is not already the boundary
of a basic block such as a labeled for loop.

Fixes #16624

Now reports 100% coverage for the test in the issue.

Change-Id: If118bb6ff53a96c738e169d92c03cb3ce97bad0e
Reviewed-on: https://go-review.googlesource.com/30977
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-14 23:38:29 +00:00
Alex Brainman
d13fa4d225 os: use FindFirstFile when GetFileAttributesEx fails in Stat
Fixes #15355

Change-Id: Idbab7a627c5de249bb62d519c5a47f3d2f6c82a7
Reviewed-on: https://go-review.googlesource.com/22796
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-14 03:58:15 +00:00
Brad Fitzpatrick
abbd502d63 net/http: allow Handlers to test Hijacked conn without spamming error log
Make a zero-byte write to a hijacked connection not log anything, so handlers
can test whether a connection is hacked by doing a Write(nil).

Fixes #16456

Change-Id: Id56caf822c8592067bd8422672f0c1aec89e866c
Reviewed-on: https://go-review.googlesource.com/30812
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2016-10-13 21:55:38 +00:00
Michael Munday
61f1a38bcb crypto/{aes,cipher}: fix panic in CBC on s390x when src length is 0
Adds a test to check that block cipher modes accept a zero-length
input.

Fixes #17435.

Change-Id: Ie093c4cdff756b5c2dcb79342e167b3de5622389
Reviewed-on: https://go-review.googlesource.com/31070
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-13 21:42:23 +00:00
Filippo Valsorda
714318be88 expvar: add Value methods
Closes #15815

Change-Id: I08154dbff416198cf7787e446b1e00e62c03a972
Reviewed-on: https://go-review.googlesource.com/30917
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-13 21:39:03 +00:00
Alan Donovan
1da1da3d6a go/internal/gcimporter: set Pos attribute of decoded types.Objects
This change is a copy of CL 22788 in x/tools.
It has no observable effect yet, but brings the two packages in synch.

Change-Id: I266c77547cb46deb69b1a36e1674dfebc430e3a5
Reviewed-on: https://go-review.googlesource.com/22936
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-13 19:31:09 +00:00
Alex Brainman
d08c3d1329 cmd/link/internal/ld: use debug/pe package to rewrite ldpe.go
This CL also includes vendored copy of debug/pe,
otherwise bootstrapping fails.

Updates #15345

Change-Id: I3a8ac990e3cb12cb4d24ec11b618b68190397fd1
Reviewed-on: https://go-review.googlesource.com/22603
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-13 19:11:02 +00:00
Russ Cox
2427123d93 encoding/xml: split attribute marshaling into its own method
No functional changes here. Just makes next CL easier to read.

Change-Id: Icf7b2281b4da6cb59ff4edff05943b2ee288576a
Reviewed-on: https://go-review.googlesource.com/30945
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-13 17:47:44 +00:00
Anthony Canino
26c7b4fb1e cmd/compile: "abc"[1] is not an ideal constant
"abc"[1] is not like 'b', in that -"abc"[1] is uint8 math, not ideal constant math.
Delay the constantification until after ideal constant folding is over.

Fixes #11370.

Change-Id: Iba2fc00ca2455959e7bab8f4b8b4aac14b1f9858
Reviewed-on: https://go-review.googlesource.com/15740
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-13 17:41:04 +00:00
Russ Cox
0da30d5cbd encoding/json: handle misspelled JSON literals in ,string
Fixes #15146.

Change-Id: I229611b9cc995a1391681c492c4d742195c787ea
Reviewed-on: https://go-review.googlesource.com/30943
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-13 17:30:39 +00:00
Ian Lance Taylor
3c1e1c30fd cmd/cgo: use alias for unsafe rather than separate functions
When we need to generate a call to _cgoCheckPointer, we need to type
assert the result back to the desired type. That is harder when the type
is unsafe.Pointer, as the package can have values of unsafe.Pointer
types without actually importing unsafe, by mixing C void* and :=. We
used to handle this by generating a special function for each needed
type, and defining that function in a separate file where we did import
unsafe.

Simplify the code by not generating those functions, but instead just
import unsafe under the alias _cgo_unsafe. This is a simplification step
toward a fix for issue #16591.

Change-Id: I0edb3e04b6400ca068751709fe063397cf960a54
Reviewed-on: https://go-review.googlesource.com/30973
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-13 16:41:06 +00:00
Matthew Dempsky
dc46b882d5 cmd/compile: stop allocating Name and Param for ODCLFIELD
name       old time/op     new time/op     delta
Template       349ms ± 5%      339ms ± 7%  -2.89%        (p=0.000 n=27+29)
Unicode        187ms ±11%      182ms ±11%  -2.77%        (p=0.039 n=29+29)
GoTypes        1.05s ± 3%      1.04s ± 4%    ~           (p=0.103 n=29+29)
Compiler       4.57s ± 3%      4.55s ± 3%    ~           (p=0.202 n=30+29)

name       old user-ns/op  new user-ns/op  delta
Template        510M ±21%       521M ±18%    ~           (p=0.281 n=30+29)
Unicode         303M ±34%       300M ±28%    ~           (p=0.592 n=30+30)
GoTypes        1.52G ± 9%      1.50G ± 9%    ~           (p=0.314 n=30+30)
Compiler       6.50G ± 5%      6.44G ± 5%    ~           (p=0.362 n=29+30)

name       old alloc/op    new alloc/op    delta
Template      44.7MB ± 0%     44.0MB ± 0%  -1.63%        (p=0.000 n=28+28)
Unicode       34.6MB ± 0%     34.5MB ± 0%  -0.18%        (p=0.000 n=30+29)
GoTypes        125MB ± 0%      123MB ± 0%  -1.14%        (p=0.000 n=30+30)
Compiler       515MB ± 0%      513MB ± 0%  -0.52%        (p=0.000 n=30+30)

name       old allocs/op   new allocs/op   delta
Template        427k ± 0%       416k ± 0%  -2.66%        (p=0.000 n=30+30)
Unicode         323k ± 0%       322k ± 0%  -0.28%        (p=0.000 n=30+30)
GoTypes        1.21M ± 0%      1.18M ± 0%  -1.84%        (p=0.000 n=29+30)
Compiler       4.40M ± 0%      4.36M ± 0%  -0.95%        (p=0.000 n=30+30)

Passes toolstash -cmp.

Change-Id: Ifee7d012b1cddadda01450e027eef8d4ecf5581f
Reviewed-on: https://go-review.googlesource.com/30980
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-13 09:37:17 +00:00
Matthew Dempsky
01bf5cc219 cmd/compile: cleanup toolstash hacks from previous CL
Change-Id: I36cf3523e00b80e2d3a690f251edd5d6f665d156
Reviewed-on: https://go-review.googlesource.com/30975
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-13 09:29:57 +00:00
Matthew Dempsky
add3ff549a cmd/compile: add OSTRUCTKEY for keyed struct literals
Previously, we used OKEY nodes to represent keyed struct literal
elements. The field names were represented by an ONAME node, but this
is clumsy because it's the only remaining case where ONAME was used to
represent a bare identifier and not a variable.

This CL introduces a new OSTRUCTKEY node op for use in struct
literals. These ops instead store the field name in the node's own Sym
field. This is similar in spirit to golang.org/cl/20890.

Significant reduction in allocations for struct literal heavy code
like package unicode:

name       old time/op     new time/op     delta
Template       345ms ± 6%      341ms ± 6%     ~           (p=0.141 n=29+28)
Unicode        200ms ± 9%      184ms ± 7%   -7.77%        (p=0.000 n=29+30)
GoTypes        1.04s ± 3%      1.05s ± 3%     ~           (p=0.096 n=30+30)
Compiler       4.47s ± 9%      4.49s ± 6%     ~           (p=0.890 n=29+29)

name       old user-ns/op  new user-ns/op  delta
Template        523M ±13%       516M ±17%     ~           (p=0.400 n=29+30)
Unicode         334M ±27%       314M ±30%     ~           (p=0.093 n=30+30)
GoTypes        1.53G ±10%      1.52G ±10%     ~           (p=0.572 n=30+30)
Compiler       6.28G ± 7%      6.34G ±11%     ~           (p=0.300 n=30+30)

name       old alloc/op    new alloc/op    delta
Template      44.5MB ± 0%     44.4MB ± 0%   -0.35%        (p=0.000 n=27+30)
Unicode       39.2MB ± 0%     34.5MB ± 0%  -11.79%        (p=0.000 n=26+30)
GoTypes        125MB ± 0%      125MB ± 0%   -0.12%        (p=0.000 n=29+30)
Compiler       515MB ± 0%      515MB ± 0%   -0.10%        (p=0.000 n=29+30)

name       old allocs/op   new allocs/op   delta
Template        426k ± 0%       424k ± 0%   -0.39%        (p=0.000 n=29+30)
Unicode         374k ± 0%       323k ± 0%  -13.67%        (p=0.000 n=29+30)
GoTypes        1.21M ± 0%      1.21M ± 0%   -0.14%        (p=0.000 n=29+29)
Compiler       4.40M ± 0%      4.39M ± 0%   -0.13%        (p=0.000 n=29+30)

Passes toolstash/buildall.

Change-Id: Iba4ee765dd1748f67e52fcade1cd75c9f6e13fa9
Reviewed-on: https://go-review.googlesource.com/30974
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-13 09:29:51 +00:00
Matthew Dempsky
032e2bd1eb cmd/compile: replace aindex with typArray
aindex is overkill when it's only ever used with known integer
constants, so just use typArray directly instead.

Change-Id: I43fc14e604172df859b3ad9d848d219bbe48e434
Reviewed-on: https://go-review.googlesource.com/30979
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-13 07:23:53 +00:00
Alex Brainman
1af769da82 os: make readConsole handle its input and output correctly
This CL introduces first test for readConsole. And new test
discovered couple of problems with readConsole.

Console characters consist of multiple bytes each, but byte blocks
returned by syscall.ReadFile have no character boundaries. Some
multi-byte characters might start at the end of one block, and end
at the start of next block. readConsole feeds these blocks to
syscall.MultiByteToWideChar to convert them into utf16, but if some
multi-byte characters have no ending or starting bytes, the
syscall.MultiByteToWideChar might get confused. Current version of
syscall.MultiByteToWideChar call will make
syscall.MultiByteToWideChar ignore all these not complete
multi-byte characters.

The CL solves this issue by changing processing from "randomly
sized block of bytes at a time" to "one multi-byte character at a
time". New readConsole code calls syscall.ReadFile to get 1 byte
first. Then it feeds this byte to syscall.MultiByteToWideChar.
The new syscall.MultiByteToWideChar call uses MB_ERR_INVALID_CHARS
flag to make syscall.MultiByteToWideChar return error if input is
not complete character. If syscall.MultiByteToWideChar returns
correspondent error, we read another byte and pass 2 byte buffer
into syscall.MultiByteToWideChar, and so on until success.

Old readConsole code would also sometimes return no data if user
buffer was smaller then uint16 size, which would confuse callers
that supply 1 byte buffer. This CL fixes that problem too.

Fixes #17097

Change-Id: I88136cdf6a7bf3aed5fbb9ad2c759b6c0304ce30
Reviewed-on: https://go-review.googlesource.com/29493
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-13 06:16:53 +00:00
Hiroshi Ioka
0a0f4bc181 cmd/compile/internal/gc: cleanup esc.go
* convert important functions to methods
* rename EscXXX to XXX in NodeEscState
* rename local variables more friendly
* simplify redundant code
* update comments

Change-Id: I8442bf4f8dde84523d9a2ad3d04b1cd326bd4719
Reviewed-on: https://go-review.googlesource.com/30893
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-10-13 03:06:06 +00:00
Alex Browne
4940a83790 cmd/vet: check for duplicate json, xml struct field tags
It is easy to make the mistake of duplicating json struct field
tags especially when copy/pasting. This commit causes go vet to
report the mistake. Only field tags in the same struct type are
considered, because that is the only case which is undoubtedly an
error.

Fixes #12791.

Change-Id: I4130e4c04b177694cc0daf8f1acaf0751d4f062b
Reviewed-on: https://go-review.googlesource.com/16704
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-13 02:08:58 +00:00
Michael Pratt
ab019da727 cmd/internal/obj: document Prog
Change-Id: Iafc392ba06452419542ec85e91d44991839eb6f8
Reviewed-on: https://go-review.googlesource.com/19593
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-13 01:27:34 +00:00
Shenghou Ma
0a55a16c91 cmd/objdump: enable tests on ppc64/ppc64le
Fixes #9039.

Change-Id: I7d213b4f8e4cda73ea7687fb97dbd22e58163949
Reviewed-on: https://go-review.googlesource.com/9683
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-13 00:11:37 +00:00
Shenghou Ma
94cf54e861 cmd/internal/objfile: add ppc64/ppc64le disassembler support
Change-Id: I7d213b4f8e4cda73ea7687fb97dbd22e58163948
Reviewed-on: https://go-review.googlesource.com/9682
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-13 00:11:22 +00:00
Russ Cox
ed0a956746 cmd: add golang.org/x/arch/ppc64/ppc64asm for disassembly
For #9039.

Change-Id: I2b1bcd76857ff332411ca21a0cc5def3097a8eaf
Reviewed-on: https://go-review.googlesource.com/30936
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-13 00:11:05 +00:00
Allan Simon
daa121167b encoding/xml: prevent omitempty from omitting non-nil pointers to empty values
There was an inconsistency between the (json encoding + documentation)
and the xml encoding implementation. Pointer to an empty value was
not being serialized (i.e simply ignored). Which had the effect of making
impossible to have a struct with a string field for which we wanted to
serialize the value ""

Fixes #5452

Change-Id: Id858701801158409be01e962d2cda843424bd22a
Reviewed-on: https://go-review.googlesource.com/15684
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-13 00:07:09 +00:00
Russ Cox
90a750857c syscall: update darwin/amd64 for timespec change
Change-Id: I74f47f519dfee10cd079ad9a4e09e36e8d74c6dc
Reviewed-on: https://go-review.googlesource.com/30937
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-12 23:51:42 +00:00
Joe Tsai
14e545b60a archive/tar: reduce allocations in formatOctal
Change-Id: I9ddb7d2a97d28aba7a107b65f278993daf7807fa
Reviewed-on: https://go-review.googlesource.com/30960
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-12 21:27:51 +00:00
Lynn Boger
6da8bdd2cc cmd/asm: recognize CR1-CR7 on ppc64x branch instructions
Some of the branch instructions (BEQ, BNE, BLT, etc.) accept
all the valid CR values as operands, but the CR register value is
not parsed and not put into the instruction, so that CR0 is always
used regardless of what was specified on the instruction.  For example
BEQ CR2,label becomes beq cr0,label.

This adds the change to the PPC64 assembler to recognize the CR value
and set the approppriate field in the instruction so the correct
CR is used.  This also adds some general comments on the branch
instruction BC and its operand values.

Fixes #17408

Change-Id: I8e956372a42846a4c09a7259e9172eaa29118e71
Reviewed-on: https://go-review.googlesource.com/30930
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-10-12 21:17:47 +00:00
Keith Randall
442de98c14 cmd/compile,runtime: redo how map assignments work
To compile:
  m[k] = v
instead of:
  mapassign(maptype, m, &k, &v), do
do:
  *mapassign(maptype, m, &k) = v

mapassign returns a pointer to the value slot in the map.  It is just
like mapaccess except that it will allocate a new slot if k is not
already present in the map.

This makes map accesses faster but potentially larger (codewise).

It is faster because the write into the map is done when the compiler
knows the concrete type, so it can be done with a few store
instructions instead of calling typedmemmove.  We also potentially
avoid stack temporaries to hold v.

The code can be larger when the map has pointers in its value type,
since there is a write barrier call in addition to the mapassign call.
That makes the code at the callsite a bit bigger (go binary is 0.3%
bigger).

This CL is in preparation for doing operations like m[k] += v with
only a single runtime call.  That will roughly double the speed of
such operations.

Update #17133
Update #5147

Change-Id: Ia435f032090a2ed905dac9234e693972fe8c2dc5
Reviewed-on: https://go-review.googlesource.com/30815
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-12 20:41:23 +00:00
Russ Cox
55ef67f2f8 unicode: change SimpleFold to handle invalid runes
Functions like ToLower and ToUpper return the invalid rune back,
so we might as well do the same here.

I changed my mind about panicking when I tried to document the behavior.

Fixes #16690 (again).

Change-Id: If1c68bfcd66daea160fd19948e7672b0e1add106
Reviewed-on: https://go-review.googlesource.com/30935
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-10-12 18:30:29 +00:00
David Crawshaw
413afcafbf cmd/link: force external linking for plugins
Fixes #17415

Change-Id: I6f896d549092e5e0dba72351e5385992b4cbe90f
Reviewed-on: https://go-review.googlesource.com/30933
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-12 17:26:34 +00:00
Adam Langley
9e98e7e668 crypto/tls: enable X25519 by default.
Since this changes the offered curves in the ClientHello, all the test
data needs to be updated too.

Change-Id: I227934711104349c0f0eab11d854e5a2adcbc363
Reviewed-on: https://go-review.googlesource.com/30825
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-12 17:07:31 +00:00
Adam Langley
8a11cb318f crypto/tls: support X25519.
X25519 (RFC 7748) is now commonly used for key agreement in TLS
connections, as specified in
https://tools.ietf.org/html/draft-ietf-tls-curve25519-01.

This change adds support for that in crypto/tls, but does not enabled it
by default so that there's less test noise. A future change will enable
it by default and will update all the test data at the same time.

Change-Id: I91802ecd776d73aae5c65bcb653d12e23c413ed4
Reviewed-on: https://go-review.googlesource.com/30824
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-12 17:04:28 +00:00
Adam Langley
8c74139cad crypto/tls: fix printing of OpenSSL output when updating a test fails.
When updating the test data against OpenSSL, the handshake can fail and
the stdout/stderr output of OpenSSL is very useful in finding out why.

However, printing that output has been broken for some time because its
no longer sent to a byte.Buffer. This change fixes that.

Change-Id: I6f846c7dc80f1ccee9fa1be36f0b579b3754e05f
Reviewed-on: https://go-review.googlesource.com/30823
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-12 17:04:02 +00:00
Adam Langley
e875fe42ee vendor/golang_org/x/crypto/curve25519: new package
This change imports the curve25519 package from x/crypto at revision
594708b89f21ece706681be23d04a6513a22de6e.

Change-Id: I379eaa71492959e404259fc1273d0057573bc243
Reviewed-on: https://go-review.googlesource.com/30822
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-12 17:03:55 +00:00
Adam Langley
9d88292c83 crypto/tls: switch to OpenSSL 1.1.0 for test data.
We will need OpenSSL 1.1.0 in order to test some of the features
expected for Go 1.8. However, 1.1.0 also disables (by default) some
things that we still want to test, such as RC4, 3DES and SSLv3. Thus
developers wanting to update the crypto/tls test data will need to build
OpenSSL from source.

This change updates the test data with transcripts generated by 1.1.0
(in order to reduce future diffs) and also causes a banner to be printed
if 1.1.0 is not used when updating.

(The test for an ALPN mismatch is removed because OpenSSL now terminates
the connection with a fatal alert if no known ALPN protocols are
offered. There's no point testing against this because it's an OpenSSL
behaviour.)

Change-Id: I957516975e0b8c7def84184f65c81d0b68f1c551
Reviewed-on: https://go-review.googlesource.com/30821
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-12 17:03:46 +00:00
Joe Tsai
0e36456bf9 archive/tar: fix and cleanup readOldGNUSparseMap
* Assert that the format is GNU.
Both GNU and STAR have some form of sparse file support with
incompatible header structures. Worse yet, both formats use the
'S' type flag to indicate the presence of a sparse file.
As such, we should check the format (based on magic numbers)
and fail early.

* Move realsize parsing logic into readOldGNUSparseMap.
This is related to the sparse parsing logic and belongs here.

* Fix the termination condition for parsing sparse fields.
The termination condition for reading the sparse fields
is to simply check if the first byte of the offset field is NULL.
This does not seem to be documented in the GNU manual, but this is
the check done by the both the GNU and BSD implementations:
	http://git.savannah.gnu.org/cgit/tar.git/tree/src/sparse.c?id=9a33077a7b7ad7d32815a21dee54eba63b38a81c#n731
	1fa9c7bf90/libarchive/archive_read_support_format_tar.c (L2207)

* Fix the parsing of sparse fields to use parseNumeric.
This is what GNU and BSD do. The previous two links show that
GNU and BSD both handle base-256 and base-8.

* Detect truncated streams.
The call to io.ReadFull does not check if the error is io.EOF.
Getting io.EOF in this method is never okay and should always be
converted to io.ErrUnexpectedEOF.

* Simplify the function.
The logic is essentially a do-while loop so we can remove
some redundant code.

Change-Id: Ib2f601b1a283eaec1e41b1d3396d649c80749c4e
Reviewed-on: https://go-review.googlesource.com/28471
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2016-10-12 16:36:57 +00:00
Joe Tsai
14204662c8 archive/tar: handle integer overflow on 32bit machines
Most calls to strconv.ParseInt(x, 10, 0) should really be
calls to strconv.ParseInt(x, 10, 64) in order to ensure that they
do not overflow on 32b architectures.

Furthermore, we should document a bug where Uid and Gid may
overflow on 32b machines since the type is declared as int.

Change-Id: I99c0670b3c2922e4a9806822d9ad37e1a364b2b8
Reviewed-on: https://go-review.googlesource.com/28472
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 16:36:41 +00:00
Hiroshi Ioka
94f49fd40d unicode: panic if given rune is negative in SimpleFold
Fixes #16690

Change-Id: I6db588c4b0f23c5ec6bc9b85a488b60fab3f2f13
Reviewed-on: https://go-review.googlesource.com/30892
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-12 15:45:03 +00:00
Momchil Velikov
be302e6d43 cmd/compile: trim more blocks
- trim blocks with multiple predecessors
 - trim blocks, which contain only phi-functions
 - trim blocks, which can be merged into the successor block

As an example, compiling the following source:

---8<------
package p

type Node struct {
        Key         int
        Left, Right *Node
}

func Search(r *Node, k int) *Node {
        for r != nil {
                switch {
                case k == r.Key:
                        return r
                case k < r.Key:
                        r = r.Left
                default:
                        r = r.Right
                }
        }
        return nil
}
---8<------

with `GOSSAFUNC=Search" go tool compile t.go`, results in the following
code:

---8<------
genssa

      00000 (t.go:8)	TEXT	"".Search(SB), $0
      00001 (t.go:8)	FUNCDATA	$0, "".gcargs·0(SB)
      00002 (t.go:8)	FUNCDATA	$1, "".gclocals·1(SB)
      00003 (t.go:8)	TYPE	"".r(FP)type.*"".Node, $8
      00004 (t.go:8)	TYPE	"".k+8(FP)type.int, $8
      00005 (t.go:8)	TYPE	"".~r2+16(FP)type.*"".Node, $8
v40   00006 (t.go:9)	MOVQ	"".k+8(FP), AX
v34   00007 (t.go:9)	MOVQ	"".r(FP), CX
v33   00008 (t.go:9)	TESTQ	CX, CX
b2    00009 (t.go:9)	JEQ	$0, 22
v16   00010 (t.go:11)	MOVQ	(CX), DX
v21   00011 (t.go:11)	CMPQ	DX, AX
b9    00012 (t.go:11)	JEQ	$0, 19
v64   00013 (t.go:13)	CMPQ	AX, DX
b13   00014 (t.go:13)	JGE	17
v36   00015 (t.go:14)	MOVQ	8(CX), CX
b4    00016 (t.go:9)	JMP	8                  <---+
v42   00017 (t.go:16)	MOVQ	16(CX), CX             |
b21   00018 (t.go:10)	JMP	16                 ----+
v28   00019 (t.go:12)	VARDEF	"".~r2+16(FP)
v29   00020 (t.go:12)	MOVQ	CX, "".~r2+16(FP)
b10   00021 (t.go:12)	RET
v44   00022 (t.go:19)	VARDEF	"".~r2+16(FP)
v45   00023 (t.go:19)	MOVQ	$0, "".~r2+16(FP)
b5    00024 (t.go:19)	RET
00025 (<unknown line number>)	END
---8<------

Note the jump at 18 jumps to another jump at 16.

Looking at the function after trimming:

--8<------
after trim [199 ns]

b1:
v1 = InitMem <mem>
v2 = SP <uintptr> : SP
v67 = Arg <*Node> {r} : r[*Node]
v59 = Arg <int> {k} : k[int]
v40 = LoadReg <int> v59 : AX
v34 = LoadReg <*Node> v67 : CX
Plain → b2

b2: ← b1 b4
v8 = Phi <*Node> v34 v68 : CX
v33 = TESTQ <flags> v8 v8
NE v33 → b9 b5 (likely)

b9: ← b2
v16 = MOVQload <int> v8 v1 : DX
v21 = CMPQ <flags> v16 v40
EQ v21 → b10 b13 (unlikely)

b13: ← b9
v64 = CMPQ <flags> v40 v16
LT v64 → b19 b21

b19: ← b13
v36 = MOVQload <*Node> [8] v8 v1 : CX
Plain → b4

b4: ← b21 b19                       <
v68 = Phi <*Node> v42 v36 : CX      <- no actual code
Plain → b2                          <

b21: ← b13
v42 = MOVQload <*Node> [16] v8 v1 : CX
Plain → b4

b10: ← b9
v28 = VarDef <mem> {~r2} v1
v29 = MOVQstore <mem> {~r2} v2 v8 v28
v30 = Copy <mem> v29
Ret v30

b5: ← b2
v44 = VarDef <mem> {~r2} v1
v45 = MOVQstoreconst <mem> {~r2} [val=0,off=0] v2 v44
v47 = Copy <mem> v45
Ret v47

--8<------

The jump at 16 corresponds to the edge b21 -> b4. The block b4 contains
only phi-ops, i.e. no actual code besides the jump to b2. However b4 is
not trimmed, because it a) has more than one predecessor, and b) it is
not empty.

This change enhances trim.go to remove more blocks, subject to the
following criteria:

 - block has predecessors (i.e. not the start block)

 - block is BlockPlain

 - block does not loop back to itself

 - block is the single predecessor of its successor; the instructions of
   the block are merged into the successor

 - block does no emit actual code, besides a possible unconditional
   jump.
     Currently only OpPhi are considered to not be actual code,
   perhaps OpKeepAlive/others should be considered too?

As an example, after the change, the block b4 is trimmed and the jump at
18 jumps directly to 8.

Revision 1: Adjust phi-ops arguments after merge

Ensure the number of phi-ops arguments matches the new number of
predecessors in the merged block.
When moving values, make them refer to the merged block.

Revision 2:
 - Make clear the intent that we do not want to trim the entry block
 - Double check that we are merging a phi operation
 - Minor code style fix
 - Fix a potentially dangerous situation when a blocks refers to the
   inline value space in another block

Change-Id: I0ab91779f931f404d11008f5c45606d985d7fbaa
Reviewed-on: https://go-review.googlesource.com/28812
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-10-12 15:10:24 +00:00
Kevin Burke
8d1d9292ff syscall: document that Exec wraps execve(2)
Change-Id: I611511434f37c75f77c22f61f469108243bc0101
Reviewed-on: https://go-review.googlesource.com/29121
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 15:02:57 +00:00
Cyrill Schumacher
6899843355 net/http: optimize internal cookie functions
- precalculate *Cookie slice in read cookie functions
- readSetCookies: pre-allocs depending on the count of Set-Cookies
- rename success variable to ok; avoid else
- refactor Cookie.String to use less allocations
- remove fmt package and replace with writes to a bytes.Buffer
- add BenchmarkReadSetCookies and BenchmarkReadCookies

name              old time/op    new time/op    delta
CookieString-8      1.42µs ± 2%    0.78µs ± 1%  -45.36%        (p=0.000 n=10+10)
ReadSetCookies-8    3.46µs ± 1%    3.42µs ± 2%   -1.39%        (p=0.001 n=10+10)
ReadCookies-8       5.12µs ± 1%    5.15µs ± 2%     ~           (p=0.393 n=10+10)

name              old alloc/op   new alloc/op   delta
CookieString-8        520B ± 0%      384B ± 0%  -26.15%        (p=0.000 n=10+10)
ReadSetCookies-8      968B ± 0%      960B ± 0%   -0.83%        (p=0.000 n=10+10)
ReadCookies-8       2.01kB ± 0%    2.01kB ± 0%     ~     (all samples are equal)

name              old allocs/op  new allocs/op  delta
CookieString-8        10.0 ± 0%       3.0 ± 0%  -70.00%        (p=0.000 n=10+10)
ReadSetCookies-8      18.0 ± 0%      17.0 ± 0%   -5.56%        (p=0.000 n=10+10)
ReadCookies-8         16.0 ± 0%      16.0 ± 0%     ~     (all samples are equal)

Change-Id: I870670987f10f3e52f9c657cfb8e6eaaa97a6162
Reviewed-on: https://go-review.googlesource.com/27850
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 14:59:36 +00:00
Alan Donovan
9c850958ce go/types: expose Default function, which converts untyped T to T
Change-Id: Ibcf5e0ba694b280744a00c2c6fda300f0a653455
Reviewed-on: https://go-review.googlesource.com/30715
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-12 14:59:23 +00:00
Emmanuel Odeke
898ca6ba0a runtime: update mkduff legacy comments
Update comments for duffzero and duffcopy
which referred to legacy locations:
+ cmd/?g/cgen.go
+ cmd/?g/ggen.go

Remnants of the old days when we had 5g, 6g etc.

Those locations have since moved to:
+ cmd/compile/internal/<arch>/cgen.go
+ cmd/compile/internal/<arch>/ggen.go

Change-Id: Ie2ea668559d52d42b747260ea69a6d5b3d70e859
Reviewed-on: https://go-review.googlesource.com/29073
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 14:51:50 +00:00
Jean-Nicolas Moal
6d702d8ed2 os: add examples of environment functions
For #16360.

Change-Id: Iaa3548704786018eacec530f7a907b976fa532fe
Reviewed-on: https://go-review.googlesource.com/27443
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-12 14:04:30 +00:00
Hiroshi Ioka
b65cdc2888 path/filepath: add a test case for EvalSymlinks error
EvalSymlinks returns error if given path or its target path don't exist.
Add a test for future improvement.

Change-Id: Ic9a4aa5eaee0fe7ac523d54d8eb3132a11b380b3
Reviewed-on: https://go-review.googlesource.com/27330
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2016-10-12 14:01:03 +00:00
Dave Cheney
6e759ad2e2 cmd/compile/internal/gc: add runtime/trace support
This change adds runtime/trace support to go tool compile.

Change-Id: I6c496b9b063796123f75eba6af511c53a57c0196
Reviewed-on: https://go-review.googlesource.com/25354
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-10-12 13:57:26 +00:00
Joshua Boelter
1a3b739b26 runtime: check for errors returned by windows sema calls
Add checks for failure of CreateEvent, SetEvent or
WaitForSingleObject. Any failures are considered fatal and
will throw() after printing an informative message.

Updates #16646

Change-Id: I3bacf9001d2abfa8667cc3aff163ff2de1c99915
Reviewed-on: https://go-review.googlesource.com/26655
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-12 13:39:43 +00:00
David du Colombier
9d36ab222d cmd/link: use HEADR to define FlagTextAddr (cosmetic change)
This cosmetic change defines ld.FlagTextAddr using ld.HEADR in
the Plan 9 cases, like it is done for other operating systems.

Change-Id: Ic929c1c437f25661058682cf3e159f0b16cdc538
Reviewed-on: https://go-review.googlesource.com/30912
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-12 13:18:34 +00:00
Mikio Hara
8fc9c50496 net: update doc for unimplemented feature on Plan 9
Also removes unnecessary allocation.

Change-Id: I3406cf75a7b64d93b2b99c7f1f5c78f580452b60
Reviewed-on: https://go-review.googlesource.com/30891
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-12 13:15:50 +00:00
David du Colombier
29c600bba1 cmd/link: fix build on plan9/amd64
Support for multiple text sections was added in CL 27790.
However, this change broke the build on plan9/amd64.

In relocsym, the R_ADDROFF relocation was changed to
use offsets relative to the start of the first text
section. However, Segtext.Vaddr is the address of
the text segment, while we expect to start from
the first section (text.runtime) of the text segment.

Fixes #17411.

Change-Id: I86bbcbda81cea735b0ecf156eab2e6e5d63acce3
Reviewed-on: https://go-review.googlesource.com/30911
Run-TryBot: David du Colombier <0intro@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-12 13:14:46 +00:00
Ian Lance Taylor
6c517df4da syscall: unify NsecToTime{spec,val}, fix for times < 1970
All the implementations of NsecToTimespec and NsecToTimeval were the
same other than types. Write a single version that uses
GOARCH/GOOS-specific setTimespec and setTimeval functions to handle the
types.

The logic in NsecToTimespec and NsecToTimeval caused times before 1970
to have a negative usec/nsec. The Linux kernel requires that usec
contain a positive number; for consistency, we do this for both
NsecToTimespec and NsecToTimeval.

Change-Id: I525eaba2e7cdb00cb57fa00182dabf19fec298ae
Reviewed-on: https://go-review.googlesource.com/30826
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 13:10:54 +00:00
Chris McGee
6ca48f710f net: implement network interface API for Plan 9
The new implementation parses the plan9 interface files
and builds Interface representations for the net package.

Updates #17218

Change-Id: I3199d18d9e96a17e922186c3abff1d7cd9cbec2e
Reviewed-on: https://go-review.googlesource.com/29963
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-12 10:12:31 +00:00
Sina Siadat
2287296dbe os: add example for IsNotExist
Show usage of os.IsNotExist in an example.

Change-Id: I5306ea06c370099de5b02668dfa02b87b0c2beac
Reviewed-on: https://go-review.googlesource.com/25571
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-12 08:03:00 +00:00
Shawn Walker-Salas
f373bf1eb9 cmd/link: non-executable stack support for Solaris
Support the tagging of binaries created with the internal linker
on Solaris as having a non-executable stack by writing a PT_SUNWSTACK
program header.

Fixes #16074

Change-Id: I3888f2153083385d04a52f341570f93e5738b276
Reviewed-on: https://go-review.googlesource.com/24142
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 06:41:25 +00:00
Gyu-Ho Lee
456b7f5a97 runtime/pprof: preallocate slice in pprof.go
To prevent slice growth when appending.

Change-Id: I2cdb9b09bc33f63188b19573c8b9a77601e63801
Reviewed-on: https://go-review.googlesource.com/23783
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 06:33:34 +00:00
Alex Brainman
81b9af7ccc os: add new tests for symbolic links and directory junctions
Updates #15978
Updates #16145

Change-Id: I161f5bc97d41c08bf5e1405ccafa86232d70886d
Reviewed-on: https://go-review.googlesource.com/25320
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 05:59:16 +00:00
Tristan Ooohry
d2ef288c8b cmd/go: added verbose error from matchGoImport
The error coming out of matchGoImport does not differentiate between
having no imports, and having some invalid imports.

This some extra context to the error message to help debug these issues.

Fixes #16467

Change-Id: I3e9a119ed73da1bed5e07365be0221ea6b7f19db
Reviewed-on: https://go-review.googlesource.com/25121
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 03:56:49 +00:00
Xuyang Kang
87b1aaa37c encoding/base64: This change modifies Go to take strict option when decoding base64
If strict option is enabled, when decoding, instead of skip the padding
bits, it will do strict check to enforce they are set to zero.

Fixes #15656

Change-Id: I869fb725a39cc9dde44dbc4ff0046446e7abc642
Reviewed-on: https://go-review.googlesource.com/24964
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-12 03:56:18 +00:00
Gustav Westling
56b5546b91 cmd/gofmt: simplify map key literals
Simplify map key literals in "gofmt -s"

Fixes #16461.

Change-Id: Ia61739b34a30ac27f6696f94a98809109a8a7b61
Reviewed-on: https://go-review.googlesource.com/25530
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 03:55:43 +00:00
Keith Randall
d07345a633 cmd/compile: update ssa html help text
Update the description of the conditions under which highlighting might
be misleading.

Fixes #16754

Change-Id: I3078a09e0b9a76d12078352e15a3f26ba3f1bbee
Reviewed-on: https://go-review.googlesource.com/30818
Reviewed-by: David Chase <drchase@google.com>
2016-10-12 03:40:23 +00:00
Dmitri Shuralyov
6597bcbe53 path/filepath: remove unneeded doc statement for SplitList
This is a followup to CL 24747, where the package doc phrase
"Functions in this package replace occurrences of slash unless otherwise specified."
was removed. The phrase was originally added in CL 7310 together
with this explicit opt out statement for SplitList.

Remove it since it's no longer neccessary. This helps consistency.

Updates #16111.
Updates #10122.

Change-Id: Iba86de57c24100adecac9cb5892ce180126c0ea6
Reviewed-on: https://go-review.googlesource.com/25250
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 02:52:01 +00:00
Gleb Stepanov
460d112f6c runtime: fix typo in comments
Fix typo in word synchronization in comments.

Change-Id: I453b4e799301e758799c93df1e32f5244ca2fb84
Reviewed-on: https://go-review.googlesource.com/25174
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 02:48:31 +00:00
Michael Munday
8728df645c runtime: remove canBackTrace variable from TestGdbPython
The canBackTrace variable is true for all of the architectures
Go supports and this is likely to remain the case as new
architectures are added.

Change-Id: I73900c018eb4b2e5c02fccd8d3e89853b2ba9d90
Reviewed-on: https://go-review.googlesource.com/22423
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-12 02:16:11 +00:00
Michael Pratt
0aadaf2ad5 cmd/pprof: instruction-level granularity in callgrind output
When generating callgrind format output, produce cost lines at
instruction granularity. This allows visualizers supporting the
callgrind format to display instruction-level profiling information.

We also need to provide the object file (ob=) in order for tools to find
the object file to disassemble when displaying assembly.

We opportunistically group cost lines corressponding to the same
function together, reducing the number of superfluous description lines.
Subposition compression (relative position numbering) is also used to
reduce the output size.

Change-Id: Id8e960b81dc7a47ec1dfbae877521f76972431c4
Reviewed-on: https://go-review.googlesource.com/23781
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Raul Silvera <rsilvera@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 02:09:12 +00:00
Filippo Valsorda
f64c670181 cmd/trace: add option to output pprof files
The trace tool can generate some interesting profiles, but it was only
exposing them as svg through the web UI.  This adds command line options
to generate the raw pprof file.

Change-Id: I52e4f909fdca6f65c3616add444e3892783640f4
Reviewed-on: https://go-review.googlesource.com/23324
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-12 01:36:22 +00:00
Ian Lance Taylor
7f6eadb64f syscall: unify TimespecToNsec and TimevalToNsec
All implementations of these functions are identical.

Change-Id: I7cbea53c02bb0cee75e30beed19d29ba0a7ef657
Reviewed-on: https://go-review.googlesource.com/30819
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-11 22:58:57 +00:00
James Clarke
e1fc292500 debug/elf: add sparc64 relocations
Change-Id: I1a2504ad9ca8607588d2d366598115fe360435b5
Reviewed-on: https://go-review.googlesource.com/30870
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-11 21:52:37 +00:00
Joe Tsai
35220534d5 archive/zip: only use Extended Timestamp on non-zero MS-DOS timestamps
We should preserve the fact that a roundtrip read on fields with the zero
value should remain the zero for those that are reasonable to stay that way.
If the zero value for a MS-DOS timestamp was used, then it is sensible for
that zero value to also be read back later.

Fixes #17403

Change-Id: I32c3915eab180e91ddd2499007374f7b85f0bd76
Reviewed-on: https://go-review.googlesource.com/30811
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-11 21:31:25 +00:00
Matthew Dempsky
303b69feb7 cmd/compile, runtime: stop padding stackmaps to 4 bytes
Shrinks cmd/go's text segment by 0.9%.

   text	   data	    bss	    dec	    hex	filename
6447148	 231643	 146328	6825119	 68249f	go.before
6387404	 231643	 146328	6765375	 673b3f	go.after

Change-Id: I431e8482dbb11a7c1c77f2196cada43d5dad2981
Reviewed-on: https://go-review.googlesource.com/30817
Reviewed-by: Austin Clements <austin@google.com>
2016-10-11 20:23:30 +00:00
Matthew Dempsky
943f5afe22 cmd/compile: refactor stackmap dumping code
Also, fix a byte-ordering problem with stack maps for assembly
function signatures on big-endian targets.

Change-Id: I6e8698f5fbb04b31771a65f4a8f3f9c045ff3c98
Reviewed-on: https://go-review.googlesource.com/30816
Reviewed-by: Austin Clements <austin@google.com>
2016-10-11 20:23:24 +00:00
Michael Munday
15817e409b cmd/compile: make link register allocatable in non-leaf functions
We save and restore the link register in non-leaf functions because
it is clobbered by CALLs. It is therefore available for general
purpose use.

Only enabled on s390x currently. The RC4 benchmarks in particular
benefit from the extra register:

name     old speed     new speed     delta
RC4_128  243MB/s ± 2%  341MB/s ± 2%  +40.46%  (p=0.008 n=5+5)
RC4_1K   267MB/s ± 0%  359MB/s ± 1%  +34.32%  (p=0.008 n=5+5)
RC4_8K   271MB/s ± 0%  362MB/s ± 0%  +33.61%  (p=0.008 n=5+5)

Change-Id: Id23bff95e771da9425353da2f32668b8e34ba09f
Reviewed-on: https://go-review.googlesource.com/30597
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-11 18:52:35 +00:00
Adam Langley
809a1de1ac crypto/x509: parse all names in an RDN.
The Subject and Issuer names in a certificate look like they should be a
list of key-value pairs. However, they're actually a list of lists of
key-value pairs. Previously we only looked at the first element of each
sublist and the vast majority of certificates only have one element per
sublist.

However, it's possible to have multiple elements and some 360
certificates from the “Pilot” log are so constructed.

This change causes all elements of the sublists to be processed.

Fixes #16836.

Change-Id: Ie0a5159135b08226ec517fcf251aa17aada37857
Reviewed-on: https://go-review.googlesource.com/30810
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-11 17:35:55 +00:00
Hajime Hoshi
c5368123fe cmd/compile: remove redundant function idom
Change-Id: Ib14b5421bb5e407bbd4d3cbfc68c92d3dd257cb1
Reviewed-on: https://go-review.googlesource.com/30732
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-10-11 16:43:12 +00:00
David Chase
f1eed92fd0 cmd/compile: escape analysis needs to run "flood" to fixed point
In some cases the members of the root set from which flood
runs themselves escape, without their referents being also
tagged as escaping.  Fix this by reflooding from those roots
whose escape increases, and also enhance the "leak" test to
include reachability from a heap-escaped root.

Fixes #17318.

Change-Id: Ied1e75cee17ede8ca72a8b9302ce8201641ec593
Reviewed-on: https://go-review.googlesource.com/30693
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-11 16:32:15 +00:00
Russ Cox
88562dc83e math/big: move ProbablyPrime into its own source file
A later CL will be adding more code here.
It will help to keep it separate from the other code.

Change-Id: I971ba53de819cd10991b51fdec665984939a5f9b
Reviewed-on: https://go-review.googlesource.com/30709
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-11 16:16:17 +00:00
Russ Cox
9927f25d71 math/big: test and optimize Exp(2, y, n) for large y, odd n
The Montgomery multiply code is applicable to this case
but was being bypassed. Don't do that.

The old test len(x) > 1 was really just a bad approximation to x > 1.

name    old time/op  new time/op  delta
Exp-8   5.56ms ± 4%  5.73ms ± 3%     ~     (p=0.095 n=5+5)
Exp2-8  7.59ms ± 1%  5.66ms ± 1%  -25.40%  (p=0.008 n=5+5)

This comes up especially when doing Fermat (Miller-Rabin)
primality tests with base 2.

Change-Id: I4cc02978db6dfa93f7f3c8f32718e25eedb4f5ed
Reviewed-on: https://go-review.googlesource.com/30708
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-11 16:15:51 +00:00
Russ Cox
9a8832f142 math/big: move exhaustive tests behind -long flag
This way you can still run 'go test' or 'go bench -run Foo'
without wondering why it is taking so very long.

Change-Id: Icfa097a6deb1d6682acb7be9f34729215c29eabb
Reviewed-on: https://go-review.googlesource.com/30707
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-10-11 16:15:12 +00:00
Cherry Zhang
2756d56c89 cmd/compile: intrinsify math/big.mulWW, divWW on AMD64
Change-Id: I59f7afa7a5803d19f8b21fe70fc85ef997bb3a85
Reviewed-on: https://go-review.googlesource.com/30542
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-10-11 16:07:46 +00:00
Cherry Zhang
7c431cb7f9 cmd/link: insert trampolines for too-far jumps on ARM
ARM direct CALL/JMP instruction has 24 bit offset, which can only
encodes jumps within +/-32M. When the target is too far, the top
bits get truncated and the program jumps wild.

This CL detects too-far jumps and automatically insert trampolines,
currently only internal linking on ARM.

It is necessary to make the following changes to the linker:
- Resolve direct jump relocs when assigning addresses to functions.
  this allows trampoline insertion without moving all code that
  already laid down.
- Lay down packages in dependency order, so that when resolving a
  inter-package direct jump reloc, the target address is already
  known. Intra-package jumps are assumed never too far.
- a linker flag -debugtramp is added for debugging trampolines:
    "-debugtramp=1 -v" prints trampoline debug message
    "-debugtramp=2"    forces all inter-package jump to use
                       trampolines (currently ARM only)
    "-debugtramp=2 -v" does both
- Some data structures are changed for bookkeeping.

On ARM, pseudo DIV/DIVU/MOD/MODU instructions now clobber R8
(unfortunate). In the standard library there is no ARM assembly
code that uses these instructions, and the compiler no longer emits
them (CL 29390).

all.bash passes with -debugtramp=2, except a disassembly test (this
is unavoidable as we changed the instruction).

TBD: debug info of trampolines?

Fixes #17028.

Change-Id: Idcce347ea7e0af77c4079041a160b2f6e114b474
Reviewed-on: https://go-review.googlesource.com/29397
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-11 13:35:33 +00:00
Ian Lance Taylor
d03e8b226c runtime: record current PC for SIGPROF on non-Go thread
If we get a SIGPROF on a non-Go thread, and the program has not called
runtime.SetCgoTraceback so we have no way to collect a stack trace, then
record a profile that is just the PC where the signal occurred. That
will at least point the user to the right area.

Retrieving the PC from the sigctxt in a signal handler on a non-G thread
required marking a number of trivial sigctxt methods as nosplit, and,
for extra safety, nowritebarrierrec.

The test shows that the existing test CgoPprofThread test does not test
the stack trace, just the profile signal. Leaving that for later.

Change-Id: I8f8f3ff09ac099fc9d9df94b5a9d210ffc20c4ab
Reviewed-on: https://go-review.googlesource.com/30252
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-10-11 12:56:15 +00:00
Hyang-Ah (Hana) Kim
c24cc40075 cmd/trace: fix a runnable goroutine count bug
When starting tracing, EvGoCreate events are added for existing
goroutines that may have been blocking in syscall. EvGoCreate
increments the runnable goroutine count. This change makes the
following EvGoInSyscall event decrement the runnable goroutine count
because we now know that goroutine is in syscall, and not runnable.

Made generateTrace return an error, at any given time, the number
of runnable/running/insyscall goroutines becomes non-negative.

Added a basic test that checks the number of runnable/running
goroutines don't include the goroutines in syscall - the test failed
before this change.

Change-Id: Ib732c382e7bd17158a437576f9d589ab89097ce6
Reviewed-on: https://go-review.googlesource.com/25552
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-10-11 12:07:44 +00:00
Alex Brainman
dd307da10c runtime/cgo: do not explicitly link msvcrt.dll
CL 14472 solved issue #12030 by explicitly linking msvcrt.dll
to every cgo executable we build. This CL achieves the same
by manually loading ntdll.dll during startup.

Updates #12030

Change-Id: I5d9cd925ef65cc34c5d4031c750f0f97794529b2
Reviewed-on: https://go-review.googlesource.com/30737
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2016-10-11 05:45:06 +00:00
John Dethridge
8f65379f94 cmd/link: more efficient encoding of DWARF line number information
The (pc, line) deltas in the line number information are currently encoded
either with a special opcode, or with a triplet of DW_LNS_advance_pc,
DW_LNS_advance_line, and DW_LNS_copy instructions.  Instead of DW_LNS_copy,
this change always uses a special opcode, which can make DW_LNS_advance_pc or
DW_LNS_advance_line unnecessary, or make their operands take fewer bytes.  It
chooses the special opcode so that the encoding of the remaining deltas is as
small as possible.

Use DW_LNS_const_add_pc or DW_LNS_fixed_advance_pc instead of DW_LNS_advance_pc
for deltas where they save a byte.

Update LINE_BASE and LINE_RANGE constants to optimal values for this strategy.

This reduces line number information by about 35% and total size by about 2%
for a typical binary.

Change-Id: Ia61d6bf19c95c1d34ba63c67ed32b376beda225f
Reviewed-on: https://go-review.googlesource.com/30577
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-11 01:42:35 +00:00
Russ Cox
3a9072829e math/big: make division faster
- Add new BenchmarkQuoRem.
- Eliminate allocation in divLarge nat pool
- Unroll mulAddVWW body 4x
- Remove some redundant slice loads in divLarge

name      old time/op  new time/op  delta
QuoRem-8  2.18µs ± 1%  1.93µs ± 1%  -11.38%  (p=0.000 n=19+18)

The starting point in the comparison here is Cherry's
pending CL to turn mulWW and divWW into intrinsics.
The optimizations in divLarge work best because all
the function calls are gone. The effect of this CL is not
as large if you don't assume Cherry's CL.

Change-Id: Ia6138907489c5b9168497912e43705634e163b35
Reviewed-on: https://go-review.googlesource.com/30613
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-10-10 18:50:23 +00:00
Cherry Zhang
68331750da cmd/compile: remove some write barriers for stack writes
This, along with CL 30140, removes ~50% of stack write barriers
mentioned in issue #17330. The remaining are most due to Phi and
FwdRef, which is not resolved when building SSA. We might be
able to do it at a later stage where Phi and Copy propagations
are done, but matching an if-(store-store-call)+ sequence seems
not very pleasant.

Updates #17330.

Change-Id: Iaa36c7b1f4c4fc3dc10a27018a3b0e261094cb21
Reviewed-on: https://go-review.googlesource.com/30290
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-10-10 13:15:04 +00:00
David Chase
2f0b8f88df cmd/compile: PPC64, elide unnecessary sign extension
Inputs to store[BHW] and cmpW(U) need not be correct
in more bits than are used by the instruction.

Added a pattern tailored to what appears to be cgo boilerplate.
Added a pattern (also seen in cgo boilerplate and hashing)
to replace {EQ,NE}-CMP-ANDconst with {EQ-NE}-ANDCCconst.
Added a pattern to clean up ANDconst shift distance inputs
(this was seen in hashing).

Simplify repeated and,or,xor.

Fixes #17109.

Change-Id: I68eac83e3e614d69ffe473a08953048c8b066d88
Reviewed-on: https://go-review.googlesource.com/30455
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-10-10 12:22:40 +00:00
Tal Shprecher
672e579444 cmd/compile: avoid leak of dottype expression on double assignment form
This is a followup to issue #13805. That change avoid leaks for types that
don't have any pointers for the single assignment form of a dottype expression.
This does the same for the double assignment form.

Fixes #15796

Change-Id: I27474cade0ff1f3025cb6392f47b87b33542bc0f
Reviewed-on: https://go-review.googlesource.com/24906
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-10-10 12:09:16 +00:00
Emmanuel Odeke
795289b114 net/http: fix typo in server commont
Change-Id: I5b04ba7e12eff933fc67eb7a1cbdfde536e4db88
Reviewed-on: https://go-review.googlesource.com/30722
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-10 04:06:49 +00:00
Anmol Sethi
334cbe3bc8 io: simplified a small part of copyBuffer
Change-Id: I0b7052103174f0864ee9714f76f8f78f2a988777
Reviewed-on: https://go-review.googlesource.com/30719
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-09 22:50:12 +00:00
Quentin Renard
5f1a013ea7 net/http: Add missing tests for parsePostForm
Renamed TestPOSTQuery to TestParseFormQuery and added testing
for the ";" delimiter, an empty key, an empty value and an
empty key + value.

Also added TestParseFormQueryMethods to make sure forms sent in
PATCH and PUT (and no others) request  are parsed correctly in
ParseForm.

Fixes #17368

Change-Id: I445aad324ffc7b38d179ea41953bffbac0cddffe
Reviewed-on: https://go-review.googlesource.com/30555
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-09 20:42:22 +00:00
Michael Munday
f13372c9f7 cmd/internal/obj/s390x: remove support for stores of global addresses
This CL removes support for MOVD instructions that store the address
of a global variable. For example:

  MOVD $main·a(SB), (R1)
  MOVD $main·b(SB), main·c(SB)

These instructions are emulated and the new backend doesn't need them
(the stores now always go through an intermediate register).

Change-Id: I3a1bcb3f19c5096ad0426afd76d35a4d7975733b
Reviewed-on: https://go-review.googlesource.com/30720
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-09 20:19:31 +00:00
Emmanuel Odeke
0ff40a76ad crypto/x509: check that the issuer name matches the issuer's subject name.
Fixes #14955.

Change-Id: I157432584bb51088bec565f6bb9e64348345cff9
Reviewed-on: https://go-review.googlesource.com/23571
Run-TryBot: Adam Langley <agl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
2016-10-09 20:05:42 +00:00
Wedson Almeida Filho
13c829e5f6 cmd/internal/obj/x86: On amd64, relocation type for and indirect call is pc-relative.
With this change, the code in bug #15609 compiles and runs properly:

0000000000401070 <main.jump>:
  401070:	ff 15 aa 7e 06 00    	callq  *0x67eaa(%rip)        # 468f20 <main.pointer>
  401076:	c3                   	retq

0000000000468f20 g     O .rodata	0000000000000008 main.pointer

Fixes #15609

Change-Id: Iebb4d5a9f9fff335b693f4efcc97882fe04eefd7
Reviewed-on: https://go-review.googlesource.com/22950
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-10-09 19:50:09 +00:00
Emmanuel Odeke
56d35d42e1 compress/gzip: document Reader.Read
Fixes #17374.

Change-Id: Ic89c35aaa31f35a8a4e3ffa09f49b68f08127625
Reviewed-on: https://go-review.googlesource.com/30718
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2016-10-09 00:22:59 +00:00
Mikio Hara
9b6ced931e vendor: update vendored lif
Updates golang_org/x/net/lif to rev 084869a for:
- lif: rename internal types and constants generated by cgo

Change-Id: Icf478d60f5ef35800966c62dcf046f7fe50204ff
Reviewed-on: https://go-review.googlesource.com/30731
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-08 00:02:11 +00:00
Mikio Hara
b108009d00 vendor: update vendored route
Updates golang_org/x/net/route to rev f09c466 for:
- route: fix typo
- route: test helper code cleanup

Change-Id: If39f0e947dc56f3b0f38190035d2f47c8d847c74
Reviewed-on: https://go-review.googlesource.com/30730
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-08 00:01:37 +00:00
Michael Munday
45b26a93f3 cmd/{asm,compile}: replace TESTB op with CMPWconst on s390x
TESTB was implemented as AND $0xff, Rx, REGTMP. Unfortunately there
is no 3-operand AND-with-immediate instruction and so it was emulated
by the assembler using two instructions.

This CL uses CMPW instead of AND and also optimizes CMPW to use
the chi instruction where possible.

Overall this CL reduces the size of the .text section of the
bin/go binary by ~2%.

Change-Id: Ic335c29fc1129378fcbb1265bfb10f5b744a0f3f
Reviewed-on: https://go-review.googlesource.com/30690
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-07 20:02:59 +00:00
Keith Randall
f4e37c8ec5 cmd/compile: use standard dom tree in nilcheckelim
No need to build a bespoke dom tree here when we might
have one cached already.  The allocations for the dom tree
were also more expensive than they needed to be.

Fixes #12021

Change-Id: I6a967880aee03660ad6fc293f8fc783779cae11d
Reviewed-on: https://go-review.googlesource.com/30671
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-07 20:02:47 +00:00
Andrew Pogrebnoy
433be563b6 cmd/compile: fix choice of phi building algorithm
The algorithm for placing a phi nodes in small functions now
unreachable. This patch fix that.

Change-Id: I253d745b414fa12ee0719459c28e78a69c6861ae
Reviewed-on: https://go-review.googlesource.com/30106
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-10-07 19:44:07 +00:00
Austin Clements
94589054d3 cmd/trace: label mark termination spans as such
Currently these are labeled "MARK", which was accurate in the STW
collector, but these really indicate mark termination now, since
marking happens for the full duration of the concurrent GC. Re-label
them as "MARK TERMINATION" to clarify this.

Change-Id: Ie98bd961195acde49598b4fa3f9e7d90d757c0a6
Reviewed-on: https://go-review.googlesource.com/30018
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-10-07 18:33:23 +00:00
Austin Clements
eed309f5fb cmd/trace: move process-wide GC events to their own row
Currently, the process-wide GC state is attributed to the P that
happened to perform the allocation that exceeded the GC trigger. This
is pretty arbitrary and makes it hard to see when GC is running since
the GC spans are intermingled with a lot of other trace noise.

The current display is particularly confusing because it creates three
sub-rows in the P row that can overlap each other. Usually a P has
just two sub-rows: one showing the current G and another showing that
G's activity. However, because GC is attributed to a proc, it winds up
as a third row that neither subsumes nor is subsumed by any other row.
This in turn screws up the trace's layout and results in overlapping
events.

Fix these problems by creating a new dedicated row like the existing
"Network" and "Timer" rows and displaying process-wide GC events in
this row. Mark termination and sweep events still appear in their
respective P rows because these are meaningfully attributed.

Change-Id: Ie1a1c6cf8c446e4b043f10f3968f91ff1b546d15
Reviewed-on: https://go-review.googlesource.com/30017
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-10-07 18:33:12 +00:00
Austin Clements
fa9b57bb1d runtime: make next_gc ^0 when GC is disabled
When GC is disabled, we set gcpercent to -1. However, we still use
gcpercent to compute several values, such as next_gc and gc_trigger.
These calculations are meaningless when gcpercent is -1 and result in
meaningless values. This is okay in a sense because we also never use
these values if gcpercent is -1, but they're confusing when exposed to
the user, for example via MemStats or the execution trace. It's
particularly unfortunate in the execution trace because it attempts to
plot the underflowed value of next_gc, which scales all useful
information in the heap row into oblivion.

Fix this by making next_gc ^0 when gcpercent < 0. This has the
advantage of being true in a way: next_gc is effectively infinite when
gcpercent < 0. We can also detect this special value when updating the
execution trace and report next_gc as 0 so it doesn't blow up the
display of the heap line.

Change-Id: I4f366e4451f8892a4908da7b2b6086bdc67ca9a9
Reviewed-on: https://go-review.googlesource.com/30016
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-07 18:32:51 +00:00
Keith Randall
93d5f43a29 cmd/compile: do regalloc check only when checkEnabled
No point doing this check all the time.

Fixes #15621

Change-Id: I1966c061986fe98fe9ebe146d6b9738c13cef724
Reviewed-on: https://go-review.googlesource.com/30670
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-07 17:33:15 +00:00
Russ Cox
0db9518ab3 fmt: document and adjust Scanf space handling to eliminate a few paradoxes
This CL makes minor adjustment to the handling of spaces and newlines
and then documents the result.

The semantic adjustment mainly concerns the handling of a run of
spaces following a newline in the format, like in "\n ".
Previously, that run of spaces was ignored entirely, leading to paradoxes
like the format "1 \n 2" not matching itself as input.
Now, spaces following a newline in the format match zero or more
spaces following the corresponding newline in the input.

The changes to the test suite show how minor the semantic adjustments are
and how they make the behavior more regular than previously.

This CL also updates the documentation to explain the handling of
spaces more precisely, incorporating the draft from CL 17723 but
describing the newly introduced behavior.

Fixes #13565.

Change-Id: I129666e9ba42de3c28b67f75cb47488e9a4c1867
Reviewed-on: https://go-review.googlesource.com/30611
Reviewed-by: Rob Pike <r@golang.org>
2016-10-07 03:46:50 +00:00
Russ Cox
23606c6fc4 fmt: add tests showing current Scanf space handling
There are no semantic changes here, just tests to establish
the status quo. A followup CL will make some semantic changes,
the (limited) scope of which should be clear from the number of
tests that change.

For #13565.

Change-Id: I960749cf59d4dfe39c324875bcc575096654f883
Reviewed-on: https://go-review.googlesource.com/30610
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-10-07 03:46:40 +00:00
Matthew Dempsky
78a267e379 cmd/compile: cache pointer and slice types
Anonymous pointer and slice types are very common and identical
anyway, so just reuse them rather than allocating new ones everywhere
they appear.

Turns out to be a small code/stack size win because SSA relies on
gc.Type identity for reusing temporary stack slots:

   text	   data	    bss	    dec	    hex	filename
6453005	 231643	 146328	6830976	 683b80	go.old
6446660	 231643	 146328	6824631	 6822b7	go.new

Saves on memory usage during compile time too, and maybe a small CPU
time win, but the benchmarks are pretty noisy:

name       old time/op     new time/op     delta
Template       342ms ± 8%      339ms ± 9%    ~           (p=0.332 n=99+99)
Unicode        183ms ± 9%      181ms ±11%    ~           (p=0.274 n=95+98)
GoTypes        1.05s ± 4%      1.04s ± 3%  -1.22%        (p=0.000 n=97+95)
Compiler       4.49s ± 7%      4.46s ± 6%    ~           (p=0.058 n=96+91)

name       old user-ns/op  new user-ns/op  delta
Template        520M ±17%       522M ±20%    ~          (p=0.544 n=98+100)
Unicode         331M ±27%       327M ±30%    ~           (p=0.615 n=98+98)
GoTypes        1.54G ±10%      1.53G ±12%    ~          (p=0.173 n=99+100)
Compiler       6.33G ±10%      6.33G ±10%    ~           (p=0.682 n=98+98)

name       old alloc/op    new alloc/op    delta
Template      44.5MB ± 0%     44.1MB ± 0%  -0.80%        (p=0.000 n=97+99)
Unicode       37.5MB ± 0%     37.3MB ± 0%  -0.44%       (p=0.000 n=98+100)
GoTypes        126MB ± 0%      124MB ± 0%  -1.41%        (p=0.000 n=98+99)
Compiler       518MB ± 0%      508MB ± 0%  -1.90%       (p=0.000 n=98+100)

name       old allocs/op   new allocs/op   delta
Template        441k ± 0%       434k ± 0%  -1.76%       (p=0.000 n=100+97)
Unicode         368k ± 0%       365k ± 0%  -0.69%        (p=0.000 n=99+99)
GoTypes        1.26M ± 0%      1.23M ± 0%  -2.27%       (p=0.000 n=100+99)
Compiler       4.60M ± 0%      4.46M ± 0%  -2.96%       (p=0.000 n=100+99)

Change-Id: I94abce5c57aed0f9c48f567b3ac24c627d4c7c91
Reviewed-on: https://go-review.googlesource.com/30632
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-07 00:04:40 +00:00
Ian Lance Taylor
15937ccb89 runtime: fix sigset type for ppc64 big-endian GNU/Linux
On 64-bit big-endian GNU/Linux machines we need to treat sigset as a
single uint64, not as a pair of uint32 values. This fix was already made
for s390x, but not for ppc64 (which is big-endian--the little endian
version is known as ppc64le). So copy os_linux_390.x to
os_linux_be64.go, and use build constraints as needed.

Fixes #17361

Change-Id: Ia0eb18221a8f5056bf17675fcfeb010407a13fb0
Reviewed-on: https://go-review.googlesource.com/30602
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-06 22:24:40 +00:00
Robert Griesemer
95a6572b2b math/big: Rat.SetString to report error if input is not consumed entirely
Also, document behavior explicitly for all SetString implementations.

Fixes #17001.

Change-Id: Iccc882b4bc7f8b61b6092f330e405c146a80dc98
Reviewed-on: https://go-review.googlesource.com/30472
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-10-06 20:37:01 +00:00
Brad Fitzpatrick
4103fedf19 runtime: skip gdb tests on linux/ppc64 for now
Updates #17366

Change-Id: Ia4bd3c74c48b85f186586184a7c2b66d3b80fc9c
Reviewed-on: https://go-review.googlesource.com/30596
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-10-06 19:52:09 +00:00
Alexander Döring
7b4a224667 math/cmplx: add examples for Abs, Exp, Polar
Updates #16360

Change-Id: I941519981ff5bda3a113e14fa6be718eb4d2bf83
Reviewed-on: https://go-review.googlesource.com/30554
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-06 19:49:12 +00:00
Brad Fitzpatrick
1c09b4dde6 time: document that calendrical calculations are with no leap seconds
Fixes #15247

Change-Id: I942fb2eacd1b54bab66cc147a6b047a3ffce0b84
Reviewed-on: https://go-review.googlesource.com/30595
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-06 19:43:14 +00:00
Yasuhiro Matsumoto
4c79ed5f44 archive/zip: handle mtime in NTFS/UNIX/ExtendedTS extra fields
Handle NTFS timestamp, UNIX timestamp, Extended extra timestamp.
Writer supports only Extended extra timestamp field, matching most
zip creators.

Fixes #10242.

Change-Id: Id665db274e63def98659231391fb77392267ac1e
Reviewed-on: https://go-review.googlesource.com/18274
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-06 19:05:52 +00:00
Michael Munday
122abe6b12 cmd/compile: fold extensions into constants on s390x
We insert extensions when lowering comparisons and they were
blocking constant folding.

Change-Id: I804bbf91c7606612ffe921a90853844a57e55955
Reviewed-on: https://go-review.googlesource.com/30541
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-06 18:57:43 +00:00
Simon Rawet
b4f3c9339e time: fix AddDate with nil location
AddDate now retrieves location from t.Location() to ensure that
it never calls Date with a nil location.

Added test for this bug on all Time's methods

Fixes #15852

Change-Id: Id2a222af56993f741ad0b802a2c3b89e8e463926
Reviewed-on: https://go-review.googlesource.com/23561
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2016-10-06 18:41:23 +00:00
Hajime Hoshi
fc47ee2332 cmd/compile/internal/gc: unexport global variable Pc
Change-Id: Id2a9fc1e9e70eaf5f25ddc7476061e06abcf60e4
Reviewed-on: https://go-review.googlesource.com/30573
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-10-06 17:43:45 +00:00
Robert Griesemer
33faa4ebb9 go/importer: better error messages when export data is not found
Fixes #17281.

Change-Id: I4e639998dbe3baa98879f1becc37d7c4d19351e7
Reviewed-on: https://go-review.googlesource.com/30473
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-10-06 17:38:35 +00:00
Cherry Zhang
8aadcc551e cmd/compile: intrinsify math.Sqrt when compiling "math" itself
Fixes #17354.

Change-Id: I0e018c8c3e791fc6cc1925dbbc18c2151ba9a111
Reviewed-on: https://go-review.googlesource.com/30539
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-06 14:57:00 +00:00
Russ Cox
4f3a641e6e math: fix Gamma(-171.5) on all platforms
Using 387 mode was computing it without underflow to zero,
apparently due to an 80-bit intermediate. Avoid underflow even
with 64-bit floats.

This eliminates the TODOs in the test suite.

Fixes linux-386-387 build and fixes #11441.

Change-Id: I8abaa63bfdf040438a95625d1cb61042f0302473
Reviewed-on: https://go-review.googlesource.com/30540
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-06 14:53:09 +00:00
Richard Gibson
20c48c9557 encoding/json: explicitly document and test "-" key tag
Struct fields can be suppressed in JSON serialization by "-" tags, but
that doesn't preclude generation of "-" object keys.
Document and verify the mechanism for doing so.

Change-Id: I7f60e1759cfee15cb7b2447cd35fab91c5b004e6
Reviewed-on: https://go-review.googlesource.com/21204
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-06 14:42:16 +00:00
Michael Munday
91706c04b9 cmd/asm, cmd/internal/obj/s390x: delete unused instructions
Deletes the following s390x instructions:

 - ADDME
 - ADDZE
 - SUBME
 - SUBZE

They appear to be emulated PPC instructions left over from the
porting process and I don't think they will ever be useful.

Change-Id: I9b1ba78019dbd1218d0c8f8ea2903878802d1990
Reviewed-on: https://go-review.googlesource.com/30538
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-06 11:45:48 +00:00
Denis Nagorny
d7507e9d11 runtime: improve memmove for amd64
Use AVX if available on 4th generation of Intel(TM) Core(TM) processors.

    (collected on E5 2609v3 @1.9GHz)
    name                        old speed      new speed       delta
    Memmove/1-6                  158MB/s ± 0%    172MB/s ± 0%    +9.09% (p=0.000 n=16+16)
    Memmove/2-6                  316MB/s ± 0%    345MB/s ± 0%    +9.09% (p=0.000 n=18+16)
    Memmove/3-6                  517MB/s ± 0%    517MB/s ± 0%      ~ (p=0.445 n=16+16)
    Memmove/4-6                  687MB/s ± 1%    690MB/s ± 0%    +0.35% (p=0.000 n=20+17)
    Memmove/5-6                  729MB/s ± 0%    729MB/s ± 0%    +0.01% (p=0.000 n=16+18)
    Memmove/6-6                  875MB/s ± 0%    875MB/s ± 0%    +0.01% (p=0.000 n=18+18)
    Memmove/7-6                 1.02GB/s ± 0%   1.02GB/s ± 1%      ~ (p=0.139 n=19+20)
    Memmove/8-6                 1.26GB/s ± 0%   1.26GB/s ± 0%    +0.00% (p=0.000 n=18+18)
    Memmove/9-6                 1.42GB/s ± 0%   1.42GB/s ± 0%    +0.00% (p=0.000 n=17+18)
    Memmove/10-6                1.58GB/s ± 0%   1.58GB/s ± 0%    +0.00% (p=0.000 n=19+19)
    Memmove/11-6                1.74GB/s ± 0%   1.74GB/s ± 0%    +0.00% (p=0.001 n=18+17)
    Memmove/12-6                1.90GB/s ± 0%   1.90GB/s ± 0%    +0.00% (p=0.000 n=19+19)
    Memmove/13-6                2.05GB/s ± 0%   2.05GB/s ± 0%    +0.00% (p=0.000 n=18+19)
    Memmove/14-6                2.21GB/s ± 0%   2.21GB/s ± 0%    +0.00% (p=0.000 n=16+20)
    Memmove/15-6                2.37GB/s ± 0%   2.37GB/s ± 0%    +0.00% (p=0.004 n=19+20)
    Memmove/16-6                2.53GB/s ± 0%   2.53GB/s ± 0%    +0.00% (p=0.000 n=16+16)
    Memmove/32-6                4.67GB/s ± 0%   4.67GB/s ± 0%    +0.00% (p=0.000 n=17+17)
    Memmove/64-6                8.67GB/s ± 0%   8.64GB/s ± 0%    -0.33% (p=0.000 n=18+17)
    Memmove/128-6               12.6GB/s ± 0%   11.6GB/s ± 0%    -8.05% (p=0.000 n=16+19)
    Memmove/256-6               16.3GB/s ± 0%   16.6GB/s ± 0%    +1.66% (p=0.000 n=20+18)
    Memmove/512-6               21.5GB/s ± 0%   24.4GB/s ± 0%   +13.35% (p=0.000 n=18+17)
    Memmove/1024-6              24.7GB/s ± 0%   33.7GB/s ± 0%   +36.12% (p=0.000 n=18+18)
    Memmove/2048-6              27.3GB/s ± 0%   43.3GB/s ± 0%   +58.77% (p=0.000 n=19+17)
    Memmove/4096-6              37.5GB/s ± 0%   50.5GB/s ± 0%   +34.56% (p=0.000 n=19+19)
    MemmoveUnalignedDst/1-6      135MB/s ± 0%    146MB/s ± 0%    +7.69% (p=0.000 n=16+14)
    MemmoveUnalignedDst/2-6      271MB/s ± 0%    292MB/s ± 0%    +7.69% (p=0.000 n=18+18)
    MemmoveUnalignedDst/3-6      438MB/s ± 0%    438MB/s ± 0%      ~ (p=0.352 n=16+19)
    MemmoveUnalignedDst/4-6      584MB/s ± 0%    584MB/s ± 0%      ~ (p=0.876 n=17+17)
    MemmoveUnalignedDst/5-6      631MB/s ± 1%    632MB/s ± 0%    +0.25% (p=0.000 n=20+17)
    MemmoveUnalignedDst/6-6      759MB/s ± 0%    759MB/s ± 0%    +0.00% (p=0.000 n=19+16)
    MemmoveUnalignedDst/7-6      885MB/s ± 0%    883MB/s ± 1%      ~ (p=0.647 n=18+20)
    MemmoveUnalignedDst/8-6     1.08GB/s ± 0%   1.08GB/s ± 0%    +0.00% (p=0.035 n=19+18)
    MemmoveUnalignedDst/9-6     1.22GB/s ± 0%   1.22GB/s ± 0%      ~ (p=0.251 n=18+17)
    MemmoveUnalignedDst/10-6    1.35GB/s ± 0%   1.35GB/s ± 0%      ~ (p=0.327 n=17+18)
    MemmoveUnalignedDst/11-6    1.49GB/s ± 0%   1.49GB/s ± 0%      ~ (p=0.531 n=18+19)
    MemmoveUnalignedDst/12-6    1.63GB/s ± 0%   1.63GB/s ± 0%      ~ (p=0.886 n=19+18)
    MemmoveUnalignedDst/13-6    1.76GB/s ± 0%   1.76GB/s ± 1%    -0.24% (p=0.006 n=18+20)
    MemmoveUnalignedDst/14-6    1.90GB/s ± 0%   1.90GB/s ± 0%      ~ (p=0.818 n=20+19)
    MemmoveUnalignedDst/15-6    2.03GB/s ± 0%   2.03GB/s ± 0%      ~ (p=0.294 n=17+16)
    MemmoveUnalignedDst/16-6    2.17GB/s ± 0%   2.17GB/s ± 0%      ~ (p=0.602 n=16+18)
    MemmoveUnalignedDst/32-6    4.05GB/s ± 0%   4.05GB/s ± 0%    +0.00% (p=0.010 n=18+17)
    MemmoveUnalignedDst/64-6    7.59GB/s ± 0%   7.59GB/s ± 0%    +0.00% (p=0.022 n=18+16)
    MemmoveUnalignedDst/128-6   11.1GB/s ± 0%   11.4GB/s ± 0%    +2.79% (p=0.000 n=18+17)
    MemmoveUnalignedDst/256-6   16.4GB/s ± 0%   16.7GB/s ± 0%    +1.59% (p=0.000 n=20+17)
    MemmoveUnalignedDst/512-6   15.7GB/s ± 0%   21.3GB/s ± 0%   +35.87% (p=0.000 n=18+20)
    MemmoveUnalignedDst/1024-6  16.0GB/s ±20%   31.5GB/s ± 0%   +96.93% (p=0.000 n=20+14)
    MemmoveUnalignedDst/2048-6  19.6GB/s ± 0%   42.1GB/s ± 0%  +115.16% (p=0.000 n=17+18)
    MemmoveUnalignedDst/4096-6  6.41GB/s ± 0%  33.18GB/s ± 0%  +417.56% (p=0.000 n=17+18)
    MemmoveUnalignedSrc/1-6      171MB/s ± 0%    166MB/s ± 0%    -3.33% (p=0.000 n=19+16)
    MemmoveUnalignedSrc/2-6      343MB/s ± 0%    342MB/s ± 1%    -0.41% (p=0.000 n=17+20)
    MemmoveUnalignedSrc/3-6      508MB/s ± 0%    493MB/s ± 1%    -2.90% (p=0.000 n=17+17)
    MemmoveUnalignedSrc/4-6      677MB/s ± 0%    660MB/s ± 2%    -2.55% (p=0.000 n=17+20)
    MemmoveUnalignedSrc/5-6      790MB/s ± 0%    790MB/s ± 0%      ~ (p=0.139 n=17+17)
    MemmoveUnalignedSrc/6-6      948MB/s ± 0%    946MB/s ± 1%      ~ (p=0.330 n=17+19)
    MemmoveUnalignedSrc/7-6     1.11GB/s ± 0%   1.11GB/s ± 0%    -0.05% (p=0.026 n=17+17)
    MemmoveUnalignedSrc/8-6     1.38GB/s ± 0%   1.38GB/s ± 0%      ~ (p=0.091 n=18+16)
    MemmoveUnalignedSrc/9-6     1.42GB/s ± 0%   1.40GB/s ± 1%    -1.04% (p=0.000 n=19+20)
    MemmoveUnalignedSrc/10-6    1.58GB/s ± 0%   1.56GB/s ± 1%    -1.15% (p=0.000 n=18+19)
    MemmoveUnalignedSrc/11-6    1.73GB/s ± 0%   1.71GB/s ± 1%    -1.30% (p=0.000 n=20+20)
    MemmoveUnalignedSrc/12-6    1.89GB/s ± 0%   1.87GB/s ± 1%    -1.18% (p=0.000 n=17+20)
    MemmoveUnalignedSrc/13-6    2.05GB/s ± 0%   2.02GB/s ± 1%    -1.18% (p=0.000 n=17+20)
    MemmoveUnalignedSrc/14-6    2.21GB/s ± 0%   2.18GB/s ± 1%    -1.14% (p=0.000 n=17+20)
    MemmoveUnalignedSrc/15-6    2.36GB/s ± 0%   2.34GB/s ± 1%    -1.04% (p=0.000 n=17+20)
    MemmoveUnalignedSrc/16-6    2.52GB/s ± 0%   2.49GB/s ± 1%    -1.26% (p=0.000 n=19+20)
    MemmoveUnalignedSrc/32-6    4.82GB/s ± 0%   4.61GB/s ± 0%    -4.40% (p=0.000 n=19+20)
    MemmoveUnalignedSrc/64-6    5.03GB/s ± 4%   7.97GB/s ± 0%   +58.55% (p=0.000 n=20+16)
    MemmoveUnalignedSrc/128-6   11.1GB/s ± 0%   11.2GB/s ± 0%    +0.52% (p=0.000 n=17+18)
    MemmoveUnalignedSrc/256-6   16.5GB/s ± 0%   16.4GB/s ± 0%    -0.10% (p=0.000 n=20+18)
    MemmoveUnalignedSrc/512-6   21.0GB/s ± 0%   22.1GB/s ± 0%    +5.48% (p=0.000 n=14+17)
    MemmoveUnalignedSrc/1024-6  24.9GB/s ± 0%   31.9GB/s ± 0%   +28.20% (p=0.000 n=19+20)
    MemmoveUnalignedSrc/2048-6  23.3GB/s ± 0%   33.8GB/s ± 0%   +45.22% (p=0.000 n=17+19)
    MemmoveUnalignedSrc/4096-6  37.3GB/s ± 0%   42.7GB/s ± 0%   +14.30% (p=0.000 n=17+17)

Change-Id: Id66aa3e499ccfb117cb99d623ef326b50d057b64
Reviewed-on: https://go-review.googlesource.com/29590
Run-TryBot: Denis Nagorny <denis.nagorny@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-10-06 10:21:58 +00:00
Michael Munday
dd1dcf9496 cmd/{asm,compile}: add ANDW, ORW and XORW instructions to s390x
Adds the following instructions and uses them in the SSA backend:

 - ANDW
 - ORW
 - XORW

The instruction encodings for 32-bit operations are typically shorter,
particularly when an immediate is used. For example, XORW $-1, R1
only requires one instruction, whereas XOR requires two.

Also removes some unused instructions (that were emulated):

 - ANDN
 - NAND
 - ORN
 - NOR

Change-Id: Iff2a16f52004ba498720034e354be9771b10cac4
Reviewed-on: https://go-review.googlesource.com/30291
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-10-06 02:59:04 +00:00
Keith Randall
1bddd2ee6a cmd/compile: don't shuffle rematerializeable values around
Better to just rematerialize them when needed instead of
cross-register spilling or other techniques for keeping them in
registers.

This helps for amd64 code that does 1 << x. It is better to do
  loop:
    MOVQ $1, AX  // materialize arg to SLLQ
    SLLQ CX, AX
    ...
    goto loop
than to do
  MOVQ $1, AX    // materialize outsize of loop
  loop:
    MOVQ AX, DX  // save value that's about to be clobbered
    SLLQ CX, AX
    MOVQ DX, AX  // move it back to the correct register
    goto loop

Update #16092

Change-Id: If7ac290208f513061ebb0736e8a79dcb0ba338c0
Reviewed-on: https://go-review.googlesource.com/30471
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2016-10-06 02:46:43 +00:00
Ian Lance Taylor
e5421e21ef runtime: add threadprof tag for test that starts busy thread
The CgoExternalThreadSIGPROF test starts a thread at constructor time
that does a busy loop. That can throw off some other tests. So only
build that code if testprogcgo is built with the tag threadprof, and
adjust the tests that use that code to pass that build tag.

This revealed that the CgoPprofThread test was not testing what it
should have, as it never actually started the cpuHog thread. It was
passing because of the busy loop thread. Fix it to start the thread as
intended.

Change-Id: I087a9e4fc734a86be16a287456441afac5676beb
Reviewed-on: https://go-review.googlesource.com/30362
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-06 01:23:09 +00:00
Larz Conwell
5fd6bb4c14 go/doc: hide methods on locally-declared predeclared types
Currently if you declare a type overwriting a predeclared type
and export methods on it they will be exposed in godoc, even
though the type itself is not exported. This corrects that
by making all methods on these types hidden, since that's
the expected output.

Fixes #9860

Change-Id: I14037bdcef1b4bbefcf299a143bac8bf363718e0
Reviewed-on: https://go-review.googlesource.com/20610
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-06 00:35:30 +00:00
Jaana Burcu Dogan
eee727d085 cmd/go: note when some Go files were ignored on no-Go-files errors
It is pretty confusing when there are Go files ignored for mismatching
build tags and similar and we output "no buildable Go files" without
giving any other information about some Go files have been ignored.

Fixes #17008.

Change-Id: I1766ee86a9a7a72f6694deae3f73b47bfc9d0be5
Reviewed-on: https://go-review.googlesource.com/29113
Run-TryBot: Jaana Burcu Dogan <jbd@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-06 00:28:04 +00:00
Dmitriy Dudkin
6abc4a7c3e cmd/go: fix go get -u wildcard corner case
Suppose you have already downloaded "foo.bar/baz", where the repo
is for all of foo.bar/, and you then "go get -u foo.bar/...".
The command-line wildcard expands to foo.bar/baz,
and go get updates the foo.bar/ repo.
Suppose that the repo update brought in foo.bar/quux,
though, which depends on other.site/bar.
Download does not consider foo.bar/quux, since it's
only looking at foo.bar/baz, so it didn't download other.site/bar.
After the download, we call importPaths(args) to decide what to install.
That call was reevaluating the original wildcard with the new repo
and matching foo.bar/quux, which was missing its dependency
other.site/bar, causing a build failure.

The fix in this CL is to remember the pre-download expansion
of the argument list and pass it to the installer. Then only the things
we tried to download get installed.

The case where foo.bar/ is not even checked out yet continues to work,
because in that case we leave the wildcard in place, and download
reevaluates it during the download.

The fix in this CL may not be the right long-term fix, but it is at least a fix.
It may be that download should be passed all the original wildcards
so that it can reexpand them as new code is downloaded, ideally reaching
a fixed point. That can be left for another day.

In short:

- The problem is that the "install" half of "go get" was trying to install
  more than the "download" half was properly downloading.
- The fix in this CL is to install just what was downloaded (install less).
- It may be that a future CL should instead download what will be installed (download more).

Fixes #14450.

Change-Id: Ia1984761d24439549b7cff322bc0dbc262c1a653
Reviewed-on: https://go-review.googlesource.com/19892
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-05 23:53:29 +00:00
Lynn Boger
3107c91e2d runtime: memclr perf improvements on ppc64x
This updates runtime/memclr_ppc64x.s to improve performance,
by unrolling loops for larger clears.

Fixes #17348

benchmark                    old MB/s     new MB/s     speedup
BenchmarkMemclr/5-80         199.71       406.63       2.04x
BenchmarkMemclr/16-80        693.66       1817.41      2.62x
BenchmarkMemclr/64-80        2309.35      5793.34      2.51x
BenchmarkMemclr/256-80       5428.18      14765.81     2.72x
BenchmarkMemclr/4096-80      8611.65      27191.94     3.16x
BenchmarkMemclr/65536-80     8736.69      28604.23     3.27x
BenchmarkMemclr/1M-80        9304.94      27600.09     2.97x
BenchmarkMemclr/4M-80        8705.66      27589.64     3.17x
BenchmarkMemclr/8M-80        8575.74      23631.04     2.76x
BenchmarkMemclr/16M-80       8443.10      19240.68     2.28x
BenchmarkMemclr/64M-80       8390.40      9493.04      1.13x
BenchmarkGoMemclr/5-80       263.05       630.37       2.40x
BenchmarkGoMemclr/16-80      904.33       1148.49      1.27x
BenchmarkGoMemclr/64-80      2830.20      8756.70      3.09x
BenchmarkGoMemclr/256-80     6064.59      20299.46     3.35x

Change-Id: Ic76c9183c8b4129ba3df512ca8b0fe6bd424e088
Reviewed-on: https://go-review.googlesource.com/30373
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <munday@ca.ibm.com>
Reviewed-by: David Chase <drchase@google.com>
2016-10-05 22:18:14 +00:00
Quentin Smith
ce645534e4 crypto/x509: support RHEL 7 cert bundle
RHEL 7 introduces a new tool, update-ca-trust(8), which places the
certificate bundle in a new location. Add this path to the list of
locations that are searched for the certificate bundle.

Fixes #15749

Change-Id: Idc97f885ee48ef085f1eb4dacbd1c2cf55f94ff5
Reviewed-on: https://go-review.googlesource.com/30375
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-05 22:12:09 +00:00
Robert Griesemer
936ae27b9c cmd/compile: untyped arrays bounds representable as integers are valid
Fixes #13485.

Change-Id: I11dd15c7d14fc19d42a3b48427a4cc1208b18e6a
Reviewed-on: https://go-review.googlesource.com/30456
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-10-05 22:07:58 +00:00
Joe Tsai
f6b4c88941 Revert "net/http: improve performance for parsePostForm"
This reverts commit 59320c396e.

Reasons:
This CL was causing failures on a large regression test that we run
within Google. The issues arises from two bugs in the CL:
* The CL dropped support for ';' as a delimiter (see https://golang.org/issue/2210)
* The handling of an empty string caused an empty record to be added when
no record was added (see https://golang.org/cl/30454 for my attempted fix)

The logic being added is essentially a variation of url.ParseQuery,
but altered to accept an io.Reader instead of a string.
Since it is duplicated (but modified) logic, there needs to be good
tests to ensure that it's implementation doesn't drift in functionality
from url.ParseQuery. Fixing the above issues and adding the associated
regression tests leads to >100 lines of codes.
For a 4% reduction in CPU time, I think this complexity and duplicated
logic is not worth the effort.

As such, I am abandoning my efforts to fix the existing issues and
believe that reverting CL/20301 is the better course of action.

Updates #14655

Change-Id: Ibb5be0a5b48a16c46337e213b79467fcafee69df
Reviewed-on: https://go-review.googlesource.com/30470
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-05 21:48:27 +00:00
Alexander Döring
a9b4953777 os/exec: add example for CommandContext
Updates #16360

Change-Id: I0e0afe7a89f2ebcb3e5bbc345f77a605d3afc398
Reviewed-on: https://go-review.googlesource.com/30103
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-05 21:30:14 +00:00
Jirka Daněk
b9fd510cd0 encoding/json: add struct and field name to UnmarshalTypeError message
The UnmarshalTypeError has two new fields Struct and Field,
used when constructing the error message.

Fixes #6716.

Change-Id: I67da171480a9491960b3ae81893770644180f848
Reviewed-on: https://go-review.googlesource.com/18692
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-05 20:28:59 +00:00
Quentin Smith
cb986def67 syscall: relax TestUnshare
Fixes #17224.

Some systems have more than just "lo" in a fresh network namespace, due
to IPv6. Instead of testing for exactly 3 lines of output (implying 1
interface), just test to make sure that the unshare call resulted in
fewer interfaces than before. This should still verify that unshare did
something.

Change-Id: Iaf84c2b0e673fc207059d62e2f4dd7583a753419
Reviewed-on: https://go-review.googlesource.com/30372
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Jessica Frazelle <me@jessfraz.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-05 19:30:42 +00:00