1
0
mirror of https://github.com/golang/go synced 2024-10-01 20:28:33 -06:00
Commit Graph

21993 Commits

Author SHA1 Message Date
Dominik Honnef
77f4b773e7 encoding/json, internal/testenv: use Fatalf
Change-Id: I64dd09e76d811000a914776fdad47808e3895690
Reviewed-on: https://go-review.googlesource.com/20989
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-03-22 05:58:27 +00:00
Michael Munday
5f0935b7d4 internal/syscall/unix: add randomTrap const for s390x
Change-Id: I81376f524e76db25fd52cc5bec2c80fbf618a0c5
Reviewed-on: https://go-review.googlesource.com/20877
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-22 04:25:34 +00:00
Michael Munday
2a7e85f162 cmd/internal/obj: add support for s390x
Adds a new R_PCRELDBL relocation for 2-byte aligned relative
relocations on s390x. Should be removed once #14218 is
implemented.

Change-Id: I79dd2d8e746ba8cbc26c570faccfdd691e8161e8
Reviewed-on: https://go-review.googlesource.com/20941
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-22 04:15:44 +00:00
Keith Randall
69a7c152a7 cmd/compile: change the way SSA does slice zero-cap detection
There is a special case for slicing s[i:j] when the resulting
slice has zero capacity, to prevent pointing to the next object
in memory.

Change this special case code from:
  rptr := rcap == 0 ? ptr : ptr+i*elemsize
to
  rptr := ptr + (rcap == 0 ? 0 : i) * elemsize

This change leads to slightly smaller generated code, replacing
a load with a register zero.

old:
	0x002e 00046 (slice.go:8)	CMPQ	BX, $0
	0x0032 00050 (slice.go:8)	JEQ	$0, 78
	0x0034 00052 (slice.go:8)	MOVQ	"".a+8(FP), BP
	0x0039 00057 (slice.go:8)	LEAQ	(BP)(CX*8), AX
	0x003e 00062 ... rest of function ...

	0x004e 00078 (slice.go:7)	MOVQ	"".a+8(FP), AX
	0x0053 00083 (slice.go:8)	JMP	62

new:
	0x002e 00046 (slice.go:8)	CMPQ	BX, $0
	0x0032 00050 (slice.go:8)	JEQ	$0, 78
	0x0034 00052 (slice.go:8)	MOVQ	"".a+8(FP), BP
	0x0039 00057 (slice.go:8)	LEAQ	(BP)(CX*8), AX
	0x003e 00062 ... rest of function...

	0x004e 00078 (slice.go:8)	MOVQ	$0, CX
	0x0050 00080 (slice.go:8)	JMP	52

Change-Id: I2a396616b0d7b090c226a47c92a7ba14b128401f
Reviewed-on: https://go-review.googlesource.com/20994
Reviewed-by: David Chase <drchase@google.com>
2016-03-22 02:21:20 +00:00
David Crawshaw
d37d3bdcfc net/http, internal/testenv: find go binary in PATH
Fixes #14901

Change-Id: Ia32e09767374a341c9a36c5d977d47d7d1a82315
Reviewed-on: https://go-review.googlesource.com/20967
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
2016-03-22 02:02:23 +00:00
Michael Munday
596949c18a cmd/dist: allow gohostarch to be s390x
Should let the s390x builder progress a little further.

Change-Id: I5eab5f384b0b039f8e246ba69ecfb24de08625d2
Reviewed-on: https://go-review.googlesource.com/20965
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-22 01:04:26 +00:00
Keith Randall
259b7edf5c cmd/compile: allow naming of subexpressions
Allow names to be used for subexpressions of match rules.
For example:

(OpA x:(OpB y)) -> ..use x here to refer to the OpB value..

This gets rid of the .Args[0].Args[0]... way of naming we
used to use.

While we're here, give all subexpression matches names instead
of recomputing them with .Args[i] sequences each time they
are referenced.  Makes the generated rule code a bit smaller.

Change-Id: Ie42139f6f208933b75bd2ae8bd34e95419bc0e4e
Reviewed-on: https://go-review.googlesource.com/20997
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-22 00:18:31 +00:00
Keith Randall
d4663e1353 cmd/compile: don't write back unchanged slice results
Don't write back parts of a slicing operation if they
are unchanged from the source of the slice.  For example:

x.s = x.s[0:5]         // don't write back pointer or cap
x.s = x.s[:5]          // don't write back pointer or cap
x.s = x.s[:5:7]        // don't write back pointer

There is more to be done here, for example:

x.s = x.s[:len(x.s):7] // don't write back ptr or len

This CL can't handle that one yet.

Fixes #14855

Change-Id: Id1e1a4fa7f3076dc1a76924a7f1cd791b81909bb
Reviewed-on: https://go-review.googlesource.com/20954
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
2016-03-21 23:40:18 +00:00
Alexandru Moșoi
9549c06ce6 cmd/compile: fold IsInBounds with small index
For the following example, but there are a few more in the stdlib:
func histogram(b []byte, h *[256]int32) {
        for _, t := range b {
                h[t]++
        }
}

Change-Id: I56615f341ae52e02ef34025588dc6d1c52122295
Reviewed-on: https://go-review.googlesource.com/20924
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-21 23:15:25 +00:00
Todd Neal
e41f527f4d cmd/compile: allow inlining of functions with switch statements
Allow inlining of functions with switch statements as long as they don't
contain a break or type switch.

Fixes #13071

Change-Id: I057be351ea4584def1a744ee87eafa5df47a7f6d
Reviewed-on: https://go-review.googlesource.com/20824
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-21 23:05:10 +00:00
Robert Griesemer
a14537816e math/big: fix rounding to smallest denormal for Float.Float32/64
Converting a big.Float value x to a float32/64 value did not correctly
round x up to the smallest denormal float32/64 if x was smaller than the
smallest denormal float32/64, but larger than 0.5 of a smallest denormal
float32/64.

Handle this case explicitly and simplify some code in the turn.

For #14651.

Change-Id: I025e24bf8f0e671581a7de0abf7c1cd7e6403a6c
Reviewed-on: https://go-review.googlesource.com/20816
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-21 20:24:06 +00:00
Alexandru Moșoi
478b594d51 encoding/binary: fix bound check
The inserted early bound checks cause the slice
to expand beyond the original length of the slice.

