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

21771 Commits

Author SHA1 Message Date
Burcu Dogan
6df8038768 runtime: listen 127.0.0.1 instead of localhost on android
Fixes #14486.
Related to #14485.

Change-Id: I2dd77b0337aebfe885ae828483deeaacb500b12a
Reviewed-on: https://go-review.googlesource.com/20340
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-08 00:22:38 +00:00
Matthew Dempsky
e853131699 cmd/internal/obj: stop using as+ALAST as an opcode
Currently, package obj reserves a range of 1<<12 opcodes for each
target architecture.  E.g., mips64 has [6<<12, 7<<12).

However, because mips.ABEQ and mips.ALAST are both within that range,
the expression mips.ABEQ+mips.ALAST in turn falls (far) outside that
range around 12<<12, meaning it could theoretically collide with
another arch's opcodes.

More practically, it's a problem because 12<<12 overflows an int16,
which hampers fixing #14692.  (We could also just switch to uint16 to
avoid the overflow, but that still leaves the first problem.)

As a workaround, use Michael Hudson-Doyle's solution from
https://golang.org/cl/20182 and use negative values for these variant
instructions.

Passes toolstash -cmp for GOARCH=arm and GOARCH=mips64.

Updates #14692.

Change-Id: Iad797d10652360109fa4db19d4d1edb6529fc2c0
Reviewed-on: https://go-review.googlesource.com/20345
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-08 00:11:15 +00:00
Brad Fitzpatrick
399f0f5fe8 go/build: introduce go1.7 build tag
This is needed now for subrepos to be able to conditionally use
API symbols found only after Go 1.6.

Change-Id: Ie7d9301332aa1739b585d93f8025424ae72a2430
Reviewed-on: https://go-review.googlesource.com/20344
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-07 23:48:25 +00:00
Caio Marcelo de Oliveira Filho
bd68b8abc2 net/http: TimeoutHandler should start timer when serving request
TimeoutHandler was starting the Timer when the handler was created,
instead of when serving a request. It also was sharing it between
multiple requests, which is incorrect, as the requests might start
at different times.

Store the timeout duration and create the Timer when ServeHTTP is
called. Different requests will have different timers.

The testing plumbing was simplified to store the channel used to
control when timeout happens. It overrides the regular timer.

Fixes #14568.

Change-Id: I4bd51a83f412396f208682d3ae5e382db5f8dc81
Reviewed-on: https://go-review.googlesource.com/20046
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-07 23:42:19 +00:00
Ian Lance Taylor
6c4e90a99e cmd/compile: change Node fields from *NodeList to Nodes
Compile time is about the same.  Getting rid of the nodeSeq interfaces,
particularly nodeSeqIterate, should produce some improvements.

Passes toolstash -cmp.

Update #14473.

Change-Id: I678abafdd9129c6cccb0ec980511932eaed496a0
Reviewed-on: https://go-review.googlesource.com/20343
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-07 23:32:49 +00:00
Josh Bleecher Snyder
a81283d5d9 cmd/compile: inline list storage stealing
It is only necessary in a few places, and this inlining will
simplify the transition away from NodeLists.

Passes toolstash -cmp.

Change-Id: I4ee9b4bf56ffa04df23e20a0a83b302d36b33510
Reviewed-on: https://go-review.googlesource.com/20290
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-07 23:05:05 +00:00
Konstantin Shaposhnikov
b8a2e25f55 cmd/vet: remove -test flag
-test flag is a testing only flag that enables all vet checks. It was needed
because there was no way to run all vet checks in a single command
invocation. However it is possible to do this now by combining -all and -shadow
flags.

Also a recently added -tests flag is similarly named, having both -test and
-tests can be confusing.

Change-Id: Ie5bacbe0bef5c8409eeace46f16141fa4e782c32
Reviewed-on: https://go-review.googlesource.com/20006
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-07 22:54:38 +00:00
Josh Bleecher Snyder
bcce5bdabd cmd/compile: remove NodeList != NodeList comparisons
Opt for replacements that avoid any assumptions
about the representations in use.

Passes toolstash -cmp.

Change-Id: Ia858a33abcae344e03fc1862fc9b0e192fde80c1
Reviewed-on: https://go-review.googlesource.com/20279
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-07 22:46:51 +00:00
Josh Bleecher Snyder
8969ab89b8 cmd/compile: add sizeof test for ssa types
Fix some test output while we're here.

Change-Id: I265cedc222e078eff120f268b92451e12b0400b2
Reviewed-on: https://go-review.googlesource.com/20294
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-07 22:41:22 +00:00
Brad Fitzpatrick
40e60e7c13 os, syscall: skip tests when environment doesn't permit testing
Fixes #14693

Change-Id: Id0a6a80b4c37c0b0f1c2755667b7233ed8964e40
Reviewed-on: https://go-review.googlesource.com/20342
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-07 22:40:50 +00:00
Austin Clements
2b19b6e3f1 runtime: fix checkmark scanning of finalizers
Currently work.finalizersDone is reset only at the beginning of
gcStart. As a result, it will be set when checkmark runs, so checkmark
will skip scanning finalizers. Hence, if there are any bugs that cause
the regular scan of finalizers to miss pointers, checkmark will also
miss them and fail to detect the missed pointer.

Fix this by resetting finalizersDone in gcResetMarkState. This way it
gets reset before any full mark, which is exactly what we want.

Change-Id: I4ddb5eba5b3b97e52aaf3e08fd9aa692bda32b20
Reviewed-on: https://go-review.googlesource.com/20332
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-07 22:32:20 +00:00
Matthew Dempsky
b4c66b176e cmd/internal/obj/mips: add ALUI const
Instead of abusing ALAST.

Passes GOARCH=mips64 toolstash -cmp.

Updates #14692.

Change-Id: Ie85e99cf76508c1d0f5847a4157056b614fd5cc6
Reviewed-on: https://go-review.googlesource.com/20341
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-07 22:09:08 +00:00
Caio Marcelo de Oliveira Filho
133c26b158 go/types: don't emit conversion error in non-numeric increment/decrement
In increment and decrement statements, explicit check that the type
of operand is numeric. This avoids a related but less clear error
about converting "1" to be emitted.

So, when checking

	package main

	func main() {
		var x bool
		x++
	}

instead of emitting the error

	prog.go:5:2: cannot convert 1 (untyped int constant) to bool

emits

	prog.go:5:2: invalid operation: x++ (non-numeric type bool).

Updates #12525.

Change-Id: I00aa6bd0bb23267a2fe10ea3f5a0b20bbf3552bc
Reviewed-on: https://go-review.googlesource.com/20244
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-07 20:53:49 +00:00
Matthew Dempsky
a03bdc3e6b runtime: eliminate unnecessary type conversions
Automated refactoring produced using github.com/mdempsky/unconvert.

Change-Id: Iacf871a4f221ef17f48999a464ab2858b2bbaa90
Reviewed-on: https://go-review.googlesource.com/20071
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-07 20:53:27 +00:00
Dave Cheney
1ec4f227f4 cmd/compile/internal/ppc64: clean up table initalisation
Move initproginfo and initvariants to ppc64.Main to avoid checking that
the tables are initialised every time.

Change-Id: I95ff4146a7abc18c42a20bfad716cc80ea8367e5
Reviewed-on: https://go-review.googlesource.com/20286
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-07 20:46:53 +00:00
Brad Fitzpatrick
795e712b72 os/user: make Current work without cgo
Fixes #14626

Change-Id: I91c40407dc35355e5c5046f24111a126f99260d9
Reviewed-on: https://go-review.googlesource.com/20192
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2016-03-07 20:22:32 +00:00
Matthew Dempsky
7893442011 cmd/internal/obj: simplify Optab range handling code
Use slices as slices, instead of as clumsy pointers.

Passes toolstash/buildall.

Change-Id: If09eacc2d8805d7d5eaa5566f9b6305541074371
Reviewed-on: https://go-review.googlesource.com/20322
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-07 20:20:38 +00:00
Ross Light
42f07ff267 os/user: add LookupGroup, LookupGroupId, and User.GroupIds functions
As part of local testing with a large group member list, I discovered
that the lookup functions don't resize their buffer if they receive
ERANGE.  I fixed this as a side-effect of this CL.

Thanks to @andrenth for the original CL.

Fixes #2617

Change-Id: Ie6aae2fe0a89eae5cce85786869a8acaa665ffe9
Reviewed-on: https://go-review.googlesource.com/19235
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-07 20:11:19 +00:00
Brad Fitzpatrick
ff555f1159 mime/multipart: don't call Read on io.Reader after an error is seen
The io.Reader contract makes no promises about how a Reader should
behave after it returns its first error. Usually the errors are
sticky, but they don't have to be. A regression in zlib.Reader (bug
accidentally relied on sticky errors.

Minimal fix: wrap the user's provided Reader in a Reader which
guarantees stickiness. The minimal fix is less scary than touching
the multipart state machine.

Fixes #14676

Change-Id: I8dd8814b13ae5530824ae0e68529f788974264a5
Reviewed-on: https://go-review.googlesource.com/20297
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-07 19:50:16 +00:00
Matthew Dempsky
c876a1b11e cmd/internal/obj: remove unused ar.go
Change-Id: I3eab54cd27c43bab38641fbead4adb6442481356
Reviewed-on: https://go-review.googlesource.com/20248
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-07 19:09:03 +00:00
Joe Tsai
5a966cf2da compress/zlib: make errors persistent
Ensure that all errors (including io.EOF) are persistent across method
calls on zlib.Reader. Furthermore, ensure that these persistent errors
are properly cleared when Reset is called.

Fixes #14675

Change-Id: I15a20c7e25dc38219e7e0ff255d1ba775a86bb47
Reviewed-on: https://go-review.googlesource.com/20292
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-07 18:32:04 +00:00
Ian Lance Taylor
2a68c6c27c cmd/compile: more nodeSeq conversions
Found by temporarily flipping fields from *NodeList to Nodes and fixing
all the compilation errors.  This CL does not actually change any
fields.

Passes toolstash -cmp.

Update #14473.

Change-Id: Ib98fa37e8752f96358224c973a743618a6a0e736
Reviewed-on: https://go-review.googlesource.com/20320
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-07 18:31:54 +00:00
Matthew Dempsky
c3dfad5df9 cmd/compile: change Oconv to take an Op parameter
Eliminates type conversions in a bunch of Oconv(int(n.Op), ...) calls.

Notably, this identified a misuse of Oconv in amd64/gsubr.go to try to
print an assembly instruction op instead of a compiler node op.

Change-Id: I93b5aa49fe14a5eaf868b05426d3b8cd8ab52bc5
Reviewed-on: https://go-review.googlesource.com/20298
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-07 17:27:05 +00:00
Richard Miller
0de0cafb9f runtime: new files for plan9_arm support
Implementation more or less follows plan9_386 version.
Revised 7 March to correct a bug in runtime.seek and
tidy whitespace for 8-column tabs.

Change-Id: I2e921558b5816502e8aafe330530c5a48a6c7537
Reviewed-on: https://go-review.googlesource.com/18966
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-07 16:25:48 +00:00
Richard Miller
d145456b16 runtime: signal handling support for plan9_arm
Plan 9 trap/signal handling differs on ARM from other architectures
because ARM has a link register.  Also trap message syntax varies
between different architectures (historical accident?).
Revised 7 March to clarify a comment.

Change-Id: Ib6485f82857a2f9a0d6b2c375cf0aaa230b83656
Reviewed-on: https://go-review.googlesource.com/18969
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-07 16:25:17 +00:00
Caio Marcelo de Oliveira Filho
c97ddf9c10 cmd/compile: don't emit conversion error in non-numeric increment/decrement
In increment and decrement statements, explicit check that the type
of operand is numeric earlier. This avoids a related but less clear
error about converting "1" to be emitted.

So, when compiling

	package main

	func main() {
		var x bool
		x++
	}

instead of emitting two errors

	prog.go:5: cannot convert 1 to type bool
	prog.go:5: invalid operation: x++ (non-numeric type bool)

just emits the second error.

Fixes #12525.

Change-Id: I6e81330703765bef0d6eb6c57098c1336af7c799
Reviewed-on: https://go-review.googlesource.com/20245
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-07 14:34:58 +00:00
Nigel Tao
ed8116989d compress/flate: remove unused woffset field.
Change-Id: Id0a12c76b0a6925f2926d38a1931157f9ef5f650
Reviewed-on: https://go-review.googlesource.com/20280
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-07 10:52:06 +00:00
Josh Bleecher Snyder
6ed10382f7 cmd/compile: soup up isSamePtr
This increases the number of matches in make.bash
from 853 to 984.

Change-Id: I12697697a50ecd86d49698200144a4c80dd3e5a4
Reviewed-on: https://go-review.googlesource.com/20274
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-07 01:30:07 +00:00
Austin Clements
ff71ed86b6 runtime: merge {bgMark,assist}StartTime
We used to start background mark workers and assists at different
times, so we needed to keep track of these separately. They're now set
to exactly the same time, so clean things up by merging them in to one
value, markStartTime.

Change-Id: I17c9843c3ed2d6f07b4c8cd0b2c438fc6de23b53
Reviewed-on: https://go-review.googlesource.com/20143
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-03-07 00:22:42 +00:00
Josh Bleecher Snyder
da1802f1df cmd/compile: use OffPtr when possible
OffPtr allocates less and is easier to optimize.

With this change, the OffPtr collapsing opt
rule matches increase from 160k to 263k,
and the Load-after-Store opt rule matches
increase from 217 to 853.

Change-Id: I763426a3196900f22a367f7f6d8e8047b279653d
Reviewed-on: https://go-review.googlesource.com/20273
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-06 23:57:06 +00:00
Josh Bleecher Snyder
3294014ae1 cmd/compile: collapse OffPtr sequences
This triggers an astonishing 160k times
during make.bash. The second biggest
generic rewrite triggers 100k times.

