1
0
mirror of https://github.com/golang/go synced 2024-11-06 04:36:15 -07:00
Commit Graph

32306 Commits

Author SHA1 Message Date
Russ Cox
92cf05daf3 test: deflake locklinear again
Fixes #19276.

Change-Id: I64f8f80331d09956b6698c0b004ed7f7d70857fc
Reviewed-on: https://go-review.googlesource.com/39591
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-04-05 18:46:31 +00:00
Russ Cox
10991fd5af cmd/go: add test for test -race -i behavior
This was fixed in CL 37598 but the test was (rightly) dropped
because it modified $GOROOT. Here's a variant that does not.

For #19151.

Change-Id: Iccdbbf9ae8ac4c252e52f4f8ff996963573c4682
Reviewed-on: https://go-review.googlesource.com/39592
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-05 18:46:16 +00:00
Austin Clements
ecb7b63820 runtime: fix gcpacertrace printing of sweep ratio
Commit 44ed88a5a7 moved printing of the "sweep done" gcpacertrace
message so that it is printed when the final sweeper finishes.
However, by this point some other thread has often already observed
that there are no more spans to sweep and zeroed sweepPagesPerByte.

Avoid printing a 0 sweep ratio in the trace when this race happens by
getting the value of the sweep ratio upon entry to sweepone and
printing that.

Change-Id: Iac0c48ae899e12f193267cdfb012c921f8b71c85
Reviewed-on: https://go-review.googlesource.com/39492
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2017-04-05 18:24:52 +00:00
Josh Bleecher Snyder
92cffa1391 cmd/internal/obj: remove dead func Copyp
Change-Id: Iaeb7bcbcdbc46c0e0e40b0aa070c706e0ca53013
Reviewed-on: https://go-review.googlesource.com/39555
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-05 15:18:14 +00:00
Lynn Boger
ed2f913b4c syscall: update comments for x/sys migration
The comments in this package state that users should be
migrating code that uses the syscall package to its
corresponding package in x/sys. However, the syscall.Signal
and syscall.Errno types and the syscall.SysProcAttr struct is
not defined in the x/sys package and still need to be referenced
from within syscall.  This adds a change to the comments to
clarify that the migration will need to continue to use some
references to syscall for now.

Fixes #19560

Change-Id: I8abb96b93bea90070ce461da16dc7bcf7b4b29c1
Reviewed-on: https://go-review.googlesource.com/39450
Reviewed-by: Rob Pike <r@golang.org>
2017-04-05 14:22:15 +00:00
Russ Cox
a7b51cfb47 testing/quick: use Uint64 instead of Int63
Followup to CL 39152.

Change-Id: I9bfed0c6071ea3d3a43294a6c4a50edc131368cf
Reviewed-on: https://go-review.googlesource.com/39313
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-05 14:03:03 +00:00
Lorenzo Masini
476f55fd8a cmd/objdump: print Go code alongside assembly
Added -S flag to print go source file line above corresponding disassembly:

$ go tool objdump -S -s main.main fmthello
TEXT main.main(SB) /home/rugginoso/Documents/src/go/src/cmd/objdump/testdata/fmthello.go
func main() {
  0x47d450		64488b0c25f8ffffff	FS MOVQ FS:0xfffffff8, CX
  0x47d459		483b6110		CMPQ 0x10(CX), SP
  0x47d45d		7631			JBE 0x47d490
  0x47d45f		4883ec18		SUBQ $0x18, SP
  0x47d463		48896c2410		MOVQ BP, 0x10(SP)
  0x47d468		488d6c2410		LEAQ 0x10(SP), BP
	Println("hello, world")
  0x47d46d		488d0563b00200		LEAQ 0x2b063(IP), AX
  0x47d474		48890424		MOVQ AX, 0(SP)
  0x47d478		48c74424080c000000	MOVQ $0xc, 0x8(SP)
  0x47d481		e81a000000		CALL main.Println(SB)
}
  0x47d486		488b6c2410		MOVQ 0x10(SP), BP
  0x47d48b		4883c418		ADDQ $0x18, SP
  0x47d48f		c3			RET
