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

8199 Commits

Author SHA1 Message Date
Keith Randall
60fd32a47f cmd/compile: change the way we handle large map values
mapaccess{1,2} returns a pointer to the value.  When the key
is not in the map, it returns a pointer to zeroed memory.
Currently, for large map values we have a complicated scheme which
dynamically allocates zeroed memory for this purpose.  It is ugly
code and requires an atomic.Load in a bunch of places we'd rather
not have it.

Switch to a scheme where callsites of mapaccess{1,2} which expect
large return values pass in a pointer to zeroed memory that
mapaccess can return if the key is not found.  This avoids the
atomic.Load on all map accesses with a few extra instructions only
for the large value acccesses, plus a bit of bss space.

There was a time (1.4 & 1.5?) where we did something like this but
all the tricks to make the right size zero value were done by the
linker.  That scheme broke in the presence of dyamic linking.
The scheme in this CL works even when dynamic linking.

Fixes #12337

Change-Id: Ic2d0319944af33bbb59785938d9ab80958d1b4b1
Reviewed-on: https://go-review.googlesource.com/22221
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-04-20 21:15:31 +00:00
David Crawshaw
79c527f4a7 cmd/link: move ppc64 genplt declarations into loop
(Split out from CL 22243.)

Change-Id: I07709a0c417e7a57e839e5085a37db7d5fbf3a35
Reviewed-on: https://go-review.googlesource.com/22322
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-20 19:10:59 +00:00
David Crawshaw
854ab14b7e cmd/link: move pcln declarations into loops
(Split out from CL 22243.)

Change-Id: Idac1748c8db2b2ed0484e4afadb105c471c6ce34
Reviewed-on: https://go-review.googlesource.com/22321
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-20 18:57:57 +00:00
David Crawshaw
1dad218da1 cmd/link: move declarations into loops
(Split out from CL 22205.)

Change-Id: Id32698f48ce02b55c15b6f2842215e0ffdbf425b
Reviewed-on: https://go-review.googlesource.com/22298
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-20 17:59:11 +00:00
Keith Randall
b57ac33331 cmd/compile: forward-looking desired register biasing
Improve forward-looking desired register calculations.
It is now inter-block and handles a bunch more cases.

Fixes #14504
Fixes #14828
Fixes #15254

Change-Id: Ic240fa0ec6a779d80f577f55c8a6c4ac8c1a940a
Reviewed-on: https://go-review.googlesource.com/22160
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-04-20 15:31:42 +00:00
Keith Randall
bfe0cbdc50 cmd/compile,runtime: pass elem type to {make,grow}slice
No point in passing the slice type to these functions.
All they need is the element type.  One less indirection,
maybe a few less []T type descriptors in the binary.

Change-Id: Ib0b83b5f14ca21d995ecc199ce8ac00c4eb375e6
Reviewed-on: https://go-review.googlesource.com/22275
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-04-20 00:31:16 +00:00
Matthew Dempsky
2244ae4173 cmd/compile/internal/gc: simplify typecheck's Efoo consts
There's no need for Eiota, Eindir, Eaddr, or Eproc; the values are
threaded through to denote various typechecking contexts, but they
don't actually influence typechecking behavior at all.

Also, while here, switch the Efoo const declarations to use iota.

Passes toolstash -cmp.

Change-Id: I5cea869ccd0755c481cf071978f863474bc9c1ed
Reviewed-on: https://go-review.googlesource.com/22271
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-19 22:57:26 +00:00
Alexandru Moșoi
8b20fd000d cmd/compile: transform some Phis into Or8.
func f(a, b bool) bool {
          return a || b
}

is now a single instructions (excluding loading and unloading the arguments):
      v10 = ORB <bool> v11 v12 : AX

Change-Id: Iff63399410cb46909f4318ea1c3f45a029f4aa5e
Reviewed-on: https://go-review.googlesource.com/21872
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-04-19 22:04:30 +00:00
Josh Bleecher Snyder
55ab07c224 cmd/compile: static composite literals are side-effect free
This extends CL 22192.

This removes the remaining performance disparity
between non-SSA and SSA on the AppendInPlace benchmarks.

Going from non-SSA to SSA:

AppendInPlace/NoGrow/2Ptr-8  1.60µs ± 5%  1.53µs ± 5%  -4.04%  (p=0.000 n=15+14)
AppendInPlace/NoGrow/3Ptr-8  2.04µs ± 3%  1.96µs ± 2%  -3.90%  (p=0.000 n=13+14)
AppendInPlace/NoGrow/4Ptr-8  2.83µs ± 8%  2.62µs ± 4%  -7.39%  (p=0.000 n=13+15)

Previously these were 20% regressions.

Change-Id: Ie87810bffd598730658e07585f5e2ef979a12b8f
Reviewed-on: https://go-review.googlesource.com/22248
Reviewed-by: Keith Randall <khr@golang.org>
2016-04-19 20:56:00 +00:00
Josh Bleecher Snyder
3c6e60c0e4 cmd/compile: fix isStaticCompositeLiteral
Previously, isStaticCompositeLiteral would
return the wrong value for literals like:

[1]struct{ b []byte }{b: []byte{1}}

Note that the outermost component is an array,
but once we recurse into isStaticCompositeLiteral,
we never check again that arrays are actually arrays.

Instead of adding more logic to the guts of
isStaticCompositeLiteral, allow it to accept
any Node and return the correct answer.