However, this is really just moving
rewrites that were happening at the
architecture level to the generic level.

Change-Id: Ife06fe5234f31433328460cb2e0741c071deda41
Reviewed-on: https://go-review.googlesource.com/20235
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-06 23:56:55 +00:00
Keith Randall
12e60452e9 cmd/compile: Combine smaller loads into a larger load
This only deals with the loads themselves.  The bounds checks
are a separate issue.  Also doesn't handle stores, those are
harder because we need to make sure intermediate memory states
aren't observed (which is hard to do with rewrite rules).

Use one byte shorter instructions for zero-extending loads.

Update #14267

Change-Id: I40af25ab5208488151ba7db32bf96081878fa7d9
Reviewed-on: https://go-review.googlesource.com/20218
Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-06 22:52:22 +00:00
Michael Hudson-Doyle
9f4a359fc2 cmd/compile, cmd/link, cmd/newlink: remove support for weak symbols
They were only used for rtype.ptrToThis which David Crawshaw removed a couple
of weeks ago. Removes two traversals of Ctxt.Allsym from the linker but it
doesn't seem to make much difference to performance.

Change-Id: I5c305e0180186f643221d57822d301de4aa18827
Reviewed-on: https://go-review.googlesource.com/20287
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-06 22:28:07 +00:00
Josh Bleecher Snyder
6bd63ca346 cmd/compile: hide NodeList details in evconst
The new code is a bit less efficient,
but it does not involve altering the structure
of any linked lists.
This will make it easier to replace NodeLists
with Node slices.
We can return to a more efficient algorithm
when NodeLists have been replaced.

Passes toolstash -cmp.

Change-Id: I0bb5ee75e7c0646e6d37fe558c8f0548729d8aa1
Reviewed-on: https://go-review.googlesource.com/20277
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-06 16:12:33 +00:00
Muhammed Uluyol
1d40e2b14b Rewrite leftover references to plan9.bell-labs.com to 9p.io.
Change-Id: Iadb4aa016a7b361d01827787dbc59164d5d147f2
Reviewed-on: https://go-review.googlesource.com/20291
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-06 07:07:01 +00:00
Josh Bleecher Snyder
786a2ef380 cmd/compile: use a uint8-sized named type for Addr.Type
No immediate reduction in the size of Addr.

Passes toolstash -cmp.

Change-Id: I78ea4c6e181b6e571ce70a5f1ae8158844eb197d
Reviewed-on: https://go-review.googlesource.com/20276
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-06 04:52:28 +00:00
Dave Cheney
8f5fb95db6 cmd/compile/internal/gc: assert size of important types
Add tests to ensure that the size of important types don't change
unexpectedly.

Skip the test on nacl platforms because of their unusual padding
requirements.

Change-Id: Iddb127a99499e089a309b721f5073356c0da8b24
Reviewed-on: https://go-review.googlesource.com/20285
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dave Cheney <dave@cheney.net>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-06 04:09:07 +00:00
Martin Möhrmann
bd6d84282a fmt: refactor and unify float and complex formatting
Removes specialized functions for each verb and float/complex size
and replaces them with generic variants fmtFloat and
fmtComplex similar to other generic fmt functions.

Simplifies the complex formatting by relying on fmtFloat
to handle the verb and default precision selection.

Complex imaginary formatting does not need to clear the f.space flag
because the set f.plus flag will force a sign instead of a space.

Sets default precision for %b to -1 (same as %g and %G)
since precision for %b has no affect in strconv.AppendFloat.

Add more tests and group them a bit better.
Use local copies of +Inf,-Inf and NaN instead
of math package functions for testing.

Saves around 8kb in the go binary.

name              old time/op  new time/op  delta
SprintfFloat-2     200ns ± 4%   196ns ± 4%  -1.55%  (p=0.007 n=20+20)
SprintfComplex-2   569ns ± 4%   570ns ± 3%    ~     (p=0.804 n=20+20)

Change-Id: I36d35dab6f835fc2bd2c042ac97705868eb2446f
Reviewed-on: https://go-review.googlesource.com/20252
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
2016-03-06 02:18:05 +00:00
Martin Möhrmann
5763476f73 fmt: use fewer allocations for %q string formatting
Reuse the internal buffer and use append versions of
the strconv quote functions to avoid some allocations.

Add more tests.

name                  old time/op    new time/op    delta
SprintfQuoteString-2     486ns ± 2%     416ns ± 2%  -14.42%  (p=0.000 n=20+20)

name                  old allocs/op  new allocs/op  delta
SprintfQuoteString-2      4.00 ± 0%      2.00 ± 0%  -50.00%  (p=0.000 n=20+20)

Change-Id: I63795b51fd95c53c5993ec8e6e99b659941f9f54
Reviewed-on: https://go-review.googlesource.com/20251
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-05 22:04:24 +00:00
Martin Möhrmann
00da3a6ec3 fmt: optimize byte slice and array formatting for %v and %d
Instead of calling printArg in fmtBytes to format each byte call
the byte formatting functions directly since it is known each
element is of type byte.

Add more tests for byte slice and array formatting.

name            old time/op  new time/op  delta
SprintfBytes-2   843ns ±16%   417ns ±11%  -50.58%  (p=0.000 n=20+20)

Change-Id: I5b907dbf52091e3de9710b09d67649c76f4c17e9
Reviewed-on: https://go-review.googlesource.com/20176
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-05 11:27:40 +00:00
Hitoshi Mitake
8c838192b8 runtime: don't print EnableGC flag in WriteHeapProfile()
Current runtime.WriteHeapProfile() doesn't print correct
EnableGC. Even if GOGC=off, the result file has below line:
 # EnableGC = true

It is hard to print correct status of the variable because of corner
cases e.g. initialization. For avoiding confusion, this commit removes
the print.

Change-Id: Ia792454a6c650bdc50a06fbaff4df7b6330ae08a
Reviewed-on: https://go-review.googlesource.com/18600
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2016-03-05 08:14:23 +00:00
Matthew Dempsky
4ab1793a78 cmd/compile: convert asmlist to []*Node
Updates #14473.

Change-Id: I88745c2a6119dea3b81b57299e70a2a7e4c584a8
Reviewed-on: https://go-review.googlesource.com/20272
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-05 04:08:12 +00:00
Martin Möhrmann
783741844b fmt: float formatting should not permanently change width
formatFloat should restore the original f.wid value before
returning. Callers should not have to save and restore f.wid.

Fixes: #14642

Change-Id: I531dae15c7997fe8909e2ad1ef7c376654afb030
Reviewed-on: https://go-review.googlesource.com/20179
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-05 03:01:22 +00:00
Ian Lance Taylor
72d90d8238 cmd/compile: change parser, racewalk, range to use nodeSeq
Passes toolstash -cmp.

Update #14473.

Change-Id: I0809c6b88643f04c7fc503f866ffe25e69f29910
Reviewed-on: https://go-review.googlesource.com/20260
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-05 02:33:00 +00:00
Ian Lance Taylor
65c4b55aba cmd/compile: convert subr, swt, typecheck to nodeSeq
Passes toolstash -cmp.

Update #14473.

Change-Id: I836197810405cde72cbb49fef7e163a517601f9c
Reviewed-on: https://go-review.googlesource.com/20242
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-05 02:26:11 +00:00
Matthew Dempsky
3da1a26fba cmd/compile: stop leaking 'any' type into user package
The new check corresponds to the (etype != TANY || Debug['A'] != 0)
that was lost in golang.org/cl/19936.

Fixes #14652.

Change-Id: Iec3788ff02529b3b0f0d4dd92ec9f3ef20aec849
Reviewed-on: https://go-review.googlesource.com/20271
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-05 02:13:04 +00:00
Matthew Dempsky
dafbcf6df7 cmd/compile: remove syslook's copy parameter
Instead make substArgTypes responsible for cloning the function
definition Node and the function signature Type tree.

Passes toolstash -cmp.

Change-Id: I9ec84c90a7ae83d164d3f578e84a91cf1490d8ab
Reviewed-on: https://go-review.googlesource.com/20239
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-05 02:10:55 +00:00
Lynn Boger
8b51ee8315 crypto/cipher: xorBytes performance ppc64le/ppc64
Update supportsUnaligned in xor.go to be true for
GOARCH values ppc64le and ppc64.  This allows the
xor of long buffers to be done on double words
(8 bytes) instead of a single byte at a time, which
significantly improves performance.

Fixes #14350

Change-Id: Iccc6b9d3df2e604a55f4c1e4890bdd3bb0d77ab0
Reviewed-on: https://go-review.googlesource.com/19519
Reviewed-by: Minux Ma <minux@golang.org>
2016-03-05 01:51:33 +00:00
Ian Lance Taylor
eb6ee75add cmd/compile: convert select, sinit, ssa to nodeSeq
Passes toolstash -cmp.

Update #14473.

Change-Id: I1b50fe981e7a266d4b14f31d849eb91afccdfda3
Reviewed-on: https://go-review.googlesource.com/20270
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-05 01:14:30 +00:00
Brad Fitzpatrick
e3a9dca7cc cmd/compile: don't allocate convX2X or assertX2X func names before syslook
Change-Id: Ib632ee7ac893750bec4cfe223745bca5f31900ab
Reviewed-on: https://go-review.googlesource.com/20234
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-04 23:24:13 +00:00
Ian Lance Taylor
80e5b52566 cmd/compile: change order.go to use nodeSeq
Passes toolstash -cmp

Update #14473.

Change-Id: I15b35d40a5ec1f4355ee38bc6d131920933ac95c
Reviewed-on: https://go-review.googlesource.com/20237
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-04 23:15:43 +00:00
Matthew Dempsky
16e2e95dd9 cmd/compile/internal/ssa: chmod -x likelyadjust.go
Change-Id: I01ec7d08884a1e0fbce94ea77281c1ee4a2cfd56
Reviewed-on: https://go-review.googlesource.com/20238
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-04 22:56:02 +00:00
Ian Lance Taylor
55c65d4a97 cmd/compile: change export.go and fmt.go to use nodeSeq
Also fix some uses of nodeSeqIterator.Len, and fix the implementation in
nodesIterator.

Passes toolstash -cmp.

Update #14473.

Change-Id: I228871470234b7f1314ffd2aae8a4c0624c35f98
Reviewed-on: https://go-review.googlesource.com/20231
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-04 21:46:30 +00:00
Rhys Hiltner
3375974e0d cmd/link/internal/ld: don't panic on short buildid
When the linker was written in C, command line arguments were passed
around as null-terminated byte arrays which encouraged checking
characters one at a time. In Go, that can easily lead to
out-of-bounds panics.

Use the more idiomatic strings.HasPrefix when checking cmd/link's -B
argument to avoid the panic, and replace the manual hex decode with
use of the encoding/hex package.

Fixes #14636

Change-Id: I45f765bbd8cf796fee1a9a3496178bf76b117827
Reviewed-on: https://go-review.googlesource.com/20211
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-04 21:20:09 +00:00
Austin Clements
b5481dd0a6 runtime: disable gcMarkRootCheck debugging check during STW
gcMarkRootCheck takes ~10ns per goroutine. This is just a debugging
check, so disable it (plus, if something is going to go wrong, it's
more likely to go wrong during concurrent mark).

We may be able to re-enable this later, or move it to after we've
started the world again. (But not for 1.6.x.)

For 1.6.x.

Fixes #14419.

name / 95%ile-time/markTerm          old          new  delta
500kIdleGs-12                24.0ms ± 0%  18.9ms ± 6%  -21.46%  (p=0.000 n=15+20)

Change-Id: Idb2a2b1771449de772c159ef95920d6df1090666
Reviewed-on: https://go-review.googlesource.com/20148
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-04 21:12:06 +00:00
Austin Clements
9ab9053344 runtime: reset mark state before stopping the world
Currently we reset the mark state during STW sweep termination. This
involves looping over all of the goroutines. Each iteration of this
loop takes ~25ns, so at around 400k goroutines, we'll exceed our 10ms
pause goal.

However, it's safe to do this before we stop the world for sweep
termination because nothing is consuming this state yet. Hence, move
the reset to just before STW.

This isn't perfect: a long reset can still delay allocating goroutines
that block on GC starting. But it's certainly better to block some
things eventually than to block everything immediately.

For 1.6.x.

Fixes #14420.

name \ 95%ile-time/sweepTerm           old          new  delta
500kIdleGs-12                 11312µs ± 6%  18.9µs ± 6%  -99.83%  (p=0.000 n=16+20)

Change-Id: I9815c4d8d9b0d3c3e94dfdab78049cefe0dcc93c
Reviewed-on: https://go-review.googlesource.com/20147
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-04 21:12:03 +00:00
Ian Lance Taylor
1716162a9a runtime: fix off-by-one error finding module for PC
Also fix compiler-invoked panics to avoid a confusing "malloc deadlock"
crash if they are invoked while executing the runtime.

Fixes #14599.

Change-Id: I89436abcbf3587901909abbdca1973301654a76e
Reviewed-on: https://go-review.googlesource.com/20219
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-04 21:06:31 +00:00
David Crawshaw
afd835434c cmd/link: deduplicate read-only string data
Many read-only strings in Go binaries are substrings of other read-only
strings. A common source is the text form of type information, which
will include both "struct { X int }" and "*struct { X int }" or
"*bytes.Reader" and "func(*bytes.Reader)" in the same binary.

Because this character data is referred to by separate string headers,
we can skip writing the smaller string and modify the pointer
relocation to point to the larger string. This CL does this
deduplication in the linker after the reachable set of strings has
been determined.

This removes 765KB from juju (1.4% without DWARF).