func main() {
  0x47d490		e8ebf1fcff		CALL runtime.morestack_noctxt(SB)
  0x47d495		ebb9			JMP main.main(SB)

Execution time:

$ time go tool objdump testdata/fmthello > /dev/null
real	0m0.430s
user	0m0.440s
sys	0m0.000s

$ time go tool objdump -S testdata/fmthello > /dev/null
real	0m0.471s
user	0m0.476s
sys	0m0.012s

Fixes #18245

Change-Id: I9b2f8338f9ee443c1352efd270d3ba85e3dd9b78
Reviewed-on: https://go-review.googlesource.com/37953
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-04-05 06:20:40 +00:00
Alex Brainman
acc1f47299 path/filepath: add test to walk symlink
For #17540.

Change-Id: Ie01f39797526934fa553f4279cbde6c7cbf14154
Reviewed-on: https://go-review.googlesource.com/36854
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-05 02:31:45 +00:00
Josh Bleecher Snyder
4c1622082e cmd/compile: don't catch panics during rewrite
This is a holdover from the days when we did not
have full SSA coverage and compiled things optimistically,
and catching the panic obscures useful information.

Change-Id: I196790cb6b97419d92b318a2dfa7f1e1097cefb7
Reviewed-on: https://go-review.googlesource.com/39534
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2017-04-04 23:37:17 +00:00
Josh Bleecher Snyder
fc327a14c4 cmd/compile: remove order canonicalization rules from mips
CL 38801 introduced automatic commutative rule generation.
Manual order canonicalization rules thus lead to infinite loops.

Fixes #19842

Change-Id: I877c476152f4d207fdc67bc6f3018265aa9bc5ac
Reviewed-on: https://go-review.googlesource.com/39533
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-04-04 23:17:23 +00:00
Filip Gruszczyński
6c5a819a5e reflect: add MakeMapWithSize for creating maps with size hint
Providing size hint when creating a map allows avoiding re-allocating
underlying data structure if we know how many elements are going to
be inserted. This can be used for example during decoding maps in
gob.

Fixes #19599

Change-Id: I108035fec29391215d2261a73eaed1310b46bab1
Reviewed-on: https://go-review.googlesource.com/38335
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-04 20:01:43 +00:00
Rob Pike
be5a201e2a text/template: fix handling of empty blocks
This was a subtle bug introduced in the previous release's fix for
issue 16156.

The definition of empty template was broken, causing the answer
to depend on the order of templates in the map.

Fixes #16156 (for real).
Fixes #19294.
Fixes #19204.

Change-Id: I1cd915c94534cad3116d83bd158cbc28700510b9
Reviewed-on: https://go-review.googlesource.com/38420
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-04 15:46:02 +00:00
Martin Möhrmann
bebfd4ba41 strings: speed up Fields
- use a string lookup to detect if a single byte is a space character
- determine the exact number of fields for ASCII and
  a possibly underestimated number of fields for non ASCII strings
  by doing a separate byte for byte scan of the input string
  before collecting the fields in an extra pass
- provide a fast path for ASCII only strings when collecting the fields
- avoid utf8.DecodeRuneInString and unicode.IsSpace for ASCII characters

Used golang.org/cl/33108 from Joe Tsai as starting point.

name                      old time/op    new time/op     delta
Fields/ASCII/16              284ns ± 1%      116ns ± 2%   -59.30%  (p=0.000 n=9+10)
Fields/ASCII/256            3.81µs ± 1%     0.80µs ± 1%   -79.10%  (p=0.000 n=10+10)
Fields/ASCII/4096           61.4µs ± 1%     12.3µs ± 1%   -79.96%  (p=0.000 n=10+9)
Fields/ASCII/65536           982µs ± 1%      235µs ± 0%   -76.04%  (p=0.000 n=10+9)
Fields/ASCII/1048576        16.7ms ± 2%      5.4ms ± 1%   -67.52%  (p=0.000 n=10+10)
Fields/Mixed/16              314ns ± 1%      168ns ± 1%   -46.33%  (p=0.000 n=9+10)
Fields/Mixed/256            3.92µs ± 1%     1.17µs ± 1%   -70.19%  (p=0.000 n=10+10)
Fields/Mixed/4096           69.1µs ± 1%     19.0µs ± 1%   -72.53%  (p=0.000 n=10+10)
Fields/Mixed/65536          1.12ms ± 1%     0.39ms ± 0%   -65.37%  (p=0.000 n=10+9)
Fields/Mixed/1048576        19.0ms ± 2%      7.3ms ± 4%   -61.75%  (p=0.000 n=10+9)

name                      old speed      new speed       delta
Fields/ASCII/16           56.3MB/s ± 1%  138.1MB/s ± 2%  +145.31%  (p=0.000 n=9+10)
Fields/ASCII/256          67.1MB/s ± 1%  321.0MB/s ± 1%  +378.26%  (p=0.000 n=10+10)
Fields/ASCII/4096         66.7MB/s ± 1%  333.0MB/s ± 1%  +398.97%  (p=0.000 n=10+9)
Fields/ASCII/65536        66.7MB/s ± 1%  278.4MB/s ± 0%  +317.39%  (p=0.000 n=10+9)
Fields/ASCII/1048576      62.7MB/s ± 2%  192.9MB/s ± 1%  +207.82%  (p=0.000 n=10+10)
Fields/Mixed/16           51.0MB/s ± 2%   94.9MB/s ± 1%   +85.87%  (p=0.000 n=10+10)
Fields/Mixed/256          65.4MB/s ± 1%  219.2MB/s ± 1%  +235.33%  (p=0.000 n=10+10)
Fields/Mixed/4096         59.3MB/s ± 1%  215.7MB/s ± 1%  +263.98%  (p=0.000 n=10+10)
Fields/Mixed/65536        58.6MB/s ± 1%  169.1MB/s ± 0%  +188.73%  (p=0.000 n=10+9)
Fields/Mixed/1048576      55.1MB/s ± 2%  144.0MB/s ± 4%  +161.44%  (p=0.000 n=10+9)

Updates #19789
Updates #17856

Change-Id: If2ce1479542702e9cd65a82a462ba55ac8eb3876
Reviewed-on: https://go-review.googlesource.com/37959
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2017-04-04 06:26:11 +00:00
Keith Randall
5cadc91b3c cmd/compile: intrinsics for math/bits.OnesCount
Popcount instructions on amd64 are not guaranteed to be
present, so we must guard their call.  Rewrite rules can't
generate control flow at the moment, so the intrinsifier
needs to generate that code.

name           old time/op  new time/op  delta
OnesCount-8    2.47ns ± 5%  1.04ns ± 2%  -57.70%  (p=0.000 n=10+10)
OnesCount16-8  1.05ns ± 1%  0.78ns ± 0%  -25.56%    (p=0.000 n=9+8)
OnesCount32-8  1.63ns ± 5%  1.04ns ± 2%  -35.96%  (p=0.000 n=10+10)
OnesCount64-8  2.45ns ± 0%  1.04ns ± 1%  -57.55%   (p=0.000 n=6+10)

Update #18616

Change-Id: I4aff2cc9aa93787898d7b22055fe272a7cf95673
Reviewed-on: https://go-review.googlesource.com/38320
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-04-04 02:40:11 +00:00
Eric Lagergren
59f6549d1c bytes, strings: declare variables inside loop they're used in
The recently updated Count functions declare variables before
special-cased returns.

Change-Id: I8f726118336b7b0ff72117d12adc48b6e37e60ea
Reviewed-on: https://go-review.googlesource.com/39357
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-03 23:30:36 +00:00
Josh Bleecher Snyder
42426ed411 cmd/compile: Fatal instead of panic in large bvbulkalloc
This provides better diagnostics when it occurs.

Updates #19751

Change-Id: I87db54c22e1345891b418c1741dc76ac5fb8ed00
Reviewed-on: https://go-review.googlesource.com/39358
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-03 23:28:29 +00:00
Eric Lagergren
094498c9a1 all: fix minor misspellings
Change-Id: I1f1cfb161640eb8756fb1a283892d06b30b7a8fa
Reviewed-on: https://go-review.googlesource.com/39356
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-03 23:19:07 +00:00
Josh Bleecher Snyder
50688fcb6e cmd/compile: unroll small static maps
When a map is small, it's not worth putting
the contents in an array and then looping over the array.
Just generate code instead.

This makes smaller binaries.
It might also be better for cache lines.

It also can avoids adding control flow in the middle
of the init function, which can be very large.
Eliminating this source of extra blocks
makes phi insertion easier for temp-heavy init functions.
This reduces the time required for compiler to
panic while compiling the code in #19751
from 15 minutes to 45 seconds.

The cutoff of 25 was chosen fairly unscientifically
by looking at the size of cmd/go.

Cutoff of   0: 10689604
Cutoff of   5: 10683572
Cutoff of  15: 10682324
Cutoff of  25: 10681700
Cutoff of  50: 10685476
Cutoff of 100: 10689412

There are probably more sophisticated mechanisms available.
For example, the smaller the key/value sizes, the better
generated code will be vs a table.
Nevertheless this is simple and seems like a good start.

Updates #19751

name       old time/op     new time/op     delta
Template       204ms ± 6%      202ms ± 5%  -0.78%  (p=0.027 n=47+45)
Unicode       84.8ms ± 6%     85.2ms ± 7%    ~     (p=0.146 n=46+45)
GoTypes        551ms ± 2%      556ms ± 3%  +0.76%  (p=0.004 n=43+45)
SSA            3.93s ± 3%      3.95s ± 4%    ~     (p=0.179 n=50+49)
Flate          123ms ± 4%      123ms ± 5%    ~     (p=0.201 n=47+49)
GoParser       145ms ± 3%      145ms ± 4%    ~     (p=0.937 n=50+50)
Reflect        356ms ± 3%      354ms ± 5%  -0.44%  (p=0.048 n=46+50)
Tar            107ms ± 6%      106ms ± 6%    ~     (p=0.188 n=50+49)
XML            201ms ± 4%      200ms ± 4%    ~     (p=0.085 n=50+49)

name       old user-ns/op  new user-ns/op  delta
Template        252M ± 9%       250M ± 7%    ~     (p=0.206 n=49+47)
Unicode         106M ± 7%       106M ± 9%    ~     (p=0.331 n=47+46)
GoTypes         724M ± 5%       729M ± 5%    ~     (p=0.160 n=47+49)
SSA            5.64G ± 2%      5.62G ± 4%    ~     (p=0.148 n=47+50)
Flate           147M ± 6%       147M ± 5%    ~     (p=0.466 n=50+49)
GoParser        179M ± 5%       179M ± 6%    ~     (p=0.584 n=50+49)
Reflect         448M ± 6%       441M ± 8%  -1.39%  (p=0.027 n=50+49)
Tar             124M ± 6%       123M ± 5%    ~     (p=0.221 n=50+47)
XML             244M ± 5%       243M ± 4%    ~     (p=0.275 n=49+49)

name       old alloc/op    new alloc/op    delta
Template      39.9MB ± 0%     39.4MB ± 0%  -1.28%  (p=0.008 n=5+5)
Unicode       29.8MB ± 0%     29.8MB ± 0%    ~     (p=0.310 n=5+5)
GoTypes        113MB ± 0%      113MB ± 0%    ~     (p=0.421 n=5+5)
SSA            854MB ± 0%      854MB ± 0%    ~     (p=0.151 n=5+5)
Flate         25.3MB ± 0%     25.3MB ± 0%    ~     (p=1.000 n=5+5)
GoParser      31.8MB ± 0%     31.8MB ± 0%    ~     (p=0.222 n=5+5)
Reflect       78.2MB ± 0%     78.2MB ± 0%    ~     (p=1.000 n=5+5)
Tar           26.7MB ± 0%     26.7MB ± 0%    ~     (p=0.841 n=5+5)
XML           42.3MB ± 0%     42.3MB ± 0%  -0.15%  (p=0.008 n=5+5)

name       old allocs/op   new allocs/op   delta
Template        390k ± 1%       386k ± 1%  -1.05%  (p=0.016 n=5+5)
Unicode         319k ± 0%       320k ± 0%    ~     (p=0.310 n=5+5)
GoTypes        1.14M ± 0%      1.14M ± 0%    ~     (p=0.421 n=5+5)
SSA            7.60M ± 0%      7.59M ± 0%    ~     (p=0.310 n=5+5)
Flate           234k ± 0%       235k ± 1%    ~     (p=1.000 n=5+5)
GoParser        315k ± 1%       317k ± 0%    ~     (p=0.151 n=5+5)
Reflect         978k ± 0%       978k ± 0%    ~     (p=0.841 n=5+5)
Tar             251k ± 1%       251k ± 1%    ~     (p=0.690 n=5+5)
XML             394k ± 0%       392k ± 0%    ~     (p=0.056 n=5+5)


Change-Id: Ic53a18627082abe075a1cbc33330ce015e50850a
Reviewed-on: https://go-review.googlesource.com/39354
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-04-03 22:41:06 +00:00
Keith Randall
53f8a6aeb0 cmd/compile: automatically handle commuting ops in rewrite rules
Note that this is a redo of an undo of the original buggy CL 38666.

We have lots of rewrite rules that vary only in the fact that
we have 2 versions for the 2 different orderings of various
commuting ops. For example:

(ADDL x (MOVLconst [c])) -> (ADDLconst [c] x)
(ADDL (MOVLconst [c]) x) -> (ADDLconst [c] x)

It can get unwieldly quickly, especially when there is more than
one commuting op in a rule.

Our existing "fix" for this problem is to have rules that
canonicalize the operations first. For example:

(Eq64 x (Const64 <t> [c])) && x.Op != OpConst64 -> (Eq64 (Const64 <t> [c]) x)

Subsequent rules can then assume if there is a constant arg to Eq64,
it will be the first one. This fix kinda works, but it is fragile and
only works when we remember to include the required extra rules.

The fundamental problem is that the rule matcher doesn't
know anything about commuting ops. This CL fixes that fact.

We already have information about which ops commute. (The register
allocator takes advantage of commutivity.)  The rule generator now
automatically generates multiple rules for a single source rule when
there are commutative ops in the rule. We can now drop all of our
almost-duplicate source-level rules and the canonicalization rules.

I have some CLs in progress that will be a lot less verbose when
the rule generator handles commutivity for me.

I had to reorganize the load-combining rules a bit. The 8-way OR rules
generated 128 different reorderings, which was causing the generator
to put too much code in the rewrite*.go files (the big ones were going
from 25K lines to 132K lines). Instead I reorganized the rules to
combine pairs of loads at a time. The generated rule files are now
actually a bit (5%) smaller.

Make.bash times are ~unchanged.

Compiler benchmarks are not observably different. Probably because
we don't spend much compiler time in rule matching anyway.

I've also done a pass over all of our ops adding commutative markings
for ops which hadn't had them previously.

Fixes #18292

Change-Id: Ic1c0e43fbf579539f459971625f69690c9ab8805
Reviewed-on: https://go-review.googlesource.com/38801
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2017-04-03 22:03:43 +00:00
Keith Randall
63a72fd447 cmd/compile: strength-reduce floating point
x*2 -> x+x
x/c, c power of 2 -> x*(1/c)

Fixes #19827

Change-Id: I74c9f0b5b49b2ed26c0990314c7d1d5f9631b6f1
Reviewed-on: https://go-review.googlesource.com/39295
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2017-04-03 21:27:03 +00:00
Josh Bleecher Snyder
095a62c349 cmd/compile: refactor maplit
Instead of walking the list of nodes twice,
once to find static entries to add to an array
and once to find dynamic entries to generate code for,
do the split once up front, into two slices.
Then process each slice individually.
This makes the code easier to read
and more importantly, easier to modify.

While we're here, add a TODO to avoid
using temporaries for mapassign_fast calls.
It's not an important TODO;
the generated code would be basically identical.
It would just avoid a minor amount of
pointless SSA optimization work.

Passes toolstash-check.
No measureable compiler performance impact.

Updates #19751

Change-Id: I84a8f2c22f9025c718ef34639059d7bd02a3c406
Reviewed-on: https://go-review.googlesource.com/39351
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-03 20:10:17 +00:00
Russ Cox
1d6a499cc0 encoding/pem: yet another fuzz fake failure
Fixes #19829.

Change-Id: I8500fd73c37b504d6ea25f5aff7017fbc0718570
Reviewed-on: https://go-review.googlesource.com/39314
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-03 18:46:56 +00:00
Brad Fitzpatrick
69fe9ea43e cmd/compile/internal/ssa: use recently agreed upon generated code header
Updates #13560

Change-Id: I9bc08ca5cf0627e653d55f748ebb83be8b69ea3b
Reviewed-on: https://go-review.googlesource.com/39296
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-03 18:04:41 +00:00
Josh Bleecher Snyder
7439ba32ff cmd/compile: respect Node.Bounded when inserting OpArraySelect
This triggers 119 times during make.bash.

This CL reduces the time it takes for the
compiler to panic while compiling the code in #19751 
from 22 minutes to 15 minutes. Yay, I guess.

Updates #19751 

Change-Id: I8ca7f1ae75f89d1eb2a361d67b3055a975221734
Reviewed-on: https://go-review.googlesource.com/39294
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2017-04-03 17:31:08 +00:00
David Chase
9d5987d79f cmd/compile: rewrite upper-bit-clear idiom to use shift-rotate
Old buggy hardware incorrectly executes the shift-left-K
then shift-right-K idiom for clearing K leftmost bits.
Use a right rotate instead of shift to avoid triggering the
bug.

Fixes #19809.

Change-Id: I6dc646b183c29e9d01aef944729f34388dcc687d
Reviewed-on: https://go-review.googlesource.com/39310
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2017-04-03 17:16:23 +00:00
Daniel Martí
d6b999436a go/parser: fix example to run on the playground
The example shouldn't rely on the existance of example_test.go. That
breaks in the playground, which is what the "run" button in
https://golang.org/pkg/go/parser/#example_ParseFile does.

Make the example self-sufficient by using a small piece of source via a
string literal instead.

Fixes #19823.

Change-Id: Ie8a3c6c5d00724e38ff727862b62e6a3621adc88
Reviewed-on: https://go-review.googlesource.com/39236
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-04-03 16:07:09 +00:00
Josh Bleecher Snyder
26308fb481 cmd/internal/obj: use string instead of LSym in Pcln
In a concurrent backend, Ctxt.Lookup will need some
form of concurrency protection, which will make it
more expensive.

This CL changes the pcln table builder to track
filenames as strings rather than LSyms.
Those strings are then converted into LSyms
at the last moment, for writing the object file.

This CL removes over 85% of the calls to Ctxt.Lookup
in a run of make.bash.

Passes toolstash-check.

Updates #15756

Change-Id: I3c53deff6f16f2643169f3bdfcc7aca2ca58b0a4
Reviewed-on: https://go-review.googlesource.com/39291
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-03 15:19:47 +00:00
Russ Cox
719c7b03ba testing/quick: generate all possible int64, uint64 values
When generating a random int8, uint8, int16, uint16, int32, uint32,
quick.Value chooses among all possible values.

But when generating a random int64 or uint64, it only chooses
values in the range [-2⁶², 2⁶²) (even for uint64).
It should, like for all the other integers, use the full range.

If it had, this would have caught #19807 earlier.
Instead it let us discover the presence of #19809.

While we are here, also make the default source of
randomness not completely deterministic.

Fixes #19808.

Change-Id: I070f852531c92b3670bd76523326c9132bfc9416
Reviewed-on: https://go-review.googlesource.com/39152
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2017-04-03 14:01:25 +00:00
Russ Cox
65c17a05e9 encoding/pem: do not try to round trip value with leading/trailing space
The header is literally

	Key: Value

If the value or the key has leading or trailing spaces, those will
be lost by the round trip.

Found because testing/quick returns different values now.

Change-Id: I0f574bdbb5990689509c24309854d8f814b5efa0
Reviewed-on: https://go-review.googlesource.com/39211
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-03 13:56:30 +00:00
Josh Bleecher Snyder
64f00fb150 cmd/compile: len(n.List.Slice()) -> n.List.Len()
Minor cleanup.

This is the only such instance in the compiler.

Change-Id: I4e8ecde57d71867c7e1ac4d17e2154a91dd262b0
Reviewed-on: https://go-review.googlesource.com/39209
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-03 02:22:17 +00:00
Josh Bleecher Snyder
96af817497 cmd/compile: add block profiling support
Updates #15756

Change-Id: Ic635812b324af926333122c02908cebfb24d7bce
Reviewed-on: https://go-review.googlesource.com/39208
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-03 01:48:59 +00:00
Josh Bleecher Snyder
877574725b cmd/compile: enforce that all nodes are used when generating DWARF
No particular need for this,
but it's nice to enforce invariants
when they are available.

Change-Id: Ia6fa88dc4116f65dac2879509746e123e2c1862a
Reviewed-on: https://go-review.googlesource.com/39201
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-03 01:23:06 +00:00
Josh Bleecher Snyder
3751513562 cmd/compile: don't modify nodfp in AllocFrame
nodfp is a global, so modifying it is unsafe in a concurrent backend.
It is also not necessary, since the Used marks
are only relevant for nodes in fn.Dcl.
For good measure, mark nodfp as always used.

Passes toolstash-check.

Updates #15756

Change-Id: I5320459f5eced2898615a17b395a10c1064bcaf5
Reviewed-on: https://go-review.googlesource.com/39200
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-03 01:22:58 +00:00
Cherry Zhang
a1cedf0842 cmd/link: canonicalize the "package" of dupok text symbols
Dupok symbols may be defined in multiple packages. Its associated
package is chosen sort of arbitrarily (the first containing package
that the linker loads). Canonicalize its package to the package
with which it will be laid down in text, which is the first package
in dependency order that defines the symbol. So later passes (for
example, trampoline insertion pass) know that the dupok symbol
is laid down along with the package.

Fixes #19764.

Change-Id: I7cbc7474ff3016d5069c8b7be04af934abab8bc3
Reviewed-on: https://go-review.googlesource.com/39150
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: David Chase <drchase@google.com>
2017-04-02 03:25:02 +00:00
Dave Cheney
78f6622b81 cmd/internal/obj/*: rename Rconv to rconv
Each architecture's Rconv function is only used inside its
respective package, so it does not need to be exported.

Change-Id: Ifbd629964d7a9edd66501d7cdf4750621d66d646
Reviewed-on: https://go-review.googlesource.com/39110
Run-TryBot: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-01 10:41:37 +00:00
Jamie Stackhouse
d96f9cbb87 mime/multipart: add Size to FileHeader
This change makes it possible to retrieve the size of a file part
without having to Seek to determine file-size.

Resolves #19501

Change-Id: I7b9994c4cf41c9b06a046eb7046f8952ae1f15e9
Reviewed-on: https://go-review.googlesource.com/39223
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-01 10:04:56 +00:00
Emmanuel Odeke
8a4cee67af cmd/compile: use yyerrorl in typecheckswitch
Replace yyerror usages with yyerrorl in function
typecheckswitch.

Updates #19683.

Change-Id: I7188cdecddd2ce4e06b8cee45b57f3765a979405
Reviewed-on: https://go-review.googlesource.com/38597
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-01 02:02:58 +00:00
Robert Griesemer
e4e1d089be go/types: use std "DO NOT EDIT" comment for generated hilbert test
For #13560.

Change-Id: I884e63f89d0756ca87b8c2092b4fd8360f791a2f
Reviewed-on: https://go-review.googlesource.com/39171
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-01 00:55:49 +00:00
Josh Bleecher Snyder
a33903b02c cmd/compile: evaluate itabname during walk instead of SSA
For backend concurrency safety. Follow-up to CL 38721.

This does introduce a Nodes where there wasn't one before,
but these are so rare that the performance impact is negligible.

Does not pass toolstash-check, but the only change is line numbers,
and the new line numbers appear preferable.

Updates #15756

name       old alloc/op    new alloc/op    delta
Template      39.9MB ± 0%     39.9MB ± 0%    ~     (p=0.841 n=5+5)
Unicode       29.8MB ± 0%     29.8MB ± 0%    ~     (p=0.690 n=5+5)
GoTypes        113MB ± 0%      113MB ± 0%  +0.09%  (p=0.008 n=5+5)
SSA            854MB ± 0%      855MB ± 0%    ~     (p=0.222 n=5+5)
Flate         25.3MB ± 0%     25.3MB ± 0%    ~     (p=0.690 n=5+5)
GoParser      31.8MB ± 0%     31.9MB ± 0%    ~     (p=0.421 n=5+5)
Reflect       78.2MB ± 0%     78.3MB ± 0%    ~     (p=0.548 n=5+5)
Tar           26.7MB ± 0%     26.7MB ± 0%    ~     (p=0.690 n=5+5)
XML           42.3MB ± 0%     42.3MB ± 0%    ~     (p=0.222 n=5+5)

name       old allocs/op   new allocs/op   delta
Template        391k ± 1%       391k ± 0%    ~     (p=0.841 n=5+5)
Unicode         320k ± 0%       320k ± 0%    ~     (p=0.841 n=5+5)
GoTypes        1.14M ± 0%      1.14M ± 0%  +0.26%  (p=0.008 n=5+5)
SSA            7.60M ± 0%      7.60M ± 0%    ~     (p=0.548 n=5+5)
Flate           234k ± 0%       234k ± 1%    ~     (p=1.000 n=5+5)
GoParser        316k ± 1%       317k ± 0%    ~     (p=0.841 n=5+5)
Reflect         979k ± 0%       980k ± 0%    ~     (p=0.690 n=5+5)
Tar             251k ± 1%       251k ± 0%    ~     (p=0.595 n=5+5)
XML             394k ± 0%       393k ± 0%    ~     (p=0.222 n=5+5)


Change-Id: I237ae5502db4560f78ce021dc62f6d289797afd6
Reviewed-on: https://go-review.googlesource.com/39197
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-04-01 00:08:31 +00:00
Josh Bleecher Snyder
bfeda6ccc7 cmd/compile: add comment to statictmp name generation
Follow-up to review comments on CL 39193.

Change-Id: I7649af9d70ad73e039061a7a66fea416a7476192
Reviewed-on: https://go-review.googlesource.com/39199
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-31 23:49:46 +00:00
Josh Bleecher Snyder
8e36575ebe cmd/compile: don't mutate shared nodes in orderinit
A few gc.Node ops may be shared across functions.
The compiler is (mostly) already careful to avoid mutating them.
However, from a concurrency perspective, replacing (say)
an empty list with an empty list still counts as a mutation.
One place this occurs is orderinit. Avoid it.

This requires fixing one spot where shared nodes were mutated.
It doesn't result in any functional or performance changes.

Passes toolstash-check.

Updates #15756

Change-Id: I63c93b31baeeac62d7574804acb6b7f2bc9d14a9
Reviewed-on: https://go-review.googlesource.com/39196
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-31 22:38:01 +00:00
Lynn Boger
a8b2e4a630 cmd/compile: improve LoweredMove performance on ppc64x
This change improves the performance for LoweredMove on ppc64le
and ppc64.

benchmark                   old ns/op     new ns/op     delta
BenchmarkCopyFat8-16        0.93          0.69          -25.81%
BenchmarkCopyFat12-16       2.61          1.85          -29.12%
BenchmarkCopyFat16-16       9.68          1.89          -80.48%
BenchmarkCopyFat24-16       4.48          1.85          -58.71%
BenchmarkCopyFat32-16       6.12          1.82          -70.26%
BenchmarkCopyFat64-16       21.2          2.70          -87.26%
BenchmarkCopyFat128-16      29.6          3.97          -86.59%
BenchmarkCopyFat256-16      52.6          13.4          -74.52%
BenchmarkCopyFat512-16      97.1          18.7          -80.74%
BenchmarkCopyFat1024-16     186           35.3          -81.02%

BenchmarkAssertE2TLarge-16      14.2          5.06          -64.37%

Fixes #19785

Change-Id: I7d5e0052712b75811c02c7d86c5112e5649ad782
Reviewed-on: https://go-review.googlesource.com/38950
Reviewed-by: Keith Randall <khr@golang.org>
2017-03-31 21:24:09 +00:00
Russ Cox
105cc2bd63 time: test and fix Time.Round, Duration.Round for d > 2⁶²
Round uses r+r < d to decide whether the remainder is
above or below half of d (to decide whether to round up or down).
This is wrong when r+r wraps negative, because it looks < d
but is really > d.

No one will ever care about rounding to a multiple of
d > 2⁶² (about 146 years), but might as well get it right.

Fixes #19807.

Change-Id: I1b55a742dc36e02a7465bc778bf5dd74fe71f7c0
Reviewed-on: https://go-review.googlesource.com/39151
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-31 20:39:58 +00:00
Josh Bleecher Snyder
8ab71304d4 cmd/compile: use newnamel in typenamesym
The node in typenamesym requires neither
a position nor a curfn.

Passes toolstash-check.

Updates #15756

Change-Id: I6d39a8961e5578fe5924aaceb29045b6de2699df
Reviewed-on: https://go-review.googlesource.com/39194
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-31 20:05:33 +00:00
Josh Bleecher Snyder
8caf21da47 cmd/compile: use newnamel in ssa.go
For concurrency safety.

Passes toolstash-check.

Updates #15756.

Change-Id: I1caca231a962781ff8f4f589b2e0454d2820ffb6
Reviewed-on: https://go-review.googlesource.com/39192
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-31 20:05:26 +00:00
Josh Bleecher Snyder
3d90378df5 cmd/compile: add newnamel, use in tempAt
newnamel is newname but with no dependency on lineno or Curfn.
This makes it suitable for use in a concurrent back end.
Use it now to make tempAt global-free.

The decision to push the assignment to n.Name.Curfn
to the caller of newnamel is based on mdempsky's
comments in #19683 that he'd like to do that
for callers of newname as well.

Passes toolstash-check. No compiler performance impact.

Updates #19683
Updates #15756

Change-Id: Idc461a1716916d268c9ff323129830d9a6e4a4d9
Reviewed-on: https://go-review.googlesource.com/39191
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-31 20:05:20 +00:00
Josh Bleecher Snyder
4927b9a9ff cmd/compile: remove makefuncdatasym_nsym global
This causes a minor reduction in allocations,
because the old funcdatasym names were
being interned unnecessarily.

Updates #15756

name       old alloc/op    new alloc/op    delta
Template      39.9MB ± 0%     39.9MB ± 0%    ~     (p=0.280 n=10+10)
Unicode       29.9MB ± 0%     29.8MB ± 0%  -0.26%  (p=0.000 n=10+10)
GoTypes        113MB ± 0%      113MB ± 0%  -0.12%  (p=0.000 n=10+10)
SSA            855MB ± 0%      855MB ± 0%  -0.03%  (p=0.001 n=10+10)
Flate         25.4MB ± 0%     25.3MB ± 0%  -0.30%  (p=0.000 n=10+10)
GoParser      31.9MB ± 0%     31.8MB ± 0%    ~     (p=0.065 n=10+9)
Reflect       78.4MB ± 0%     78.2MB ± 0%  -0.15%  (p=0.000 n=9+10)
Tar           26.7MB ± 0%     26.7MB ± 0%  -0.17%  (p=0.000 n=9+10)
XML           42.3MB ± 0%     42.4MB ± 0%  +0.07%  (p=0.011 n=10+10)

name       old allocs/op   new allocs/op   delta
Template        390k ± 0%       390k ± 0%    ~     (p=0.905 n=9+10)
Unicode         319k ± 1%       319k ± 1%    ~     (p=0.724 n=10+10)
GoTypes        1.14M ± 0%      1.14M ± 0%    ~     (p=0.393 n=10+10)
SSA            7.60M ± 0%      7.60M ± 0%    ~     (p=0.604 n=9+10)
Flate           235k ± 1%       234k ± 1%    ~     (p=0.105 n=10+10)
GoParser        317k ± 0%       316k ± 1%    ~     (p=0.280 n=10+10)
Reflect         979k ± 0%       979k ± 0%    ~     (p=0.315 n=10+10)
Tar             251k ± 0%       251k ± 1%    ~     (p=0.762 n=8+10)
XML             393k ± 0%       394k ± 1%    ~     (p=0.095 n=9+10)

name       old text-bytes  new text-bytes  delta
HelloSize       684k ± 0%       684k ± 0%    ~     (all equal)

name       old data-bytes  new data-bytes  delta
HelloSize       138k ± 0%       138k ± 0%    ~     (all equal)

name       old exe-bytes   new exe-bytes   delta
HelloSize      1.03M ± 0%      1.03M ± 0%    ~     (all equal)

Change-Id: Idba33da4e89c325984ac46e4852cf12e4a7fd1a9
Reviewed-on: https://go-review.googlesource.com/39032
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-03-31 19:53:26 +00:00
Josh Bleecher Snyder
2f072a427a cmd/compile: clean up methodsym
Convert yyerrors into Fatals.
Remove the goto.
Move variable declaration closer to use.
Unify printing strings a bit.
Convert an int param into a bool.

Passes toolstash-check. No compiler performance impact.

Change-Id: I9017681417b785cf8693d18b124ac4f1ff37f2b5
Reviewed-on: https://go-review.googlesource.com/39170
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-31 19:30:51 +00:00
Josh Bleecher Snyder
3237af2da8 cmd/compile: don't use lookupN for statictmps
The names never occur more than once,
so interning the results is counterproductive.

The impact is not very big, but neither is the fix.

name     old time/op     new time/op     delta
Unicode     90.2ms ± 3%     88.3ms ± 5%  -2.10%  (p=0.000 n=94+98)


Change-Id: I1e3a24433db4ae0c9a6e98166568941824ff0779
Reviewed-on: https://go-review.googlesource.com/39193
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-31 19:25:01 +00:00
Robert Griesemer
9e28ea0c08 cmd/compile: use std "DO NOT EDIT" comment for generated files
Also: Fix (testdata/gen/) copyGen.go, zeroGen.go, and arithConstGen.go
to actually match (testdata/) copy.go, zero.go, and arithConst.go, all
of which were manually edited in https://go-review.googlesource.com/20823
and https://go-review.googlesource.com/22748 despite the 'do not edit'
(or perhaps because it was missing in the case of arithConst.go).

For #13560.

Change-Id: I366e1b521e51885e0d318ae848760e5e14ccd488
Reviewed-on: https://go-review.googlesource.com/39172
Reviewed-by: Rob Pike <r@golang.org>
2017-03-31 18:50:40 +00:00