Change-Id: I6af7814a9037bbc7043da9a96137fbee067bbe0e
Reviewed-on: https://go-review.googlesource.com/22247
Reviewed-by: Keith Randall <khr@golang.org>
2016-04-19 20:55:41 +00:00
Josh Bleecher Snyder
03e216f30d cmd/compile: re-enable in-place append optimization
CL 21891 was too clever in its attempts to avoid spills.
Storing newlen too early caused uses of append in the runtime
itself to receive an inconsistent view of a slice,
leading to corruption.

This CL makes the generate code much more similar to
the old backend. It spills more than before,
but those spills have been contained to the grow path.
It recalculates newlen unnecessarily on the fast path,
but that's measurably cheaper than spilling it.

CL 21891 caused runtime failures in 6 of 2000 runs
of net/http and crypto/x509 in my test setup.
This CL has gone 6000 runs without a failure.


Benchmarks going from master to this CL:

name                         old time/op  new time/op  delta
AppendInPlace/NoGrow/Byte-8   439ns ± 2%   436ns ± 2%  -0.72%  (p=0.001 n=28+27)
AppendInPlace/NoGrow/1Ptr-8   901ns ± 0%   856ns ± 0%  -4.95%  (p=0.000 n=26+29)
AppendInPlace/NoGrow/2Ptr-8  2.15µs ± 1%  1.95µs ± 0%  -9.07%  (p=0.000 n=28+30)
AppendInPlace/NoGrow/3Ptr-8  2.66µs ± 0%  2.45µs ± 0%  -7.93%  (p=0.000 n=29+26)
AppendInPlace/NoGrow/4Ptr-8  3.24µs ± 1%  3.02µs ± 1%  -6.75%  (p=0.000 n=28+30)
AppendInPlace/Grow/Byte-8     269ns ± 1%   271ns ± 1%  +0.84%  (p=0.000 n=30+29)
AppendInPlace/Grow/1Ptr-8     275ns ± 1%   280ns ± 1%  +1.75%  (p=0.000 n=30+30)
AppendInPlace/Grow/2Ptr-8     384ns ± 0%   391ns ± 0%  +1.94%  (p=0.000 n=27+30)
AppendInPlace/Grow/3Ptr-8     455ns ± 0%   462ns ± 0%  +1.43%  (p=0.000 n=29+29)
AppendInPlace/Grow/4Ptr-8     478ns ± 0%   479ns ± 0%  +0.23%  (p=0.000 n=30+27)


However, for the large no-grow cases, there is still more work to be done.
Going from this CL to the non-SSA backend:

name                         old time/op  new time/op  delta
AppendInPlace/NoGrow/Byte-8   436ns ± 2%   436ns ± 2%     ~     (p=0.967 n=27+29)
AppendInPlace/NoGrow/1Ptr-8   856ns ± 0%   884ns ± 0%   +3.28%  (p=0.000 n=29+26)
AppendInPlace/NoGrow/2Ptr-8  1.95µs ± 0%  1.56µs ± 0%  -20.28%  (p=0.000 n=30+29)
AppendInPlace/NoGrow/3Ptr-8  2.45µs ± 0%  1.89µs ± 0%  -22.88%  (p=0.000 n=26+28)
AppendInPlace/NoGrow/4Ptr-8  3.02µs ± 1%  2.56µs ± 1%  -15.35%  (p=0.000 n=30+28)
AppendInPlace/Grow/Byte-8     271ns ± 1%   283ns ± 1%   +4.56%  (p=0.000 n=29+29)
AppendInPlace/Grow/1Ptr-8     280ns ± 1%   288ns ± 1%   +2.99%  (p=0.000 n=30+30)
AppendInPlace/Grow/2Ptr-8     391ns ± 0%   409ns ± 0%   +4.66%  (p=0.000 n=30+29)
AppendInPlace/Grow/3Ptr-8     462ns ± 0%   481ns ± 0%   +4.13%  (p=0.000 n=29+30)
AppendInPlace/Grow/4Ptr-8     479ns ± 0%   502ns ± 0%   +4.81%  (p=0.000 n=27+26)


New generated code:

var x []byte

func a() {
	x = append(x, 1)
}