Change-Id: Ib38891605f4a9a12d3b9e2071a5f77640b083d2d
Reviewed-on: https://go-review.googlesource.com/20981
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2016-03-21 19:22:22 +00:00
Keith Randall
6a33f7765f runtime: use MOVSB instead of MOVSQ for unaligned moves
MOVSB is quite a bit faster for unaligned moves.
Possibly we should use MOVSB all of the time, but Intel folks
say it might be a bit faster to use MOVSQ on some processors
(but not any I have access to at the moment).

benchmark                              old ns/op     new ns/op     delta
BenchmarkMemmove4096-8                 93.9          93.2          -0.75%
BenchmarkMemmoveUnalignedDst4096-8     256           151           -41.02%
BenchmarkMemmoveUnalignedSrc4096-8     175           90.5          -48.29%

Fixes #14630

Change-Id: I568e6d6590eb3615e6a699fb474020596be665ff
Reviewed-on: https://go-review.googlesource.com/20293
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-21 19:10:24 +00:00
Josh Bleecher Snyder
b07a214d39 cmd/internal/obj: change linkgetline from C to Go func style
Passes toolstash -cmp.

Change-Id: I8725dee490778be9c1fd31990a6b27df9713c3c9
Reviewed-on: https://go-review.googlesource.com/20957
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-21 18:45:20 +00:00
Josh Bleecher Snyder
075d66646c cmd/compile: remove formatting dreg
Left over from CL 20931.

Change-Id: I3b8dd9ef748bcbf70b5118da28135aaa1e5ba3a8
Reviewed-on: https://go-review.googlesource.com/20955
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
2016-03-21 18:44:46 +00:00
Robert Griesemer
07749aef98 cmd/compile: special-case const comparisons against zero
Constant comparisons against 0 are reasonably common.
Special-case and avoid allocating a new zero value each time.

Change-Id: I6c526c8ab30ef7f0fef59110133c764b7b90ba05
Reviewed-on: https://go-review.googlesource.com/20956
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-21 17:58:21 +00:00
Matthew Dempsky
d3253876f2 cmd/compile: change Mp{int,flt} functions into methods
Also give them more idiomatic Go names. Adding godocs is outside the
scope of this CL. (Besides, the method names almost all directly
parallel an underlying math/big.Int or math/big.Float method.)

CL prepared mechanically with sed (for rewriting mpint.go/mpfloat.go)
and gofmt (for rewriting call sites).

Passes toolstash -cmp.

Change-Id: Id76f4aee476ba740f48db33162463e7978c2083d
Reviewed-on: https://go-review.googlesource.com/20909
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-21 17:25:50 +00:00
Marcel van Lohuizen
5fb6aa3e09 testing: add test for not exceeding maximum parallism
Fixed bug that slipped probably slipped in after rebasing and
explain why it failed on nacl/netbsd/plan9, which set default
maxparallelism to 1.

Change-Id: I4d59682fb2843d138b320334189f53fcdda5b2f6
Reviewed-on: https://go-review.googlesource.com/20980
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-21 16:52:04 +00:00
Robert Griesemer
bea2008b83 math/cmplx: added clarifying comment
Fixes #14890.

Change-Id: Ie790276b0e2ef94c92db3a777042d750269f876a
Reviewed-on: https://go-review.googlesource.com/20953
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-21 16:18:38 +00:00
Michael Munday
cd187e9102 syscall: change clone argument order on s390x
The Linux ABI takes arguments in a different order on s390x.

Change-Id: Ic9cfcc22a5ea3d8ef77d4dd0b915fc266ff3e5f7
Reviewed-on: https://go-review.googlesource.com/20960
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-21 08:59:18 +00:00
Michael Munday
254d63baa7 cmd/go: add s390x support
Minimum architecture of z196 required so that GCC can assemble
gcc_s390x.S in runtime/cgo.

Change-Id: I603ed2edd39f826fb8193740ece5bd11d18c3dc5
Reviewed-on: https://go-review.googlesource.com/20876
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-21 08:51:21 +00:00
Brad Fitzpatrick
f226e886c2 internal/syscall/unix: document randomTrap
Updates #10848

Change-Id: I8353100ed01cb0e8fc19225157f5709bae388612
Reviewed-on: https://go-review.googlesource.com/20975
Reviewed-by: Rob Pike <r@golang.org>
2016-03-21 08:36:38 +00:00
Michael Munday
cc17d1ba76 runtime/internal/sys: add s390x support
Change-Id: I928532b406a3457d2c5f75f4de7d46a3f795192e
Reviewed-on: https://go-review.googlesource.com/20939
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-21 08:04:38 +00:00
Michael Hudson-Doyle
74a3b205eb cmd/link: remove Link.Nsymbol
It was just a funny way of saying len(Ctxt.Allsym) by now.

Change-Id: Iff75e73c9f7ec4ba26cfef479bbd05d7dcd172f5
Reviewed-on: https://go-review.googlesource.com/20973
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-21 07:57:25 +00:00
Michael Hudson-Doyle
b6fe2c2c20 cmd/link: re-use duplicate symbol object
Nothing cares about it.

I did this after looking at the memprof output, but it helps performance a bit:

name       old s/op    new s/op    delta
LinkCmdGo   0.44 ± 3%   0.43 ± 3%  -2.20%   (p=0.000 n=94+90)
LinkJuju    3.98 ± 5%   3.94 ± 5%  -1.19%  (p=0.000 n=100+91)

As well as MaxRSS (i.e. what /usr/bin/time -f '%M' prints):

name       old MaxRSS  new MaxRSS  delta
LinkCmdGo   130k ± 0%   120k ± 3%  -7.79%   (p=0.000 n=79+90)
LinkJuju    862k ± 6%   827k ± 8%  -4.01%  (p=0.000 n=100+99)

Change-Id: I6306b7b3369576a688659e2ecdb0815b4152ae96
Reviewed-on: https://go-review.googlesource.com/20972
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-21 07:48:30 +00:00
Michael Munday
8bfb3045db cmd/dist: enable -shared and external linking tests on s390x
Change-Id: Iedd01ef3a9d2831cb55c53b7a1984e7e932f4249
Reviewed-on: https://go-review.googlesource.com/20932
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-21 07:45:38 +00:00
Brad Fitzpatrick
060a6915d4 cmd/compile: remove most of the Lookupf users and garbage
Introduce garbage-free LookupN to replace most users of Lookupf.

Also, remove the string interning from LookupBytes which was hurting
more than helping.