Link time goes at tip goes form 4.6s to 6.3s, but note that this CL
is part of a series that recently reduced link time from 9.6s.

For #6853.

Change-Id: Ib2087cf627c9f1e9a1181f9b4c8f81d1a3f42191
Reviewed-on: https://go-review.googlesource.com/19987
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-04 20:38:35 +00:00
David Crawshaw
69285a8b46 reflect: recognize unnamed directional channels
go test github.com/onsi/gomega/gbytes now passes at tip, and tests
added to the reflect package.

Fixes #14645

Change-Id: I16216c1a86211a1103d913237fe6bca5000cf885
Reviewed-on: https://go-review.googlesource.com/20221
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-04 20:34:30 +00:00
Michael Munday
4c69e92f51 cmd/link: align string data to Minalign when merging strings
Minalign > 1 implies that relocations inserted by the linker cannot
target arbitrary bytes.

Related to #14604

Change-Id: Ie68d14887bc4047d9b29b0cb1149a8d14b6c62e2
Reviewed-on: https://go-review.googlesource.com/20214
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-04 20:12:55 +00:00
Ian Lance Taylor
99b6b77e22 cmd/compile: convert inl.go to use nodeSeq
Passes toolstash -cmp.

Update #14473.

Change-Id: I60ef7cac553b346ca6b8cc7152cd184e59994b66
Reviewed-on: https://go-review.googlesource.com/20216
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-04 19:25:42 +00:00
Keith Randall
c0740fed37 cmd/compile: more ssa config flags
To turn ssa compilation on or off altogether, use
-ssa=1 or -ssa=0.  Default is on.

To turn on or off consistency checks, do
-d=ssa/check/on or -d=ssa/check/off.  Default is on for now.

Change-Id: I277e0311f538981c8b9c62e7b7382a0c8755ce4c
Reviewed-on: https://go-review.googlesource.com/20217
Reviewed-by: David Chase <drchase@google.com>
2016-03-04 19:03:12 +00:00
Matthew Dempsky
7f13fbf766 cmd/compile: small cleanup to syslook calls
Passing copy==1 to syslook is only necessary to support subsequent
calls to substArgTypes.  typ2Itab and concatstring* don't have "any"
parameters, so no point in deep copying their function signatures at
every call site.

For a couple other syslook calls (makemap and conv[IET]2[IET]), move
them closer to their corresponding substArgTypes calls so it's easier
to see that all syslook(fn, 1) calls are necessary.

Change-Id: I4a0588ab2b8b5b8ce7a0a44b24c8cf8fda489af6
Reviewed-on: https://go-review.googlesource.com/20215
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-04 17:44:02 +00:00
Robert Griesemer
646939c0e3 cmd/compile: re-vendor math/big to pick up bug fix
The changes to internal/big are completely automatic
by running vendor.bash in that directory.

Also added respective test case.

For #14553.

Change-Id: I98b124bcc9ad9e9bd987943719be27864423cb5d
Reviewed-on: https://go-review.googlesource.com/20199
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-04 17:40:16 +00:00
Robert Griesemer
3858efcc58 math/big: use correct precision in Float.Float32/64 for denormals
When a big.Float is converted to a denormal float32/64, the rounding
precision depends on the size of the denormal. Rounding may round up
and thus change the size (exponent) of the denormal. Recompute the
correct precision again for correct placement of the mantissa.

Fixes #14553.

Change-Id: Iedab5810a2d2a405cc5da28c6de7be34cb035b86
Reviewed-on: https://go-review.googlesource.com/20198
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-04 17:39:50 +00:00
David Crawshaw
08c2cd8469 cmd/compile: remove NUL-terminator from string data
Makes godoc 37KB smaller.
For #6853.

Change-Id: I0bd6e40f2b4da193768a9fc2ce494cacf7e83c32
Reviewed-on: https://go-review.googlesource.com/19697
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-04 15:16:31 +00:00
Matthew Dempsky
62e26e7511 cmd/compile: simplify Eqtype
Change-Id: I443f997ed53f965ef5b33734351ab8a07a09746b
Reviewed-on: https://go-review.googlesource.com/20213
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-04 15:15:53 +00:00
Ian Lance Taylor
132ebeac3f cmd/compile: convert walk.go and friends to use nodeSeq
Pases toolstash -cmp.

Update #14473.

Change-Id: I450d9f51fd280da91952008cd917b749d88960a3
Reviewed-on: https://go-review.googlesource.com/20210
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-04 14:35:00 +00:00
Matthew Dempsky
1765863e57 cmd/compile: replace TypeList with []*Type
Good riddance to another one-off linked list type.

Change-Id: Idf9926a701ab4da8a022be1d61f1257020d58fc5
Reviewed-on: https://go-review.googlesource.com/20212
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-04 14:30:35 +00:00
Michael Hudson-Doyle
060a2bacb7 cmd/internal/obj/ppc64: eliminate ~700 conversions by tweaking signatures
This is mostly changing the opXXX helpers to take an int16 (matching Prog.As)
argument and return a uint32. The only bit that's not completely trivial is
passing -p.As to opirr to signal operating on a shifted constant, because AADD
+ ALAST overflows int16.

Change-Id: I69133800bbe41c38fa4a89bbbf49823043b3419c
Reviewed-on: https://go-review.googlesource.com/20182
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-04 06:30:25 +00:00
Dave Cheney
a162d11540 cmd/compile: post CL 20089 cleanups
This CL addresses some issues noted during CL 20089.

Change-Id: I4e91a8077c07a571ccc9c004278672eb951c5104
Reviewed-on: https://go-review.googlesource.com/20181
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-04 04:10:36 +00:00
djherbis
14bf9c8c07 bufio: Reader.Peek returns partial results on ErrBufferFull
The existing implementation returns nil, ErrBufferFull when n > len(b.buf),
now it will return any data in the buffer and ErrBufferFull.

Fixes #14121

Change-Id: Ie52d32ccd80e4078ebfae6e75393c89675959ead
Reviewed-on: https://go-review.googlesource.com/19091
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-04 03:51:22 +00:00
Ian Lance Taylor
7047742f12 cmd/compile: change esc.go to use nodeSeq
Move a few local fields all the way to []*Node while I'm at it.

Update #14473.

Change-Id: Ib18360879839ac592f778cf1042f111bdf14add3
Reviewed-on: https://go-review.googlesource.com/20197
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-04 03:23:52 +00:00
Matthew Dempsky
def1e7276a cmd/compile: remove unnecessary conversions
Automated CL prepared by github.com/mdempsky/unconvert, except for
reverting changes to ssa/rewritegeneric.go (generated file) and
package big (vendored copy of math/big).

Change-Id: I64dc4199f14077c7b6a2f334b12249d4a785eadd
Reviewed-on: https://go-review.googlesource.com/20089
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-03-04 01:57:33 +00:00
Ian Lance Taylor
2aa2da295f cmd/compile: convert dcl.go to nodeSeq
Add new functions setNodeSeqNode, appendNodeSeq, appendNodeSeqNode.

Passes toolstash -cmp.

Change-Id: I6c1745b1108dea45a2c0d029b9de1917ae17a962
Reviewed-on: https://go-review.googlesource.com/20196
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-04 00:52:48 +00:00
Spencer Nelson
867910ea17 cmd/vet: Use function signature to find format string index.
cmd/vet's printf checker currently uses a hardcoded map of function
names to expected positions of format strings. We can be a bit more
precise than this by looking up the signature of the function, which
helps when libraries implement functions like Errorf or Logf with
extra arguments like log levels or error codes.

Specifically, the format string param is assumed to be the last string
parameter of the called function.

Fixes #12294.

Change-Id: Icf10ebb819bba91fa1c4109301417042901e34c7
Reviewed-on: https://go-review.googlesource.com/20163
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-04 00:00:20 +00:00
Ian Lance Taylor
bf3909824c cmd/compile: convert cgen/gen/pgen and friends to nodeListSeq
Added Seq method to nodeListIterator. Added new functions nodeSeqLen,
nodeSeqFirst, nodeSeqSecond. Allow nil as source argument to setNodeSeq.

Change-Id: Ifc1cd4d7207b7a125b3830c92c4d6d6f00eedd54
Reviewed-on: https://go-review.googlesource.com/20195
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-03 23:33:24 +00:00
Ian Lance Taylor
ca56c590d4 cmd/compile: add setNodeSeq, and use it in bimport.go
Also rewrite bexport.go to use nodeSeqIterate.

The new setNodeSeq is a transitional generic function to set either a
NodeList or a slice to either a NodeList or a slice.  This should permit
us to flip fields from *NodeList to []*Node, or Nodes, without changing
other code.

Passes toolstash -cmp.

Change-Id: I872cbfe45bc5f432595737c1f6da641c502b1ab6
Reviewed-on: https://go-review.googlesource.com/20194
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-03 22:28:00 +00:00
David du Colombier
d55a099e22 cmd/compile: don't use duffcopy and duffzero on Plan 9
The ssa compiler uses the duffcopy and duffzero functions,
which rely on the MOVUPS instructions.

However, this doesn't work on Plan 9, since floating point
operations are not allowed in the note handler.

This change disables the use of duffcopy and duffzero
on Plan 9 in the ssa compiler.

Updates #14605.

Change-Id: I017f8ff83de00eabaf7e146b4344a863db1dfddc
Reviewed-on: https://go-review.googlesource.com/20171
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-03 21:36:11 +00:00
Ian Lance Taylor
466c948b55 cmd/compile: add nodeSeqIterator interface
I tried to write a program to convert *NodeList to Node, but ran into
too many problem cases.  I'm backing off and trying a more iterative
approach using interfaces.

This CL adds an interface for iteration over either a *NodeList or a
Nodes.  I changed typechecklist to use it, to show how it works.  After
NodeList is eliminated, we can change the typechecklist parameter type
to Nodes.

Passes toolstash -cmp.

Change-Id: I5c7593714b020d20868b99151b1e7cadbbdbc397
Reviewed-on: https://go-review.googlesource.com/20190
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-03 20:14:06 +00:00
David Crawshaw
0c84c4f19c cmd/link: combine all string data into one symbol
This CL introduces a mergestrings pass after the reachability
analysis to combine all reachable go.string."..." character data
symbols into a single symbol.

Shrinks juju by 1.2mb (1.5%).
Shrinks cmd/go by 0.5% when building without DWARF.
No noticable effect on linker speed.

Change-Id: I2ba3e60bf418f65766bda257f6ca9eea26d895b6
Reviewed-on: https://go-review.googlesource.com/20165
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-03 19:57:16 +00:00
Ian Lance Taylor
7e92c86df2 cmd/compile: remove listsort
The listsort function is no longer used, except in a test.  Change the
test to use sort.Sort instead.

Change-Id: Ib634705cc1bc3b1d8fc3795bd4ed2894e6abc284
Reviewed-on: https://go-review.googlesource.com/19964
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-03 19:50:23 +00:00
Keith Randall
686fbdb3b0 cmd/compile: make compilation deterministic, fixes toolstash
Make sure we don't depend on map iterator order.

Fixes #14600

Change-Id: Iac0e0c8689f3ace7a4dc8e2127e2fd3c8545bd29
Reviewed-on: https://go-review.googlesource.com/20158
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-03 18:03:45 +00:00
Keith Randall
c03ed491fe cmd/compile: load some live values into registers before loop
If we're about to enter a loop, load values which are live
and will soon be used in the loop into registers.

name                     old time/op    new time/op    delta
BinaryTree17-8              2.80s ± 4%     2.62s ± 2%   -6.43%          (p=0.008 n=5+5)
Fannkuch11-8                2.45s ± 2%     2.14s ± 1%  -12.43%          (p=0.008 n=5+5)
FmtFprintfEmpty-8          49.0ns ± 1%    48.4ns ± 1%   -1.35%          (p=0.032 n=5+5)
FmtFprintfString-8          160ns ± 1%     153ns ± 0%   -4.63%          (p=0.008 n=5+5)
FmtFprintfInt-8             152ns ± 0%     150ns ± 0%   -1.57%          (p=0.000 n=5+4)
FmtFprintfIntInt-8          252ns ± 2%     244ns ± 1%   -3.02%          (p=0.008 n=5+5)
FmtFprintfPrefixedInt-8     223ns ± 0%     223ns ± 0%     ~     (all samples are equal)
FmtFprintfFloat-8           293ns ± 2%     291ns ± 2%     ~             (p=0.389 n=5+5)
FmtManyArgs-8               956ns ± 0%     936ns ± 0%   -2.05%          (p=0.008 n=5+5)
GobDecode-8                7.18ms ± 0%    7.11ms ± 0%   -1.02%          (p=0.008 n=5+5)
GobEncode-8                6.12ms ± 3%    6.07ms ± 1%     ~             (p=0.690 n=5+5)
Gzip-8                      284ms ± 1%     284ms ± 0%     ~             (p=1.000 n=5+5)
Gunzip-8                   40.8ms ± 1%    40.6ms ± 1%     ~             (p=0.310 n=5+5)
HTTPClientServer-8         69.8µs ± 1%    72.2µs ± 4%     ~             (p=0.056 n=5+5)
JSONEncode-8               16.1ms ± 2%    16.2ms ± 1%     ~             (p=0.151 n=5+5)
JSONDecode-8               54.9ms ± 0%    57.0ms ± 1%   +3.79%          (p=0.008 n=5+5)
Mandelbrot200-8            4.35ms ± 0%    4.39ms ± 0%   +0.85%          (p=0.008 n=5+5)
GoParse-8                  3.56ms ± 1%    3.42ms ± 1%   -4.03%          (p=0.008 n=5+5)
RegexpMatchEasy0_32-8      75.6ns ± 1%    75.0ns ± 0%   -0.83%          (p=0.016 n=5+4)
RegexpMatchEasy0_1K-8       250ns ± 0%     252ns ± 1%   +0.80%          (p=0.016 n=4+5)
RegexpMatchEasy1_32-8      75.0ns ± 0%    75.4ns ± 2%     ~             (p=0.206 n=5+5)
RegexpMatchEasy1_1K-8       401ns ± 0%     398ns ± 1%     ~             (p=0.056 n=5+5)
RegexpMatchMedium_32-8      119ns ± 0%     118ns ± 0%   -0.84%          (p=0.008 n=5+5)
RegexpMatchMedium_1K-8     36.6µs ± 0%    36.9µs ± 0%   +0.91%          (p=0.008 n=5+5)
RegexpMatchHard_32-8       1.95µs ± 1%    1.92µs ± 0%   -1.23%          (p=0.032 n=5+5)
RegexpMatchHard_1K-8       58.3µs ± 1%    58.1µs ± 1%     ~             (p=0.548 n=5+5)
Revcomp-8                   425ms ± 1%     389ms ± 1%   -8.39%          (p=0.008 n=5+5)
Template-8                 65.5ms ± 1%    63.6ms ± 1%   -2.86%          (p=0.008 n=5+5)
TimeParse-8                 363ns ± 0%     354ns ± 1%   -2.59%          (p=0.008 n=5+5)
TimeFormat-8                363ns ± 0%     364ns ± 1%     ~             (p=0.159 n=5+5)