"".a t=1 size=208 args=0x0 locals=0x48
	0x0000 00000 (a.go:5)	TEXT	"".a(SB), $72-0
	0x0000 00000 (a.go:5)	MOVQ	(TLS), CX
	0x0009 00009 (a.go:5)	CMPQ	SP, 16(CX)
	0x000d 00013 (a.go:5)	JLS	190
	0x0013 00019 (a.go:5)	SUBQ	$72, SP
	0x0017 00023 (a.go:5)	FUNCDATA	$0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0017 00023 (a.go:5)	FUNCDATA	$1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0017 00023 (a.go:6)	MOVQ	"".x+16(SB), CX
	0x001e 00030 (a.go:6)	MOVQ	"".x+8(SB), DX
	0x0025 00037 (a.go:6)	MOVQ	"".x(SB), BX
	0x002c 00044 (a.go:6)	LEAQ	1(DX), BP
	0x0030 00048 (a.go:6)	CMPQ	BP, CX
	0x0033 00051 (a.go:6)	JGT	$0, 73
	0x0035 00053 (a.go:6)	LEAQ	1(DX), AX
	0x0039 00057 (a.go:6)	MOVQ	AX, "".x+8(SB)
	0x0040 00064 (a.go:6)	MOVB	$1, (BX)(DX*1)
	0x0044 00068 (a.go:7)	ADDQ	$72, SP
	0x0048 00072 (a.go:7)	RET
	0x0049 00073 (a.go:6)	LEAQ	type.[]uint8(SB), AX
	0x0050 00080 (a.go:6)	MOVQ	AX, (SP)
	0x0054 00084 (a.go:6)	MOVQ	BX, 8(SP)
	0x0059 00089 (a.go:6)	MOVQ	DX, 16(SP)
	0x005e 00094 (a.go:6)	MOVQ	CX, 24(SP)
	0x0063 00099 (a.go:6)	MOVQ	BP, 32(SP)
	0x0068 00104 (a.go:6)	PCDATA	$0, $0
	0x0068 00104 (a.go:6)	CALL	runtime.growslice(SB)
	0x006d 00109 (a.go:6)	MOVQ	40(SP), CX
	0x0072 00114 (a.go:6)	MOVQ	48(SP), DX
	0x0077 00119 (a.go:6)	MOVQ	DX, "".autotmp_0+64(SP)
	0x007c 00124 (a.go:6)	MOVQ	56(SP), BX
	0x0081 00129 (a.go:6)	MOVQ	BX, "".x+16(SB)
	0x0088 00136 (a.go:6)	MOVL	runtime.writeBarrier(SB), AX
	0x008e 00142 (a.go:6)	TESTB	AL, AL
	0x0090 00144 (a.go:6)	JNE	$0, 162
	0x0092 00146 (a.go:6)	MOVQ	CX, "".x(SB)
	0x0099 00153 (a.go:6)	MOVQ	"".x(SB), BX
	0x00a0 00160 (a.go:6)	JMP	53
	0x00a2 00162 (a.go:6)	LEAQ	"".x(SB), BX
	0x00a9 00169 (a.go:6)	MOVQ	BX, (SP)
	0x00ad 00173 (a.go:6)	MOVQ	CX, 8(SP)
	0x00b2 00178 (a.go:6)	PCDATA	$0, $0
	0x00b2 00178 (a.go:6)	CALL	runtime.writebarrierptr(SB)
	0x00b7 00183 (a.go:6)	MOVQ	"".autotmp_0+64(SP), DX
	0x00bc 00188 (a.go:6)	JMP	153
	0x00be 00190 (a.go:6)	NOP
	0x00be 00190 (a.go:5)	CALL	runtime.morestack_noctxt(SB)
	0x00c3 00195 (a.go:5)	JMP	0


Fixes #14969 again

Change-Id: Ia50463b1f506011aad0718a4fef1d4738e43c32d
Reviewed-on: https://go-review.googlesource.com/22197
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-04-19 18:48:05 +00:00
Robert Griesemer
a5386f3c7d cmd/compile: fix internal consistency check with binary exporter
Per feedback from mdempsky from https://go-review.googlesource.com/22096.

Also fix emitted position info.

Change-Id: I7ff1967430867d922be8784832042c75d81df28b
Reviewed-on: https://go-review.googlesource.com/22198
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-18 22:00:31 +00:00
David Crawshaw
f81ae3b22c cmd/link: shorter type symbol names
Use (part of) a SHA-1 checksum to replace type symbol names.

In typical programs this has no effect because types are not included
in the symbol table. But when dynamically linking, types are in the
table to make sure there is only one *rtype per Go type.

Eventually we may be able to get rid of all pointers to rtype values in
the binary, but probably not by 1.7. And this has a nice effect on
binary size today:

libstd.so:
	before 27.4MB
	after  26.2MB

For #6853.

Change-Id: I603d7f3e5baad84f59f2fd37eeb1e4ae5acfe44a
Reviewed-on: https://go-review.googlesource.com/21583
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-18 20:32:57 +00:00
Keith Randall
4d5adf1eb1 cmd/compile: logical operation identities
Some rewrites to simplify logical operations.

Fixes #14363

Change-Id: I45a1e8f227267cbcca0778101125f7bab776a5dd
Reviewed-on: https://go-review.googlesource.com/22188
Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-18 20:16:15 +00:00
David Crawshaw
4140da7b57 cmd/link, cmd/compile: typelink sorting in linker
Instead of writing out the type almost twice in the symbol name,
teach the linker how to sort typelink symbols by their contents.

This ~halves the size of typelink symbol names, which helps very
large (6KB) names like those mentioned in #15104.

This does not increase the total sorting work done by the linker,
and makes it possible to use shorter symbol names for types. See
the follow-on CL 21583.

Change-Id: Ie5807565ed07d31bc477d20f60e4c0b47144f337
Reviewed-on: https://go-review.googlesource.com/21457
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-18 19:20:37 +00:00
Keith Randall
b024ed0d94 cmd/compile: eliminate copy for static literals
*p = [5]byte{1,2,3,4,5}

First we allocate a global containing the RHS.  Then we copy
that global to a local stack variable, and then copy that local
stack variable to *p.  The intermediate copy is unnecessary.

Note that this only works if the RHS is completely constant.
If the code was:
*p = [5]byte{1,2,x,4,5}
this optimization doesn't apply as we have to construct the
RHS on the stack before copying it to *p.

Fixes #12841