name       old alloc/op    new alloc/op    delta
Template      63.0MB ± 0%     62.7MB ± 0%  -0.48%         (p=0.000 n=10+9)
Unicode       43.0MB ± 0%     43.0MB ± 0%  -0.17%         (p=0.000 n=10+7)
GoTypes        219MB ± 0%      218MB ± 0%  -0.14%        (p=0.000 n=10+10)
Compiler       992MB ± 0%      991MB ± 0%  -0.12%        (p=0.000 n=10+10)

name       old allocs/op   new allocs/op   delta
Template        683k ± 0%       681k ± 0%  -0.38%         (p=0.000 n=10+8)
Unicode         541k ± 0%       541k ± 0%  -0.11%        (p=0.000 n=10+10)
GoTypes        2.09M ± 0%      2.08M ± 0%  -0.40%        (p=0.000 n=10+10)
Compiler       9.28M ± 0%      9.24M ± 0%  -0.36%        (p=0.000 n=10+10)

Size of $GOROOT/pkg/darwin_amd64 drops from 40124 KB to 40100 KB too,
removing the zero padding as suggested by josharian.

Updates #6853

Change-Id: I3c557266e9325fe29c459cef8e5b8954913e7abb
Reviewed-on: https://go-review.googlesource.com/20931
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-21 07:40:15 +00:00
Michael Munday
4fbe96adc3 cmd/dist: add "s390x" to okgoarch and cgoEnabled
Allows the compiler to recognise s390x specific files and s390x
build tags.

Change-Id: I7c62ab7361cf708181b1d9cfbe9b1fcb01be31e0
Reviewed-on: https://go-review.googlesource.com/20872
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-21 07:31:00 +00:00
Dominik Honnef
b2cf571040 all: delete dead test code
This deletes unused code and helpers from tests.

Change-Id: Ie31d46115f558ceb8da6efbf90c3c204e03b0d7e
Reviewed-on: https://go-review.googlesource.com/20927
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-21 07:10:08 +00:00
Michael Munday
992320aaa8 cmd/internal/objfile: add s390x support
Change-Id: I39aa6569c9a6f327f7aaa01f8b4ace814fd5b766
Reviewed-on: https://go-review.googlesource.com/20943
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-21 07:09:26 +00:00
Michael Hudson-Doyle
49be1ebab4 cmd/link: delete more unreachable code
Debugasm can never be set in cmd/link, so delete it and the code it enables.

Change-Id: If828db0b09f1a9e512dc660ac2750657a769094c
Reviewed-on: https://go-review.googlesource.com/20971
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-21 06:56:51 +00:00
Michael Hudson-Doyle
70ef564e79 cmd/link: delete unreachable hash collision check
This expression in readsym:

    dup != nil && len(dup.P) > 0 && strings.HasPrefix(s.Name, "gclocals·")

can never be true: if dup != nil, then s.Name is ".dup" (and this is not new:
the same broken logic is present in 1.4, at least). Delete the whole block.

Change-Id: I33b14d9a82b292116d6fd79d22b38e3842501317
Reviewed-on: https://go-review.googlesource.com/20970
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-21 06:53:27 +00:00
Dave Cheney
ca0f5c9740 cmd/internal/obj: move Nocache helper to arm back end
The obj.Nocache helper was only used by the arm back end, move it there.

Change-Id: I5c9faf995499991ead1f3d8c8ffc3b6af7346876
Reviewed-on: https://go-review.googlesource.com/20868
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-21 04:27:24 +00:00
Josh Bleecher Snyder
a4dce12803 cmd/compile: unexport convlit
Add a special helper for its one external use.

This is in preparation for an upcoming CL.

Passes toolstash -cmp / buildall.

Change-Id: I9d3463792afe220cc4bc89269bdecf0279abd281
Reviewed-on: https://go-review.googlesource.com/20933
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-21 04:11:11 +00:00
Dave Cheney
39af1eb96f cmd/internal/obj: remove Link.Windows field
This CL addresses a long standing CL by rsc by pushing the use of
Link.Windows down to its two users.

Link.Window was always initalised with the value of runtime.GOOS so
this does not affect cross compilation.

Change-Id: Ibbae068f8b5aad06336909691f094384caf12352
Reviewed-on: https://go-review.googlesource.com/20869
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-21 04:07:09 +00:00
Matthew Dempsky
e28a3929ef math/big: cleanup documentation for Format methods
'b' is a standard verb for floating point values. The runes like '+'
and '#' are called "flags" by package fmt's documentation. The flag
'-' controls left/right justification, not anything related to signs.

Change-Id: Ia9cf81b002df373f274ce635fe09b5bd0066aa1c
Reviewed-on: https://go-review.googlesource.com/20930
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-21 02:49:32 +00:00
Michael Hudson-Doyle
36d5650a1c cmd/internal/obj, cmd/link: put all symbol data in one contiguous section
Another object file change, gives a reasonable improvement:

name       old s/op   new s/op   delta
LinkCmdGo  0.46 ± 3%  0.44 ± 9%  -3.34%  (p=0.000 n=98+82)
LinkJuju   4.09 ± 4%  3.92 ± 5%  -4.30%  (p=0.000 n=98+99)

I guess the data section could be mmap-ed instead of read, I haven't tried
that.

Change-Id: I959eee470a05526ab1579e3f5d3ede41c16c954f
Reviewed-on: https://go-review.googlesource.com/20928
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-21 01:36:00 +00:00
Richard Miller
34f0c0b3de net/http: adaptive wait time in PersistConnLeak tests
In tests TransportPersistConnLeak and TransportPersistConnLeakShortBody,
there's a fixed wait time (100ms and 400ms respectively) to allow
goroutines to exit after CloseIdleConnections is called. This
is sometimes too short on a slow host running many simultaneous
tests.

This CL replaces the fixed sleep in each test with a sequence of
shorter sleeps, testing the number of remaining goroutines until
it reaches the threshold or an overall time limit of 500ms expires.
This prevents some failures in the plan9_arm builder, while reducing
the test time on faster machines.

Fixes #14887

Change-Id: Ia5c871062df139e2667cdfb2ce8283e135435318
Reviewed-on: https://go-review.googlesource.com/20922
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-20 22:53:45 +00:00
Alexandru Moșoi
a7a199947a cmd/compile: add rules to simplify AddPtr
Fixes #14849

