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

7705 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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