Change-Id: I7cd0404ecc7a2d1750cbd8fe1222dba0fa44611f
Reviewed-on: https://go-review.googlesource.com/22192
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-04-18 18:51:10 +00:00
David Crawshaw
a3c92c9db1 cmd/link: use gold when dynamic linking on arm64
The GNU linker follows the letter of -znocopyreloc by refusing to
generate COPY relocations on arm64. Unfortunately it generates an
error instead of finding another way. The gold linker works, so
switch to it.

Fixes linux/arm64 build.

Change-Id: I1f7119d999c8f9f1f2d0c1e06b6462cea9c02a71
Reviewed-on: https://go-review.googlesource.com/22185
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-18 16:14:44 +00:00
Ian Lance Taylor
f5423a63df cmd/compile: a dot expression can not be a struct literal key
Passes toolstash -cmp.

Fixes #15311.

Change-Id: I1d67f5c9de38e899ab2d6c8986fabd6f197df23a
Reviewed-on: https://go-review.googlesource.com/22162
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-04-18 15:09:47 +00:00
David Crawshaw
95df0c6ab9 cmd/compile, etc: use name offset in method tables
Introduce and start using nameOff for two encoded names. This pair
of changes is best done together because the linker's method decoder
expects the method layouts to match.

Precursor to converting all existing name and *string fields to
nameOff.

linux/amd64:
	cmd/go:  -45KB (0.5%)
	jujud:  -389KB (0.6%)

linux/amd64 PIE:
	cmd/go: -170KB (1.4%)
	jujud:  -1.5MB (1.8%)

For #6853.

Change-Id: Ia044423f010fb987ce070b94c46a16fc78666ff6
Reviewed-on: https://go-review.googlesource.com/21396
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-18 09:12:41 +00:00
David Crawshaw
3c8d6af8e0 cmd/link: use -znocopyreloc when dynamic linking
On ARM, use the gold linker to avoid copy relocations.
https://sourceware.org/bugzilla/show_bug.cgi?id=19962

Change-Id: Icf82a38d39495d4518812713b957a03a6652c728
Reviewed-on: https://go-review.googlesource.com/22141
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-18 09:03:42 +00:00
Andrew Gerrand
135572eb32 cmd/go: mention that _test.go files are ignored when building
Fixes #15315

Change-Id: I8fea31507a5f83df8a86fb067f1b11d90133dc09
Reviewed-on: https://go-review.googlesource.com/22180
Reviewed-by: Chris Broadfoot <cbro@golang.org>
2016-04-18 04:05:23 +00:00
Josh Bleecher Snyder
2563b6f9fe cmd/compile/internal/ssa: use Compare instead of Equal
They have different semantics.

Equal is stricter and is designed for the front-end.
Compare is looser and cheaper and is designed for the back-end.
To avoid possible regression, remove Equal from ssa.Type.

Updates #15043

Change-Id: Ie23ce75ff6b4d01b7982e0a89e6f81b5d099d8d6
Reviewed-on: https://go-review.googlesource.com/21483
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2016-04-17 04:50:45 +00:00
Ian Lance Taylor
1d0977a1d5 cmd/cgo: add missing formatting directive in error message
Fixes #15310.

Change-Id: I588b3c630a20a6878f7cd00f9af29b1dd8a4abf6
Reviewed-on: https://go-review.googlesource.com/22100
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-15 22:03:22 +00:00
Matthew Dempsky
d57a118afa cmd/compile: remove dead flags
For some time now, the -d flag has been used to control various named
debug options, rather than setting Debug['d']. Consequently, that
means dflag() always returns false, which means the -y flag is also
useless.

Similarly, Debug['L'] is never used anywhere, so the -L flag can be
dropped too.

Change-Id: I4bb12454e462410115ec4f5565facf76c5c2f255
Reviewed-on: https://go-review.googlesource.com/22121
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-15 21:52:58 +00:00
Matthew Dempsky
106b9d3915 cmd/internal/obj, cmd/link: random style cleanups
Identified during review of golang.org/cl/22103.

Change-Id: I86bab4cc17204df1e45deefdb0d0f9a8f6e17073
Reviewed-on: https://go-review.googlesource.com/22106
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-15 06:54:36 +00:00
Matthew Dempsky
1441f76938 cmd: remove unnecessary type conversions
CL generated mechanically with github.com/mdempsky/unconvert.

Change-Id: Ic590315cbc7026163a1b3f8ea306ba35f1a53256
Reviewed-on: https://go-review.googlesource.com/22103
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-04-15 02:32:10 +00:00
Matthew Dempsky
e7b96e1a1f cmd/internal/sys: cleanup documentation
Expand description of ArchFamily, because it seems to be a common
source of confusion.  Also, update InFamily's description to reflect
current name.

Change-Id: I66b7999aef64ab8fee39aec0f752ae4f3a08d36d
Reviewed-on: https://go-review.googlesource.com/22102
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-15 02:07:38 +00:00
Todd Neal
77d374940e cmd/compile: speed up dom checking in cse
Process a slice of equivalent values by setting replaced values to nil
instead of removing them from the slice to eliminate copying.  Also take
advantage of the entry number sort to break early once we reach a value
in a block that is not dominated.

For the code in issue #15112:

Before:
real    0m52.603s
user    0m56.957s
sys     0m1.213s

After:
real    0m22.048s
user    0m26.445s
sys     0m0.939s

Updates #15112