Change-Id: I86e2dc27ca73bb6b24261a68cbf0094a63167414
Reviewed-on: https://go-review.googlesource.com/20833
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 20:57:28 +00:00
Ian Lance Taylor
a9407b5797 cmd/compile: fix varexpr handling of ODOT
For a long time varexpr has handled ODOT incorrectly: it has always
returned false.  Before https://golang.org/cl/20890 this has been
because an ODOT had a Right field with an ONAME with no Class, for which
varexpr returns false.  CL 20890 preserved the behavior of varexpr for
ODOT, so that the change would pass toolstash -cmp.

This CL fixes varexpr so that ODOT can return true in some cases.  This
breaks toolstash -cmp.  While the changed compiler allocates temporary
variables in a different order, I have not been able to find any
examples where the generated code is different, other than using
different stack offsets and, in some cases, registers.  It seems that
other parts of the compiler will force the ODOT into a temporary anyhow.

Still, this change is clearly correct, and is a minor compiler cleanup.

Change-Id: I71506877aa3c13966bb03c281aa16271ee7fe80a
Reviewed-on: https://go-review.googlesource.com/20907
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 18:28:09 +00:00
Shahar Kohanim
93098de0cc cmd/link: patch up symbols only once per object file
name       old s/op   new s/op   delta
LinkCmdGo  0.57 ± 5%  0.55 ± 6%  -2.37%  (p=0.000 n=97+98)

GOGC=off:

name       old s/op   new s/op   delta
LinkCmdGo  0.48 ± 3%  0.47 ± 3%  -2.90%  (p=0.000 n=100+100)

Change-Id: I1a36dbf84914cacb79842bc0ddb1e26b4c5a5828
Reviewed-on: https://go-review.googlesource.com/20917
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 17:36:30 +00:00
Ian Lance Taylor
060038bdd0 cmd/compile: don't penalize ODOT and friends when inlining
Historically ODOT and friends have been considered to cost an extra
budget point when deciding whether they should be inlined, because they
had an ONAME node that represented the name to the right of the dot.
This doesn't really make sense, as in general that symbol does not add
any extra instructions; it just affects the offset of the load or store
instruction.  And the ONAME node is gone now.  So, remove the extra
cost.

This does not pass toolstash -cmp, as it changes inlining decisions.
For example, mspan.init in runtime/mheap.go is now considered to be an
inlining candidate.

Change-Id: I5ad27f08c66fd5daa4c8472dd0795df989183f5e
Reviewed-on: https://go-review.googlesource.com/20891
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 17:25:02 +00:00
Shahar Kohanim
d6d33f678d cmd/link: use encbuf when writing integers
name       old s/op   new s/op   delta
LinkCmdGo  0.59 ± 6%  0.58 ± 5%  -1.61%  (p=0.000 n=99+99)

GOGC=off:
name       old s/op   new s/op   delta
LinkCmdGo  0.50 ± 3%  0.49 ± 3%  -1.28%  (p=0.000 n=98+99)

Change-Id: I737ae056214999441a210c69ec0cf4febc39a715
Reviewed-on: https://go-review.googlesource.com/20914
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 14:34:33 +00:00
Shahar Kohanim
78fc59ef42 cmd/compile, cmd/link: remove unused fields from relocations
Reduces size of archives in pkg/linux_amd64 by 3% from 41.5MB to 40.2MB

Change-Id: Id64ca7995de8dd84c9e7ce1985730927cf4bfd66
Reviewed-on: https://go-review.googlesource.com/20912
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-20 13:44:31 +00:00
Shahar Kohanim
3504945081 cmd/link: optimize int parsing
Speeds up linking cmd/go by ~1.5%:

name       old s/op   new s/op   delta
LinkCmdGo  0.58 ± 6%  0.57 ± 5%  -1.21%  (p=0.000 n=98+99)

Less noisy benchmark, with garbage collection off:

name       old s/op   new s/op   delta
LinkCmdGo  0.49 ± 2%  0.49 ± 2%  -1.79%  (p=0.000 n=98+99)

Change-Id: I0123bcb66a87cbc4d703356e4c5a4035032012ec
Reviewed-on: https://go-review.googlesource.com/20916
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 13:10:33 +00:00
Martin Möhrmann
8d9ece9dde fmt: unify integer formatting
Deduplicate the verb switch for signed and unsigned integer formatting.

Make names of integer related functions consistent
with names of other fmt functions.

Consolidate basic integer tests.

Change-Id: I0c19c24f1c2c06a3b1a4d7d377dcdac3b36bb0f5
Reviewed-on: https://go-review.googlesource.com/20831
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-20 12:08:03 +00:00
Matthew Dempsky
3eaa304629 cmd/compile: ignore receiver name when checking duplicate methods
In golang.org/cl/20602, I changed the semantics of Eqtype to stop
checking the receiver parameters for type equality, and pushed this
responsibility to addmethod (the only Eqtype caller that cared).
However, I accidentally made the check stricter by making it start
requiring that receiver names were identical.

In general, this is a non-problem because the receiver names in export
data will always match the original source. But running
GO_GCFLAGS=-newexport ./all.bash at one point tries to load both old
and new format export data for package sync, which reveals the
problem. (See golang.org/issue/14877 for details.)

Easy fix: just check the receiver type for type equality in addmethod,
instead of the entire receiver parameter list.

Fixes #14877.

Change-Id: If10b79f66ba58a1b7774622b4fbad1916aba32f1
Reviewed-on: https://go-review.googlesource.com/20906
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-20 04:37:04 +00:00
Josh Bleecher Snyder
ec7c494535 cmd/compile: remove typechecklist
Convert remaining uses to typecheckslice.

Passes toolstash -cmp.

Change-Id: I6ed0877386fb6c0b036e8ee5a228433343855abd
Reviewed-on: https://go-review.googlesource.com/20905
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 00:34:42 +00:00
Josh Bleecher Snyder
ad4c55c076 cmd/compile: convert fmt.Sprintf to concatenation
There are plenty more, but these cover most of
the trivial cases, and all the cases that
showed up in profiling.

name       old time/op     new time/op     delta
Template       331ms ± 3%      327ms ± 6%    ~           (p=0.143 n=10+10)
Unicode        183ms ± 4%      180ms ± 2%    ~             (p=0.114 n=9+8)
GoTypes        1.12s ± 4%      1.07s ± 1%  -4.34%         (p=0.000 n=10+9)
Compiler       5.16s ± 2%      5.04s ± 2%  -2.24%         (p=0.001 n=10+9)
MakeBash       41.7s ± 2%      42.3s ± 1%  +1.51%        (p=0.000 n=10+10)