Fixes #14511

Change-Id: I1b79d2545271fa90d5b04712cc25573bdc94f2ce
Reviewed-on: https://go-review.googlesource.com/20151
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-03-03 17:39:43 +00:00
David Crawshaw
5be961a352 cmd/link: replace Autom linked list with slice
Change-Id: I939129da0e71a7ccc61bec79515a34f0b1e59502
Reviewed-on: https://go-review.googlesource.com/20162
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-03 17:21:06 +00:00
David Crawshaw
1661493c73 cmd/link: replace LSym.Queue with a slice
Change-Id: Idc95452088d23be8e18522209d98f789dfca070b
Reviewed-on: https://go-review.googlesource.com/20161
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-03 17:20:33 +00:00
Caleb Spare
596df2424d cmd/go: set GOPATH in list's Context
Fixes #14547.

Change-Id: Ic175ee8f7e65b9b99f1f47fbf267a2aba7c8fec7
Reviewed-on: https://go-review.googlesource.com/20010
Run-TryBot: Caleb Spare <cespare@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2016-03-03 09:09:16 +00:00
Martin Möhrmann
033e3e106e fmt: optimize %x and %X formatting for byte slices and strings
No extra buffering is needed to save the encoding
since the left padding can be computed and written out
before the encoding is generated.

Add extra tests to both string and byte slice formatting.

name                old time/op  new time/op  delta
SprintfHexString-2   410ns ± 3%   194ns ± 3%  -52.60%  (p=0.000 n=20+19)
SprintfHexBytes-2    431ns ± 3%   202ns ± 2%  -53.13%  (p=0.000 n=18+20)

Change-Id: Ibca4316427c89f834e4faee61614493c7eedb42b
Reviewed-on: https://go-review.googlesource.com/20097
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-03 08:25:28 +00:00
Keith Randall
71d13a8c01 cmd/compile: fix fieldtrack experiment
The ODOTPTRs introduced in CL #19814 don't have field names,
just offsets.  The fieldtrack experiment crashes when
examining them.  Instead, just ignore them.  We'll never track
these fields anyway.

It would be nice to have the runtime type struct build in the
compiler (like we do sudog, for example) so we could use its
fieldnames.  Doesn't seem worth it just for this CL.

Change-Id: I5e75024f5a8333eb7439543b3f466ea40213a1b9
Reviewed-on: https://go-review.googlesource.com/20157
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-03 05:34:48 +00:00
Matthew Dempsky
868fb9ff1d cmd/compile: more lineno type conversions
Change-Id: Ib0a116a78f61eafe88a0ea5dc6733750ae755fdf
Reviewed-on: https://go-review.googlesource.com/20156
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-03 04:59:13 +00:00
Michael Munday
90cb1fdaf2 cmd/link: add Minalign field to ld.Arch
The new Minalign field sets the minimum alignment for all symbols.
This is required for the upcoming s390x port which requires symbols
be 2-byte aligned for efficient relative addressing.

All preexisting architectures have Minalign set to 1 which means
that this commit should have no effect.

I tested values of 2, 4 and 8 on linux amd64 and the tests appear to
pass. Increasing Minalign to 16 appears to break the runtime. I
think this is due to assumptions made about the layout of module
data.

toolstash -cmp on linux amd64 shows no changes due to this commit.

Resolves #14604

Change-Id: I0fe042d52c4e4732eba5fabcd0c31102a2408764
Reviewed-on: https://go-review.googlesource.com/20149
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-03 04:29:08 +00:00
Mikio Hara
b0f4ee533a net: deduplicate TCP socket code
This change consolidates functions and methods related to TCPAddr,
TCPConn and TCPListener for maintenance purpose, especially for
documentation. Also refactors Dial error code paths.

The followup changes will update comments and examples.

Updates #10624.

Change-Id: I3333ee218ebcd08928f9e2826cd1984d15ea153e
Reviewed-on: https://go-review.googlesource.com/20009
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-03 04:23:59 +00:00
Robert Griesemer
533f30b924 cmd/compile: exit early if oldname doesn't find a name
Change-Id: I59ce1b40bc3472cc92a9a0a9fbd32342e0b945ad
Reviewed-on: https://go-review.googlesource.com/20152
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-03 04:07:32 +00:00
Robert Griesemer
c41608f4ac cmd/compile: remove more superfluous int(lineno) conversions
Change-Id: Ia3e5d62b9d38a6c356baec8eb88b2bdabff5820f
Reviewed-on: https://go-review.googlesource.com/20150
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
2016-03-03 04:05:45 +00:00
Joe Tsai
8a83d36b8e compress/bzip2: refactor unit tests
Over the years as more bugs were discovered with the bzip2 library,
new Tests were appended the unit tests and the tests became gnarly.

Clean up the tests to be more consistent with modern Go style in
addition to coalescing common tests into a general version that
iterates over a list of input/output pairs. This has the advantage that
the input, output, and test code are all in the same area, rather than
being sprawled around the test file.

There is no loss of test coverage.

Change-Id: I377ed89378f0b89763d4a56ffc37b22d9c2a369e
Reviewed-on: https://go-review.googlesource.com/20133
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-03 02:53:34 +00:00
Burcu Dogan
fcb23249b2 net: skip TestLookupPort on android with netgo
/etc/services is not available on Android. The pure Go implementation
of LookupPort will never succeed on Android. Skipping the test.

Updates #14576.

Change-Id: I707ac24aea3f988656b95b1816ee5c9690106985
Reviewed-on: https://go-review.googlesource.com/20154
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-03 02:52:18 +00:00
Rob Pike
0f9cc465fa math: delete unused function sqrtC
It appears to be a trivial dreg. Unreferenced. Gone.

Change-Id: I4a5ceed48e84254bc8a07fdb04487a18a0edf965
Reviewed-on: https://go-review.googlesource.com/20122
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-03-03 02:29:09 +00:00
Matthew Dempsky
a40b27e304 cmd/compile: eliminate arch-specific typedefs
Arch backends already provide us Widthint and Widthptr, which is ample
information to figure out how to define the universal "int", "uint",
and "uintptr" types.  No need for providing a generic typedef
mechanism beyond that.

Change-Id: I35c0c17a67c80605a9208b93d77d6960b2cbb17d
Reviewed-on: https://go-review.googlesource.com/20153
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-03 02:23:37 +00:00
David Crawshaw
a3c258a567 cmd/link: pack LSym boolean attributes
No performance improvement, but possibly more readable.

Linking juju:
	tip:  real 0m5.470s user 0m6.131s
	this: real 0m5.392s user 0m6.087s

Change-Id: I578e94fbe6c11b19d79034c33b3db31d9689d439
Reviewed-on: https://go-review.googlesource.com/20108
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
2016-03-03 00:17:21 +00:00
Brad Fitzpatrick
d7cdf66978 cmd/link: stop generating garbage in elfhash
All callers already had strings. No need to generate byte slice copies
to work on bytes.

Performance not measured, but probably helps at least a bit.

Change-Id: Iec3230b69724fac68caae7aad46f2ce1504e82e5
Reviewed-on: https://go-review.googlesource.com/20136
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-03 00:11:31 +00:00
David Crawshaw
4b92cd4ec1 cmd/link: make Allsym a slice
Looks a tiny bit faster, which is a surprise. Probably noise.
Motivation is making the LSym structure a little easier to understand.

Linking juju, best of 10:

before: real 0m4.811s user 0m5.582s
after:  real 0m4.611s user 0m5.267s

Change-Id: Idbedaf4a6e6e199036a1bbb6760e98c94ed2c282
Reviewed-on: https://go-review.googlesource.com/20142
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-02 23:28:17 +00:00
Robert Griesemer
4598382724 cmd/compile/internal/gc: export & import function bodies, but don't hook up
Function bodies are not yet hooked up because the node structure is not
100% correct. This commit establishes that we can correctly write bodies
out and read them in again.

- export and import all exported inlined function bodies:
  (export GO_GCFLAGS="-newexport"; sh all.bash) working
- inlined functions are not yet hooked up (just dropped on the floor)
- improved tracing output and error messages
- make mkbuiltin.go work for both textual and binary export data
  so we can run tests with the new format

Change-Id: I70dc4de419df1b604389c3747041d6dba8730b0b
Reviewed-on: https://go-review.googlesource.com/16284
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-02 22:26:40 +00:00
David Crawshaw
c0f7195d62 cmd/link: replace custom hashmap in DWARF writer
Also stop creating a map for each symbol, as it does not seem to help.

Linking juju:
	tip:  real 0m5.470s user 0m6.131s
	this: real 0m4.811s user 0m5.582s

Change-Id: Ib3d931c996396a00942581770ff32df1eb8d6615
Reviewed-on: https://go-review.googlesource.com/20140
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-02 22:18:43 +00:00
David Chase
97b2295f06 cmd/compile: trunc(and(x,K)) rewrite to trunc(x) for some K
uint8(s.b & 0xff) ought to produce same code as uint8(s.b)
but it did not.  RLH found this one looking for moles to
whack in the GC code.

Change-Id: I883d68ec7a5746d652712be84a274a11256b3b33
Reviewed-on: https://go-review.googlesource.com/20141
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-02 21:50:55 +00:00
Robert Griesemer
3a880bae91 cmd/compile: remove missed int(lineno) conversions
Follow-up to https://go-review.googlesource.com/20131 .

Change-Id: Id8351fa39f24e6ea488cdbfcb855b69a31ffff31
Reviewed-on: https://go-review.googlesource.com/20134
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-02 21:07:16 +00:00
Martin Möhrmann
83765d135f fmt: optimize string truncation
Count only the runes up to the requested precision
to decide where to truncate a string.

Change the loop within truncate to need fewer jumps.

name                     old time/op  new time/op  delta
SprintfTruncateString-2   188ns ± 3%   155ns ± 3%  -17.43%  (p=0.000 n=20+20)

Change-Id: I17ca9fc0bb8bf7648599df48e4785251bbc31e99
Reviewed-on: https://go-review.googlesource.com/20098
Reviewed-by: Rob Pike <r@golang.org>
2016-03-02 20:51:38 +00:00
Robert Griesemer
2faf5bca2e cmd/compile: introduce linestr helper to simplify line reporting
Change-Id: Ic9ca792b55cc4ebd0ac6cfa2fbdb58030893bacd
Reviewed-on: https://go-review.googlesource.com/20132
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02 20:43:48 +00:00
Russ Cox
6969d9bf03 runtime/pprof: sort counted profiles by count
This is especially helpful in programs with very large numbers of goroutines:
the bulk of the goroutines will show up at the top.

Before:
	1 @ 0x86ab8 0x86893 0x82164 0x8e7ce 0x7b798 0x5b871
	#	0x86ab8	runtime/pprof.writeRuntimeProfile+0xb8		/Users/rsc/go/src/runtime/pprof/pprof.go:545
	#	0x86893	runtime/pprof.writeGoroutine+0x93		/Users/rsc/go/src/runtime/pprof/pprof.go:507
	#	0x82164	runtime/pprof.(*Profile).WriteTo+0xd4		/Users/rsc/go/src/runtime/pprof/pprof.go:236
	#	0x8e7ce	runtime/pprof_test.TestGoroutineCounts+0x15e	/Users/rsc/go/src/runtime/pprof/pprof_test.go:603
	#	0x7b798	testing.tRunner+0x98				/Users/rsc/go/src/testing/testing.go:473

	1 @ 0x2d373 0x2d434 0x560f 0x516b 0x7cd42 0x7b861 0x2297 0x2cf90 0x5b871
	#	0x7cd42	testing.RunTests+0x8d2	/Users/rsc/go/src/testing/testing.go:583
	#	0x7b861	testing.(*M).Run+0x81	/Users/rsc/go/src/testing/testing.go:515
	#	0x2297	main.main+0x117		runtime/pprof/_test/_testmain.go:72
	#	0x2cf90	runtime.main+0x2b0	/Users/rsc/go/src/runtime/proc.go:188

	10 @ 0x2d373 0x2d434 0x560f 0x516b 0x8e5b6 0x5b871
	#	0x8e5b6	runtime/pprof_test.func1+0x36	/Users/rsc/go/src/runtime/pprof/pprof_test.go:582

	50 @ 0x2d373 0x2d434 0x560f 0x516b 0x8e656 0x5b871
	#	0x8e656	runtime/pprof_test.func3+0x36	/Users/rsc/go/src/runtime/pprof/pprof_test.go:584

	40 @ 0x2d373 0x2d434 0x560f 0x516b 0x8e606 0x5b871
	#	0x8e606	runtime/pprof_test.func2+0x36	/Users/rsc/go/src/runtime/pprof/pprof_test.go:583