Change-Id: I06d9e1e1f1ad85d7fa196c5d51f0dc163907376d
Reviewed-on: https://go-review.googlesource.com/22068
Reviewed-by: David Chase <drchase@google.com>
2016-04-15 00:30:39 +00:00
Robert Griesemer
5c593a3227 cmd/compile: first cut at exporting position info
- position info for all exported globals, plus methods and fields
- use delta-encoded line number info in most cases
- canonicalize all strings: each filename appears only once,
  but will also compact other strings (names) to at most one
  occurence in encoding
- positions not yet hooked up when reading in

Also:
- adjusted go/importer (gcimporter)
- some refactoring for better symmetry

Stats:
- comparison of export data size w/o and w/ position info (bytes).
- delta is increase in %
- overall (see bottom of table): 14% increase
- however, the current binary format decreased from
  the original binary format last week by 14%
- compared to original textual format: 65% decrease
  (increase by 14% after decrease by 14% still leads
  to a decrease from original textual format)

(caveat: we used the textual size from last week, assuming
it has not changed - there may be a small error here).

package				w/o pos	w/ pos	delta

archive/tar			4234	4902	16%
archive/zip			6387	7340	15%
bufio				3106	3419	10%
bytes				4362	4757	9%
cmd/addr2line			27	70	159%
cmd/api				12065	13590	13%
cmd/asm				27	64	137%
cmd/asm/internal/arch		9957	11529	16%
cmd/asm/internal/asm		11788	13385	14%
cmd/asm/internal/flags		239	311	30%
cmd/asm/internal/lex		13415	15358	14%
cmd/cgo				13064	15006	15%
cmd/compile			27	67	148%
cmd/compile/internal/amd64	461	869	89%
cmd/compile/internal/arm	5963	7273	22%
cmd/compile/internal/arm64	363	657	81%
cmd/compile/internal/big	7186	8590	20%
cmd/compile/internal/gc		48242	56234	17%
cmd/compile/internal/mips64	367	666	81%
cmd/compile/internal/ppc64	372	721	94%
cmd/compile/internal/s390x	330	569	72%
cmd/compile/internal/ssa	30464	35058	15%
cmd/compile/internal/x86	429	770	79%
cmd/cover			3984	4731	19%
cmd/dist			74	154	108%
cmd/doc				7272	8591	18%
cmd/expdump			27	71	163%
cmd/fix				342	419	23%
cmd/go				8126	9520	17%
cmd/gofmt			27	70	159%
cmd/gofmt2			27	69	156%
cmd/gofmt2/internal/format	702	856	22%
cmd/gofmt2/internal/lexical	2954	3509	19%
cmd/gofmt2/internal/parse	6185	7295	18%
cmd/gofmt2/internal/syntax	3533	4738	34%
cmd/gofmt2/internal/test	540	615	14%
cmd/internal/bio		5395	6060	12%
cmd/internal/gcprog		533	663	24%
cmd/internal/goobj		1022	1277	25%
cmd/internal/obj		10951	12825	17%
cmd/internal/obj/arm		8612	9985	16%
cmd/internal/obj/arm64		15814	17638	12%
cmd/internal/obj/mips		10928	12487	14%
cmd/internal/obj/ppc64		13576	15277	13%
cmd/internal/obj/s390x		16513	18708	13%
cmd/internal/obj/x86		21152	23482	11%
cmd/internal/objfile		14442	16505	14%
cmd/internal/pprof/commands	1663	1885	13%
cmd/internal/pprof/driver	9517	10789	13%
cmd/internal/pprof/fetch	7632	8635	13%
cmd/internal/pprof/plugin	13150	14809	13%
cmd/internal/pprof/profile	7004	8248	18%
cmd/internal/pprof/report	7763	8942	15%
cmd/internal/pprof/svg		1332	1534	15%
cmd/internal/pprof/symbolizer	7376	8439	14%
cmd/internal/pprof/symbolz	6970	7976	14%
cmd/internal/pprof/tempfile	3645	4093	12%
cmd/internal/sys		505	619	23%
cmd/internal/unvendor/golang.org/x/arch/arm/armasm	73951	79188	7%
cmd/internal/unvendor/golang.org/x/arch/x86/x86asm	10140	11738	16%
cmd/link			27	64	137%
cmd/link/internal/amd64		9317	11034	18%
cmd/link/internal/arm		110	213	94%
cmd/link/internal/arm64		112	219	96%
cmd/link/internal/ld		53524	60149	12%
cmd/link/internal/mips64	113	222	96%
cmd/link/internal/ppc64		113	220	95%
cmd/link/internal/s390x		112	219	96%
cmd/link/internal/x86		110	212	93%
cmd/nm				27	61	126%
cmd/objdump			27	68	152%
cmd/pack			4141	4688	13%
cmd/pprof			27	67	148%
cmd/trace			624	842	35%
cmd/vet				11194	13140	17%
cmd/vet/internal/whitelist	52	113	117%
cmd/yacc			1141	1317	15%
compress/bzip2			2101	2484	18%
compress/flate			3619	4336	20%
compress/gzip			6261	7111	14%
compress/lzw			276	401	45%
compress/zlib			3630	4158	15%
container/heap			187	250	34%
container/list			1370	1506	10%
container/ring			466	546	17%
context				3005	3338	11%
crypto				728	856	18%
crypto/aes			181	321	77%
crypto/cipher			744	1163	56%
crypto/des			220	320	45%
crypto/dsa			4526	4990	10%
crypto/ecdsa			5341	5982	12%
crypto/elliptic			4969	5593	13%
crypto/hmac			188	250	33%
crypto/md5			560	706	26%
crypto/rand			4218	4746	13%
crypto/rc4			214	321	50%
crypto/rsa			5648	6355	13%
crypto/sha1			597	751	26%
crypto/sha256			228	351	54%
crypto/sha512			354	484	37%
crypto/subtle			586	621	6%
crypto/tls			20909	23438	12%
crypto/x509			14862	16857	13%
crypto/x509/pkix		8384	9278	11%
database/sql			6721	7715	15%
database/sql/driver		1243	1535	23%
debug/dwarf			7867	9153	16%
debug/elf			25479	28025	10%
debug/gosym			1887	2267	20%
debug/macho			7222	8846	22%
debug/pe			6921	8081	17%
debug/plan9obj			1084	1319	22%
encoding			217	280	29%
encoding/ascii85		587	722	23%
encoding/asn1			1043	1268	22%
encoding/base32			929	1112	20%
encoding/base64			1166	1368	17%
encoding/binary			2168	2410	11%
encoding/csv			3761	4203	12%
encoding/gob			11304	12936	14%
encoding/hex			510	606	19%
encoding/json			9965	11395	14%
encoding/pem			202	266	32%
encoding/xml			11817	13361	13%
errors				126	170	35%
expvar				930	1142	23%
flag				5905	6519	10%
fmt				1027	1190	16%
go/ast				12910	15541	20%
go/build			5460	6173	13%
go/constant			1645	1816	10%
go/doc				3107	3882	25%
go/format			1416	1729	22%
go/importer			1426	1668	17%
go/internal/gccgoimporter	1624	2028	25%
go/internal/gcimporter		2650	3095	17%
go/parser			6220	7073	14%
go/printer			1924	2306	20%
go/scanner			3137	3602	15%
go/token			3053	3474	14%
go/types			21793	25561	17%
hash				234	327	40%
hash/adler32			465	553	19%
hash/crc32			668	817	22%
hash/crc64			630	727	15%
hash/fnv			1413	1582	12%
html				76	114	50%
html/template			14382	16457	14%
image				10248	11409	11%
image/color			2247	2562	14%
image/color/palette		107	169	58%
image/draw			2313	2494	8%
image/gif			3079	3450	12%
image/internal/imageutil	3136	3456	10%
image/jpeg			2349	2735	16%
image/png			2404	2695	12%
index/suffixarray		4978	5596	12%
internal/race			225	278	24%
internal/singleflight		551	697	26%
internal/syscall/windows/sysdll	97	166	71%
internal/testenv		4488	5052	13%
internal/trace			1392	1680	21%
io				2811	3318	18%
io/ioutil			3988	4467	12%
log				3532	3907	11%
log/syslog			4247	4775	12%
math				3021	4499	49%
math/big			7250	8456	17%
math/cmplx			1034	1617	56%
math/rand			734	885	21%
mime				1889	2194	16%
mime/multipart			4313	4849	12%
mime/quotedprintable		1758	1996	14%
net				15686	18617	19%
net/http			42182	47848	13%
net/http/cgi			19496	21768	12%
net/http/cookiejar		4615	5248	14%
net/http/fcgi			17758	19771	11%
net/http/httptest		26108	29350	12%
net/http/httputil		20732	23286	12%
net/http/internal		2195	2497	14%
net/http/pprof			17596	19545	11%
net/internal/socktest		1689	2153	27%
net/mail			4328	4810	11%
net/rpc				24328	27249	12%
net/rpc/jsonrpc			11052	12438	13%
net/smtp			17127	19174	12%
net/textproto			3705	4329	17%
net/url				1193	1371	15%
os				8493	10113	19%
os/exec				6625	7532	14%
os/signal			137	236	72%
os/user				529	761	44%
path				295	372	26%
path/filepath			3452	3952	14%
reflect				5091	6028	18%
regexp				4848	5585	15%
regexp/syntax			2590	3076	19%
runtime				8721	11598	33%
runtime/cgo			17	17	0%
runtime/debug			2721	3130	15%
runtime/internal/atomic		569	704	24%
runtime/internal/sys		1874	2318	24%
runtime/pprof			478	582	22%
runtime/race			18	18	0%
runtime/trace			95	146	54%
sort				1052	1215	15%
strconv				1389	1667	20%
strings				3372	3772	12%
sync				946	1371	45%
sync/atomic			962	1079	12%
syscall				41574	45613	10%
testing				6184	7243	17%
testing/iotest			883	1116	26%
testing/quick			4659	5443	17%
text/scanner			2930	3269	12%
text/tabwriter			2333	2607	12%
text/template			13335	15274	15%
text/template/parse		8270	9285	12%
time				4687	5313	13%
unicode				3831	4355	14%
unicode/utf16			530	584	10%
unicode/utf8			872	946	8%
vendor/golang.org/x/net/http2/hpack	3386	3970	17%

				1295440	1481566	14%