name       old alloc/op    new alloc/op    delta
Template      63.4MB ± 0%     63.1MB ± 0%  -0.42%        (p=0.000 n=10+10)
Unicode       43.2MB ± 0%     43.1MB ± 0%  -0.22%         (p=0.000 n=9+10)
GoTypes        220MB ± 0%      219MB ± 0%  -0.57%         (p=0.000 n=8+10)
Compiler       978MB ± 0%      975MB ± 0%  -0.30%        (p=0.000 n=10+10)

name       old allocs/op   new allocs/op   delta
Template        702k ± 0%       686k ± 0%  -2.35%        (p=0.000 n=10+10)
Unicode         548k ± 0%       542k ± 0%  -1.09%        (p=0.000 n=10+10)
GoTypes        2.17M ± 0%      2.09M ± 0%  -3.61%        (p=0.000 n=10+10)
Compiler       9.33M ± 0%      9.15M ± 0%  -1.93%        (p=0.000 n=10+10)

Change-Id: I3a3d7f2d56876427b04cfedc7302d7f496d5bb65
Reviewed-on: https://go-review.googlesource.com/20904
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-20 00:17:30 +00:00
Keith Randall
8dc04cbedc cmd/compile: enforce 32-bit restrictions on ops
Most 64-bit x86 ops can only take a signed 32-bit constant.
Clean up our rewrite rules to enforce this restriction.

Modify the assembler to fail if the offset does not fit
in the instruction.

That last check triggers a few times on weird testing code.
Suppress those errors if the compiler itself generated errors.

Fixes #14862

Change-Id: I76559af035b38483b1e59621a8029fc66b3a5d1e
Reviewed-on: https://go-review.googlesource.com/20815
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-03-20 00:12:47 +00:00
Martin Möhrmann
d246eedcaa fmt: integer formatting should not permanently change padding
Changes the integer function to restore the original f.zero value
and therefore padding type before returning.

Change-Id: I456449259a3d39bd6d62e110553120c31ec63f23
Reviewed-on: https://go-review.googlesource.com/20512
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-19 23:49:18 +00:00
Martin Möhrmann
2f4d420683 fmt: remove depth argument from handleMethods and printArg
handleMethods can format Error() and String() directly as its known
these return strings that can be directly printed using fmtString.
Remove the obsolete depth argument from handleMethods.

Remove the depth argument from printArg since it is only ever
called with depth set to 0. Recursion for formatting complex
arguments is handled only by printValue which keeps track of depth.

Change-Id: I4c4be588751de12ed999e7561a51bc168eb9eb2d
Reviewed-on: https://go-review.googlesource.com/20911
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-19 21:45:13 +00:00
Ian Lance Taylor
5f525ca60d cmd/compile: change ODOT and friends to use Sym, not Right
The Node type ODOT and its variants all represent a selector, with a
simple name to the right of the dot.  Before this change this was
represented by using an ONAME Node in the Right field.  This ONAME node
served no useful purpose.  This CL changes these Node types to store the
symbol in the Sym field instead, thus not requiring allocating a Node
for each selector.

When compiling x/tools/go/types this CL eliminates nearly 5000 calls to
newname and reduces the total number of Nodes allocated by about 6.6%.
It seems to cut compilation time by 1 to 2 percent.

Getting this right was somewhat subtle, and I added two dubious changes
to produce the exact same output as before.  One is to ishairy in
inl.go: the ONAME node increased the cost of ODOT and friends by 1, and
I retained that, although really ODOT is not more expensive than any
other node.  The other is to varexpr in walk.go: because the ONAME in
the Right field of an ODOT has no class, varexpr would always return
false for an ODOT, although in fact for some ODOT's it seemingly ought
to return true; I added an && false for now.  I will send separate CLs,
that will break toolstash -cmp, to clean these up.

This CL passes toolstash -cmp.

Change-Id: I4af8a10cc59078c436130ce472f25abc3a9b2f80
Reviewed-on: https://go-review.googlesource.com/20890
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-19 00:45:09 +00:00
Todd Neal
fc6bcdee79 cmd/compile: allow inlining of functions that declare a const
Consider functions with an ODCLCONST for inlining and modify exprfmt to
ignore those nodes when exporting. Don't add symbols to the export list
if there is no definition.  This occurs when OLITERAL symbols are looked
up via Pkglookup for non-exported symbols.

Fixes #7655

Change-Id: I1de827850f4c69e58107447314fe7433e378e069
Reviewed-on: https://go-review.googlesource.com/20773
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-18 23:26:36 +00:00
Keith Randall
3dd4f74e06 cmd/compile: merge shifts into LEAs
Change-Id: I5a43c354f36184ae64a52268023c3222da3026d8
Reviewed-on: https://go-review.googlesource.com/20880
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-18 23:08:24 +00:00
Keith Randall
377eaa7494 runtime: add space
Missed this in review of 20812

Change-Id: I01e220499dcd58e1a7205e2a577dd9630a8b7174
Reviewed-on: https://go-review.googlesource.com/20819
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-18 21:31:49 +00:00
Martin Möhrmann
e97789f7d9 fmt: simplify handling of reporting flags to formatters
Remove rewriting of flags before calling formatters.
Change Flag method to directly take plusV and sharpV flags
into account when reporting if plus or sharp flag is set.

Change-Id: Ic3423881ad89e5a5f9fff5ab59e842062394ef6d
Reviewed-on: https://go-review.googlesource.com/20859
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-18 21:28:06 +00:00
Keith Randall
15ea61146e runtime: use unaligned loads on ppc64
benchmark                      old ns/op     new ns/op     delta
BenchmarkAlignedLoad-160       8.67          7.42          -14.42%
BenchmarkUnalignedLoad-160     8.63          7.37          -14.60%

Change-Id: Id4609d7b4038c4d2ec332efc4fe6f1adfb61b82b
Reviewed-on: https://go-review.googlesource.com/20812
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-18 19:21:53 +00:00
David Chase
982322769c cmd/dist: redo flag-passing for bootstrap
This ought to revert the bad effects of
https://go-review.googlesource.com/#/c/20775/
If you don't pass BOOT_GO_GCFLAGS, you get the
old behavior.

Tweaked to allow multiple space-separated flags in
BOOT_GO_GCFLAGS.