After:

	50 @ 0x2d373 0x2d434 0x560f 0x516b 0x8ecc6 0x5b871
	#	0x8ecc6	runtime/pprof_test.func3+0x36	/Users/rsc/go/src/runtime/pprof/pprof_test.go:584

	40 @ 0x2d373 0x2d434 0x560f 0x516b 0x8ec76 0x5b871
	#	0x8ec76	runtime/pprof_test.func2+0x36	/Users/rsc/go/src/runtime/pprof/pprof_test.go:583

	10 @ 0x2d373 0x2d434 0x560f 0x516b 0x8ec26 0x5b871
	#	0x8ec26	runtime/pprof_test.func1+0x36	/Users/rsc/go/src/runtime/pprof/pprof_test.go:582

	1 @ 0x2d373 0x2d434 0x560f 0x516b 0x7cd42 0x7b861 0x2297 0x2cf90 0x5b871
	#	0x7cd42	testing.RunTests+0x8d2	/Users/rsc/go/src/testing/testing.go:583
	#	0x7b861	testing.(*M).Run+0x81	/Users/rsc/go/src/testing/testing.go:515
	#	0x2297	main.main+0x117		runtime/pprof/_test/_testmain.go:72
	#	0x2cf90	runtime.main+0x2b0	/Users/rsc/go/src/runtime/proc.go:188

	1 @ 0x87128 0x86f03 0x82164 0x8ee30 0x7b798 0x5b871
	#	0x87128	runtime/pprof.writeRuntimeProfile+0xb8		/Users/rsc/go/src/runtime/pprof/pprof.go:566
	#	0x86f03	runtime/pprof.writeGoroutine+0x93		/Users/rsc/go/src/runtime/pprof/pprof.go:528
	#	0x82164	runtime/pprof.(*Profile).WriteTo+0xd4		/Users/rsc/go/src/runtime/pprof/pprof.go:236
	#	0x8ee30	runtime/pprof_test.TestGoroutineCounts+0x150	/Users/rsc/go/src/runtime/pprof/pprof_test.go:603
	#	0x7b798	testing.tRunner+0x98				/Users/rsc/go/src/testing/testing.go:473

Change-Id: I43de9eee2d96f9c46f7b0fbe099a0571164324f5
Reviewed-on: https://go-review.googlesource.com/20107
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-02 20:04:29 +00:00
Robert Griesemer
b83f3972fe cmd/compile: use int32 for line numbers consistently
- removed lots of unnecessary int(x) casts
- removed parserline() - was inconsistently used anyway
- minor simplifications in dcl.go

Change-Id: Ibf7de679eea528a31c9692ef1c76a1d9b3239211
Reviewed-on: https://go-review.googlesource.com/20131
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-02 19:32:41 +00:00
Ian Lance Taylor
053aef4f1b go/ast: fix typo in comment
Change-Id: I719231466286b3c0135314388a7c560ef44d7c35
Reviewed-on: https://go-review.googlesource.com/20130
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02 19:16:10 +00:00
Tamir Duberstein
37c28759ca crypto/tls: check errors from (*Conn).writeRecord
This promotes a connection hang during TLS handshake to a proper error.
This doesn't fully address #14539 because the error reported in that
case is a write-on-socket-not-connected error, which implies that an
earlier error during connection setup is not being checked, but it is
an improvement over the current behaviour.

Updates #14539.

Change-Id: I0571a752d32d5303db48149ab448226868b19495
Reviewed-on: https://go-review.googlesource.com/19990
Reviewed-by: Adam Langley <agl@golang.org>
2016-03-02 18:20:46 +00:00
David Crawshaw
1012892f1e cmd/link: C is gone, remove check for Go calling C
It looks like the compiler still uses the Cfunc flag for functions
marked as //go:systemstack, but if I'm reading this right, that
doesn't apply here and the linker no longer needs Cfunc.

Change-Id: I63b9192c2f52f41401263c29dc8dfd8be8a901a1
Reviewed-on: https://go-review.googlesource.com/20105
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-02 16:34:56 +00:00
Joe Tsai
8b360d5fda compress/bzip2: prevent zero-length Huffman codes
Unlike RFC 1951 (DEFLATE), bzip2 does not use zero-length Huffman codes
to indicate that the symbol is missing. Instead, bzip2 uses a sparse
bitmap to indicate which symbols are present. Thus, it is undefined what
happens when a length of zero is used. Thus, fix the parsing logic so that
the length cannot ever go below 1-bit similar to how the C logic does things.

To confirm that the C bzip2 utility chokes on this data:
	$ echo "425a6836314159265359b1f7404b000000400040002000217d184682ee48
	a70a12163ee80960" | xxd -r -p | bzip2 -d

	bzip2: Data integrity error when decompressing

For reference see:
	bzip2-1.0.6/decompress.c:320

Change-Id: Ic1568f8e7f80cdea51d887b4d712cc239c2fe85e
Reviewed-on: https://go-review.googlesource.com/20119
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-02 16:32:46 +00:00
Mohit Agarwal
1c94e7276e net: fix vet warnings
Updates #11041

Change-Id: I12c20beab75d7981efe470eb418e4b58dc8eb066
Reviewed-on: https://go-review.googlesource.com/20002
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02 16:26:36 +00:00
David Crawshaw
0d1a98e210 cmd/link: rename Hide to Hidden and make a bool
Change-Id: Ic99bd63c96b1eba5cc2b5cd2be3a575890a02996
Reviewed-on: https://go-review.googlesource.com/20103
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02 13:01:44 +00:00
David Crawshaw
3601a1e77d cmd/link: write DWARF PC table without seeking
This per-symbol table was written with the strategy:

	1. record offset and write fake header
	2. write body
	3. seek back to fake header
	4. write real header

This CL collects the per-symbol body into a []byte, then writes the
real header followed by the body to the output file. This saves two
seeks per-symbol and overwriting the fake header.

Small performance improvement (3.5%) in best-of-ten links of godoc:

tip:  real 0m1.132s user 0m1.256s
this: real 0m1.090s user 0m1.210s

I'm not sure if the performance measured here alone justifies it,
but I think this is an easier to read style of code.

Change-Id: I1663901eb7c2ee330591b8b6550cdff0402ed5dc
Reviewed-on: https://go-review.googlesource.com/20074
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02 12:19:35 +00:00
David Crawshaw
021e0c5f1f cmd/link: add array append version of methods
Used by DWARF writer changes in a followup CL.

Change-Id: I6ec40dcfeaba909d9b8f6cf2603bc5b85c1fa873
Reviewed-on: https://go-review.googlesource.com/20073
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02 12:19:07 +00:00
Keith Randall
62ac107a34 cmd/compile: some SSA cleanup
Do some easy TODOs.
Move a bunch of other TODOs into bugs.

Change-Id: Iaba9dad6221a2af11b3cbcc512875f4a85842873
Reviewed-on: https://go-review.googlesource.com/20114
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-02 03:17:46 +00:00
Brad Fitzpatrick
3afbb690d5 net/url: fix parsing of URLs ending in question mark
Fixes parsing regression from https://golang.org/cl/19931 which
added the URL.ForceQuery field.

Fixes #14573

Change-Id: I89575cab3f778b1bf78b2389623c866450b26943
Reviewed-on: https://go-review.googlesource.com/20116
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-02 03:05:18 +00:00
Robert Griesemer
37c2972772 cmd/compile: give SymFlags type to Sym flags
Change-Id: Ifa65a35418c2b5a2c517c0d9bbe37f472091e759
Reviewed-on: https://go-review.googlesource.com/20115
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-02 00:50:29 +00:00
Marvin Stenger
a8d4463e50 cmd/vet: polish output of shadow test
This commit modifies the style of a error message in case of -shadow.

Previously such a message would look like:
foo.go:42: declaration of err shadows declaration at shadow.go:13:

Changes of the commit include highlighting the variable name and
removing the ": "(space intended) at the end of the line:
foo.go:42: declaration of "err" shadows declaration at shadow.go:13

Fixes #14585.

Change-Id: Ia6a6bf396668dcba9a24f025a08d8826db31f434
Reviewed-on: https://go-review.googlesource.com/20093
Reviewed-by: Rob Pike <r@golang.org>
2016-03-02 00:49:39 +00:00
Brad Fitzpatrick
5fea2ccc77 all: single space after period.
The tree's pretty inconsistent about single space vs double space
after a period in documentation. Make it consistently a single space,
per earlier decisions. This means contributors won't be confused by
misleading precedence.

This CL doesn't use go/doc to parse. It only addresses // comments.
It was generated with:

$ perl -i -npe 's,^(\s*// .+[a-z]\.)  +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.)  +([A-Z])')
$ go test go/doc -update

Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7
Reviewed-on: https://go-review.googlesource.com/20022
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dave Day <djd@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02 00:13:47 +00:00
Ian Lance Taylor
8b4deb448e cmd/compile: fix OADDSTR buffer size calculation
The size calculation has been wrong since this code was first committed
in https://golang.org/cl/3120.  The effect was that the compiler always
allocated a temporary buffer on the stack for a non-escaping string
concatenation.  This turns out to make no practical difference, as the
compiler always allocates a buffer of the same size (32 bytes) and the
runtime only uses the temporary buffer if the concatenated strings
fit (check is in rawstringtmp in runtime/string.go).

The effect of this change is to avoid generating a temporary buffer on
the stack that will not be used.

Change-Id: Id632bfe3d6c113c9934c018a2dd4bcbf1784a63d
Reviewed-on: https://go-review.googlesource.com/20112
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-02 00:04:53 +00:00
Ian Lance Taylor
88e18032bd cmd/compile: s/flag_race/instrumenting/ in OCONVNOP check
This check seems to apply to all code instrumentation, not just -race.

Fixes #14589.

Change-Id: I16ae07749ede7c1e6ed06f472711638d195034ac
Reviewed-on: https://go-review.googlesource.com/20113
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
2016-03-01 23:58:35 +00:00
Brad Fitzpatrick
519474451a all: make copyright headers consistent with one space after period
This is a subset of https://golang.org/cl/20022 with only the copyright
header lines, so the next CL will be smaller and more reviewable.

Go policy has been single space after periods in comments for some time.

The copyright header template at:

    https://golang.org/doc/contribute.html#copyright

also uses a single space.

Make them all consistent.

Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0
Reviewed-on: https://go-review.googlesource.com/20111
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 23:34:33 +00:00
Robert Griesemer
8fd7c11d59 cmd/compile: delete unused lexer tokens, replace with LOPER
Also: Use same ordering of tokens in the various tables/maps.

Change-Id: Ief84c6ca3da36213ace6b2c10b513e2ca16318ab
Reviewed-on: https://go-review.googlesource.com/20110
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-01 23:05:14 +00:00
Keith Randall
59681802ad cmd/compile: remove _ssa print trigger
SSA is a real compiler now, don't trigger on function names.

Change-Id: Iaf6dd78248c1b6ca2630275bd59f7ea7b7576497
Reviewed-on: https://go-review.googlesource.com/20088
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 22:21:12 +00:00
Gerrit Code Review
a6fb2aede7 Merge "Merge branch 'dev.ssa' into mergebranch" 2016-03-01 21:36:45 +00:00
Keith Randall
9d854fd44a Merge branch 'dev.ssa' into mergebranch
Merge dev.ssa branch back into master.

Change-Id: Ie6fac3f8d355ab164f934415fe4fc7fcb8c3db16
2016-03-01 12:50:17 -08:00
Rob Pike
998aaf8a64 cmd/vet: add a README explaining the criteria for new checks
Correctness, Frequency, Precision.

Change-Id: I7f202c220aef8512d611dc04a4370b4a237f217c
Reviewed-on: https://go-review.googlesource.com/20003
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-01 20:48:20 +00:00
David Chase
6b3462c784 [dev.ssa] cmd/compile: adjust branch likeliness for calls/loops
Static branch predictions (which guide block ordering) are
adjusted based on:

loop/not-loop     (favor looping)
abnormal-exit/not (avoid panic)
call/not-call     (avoid call)
ret/default       (treat returns as rare)

This appears to make no difference in performance of real
code, meaning the compiler itself.  The earlier version of
this has been stripped down to help make the cost of this
only-aesthetic-on-Intel phase be as cheap as possible (we
probably want information about inner loops for improving
register allocation, but because register allocation follows
close behind this pass, conceivably the information could be
reused -- so we might do this anyway just to normalize
output).

For a ./make.bash that takes 200 user seconds, about .75
second is reported in likelyadjust (summing nanoseconds
reported with -d=ssa/likelyadjust/time ).

Upstream predictions are respected.
Includes test, limited to build on amd64 only.
Did several iterations on the debugging output to allow
some rough checks on behavior.
Debug=1 logging notes agree/disagree with earlier passes,
allowing analysis like the following:

Run on make.bash:
GO_GCFLAGS=-d=ssa/likelyadjust/debug \
   ./make.bash >& lkly5.log

grep 'ranch prediction' lkly5.log | wc -l
   78242 // 78k predictions

grep 'ranch predi' lkly5.log | egrep -v 'agrees with' | wc -l
   29633 // 29k NEW predictions

grep 'disagrees' lkly5.log | wc -l
     444 // contradicted 444 times

grep '< exit' lkly5.log | wc -l
   10212 // 10k exit predictions

grep '< exit' lkly5.log | egrep 'disagrees' | wc -l
       5 // 5 contradicted by previous prediction

grep '< exit' lkly5.log | egrep -v 'agrees' | wc -l
     702 // 702-5 redundant with previous prediction