orig. textual			4253585	1481566	-65%
orig. binary			1724071	1481566 -14%

Change-Id: I4177c6511cc57ebe5eb80c89bf3aefc83376ce86
Reviewed-on: https://go-review.googlesource.com/22096
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-04-14 23:12:29 +00:00
Keith Randall
ac8127d7e6 cmd/compile: fix register size for ODOTPTR result
The result of ODOTPTR, as well as a bunch of other ops,
should be the type of the result, not always a pointer type.

This fixes an amd64p32 bug where we were incorrectly truncating
a 64-bit slice index to 32 bits, and then barfing on a weird
load-64-bits-but-then-truncate-to-32-bits op that doesn't exist.

Fixes #15252

Change-Id: Ie62f4315fffd79f233e5449324ccc0879f5ac343
Reviewed-on: https://go-review.googlesource.com/22094
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-14 21:19:12 +00:00
Michael Hudson-Doyle
12e3b184f0 cmd/go: deduplicate gccgo afiles by package path, not *Package
This code was fixed a while ago to ensure that xtest and fake packages came
first on the link line, but golang.org/cl/16775 added --whole-archive ...
--no-whole-archive around all the .a files and rendered this fix useless.

So, take a different approach and only put one .a file on the linker command
line for each ImportPath we see while traversing the action graph, not for each
*Package we see. The way we walk the graph ensures that we'll see the .a files
that need to be first first.