Change-Id: I2a22a04211b4535d1c5a8ec7a8a78cb051161c31
Reviewed-on: https://go-review.googlesource.com/20871
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 19:00:03 +00:00
Martin Möhrmann
40bd28f0c7 fmt: remove unused field from printer struct
Change-Id: I0ec775c51f461c6f0cbff88e796a7af55b736fcb
Reviewed-on: https://go-review.googlesource.com/20838
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-18 17:02:51 +00:00
Marcel van Lohuizen
f693015be6 sync: don't assume b.N > 0
Change-Id: I6eb91ea73ef887b025e5a8de1dd55f30618e1aa6
Reviewed-on: https://go-review.googlesource.com/20857
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-18 16:37:39 +00:00
Alan Donovan
a5cd53a9fd cmd/compile/internal/gc: support invalid types/constants in binary export data
(Corresponding x/tools/go/gcimporter change is https://go-review.googlesource.com/#/c/20827/)

Change-Id: I64e7fee2e273d387f1c51b87986294489978d250
Reviewed-on: https://go-review.googlesource.com/20828
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-18 16:33:38 +00:00
Marcel van Lohuizen
2d4c3d2489 testing: disable tests that cause a hang on some platforms
plan9, nacl, and netbsd to be precise.

Only the first test causes a hang, but just to be sure.

Change-Id: I400bb356ee2a0cf12c8666c95af79c924d1629aa
Reviewed-on: https://go-review.googlesource.com/20839
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 16:24:27 +00:00
Marcel van Lohuizen
f39d6d9613 testing: always ignore RunParallel in probe phase
Change-Id: If45410a2d7e48d1c9e6800cd98f81dd89024832c
Reviewed-on: https://go-review.googlesource.com/20852
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 16:23:51 +00:00
Marcel van Lohuizen
872ca73cad runtime: don't assume b.N > 0
Change-Id: I2e26717f2563d7633ffd15f4adf63c3d0ee3403f
Reviewed-on: https://go-review.googlesource.com/20856
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 15:55:02 +00:00
Marcel van Lohuizen
3e2e80599e net/url: don't assume b.N > 0
Change-Id: Ie79c16d6e61b3baa274069528cf883b22fd255fe
Reviewed-on: https://go-review.googlesource.com/20855
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 15:54:59 +00:00
Marcel van Lohuizen
d3ce412fa5 net/rpc: don't assume b.N > 0
Change-Id: I58c4a75168fd1f797a25735c4151f501f0475332
Reviewed-on: https://go-review.googlesource.com/20854
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 15:54:55 +00:00
Marcel van Lohuizen
6e2deaa1e1 encoding/binary: don't assume b.N > 0
Change-Id: I9e887a0b32baf0adc85fa9e4b85b319e8ef333e9
Reviewed-on: https://go-review.googlesource.com/20853
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 15:54:51 +00:00
Marcel van Lohuizen
705be76b6f encoding/binary: improve error messages for benchmarks
Change-Id: I0f4b6752ecc8b4945ecfde627cdec13fc4bb6a69
Reviewed-on: https://go-review.googlesource.com/20850
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 15:38:58 +00:00
Todd Neal
b2dc1f82a5 cmd/compile: perform minimal phi elimination during critical
Phi splitting sometimes leads to a phi with only a single predecessor.
This must be replaced with a copy to maintain a valid SSA form.

Fixes #14857

Change-Id: I5ab2423fb6c85a061928e3206b02185ea8c79cd7
Reviewed-on: https://go-review.googlesource.com/20826
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-18 15:35:49 +00:00
Marcel van Lohuizen
2330ae8cf8 testing: finish implementation of subtests
API not exposed yet.

Change-Id: Iaba0adc0fa1ae8075e6b56796f99ee8db9177a78
Reviewed-on: https://go-review.googlesource.com/18896
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 12:30:39 +00:00
Marcel van Lohuizen
1857bfca13 testing: implementation of subbenchmarks
API is not exposed yet.

Change-Id: I729360ef2be1d8ea683ca93cdb1763897cc8657c
Reviewed-on: https://go-review.googlesource.com/18895
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 12:05:55 +00:00
Marcel van Lohuizen
89cda2db00 testing: hoisted chunks of code to prepare for Run method
testing.go:
- run method will evolve into the Run method.
- added level field in common

benchmark.go:
- benchContext will be central to distinguish handling of benchmarks
  between normal Run methods and ones called from within Benchmark
  function.
- expandCPU will evolve into the processing hook for Run methods
  called within normal processing.
- runBench will evolve into the Run method.

Change-Id: I1816f9985d5ba94deb0ad062302ea9aee0bb5338
Reviewed-on: https://go-review.googlesource.com/18894
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 11:35:16 +00:00
Marcel van Lohuizen
5c83e651ad testing: prepare for the introduction of Run methods
The biggest change is that each test is now responsible for managing
the starting and stopping of its parallel subtests.

The "Main" test could be run as a tRunner as well. This shows that
the introduction of subtests is merely a generalization of and
consistent with the current semantics.

Change-Id: Ibf8388c08f85d4b2c0df69c069326762ed36a72e
Reviewed-on: https://go-review.googlesource.com/18893
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 11:25:54 +00:00
David Symonds
248c3a3c7b regexp: avoid copying mutex in (*Regexp).Copy.
There's nothing guaranteeing that the *Regexp isn't in active use,
and so copying the sync.Mutex value is invalid.

Updates #14839.

Change-Id: Iddf52bf69df1b563377922399f64a571f76b95dd
Reviewed-on: https://go-review.googlesource.com/20841
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-18 03:56:28 +00:00
David Chase
815c9a7f28 cmd/compile: use loop information in regalloc
This seems to help the problem reported in #14606; this
change seems to produce about a 4% improvement (mostly
for the 128-8192 shards).

Fixes #14789.

Change-Id: I1bd52c82d4ca81d9d5e9ab371fdfc860d7e8af50
Reviewed-on: https://go-review.googlesource.com/20660
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-18 01:23:29 +00:00
Christopher Nelson
e4d489a85f cmd/go: fix TestShadowingLogic fails when GOROOT path has spaces
Improve the test by also translating " " to "_".

Fixes #14671.

Change-Id: Ie5997934b93c7663d7b8432244fad47bb5d3ffbe
Reviewed-on: https://go-review.googlesource.com/20714
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-18 01:12:06 +00:00
David Chase
09a9ce60c7 cmd/compile: get gcflags to bootstrap; ssa debug opts for "all"
This is intended to help debug compiler problems that pop
up in the bootstrap phase of make.bash.  GO_GCFLAGS does not
normally apply there.  Options-for-all phases is intended
to allow crude tracing (and full timing) by turning on timing
for all phases, not just one.

Phase names can also be specified using a regular expression,
for example
BOOT_GO_GCFLAGS=-d='ssa/~^.*scc$/off' \
GO_GCFLAGS='-d=ssa/~^.*scc$/off' ./make.bash

I just added this because it was the fastest way to get
me to a place where I could easily debug the compiler.

Change-Id: I0781f3e7c19651ae7452fa25c2d54c9a245ef62d
Reviewed-on: https://go-review.googlesource.com/20775
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-18 01:04:47 +00:00
Todd Neal
2cc42cf2a8 cmd/compile/test: replace switch{} with go:noinline
Change-Id: Ic40449b2e4b4f18cbe5b5d4c3d51ea7b05ac674d
Reviewed-on: https://go-review.googlesource.com/20823
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-17 23:49:35 +00:00
Mikio Hara
ac2f84d524 net: make unexposed methods start with lowercase letters
This change makes unexposed methods start with lowercase letters for
avoiding unnecessary confusion because the net package uses many
embedding structures and intrefaces for controlling exposure of APIs.

Note that this change leaves DNS-related methods as they are.

Change-Id: I253758d1659175c5d0af6b2efcd30ce83f46543d
Reviewed-on: https://go-review.googlesource.com/20784
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-17 21:43:41 +00:00
Hyang-Ah Hana Kim
50487b2c8d cmd/pack,vet: use go doc instead of godoc in doc
Change-Id: Ic5f62a7d0a5c090da69213d1d0187af0ea48e358
Reviewed-on: https://go-review.googlesource.com/20820
Reviewed-by: Rob Pike <r@golang.org>
2016-03-17 21:06:40 +00:00
David Chase
3a17fdaba0 cmd/compile: correct maintain use count when phi args merge
The critical phase did not correctly maintain the use count
when two predecessors of a new critical block transmit the
same value.

Change-Id: Iba802c98ebb84e36a410721ec32c867140efb6d4
Reviewed-on: https://go-review.googlesource.com/20822
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-17 20:55:13 +00:00
Alexandru Moșoi
ebd9f1bd4c encoding/binary: remove bound checks from conversions.
* This the simplest solution I could came up with
that doesn't required changing the compiler.
* The bound checks become constants now
so they are removed during opt phase.

Updates #14808

Change-Id: If32c33d7ec08bb400321b465015d152f0a5d3001
Reviewed-on: https://go-review.googlesource.com/20654
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-17 20:48:39 +00:00
Matthew Dempsky
dbed1c6361 cmd/compile: eliminate NumFields wrapper functions
Change-Id: I3c6035559288cfdc33857216f50241b81932c8a4
Reviewed-on: https://go-review.googlesource.com/20811
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-17 20:43:18 +00:00
Keith Randall
15ed37d7b7 cmd/compile: enforce nowritebarrier in SSA compiler
Make sure we don't generate write barriers in runtime
code that is marked to forbid write barriers.

Implement the optimization that if we're writing a sliced
slice back to the location it came from, we don't need a
write barrier.

Fixes #14784

Change-Id: I04b6a3b2ac303c19817e932a36a3b006de103aaa
Reviewed-on: https://go-review.googlesource.com/20791
Reviewed-by: Austin Clements <austin@google.com>
2016-03-17 20:13:24 +00:00
Shahar Kohanim
16029babe2 cmd/compile: deduplicate symbol references
Reduces size of archives in pkg/linux_amd64 by 1.4MB (3.2%),
slightly improving link time.

name       old s/op   new s/op   delta
LinkCmdGo  0.52 ± 3%  0.51 ± 2%  -0.65%  (p=0.000 n=98+99)

Change-Id: I7e265f4d4dd08967c5c5d55c1045e533466bbbec
Reviewed-on: https://go-review.googlesource.com/20802
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-17 20:09:40 +00:00
Ingo Oeser
2d03b5b572 cmd/compile: fix comment
Change-Id: I32fd5c36f055fdb1dfe56524085676aa4111089a
Reviewed-on: https://go-review.googlesource.com/20830
Reviewed-by: David Chase <drchase@google.com>
2016-03-17 19:45:30 +00:00
Matthew Dempsky
c837761b52 cmd/compile: get rid of Type's {This,In,Out}tuple fields
Boolean expressions involving t.Thistuple were converted to use
t.Recv(), because it's a bit clearer and will hopefully reveal cases
where we could remove redundant calls to t.Recv() (in followup CLs).

The other cases were all converted to use t.Recvs().NumFields(),
t.Params().NumFields(), or t.Results().NumFields().

Change-Id: I4df91762e7dc4b2ddae35995f8dd604a52c09b09
Reviewed-on: https://go-review.googlesource.com/20796
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2016-03-17 19:38:30 +00:00
Matthew Dempsky
d447613875 cmd/compile: simplify typehash
We never need a type hash for a method type, so skip trying to
overwrite Thistuple.

Change-Id: I8de6480ba5fd321dfa134facf7661461d298840e
Reviewed-on: https://go-review.googlesource.com/20795
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-17 19:38:21 +00:00
Matthew Dempsky
f6bca3f32d cmd/compile: eliminate a bunch of IterFields/IterMethods calls
This is an automated rewrite of all the calls of the form:

    for f, it := IterFields(t); f != nil; f = it.Next() { ... }

Followup CLs will work on cleaning up the remaining cases.

Change-Id: Ic1005ad45ae0b50c63e815e34e507e2d2644ba1a
Reviewed-on: https://go-review.googlesource.com/20794
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-17 19:38:15 +00:00
Matthew Dempsky
517b6131b2 cmd/compile: add and use new Fields type
Analogous to the Nodes type used as a more space efficient []*Node
representation.

Passes toolstash -cmp.

Change-Id: I8341e45304777d6e4200bd36dadc935b07ccf3ff
Reviewed-on: https://go-review.googlesource.com/20793
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-17 19:37:14 +00:00
Austin Clements
857d0b48db runtime: document sudog
Change-Id: I85c0bcf02842cc32dbc9bfdcea27efe871173574
Reviewed-on: https://go-review.googlesource.com/20774
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-17 18:57:10 +00:00
Matthew Dempsky
ac74e5debc cmd/compile: stop constructing sudog type
The compiler doesn't care about the runtime's sudog type. Stop
constructing it.

Change-Id: If1885fe30b2e215a08d17662eab5ea6d81fe58ab
Reviewed-on: https://go-review.googlesource.com/20797
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2016-03-17 18:02:40 +00:00
Ian Lance Taylor
65b4020403 cmd/compile: don't create 2 Sym's and 2 Node's for every string
For every string constant the compiler was creating 2 Sym's and 2
Node's.  It would never refer to them again, but would keep them alive
in gostringpkg.  This changes the code to just use obj.LSym's instead.

When compiling x/tools/go/types, this yields about a 15% reduction in
the number of calls to newname and a 3% reduction in the total number of
Node objects.  Unfortunately I couldn't see any change in compile time,
but reducing memory usage is desirable anyhow.

Passes toolstash -cmp.

Change-Id: I24f1cb1e6cff0a3afba4ca66f7166874917a036b
Reviewed-on: https://go-review.googlesource.com/20792
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-17 16:15:11 +00:00
David Chase
2d56dee61b cmd/compile: escape analysis explanations added to -m -m output
This should probably be considered "experimental" at this stage, but
what it needs is feedback from adventurous adopters.  I think the data
structure used for describing escape reasons might be extendable to
allow a cleanup of the underlying algorithms, which suffers from
insufficiently separated concerns (the graph does not deal well with
escape level adjustments, so it is augmented by a second custom-walk
portion of the "flood" phase. It would be better to put it all,
including level adjustments, in a single graph structure, and then
simply flood the graph.

Tweaked to avoid allocations in the no-logging case.

Modified run.go to ignore lines with leading "#" in the output (since
it can never match a line), and in -update_errors to ignore leading
tabs in output lines and to normalize embedded filenames.

Currently requires -m -m because otherwise the noise/update
burden for the other escape tests is considerable.

There is a partial test.  Existing escape analysis tests seem to
cover all except the panic case and what looks like it might be
unreachable code in escape analysis.

Fixes #10526.

Change-Id: I2524fdec54facae48b00b2548e25d9e46fcaf832
Reviewed-on: https://go-review.googlesource.com/18041
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-17 13:29:48 +00:00
Todd Neal
50bc546d43 cmd/compile: reuse blocks in critical pass
If a phi has duplicate arguments, then the new block that is constructed
to remove the critical edge can be used for all of the duplicate
arguments.

read-only data = -904 bytes (-0.058308%)
global text (code) = -2240 bytes (-0.060056%)
Total difference -3144 bytes (-0.056218%)

Change-Id: Iee3762744d6a8c9d26cdfa880bb23feb62b03c9c
Reviewed-on: https://go-review.googlesource.com/20746
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-17 12:12:34 +00:00
Richard Miller
f2f2434d47 syscall: avoid failure in plan9 StartProcess from fd close race
Between the enumeration of fdsToClose in the parent and the
closing of fds in the child, it's possible for a file to be
closed in another thread. If that file descriptor is reused
when opening the child-parent status pipe, it will be closed
prematurely in the child and the forkExec gets out of sync.
This has been observed to cause failures in builder tests
when the link step of a build is started before the compile
step has run, with "file does not exist" messages as the
visible symptom.

The simple workaround is to check against closing the pipe.
A more comprehensive solution would be to rewrite the fd
closing code to avoid races, along the lines of the long
ago proposed https://golang.org/cl/57890043 - but meanwhile
this correction will prevent some builder failures.

Change-Id: I4ef5eaea70c21d00f4df0e0847a1c5b2966de7da
Reviewed-on: https://go-review.googlesource.com/20800
Run-TryBot: David du Colombier <0intro@gmail.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
2016-03-17 11:40:51 +00:00
Martin Möhrmann
d38275c74a fmt: separate unicode and integer formatting
Separate unicode formatting into its own fmt_unicode function.
Remove the fmtUnicode wrapper and the f.unicode and f.uniQuote
flags that are not needed anymore. Remove mangling and restoring
of the precision and sharp flags.

Removes the buffer copy needed for %#U by moving
the character encoding before the number encoding.

Changes the behavior of plus and space flag to have
no effect instead of printing a plus or space before "U+".

Always print at least four digits after "U+"
even if precision is set to less than 4.

Change-Id: If9a0ee79e9eca2c76f06a4e0fdd75d98393899ac
Reviewed-on: https://go-review.googlesource.com/20574
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-17 09:30:26 +00:00
Keith Randall
56e0ecc5ea cmd/compile: keep value use counts in SSA
Keep track of how many uses each Value has.  Each appearance in
Value.Args and in Block.Control counts once.

The number of uses of a value is generically useful to
constrain rewrite rules.  For instance, we might want to
prevent merging index operations into loads if the same
index expression is used lots of times.

But I have one use in particular for which the use count is required.
We must make sure we don't combine ops with loads if the load has
more than one use.  Otherwise, we may split a single load
into multiple loads and that breaks perceived behavior in
the presence of races.  In particular, the load of m.state
in sync/mutex.go:Lock can't be done twice.  (I have a separate
CL which triggers the mutex failure.  This CL has a test which
demonstrates a similar failure.)

Change-Id: Icaafa479239f48632a069d0c3f624e6ebc6b1f0e
Reviewed-on: https://go-review.googlesource.com/20790
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-17 04:20:02 +00:00
Dave Cheney
cb1f2afc99 cmd/compile/internal/gc: disable logProgs debug flag
Spotted while splunking in the compiler with GOGC=off.

name       old time/op     new time/op     delta
Template       407ms ± 5%      402ms ± 6%     ~           (p=0.301 n=20+20)
GoTypes        1.33s ± 2%      1.29s ± 1%   -3.47%        (p=0.000 n=20+20)
Compiler       6.21s ± 1%      5.91s ± 2%   -4.83%        (p=0.000 n=20+20)

name       old alloc/op    new alloc/op    delta
Template      66.8MB ± 0%     63.9MB ± 0%   -4.46%        (p=0.000 n=19+20)
GoTypes        232MB ± 0%      220MB ± 0%   -5.16%        (p=0.000 n=19+17)
Compiler      1.02GB ± 0%     0.97GB ± 0%   -5.81%        (p=0.000 n=20+20)

name       old allocs/op   new allocs/op   delta
Template        789k ± 0%       708k ± 0%  -10.28%        (p=0.000 n=19+20)
GoTypes        2.49M ± 0%      2.20M ± 0%  -11.57%        (p=0.000 n=20+20)
Compiler       10.8M ± 0%       9.4M ± 0%  -12.82%        (p=0.000 n=20+20)

Change-Id: I76615cab912dde10595ca6ab9979ff6c5f1aec49
Reviewed-on: https://go-review.googlesource.com/20782
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-17 03:50:54 +00:00