grep '< call' lkly5.log | egrep -v 'agrees' | wc -l
   16699 // 16k new call predictions

grep 'stay in loop' lkly5.log | egrep -v 'agrees' | wc -l
    3951 // 4k new "remain in loop" predictions

Fixes #11451.

Change-Id: Iafb0504f7030d304ef4b6dc1aba9a5789151a593
Reviewed-on: https://go-review.googlesource.com/19995
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-01 20:09:41 +00:00
Matthew Dempsky
9ace455e78 cmd/compile/internal/ssa: cleanup godocs
Add a blank line before the "package ssa" lines so the "autogenerated
don't edit" comments don't end up in godoc output.

Change-Id: I82bf90d52d426ce1a8e21483fc8f47b3689259c7
Reviewed-on: https://go-review.googlesource.com/20086
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-01 19:20:24 +00:00
David Crawshaw
dd0a128a02 cmd/link: make rddataBufMax a const
Change-Id: I1ece7463d35efba0e8d2b1e61727dd25283ff720
Reviewed-on: https://go-review.googlesource.com/20059
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 18:08:02 +00:00
Alexandru Moșoi
e197f467d5 [dev.ssa] cmd/compile/internal/ssa: simplify boolean phis
* Decreases the generated code slightly.
* Similar to phiopt pass from gcc, except it only handles
booleans. Handling Eq/Neq had no impact on the generated code.

name       old time/op     new time/op     delta
Template       453ms ± 4%      451ms ± 4%    ~           (p=0.468 n=24+24)
GoTypes        1.55s ± 1%      1.55s ± 2%    ~           (p=0.287 n=24+25)
Compiler       6.53s ± 2%      6.56s ± 1%  +0.46%        (p=0.050 n=23+23)
MakeBash       45.8s ± 2%      45.7s ± 2%    ~           (p=0.866 n=24+25)

name       old text-bytes  new text-bytes  delta
HelloSize       676k ± 0%       676k ± 0%    ~     (all samples are equal)
CmdGoSize      8.07M ± 0%      8.07M ± 0%  -0.03%        (p=0.000 n=25+25)

Change-Id: Ia62477b7554127958a14cb27f85849b095d63663
Reviewed-on: https://go-review.googlesource.com/20090
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 17:56:13 +00:00
Alexandru Moșoi
1f6e9e36b0 [dev.ssa] cmd/compile/internal/ssa: distribute multiplication into addition
* This is a very basic form of straight line strength reduction.
* Removes one multiplication from a[b].c++; a[b+1].c++
* It increases pressure on the register allocator because
CSE creates more copies of the multiplication sizeof(a[0])*b.

Change-Id: I686a18e9c24cc6f8bdfa925713afed034f7d36d0
Reviewed-on: https://go-review.googlesource.com/20091
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-01 17:05:13 +00:00
Ilya Tocar
e96b232993 [dev.ssa] cmd/compile: promote byte/word operation
Writing to low 8/16 bits of register creates false dependency
Generate 32-bit operations when possible.

Change-Id: I8eb6c1c43a66424eec6baa91a660bceb6b80d1d3
Reviewed-on: https://go-review.googlesource.com/19506
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 15:54:52 +00:00
Matthew Dempsky
ac006ad103 cmd/compile: change defaultlit2's force param to bool
Change-Id: I5546c4e8092ef61648cdae9c04288bb7d6f32476
Reviewed-on: https://go-review.googlesource.com/20084
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 08:50:45 +00:00
Martin Möhrmann
33c0ef2de3 fmt: make identification of string arguments consistent
Use only reflect.TypeOf to detect if argument is a string.

The wasString return is only needed in doPrint with the 'v' verb.
This type of string detection is handled correctly by reflect.TypeOf
which is used already in doPrint for identifying a string argument.

Remove now obsolete wasString computations and return values.

Change-Id: Iea2de7ac0f5c536a53eec63f7e679d628f5af8dc
Reviewed-on: https://go-review.googlesource.com/19976
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-01 07:36:06 +00:00
Matthew Dempsky
8ad027c0c4 go/types: nicer shift error message
Updates #13940.

Change-Id: I41974c292dd981d82ac03b9b8b406713445362c3
Reviewed-on: https://go-review.googlesource.com/20081
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-01 06:05:49 +00:00
Matthew Dempsky
86235d5dd7 go/constant: fix typos in MakeFromLiteral docs
Change-Id: I99c737415a082df883a9c12cdb43bdd5a1b9a8ad
Reviewed-on: https://go-review.googlesource.com/20082
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-01 06:04:27 +00:00
Matthew Dempsky
35dd2ed58d cmd/compile: give mparith{2,3}.go files more meaningful names
Also, relocate related const and type definitions from go.go.

Change-Id: Ieb9b672da8dd510ca67022b4f7ae49a778a56579
Reviewed-on: https://go-review.googlesource.com/20080
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-01 05:03:58 +00:00
Matthew Dempsky
a6c95ae1df cmd/compile: remove some unnecessary EType/int conversions
Change-Id: I2d8efef333f2441da6742e125e23ff57c9853ebd
Reviewed-on: https://go-review.googlesource.com/20078
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-03-01 04:38:05 +00:00
Matthew Dempsky
55e7636f9c cmd/compile: remove some unused consts from the old yacc parser
Change-Id: I42f370b987fcc85201f7aaa055b9e58ee9b9a99e
Reviewed-on: https://go-review.googlesource.com/20079
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 04:30:46 +00:00
Keith Randall
6a8a9da572 [dev.ssa] cmd/compile: Make PPARAMOUT variables SSAable
Add writeback code to each return location which copies
the final result back to the correct stack location.

Cgo plays tricky games by taking the address of a
in f(a int) (b int) and then using that address to
modify b.  So for cgo-generated Go code, disable the
SSAing of output args.

Update #14511

Change-Id: I95cba727d53699d31124eef41db0e03935862be9
Reviewed-on: https://go-review.googlesource.com/19988
Reviewed-by: Todd Neal <todd@tneal.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-01 02:00:04 +00:00
Shahar Kohanim
d3b00a8cc4 cmd/link: batch writing of bytes
In best of 10, linking cmd/go shows a ~10% improvement.

tip:              real  0m1.152s user  0m1.005s
this:             real  0m1.065s user  0m0.924s

Change-Id: I303a20b94332feaedc1033c453247a0e4c05c843
Reviewed-on: https://go-review.googlesource.com/19978
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-29 23:54:19 +00:00
Gerrit Code Review
acdb0da47d Merge "[dev.ssa] Merge remote-tracking branch 'origin/master' into ssamerge" into dev.ssa 2016-02-29 23:19:17 +00:00
Josh Bleecher Snyder
194c79c163 [dev.ssa] cmd/compile: add constant cache
The cache gets a 62% hit rate while compiling
the standard library.


name      old time/op    new time/op    delta
Template     449ms ± 2%     443ms ± 4%  -1.40%  (p=0.006 n=23+25)
GoTypes      1.54s ± 1%     1.50s ± 2%  -2.53%  (p=0.000 n=22+22)
Compiler     5.51s ± 1%     5.39s ± 1%  -2.29%  (p=0.000 n=23+25)

name      old alloc/op   new alloc/op   delta
Template    90.4MB ± 0%    90.0MB ± 0%  -0.45%  (p=0.000 n=25+25)
GoTypes      334MB ± 0%     331MB ± 0%  -1.05%  (p=0.000 n=25+25)
Compiler    1.12GB ± 0%    1.10GB ± 0%  -1.57%  (p=0.000 n=25+24)

name      old allocs/op  new allocs/op  delta
Template      681k ± 0%      682k ± 0%  +0.26%  (p=0.000 n=25+25)
GoTypes      2.23M ± 0%     2.23M ± 0%  +0.05%  (p=0.000 n=23+24)
Compiler     6.46M ± 0%     6.46M ± 0%  +0.02%  (p=0.000 n=24+25)


Change-Id: I2629c291892827493d7b55ec4d83f6973a2ab133
Reviewed-on: https://go-review.googlesource.com/20026
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-29 22:40:43 +00:00
Keith Randall
4fffd4569d [dev.ssa] Merge remote-tracking branch 'origin/master' into ssamerge
(Last?) Semi-regular merge from tip to dev.ssa.

Conflicts:
	src/cmd/compile/internal/gc/closure.go
	src/cmd/compile/internal/gc/gsubr.go
	src/cmd/compile/internal/gc/lex.go
	src/cmd/compile/internal/gc/pgen.go
	src/cmd/compile/internal/gc/syntax.go
	src/cmd/compile/internal/gc/walk.go
	src/cmd/internal/obj/pass.go

Change-Id: Ib5ea8bf74d420f4902a9c6208761be9f22371ae7
2016-02-29 13:32:20 -08:00
Keith Randall
f1f366c1e7 [dev.ssa] cmd/compile: MOVBconst might also clobber flags
It gets rewritten to an xor by the linker also.

Change-Id: Iae35130325d41bd1a09b7e971190cae6f4e17fac
Reviewed-on: https://go-review.googlesource.com/20058
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-29 19:39:15 +00:00
David Crawshaw
07ccc21295 cmd/link: skip allocation when reading symbol name
The object file reader in cmd/link reads the symbol name into a scratch
[]byte, converts it to a string, and then does a substring replacement.
Instead, this CL does the replacement on the []byte into the scratch
space and then creates the final string.

Linking godoc without DWARF, best of ten, shows a ~10% improvement.

tip:           real 0m1.099s user 0m1.541s
this:          real 0m0.990s user 0m1.280s

This is part of an attempt to make suffixarray string deduping
come out as a wash, but it's not there yet:

cl/19987:      real 0m1.335s user 0m1.794s
cl/19987+this: real 0m1.225s user 0m1.540s

Change-Id: Idf061fdfbd7f08aa3a1f5933d3f111fdd1659210
Reviewed-on: https://go-review.googlesource.com/20025
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-29 19:30:48 +00:00
David Crawshaw
6d0b551931 cmd/link: track offset instead of using seek
The Cpos function is used frequently (at least once per symbol) and
it is implemented with the seek syscall. Instead, track current
output offset and use it.

Building the godoc binary with DWARF, best of ten:

tip:  real 0m1.287s user 0m1.573s
this: real 0m1.208s user 0m1.555s

Change-Id: I068148695cd6b4d32cd145db25e59e6f6bae6945
Reviewed-on: https://go-review.googlesource.com/20055
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-29 19:14:20 +00:00
Robert Griesemer
ed1a5e5da6 cmd/compile: cleanup number lexing
Change-Id: Ib0dd458d4ab1c58a2baf36491e288ac32e2ff99e
Reviewed-on: https://go-review.googlesource.com/19962
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-29 19:00:10 +00:00
David Crawshaw
36f25a7e7b cmd/link: allocate small []byte reads together
Reduces number of memory allocations by 12%:

Before: 1816664
After:  1581591

Small speed improvement.

Change-Id: I61281fb852e8e31851a350e3ae756676705024a4
Reviewed-on: https://go-review.googlesource.com/20027
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-29 18:45:35 +00:00
Shahar Kohanim
8096881927 cmd/link: batch allocations of Lsym
Reduces best of 10 linking of cmd/go by ~5%