Change-Id: I137f00f129ccc9fc99f40eee885cc04cc358a62e
Reviewed-on: https://go-review.googlesource.com/21692
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-14 20:19:43 +00:00
Michael Hudson-Doyle
e5463f5055 cmd/go: fix "#cgo pkg-config:" comments with gccgo
The unique difficulty of #cgo pkg-config is that the linker flags are recorded
when the package is compiled but (obviously) must be used when the package is
linked into an executable -- so the flags need to be stored on disk somewhere.
As it happens cgo already writes out a _cgo_flags file: nothing uses it
currently, but this change adds it to the lib$pkg.a file when compiling a
package, reads it out when linking (and passes a version of the .a file with
_cgo_flags stripped out of it to the linker). It's all fairly ugly but it works
and I can't really think of any way of reducing the essential level of
ugliness.

Fixes #11739

Change-Id: I35621878014e1e107eda77a5b0b23d0240ec5750
Reviewed-on: https://go-review.googlesource.com/18790
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-14 20:18:56 +00:00
David Crawshaw
c9638810df cmd/compile: use type. prefix on importpath symbol
This ensures that importpath symbols are treated like other type data
and end up in the same section under all build modes.

Fixes: go test -buildmode=pie reflect

Change-Id: Ibb8348648e8dcc850f2424d206990a06090ce4c6
Reviewed-on: https://go-review.googlesource.com/22081
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-14 19:59:15 +00:00
Josh Bleecher Snyder
644493f109 cmd/compile: clear hidden value at end of channel range body
While we’re here, clean up a few comments.

Fixes #15281

Change-Id: Ia6173e9941133db08f57bc80bdd3c5722122bfdb
Reviewed-on: https://go-review.googlesource.com/22082
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-04-14 19:20:26 +00:00
David Chase
6b0b3f86d6 cmd/compile: fix use of original spill name after sinking
This is a fix for the ssacheck builder
http://build.golang.org/log/baa00f70c34e41186051cfe90568de3d91f115d7
after CL 21307 for sinking spills down loop exits
https://go-review.googlesource.com/#/c/21037/

The fix is to reuse (move) the original spill, thus preserving
the definition of the variable and its use count. Original and
copy both use the same stack slot, but ssacheck needs to see
a definition for the variable itself.

Fixes #15279.

Change-Id: I286285490193dc211b312d64dbc5a54867730bd6
Reviewed-on: https://go-review.googlesource.com/21995
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-14 18:24:54 +00:00
Josh Bleecher Snyder
67cdec00c2 cmd/vet: teach asm checker about PEXTRD’s op size
Fixes #15271

Change-Id: I28e3fb5bde1e6fd5b263b1434873b8ce051aee97
Reviewed-on: https://go-review.googlesource.com/22083
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-04-14 17:58:51 +00:00
Matthew Dempsky
045411e6f2 cmd/internal/obj: remove use of package bio
Also add MustClose and MustWriter to cmd/internal/bio, and use them in
cmd/asm.

Change-Id: I07f5df3b66c17bc5b2e6ec9c4357d9b653e354e0
Reviewed-on: https://go-review.googlesource.com/21938
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-14 17:58:33 +00:00
Luan Santos
8d8feb4d2f cmd/vet: allow untyped composite literals to be unkeyed
We can trust that untyped composite literals are part of a slice literal
and not emit a vet warning for those.

Fixes #9171

Change-Id: Ia7c081e543b850f8be1fd1f9e711520061e70bed
Reviewed-on: https://go-review.googlesource.com/22000
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-04-14 16:20:58 +00:00
Dmitry Vyukov
2c9d773f74 misc/trace: update trace viewer html
The old trace-viewer is broken since Chrome 49:
https://bugs.chromium.org/p/chromium/issues/detail?id=569417
It was fixed in:
506457cbd7

This change updates trace-viewer to the latest version
(now it is called catapult).