Change-Id: If673b877ee12595dae517d7eb48430451e5cadba
Reviewed-on: https://go-review.googlesource.com/20060
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-29 17:32:11 +00:00
Shahar Kohanim
e0b04fa508 cmd/link: Preallocate Lsym map
Preallocate ~2MB for Lsym map (size calculation from http://play.golang.org/p/9L7F5naXRr).
Reduces best of 10 link time of cmd/go by ~4%.
On cmd/go max resident size unaffected, on println hello world max resident size grows by 4mb from 18mb->22mb. Performance improves in both cases.

tip:  real  0m1.283s user  0m1.502s sys 0m0.144s
this: real  0m1.341s user  0m1.598s sys 0m0.136s

Change-Id: I4a95e45fe552f1f64f53e868421b9f45a34f8b96
Reviewed-on: https://go-review.googlesource.com/19979
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-29 17:30:13 +00:00
Benoit Sigoure
21f2cb60ea syscall: Fix generator for Linux syscalls.
In golang.org/cl/14449 the `getdents' system call got changed to use
_SYS_getdents as a layer of indirection instead of SYS_GETDENTS64 for
compatibility with mips64, but this broke mksyscall.pl, which then
died with with:
  syscall_linux.go:840: malformed //sys declaration

Change-Id: Icb61965d8730f6e81f9fb0fa28c7bab635470f09
Reviewed-on: https://go-review.googlesource.com/20051
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-29 17:28:00 +00:00
Ilya Tocar
5c5fa3628c [dev.ssa] cmd/compile/internal/ssa: replace load of store with a copy
This is a AMD64 version of CL19743.
Saves additional 1574 bytes in go binary.
This also speeds up bzip2 by 1-4%

Change-Id: I031ba423663c4e83fdefe44e5296f24143e303da
Reviewed-on: https://go-review.googlesource.com/19939
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-29 14:29:28 +00:00
Ilya Tocar
1b1d0a9a80 [dev.ssa] cmd/compile: Use movups for xmm->xmm mov
Movups is 1 byte smaller than movapd that we currently use.

Change-Id: I22f771f066529352722a28543535ec43497cb9c5
Reviewed-on: https://go-review.googlesource.com/19938
Reviewed-by: David Chase <drchase@google.com>
2016-02-29 14:23:44 +00:00
Brad Fitzpatrick
351c15f1ce all: remove public named return values when useless
Named returned values should only be used on public funcs and methods
when it contributes to the documentation.

Named return values should not be used if they're only saving the
programmer a few lines of code inside the body of the function,
especially if that means there's stutter in the documentation or it
was only there so the programmer could use a naked return
statement. (Naked returns should not be used except in very small
functions)

This change is a manual audit & cleanup of public func signatures.

Signatures were not changed if:

* the func was private (wouldn't be in public godoc)
* the documentation referenced it
* the named return value was an interesting name. (i.e. it wasn't
  simply stutter, repeating the name of the type)

There should be no changes in behavior. (At least: none intended)

Change-Id: I3472ef49619678fe786e5e0994bdf2d9de76d109
Reviewed-on: https://go-review.googlesource.com/20024
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-02-29 03:31:19 +00:00
Shenghou Ma
28ce6f3600 time: document Tick will return nil if d <= 0
Fixes #14557.

Change-Id: I9610b79aafe9c15f9c998739b586fd0b41b90d70
Reviewed-on: https://go-review.googlesource.com/20031
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-29 02:33:26 +00:00
Josh Bleecher Snyder
1b417e20ff cmd/compile: superficial cleanup in maplit
Mostly renaming variables for clarity.

Passes toolstash -cmp.

Change-Id: I9867137c34c14985cbbbdb2d34fbbe4cc65cb6fb
Reviewed-on: https://go-review.googlesource.com/20023
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-29 02:17:58 +00:00
Ian Lance Taylor
1d5001afef cmd/compile: change Node.Nbody, Func.Inl from *NodeList to Nodes
Passes toolstash -cmp.

Casual timings show about a 3% improvement in compile times.

Update #14473.

Change-Id: I584add2e8f1a52486ba418b25ba6122b7347b643
Reviewed-on: https://go-review.googlesource.com/19989
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-29 00:33:32 +00:00
Martin Möhrmann
75cc05fa55 fmt: fix formatting of numbers with f.space and f.plus specified
Do not replace the sign in front of a number with a space if both
f.space and f.plus are both specified for number formatting.
This was already the case for integers but not for floats
and complex numbers.

Updates: #14543.

Change-Id: I07ddeb505003db84a8a7d2c743dc19fc427a00bd
Reviewed-on: https://go-review.googlesource.com/19974
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-02-29 00:17:07 +00:00
Ian Lance Taylor
f5ab890c18 cmd/go: only check SWIG intsize once per build
Besides being more efficient in a large build, this avoids a possible
race when creating the input file.

Change-Id: Ifc2cb055925a76be9c90eac56d84ebd9e14f2bbc
Reviewed-on: https://go-review.googlesource.com/19392
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-02-29 00:08:51 +00:00
David Chase
8107b0012f [dev.ssa] cmd/compile: use 32-bit load to read writebarrier
Avoid targeting a partial register with load;
ensure source of load (writebarrier) is aligned.

Better yet would be "CMPB $1,writebarrier" but that requires
wrestling with flagalloc (mem operand complicates moving
instruction around).

Didn't see a change in time for
   benchcmd -n 10 Build go build net/http

Verified that we clean the code up properly:
   0x20a8 <main.main+104>:	mov    0xc30a2(%rip),%eax
                            # 0xc5150 <runtime.writeBarrier>
   0x20ae <main.main+110>:	test   %al,%al

Change-Id: Id5fb8c260eaec27bd727cb0ae1476c60343b0986
Reviewed-on: https://go-review.googlesource.com/19998
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-28 22:29:23 +00:00
David Chase
34f048c9d9 [dev.ssa] cmd/compile: small optimization to prove using sdom tweak
Exposed data already in sdom to avoid recreating it in prove.

Change-Id: I834c9c03ed8faeaee013e5a1b3f955908f0e0915
Reviewed-on: https://go-review.googlesource.com/19999
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro>
2016-02-28 22:28:24 +00:00
Tamir Duberstein
622780b1c1 crypto/tls: don't log expected errors in test
This is minor cleanup that reduces test output noise.

Change-Id: Ib6db4daf8cb67b7784b2d5b222fa37c7f78a6a04
Reviewed-on: https://go-review.googlesource.com/19997
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 20:36:38 +00:00
Alexandru Moșoi
bdea1d58cf [dev.ssa] cmd/compile/internal/ssa: remove proven redundant controls.
* It does very simple bounds checking elimination. E.g.
removes the second check in for i := range a { a[i]++; a[i++]; }
* Improves on the following redundant expression:
return a6 || (a6 || (a6 || a4)) || (a6 || (a4 || a6 || (false || a6)))
* Linear in the number of block edges.

I patched in CL 12960 that does bounds, nil and constant propagation
to make sure this CL is not just redundant. Size of pkg/tool/linux_amd64/*
(excluding compile which is affected by this change):

With IsInBounds and IsSliceInBounds
-this -12960 92285080
+this -12960 91947416
-this +12960 91978976
+this +12960 91923088

Gain is ~110% of 12960.

Without IsInBounds and IsSliceInBounds (older run)
-this -12960 95515512
+this -12960 95492536
-this +12960 95216920
+this +12960 95204440

Shaves 22k on its own.

* Can we handle IsInBounds better with this? In
for i := range a { a[i]++; } the bounds checking at a[i]
is not eliminated.

Change-Id: I98957427399145fb33693173fd4d5a8d71c7cc20
Reviewed-on: https://go-review.googlesource.com/19710
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 19:48:20 +00:00
Tamir Duberstein
186d3e30be crypto/tls: tests prefer constants to opaque literals
This is minor cleanup that makes the tests more readable.

Change-Id: I9f1f98f0f035096c284bdf3501e7520517a3e4d9
Reviewed-on: https://go-review.googlesource.com/19993
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 19:31:48 +00:00
Justin Nuß
92408107dc mime: Fix BenchmarkQDecodeHeader to call DecodeHeader
Found this while reading through the code. The benchmark
accidently called the wrong function.

Change-Id: Idb88aa71e7098a4e29e7f5f39e64f8c5f8936a2a
Reviewed-on: https://go-review.googlesource.com/19977
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 17:24:01 +00:00
Todd Neal
4e95dfed01 [dev.ssa] cmd/compile: add max arg length to opcodes
Add the max arg length to opcodes and use it in zcse.  Doesn't affect
speed, but allows better checking in checkFunc and removes the need
to keep a list of zero arg opcodes up to date.

Change-Id: I157c6587154604119720ec6228b767b6e52bb5c7
Reviewed-on: https://go-review.googlesource.com/19994
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 14:50:19 +00:00
Joe Tsai
ff27421067 compress/bzip2: fix benchmark to actually measure decompression rate
Motivation:
* Previously, the size of the compressed data was used for metrics,
rather than the uncompressed size. This causes the library to appear
to perform poorly relative to C or other implementation. Switch it
to use the uncompressed size so that it matches how decompression
benchmarks are usually done (like in compress/flate). This also makes
it easier to compare bzip2 rates to other algorithms since they measure
performance in this way.
* Also, reset the timer after doing initialization work.

Change-Id: I32112c2ee8e7391e658c9cf31039f70a689d9b9d
Reviewed-on: https://go-review.googlesource.com/17611
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 11:06:40 +00:00
Joe Tsai
47379929f1 compress/bzip2: use correct block size
The bzip2 block size is a multiple of 100*1000 not 100*1024.
Thus, the bzip2 decoder would incorrectly decode files with larger
block sizes when it should have otherwise failed.
Fortunately, we can correct this in a backwards compatible way since
Go has no implementation of a bzip2 encoder to produce bad blocks :)

To confirm that the C bzip2 utlity chokes on this data:
	$ echo "425a683131415926535936dc55330063ffc0006000200020a40830008b00
	08b8bb9229c28481b6e2a998" | xxd -r -p | bzip2 -d

	bzip2: Data integrity error when decompressing.

Fixes #13941

Change-Id: I2402e8829a8027ef94dd4fac050b200440a3d4e4
Reviewed-on: https://go-review.googlesource.com/20011
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 10:54:03 +00:00
Joe Tsai
5fc4decd10 compress/flate: extract LZ77 dictionary logic into seperate struct
The LZ77 portion of DEFLATE is relatively self-contained. For the
decompression side of things, we extract this logic out for the
following reasons:
* It is easier to test just the LZ77 portion of the logic.
* It reduces the noise in the inflate.go

Also, we adjust the way that callbacks are handled in the inflate.
Instead of using functions to abstract the logical componets of
huffmanBlock(), use goto statements to jump between the necessary
sections. This is faster since it avoids a function call and is
arguably more readable.

benchmark                              old MB/s     new MB/s     speedup
BenchmarkDecodeDigitsSpeed1e4-4        53.62        60.11        1.12x
BenchmarkDecodeDigitsSpeed1e5-4        61.90        69.07        1.12x
BenchmarkDecodeDigitsSpeed1e6-4        63.24        70.58        1.12x
BenchmarkDecodeDigitsDefault1e4-4      54.10        59.00        1.09x
BenchmarkDecodeDigitsDefault1e5-4      69.50        74.07        1.07x
BenchmarkDecodeDigitsDefault1e6-4      71.54        75.85        1.06x
BenchmarkDecodeDigitsCompress1e4-4     54.39        58.94        1.08x
BenchmarkDecodeDigitsCompress1e5-4     69.21        73.96        1.07x
BenchmarkDecodeDigitsCompress1e6-4     71.14        75.75        1.06x
BenchmarkDecodeTwainSpeed1e4-4         53.15        58.13        1.09x
BenchmarkDecodeTwainSpeed1e5-4         66.56        72.29        1.09x
BenchmarkDecodeTwainSpeed1e6-4         69.13        75.11        1.09x
BenchmarkDecodeTwainDefault1e4-4       56.00        60.23        1.08x
BenchmarkDecodeTwainDefault1e5-4       77.84        82.27        1.06x
BenchmarkDecodeTwainDefault1e6-4       82.07        86.85        1.06x
BenchmarkDecodeTwainCompress1e4-4      56.13        60.38        1.08x
BenchmarkDecodeTwainCompress1e5-4      78.23        82.62        1.06x
BenchmarkDecodeTwainCompress1e6-4      82.38        86.73        1.05x

Change-Id: I8c6ae0e6bed652dd0570fc113c999977f5e71636
Reviewed-on: https://go-review.googlesource.com/16528
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 10:36:01 +00:00
Caio Marcelo de Oliveira Filho
3cb870d47b testing: make failure in benchmark cause non-zero exit status
Moves the implementation of RunBenchmarks to a non-exported function
that returns whether the execution was OK, and uses that to identify
failure in benchmarks.The exported function is kept for compatibility.

Like before, benchmarks will only be executed if tests and examples
pass. The PASS message will not be printed if there was a failure in
a benchmark.

Example output

	BenchmarkThatCallsFatal-8	--- FAIL: BenchmarkThatCallsFatal-8
		x_test.go:6: called by benchmark
	FAIL
	exit status 1
	FAIL	_/.../src/cmd/go/testdata/src/benchfatal	0.009s

Fixes #14307.

Change-Id: I6f3ddadc7da8a250763168cc099ae8b325a79602
Reviewed-on: https://go-review.googlesource.com/19889
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-28 05:19:05 +00:00
Ian Lance Taylor
c8ef0df06c cmd/cgo: add hooks for thread sanitizer
When Go code is used with C code compiled with -fsanitize=thread, adds
thread sanitizer calls so that correctly synchronized Go code does not
cause spurious failure reports from the thread sanitizer.  This may
cause some false negatives, but for the thread sanitizer what is most
important is avoiding false positives.

Change-Id: If670e4a6f2874c7a2be2ff7db8728c6036340a52
Reviewed-on: https://go-review.googlesource.com/17421
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2016-02-28 04:56:17 +00:00
Austin Clements
d62d831882 runtime: clean up adjustpointer and eliminate write barrier
Commit a5c3bbe modified adjustpointers to use *uintptrs instead of
*unsafe.Pointers for manipulating stack pointers for clarity and to
eliminate the unnecessary write barrier when writing the updated stack
pointer.

This commit makes the equivalent change to adjustpointer.

Change-Id: I6dc309590b298bdd86ecdc9737db848d6786c3f7
Reviewed-on: https://go-review.googlesource.com/17148
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-28 04:19:01 +00:00
Ian Lance Taylor
71cc445cf9 cmd/cgo: recognize known C typedefs as types
Fixes #14483.

Change-Id: I0cddfe27fd8d00ba85659d0b618410e39ebf45cb
Reviewed-on: https://go-review.googlesource.com/19860
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-27 22:51:51 +00:00
Ian Lance Taylor
922ce58de0 cmd/compile: change Func.Cvars to the new Nodes type
Update #14473.

Change-Id: Iba1ecf42d9ab5a93144941439d5cc6b0b4f4a3ac
Reviewed-on: https://go-review.googlesource.com/19992
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-27 22:43:26 +00:00
Martin Möhrmann
7da4ceddd0 fmt: simplify buffer write methods and adjust calls to them
Once upon a time fmt did use bytes.Buffer for its buffer.
The buffer write methods still mimic the bytes.Buffer signatures.
The current code depends on manipulating the buffer []bytes array directly
which makes going back to bytes.Buffer by only changing the type of buffer
impossible. Since type buffer is not exported the methods can be simplified
to the needs of fmt. This saves space and avoids unnecessary overhead.

Use WriteString instead of Write for known inputs since
WriteString is faster than Write to append the same data.
This also saves space in the binary.

Remove the add method from Printer and depending on the data to be written
use WriteRune or WriteByte directly instead.

In total makes the go binary around 4 kilobyte smaller.

name                  old time/op  new time/op  delta
SprintfEmpty-2        24.1ns ± 3%  23.8ns ± 1%  -1.14%  (p=0.000 n=20+20)
SprintfString-2        114ns ± 2%   114ns ± 4%    ~     (p=0.558 n=20+19)
SprintfInt-2           116ns ± 9%   118ns ± 7%    ~     (p=0.086 n=20+20)
SprintfIntInt-2        195ns ± 6%   193ns ± 5%    ~     (p=0.345 n=20+19)
SprintfPrefixedInt-2   251ns ±16%   241ns ± 9%  -3.69%  (p=0.024 n=20+19)
SprintfFloat-2         203ns ± 4%   205ns ± 5%    ~     (p=0.153 n=20+20)
SprintfBoolean-2       101ns ± 7%    96ns ±11%  -5.23%  (p=0.005 n=19+20)
ManyArgs-2             651ns ± 7%   628ns ± 7%  -3.44%  (p=0.002 n=20+20)
FprintInt-2            164ns ± 2%   158ns ± 2%  -3.62%  (p=0.000 n=20+18)
FprintfBytes-2         215ns ± 1%   216ns ± 1%  +0.58%  (p=0.000 n=20+20)
FprintIntNoAlloc-2     115ns ± 0%   112ns ± 0%  -2.61%  (p=0.000 n=20+20)
ScanInts-2             700µs ± 0%   702µs ± 1%  +0.38%  (p=0.000 n=18+20)
ScanRecursiveInt-2    82.7ms ± 0%  82.7ms ± 0%    ~     (p=0.820 n=20+20)

Change-Id: I0409eb170b8a26d9f4eb271f6292e5d39faf2d8b
Reviewed-on: https://go-review.googlesource.com/19955
Reviewed-by: Rob Pike <r@golang.org>
2016-02-27 21:12:19 +00:00
Justin Nuß
9d73a6dcad strconv: Avoid allocation in AppendQuote*
The current implementations of the AppendQuote functions use quoteWith
(through Quote) for quoting the given value and appends the returned
string to the dst byte slice. quoteWith internally creates a byte slice
on each call which gets converted to a string in Quote.

This means the AppendQuote functions always allocates a new byte slice
and a string only to append them to an existing byte slice. In the case
of (Append)QuoteRune the string passed to quoteWith will also needs to
be allocated from a rune first.

Split quoteWith into two functions (quoteWith and appendQuotedWith) and
replace the call to Quote inside AppendQuote with appendQuotedWith,
which appends directly to the byte slice passed to AppendQuote and also
avoids the []byte->string conversion.

Also introduce the 2 functions quoteRuneWith and appendQuotedRuneWith
that work the same way as quoteWith and appendQuotedWith, but take a
single rune instead of a string, to avoid allocating a new string when
appending a single rune, and use them in (Append)QuoteRune.

Also update the ToASCII and ToGraphic variants to use the new functions.

Benchmark results:

benchmark                      old ns/op     new ns/op     delta
BenchmarkQuote-8               428           503           +17.52%
BenchmarkQuoteRune-8           148           105           -29.05%
BenchmarkAppendQuote-8         435           307           -29.43%
BenchmarkAppendQuoteRune-8     158           23.5          -85.13%

benchmark                      old allocs     new allocs     delta
BenchmarkQuote-8               3              3              +0.00%
BenchmarkQuoteRune-8           3              2              -33.33%
BenchmarkAppendQuote-8         3              0              -100.00%
BenchmarkAppendQuoteRune-8     3              0              -100.00%

benchmark                      old bytes     new bytes     delta
BenchmarkQuote-8               144           144           +0.00%
BenchmarkQuoteRune-8           16            16            +0.00%
BenchmarkAppendQuote-8         144           0             -100.00%
BenchmarkAppendQuoteRune-8     16            0             -100.00%

Change-Id: I77c148d5c7242f1b0edbbeeea184878abb51a522
Reviewed-on: https://go-review.googlesource.com/18962
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-27 17:15:01 +00:00
Mikio Hara
f3f920ff8d crypto/tls: don't send IPv6 literals and absolute FQDNs as SNI values
This is a followup change to #13111 for filtering out IPv6 literals and
absolute FQDNs from being as the SNI values.

Updates #13111.
Fixes #14404.

Change-Id: I09ab8d2a9153d9a92147e57ca141f2e97ddcef6e
Reviewed-on: https://go-review.googlesource.com/19704
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-27 10:05:53 +00:00
Martin Möhrmann
abcad1e59d fmt: change padding functions to avoid package init
Move the decision if zero padding is allowed to doPrintf
where the other formatting decisions are made.

Removes some dead code for negative f.wid that was never used
due to f.wid always being positive and f.minus deciding if left
or right padding should be used.

New padding code writes directly into the buffer and is as fast
as the old version but avoids the cost of needing package init.

name              old time/op  new time/op  delta
SprintfPadding-2   246ns ± 5%   245ns ± 4%   ~     (p=0.345 n=50+47)

Change-Id: I7dfddbac8e328f4ef0cdee8fafc0d06c784b2711
Reviewed-on: https://go-review.googlesource.com/19957
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-02-27 06:59:39 +00:00
Matthew Dempsky
8b96bc6818 cmd/compile: remove unneeded test binary
Accidentally added in https://golang.org/cl/19968.

Change-Id: Id70917c4d1f69db149688d797c90a19557d16f72
Reviewed-on: https://go-review.googlesource.com/19985
Reviewed-by: Minux Ma <minux@golang.org>
2016-02-27 06:17:36 +00:00
David du Colombier
ccf39a23b1 debug/gosym: fix TestPCLine on Plan 9
Plan 9 doesn't define main, so the INITENTRY
symbol remains with the SXREF type, which leads
Entryvalue to fail on "entry not text: main".

Fixes #14536.

Change-Id: Id9b7d61e5c2202aba3ec9cd52f5b56e0a38f7c47
Reviewed-on: https://go-review.googlesource.com/19973
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-27 05:13:33 +00:00
Keith Randall
91f69c675d [dev.ssa] cmd/compile: with -N, don't put JMPs after calls
plive doesn't like the fact that we put JMPs right
after CALL ops to select{send,recv}.

Fixes SSA -N build.

Change-Id: I9b3c9e5293196094fd5a6206dd2f99784951f7a9
Reviewed-on: https://go-review.googlesource.com/19982
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-02-27 02:42:19 +00:00
Matthew Dempsky
52f099c426 cmd/compile: simplify lexinit and lexfini
Split the syms array into separate basicTypes and builtinFuncs arrays.

Also, in lexfini, instead of duplicating the code from lexinit to
declare the builtin identifiers in the user package, just import them
from builtinpkg like how importdot works.

Change-Id: Ic3b3b454627a46f7bd5f290d0e31443e659d431f
Reviewed-on: https://go-review.googlesource.com/19936
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-27 01:02:25 +00:00
Ian Lance Taylor
188e3d2515 cmd/compile: change Func.{Enter,Exit} from NodeList to slice
Introduces a new types Nodes that can be used to replace NodeList.

Update #14473.

Change-Id: Id77c5dcae0cbeb898ba12dd46bd400aad408871c
Reviewed-on: https://go-review.googlesource.com/19969
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-27 00:59:47 +00:00
Martin Möhrmann
6520da6ed5 fmt: use public io.RuneScanner interface for ScanState reader
All io.Reader that are passed to newScanState in all the standard
library tests that implement io.RuneReader also implement io.RuneScanner.

Do not check on each call ScanState's UnreadRune that the used RuneReader
also implements the UnreadRune method by using a private interface.
Instead require the used Reader to implement the public RuneScanner
interface.

The extra implementation logic for UnreadRune is removed from ScanState.
Instead the readRune wrapper is extended to implement UnreadRune for the
RuneScanner interface. If the Reader passed to newScanstate does not
implement RuneScanner the readRune wrapper is used to implement the
missing functionality.

Note that a RuneReader that does not implement RuneScanner will also
be wrapped by runeRead which was not the case before.
Performance with the readRune wrapper is better than without before.

Add benchmark to compare performance with and without using the
readRune wrapper.

name                             old time/op  new time/op  delta
ScanInts-2                        704µs ± 0%   615µs ± 1%  -12.73%  (p=0.000 n=20+20)
ScanRecursiveInt-2               82.6ms ± 0%  51.4ms ± 0%  -37.71%  (p=0.000 n=20+20)
ScanRecursiveIntReaderWrapper-2  85.1ms ± 0%  52.4ms ± 0%  -38.36%  (p=0.000 n=20+20)

Change-Id: I8c6e85db9b87a8171caab12f020b6e256b498e81
Reviewed-on: https://go-review.googlesource.com/19895
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-02-26 23:46:51 +00:00
Josh Bleecher Snyder
b30e1d728c cmd/compile: consolidate alg code
Pull all alg-related code into its own file.
subr.go is a Hobbesian Leviathan.

100% code movement. Cleanup and improvements to follow.

Change-Id: Ib9c8f66563fdda90c6e8cf646d366a9487a4648d
Reviewed-on: https://go-review.googlesource.com/19980
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 23:39:01 +00:00
Matthew Dempsky
f5f8b38462 cmd/compile: eliminate prectab
While here, merge LINC and LDEC into LINCOP.

Fixes #13244.

Change-Id: I8ea426f986d60d35c3b1a80c056a7aa49d22d802
Reviewed-on: https://go-review.googlesource.com/19928
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-02-26 23:12:43 +00:00
Ian Lance Taylor
6abc8c9a88 cmd/compile: change Func.Inldcl from []*Node to *[]*Node
Save a few bytes in Func.

Passes toolstash -cmp.

Update #14473.

Change-Id: I824fa7d5cb2d93f6f59938ccd86114abcbea0043
Reviewed-on: https://go-review.googlesource.com/19968
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26 22:45:21 +00:00
Ian Lance Taylor
52d9479e3b cmd/compile: convert Func.Cvars from *NodeList to *[]*Node
Passes toolstash -cmp.

Update #14473.

Change-Id: I7285175b1992a29033fdc9e81d6f30545e5cc30d
Reviewed-on: https://go-review.googlesource.com/19967
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26 22:38:44 +00:00
Josh Bleecher Snyder
92bf58c238 cmd/compile: recognize more memory runs in generated algs
The old implementation assumed that all memory runs
were terminated by non-memory fields.
This isn't necessarily so.
They might be terminated by padding or blank fields.

For example, given

type T struct {
	a int64
	b byte
	c, d, e int64
}

the old implementation did a memory comparison on a+b, on c, and on d+e.

Instead, check for memory runs at the beginning of every round.
This now generates a memory comparison on a+b and on c+d+e.

Also, delete some now-dead code.

Change-Id: I66bffb111420adf6919bd708e4fb3a1e1f07fadd
Reviewed-on: https://go-review.googlesource.com/19841
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-26 22:18:30 +00:00
Josh Bleecher Snyder
0f5d78f678 cmd/compile: factor shared code from geneq and genhash
Passes toolstash -cmp.

Change-Id: Ifae69e5ba673f01da3dfc1fd30cdc51873481623
Reviewed-on: https://go-review.googlesource.com/19840
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-02-26 22:17:31 +00:00
Robert Griesemer
3c0fae5306 cmd/compile: track pragmas in lexer rather than global variables
By using a Pragma bit set (8 bits) rather than 8 booleans, also
reduce Func type size by 8 bytes (208B -> 200B on 64bit platforms,
116B -> 108B on 32bit platforms).

Change-Id: Ibb7e1f8c418a0b5bc6ff813cbdde7bc6f0013b5a
Reviewed-on: https://go-review.googlesource.com/19966
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-02-26 22:01:16 +00:00
Matthew Dempsky
071e43a958 cmd/compile: stop representing keywords as Syms
Instead add a dedicated keywords map for use in lexer.ident and drop
Sym's Lexical field.

Change-Id: Ia668e65499035ff7167fabbbd0cd027102b21231
Reviewed-on: https://go-review.googlesource.com/19935
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 21:25:59 +00:00
Matthew Dempsky
af558acc47 cmd/compile: fix contrived line number errors
If a general comment contains multiple newline characters, we can't
simply unread one and then re-lex it via the general whitespace lexing
phase, because then we'll reset lineno to the line before the "*/"
marker, rather than keeping it where we found the "/*" marker.

Also, for processing imports, call importfile before advancing the
lexer with p.next(), so that lineno reflects the line where we found
the import path, and not the token afterwards.

Fixes #14520.

Change-Id: I785a2d83d632280113d4b757de0d57c88ba2caf4
Reviewed-on: https://go-review.googlesource.com/19934
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 21:25:43 +00:00
Ian Lance Taylor
a131a66e63 cmd/compile: create test binary in temp directory
The new TestDashS was leaving a dreg "test" file in
cmd/compile/internal/gc.  Create it in the temporary directory instead.

Also change path.Join to filepath.Join throughout global_test.go.

Change-Id: Ib7707fada2b3ab5e8abc2ba74e4c402821c1408b
Reviewed-on: https://go-review.googlesource.com/19965
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-02-26 21:24:42 +00:00
Ian Lance Taylor
b66a892358 cmd/compile: change Func.{Dcl,Inldcl} from NodeList to slice
A slice uses less memory than a NodeList, and has better memory locality
when walking the list.

This uncovered a tricky case involving closures: the escape analysis
pass when run on a closure was appending to the Dcl list of the OCLOSURE
rather than the ODCLFUNC.  This happened to work because they shared the
same NodeList.  Fixed with a change to addrescapes, and a check to
Tempname to catch any recurrences.

This removes the last use of the listsort function outside of tests.
I'll send a separate CL to remove it.

Unfortunately, while this passes all tests, it does not pass toolstash
-cmp.  The problem is that cmpstackvarlt does not fully determine the
sort order, and the change from listsort to sort.Sort, while generally
desirable, produces a different ordering.  I could stage this by first
making cmpstackvarlt fully determined, but no matter what toolstash -cmp
is going to break at some point.

In my casual testing the compiler is 2.2% faster.

Update #14473.

Change-Id: I367d66daa4ec73ed95c14c66ccda3a2133ad95d5
Reviewed-on: https://go-review.googlesource.com/19919
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-26 20:43:23 +00:00