This version has a bug in the lean config that we use, though:
https://github.com/catapult-project/catapult/issues/2247
So use full config for now (it works, but leads to larger html).
When the bug is fixed we need to switch back to lean config (issue #15302).

Change-Id: Ifb8d782ced66e3292d81c5604039fe18eaf267c5
Reviewed-on: https://go-review.googlesource.com/22013
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-14 14:48:04 +00:00
Matthew Dempsky
babfb4ec3b cmd/internal/obj: change Link.Flag_shared to bool
Change-Id: I9bda2ce6f45fb8292503f86d8f9f161601f222b7
Reviewed-on: https://go-review.googlesource.com/22053
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-04-14 02:11:17 +00:00
Matthew Dempsky
980ab12ade cmd/compile/internal/gc: change flags to bool where possible
Some of the Debug[x] flags are actually boolean too, but not all, so
they need to be handled separately.

While here, change some obj.Flagstr and obj.Flagint64 calls to
directly use flag.StringVar and flag.Int64Var instead.

Change-Id: Iccedf6fed4328240ee2257f57fe6d66688f237c4
Reviewed-on: https://go-review.googlesource.com/22052
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-04-14 02:10:35 +00:00
Robert Griesemer
ae98045958 cmd/compile: use correct export function (fix debugFormat)
Tested with debugFormat enabled and running
(export GO_GCFLAGS=-newexport; sh all.bash).

Change-Id: If7d43e1e594ea43c644232b89e670f7abb6b003e
Reviewed-on: https://go-review.googlesource.com/22033
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-04-14 00:41:29 +00:00
Robert Griesemer
6e5027a37a cmd/compile: don't export unneeded OAS, OASWB nodes
Also:
- "rewrite" node Op in exporter for some nodes instead of importer
- more comments

Change-Id: I809e6754d14987b28f1da9379951ffa2e690c2a7
Reviewed-on: https://go-review.googlesource.com/22008
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-13 23:16:02 +00:00
David Crawshaw
f120936dff cmd/compile, etc: use name for type pkgPath
By replacing the *string used to represent pkgPath with a
reflect.name everywhere, the embedded *string for package paths
inside the reflect.name can be replaced by an offset, nameOff.
This reduces the number of pointers in the type information.

This also moves all reflect.name types into the same section, making
it possible to use nameOff more widely in later CLs.

No significant binary size change for normal binaries, but:

linux/amd64 PIE:
	cmd/go: -440KB (3.7%)
	jujud:  -2.6MB (3.2%)

For #6853.

Change-Id: I3890b132a784a1090b1b72b32febfe0bea77eaee
Reviewed-on: https://go-review.googlesource.com/21395
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-13 20:48:26 +00:00
David Crawshaw
79048df2cc cmd/link: handle long symbol names
Fixes #15104.

Change-Id: I9ddfbbf39ef0a873b703ee3e04fbb7d1192f5f39
Reviewed-on: https://go-review.googlesource.com/21581
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-13 20:31:43 +00:00
Todd Neal
3ea7cfabbb cmd/compile: sort partitions by dom to speed up cse
We do two O(n) scans of all values in an eqclass when computing
substitutions for CSE.

In unfortunate cases, like those found in #15112, we can have a large
eqclass composed of values found in blocks none of whom dominate the
other.  This leads to O(n^2) behavior. The elements are removed one at a
time, with O(n) scans each time.

This CL removes the linear scan by sorting the eqclass so that dominant
values will be sorted first.  As long as we also ensure we don't disturb
the sort order, then we no longer need to scan for the maximally
dominant value.

For the code in issue #15112:

Before:
real    1m26.094s
user    1m30.776s
sys     0m1.125s

Aefter:
real    0m52.099s
user    0m56.829s
sys     0m1.092s

Updates #15112

Change-Id: Ic4f8680ed172e716232436d31963209c146ef850
Reviewed-on: https://go-review.googlesource.com/21981
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-13 19:55:15 +00:00
Dmitry Vyukov
da6205b67e cmd/pprof/internal/profile: always subtract 1 from PCs
Go runtime never emits PCs that are not a return address
(except for cpu profiler).

Change-Id: I08d9dc5c7c71e23f34f2f0c16f8baeeb4f64fcd6
Reviewed-on: https://go-review.googlesource.com/21735
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-13 17:22:38 +00:00
Robert Griesemer
eb79f21c48 cmd/compile, go/importer: minor cleanups
Change-Id: Ic7a1fb0dbbf108052c970a4a830269a5673df7df
Reviewed-on: https://go-review.googlesource.com/21963
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-04-13 17:03:08 +00:00
Robert Griesemer
7d0d122247 cmd/compile: move more compiler specifics into compiler specific export section
Instead of indicating with each function signature if it has an inlineable
body, collect all functions in order and export function bodies with function
index in platform-specific section.

Moves this compiler specific information out of the platform-independent
export data section, and removes an int value for all functions w/o body.
Also simplifies the code a bit.

Change-Id: I8b2d7299dbe81f2706be49ecfb9d9f7da85fd854
Reviewed-on: https://go-review.googlesource.com/21939
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-04-13 17:00:49 +00:00
David Chase
6b85a45edc cmd/compile: move spills to loop exits when easy.
For call-free inner loops.

Revised statistics:
  85 inner loop spills sunk
 341 inner loop spills remaining
1162 inner loop spills that were candidates for sinking
     ended up completely register allocated
 119 inner loop spills could have been sunk were used in
     "shuffling" at the bottom of the loop.
   1 inner loop spill not sunk because the register assigned
     changed between def and exit,

 Understanding how to make an inner loop definition not be
 a candidate for from-memory shuffling (to force the shuffle
 code to choose some other value) should pick up some of the
 119 other spills disqualified for this reason.

 Modified the stats printing based on feedback from Austin.

Change-Id: If3fb9b5d5a028f42ccc36c4e3d9e0da39db5ca60
Reviewed-on: https://go-review.googlesource.com/21037
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-13 15:59:42 +00:00