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

8451 Commits

Author SHA1 Message Date
Dave Cheney
bce9747ed0 cmd: remove unused code
Generated with honnef.co/go/unused

There is a large amount of unused code in cmd/internal/obj/s390x but
that can wait til the s390x port is merged.

There is some unused code in
cmd/internal/unvendor/golang.org/x/arch/arm/armasm but that should be
addressed upstream and a new revision imported.

Change-Id: I252c0f9ea8c5bb1a0b530a374ef13a0a20ea56aa
Reviewed-on: https://go-review.googlesource.com/21782
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dave Cheney <dave@cheney.net>
2016-04-09 06:55:21 +00:00
Dave Cheney
93368be61e cmd/internal/bio: embed bufio.{Reader,Writer} in bio.{Reader,Writer}
Change-Id: Ie95b0b0d4f724f4769cf2d4f8063cb5019fa9bc9
Reviewed-on: https://go-review.googlesource.com/21781
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-09 06:12:13 +00:00
Dave Cheney
ca397bb68e cmd: remove bio.BufReader and bio.BufWriter
bio.BufReader was never used.

bio.BufWriter was used to wrap an existing io.Writer, but the
bio.Writer returned would not be seekable, so replace all occurences
with bufio.Reader instead.

Change-Id: I9c6779e35c63178aa4e104c17bb5bb8b52de0359
Reviewed-on: https://go-review.googlesource.com/21722
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-09 03:53:38 +00:00
Dave Cheney
6fee4aa5c7 cmd/link/internal: make ld.Bso a *bio.Writer
This is a pre requesite of CL 21722 and removes a lot of unidiomatic
boilerplate in the linker.

Change-Id: If7491b88212b2be7b0c8c588e9c196839131f8ad
Reviewed-on: https://go-review.googlesource.com/21780
Run-TryBot: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-09 03:22:13 +00:00
Michael Hudson-Doyle
092ef8a2ca cmd/cgo: fix cgo with gccgo
Change-Id: I1780899255e22c16d7f8e9947609a1c284d7c42e
Reviewed-on: https://go-review.googlesource.com/21690
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-08 23:27:33 +00:00
David Chase
c3b3e7b4ef cmd/compile: insert instrumentation more carefully in racewalk
Be more careful about inserting instrumentation in racewalk.
If the node being instrumented is an OAS, and it has a non-
empty Ninit, then append instrumentation to the Ninit list
rather than letting it be inserted before the OAS (and the
compilation of its init list).  This deals with the case that
the Ninit list defines a variable used in the RHS of the OAS.

Fixes #15091.

Change-Id: Iac91696d9104d07f0bf1bd3499bbf56b2e1ef073
Reviewed-on: https://go-review.googlesource.com/21771
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: David Chase <drchase@google.com>
2016-04-08 21:06:39 +00:00
Dmitry Vyukov
0fb7b4cccd runtime: emit file:line info into traces
This makes traces self-contained and simplifies trace workflow
in modern cloud environments where it is simpler to reach
a service via HTTP than to obtain the binary.

Change-Id: I6ff3ca694dc698270f1e29da37d5efaf4e843a0d
Reviewed-on: https://go-review.googlesource.com/21732
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2016-04-08 20:52:30 +00:00
Michael Munday
9ada88aec2 cmd/cgo: increase s390x int type size to 8 bytes
The size of the int type in Go on s390x is 8 bytes, not 4.

Change-Id: I1a71ce8c9925f3499abb61c1aa4f6fa2d2ec0d7e
Reviewed-on: https://go-review.googlesource.com/21760
Reviewed-by: Bill O'Farrell <billotosyr@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-08 20:31:58 +00:00
Michael Munday
78715cebcf cmd/link: add s390x to link tool main function
Change-Id: I83bc2b4a00216b069f133113e4ae9ad76c98a708
Reviewed-on: https://go-review.googlesource.com/21741
Run-TryBot: Michael Munday <munday@ca.ibm.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-08 16:00:41 +00:00
Dave Cheney
8f2edf1199 cmd: replace bio.Buf with bio.Reader and bio.Writer
Replace the bidirectional bio.Buf type with a pair of unidirectional
buffered seekable Reader and Writers.

Change-Id: I86664a06f93c94595dc67c2cbd21356feb6680ef
Reviewed-on: https://go-review.googlesource.com/21720
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-08 14:37:37 +00:00
Michael Munday
d22357ce9d cmd/compile: cleanup -dynlink/-shared support check
Moves the list of architectures that support shared libraries into
a function. Also adds s390x to that list.

Change-Id: I99c8a9f6cd4816ce3d53abaabaf8d002e25e6b28
Reviewed-on: https://go-review.googlesource.com/21661
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Run-TryBot: Michael Munday <munday@ca.ibm.com>
2016-04-08 14:34:31 +00:00
Dave Cheney
49e07f2b7e cmd/compile/internal/gc: unexport Export
Export does not need to be exported.

Change-Id: I252f0c024732f1d056817cab13e8e3c589b54d13
Reviewed-on: https://go-review.googlesource.com/21721
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-08 14:01:21 +00:00
Andrew Gerrand
4dae828f77 cmd/go: fix failing tests since vet was moved from x/tools
Change-Id: I3276a118ced78f3efd8f1bc5fb8b8fa2fde52496
Reviewed-on: https://go-review.googlesource.com/21704
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-08 05:40:53 +00:00
Keith Randall
68ac1f7746 cmd/compile: Fix constant-folding of unsigned shifts
Make sure the results of unsigned constant-folded
shifts are sign-extended into the AuxInt field.

Fixes #15175

Change-Id: I3490d1bc3d9b2e1578ed30964645508577894f58
Reviewed-on: https://go-review.googlesource.com/21586
Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-07 21:39:32 +00:00
Cheng-Lung Sung
dfded57819 cmd/go: revise importPath when ImportPath is 'command-line-arguments'
Fixes #14613

Change-Id: I40d9696db3879549e78373ef17f6c92bd4b3470b
Reviewed-on: https://go-review.googlesource.com/21596
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-07 21:34:12 +00:00
David Crawshaw
9658b7ef83 cmd/link: hide go.dwarf symbols
Fixes #15179

Change-Id: I0f70b7ae1682eafaece7f22d8e76f0aa806f3ec9
Reviewed-on: https://go-review.googlesource.com/21589
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-07 18:54:45 +00:00
David Crawshaw
e6181eb9e1 cmd/link: disable DWARF when not generating symtab
Fixes #15166

Change-Id: I30284e3c0fb2c80b26a2572e2fb249b8018e85f9
Reviewed-on: https://go-review.googlesource.com/21587
Run-TryBot: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-07 18:27:47 +00:00
Alexandru Moșoi
8448d3aace cmd/compile: fold CMPconst and SHR
Fold the comparison when the SHR result is small.

Useful for:
- murmur mix like hashing where higher bits are desirable, i.e. hash = uint32(i * C) >> 18
- integer log2 via DeBruijn sequence: http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogDeBruijn

Change-Id: If70ae18cb86f4cc83ab6213f88ced03cc4986156
Reviewed-on: https://go-review.googlesource.com/21514
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-04-07 13:28:13 +00:00
Matthew Dempsky
438ce713a1 cmd/link/internal/amd64: remove empty source file
Change-Id: I2da012ed996c669db513a462f014c6f3ffa396ee
Reviewed-on: https://go-review.googlesource.com/21646
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-04-07 06:45:47 +00:00
Matthew Dempsky
4b7e36cdfe cmd: extract obj's Biobuf code into new bio package
API could still be made more Go-ey.

Updates #15165.

Change-Id: I514ffceffa43c293ae5d7e5f1e9193fda0098865
Reviewed-on: https://go-review.googlesource.com/21644
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-07 06:09:54 +00:00
Matthew Dempsky
b17b95301a cmd/internal/sys: change ArchFamily constants to iotas
RIP architecture characters.

Change-Id: I36f53afdc311b14b9459ff3821bd6df54a057ded
Reviewed-on: https://go-review.googlesource.com/21628
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-04-07 04:17:26 +00:00
Matthew Dempsky
22ef687da8 cmd/link: remove dependency on sys.ArchFamily values
Change-Id: I858054b72847f4f27a1ebbdaff82820a28c03743
Reviewed-on: https://go-review.googlesource.com/21627
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-07 04:17:10 +00:00
Matthew Dempsky
d481ffc1af cmd/compile, cmd/link: eliminate uses of ArchFamily in error messages
Two of these error messages are already dead code: cmd/compile.main
and cmd/link.main already switch on $GOARCH, ensuring it must be a
prefix of the sys.Arch.Family.

The error message about uncompiled Go source files can be just be
simplified: anyone who's manually constructing Go object file archives
probably knows what tool to use to compile Go source files.

Change-Id: Ia4a67c0a1d1158379c127c91e909226d3367f3c2
Reviewed-on: https://go-review.googlesource.com/21626
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-07 02:46:53 +00:00
Matthew Dempsky
c6e11fe037 cmd: add new common architecture representation
Information about CPU architectures (e.g., name, family, byte
ordering, pointer and register size) is currently redundantly
scattered around the source tree. Instead consolidate the basic
information into a single new package cmd/internal/sys.

Also, introduce new sys.I386, sys.AMD64, etc. names for the constants
'8', '6', etc. and replace most uses of the latter. The notable
exceptions are a couple of error messages that still refer to the old
char-based toolchain names and function reltype in cmd/link.

Passes toolstash/buildall.

Change-Id: I8a6f0cbd49577ec1672a98addebc45f767e36461
Reviewed-on: https://go-review.googlesource.com/21623
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-07 01:23:25 +00:00
Ryan Brown
a037c73ccf cmd/link: generate DWARF info using symbols
This updates dwarf.go to generate debug information as symbols
instead of directly writing to the output file. This should make
it easier to move generation of some of the debug info into the compiler.

Change-Id: Id2358988bfb689865ab4d68f82716f0676336df4
Reviewed-on: https://go-review.googlesource.com/20679
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-06 23:50:14 +00:00
Robert Griesemer
81aacb80d5 cmd/compile, go/importer: minor cleanups
Change-Id: I4ffb79d8cb08b0b44f59757fb7f0ec3ed1e4479f
Reviewed-on: https://go-review.googlesource.com/21624
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-04-06 22:37:47 +00:00
Josh Bleecher Snyder
007b12977a cmd/compile: move Type.Maplineno to separate data structure
Relatively few types are ever used as map keys,
so tracking this separately is a net win.

Passes toolstash -cmp.

name       old alloc/op     new alloc/op     delta
Template       55.9MB ± 0%      55.5MB ± 0%  -0.71%        (p=0.000 n=10+10)
Unicode        37.8MB ± 0%      37.7MB ± 0%  -0.27%        (p=0.000 n=10+10)
GoTypes         180MB ± 0%       179MB ± 0%  -0.52%         (p=0.000 n=7+10)
Compiler        806MB ± 0%       803MB ± 0%  -0.41%        (p=0.000 n=10+10)

CPU and number of allocs are unchanged.

Change-Id: I6d60d74a4866995a231dfed3dd5792d75d904292
Reviewed-on: https://go-review.googlesource.com/21622
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-04-06 22:03:47 +00:00
Alexandru Moșoi
04945edd40 cmd/compile: replaces ANDQ with MOV?ZX
Where possible replace ANDQ with MOV?ZX.
Takes care that we don't regress wrt bounds checking,
for example [1000]int{}[i&255].

According to "Intel 64 and IA-32 Architectures Optimization Reference
Manual" Section: "3.5.1.13 Zero-Latency MOV Instructions"
MOV?ZX instructions have zero latency on newer processors.

Updates #15105

Change-Id: I63539fdbc5812d5563aa1ebc49eca035bd307997
Reviewed-on: https://go-review.googlesource.com/21508
Reviewed-by: Айнар Гарипов <gugl.zadolbal@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
2016-04-06 20:38:51 +00:00
Josh Bleecher Snyder
f38f43d029 cmd/compile: shrink gc.Type in half
Many of Type's fields are etype-specific.
This CL organizes them into their own auxiliary types,
duplicating a few fields as necessary,
and adds an Extra field to hold them.
It also sorts the remaining fields for better struct packing.
It also improves documentation for most fields.

This reduces the size of Type at the cost of some extra allocations.
There's no CPU impact; memory impact below.
It also makes the natural structure of Type clearer.

Passes toolstash -cmp on all architectures.

Ideas for future work in this vein:

(1) Width and Align probably only need to be
stored for Struct and Array types.
The refactoring to accomplish this would hopefully
also eliminate TFUNCARGS and TCHANARGS entirely.

(2) Maplineno is sparsely used and could probably better be
stored in a separate map[*Type]int32, with mapqueue updated
to store both a Node and a line number.

(3) The Printed field may be removable once the old (non-binary)
importer/exported has been removed.

(4) StructType's fields field could be changed from *[]*Field to []*Field,
which would remove a common allocation.

(5) I believe that Type.Nod can be moved to ForwardType. Separate CL.

name       old alloc/op     new alloc/op     delta
Template       57.9MB ± 0%      55.9MB ± 0%  -3.43%        (p=0.000 n=50+50)
Unicode        38.3MB ± 0%      37.8MB ± 0%  -1.39%        (p=0.000 n=50+50)
GoTypes         185MB ± 0%       180MB ± 0%  -2.56%        (p=0.000 n=50+50)
Compiler        824MB ± 0%       806MB ± 0%  -2.19%        (p=0.000 n=50+50)

name       old allocs/op    new allocs/op    delta
Template         486k ± 0%        497k ± 0%  +2.25%        (p=0.000 n=50+50)
Unicode          377k ± 0%        379k ± 0%  +0.55%        (p=0.000 n=50+50)
GoTypes         1.39M ± 0%       1.42M ± 0%  +1.63%        (p=0.000 n=50+50)
Compiler        5.52M ± 0%       5.57M ± 0%  +0.84%        (p=0.000 n=47+50)

Change-Id: I828488eeb74902b013d5ae4cf844de0b6c0dfc87
Reviewed-on: https://go-review.googlesource.com/21611
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-06 19:10:10 +00:00
Robert Griesemer
ff7ba773f4 cmd/gofmt: make gofmt -s simplify slices in presence of dot-imports
A dot-import cannot possibly introduce a `len` function since that
function would not be exported (it's lowercase). Furthermore, the
existing code already (incorrectly) assumed that there was no other
`len` function in another file of the package. Since this has been
an ok assumption for years, let's leave it, but remove the dot-import
restriction.

Fixes #15153.

Change-Id: I18fbb27acc5a5668833b4b4aead0cca540862b52
Reviewed-on: https://go-review.googlesource.com/21613
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-06 18:19:33 +00:00
Aliaksandr Valialkin
d7ddee78dd icmd/vet: improved checking for variadic Println-like functions
- Automatically determine the first argument to check.
- Skip checking matching non-variadic functions.
- Skip checking matching functions accepting non-interface{}
  variadic arguments.
- Removed fragile 'magic' code for special cases such as math.Log
  and error interface.

Fixes #15067
Fixes #15099

Change-Id: Ib313557f18b12b36daa493f4b02c598b9503b55b
Reviewed-on: https://go-review.googlesource.com/21513
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-04-06 18:11:36 +00:00
Matthew Dempsky
ec3c5b9d17 cmd/link: eliminate a bunch of open coded elf64/rela switches
We already have variables to track whether the target platform is
64-bit vs 32-bit or RELA vs REL, so no point in repeating the list of
obscure architecture characters everywhere.

Passes toolstash/buildall.

Change-Id: I6a07f74188ac592ef229a7c65848a9ba93013cdb
Reviewed-on: https://go-review.googlesource.com/21569
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-06 17:25:19 +00:00
Konstantin Shaposhnikov
0d37538196 cmd/vet: do not treat declaration as asignment in atomic check
Fixes #15118

Change-Id: Iad56ed412535c8ac0a01c4bd7769fd3d37688ac9
Reviewed-on: https://go-review.googlesource.com/21526
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-04-06 16:38:24 +00:00
Keith Randall
309144b7f1 cmd/compile: fix x=x assignments
No point in doing anything for x=x assignments.
In addition, skipping these assignments prevents generating:
    VARDEF x
    COPY x -> x
which is bad because x is incorrectly considered
dead before the vardef.

Fixes #14904

Change-Id: I6817055ec20bcc34a9648617e0439505ee355f82
Reviewed-on: https://go-review.googlesource.com/21470
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-04-06 15:04:32 +00:00
Josh Bleecher Snyder
fda831ed3f cmd/compile: encapsulate reads of gc.Type.Funarg
Changes generated with eg and then manually
checked and in some cases simplified.

Passes toolstash -cmp.

Change-Id: I2119f37f003368ce1884d2863b406d6ffbfe38c7
Reviewed-on: https://go-review.googlesource.com/21563
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-04-06 02:49:18 +00:00
Matthew Dempsky
5ba797bd18 cmd/compile: move a lot of declarations outside of go.go
go.go is currently a grab bag of various unrelated type and variable
declarations. Move a bunch of them into other more relevant source
files.

There are still more that can be moved, but these were the low hanging
fruit with obvious homes.

No code/comment changes. Just shuffling stuff around.

Change-Id: I43dbe1a5b8b707709c1a3a034c693d38b8465063
Reviewed-on: https://go-review.googlesource.com/21561
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-05 21:38:15 +00:00
Matthew Dempsky
cca4ddb497 cmd/compile: add comments explaining how declarations/scopes work
Change-Id: I301760b015eb69ff12eee53473fdbf5e9f168413
Reviewed-on: https://go-review.googlesource.com/21542
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-04-05 21:04:11 +00:00
Josh Bleecher Snyder
5e1b7bdecf cmd/compile: pull ssa OAPPEND expression handing into its own function
Pure code movement.

Change-Id: Ia07ee0b0041c931b08adf090f262a6f74a6fdb01
Reviewed-on: https://go-review.googlesource.com/21546
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-05 20:31:38 +00:00
Josh Bleecher Snyder
7735dfb67c cmd/compile: give TLS relocations a name when dumping assembly
Before:

	...
	0x00d0 ff ff ff e8 00 00 00 00 e9 23 ff ff ff cc cc cc  .........#......
	rel 5+4 t=14 +0
	rel 82+4 t=13 runtime.writeBarrier+0
	...

After:

	...
	0x00d0 ff ff ff e8 00 00 00 00 e9 23 ff ff ff cc cc cc  .........#......
	rel 5+4 t=14 TLS+0
	rel 82+4 t=13 runtime.writeBarrier+0
	...

Change-Id: Ibdaf694581b5fd5fb87fa8ce6a792f3eb4493622
Reviewed-on: https://go-review.googlesource.com/21545
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-05 20:21:25 +00:00
David Chase
d8c815d8b5 cmd/compile: note escape of parts of closured-capture vars
Missed a case for closure calls (OCALLFUNC && indirect) in
esc.go:esccall.

Cleanup to runtime code for windows to more thoroughly hide
a technical escape.  Also made code pickier about failing
to late non-optional kernel32.dll.

Fixes #14409.

Change-Id: Ie75486a2c8626c4583224e02e4872c2875f7bca5
Reviewed-on: https://go-review.googlesource.com/20102
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-05 18:10:09 +00:00
Ilya Tocar
036d09d5bf cmd/compile/internal/amd64: Use 32-bit operands for byte operations
We already generate ADDL for byte operations, reflect this in code.
This also allows inc/dec for +-1 operation, which are 1-byte shorter,
and enables lea for 3-operand addition/subtraction.

Change-Id: Ibfdfee50667ca4cd3c28f72e3dece0c6d114d3ae
Reviewed-on: https://go-review.googlesource.com/21251
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-05 15:15:19 +00:00
Alexandru Moșoi
1747788c56 cmd/compile: add a pass to print bound checks
Since BCE happens over several passes (opt, loopbce, prove)
it's easy to regress especially with rewriting.

The pass is only activated with special debug flag.

Change-Id: I46205982e7a2751156db8e875d69af6138068f59
Reviewed-on: https://go-review.googlesource.com/21510
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-04-05 12:46:59 +00:00
Dave Cheney
7208a2cd78 cmd/compile/internal/ssa: hide gen packge from ./make.bash
Fixes #15122

Change-Id: Ie2c802d78aea731e25bf4b193b3c2e4c884e0573
Reviewed-on: https://go-review.googlesource.com/21524
Run-TryBot: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-05 05:53:15 +00:00
Alex Brainman
bbbd572c10 cmd/go: leave directory before removing it in TestSharedLibName
Fixes #15124

Change-Id: I55fe4c2957370f3fb417c3df54f99fb085a5dada
Reviewed-on: https://go-review.googlesource.com/21522
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-05 04:45:47 +00:00
Matthew Dempsky
0c71e293b5 cmd/compile: minor cleanup to import loading
Briefly document what the importfoo functions do.

Get rid of importsym's unused result parameter.

Get rid of the redundant calls to importsym(s, OTYPE)
after we've already called pkgtype(s).

Passes toolstash -cmp.

Change-Id: I4c057358144044f5356e4dec68907ec85f1fe806
Reviewed-on: https://go-review.googlesource.com/21498
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-04 23:47:25 +00:00
Shahar Kohanim
bc94282306 cmd/link: grow rdBuf lazily
Counting the final buffer size usually doesn't result in the buffer growing,
so assume that it doesn't need to grow and only grow if necessary.

name       old secs    new secs    delta
LinkCmdGo   0.49 ± 4%   0.48 ± 3%  -1.31%   (p=0.000 n=95+95)

name       old MaxRSS  new MaxRSS  delta
LinkCmdGo   122k ± 4%   121k ± 5%    ~     (p=0.065 n=96+100)

Change-Id: I85e7f5688a61ef5ef2b1b7afe56507e71c5bd5b1
Reviewed-on: https://go-review.googlesource.com/21509
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Shahar Kohanim <skohanim@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-04-04 21:22:44 +00:00
Robert Griesemer
a9ea36afbb cmd/compile: export inlined function bodies
Completed implementation for exporting inlined functions
using the new binary export format. This change passes
(export GO_GCFLAGS=-newexport; make all.bash) but for
gc's builtin_test.go which we need to adjust before enabling
this code by default.

For a high-level description of the export format see the
comment at the top of bexport.go.

Major changes:

1) The export format for the platform independent export data
   changed: When we export inlined function bodies, additional
   objects (other functions, types, etc.) that are referred to
   by the function bodies will need to be exported. While this
   doesn't affect the platform-independent portion directly, it
   adds more objects to the exportlist while we are exporting.
   Instead of trying to sort the objects into groups, just export
   objects as they appear in the export list. This is slightly
   less compact (one extra byte per object), but it is simpler
   and much more flexible.

2) The export format contains now three sections: 1) The plat-
   form independent objects, 2) the objects pulled in for export
   via inlined function bodies, and 3) the inlined function bodies.

3) Completed the exporting and importing code for inlined function
   bodies. The format is completely compiler-specific and easily
   changeable w/o affecting other tools. There is still quite a
   bit of room for denser encoding. This can happen at any time
   in the future.

This change contains also the adjustments for go/internal/gcimporter,
necessary because of the export format change 1) mentioned above.

For #13241.

Change-Id: I86bca0bd984b12ccf13d0d30892e6e25f6d04ed5
Reviewed-on: https://go-review.googlesource.com/21172
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-04 19:22:24 +00:00
Matthew Dempsky
38e11d05b9 cmd/compile: use *byte for pointer to string memory
Change-Id: I14cff013ef4920d33b5ead0c75d51681bb4f635a
Reviewed-on: https://go-review.googlesource.com/21337
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-04 18:19:51 +00:00
Alexandru Moșoi
060501dc0e cmd/compile: constant fold modulo
Fixes #15079

Change-Id: Ib4dd9eab322da39234008e040100e75cb58761b3
Reviewed-on: https://go-review.googlesource.com/21501
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-04 16:58:17 +00:00
Alexandru Moșoi
68325b56e7 cmd/compile: fold IsInBounds of modulo.
In b we only need the division by 0 check.

func b(i uint, v []byte) byte {
    return v[i%uint(len(v))]
}

Updates #15079.

Change-Id: Ic7491e677dd57cd6ba577efbce576dbb6e023cbd
Reviewed-on: https://go-review.googlesource.com/21502
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ahmed Waheed <oneofone@gmail.com>
2016-04-04 16:06:34 +00:00
David Crawshaw
2d5688952d cmd/link: keep types together when dynamic linking
To refer to types and names by offsets, we want to keep the symbols in
the same sections. Do this by making all types .relro for now.

Once name offsets are further along, name data can move out of relro.

Change-Id: I1cbd2e914bd180cdf25c4aeb13d9c1c734febe69
Reviewed-on: https://go-review.googlesource.com/21394
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-04 15:30:40 +00:00
Caio Marcelo de Oliveira Filho
f229e46783 cmd/compile: better error when assigning to struct field in map
Identify this assignment case and instead of the more general error

    prog.go:6: cannot assign to students["sally"].age

produce

    prog.go:6: cannot directly assign to struct field students["sally"].age in map

that explains why the assignment is not possible.

Fixes #13779.

Change-Id: I90c10b445f907834fc1735aa66e44a0f447aa74f
Reviewed-on: https://go-review.googlesource.com/21462
Reviewed-by: David Chase <drchase@google.com>
2016-04-04 14:07:47 +00:00
Christopher Nelson
ed8f0e5c33 cmd/go: fix -buildmode=c-archive should work on windows
Add supporting code for runtime initialization, including both
32- and 64-bit x86 architectures.

Add .ctors section on Windows to PE .o files, and INITENTRY to .ctors
section to plug in to the GCC C/C++ startup initialization mechanism.
This allows the Go runtime to initialize itself. Add .text section
symbol for .ctor relocations. Note: This is unlikely to be useful for
MSVC-based toolchains.

Fixes #13494

Change-Id: I4286a96f70e5f5228acae88eef46e2bed95813f3
Reviewed-on: https://go-review.googlesource.com/18057
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2016-04-04 03:38:25 +00:00
Brad Fitzpatrick
386c0e6598 cmd/compile: give ChanDir a type
Change-Id: I03621db79637b04982e1f0e7b4268c4ed2db6d22
Reviewed-on: https://go-review.googlesource.com/21484
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-03 23:35:40 +00:00
Brad Fitzpatrick
73edd7b208 cmd/link: simplify readSymName, taking advantage of bufio.Reader
Now that cmd/link uses bufio.Reader, take advantage of it.
I find this new version easier to reason about.

Reduces allocations by 1.1% when linking a basic HTTP server.

Numbers are stable with each round measuring using:
rm prof.mem; go tool link -o foo  -memprofile=prof.mem -memprofilerate=1 foo.a

Before:

65.36MB of 74.53MB total (87.70%)
Dropped 157 nodes (cum <= 0.37MB)
Showing top 10 nodes out of 39 (cum >= 1.47MB)
      flat  flat%   sum%        cum   cum%
   21.48MB 28.81% 28.81%    21.48MB 28.81%  cmd/link/internal/ld.Linklookup
   16.04MB 21.52% 50.33%    16.04MB 21.52%  cmd/link/internal/ld.(*objReader).readSlices
    4.61MB  6.19% 56.52%     4.61MB  6.19%  cmd/link/internal/ld.(*objReader).readSymName
    4.51MB  6.05% 62.57%     6.32MB  8.48%  cmd/link/internal/ld.writelines
    4.50MB  6.03% 68.60%     4.50MB  6.03%  cmd/link/internal/ld.Symgrow
    4.02MB  5.39% 73.99%     4.02MB  5.39%  cmd/link/internal/ld.linknew
    3.98MB  5.34% 79.33%     3.98MB  5.34%  cmd/link/internal/ld.setaddrplus
    2.96MB  3.97% 83.30%    28.78MB 38.62%  cmd/link/internal/ld.(*objReader).readRef
    1.81MB  2.43% 85.73%     1.81MB  2.43%  cmd/link/internal/ld.newcfaoffsetattr
    1.47MB  1.97% 87.70%     1.47MB  1.97%  cmd/link/internal/ld.(*objReader).readSym

After:

64.66MB of 73.87MB total (87.53%)
Dropped 156 nodes (cum <= 0.37MB)
Showing top 10 nodes out of 40 (cum >= 1.47MB)
      flat  flat%   sum%        cum   cum%
   21.48MB 29.08% 29.08%    21.48MB 29.08%  cmd/link/internal/ld.Linklookup
   16.04MB 21.71% 50.79%    16.04MB 21.71%  cmd/link/internal/ld.(*objReader).readSlices
    4.51MB  6.10% 56.90%     6.32MB  8.56%  cmd/link/internal/ld.writelines
    4.50MB  6.09% 62.99%     4.50MB  6.09%  cmd/link/internal/ld.Symgrow
    4.02MB  5.44% 68.42%     4.02MB  5.44%  cmd/link/internal/ld.linknew
    3.98MB  5.38% 73.81%     3.98MB  5.38%  cmd/link/internal/ld.setaddrplus
    3.90MB  5.28% 79.09%     3.90MB  5.28%  cmd/link/internal/ld.(*objReader).readSymName
    2.96MB  4.01% 83.09%    28.08MB 38.01%  cmd/link/internal/ld.(*objReader).readRef
    1.81MB  2.45% 85.55%     1.81MB  2.45%  cmd/link/internal/ld.newcfaoffsetattr
    1.47MB  1.99% 87.53%     1.47MB  1.99%  cmd/link/internal/ld.(*objReader).readSym

Also tested locally with asserts that that the calculated length is
always correct and thus the adjName buf never reallocates.

Change-Id: I19e3e8bfa6a12bcd8b5216f6232f42c122e4f80e
Reviewed-on: https://go-review.googlesource.com/21481
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-03 23:30:43 +00:00
Michael Hudson-Doyle
1934a77f5a cmd/link: define a variable for the target platform's elf relocation type
Rather than having half a dozen switch statements. Also remove some c2go dregs.

Change-Id: I19af5b64f73369126020e15421c34cad5bbcfbf8
Reviewed-on: https://go-review.googlesource.com/21442
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-04-03 23:20:04 +00:00
Shahar Kohanim
fe5be5aced cmd/link: more idiomatic object reader
name       old secs    new secs    delta
LinkCmdGo   0.52 ± 3%   0.52 ± 7%    ~     (p=0.325 n=93+100)

name       old MaxRSS  new MaxRSS  delta
LinkCmdGo   120k ± 1%   118k ± 4%  -1.10%   (p=0.000 n=87+96)

Change-Id: I967660b8dc6036d28eeea1b6b30f400fadd57b05
Reviewed-on: https://go-review.googlesource.com/21372
Run-TryBot: Shahar Kohanim <skohanim@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-03 17:16:12 +00:00
Eric Engestrom
7a8caf7d43 all: fix spelling mistakes
Signed-off-by: Eric Engestrom <eric@engestrom.ch>

Change-Id: I91873aaebf79bdf1c00d38aacc1a1fb8d79656a7
Reviewed-on: https://go-review.googlesource.com/21433
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-03 17:03:15 +00:00
Michael Munday
29a6149e67 cmd/link/internal/s390x: add s390x support
Supports basic internal linking, external linking and shared library
linking.

Change-Id: Ic9693dd94df561b0f9df9880009b1e8ab9d59b92
Reviewed-on: https://go-review.googlesource.com/20879
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-04-03 07:17:59 +00:00
Michael Munday
163ff700b8 cmd/link/internal/ld: add s390x support
Introduces the new relocation variant RV_390_DBL which indicates
that the relocation value should be shifted right by 1 (to make
it 2-byte aligned).

Change-Id: I03fa96b4759ee19330c5298c3720746622fb1a03
Reviewed-on: https://go-review.googlesource.com/20878
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-03 05:31:57 +00:00
Josh Bleecher Snyder
29267c2131 cmd/compile: add Type.ChanDir
Generated with eg.

Passes toolstash -cmp.

Change-Id: I3af35191e73a558080f777a4eed93bcec7dfe1f5
Reviewed-on: https://go-review.googlesource.com/21469
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-03 01:50:04 +00:00
Alexandru Moșoi
27ebc84716 cmd/compile: handle non-negatives in prove
Handle this case:
if 0 <= i && i < len(a) {
        use a[i]
}

Shaves about 5k from pkg/tools/linux_amd64/*.

Change-Id: I6675ff49aa306b0d241b074c5738e448204cd981
Reviewed-on: https://go-review.googlesource.com/21431
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-02 20:34:38 +00:00
Todd Neal
ac8d97b679 cmd/compile: fix inlining of switch issue
The issue was seen when inlining an exported function that contained
a fallthrough statement.

Fixes #15071

Change-Id: I1e8215ad49d57673dba7e8f8bd2ed8ad290dc452
Reviewed-on: https://go-review.googlesource.com/21452
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-04-02 12:38:00 +00:00
Matthew Dempsky
75a22d0d10 cmd/compile: eliminate dead code in walkappend
The IsStruct case is meant to handle cases like append(f()) where f's
result parameters are something like ([]int, int, int). However, at
this point in the compiler we've already rewritten append(f()) into
"tmp1, tmp2, tmp3 := f(); append(tmp1, tmp2, tmp3)".

As further evidence, the t.Elem() is not a valid method call for a
struct type anyway, which would trigger the Fatalf call in Type.Elem
if this code was ever hit.

Change-Id: Ia066f93df66ee3fadc9a9a0f687be7b5263af163
Reviewed-on: https://go-review.googlesource.com/21427
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-02 00:06:30 +00:00
Brad Fitzpatrick
683448a304 runtime, syscall: only search for Windows DLLs in the System32 directory
Make sure that for any DLL that Go uses itself, we only look for the
DLL in the Windows System32 directory, guarding against DLL preloading
attacks.

(Unless the Windows version is ancient and LoadLibraryEx is
unavailable, in which case the user probably has bigger security
problems anyway.)

This does not change the behavior of syscall.LoadLibrary or NewLazyDLL
if the DLL name is something unused by Go itself.

This change also intentionally does not add any new API surface. Instead,
x/sys is updated with a LoadLibraryEx function and LazyDLL.Flags in:
    https://golang.org/cl/21388

Updates #14959

Change-Id: I8d29200559cc19edf8dcf41dbdd39a389cd6aeb9
Reviewed-on: https://go-review.googlesource.com/21140
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-01 22:55:36 +00:00
Josh Bleecher Snyder
5cab01698a cmd/compile: rename Node.Int to Node.Int64
gorename -from '"cmd/compile/internal/gc".Node.Int' -to 'Int64'

Change-Id: I2fe3bf9a26ae6b0600d990d0c981e4b8b53020a4
Reviewed-on: https://go-review.googlesource.com/21426
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-01 22:00:47 +00:00
Matthew Dempsky
00e5a68c3e cmd/compile: more Isfoo Type cleanups
Replace isideal(t) with t.IsUntyped().
Replace Istype(t, k) with t.IsKind(k).
Replace isnilinter(t) with t.IsEmptyInterface().

Also replace a lot of t.IsKind(TFOO) with t.IsFoo().

Replacements prepared mechanically with gofmt -w -r.

Passes toolstash -cmp.

Change-Id: Iba48058f3cc863e15af14277b5ff5e729e67e043
Reviewed-on: https://go-review.googlesource.com/21424
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2016-04-01 21:08:39 +00:00
Josh Bleecher Snyder
5dd129bcff cmd/compile: add Type.SetNumElem
This removes all access to Type.Bound
from outside type.go.

Update sinit to make a new type rather than
copy and mutate.

Update bimport to create a new slice type
instead of mutating TDDDFIELD.
These are rare, so the extra allocs are nominal.

I’m not happy about having a setter,
but it appears the most practical route
forward at the moment, and it only has a few uses.

Passes toolstash -cmp.

Change-Id: I174f07c8f336afc656904bde4bdbde4f3ef0db96
Reviewed-on: https://go-review.googlesource.com/21423
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-01 20:04:17 +00:00
Josh Bleecher Snyder
e504055e78 cmd/compile: use Node.Int more
Generated by eg.

Passes toolstash -cmp.

Change-Id: I7516c211ca9aacf824f74894671dc62d31763b01
Reviewed-on: https://go-review.googlesource.com/21422
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-01 20:03:39 +00:00
Josh Bleecher Snyder
3a0783c504 cmd/compile: use NumElem instead of Type.Bound
This eliminates all direct reads of Type.Bound
outside type.go.

Change-Id: I0a9a72539f8f4c0de7f5e05e1821936bf7db5eb7
Reviewed-on: https://go-review.googlesource.com/21421
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-01 20:03:19 +00:00
Matthew Dempsky
077902d1a6 cmd/compile: cleanup algtype code
Add AlgKind enum type to represent AFOO values.

Add IsComparable, IsRegularMemory, IncomparableField helper methods to
codify common higher-level idioms.

Passes toolstash -cmp.

Change-Id: I54c544953997a8ccc72396b3058897edcbbea392
Reviewed-on: https://go-review.googlesource.com/21420
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-04-01 19:23:53 +00:00
Sebastien Binet
633ab7426a reflect: implement StructOf
This change exposes a facility to create new struct types from a slice of
reflect.StructFields.

- reflect: first stab at implementing StructOf
- reflect: tests for StructOf

StructOf creates new struct types in the form of structTypeWithMethods
to accomodate the GC (especially the uncommonType.methods slice field.)

Creating struct types with embedded interfaces with unexported methods
is not supported yet and will panic.
Creating struct types with non-ASCII field names or types is not yet
supported (see #15064.)

Binaries' sizes for linux_amd64:

old=tip (0104a31)

            old bytes     new bytes     delta
bin/go      9911336       9915456       +0.04%
reflect     781704        830048        +6.18%

Updates #5748.
Updates #15064.

Change-Id: I3b8fd4fadd6ce3b1b922e284f0ae72a3a8e3ce44
Reviewed-on: https://go-review.googlesource.com/9251
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
2016-04-01 14:56:21 +00:00
Shahar Kohanim
014f3e1e09 cmd/internal/obj: more idiomatic object writer
Change-Id: I41722ee605ea76a6b52e8a7e1e10f2293cef1a7a
Reviewed-on: https://go-review.googlesource.com/21371
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-04-01 09:39:50 +00:00
Alexandru Moșoi
b91cc53033 cmd/compile/internal/ssa: BCE for induction variables
There are 5293 loop in the main go repository.
A survey of the top most common for loops:

     18 for __k__ := 0; i < len(sa.Addr); i++ {
     19 for __k__ := 0; ; i++ {
     19 for __k__ := 0; i < 16; i++ {
     25 for __k__ := 0; i < length; i++ {
     30 for __k__ := 0; i < 8; i++ {
     49 for __k__ := 0; i < len(s); i++ {
     67 for __k__ := 0; i < n; i++ {
    376 for __k__ := range __slice__ {
    685 for __k__, __v__ := range __slice__ {
   2074 for __, __v__ := range __slice__ {

The algorithm to find induction variables handles all cases
with an upper limit. It currently doesn't find related induction
variables such as c * ind or c + ind.

842 out of 22954 bound checks are removed for src/make.bash.
1957 out of 42952 bounds checks are removed for src/all.bash.

Things to do in follow-up CLs:
* Find the associated pointer for `for _, v := range a {}`
* Drop the NilChecks on the pointer.
* Replace the implicit induction variable by a loop over the pointer

Generated garbage can be reduced if we share the sdom between passes.

% benchstat old.txt new.txt
name       old time/op     new time/op     delta
Template       337ms ± 3%      333ms ± 3%    ~             (p=0.258 n=9+9)
GoTypes        1.11s ± 2%      1.10s ± 2%    ~           (p=0.912 n=10+10)
Compiler       5.25s ± 1%      5.29s ± 2%    ~             (p=0.077 n=9+9)
MakeBash       33.5s ± 1%      34.1s ± 2%  +1.85%          (p=0.011 n=9+9)

name       old alloc/op    new alloc/op    delta
Template      63.6MB ± 0%     63.9MB ± 0%  +0.52%         (p=0.000 n=10+9)
GoTypes        218MB ± 0%      219MB ± 0%  +0.59%         (p=0.000 n=10+9)
Compiler       978MB ± 0%      985MB ± 0%  +0.69%        (p=0.000 n=10+10)

name       old allocs/op   new allocs/op   delta
Template        582k ± 0%       583k ± 0%  +0.10%        (p=0.000 n=10+10)
GoTypes        1.78M ± 0%      1.78M ± 0%  +0.12%        (p=0.000 n=10+10)
Compiler       7.68M ± 0%      7.69M ± 0%  +0.05%        (p=0.000 n=10+10)

name       old text-bytes  new text-bytes  delta
HelloSize       581k ± 0%       581k ± 0%  -0.08%        (p=0.000 n=10+10)
CmdGoSize      6.40M ± 0%      6.39M ± 0%  -0.08%        (p=0.000 n=10+10)

name       old data-bytes  new data-bytes  delta
HelloSize      3.66k ± 0%      3.66k ± 0%    ~     (all samples are equal)
CmdGoSize       134k ± 0%       134k ± 0%    ~     (all samples are equal)

name       old bss-bytes   new bss-bytes   delta
HelloSize       126k ± 0%       126k ± 0%    ~     (all samples are equal)
CmdGoSize       149k ± 0%       149k ± 0%    ~     (all samples are equal)

name       old exe-bytes   new exe-bytes   delta
HelloSize       947k ± 0%       946k ± 0%  -0.01%        (p=0.000 n=10+10)
CmdGoSize      9.92M ± 0%      9.91M ± 0%  -0.06%        (p=0.000 n=10+10)

Change-Id: Ie74bdff46fd602db41bb457333d3a762a0c3dc4d
Reviewed-on: https://go-review.googlesource.com/20517
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
2016-04-01 09:37:58 +00:00
David Chase
b64f549ba9 cmd/compile: ignore OXXX nodes in closure captured vars list
Added a debug flag "-d closure" to explain compilation of
closures (should this be done some other way? Should we
rewrite the "-m" flag to "-d escapes"?)  Used this to
discover that cause was an OXXX node in the captured vars
list, and in turn noticed that OXXX nodes are explicitly
ignored in all other processing of captured variables.

Couldn't figure out a reproducer, did verify that this OXXX
was not caused by an unnamed return value (which is one use
of these).  Verified lack of heap allocation by examining -S
output.

Assembly:
(runtime/mgc.go:1371) PCDATA $0, $2
(runtime/mgc.go:1371) CALL "".notewakeup(SB)
(runtime/mgc.go:1377) LEAQ "".gcBgMarkWorker.func1·f(SB), AX
(runtime/mgc.go:1404) MOVQ AX, (SP)
(runtime/mgc.go:1404) MOVQ "".autotmp_2242+88(SP), CX
(runtime/mgc.go:1404) MOVQ CX, 8(SP)
(runtime/mgc.go:1404) LEAQ go.string."GC worker (idle)"(SB), AX
(runtime/mgc.go:1404) MOVQ AX, 16(SP)
(runtime/mgc.go:1404) MOVQ $16, 24(SP)
(runtime/mgc.go:1404) MOVB $20, 32(SP)
(runtime/mgc.go:1404) MOVQ $0, 40(SP)
(runtime/mgc.go:1404) PCDATA $0, $2
(runtime/mgc.go:1404) CALL "".gopark(SB)

Added a check for compiling_runtime to ensure that this is
caught in the future.  Added a test to test the check.
Verified that 1.5.3 did NOT reject the test case when
compiled with -+ flag, so this is not a recently added bug.

Cause of bug is two-part -- there was no leaking closure
detection ever, and instead it relied on capture-of-variables
to trigger compiling_runtime test, but closures improved in
1.5.3 so that mere capture of a value did not also capture
the variable, which thus allowed closures to escape, as well
as this case where the escape was spurious.  In
fixedbugs/issue14999.go, compare messages for f and g;
1.5.3 would reject g, but not f.  1.4 rejects both because
1.4 heap-allocates parameter x for both.

Fixes #14999.

Change-Id: I40bcdd27056810628e96763a44f2acddd503aee1
Reviewed-on: https://go-review.googlesource.com/21322
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-04-01 02:08:56 +00:00
Dominik Honnef
1cb3044c9f all: use bytes.Equal, bytes.Contains and strings.Contains
Change-Id: Iba82a5bd3846f7ab038cc10ec72ff6bcd2c0b484
Reviewed-on: https://go-review.googlesource.com/21377
Run-TryBot: Dave Cheney <dave@cheney.net>
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-04-01 02:05:01 +00:00
Ian Lance Taylor
92bb694a49 cmd/compile: s.f aliases itself
The change in 20907 fixed varexpr but broke aliased.  After that change,
a reference to a field in a struct would not be seen as aliasing itself.
Before that change, it would, but only because all fields in a struct
aliased everything.

This CL changes the compiler to consider all references to a field as
aliasing all other fields in that struct.  This is imperfect--a
reference to one field does not alias another field--but is a simple fix
for the immediate problem.  A better fix would require tracking the
specific fields as well.

Fixes #15042.

Change-Id: I5c95c0dd7b0699e53022fce9bae2e8f50d6d1d04
Reviewed-on: https://go-review.googlesource.com/21390
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-04-01 00:47:56 +00:00
Alexandru Moșoi
7a4211bc1f cmd/compile: constant fold ANDs.
ANDQConst show up occassionally because of right shifting lowering.
ORs and XORs are already folded properly during generic.

Change-Id: I2f9134679555029c641264ce5333d70e167c65f7
Reviewed-on: https://go-review.googlesource.com/21375
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-31 23:32:11 +00:00
Alexandru Moșoi
ec5083e49b cmd/compile: combine SHLQ into loads and stores
Very common, cuts about 70k from pkg/tools/linux_amd64/* binaries.

Change-Id: Ied0c049e56e56a56810c781435d79027fbcaf274
Reviewed-on: https://go-review.googlesource.com/21374
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
2016-03-31 23:18:24 +00:00
Christopher Nelson
8677cad199 cmd/link: Replace fmt.Sprintf with filepath.Join
In a number of places the code was joining filepaths explicitly with
"/", instead of using filepath.Join. This may cause problems on Windows
(or other) platforms.

This is in support of https://go-review.googlesource.com/#/c/18057

Change-Id: Ieb1334f35ddb2e125be690afcdadff8d7b0ace10
Reviewed-on: https://go-review.googlesource.com/21369
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-31 22:32:28 +00:00
Keith Randall
4a7aba775d cmd/compile: better job of naming compound types
Compound AUTO types weren't named previously.  That was because live
variable analysis (plive.go) doesn't handle spilling to compound types.
It can't handle them because there is no valid place to put VARDEFs when
regalloc is spilling compound types.

compound types = multiword builtin types: complex, string, slice, and
interface.

Instead, we split named AUTOs into individual one-word variables.  For
example, a string s gets split into a byte ptr s.ptr and an integer
s.len.  Those two variables can be spilled to / restored from
independently.  As a result, live variable analysis can handle them
because they are one-word objects.

This CL will change how AUTOs are described in DWARF information.
Consider the code:

func f(s string, i int) int {
    x := s[i:i+5]
    g()
    return lookup(x)
}

The old compiler would spill x to two consecutive slots on the stack,
both named x (at offsets 0 and 8).  The new compiler spills the pointer
of x to a slot named x.ptr.  It doesn't spill x.len at all, as it is a
constant (5) and can be rematerialized for the call to lookup.

So compound objects may not be spilled in their entirety, and even if
they are they won't necessarily be contiguous.  Such is the price of
optimization.

Re-enable live variable analysis tests.  One test remains disabled, it
fails because of #14904.

Change-Id: I8ef2b5ab91e43a0d2136bfc231c05d100ec0b801
Reviewed-on: https://go-review.googlesource.com/21233
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-03-31 22:18:26 +00:00
Keith Randall
9f66636c93 cmd/compile: don't put SP in index slot
For idx1 ops, SP can appear in the index slot.
Swap SP into the base register slot so we can encode
the instruction.

Fixes #15053

Change-Id: I19000cc9d6c86c7611743481e6e2cb78b1ef04eb
Reviewed-on: https://go-review.googlesource.com/21384
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-31 22:10:47 +00:00
Keith Randall
47c9e139ae cmd/compile: extend prove pass to handle constant comparisons
Find comparisons to constants and propagate that information
down the dominator tree.  Use it to resolve other constant
comparisons on the same variable.

So if we know x >= 7, then a x > 4 condition must return true.

This change allows us to use "_ = b[7]" hints to eliminate bounds checks.

Fixes #14900

Change-Id: Idbf230bd5b7da43de3ecb48706e21cf01bf812f7
Reviewed-on: https://go-review.googlesource.com/21008
Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro>
2016-03-31 21:16:23 +00:00
Matthew Dempsky
11d916b157 cmd/compile: remove Node.Nointerface field
We already keep the entire pragma bitset in n.Func.Pragma, so there's
no need to track Nointerface separately.

Passes toolstash -cmp.

Change-Id: Ic027ece477fcf63b0c1df128a08b89ef0f34fd58
Reviewed-on: https://go-review.googlesource.com/21381
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-31 20:31:22 +00:00
Matthew Dempsky
7c4d53c2c8 cmd/compile: stop generating garbage when checking map key types
Change-Id: Ib500ee92ae1a3d15f7c9f3f46d238b75184b4304
Reviewed-on: https://go-review.googlesource.com/21382
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-31 20:30:32 +00:00
Josh Bleecher Snyder
00289c296c cmd/compile: dump stack trace in Fatalf during development
See discussion in #15029.

Change-Id: I5cc8be5737ddb7c1f5e4a6cd92cf557af45e961d
Reviewed-on: https://go-review.googlesource.com/21347
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-31 20:17:09 +00:00
David Crawshaw
43a274fd67 cmd/compile: include pkgPath on all struct types
Fixes #15026.

Change-Id: I61ed71152b99973270d79264d1e8f466f7343c02
Reviewed-on: https://go-review.googlesource.com/21286
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-31 20:11:39 +00:00
Josh Bleecher Snyder
e775b8df7a cmd/compile: add sliceBound
Add a constant for the magic -1 for slice bounds.
Use it.
Enforce more aggressively that bounds must be
slice, ddd, or non-negative.
Remove ad hoc check in plive.go.
Check bounds before constructing an array type
when typechecking.

All changes are manual.

Passes toolstash -cmp.

Change-Id: I9fd9cc789d7d4b4eea3b30b24037a254d3788add
Reviewed-on: https://go-review.googlesource.com/21348
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-31 18:41:30 +00:00
Keith Randall
af517da2f9 cmd/compile: Add more idx1 load/store instructions
Helpful for indexed loads and stores when the stride is not equal to
the size being loaded/stored.

Update #7927

Change-Id: I8714dd4c7b18a96a611bf5647ee21f753d723945
Reviewed-on: https://go-review.googlesource.com/21346
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-31 17:30:40 +00:00
Keith Randall
b81f2f106f cmd/compile: place combined loads at the location of the last byte load
We need to make sure all the bounds checks pass before issuing
a load which combines several others.  We do this by issuing the
combined load at the last load's block, where "last" = closest to
the leaf of the dominator tree.

Fixes #15002

Change-Id: I7358116db1e039a072c12c0a73d861f3815d72af
Reviewed-on: https://go-review.googlesource.com/21246
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-31 17:21:33 +00:00
Josh Bleecher Snyder
b83618f964 cmd/compile: encapsulate Type.Nname
Generated by eg, manually fixed up.

I’m not thrilled about having a setter,
but given the variety of contexts in which this
gets fiddled with, it is the cleanest
available alternative.

Change-Id: Ibdf23e638fe0bdabded014c9e59d557fab8c955f
Reviewed-on: https://go-review.googlesource.com/21341
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-31 15:38:34 +00:00
Matthew Dempsky
e6066711a0 cmd/compile, runtime: fix pedantic int->string conversions
Previously, cmd/compile rejected constant int->string conversions if
the integer value did not fit into an "int" value. Also, runtime
incorrectly truncated 64-bit values to 32-bit before checking if
they're a valid Unicode code point. According to the Go spec, both of
these cases should instead yield "\uFFFD".

Fixes #15039.

Change-Id: I3c8a3ad9a0780c0a8dc1911386a523800fec9764
Reviewed-on: https://go-review.googlesource.com/21344
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-31 10:28:23 +00:00
Matthew Dempsky
71ab3c1ccf cmd/link: remove -H elf flag
We create appropriate ELF files automatically based on GOOS. There's
no point in supporting -H elf flag, particularly since we need to emit
different flavors of ELF depending on GOOS anyway.

If that weren't reason enough, -H elf appears to be broken since at
least Go 1.4. At least I wasn't able to find a way to make use of it.

As best I can tell digging through commit history, -H elf is just an
artifact leftover from Plan 9's 6l linker.

Change-Id: I7393caaadbc60107bbd6bc99b976a4f4fe6b5451
Reviewed-on: https://go-review.googlesource.com/21343
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-31 06:33:01 +00:00
Ian Lance Taylor
b4117995e3 cmd/pprof: use DWARF info to lookup unknown PC addresses
Test to follow in a separate CL that arranges for the runtime package to
store non-Go addresses in a CPU profile.

Change-Id: I33ce1d66b77340b1e62b54505fc9b1abcec108a9
Reviewed-on: https://go-review.googlesource.com/21055
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2016-03-31 04:05:06 +00:00
Dave Cheney
1a9373bc57 cmd/compile/internal/gc: avoid append when building Type fields
As a followup to CL 21296, avoid append operations when constructing the
fields of a Type if the length is known beforehand

This also includes some small scoping driveby cleanups, and a change to
tointerface0 to avoid iterating over the field list twice.

compilebench shows a very small reduction in allocations.

 name      old time/op    new time/op    delta
Template     364ms ± 5%     363ms ± 4%    ~     (p=0.945 n=20+19)
Unicode      182ms ±11%     185ms ±12%    ~     (p=0.445 n=20+20)
GoTypes      1.14s ± 2%     1.14s ± 3%    ~     (p=0.221 n=20+20)
Compiler     5.85s ± 2%     5.84s ± 2%    ~     (p=0.369 n=20+20)

name      old alloc/op   new alloc/op   delta
Template    56.7MB ± 0%    56.7MB ± 0%  -0.04%  (p=0.000 n=20+20)
Unicode     38.3MB ± 0%    38.3MB ± 0%    ~     (p=0.728 n=20+19)
GoTypes      180MB ± 0%     180MB ± 0%  -0.02%  (p=0.000 n=20+20)
Compiler     812MB ± 0%     812MB ± 0%  -0.02%  (p=0.000 n=19+20)

name      old allocs/op  new allocs/op  delta
Template      482k ± 0%      480k ± 0%  -0.34%  (p=0.000 n=20+20)
Unicode       377k ± 0%      377k ± 0%  -0.04%  (p=0.010 n=20+20)
GoTypes      1.36M ± 0%     1.35M ± 0%  -0.24%  (p=0.000 n=20+20)
Compiler     5.47M ± 0%     5.46M ± 0%  -0.11%  (p=0.000 n=20+18)

Change-Id: Ibb4c40229fa3816acd8de98ba41d1571a2aabacf
Reviewed-on: https://go-review.googlesource.com/21352
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dave Cheney <dave@cheney.net>
2016-03-31 02:22:18 +00:00
Dave Cheney
ea5091fcd7 cmd/compile/internal/gc: don't let the argument to Fields.Set escape
Apply Robert's optimisation from CL 21241 to Type.Fields. The results
are less impressive, possibly because of the makeup of the test data.

name      old time/op    new time/op    delta
Template     365ms ± 5%     365ms ± 3%    ~     (p=0.888 n=20+16)
Unicode      182ms ±10%     180ms ± 9%    ~     (p=0.883 n=20+20)
GoTypes      1.14s ± 2%     1.13s ± 3%    ~     (p=0.096 n=20+20)
Compiler     5.74s ± 1%     5.76s ± 2%    ~     (p=0.369 n=20+20)

name      old alloc/op   new alloc/op   delta
Template    56.8MB ± 0%    56.7MB ± 0%  -0.15%  (p=0.000 n=19+20)
Unicode     38.3MB ± 0%    38.3MB ± 0%  -0.02%  (p=0.006 n=20+19)
GoTypes      180MB ± 0%     180MB ± 0%  -0.13%  (p=0.000 n=20+20)
Compiler     805MB ± 0%     804MB ± 0%  -0.05%  (p=0.000 n=20+20)

name      old allocs/op  new allocs/op  delta
Template      485k ± 0%      482k ± 0%  -0.54%  (p=0.000 n=19+20)
Unicode       377k ± 0%      377k ± 0%  -0.05%  (p=0.005 n=20+20)
GoTypes      1.37M ± 0%     1.36M ± 0%  -0.53%  (p=0.000 n=20+19)
Compiler     5.42M ± 0%     5.41M ± 0%  -0.21%  (p=0.000 n=20+20)

Change-Id: I6782659fadd605ce9931bf5c737c7058b96a29eb
Reviewed-on: https://go-review.googlesource.com/21296
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-31 00:40:11 +00:00
Dave Cheney
0373128318 cmd/compile/internal/gc: don't iterate over field list twice
In tostruct0 and tofunargs we take a list of nodes, transform them into
a slice of Fields, set the fields on a type, then use the IterFields
iterator to iterate over the list again to see if any of them are
broken.

As we know the slice of fielde-we just created it-we can combine these two
interations into one pass over the fields.

Change-Id: I8b04c90fb32fd6c3b1752cfc607128a634ee06c5
Reviewed-on: https://go-review.googlesource.com/21350
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-31 00:21:37 +00:00
Matthew Dempsky
e76fc1b921 cmd/compile: use t.IsFoo() instead of Isfoo[t.Etype]
This allows us to get rid of Isptr and Issigned. Still some code to
clean up for Isint, Isfloat, and Iscomplex.

CL produced mechanically using gofmt -w -r.

Passes toolstash -cmp.

Change-Id: If4f807bb7f2b357288d2547be2380eb511875786
Reviewed-on: https://go-review.googlesource.com/21339
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-03-30 22:48:34 +00:00
Matthew Dempsky
3efefd9395 cmd/compile: use t.IsFoo() instead of t.Etype == TFOO
CL produced mechanically using gofmt -w -r.

Passes toolstash -cmp.

Change-Id: Ib2e8710ebd844e2149125b41c335b71a02fcab53
Reviewed-on: https://go-review.googlesource.com/21338
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-30 22:31:07 +00:00
Alexandru Moșoi
d8f1f8d856 cmd/compile: generalize strength reduction of mulq
* This is an improved version of an earlier patch.
* Verified with gcc up to 100.
* Limited to two instructions based on costs from
https://gmplib.org/~tege/x86-timing.pdf

Change-Id: Ib7c37de6fd8e0ba554459b15c7409508cbcf6728
Reviewed-on: https://go-review.googlesource.com/21103
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-30 22:27:13 +00:00
Matthew Dempsky
1624a9c9e7 cmd/compile: get rid of redundant Type helper functions
Replace Isfixedarray, Isslice, and Isinter with the IsArray, IsSlice,
and IsInterface methods added for SSA. Rewrite performed mechanically
using gofmt -w -r "Isfoo(t) -> t.IsFoo()".

Because the IsFoo methods panic when given a nil pointer, a handful of
call sites had to be modified to check for nil Type values. These
aren't strictly necessary, because nil Type values should only occur
in invalid Go source programs, so it would be okay if we panicked on
them and gave up type checking the rest of the package. However, there
are a couple regress tests that expect we continue, so add checks to
keep those tests passing. (See #15029.)

Passes toolstash -cmp.

Change-Id: I511c6ac4cfdf3f9cbdb3e52a5fa91b6d09d82f80
Reviewed-on: https://go-review.googlesource.com/21336
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-30 21:58:18 +00:00
Josh Bleecher Snyder
2592e0999e cmd/compile: s/typeX/typX/
Apparently I’m having a hard time following my
own naming scheme.

Change-Id: I99c801bef09fa65c1f0e8ecc2fba154a495e9c17
Reviewed-on: https://go-review.googlesource.com/21332
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2016-03-30 21:22:09 +00:00
Josh Bleecher Snyder
8640b51df8 cmd/compile: add Type.Elem
This removes almost all direct access to
Type’s heavily overloaded Type field.

Mostly generated by eg, manually checked.

Significant manual changes:

* reflect.go's typPkg used Type indiscriminately.
  Use it only for specific etypes.
* gen.go's visitComponents contained a usage of Type
  with structs. Using Type for structs no longer
  occurs, and the Fatal contained therein has not triggered,
  so it has been axed.
* Scary code in cgen.go's cgen_slice is now explicitly scary.

Passes toolstash -cmp.

Change-Id: I2dbfb3c959da7ae239f964d83898c204affcabc6
Reviewed-on: https://go-review.googlesource.com/21331
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-30 21:21:55 +00:00
Josh Bleecher Snyder
76e72691a0 cmd/compile: add typMap
Also, add two uses of Key and Val that I missed earlier.
As before, direct writes to Down and Type remain in bimport.

Change-Id: I487aa975926b30092db1ad74ace17994697117c1
Reviewed-on: https://go-review.googlesource.com/21330
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-30 21:05:29 +00:00
Alexandru Moșoi
dc5a7682f0 cmd/compile: use inc/dec for bytes, too
Change-Id: Ib2890ab1983cbef7c1c1ee5a10204ba3ace19b53
Reviewed-on: https://go-review.googlesource.com/21312
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-30 20:18:16 +00:00
Matthew Dempsky
788f11263a cmd/compile: rename Type.IsPtr to Type.IsPtrShaped
Previously, t.IsPtr() reported whether t was represented with a
pointer, but some of its callers expected it to report whether t is an
actual Go pointer. Resolve this by renaming t.IsPtr to t.IsPtrShaped
and adding a new t.IsPtr method to report Go pointer types.

Updated a couple callers in gc/ssa.go to use IsPtr instead of
IsPtrShaped.

Passes toolstash -cmp.

Updates #15028.

Change-Id: I0a8154b5822ad8a6ad296419126ad01a3d2a5dc5
Reviewed-on: https://go-review.googlesource.com/21232
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-03-30 19:11:16 +00:00
Josh Bleecher Snyder
fdf6761e01 cmd/compile: add typPtr
Passes toolstash -cmp.

Change-Id: I721348ed2122b6a9cd87ad2041b6ee3bf6b2bbb5
Reviewed-on: https://go-review.googlesource.com/21306
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-30 17:19:59 +00:00
Josh Bleecher Snyder
e3c7497327 cmd/compile: add typWrapper and Type.Wrapped
Passes toolstash -cmp.

Change-Id: I7dffd9bc5bab323590df6fb591bf1e73edf2e465
Reviewed-on: https://go-review.googlesource.com/21305
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-30 17:19:50 +00:00
Josh Bleecher Snyder
09c672d50a cmd/compile: add typChan
Passes toolstash -cmp.

Change-Id: I2c71882f957c44047c7ac83c78236dcc3dfa15a1
Reviewed-on: https://go-review.googlesource.com/21304
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-30 17:19:42 +00:00
Josh Bleecher Snyder
331f962508 cmd/compile: use IsSlice and IsArray instead of checking Bound
Changes generated by eg and manually checked.

Isfixedarray, Isslice, and many other
Type-related functions in subr.go should
either be deleted or moved to type.go.
Later, though; the game now is cleanup via encapsulation.

Passes toolstash -cmp.

Change-Id: I83dd8816f6263b74367d23c2719a08c362e330f9
Reviewed-on: https://go-review.googlesource.com/21303
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-30 17:18:29 +00:00
Alexandru Moșoi
d7f7ea6ea8 cmd/compile: ignore dead phis in fuse
Happens occasionally for boolean phis was used as a control.

Change-Id: Ie0f2483e9004c1706751d8dfb25ee2e5106d917e
Reviewed-on: https://go-review.googlesource.com/21310
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-30 15:37:18 +00:00
kortschak
6b97dbf848 cmd/dist: make fortran test conditional on bash existence
Fixes #14929.

Change-Id: I0391acf9f5f65389f73637533306a7c4240320b8
Reviewed-on: https://go-review.googlesource.com/21295
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-30 11:35:40 +00:00
Michael Munday
354e9778a3 cmd/asm: add s390x support
s390x doesn't introduce any new assembly syntax. There are a few
instructions which require the operands to be reordered, notably
the storage-storage instructions that put the length into From3 so
that the memory operands can be put into From and To.

The assembly test currently covers a subset of instructions but
tries to hit edge cases as much as possible. Unlike the other ports
it can be linked as an executable to make disassembling it easy.
It would be nice to autogenerate it at some point in the future.

Change-Id: I8dd542c34b9e450b8129d46693a5acb0ded791ce
Reviewed-on: https://go-review.googlesource.com/21253
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-30 05:25:49 +00:00
Josh Bleecher Snyder
268c31870a cmd/compile: move substAny to type.go
substAny needs access to many internal details
of gc.Type. substArgTypes comes along for the ride.

Change-Id: I430a4edfd54a1266522f7a9818e5e7b5da72479c
Reviewed-on: https://go-review.googlesource.com/21250
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-30 05:23:11 +00:00
Michael Munday
0a85be573c cmd/internal/obj: add copyright header to files
Change-Id: I4ed33f3fdb9ad5f0f8984d3ef282c34e26eb2cde
Reviewed-on: https://go-review.googlesource.com/21301
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-30 05:01:49 +00:00
Michael Munday
13f97ea456 cmd/internal/obj/s390x: add s390x support
Based on the ppc64 port.

s390x supports 2, 4 and 6 byte instructions and Go assembly
instructions sometimes map to several s390x instructions. The
assembler loops until a fixed point is reached in order to use
branch instructions that can only handle a short offset in a
similar way to other ports.

Change-Id: I4278bf46aca35a96ca9cea0857e6229643c9c1e3
Reviewed-on: https://go-review.googlesource.com/20942
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-30 04:57:30 +00:00
Keith Randall
7fc5621991 cmd/compile: define high bits of AuxInt
Previously if we were only using the low bits of AuxInt,
the high bits were ignored and could be junk.  This CL
changes that behavior to define the high bits to be the
sign-extended version of the low bits for all cases.

There are 2 main benefits:
- Deterministic representation.  This helps with CSE.
  (Const8 [0x1]) and (Const8 [0x101]) used to be the same "value"
  but CSE couldn't see them as such.
- Testability.  We can check that all ops leave AuxInt in a state
  consistent with the new rule.  In the old scheme, it was hard
  to check whether a rule correctly used only the low-order bits.
Side benefits:
- ==0 and !=0 tests are easier.

Drawbacks:
- This differs from the runtime representation in registers,
  where it is important that we allow upper bits to be undefined
  (so we're not sign/zero-extending all the time).
- Ops that treat AuxInt as unsigned (shifts, mostly) need to be
  a bit more careful.

Change-Id: I9a685ff27e36dc03287c9ab1cecd6c0b4045c819
Reviewed-on: https://go-review.googlesource.com/21256
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-03-30 04:48:28 +00:00
Shahar Kohanim
7f067c87d8 cmd/compile, cmd/link: record lengths in object file
Record total number of relocations, pcdata, automatics, funcdata and files in
object file and use these numbers in the linker to allocate contiguous
slices to later be filled by the defined symbols.

name       old secs    new secs    delta
LinkCmdGo   0.52 ± 3%   0.49 ± 3%  -4.21%   (p=0.000 n=91+92)
LinkJuju    4.48 ± 4%   4.21 ± 7%  -6.08%  (p=0.000 n=96+100)

name       old MaxRSS  new MaxRSS  delta
LinkCmdGo   122k ± 2%   120k ± 4%  -1.66%   (p=0.000 n=98+93)
LinkJuju    799k ± 5%   865k ± 8%  +8.29%   (p=0.000 n=89+99)

GOGC=off

name       old secs    new secs    delta
LinkCmdGo   0.42 ± 2%   0.41 ± 0%  -2.98%    (p=0.000 n=89+70)
LinkJuju    3.61 ± 0%   3.52 ± 1%  -2.46%    (p=0.000 n=80+89)

name       old MaxRSS  new MaxRSS  delta
LinkCmdGo   130k ± 1%   128k ± 1%  -1.33%  (p=0.000 n=100+100)
LinkJuju   1.00M ± 0%  0.99M ± 0%  -1.70%  (p=0.000 n=100+100)

Change-Id: Ie08f6ccd4311bb78d8950548c678230a58635c73
Reviewed-on: https://go-review.googlesource.com/21026
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-30 03:44:41 +00:00
Ian Lance Taylor
777a77b4d2 cmd/compile: don't skip PPARAMOUT in esccall after varargs
Fixes bug I introduced in CL 21202.

Fixes #15013.

Change-Id: I2344d7e22b8273425a0a56f4a77588b5c6e4d8c6
Reviewed-on: https://go-review.googlesource.com/21270
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-30 02:43:08 +00:00
Philip Hofer
c12a0e645a cmp/compile: rewrite CMP $0 with TEST
The CMP* family of instructions are longer than their TEST counterparts by one byte.

After this change, my go tool has 13 cmp.*$0x0 instructions, compared to 5612 before.

Change-Id: Ieb87d65657917e494c0e4b711a7ba2918ae27610
Reviewed-on: https://go-review.googlesource.com/21255
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-30 00:50:53 +00:00
Aliaksandr Valialkin
72a1b53b67 cmd/vet: allow lock types inside built-in new()
Updates #14839
Fixes #14994

Change-Id: I9bb51bad19105a17c80d690c5486e5dd007ac84a
Reviewed-on: https://go-review.googlesource.com/21222
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-30 00:16:48 +00:00
Josh Bleecher Snyder
eb98e51563 cmd/compile: add typArray, typSlice, and typDDDArray
These are the first of several convenience
constructors for types.

They are part of type field encapsulation.
This removes most external writes to TARRAY Type and Bound fields.

substAny still directly fiddles with the .Type field.
substAny generally needs access to Type internals.
It will be moved to type.go in a future CL.

bimport still directly writes the .Type field.
This is hard to change.

Also of note:

* inl.go contains an (apparently irrelevant) bug fix:
  as.Right was given the wrong type.
  vararrtype was previously unused.
* I believe that aindex (subr.go) never creates slices,
  but it is safer to keep existing behavior.
  The removal of -1 as a constant there is part
  of hiding that implementation detail.
  Future CLs will finish that job.

Passes toolstash -cmp.

Change-Id: If09bf001a874d7dba08e9ad0bcd6722860af4b91
Reviewed-on: https://go-review.googlesource.com/21249
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-29 23:48:24 +00:00
Josh Bleecher Snyder
f32161daf8 cmd/compile: make only one new Node in defaultlit
defaultlit and friends sometimes create a new
OLITERAL node, only to have replace it.
Thread hints when that is unnecessary.

name       old time/op     new time/op     delta
Template       318ms ± 6%      322ms ± 4%     ~           (p=0.154 n=24+25)
Unicode        162ms ± 6%      151ms ± 7%   -6.94%        (p=0.000 n=22+23)
GoTypes        1.04s ± 1%      1.04s ± 3%     ~           (p=0.136 n=20+25)
Compiler       5.08s ± 2%      5.10s ± 4%     ~           (p=0.788 n=25+25)
MakeBash       41.4s ± 1%      41.5s ± 1%     ~           (p=0.084 n=25+25)

name       old user-ns/op  new user-ns/op  delta
Template        438M ±10%       441M ± 9%     ~           (p=0.418 n=25+25)
Unicode         272M ± 5%       219M ± 5%  -19.33%        (p=0.000 n=24+21)
GoTypes        1.51G ± 3%      1.51G ± 3%     ~           (p=0.500 n=25+25)
Compiler       7.31G ± 3%      7.32G ± 3%     ~           (p=0.572 n=25+24)

name       old alloc/op    new alloc/op    delta
Template      57.3MB ± 0%     57.2MB ± 0%   -0.16%        (p=0.000 n=25+25)
Unicode       41.1MB ± 0%     38.7MB ± 0%   -5.81%        (p=0.000 n=25+25)
GoTypes        191MB ± 0%      191MB ± 0%   -0.06%        (p=0.000 n=25+25)
Compiler       840MB ± 0%      839MB ± 0%   -0.12%        (p=0.000 n=25+25)

name       old allocs/op   new allocs/op   delta
Template        500k ± 0%       500k ± 0%   -0.12%        (p=0.000 n=24+25)
Unicode         400k ± 0%       384k ± 0%   -4.16%        (p=0.000 n=25+25)
GoTypes        1.50M ± 0%      1.49M ± 0%   -0.05%        (p=0.000 n=25+25)
Compiler       6.04M ± 0%      6.03M ± 0%   -0.11%        (p=0.000 n=25+25)

Change-Id: I2fda5e072db67ba239848bde827c7deb2ad4abae
Reviewed-on: https://go-review.googlesource.com/20813
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-29 23:47:48 +00:00
Aliaksandr Valialkin
ee1b90ad2c cmd/vet: improve detecting printf-like format argument
Previously format argument was detected via scanning func type args.
This didn't work when func type couldn't be determined if the func
is declared in the external package. Fall back to scanning for
the first string call argument in this case.

Fixes #14754

Change-Id: I571cc29684cc641bc87882002ef474cf1481e9e2
Reviewed-on: https://go-review.googlesource.com/21023
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-29 23:40:52 +00:00
Marvin Stenger
d0fb649713 all: use &^ operator if possible
This is a change improving consistency in the source tree.
The pattern foo &= ^bar, was only used six times in src/ directory.
The usage of the supported &^ (bit clear / AND NOT) operator is way more
common, about factor 10x.

Change-Id: If26a2994fd81d23d42189bee00245eb84e672cf3
Reviewed-on: https://go-review.googlesource.com/21224
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-29 14:28:41 +00:00
Shahar Kohanim
1b6402ea9d cmd/link: remove some more dead fields from Pcln
Change-Id: Ibb98de29d84a605fb1588c7dc11ad66e3965a137
Reviewed-on: https://go-review.googlesource.com/21223
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
2016-03-29 11:12:45 +00:00
Josh Bleecher Snyder
093a9a1f56 cmd/compile: encapsulate map value type
Passes toolstash -cmp.

Change-Id: I83af544974e1e91e0810e13321afb3e665dcdf12
Reviewed-on: https://go-review.googlesource.com/21248
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-29 05:26:32 +00:00
Josh Bleecher Snyder
bf5f24b98e cmd/compile: use t.Key() instead of t.Down
This was the only unconverted instance.

Change-Id: Ic0ba75824614fcd1e055316e62e26acd06801dd1
Reviewed-on: https://go-review.googlesource.com/21247
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-29 05:08:43 +00:00
Matthew Dempsky
da19a0cff4 cmd/compile: fix plan9-amd64 build
The previous rules to combine indexed loads produced addresses like:

    From: obj.Addr{
        Type:   TYPE_MEM,
        Reg:    REG_CX,
        Name:   NAME_AUTO,
        Offset: 121,
        ...
    }

which are erroneous because NAME_AUTO implies a base register of
REG_SP, and cmd/internal/obj/x86 makes many assumptions to this
effect.  Note that previously we were also producing an extra "ADDQ
SP, CX" instruction, so indexing off of SP was already handled.

The approach taken by this CL to address the problem is to instead
produce addresses like:

    From: obj.Addr{
        Type:   TYPE_MEM,
        Reg:    REG_SP,
        Name:   NAME_AUTO,
        Offset: 121,
        Index:  REG_CX,
        Scale:  1,
    }

and to omit the "ADDQ SP, CX" instruction.

Downside to this approach is it requires adding a lot of new
MOV[WLQ]loadidx1 instructions that nearly duplicate functionality of
the existing MOV[WLQ]loadidx[248] instructions, but with a different
Scale.

Fixes #15001.

Change-Id: Iad9a1a41e5e2552f8d22e3ba975e4ea0862dffd2
Reviewed-on: https://go-review.googlesource.com/21245
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-29 03:22:06 +00:00
Michel Lespinasse
859b63cc09 cmd/compile: optimize remaining convT2I calls
See #14874
Updates #6853

This change adds a compiler optimization for non pointer shaped convT2I.
Since itab symbols are now emitted by the compiler, the itab address can
be passed directly to convT2I instead of passing the iface type and a
cache pointer argument.

Compilebench results for the 5-commits series ending here:

name       old time/op     new time/op     delta
Template       336ms ± 4%      344ms ± 4%   +2.61%          (p=0.027 n=9+8)
Unicode        165ms ± 6%      173ms ± 7%   +5.11%          (p=0.014 n=9+9)
GoTypes        1.09s ± 1%      1.06s ± 2%   -3.29%          (p=0.000 n=9+9)
Compiler       5.09s ±10%      4.75s ±10%   -6.64%        (p=0.011 n=10+10)
MakeBash       31.1s ± 5%      30.3s ± 3%     ~           (p=0.089 n=10+10)

name       old text-bytes  new text-bytes  delta
HelloSize       558k ± 0%       558k ± 0%   +0.02%        (p=0.000 n=10+10)
CmdGoSize      6.24M ± 0%      6.11M ± 0%   -2.11%        (p=0.000 n=10+10)

name       old data-bytes  new data-bytes  delta
HelloSize      3.66k ± 0%      3.74k ± 0%   +2.41%        (p=0.000 n=10+10)
CmdGoSize       134k ± 0%       162k ± 0%  +20.76%        (p=0.000 n=10+10)

name       old bss-bytes   new bss-bytes   delta
HelloSize       126k ± 0%       126k ± 0%     ~     (all samples are equal)
CmdGoSize       149k ± 0%       146k ± 0%   -2.17%        (p=0.000 n=10+10)

name       old exe-bytes   new exe-bytes   delta
HelloSize       924k ± 0%       924k ± 0%   +0.05%        (p=0.000 n=10+10)
CmdGoSize      9.77M ± 0%      9.62M ± 0%   -1.47%        (p=0.000 n=10+10)

Change-Id: Ib230ddc04988824035c32287ae544a965fedd344
Reviewed-on: https://go-review.googlesource.com/20902
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Michel Lespinasse <walken@google.com>
2016-03-29 02:21:50 +00:00
Michel Lespinasse
7427f2c4bd cmd/compile: optimize convT2I as a two-word copy when T is pointer-shaped
See #14874

This change adds a compiler optimization for pointer shaped convT2I.
Since itab symbols are now emitted by the compiler, the itab address can
be directly moved into the iface structure.

Change-Id: I311483af544519ca682c5f872960717ead772f26
Reviewed-on: https://go-review.googlesource.com/20901
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-29 02:21:41 +00:00
Michel Lespinasse
79688ca58f cmd/link: collect itablinks as a slice in moduledata
See #14874

This change tells the linker to collect all the itablink symbols and
collect them so that moduledata can have a slice of all compiler
generated itabs.

The logic is shamelessly adapted from what is done with typelink symbols.

Change-Id: Ie93b59acf0fcba908a876d506afbf796f222dbac
Reviewed-on: https://go-review.googlesource.com/20889
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-29 02:18:56 +00:00
Michel Lespinasse
f00bbd5f81 cmd/compile: emit itabs and itablinks
See #14874

This change tells the compiler to emit itab and itablink symbols in
situations where they could be useful; however the compiled code does
not actually make use of the new symbols yet.

Change-Id: I0db3e6ec0cb1f3b7cebd4c60229e4a48372fe586
Reviewed-on: https://go-review.googlesource.com/20888
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Michel Lespinasse <walken@google.com>
2016-03-29 02:18:03 +00:00
Matthew Dempsky
deb83d0639 cmd/compile: remove unused write barrier helpers
These have been unused since CL 10316.

Passes toolstash -cmp.

Change-Id: Icc19f3fcc7275fbee1c665f704e10a110ecce2a5
Reviewed-on: https://go-review.googlesource.com/21242
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2016-03-29 00:16:55 +00:00
Josh Bleecher Snyder
361b334cbd cmd/compile: encapsulate Type.Argwid
Passes toolstash -cmp.

Change-Id: I72fb271052e449a83adfa9bd3b923d40781d6341
Reviewed-on: https://go-review.googlesource.com/21243
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-29 00:08:56 +00:00
Josh Bleecher Snyder
272df158ac cmd/compile: clean up ... Bound marker
This mostly a mechanical change.
However, the change in assignop (subr.go) is a bug fix.
The code didn’t match the comment,
and the comment was correct.
Nevertheless, this CL passes toolstash -cmp.

The last direct reference to dddBound outside
type.go (in typecheck.go) will go away
in a future CL.

Change-Id: Ifb1691e0a07f906712c18c4a4cd23060807a5da5
Reviewed-on: https://go-review.googlesource.com/21235
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-28 23:33:30 +00:00
Raul Silvera
fcd2a06ab6 cmd/pprof/internal: use and accept packed encoding for repeated fields
Packed encoding is the default on the proto3 format. Profiles generated
in the profile.proto format by third parties cannot be decoded by the
Go pprof tool, since its proto decoder does not recognize packed
encoding for repeated fields.

In particular this issue prevents go tool pprof from reading profiles
generated by the version of pprof in github.com/google/pprof

Profiles generated by go tool pprof after this change will use packed
repeating fields, so older versions of pprof will not be able to read
them. pprof will continue to be able to read profiles generated before
this change.

Change-Id: Ife0b353a535ae1e495515b9bcec588dd967e171b
Reviewed-on: https://go-review.googlesource.com/21240
Reviewed-by: David Symonds <dsymonds@golang.org>
Run-TryBot: David Symonds <dsymonds@golang.org>
2016-03-28 22:55:20 +00:00
Robert Griesemer
621aa713d4 cmd/compile: avoid allocation in Nodes.Set in common case
When building make.bash, calling Nodes.Set(s) where len(s) == 0 occurs
4738678 times vs 1465415 calls where len(s) > 0; i.e., it is over 3x
more common to set Nodes.slice to nil rather than to s.

Make a copy of slice (header) and take address of that copy instead
to avoid allocating the argument slice on the heap always even when
not needed.

Saves 4738678 slice header allocations and slice header value copies.

Change-Id: I88e8e919ea9868ceb2df46173d187af4109bd947
Reviewed-on: https://go-review.googlesource.com/21241
Reviewed-by: Alan Donovan <adonovan@google.com>
2016-03-28 21:41:11 +00:00
Matthew Dempsky
390d1ce686 cmd/compile: simplify substAny's TSTRUCT case
Now that structs use a slice to store their fields, this code can be
simplified somewhat.

Passes toolstash -cmp.

Change-Id: If17b1c89871fa06f34938fa67df0f8c6bcf1a86b
Reviewed-on: https://go-review.googlesource.com/21219
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-28 21:07:05 +00:00
Keith Randall
7294ccb54e cmd/compile: join indexed byte loads into larger loads
Fixes #14920

Change-Id: I1535dc529779e26141d92d9e2b6ba7b016590c1a
Reviewed-on: https://go-review.googlesource.com/21005
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
Reviewed-by: Ahmed Waheed <oneofone@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
2016-03-28 20:27:58 +00:00
Matthew Dempsky
810799a16d Revert "cmd/asm: add s390x support"
This reverts commit 85bbabd9c4.

The reverted CL broke all builds, because it depends on other CLs
that haven't been reviewed or landed yet.

Change-Id: I936f969431e0ac77133e43de2bf63042cef6b777
Reviewed-on: https://go-review.googlesource.com/21238
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2016-03-28 20:22:08 +00:00
Matthew Dempsky
1b2fbb49c8 cmd/compile: cleanup alg.go for Field slices
Passes toolstash -cmp.

Change-Id: Ie41d7e74847c44a8fd174731374339c6c32b1460
Reviewed-on: https://go-review.googlesource.com/21231
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-28 20:13:59 +00:00
Matthew Dempsky
62dddd4770 cmd/compile: rename Field's Width field to Offset
gorename -from '"cmd/compile/internal/gc".Field.Width' -to Offset

Passes toolstash -cmp.

Change-Id: I310538a1f60bbab470a6375e813e9d5eb52c5bbf
Reviewed-on: https://go-review.googlesource.com/21230
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-28 20:13:51 +00:00
Michael Munday
85bbabd9c4 cmd/asm: add s390x support
s390x doesn't introduce any new assembly syntax. There are a few
instructions which require the operands to be reordered, notably
the storage-storage instructions that put the length into From3 so
that the memory operands can be put into From and To.

The assembly test currently covers a subset of instructions but
tries to hit edge cases as much as possible. Unlike the other ports
it can be linked as an executable to make disassembling it easy.
It would be nice to autogenerate it at some point in the future.

Change-Id: I7615ac6ecf239e3f347fad9ae1f8eede91742859
Reviewed-on: https://go-review.googlesource.com/20934
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-28 20:13:17 +00:00
Josh Bleecher Snyder
cabf73ffb8 cmd/compile: add EType.String and missing EType names
Passes toolstash -cmp.

Change-Id: Icc387eb557d5029e903923a051b565812fd2246b
Reviewed-on: https://go-review.googlesource.com/21234
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-28 18:44:07 +00:00
Marvin Stenger
2326c24cc7 cmd/internal/obj: convert fields of LSym from uint8 to bool
No performance regression measurable:

name      old time/op    new time/op    delta
Template     432ms ± 3%     422ms ± 2%  -2.34%   (p=0.010 n=10+9)
GoTypes      1.46s ± 1%     1.46s ± 1%    ~     (p=0.796 n=10+10)
Compiler     7.15s ± 1%     7.14s ± 1%    ~      (p=0.447 n=10+9)

Change-Id: I21b93cb989017b6fec2215de2423d87f25cf538c
Reviewed-on: https://go-review.googlesource.com/21220
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-28 16:32:59 +00:00
David Chase
8eec2bbfbc cmd/compile: added some intrinsics to SSA back end
One intrinsic was needed to help get the very best
performance out of a future GC; as long as that one was
being added, I also added Bswap since that is sometimes
a handy thing to have.  I had intended to fill out the
bit-scan intrinsic family, but the mismatch between the
"scan forward" instruction and "count leading zeroes"
was large enough to cause me to leave it out -- it poses
a dilemma that I'd rather dodge right now.

These intrinsics are not exposed for general use.
That's a separate issue requiring an API proposal change
( https://github.com/golang/proposal )

All intrinsics are tested, both that they are substituted
on the appropriate architecture, and that they produce the
expected result.

Change-Id: I5848037cfd97de4f75bdc33bdd89bba00af4a8ee
Reviewed-on: https://go-review.googlesource.com/20564
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-28 16:29:59 +00:00
Shahar Kohanim
2e90192b0e cmd/link: refactor symbol lookup
Calling the read only Linkrlookup will now not cause the name
string to escape. So a lookup can be performed on a []byte
casted to a string without allocating. This will help a followup
cl and it is also much simpler and cleaner.
Performance not impacted by this.

name       old s/op   new s/op   delta
LinkCmdGo  0.51 ± 6%  0.51 ± 5%   ~     (p=0.192 n=98+98)

Change-Id: I7846ba3160eb845a3a29cbf0be703c47369ece16
Reviewed-on: https://go-review.googlesource.com/21187
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-28 16:09:54 +00:00
Ian Lance Taylor
7e88826a69 cmd/compile: clear OTFUNC info when converting to OTYPE
I want to get rid of OTFUNC, which serves no useful purpose.  However,
it turns out that the escape analysis pass looks at the node slices set
up for OTFUNC, even though by the time escape analysis runs the OTFUNC
has been converted to OTYPE.  This CL converts the escape analysis code
to look at the function decls instead, and clears the OTFUNC info when
converting to OTYPE to ensure that nothing else looks at it.

Change-Id: I3f2f5997ea8ea7a127a858e94b20aabfab84a5bf
Reviewed-on: https://go-review.googlesource.com/21202
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-28 14:10:21 +00:00
Dominik Honnef
aa482f9715 cmd/go: remove code specific to Google Code
Remove all special handling of Google Code, which has shut down.

Commit 4ec2fd3e6a suggested that maybe the
shutdown warning should remain. However, it has been missing from Go 1.6
already, and by Go 1.7 people will most likely have realised that Google
Code has shut down.

Updates #10193.

Change-Id: I5749bbbe2fe3b07cff4edd20303bbedaeaa8d77b
Reviewed-on: https://go-review.googlesource.com/21189
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-28 05:37:04 +00:00
Josh Bleecher Snyder
a637717e7d cmd/compile: rename T_old_DARRAY and update comments
Change-Id: Ifa3b1b1e5458e4f109828a476d37f1caf96fe14b
Reviewed-on: https://go-review.googlesource.com/21211
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-27 20:38:56 +00:00
Josh Bleecher Snyder
fcca9d265c cmd/compile: remove pointless conversions in copytype
Passes toolstash -cmp.

Change-Id: I8b000d4e90e6aa1a0e60bd46fb7cba2ddc1774b5
Reviewed-on: https://go-review.googlesource.com/21210
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-27 19:52:36 +00:00
Matthew Dempsky
995fb0319e cmd/compile: fix stringtoslicebytetmp optimization
Fixes #14973.

Change-Id: Iea68c9deca9429bde465c9ae05639209fe0ccf72
Reviewed-on: https://go-review.googlesource.com/21175
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-27 19:12:37 +00:00
Dominik Honnef
4ffa5eb876 cmd/vet: don't treat fields like variables in rangeloop check
Fixes #13236

Change-Id: If902ac66718e0a0790fab9835921ce4ef980965b
Reviewed-on: https://go-review.googlesource.com/21183
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-27 05:31:54 +00:00
Josh Bleecher Snyder
688840593b cmd/compile: don’t generate a new Node for convas
This removes about 3% of the Nodes allocated
while compiling std+cmd.

Passes toolstash -cmp.

name       old time/op     new time/op     delta
Template       320ms ± 3%      316ms ± 5%    ~           (p=0.063 n=21+23)
Unicode        162ms ± 9%      161ms ± 6%    ~           (p=0.788 n=25+25)
GoTypes        1.03s ± 4%      1.03s ± 4%    ~           (p=0.929 n=24+25)
Compiler       4.99s ± 3%      4.95s ± 2%  -0.84%        (p=0.011 n=25+23)
MakeBash       40.3s ± 1%      40.3s ± 1%    ~           (p=0.468 n=24+24)

name       old alloc/op    new alloc/op    delta
Template      57.3MB ± 0%     57.0MB ± 0%  -0.51%        (p=0.000 n=25+23)
Unicode       41.1MB ± 0%     41.0MB ± 0%  -0.27%        (p=0.000 n=25+24)
GoTypes        191MB ± 0%      190MB ± 0%  -0.46%        (p=0.000 n=25+25)
Compiler       839MB ± 0%      834MB ± 0%  -0.62%        (p=0.000 n=24+24)

name       old allocs/op   new allocs/op   delta
Template        500k ± 0%       498k ± 0%  -0.42%        (p=0.000 n=25+25)
Unicode         400k ± 0%       399k ± 0%  -0.22%        (p=0.000 n=24+25)
GoTypes        1.50M ± 0%      1.49M ± 0%  -0.41%        (p=0.000 n=23+25)
Compiler       6.04M ± 0%      6.00M ± 0%  -0.59%        (p=0.000 n=25+25)

Change-Id: I7d3f177d1ab4a75a4c047fa465f2eee38747603f
Reviewed-on: https://go-review.googlesource.com/21178
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-26 23:13:32 +00:00
Matthew Dempsky
d53287d0c3 cmd/compile: simplify keydup
Use a type switch instead of calling Val.Ctype (which in turn just
uses a type switch anyway).

Use continue statements to simplify the control flow.

Change-Id: I65c139d706d4d78e5b4ce09d1b1505a3e424496b
Reviewed-on: https://go-review.googlesource.com/21173
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-26 05:15:50 +00:00
Josh Bleecher Snyder
080e2d4320 cmd/compile: don’t generate Nodes for PCDATA
We were allocating two Nodes just to help Naddr
fill in Type and Offset.
Fill them in directly instead.

Passes toolstash -cmp.

name       old time/op     new time/op     delta
Template       324ms ± 5%      320ms ± 5%  -1.34%        (p=0.033 n=25+22)
Unicode        164ms ± 6%      162ms ± 5%    ~           (p=0.152 n=24+23)
GoTypes        1.05s ± 5%      1.05s ± 6%    ~           (p=0.653 n=23+25)
Compiler       5.12s ± 4%      5.06s ± 3%  -1.13%        (p=0.006 n=25+23)
MakeBash       41.8s ± 2%      41.6s ± 3%  -0.65%        (p=0.024 n=24+24)

name       old alloc/op    new alloc/op    delta
Template      57.8MB ± 0%     57.3MB ± 0%  -0.87%        (p=0.000 n=25+25)
Unicode       41.2MB ± 0%     41.1MB ± 0%  -0.29%        (p=0.000 n=24+22)
GoTypes        193MB ± 0%      191MB ± 0%  -0.97%        (p=0.000 n=22+25)
Compiler       850MB ± 0%      840MB ± 0%  -1.28%        (p=0.000 n=25+25)

name       old allocs/op   new allocs/op   delta
Template        506k ± 0%       500k ± 0%  -1.15%        (p=0.000 n=25+25)
Unicode         402k ± 0%       400k ± 0%  -0.37%        (p=0.000 n=24+25)
GoTypes        1.52M ± 0%      1.50M ± 0%  -1.42%        (p=0.000 n=25+25)
Compiler       6.16M ± 0%      6.04M ± 0%  -2.05%        (p=0.000 n=24+25)

Change-Id: Ia80d28b32023a620d9ddf99c1252c16fa6477b3c
Reviewed-on: https://go-review.googlesource.com/21174
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-26 01:36:03 +00:00
Robert Griesemer
135109d241 cmd/compile: reduce slice header allocation when parsing := assignments
The colas function allocates 2 slice headers in each call (via Nodes.Set)
only to throw away those slice headers in the common case where both the
lhs and rhs in "lhs := rhs" have length 1.

Avoid the Nodes.Set calls in those cases. For make.bash, this eliminates
~63,000 slice header allocations.

Also: Minor cleanups in colasdefn.

Change-Id: Ib114a67c3adeb8821868bd71a5e0f5e2e19fcd4f
Reviewed-on: https://go-review.googlesource.com/21170
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-25 23:09:19 +00:00
Mohit Agarwal
edb19aa1cd cmd/go: stat the archive file only when executing the commands
Fixes #14944

Change-Id: I73e0997cb6ebaeced1045b0ddadac893319bd78f
Reviewed-on: https://go-review.googlesource.com/21065
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2016-03-25 18:35:15 +00:00
David Crawshaw
4d920410d2 cmd/compile: avoid pointers in go.string.* symbols
When creating binaries for dynamic linking, the linker moves
read-only data symbols that contain pointers into relro sections.
It is not setup for handling a go.string symbol moving to relro.

Instead of teaching it how (because go.string symbols with pointers
are unusual anyhow), put the data in a type.. section.

Fixes the android builder.

Change-Id: Ica4722d32241643c060923517b90276ff8ac6b07
Reviewed-on: https://go-review.googlesource.com/21110
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-25 16:38:46 +00:00
Josh Bleecher Snyder
41e176fbe0 cmd/compile/ssa: generate less garbage in schedule
Passes toolstash -cmp.

name       old alloc/op    new alloc/op    delta
Template      58.5MB ± 0%     57.8MB ± 0%  -1.15%        (p=0.000 n=10+10)
Unicode       41.3MB ± 0%     41.2MB ± 0%  -0.17%        (p=0.000 n=10+10)
GoTypes        196MB ± 0%      193MB ± 0%  -1.26%        (p=0.000 n=10+10)
Compiler       863MB ± 0%      850MB ± 0%  -1.49%        (p=0.000 n=10+10)

name       old allocs/op   new allocs/op   delta
Template        522k ± 0%       507k ± 0%  -2.99%        (p=0.000 n=10+10)
Unicode         403k ± 0%       401k ± 0%  -0.42%        (p=0.000 n=10+10)
GoTypes        1.58M ± 0%      1.52M ± 0%  -3.61%        (p=0.000 n=10+10)
Compiler       6.47M ± 0%      6.17M ± 0%  -4.62%        (p=0.000 n=10+10)

Change-Id: Ia7a6242e8d226b41966c344d253814dcce6424a8
Reviewed-on: https://go-review.googlesource.com/21141
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-03-25 15:41:10 +00:00
Marcel van Lohuizen
4e31221bd1 cmd/go: remove double space in template
Change-Id: I6113145baa727b9fd103765f74dc5d7af86dfdf8
Reviewed-on: https://go-review.googlesource.com/21131
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-25 09:33:26 +00:00
Marcel van Lohuizen
2e79d7fbee cmd/go: update alldocs.go
Also added go:generate directive.

Change-Id: Ib1f0eddc75e3c47a4d904786a29b964a35b18456
Reviewed-on: https://go-review.googlesource.com/21042
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
2016-03-25 08:49:59 +00:00
Dominik Honnef
fdba5a7544 all: delete dead non-test code
This change removes a lot of dead code. Some of the code has never been
used, not even when it was first commited. The rest shouldn't have
survived refactors.

This change doesn't remove unused routines helpful for debugging, nor
does it remove code that's used in commented out blocks of code that are
only unused temporarily. Furthermore, unused constants weren't removed
when they were part of a set of constants from specifications.

One noteworthy omission from this CL are about 1000 lines of unused code
in cmd/fix, 700 lines of which are the typechecker, which hasn't been
used ever since the pre-Go 1 fixes have been removed. I wasn't sure if
this code should stick around for future uses of cmd/fix or be culled as
well.

Change-Id: Ib714bc7e487edc11ad23ba1c3222d1fd02e4a549
Reviewed-on: https://go-review.googlesource.com/20926
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-25 06:28:13 +00:00
Elias Naur
ba333a3061 cmd/go: remove limits on parallel tasks in the Go command for iOS
Ther darwin/arm{,64} exec wrapper now limits the number of concurrent
executions to 1, so remove the higher level parallel task limit from
the Go command.

Change-Id: Id84f65c3908305bde0452b3c8db6df8c5a8881bb
Reviewed-on: https://go-review.googlesource.com/21100
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-25 01:09:28 +00:00
Elias Naur
95add73abf misc/cgo/testcarchive: fix build
I failed to rebase (and re-test) CL 21102 before submit, which meant
that two extra tests sneaked into testcarchive that still referenced
runtime.GOOS and runtime.GOARCH.

Convert the new tests.

While we're here, make sure pending tasks are flushed before running
the host tests. If not, the "##### misc/cgo/testcarchive" banner
and "PASS" won't show up in the all.bash output.

Change-Id: I41fc4ec9515f9a193fa052f7c31fac452153c897
Reviewed-on: https://go-review.googlesource.com/21106
Run-TryBot: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-25 00:55:07 +00:00
David Crawshaw
24ce64d1a9 cmd/compile, runtime: new static name encoding
Create a byte encoding designed for static Go names.

It is intended to be a compact representation of a name
and optional tag data that can be turned into a Go string
without allocating, and describes whether or not it is
exported without unicode table.

The encoding is described in reflect/type.go:

// The first byte is a bit field containing:
//
//	1<<0 the name is exported
//	1<<1 tag data follows the name
//	1<<2 pkgPath *string follow the name and tag
//
// The next two bytes are the data length:
//
//	 l := uint16(data[1])<<8 | uint16(data[2])
//
// Bytes [3:3+l] are the string data.
//
// If tag data follows then bytes 3+l and 3+l+1 are the tag length,
// with the data following.
//
// If the import path follows, then ptrSize bytes at the end of
// the data form a *string. The import path is only set for concrete
// methods that are defined in a different package than their type.

Shrinks binary sizes:

	cmd/go: 164KB (1.6%)
	jujud:  1.0MB (1.5%)

For #6853.

Change-Id: I46b6591015b17936a443c9efb5009de8dfe8b609
Reviewed-on: https://go-review.googlesource.com/20968
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-25 00:13:49 +00:00
Elias Naur
0a82ed5d7c misc/cgo/testcarchive: re-enable c-archive test on iOS and Android
The c-archive test were recently converted from shell script to Go.
Unfortunately, it also lost the ability to target iOS and Android
that lack C compilers and require exec wrappers.

Compile the c-archive test for the host and run it with the target
GOOS/GOARCH environment. Change the test to rely on go env GOOS
and go env GOARCH instead of runtime.GOOS and runtime.GOARCH.

Fixes #8345

Change-Id: I290ace2f7e96b87c55d99492feb7d660140dcb32
Reviewed-on: https://go-review.googlesource.com/21102
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-24 23:43:27 +00:00
Alexandru Moșoi
afafab3b97 cmd/compile: simplify shifts when the counter fits 6 bits.
In f the extra & 63 is redundant because SHRQ already
looks at the bottom 6 bits only. This is a trick on AMD64
to get rid of CMPQ/SBBQ/ANDQ if one knows that the shift
counter is small.

func f(x uint64, s uint) uint64 {
        return x >> (s & 63)
}

Change-Id: I4861c902168dabec9a6a14a85750246dde94fc08
Reviewed-on: https://go-review.googlesource.com/21073
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-24 20:06:34 +00:00
Alexandru Moșoi
d8ee180ab2 cmd/compile: fold more of CMPQ and ANDQ
g used to produce CMPQ/SBBQ/ANDQ, but f didn't even though
s&15 is at most s&63.

func f(x uint64, s uint) uint64 {
        return x >> (s & 63)
}
func g(x uint64, s uint) uint64 {
        return x >> (s & 15)
}

Change-Id: Iab4a1a6e10b471dead9f1203e9d894677cf07bb2
Reviewed-on: https://go-review.googlesource.com/21048
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-24 19:38:21 +00:00
Josh Bleecher Snyder
fc4358951a cmd/compile: avoid allocating a Nodes for readonly method receivers
We were allocating a Nodes for common method calls
that did not modify the Nodes.
Though there is no clear wall time impact,
this significantly reduces the number of allocations,
so it seems worth doing.

Passes toolstash -cmp.

name       old alloc/op    new alloc/op    delta
Template      59.0MB ± 0%     58.6MB ± 0%   -0.81%        (p=0.000 n=25+25)
Unicode       41.4MB ± 0%     41.3MB ± 0%   -0.18%        (p=0.000 n=25+25)
GoTypes        198MB ± 0%      197MB ± 0%   -0.80%        (p=0.000 n=24+25)
Compiler       875MB ± 0%      865MB ± 0%   -1.09%        (p=0.000 n=25+25)

name       old allocs/op   new allocs/op   delta
Template        581k ± 0%       520k ± 0%  -10.42%        (p=0.000 n=25+25)
Unicode         413k ± 0%       403k ± 0%   -2.30%        (p=0.000 n=25+25)
GoTypes        1.78M ± 0%      1.58M ± 0%  -11.18%        (p=0.000 n=25+25)
Compiler       7.66M ± 0%      6.47M ± 0%  -15.51%        (p=0.000 n=25+25)

Change-Id: I012a9f4b333821bdf61b4f2bdff4ce5c3b5d3057
Reviewed-on: https://go-review.googlesource.com/21056
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-24 16:52:19 +00:00
Elias Naur
570a2b0eec cmd/dist: skip testcarchive test in Android and iOS
CL 20892 converted the misc/cgo/testcarchive test to Go.
Unfortunately, dist does not (yet) support tests running off the host
so the testcarchive is disabled for now.

For #14318

Change-Id: Iab3d0a7b5309187a603b48f22a7fa736f089f89d
Reviewed-on: https://go-review.googlesource.com/21070
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-24 14:15:17 +00:00
Dave Cheney
b9feb91f32 cmd/compile: minor cleanups
Some minor scoping cleanups found by a very old version of grind.

Change-Id: I1d373817586445fc87e38305929097b652696fdd
Reviewed-on: https://go-review.googlesource.com/21064
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-24 11:18:04 +00:00
Dave Cheney
edca4cda88 cmd/compile/internal/gc: remove remaining Nod(OXXX, ...)
Remove almost all the remaining Nod(OXXX, ... ) uses. The performance
change is due entirely to the changes to func temp(*Type). The other
cleanups have no effect, as expected.

I'll address the remaining Nod(OXXX, ...) uses in a followup CL as they
are very sensitive to change.

lucky(~/go/src/cmd/compile) % benchstat /tmp/{old,new}.txt
name      old time/op    new time/op    delta
Template     391ms ± 6%     385ms ± 6%    ~     (p=0.127 n=19+20)
GoTypes      1.27s ± 2%     1.27s ± 2%    ~     (p=0.172 n=19+19)
Compiler     6.17s ± 2%     6.15s ± 2%    ~     (p=0.647 n=19+20)

name      old alloc/op   new alloc/op   delta
Template    63.7MB ± 0%    63.4MB ± 0%  -0.35%  (p=0.000 n=16+20)
GoTypes      219MB ± 0%     218MB ± 0%  -0.38%  (p=0.000 n=20+20)
Compiler     980MB ± 0%     976MB ± 0%  -0.38%  (p=0.000 n=20+20)

name      old allocs/op  new allocs/op  delta
Template      586k ± 0%      584k ± 0%  -0.30%  (p=0.000 n=20+20)
GoTypes      1.80M ± 0%     1.79M ± 0%  -0.31%  (p=0.000 n=20+20)
Compiler     7.74M ± 0%     7.71M ± 0%  -0.34%  (p=0.000 n=20+20)

Change-Id: Ie21a5443c33a23ce30f987bdddec9fe350365d35
Reviewed-on: https://go-review.googlesource.com/21017
Reviewed-by: Ian Lance Taylor <iant@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-24 01:21:51 +00:00
Josh Bleecher Snyder
babc73547e cmd/compile: remove redundant parameter from finishcompare
This is follow-up 3 of 3 to CL 20959.

Passes toolstash -cmp.

Change-Id: I06efded21bbc970cbefa10e8f2cac1ebc6942e1b
Reviewed-on: https://go-review.googlesource.com/21054
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-24 01:17:47 +00:00
Josh Bleecher Snyder
7e8e9abe0a cmd/compile: reduce stutter
This is follow-up 1 of 3 to CL 20959.

Passes toolstash -cmp.

Change-Id: I9bddf7d88333fa4755e03ff8a034a35bd01b7855
Reviewed-on: https://go-review.googlesource.com/21052
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-24 01:17:23 +00:00
Marvin Stenger
bd83cc6dae cmd/compile: prettify loop iterations
This commit replaces some of

for i := len(x) - 1; i >= 0; i-- {...}

style loops, which do not rely on reverse iteration order.

Change-Id: I5542834286562da058200c06e7a173b13760e54d
Reviewed-on: https://go-review.googlesource.com/21044
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-23 22:49:49 +00:00
Brad Fitzpatrick
ca5417b8e0 cmd/compile: reduce some SSA garbage
It's pretty hard to get reliable CPU numbers, even with 50 runs on an
otherwise-idle physical Linux machine, but the garbage reduction
numbers are nice. To get useful time/op numbers, I modified
compilebench to report user CPU time instead of wall time:

name       old time/op     new time/op     delta
Template       547ms ± 6%      557ms ± 5%   +1.80%        (p=0.001 n=49+49)
Unicode        360ms ± 9%      365ms ± 6%     ~           (p=0.094 n=50+45)
GoTypes        1.84s ± 3%      1.82s ± 3%   -1.50%        (p=0.000 n=50+49)
Compiler       9.19s ± 2%      9.02s ± 2%   -1.87%        (p=0.000 n=45+50)

name       old alloc/op    new alloc/op    delta
Template      63.3MB ± 0%     59.1MB ± 0%   -6.72%        (p=0.000 n=50+50)
Unicode       43.1MB ± 0%     42.9MB ± 0%   -0.47%        (p=0.000 n=50+49)
GoTypes        220MB ± 0%      200MB ± 0%   -9.00%        (p=0.000 n=50+50)
Compiler      1.00GB ± 0%     0.89GB ± 0%  -10.09%        (p=0.000 n=50+49)

name       old allocs/op   new allocs/op   delta
Template        681k ± 0%       680k ± 0%   -0.16%        (p=0.000 n=50+48)
Unicode         541k ± 0%       541k ± 0%   -0.02%        (p=0.011 n=48+50)
GoTypes        2.08M ± 0%      2.08M ± 0%   -0.19%        (p=0.000 n=48+50)
Compiler       9.24M ± 0%      9.23M ± 0%   -0.11%        (p=0.000 n=50+50)

Change-Id: I1fac4ebf85a1783e3289c3ffb1ed365442837643
Reviewed-on: https://go-review.googlesource.com/20995
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-23 19:50:02 +00:00
Matthew Dempsky
0659cf6911 cmd/compile: small Mpint method simplifications
Get rid of (*Mpint).Add's "quiet" parameter: it's always set to 0.

Inline (*Mpint).shift into (*Mpint).Lsh and (*Mpint).Rsh. There's no
need for a common shift method that can handle both left or right
shifts based on sign when the higher level abstractions only ever do
one or the other.

Change-Id: Icd3b082413f9193961b6835279e0bd4b6a6a6621
Reviewed-on: https://go-review.googlesource.com/21050
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-23 19:22:53 +00:00
Keith Randall
4c9a470d46 cmd/compile: start on ARM port
Start working on arm port.  Gets close to correct
code for fibonacci:
    func fib(n int) int {
        if n < 2 {
            return n
        }
        return fib(n-1) + fib(n-2)
    }

Still a lot to do, but this is a good starting point.

Cleaned up some arch-specific dependencies in regalloc.

Change-Id: I4301c6c31a8402168e50dcfee8bcf7aee73ea9d5
Reviewed-on: https://go-review.googlesource.com/21000
Reviewed-by: David Chase <drchase@google.com>
2016-03-23 17:46:05 +00:00
David Crawshaw
44d3f89e99 cmd/link, reflect: remove some method type data
Remove reflect type information for unexported methods that do not
satisfy any interface in the program.

Ideally the unexported method would not appear in the method list at
all, but that is tricky because the slice is built by the compiler.

Reduces binary size:

	cmd/go: 81KB (0.8%)
	jujud: 258KB (0.4%)

For #6853.

Change-Id: I25ef8df6907e9ac03b18689d584ea46e7d773043
Reviewed-on: https://go-review.googlesource.com/21033
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-23 17:00:43 +00:00
Alexandru Moșoi
c1892b9c4b cmd/compile: don't simplify nilchecks in loops
khr: Lifting the nil check out of the loop altogether is an admirable
goal, and this rewrite is one step on the way. But without lifting it
out of the loop, the rewrite is just hurting us.

Fixes #14917

Change-Id: Idb917f37d89f50f8e046d5ebd7c092b1e0eb0633
Reviewed-on: https://go-review.googlesource.com/21040
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-23 15:51:55 +00:00
Shahar Kohanim
516c6b4085 cmd/link: Clean up Pcln struct
Removes unnecessary fields from Pcln.

Change-Id: I175049ca749b510eedaf65162355bc4d7a93315e
Reviewed-on: https://go-review.googlesource.com/21041
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-23 13:02:01 +00:00
Dave Cheney
e6beec1fc8 cmd/compile/internal/ssa: avoid string conversion in zcse
Some ssa.Type implementations fell through to gc.Tconv which generated
garbage to produce a string form of the Type.

name      old time/op    new time/op    delta
Template     405ms ± 7%     401ms ± 6%    ~     (p=0.478 n=20+20)
GoTypes      1.32s ± 1%     1.30s ± 2%  -1.27%  (p=0.000 n=19+20)
Compiler     6.07s ± 2%     6.03s ± 2%    ~     (p=0.121 n=20+20)

name      old alloc/op   new alloc/op   delta
Template    63.9MB ± 0%    63.7MB ± 0%  -0.21%  (p=0.000 n=19+20)
GoTypes      220MB ± 0%     219MB ± 0%  -0.21%  (p=0.000 n=20+20)
Compiler     966MB ± 0%     965MB ± 0%  -0.11%  (p=0.000 n=20+20)

name      old allocs/op  new allocs/op  delta
Template      708k ± 0%      701k ± 0%  -0.99%  (p=0.000 n=20+20)
GoTypes      2.20M ± 0%     2.17M ± 0%  -1.43%  (p=0.000 n=17+20)
Compiler     9.45M ± 0%     9.36M ± 0%  -0.91%  (p=0.000 n=20+20)

Change-Id: I5fcc30e0f76a823d1c301d4980b583d716a75ce3
Reviewed-on: https://go-review.googlesource.com/20844
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-23 11:02:26 +00:00
Dave Cheney
a4be24cbe6 cmd/compile/internal/gc: remove redundant Nod(OXXX, ...) pattern
The pattern

    n := Nod(OXXX, nil, nil)
    Nodconst(n, ...)

was a leftover from the C days where n must be heap allocated.

No change in benchmarks, none expected as n escapes anyway.

name      old time/op    new time/op    delta
Template     391ms ± 6%     388ms ± 5%    ~     (p=0.659 n=20+20)
GoTypes      1.27s ± 1%     1.27s ± 2%    ~     (p=0.828 n=18+20)
Compiler     6.16s ± 2%     6.15s ± 1%    ~     (p=0.947 n=20+20)

name      old alloc/op   new alloc/op   delta
Template    63.7MB ± 0%    63.7MB ± 0%    ~     (p=0.414 n=20+20)
GoTypes      219MB ± 0%     219MB ± 0%    ~     (p=0.904 n=20+20)
Compiler     980MB ± 0%     980MB ± 0%  +0.00%  (p=0.007 n=20+19)

name      old allocs/op  new allocs/op  delta
Template      586k ± 0%      586k ± 0%    ~     (p=0.564 n=19+20)
GoTypes      1.80M ± 0%     1.80M ± 0%    ~     (p=0.718 n=20+20)
Compiler     7.74M ± 0%     7.74M ± 0%    ~     (p=0.358 n=20+20)

The reuse of nc in multiple overlapping scopes in walk.go is the worst.

Change-Id: I4ed6a63f7ffbfff68124ad609f6e3a68d95cbbba
Reviewed-on: https://go-review.googlesource.com/21015
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-23 10:59:55 +00:00
Aliaksandr Valialkin
1374515a1c cmd/vet: check lock copy in function calls and return statements
Fixes #14529

Change-Id: I6ed059d279ba0fe12d76416859659f28d61781d2
Reviewed-on: https://go-review.googlesource.com/20832
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-23 07:14:26 +00:00
Ian Lance Taylor
bac0005ec7 misc/cgo/testcarchive: rewrite test from bash to Go
This is to support https://golang.org/cl/18057, which is going to add
Windows support to this directory.  Better to write the test in Go then
to have both test.bash and test.bat.

Update #13494.

Change-Id: I4af7004416309e885049ee60b9470926282f210d
Reviewed-on: https://go-review.googlesource.com/20892
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-23 02:08:49 +00:00
Mikio Hara
bafa0275db cmd/dist: disable misc/cgo/fortran test on dragonfly
Updates #14544.

Change-Id: I24ab8e6f9ad9d290a672216fc2f50f78c3ed8812
Reviewed-on: https://go-review.googlesource.com/21014
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-23 00:43:30 +00:00
Keith Randall
68e86e6dfa cmd/compile: MOVBload and MOVBQZXload are the same op
No need to have both ops when they do the same thing.
Just declare MOVBload to zero extend and we can get rid
of MOVBQZXload.  Same for W and L.

Kind of a followon cleanup for https://go-review.googlesource.com/c/19506/
Should enable an easier fix for #14920

Change-Id: I7cfac909a8ba387f433a6ae75c050740ebb34d42
Reviewed-on: https://go-review.googlesource.com/21004
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-23 00:28:01 +00:00
Shahar Kohanim
90a59d448e cmd/link: use stdlib sort in dodata
Speeds up linking cmd/go by 1.7%

name       old s/op   new s/op   delta
LinkCmdGo  0.58 ± 4%  0.57 ± 5%  -1.74%  (p=0.000 n=96+97)

Change-Id: I7844cf4e2eeac260318de2b6ddf52ce07a6e00f5
Reviewed-on: https://go-review.googlesource.com/20915
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-22 20:14:49 +00:00
Keith Randall
7177cb9fa4 cmd/compile: remove dots from register names
They are kind of useless and are cluttering up
https://go-review.googlesource.com/c/21000/

Change-Id: Iafdec75ada11c7ebdc40540d251fdc514bb00d3d
Reviewed-on: https://go-review.googlesource.com/21001
Reviewed-by: Minux Ma <minux@golang.org>
2016-03-22 17:30:30 +00:00
Robert Griesemer
c12e1b0b2e cmd/compile: update vendored math/big to latest version
This makes the rounding bug fix in math/big for issue 14651 available
to the compiler.

- changes to cmd/compile/internal/big fully automatic via script
- added test case for issue
- updated old test case with correct test data

Fixes #14651.

Change-Id: Iea37a2cd8d3a75f8c96193748b66156a987bbe40
Reviewed-on: https://go-review.googlesource.com/20818
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-22 17:09:29 +00:00
Alexandru Moșoi
e61db3119c cmd/compile: simplify SliceCap when it equals SliceLen
Shows up occassionally, especially after p = p[:8:len(p)]

Updates #14905

Change-Id: Iab35ef2eac57817e6a10c6aaeeb84709e8021641
Reviewed-on: https://go-review.googlesource.com/21025
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-22 16:56:03 +00:00
Josh Bleecher Snyder
34699bc7a8 cmd/compile: reduce use of **Node parameters
Escape analysis has a hard time with tree-like
structures (see #13493 and #14858).
This is unlikely to change.
As a result, when invoking a function that accepts
a **Node parameter, we usually allocate a *Node
on the heap. This happens a whole lot.

This CL changes functions from taking a **Node
to acting more like append: It both modifies
the input and returns a replacement for it.

Because of the cascading nature of escape analysis,
in order to get the benefits, I had to modify
almost all such functions. The remaining functions
are in racewalk and the backend. I would be happy
to update them as well in a separate CL.

This CL was created by manually updating the
function signatures and the directly impacted
bits of code. The callsites were then automatically
updated using a bespoke script:
https://gist.github.com/josharian/046b1be7aceae244de39

For ease of reviewing and future understanding,
this CL is also broken down into four CLs,
mailed separately, which show the manual
and the automated changes separately.
They are CLs 20990, 20991, 20992, and 20993.

Passes toolstash -cmp.

name       old time/op     new time/op     delta
Template       335ms ± 5%      324ms ± 5%   -3.35%        (p=0.000 n=23+24)
Unicode        176ms ± 9%      165ms ± 6%   -6.12%        (p=0.000 n=23+24)
GoTypes        1.10s ± 4%      1.07s ± 2%   -2.77%        (p=0.000 n=24+24)
Compiler       5.31s ± 3%      5.15s ± 3%   -2.95%        (p=0.000 n=24+24)
MakeBash       41.6s ± 1%      41.7s ± 2%     ~           (p=0.586 n=23+23)

name       old alloc/op    new alloc/op    delta
Template      63.3MB ± 0%     62.4MB ± 0%   -1.36%        (p=0.000 n=25+23)
Unicode       42.4MB ± 0%     41.6MB ± 0%   -1.99%        (p=0.000 n=24+25)
GoTypes        220MB ± 0%      217MB ± 0%   -1.11%        (p=0.000 n=25+25)
Compiler       994MB ± 0%      973MB ± 0%   -2.08%        (p=0.000 n=24+25)

name       old allocs/op   new allocs/op   delta
Template        681k ± 0%       574k ± 0%  -15.71%        (p=0.000 n=24+25)
Unicode         518k ± 0%       413k ± 0%  -20.34%        (p=0.000 n=25+24)
GoTypes        2.08M ± 0%      1.78M ± 0%  -14.62%        (p=0.000 n=25+25)
Compiler       9.26M ± 0%      7.64M ± 0%  -17.48%        (p=0.000 n=25+25)

name       old text-bytes  new text-bytes  delta
HelloSize       578k ± 0%       578k ± 0%     ~     (all samples are equal)
CmdGoSize      6.46M ± 0%      6.46M ± 0%     ~     (all samples are equal)

name       old data-bytes  new data-bytes  delta
HelloSize       128k ± 0%       128k ± 0%     ~     (all samples are equal)
CmdGoSize       281k ± 0%       281k ± 0%     ~     (all samples are equal)

name       old exe-bytes   new exe-bytes   delta
HelloSize       921k ± 0%       921k ± 0%     ~     (all samples are equal)
CmdGoSize      9.86M ± 0%      9.86M ± 0%     ~     (all samples are equal)

Change-Id: I277d95bd56d51c166ef7f560647aeaa092f3f475
Reviewed-on: https://go-review.googlesource.com/20959
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-22 14:11:36 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Michael Hudson-Doyle
956e9e6c83 cmd/link: do not add duplicate symbols to Allsym
When building shared libraries, all symbols on Allsym are marked reachable.
What I didn't realize was that this includes the ".dup" symbols created when
"dupok" symbols are read from multiple package files. This breaks now because
deadcode makes some assumptions that fail for these ".dup" symbols, but in any
case was a bad idea -- I suspect this change makes libstd.so a bunch smaller,
but creating it was broken before this CL so I can't be sure.

This change simply stops adding these symbols to Allsym, which might make some
of the many iterations over Allsym the linker does a touch quicker, although
that's not the motivation here.

Add a test that no symbols called ".dup" makes it into the runtime shared
library.

Fixes #14841

Change-Id: I65dd6e88d150a770db2d01b75cfe5db5fd4f8d25
Reviewed-on: https://go-review.googlesource.com/20780
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-17 01:15:19 +00:00
Matthew Dempsky
b2b5e779f5 cmd/compile: ignore receiver parameters in Eqtype
Receiver parameters generally aren't relevant to the function
signature type. In particular:

  1. When checking whether a type's method implements an interface's
     method, we specifically want to ignore the receiver parameters,
     because they'll be different.

  2. When checking interface type equality, interface methods always
     use the same "fakethis" *struct{} type as their receiver.

  3. Finally, method expressions and method values degenerate into
     receiver-less function types.

The only case where we care about receiver types matching is in
addmethod, which is easily handled by adding an extra Eqtype check of
the receiver parameters. Also, added a test for this, since
(surprisingly) there weren't any.

As precedence, go/types.Identical ignores receiver parameters when
comparing go/types.Signature values.

Notably, this allows us to slightly simplify the "implements"
function, which is used for checking whether type/interface t
implements interface iface. Currently, cmd/compile actually works
around Eqtype's receiver parameter checking by creating new throwaway
TFUNC Types without the receiver parameter.

(Worse, the compiler currently only provides APIs to build TFUNC Types
from Nod syntax trees, so building those throwaway types also involves
first building throwaway syntax trees.)

Passes toolstash -cmp.

Change-Id: Ib07289c66feacee284e016bc312e8c5ff674714f
Reviewed-on: https://go-review.googlesource.com/20602
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-17 00:38:15 +00:00
Josh Bleecher Snyder
d33e37a7e3 cmd/compile: further sinit.go cleanup
Follow-up to CL 20674.

Passes toolstash -cmp.

Change-Id: I065fd4cd80d996c1e6566773189401ca4630c1ca
Reviewed-on: https://go-review.googlesource.com/20692
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-03-16 23:28:36 +00:00
Josh Bleecher Snyder
8262564971 cmd/internal/obj/x86: estimate text size
We can’t perfectly predict how large the function
will be, but we can make a safe overestimate.
No significant CPU time changes.

name       old alloc/op    new alloc/op    delta
Template      67.7MB ± 0%     67.5MB ± 0%   -0.24%          (p=0.029 n=4+4)
Unicode       43.9MB ± 0%     43.8MB ± 0%   -0.13%          (p=0.029 n=4+4)
GoTypes        244MB ± 0%      244MB ± 0%   -0.28%          (p=0.029 n=4+4)
Compiler      1.05GB ± 0%     1.05GB ± 0%   -0.38%          (p=0.029 n=4+4)

name       old allocs/op   new allocs/op   delta
Template        795k ± 0%       794k ± 0%   -0.14%          (p=0.029 n=4+4)
Unicode         569k ± 0%       569k ± 0%     ~             (p=0.114 n=4+4)
GoTypes        2.59M ± 0%      2.58M ± 0%   -0.11%          (p=0.029 n=4+4)
Compiler       11.0M ± 0%      11.0M ± 0%   -0.09%          (p=0.029 n=4+4)

Passes toolstash -cmp.

Change-Id: I0a92ab04cba7520540ec58fe7189666d0e771454
Reviewed-on: https://go-review.googlesource.com/20771
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2016-03-16 23:27:19 +00:00
Josh Bleecher Snyder
fb950cd778 cmd/internal/obj: convert Symgrow to a method
Passes toolstash -cmp.

Change-Id: I77a415a4e5d8de7eb902fb0866aaf8783259485a
Reviewed-on: https://go-review.googlesource.com/20770
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 23:25:33 +00:00
James Bardin
5a34472d74 cmd/cgo: add C.CBytes
Add a C.CBytes function to copy a Go byte slice into C memory. This
returns an unsafe.Pointer, since that is what needs to be passed to
C.free, and the data is often opaque bytes anyway.

Fixes #14838

Change-Id: Ic7bc29637eb6f1f5ee409b3898c702a59833a85a
Reviewed-on: https://go-review.googlesource.com/20762
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-16 23:22:10 +00:00
Austin Clements
3e54ca9a46 cmd/compile: omit write barrier when assigning global function
Currently we generate write barriers when the right side of an
assignment is a global function. This doesn't fall into the existing
case of storing an address of a global because we haven't lowered the
function to a pointer yet.

This write barrier is unnecessary, so eliminate it.

Fixes #13901.

Change-Id: Ibc10e00a8803db0fd75224b66ab94c3737842a79
Reviewed-on: https://go-review.googlesource.com/20772
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-16 22:42:45 +00:00
Josh Bleecher Snyder
4e75932cf7 cmd/compile: make sinit consts Go-ish
Passes toolstash -cmp.

Change-Id: Ie11912a16d2cd54500e2f6e84316519b80e7c304
Reviewed-on: https://go-review.googlesource.com/20672
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 22:21:02 +00:00
Josh Bleecher Snyder
e6ed3e8a46 cmd/internal/obj/x86: clean up asm buffer
c2go translated writing and advancing a pointer using slices.
Switch to something more idiomatic.
It is also more efficient, but not enough to matter.

Change-Id: I67709632ac53253615a35365824ae97bbe5458d5
Reviewed-on: https://go-review.googlesource.com/20767
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-16 21:57:15 +00:00
Josh Bleecher Snyder
e248b96d24 cmd/internal/obj/x86: clean up part of span6
Passes toolstash -cmp.

Change-Id: I38eb507de2e9dc2cf01822e420bf31a91fb1b720
Reviewed-on: https://go-review.googlesource.com/20766
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 21:56:57 +00:00
Robert Griesemer
c1a4fe8d57 cmd/compile: remove dead code handling '~' operator
The parser code was not reachable ever since some of the lexer cleanups.
We could recognize '~' in the lexer, complain, and return a '^' instead,
but it's been a few years since Go was new and this may have been a use-
ful error. The lexer complains with "illegal character U+007E '~'" which
is good enough.

For #13244.

Change-Id: Ie3283738486eb6f8462d594f2728ac98333c0520
Reviewed-on: https://go-review.googlesource.com/20768
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-16 21:39:49 +00:00
Josh Bleecher Snyder
826831acf7 cmd/compile: move LSym.RefIdx for better packing
Change-Id: I0516d49ee8381c5e022d77c2fb41515c01c8a631
Reviewed-on: https://go-review.googlesource.com/20764
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-16 20:52:33 +00:00
Josh Bleecher Snyder
31a9e50524 cmd/internal/obj: remove LSym.Etext
Use a local variable instead.

Passes toolstash -cmp.

Change-Id: I9623a40ff0d568f11afd1279b6aaa1c33eda644c
Reviewed-on: https://go-review.googlesource.com/20730
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-16 20:52:21 +00:00
Josh Bleecher Snyder
dd2ba0c7a7 cmd/internal/obj: remove LSym.Next
Instead, use a slice.

Passes toolstash -cmp.

Change-Id: I889fdb4ae997416f907522f549b96506be13bec7
Reviewed-on: https://go-review.googlesource.com/20699
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 20:40:58 +00:00
Josh Bleecher Snyder
61b9315d37 cmd/internal/obj: remove LSym.Value
It is unused.

Passes toolstash -cmp.

Change-Id: I22ae2bb432ce6be377dea43cf018ffccb6e95f37
Reviewed-on: https://go-review.googlesource.com/20698
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 20:40:50 +00:00
Austin Clements
26594c3dfd runtime: use indexes for select lock order
Currently the select lock order is a []*hchan. We're going to need to
refer to things other than the channel itself in lock order shortly,
so switch this to a []uint16 of indexes into the select cases. This
parallels the existing representation for the poll order.

Change-Id: I89262223fe20b4ddf5321592655ba9eac489cda1
Reviewed-on: https://go-review.googlesource.com/20036
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 20:13:05 +00:00
Austin Clements
e4a95b6343 runtime: record channel in sudog
Given a G, there's currently no way to find the channel it's blocking
on. We'll need this information to fix a (probably theoretical) bug in
select and to implement concurrent stack shrinking, so record the
channel in the sudog.

For #12967.

Change-Id: If8fb63a140f1d07175818824d08c0ebeec2bdf66
Reviewed-on: https://go-review.googlesource.com/20035
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 20:13:02 +00:00
Robert Griesemer
bb3b10214d cmd/compile: faster parameter parsing with no OKEY nodes
Step 2 of stream-lining parameter parsing

- do parameter validity checks in parser
- two passes instead of multiple (and theoretically quadratic) passes
  when checking parameters
- removes the need for OKEY and some ONONAME nodes in those passes

This removes allocation of ~123K OKEY (incl. some ONONAME) nodes
out of a total of ~10M allocated nodes when running make.bash, or
a reduction of the number of alloacted nodes by ~1.2%.

Change-Id: I4a8ec578d0ee2a7b99892ac6b92e56f8e0415f03
Reviewed-on: https://go-review.googlesource.com/20748
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
2016-03-16 18:54:31 +00:00
Robert Griesemer
9f301643bd cmd/compile: factor parameter parsing
Step 1 of streamlining parameter parsing.

Change-Id: If9fd38295ccc08aafc7f1d26188d0926dd73058b
Reviewed-on: https://go-review.googlesource.com/20747
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 15:56:36 +00:00
Todd Neal
c8b148e7a5 cmd/compile: fold constants from lsh/rsh/lsh and rsh/lsh/rsh
Fixes #14825

Change-Id: Ib44d80579a55c15d75ea2ad1ef54efa6ca66a9a6
Reviewed-on: https://go-review.googlesource.com/20745
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 11:40:20 +00:00
Aliaksandr Valialkin
fee86e4aa8 cmd/vet: added some missing copylock checks
Fixes #14664

Change-Id: I8bda2435857772f590859808904c48d768b87d46
Reviewed-on: https://go-review.googlesource.com/20254
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-16 05:12:48 +00:00
Todd Neal
763afe13b9 cmd/compile: change logging of spills for regalloc to Warnl format
Change-Id: I01c000ff3f6dc6b0ed691e289eeef0fa61500337
Reviewed-on: https://go-review.googlesource.com/20744
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-16 02:50:13 +00:00
Todd Neal
8edb72587f cmd/compile: add logging to critical and phielim
Change-Id: Ieefeceea40bd29657fd519368b0920dad8443844
Reviewed-on: https://go-review.googlesource.com/20712
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-15 22:53:12 +00:00
Keith Randall
5305a329d8 cmd/compile: turn off SSA internal consistency checks
They've been on for a few weeks of general use and nothing
has tripped up on them yet.

Makes the compiler ~18% faster.

Change-Id: I42d7bbc0581597f9cf4fb28989847814c81b08a2
Reviewed-on: https://go-review.googlesource.com/20741
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-15 22:25:48 +00:00
Matthew Dempsky
63142027de cmd: collapse internal/obj/fmt.go into compile/internal/gc/fmt.go
The obj.Fmt* values are only used by gc/fmt.go, so just move them
there. Also, add comments documenting the correspondance between
FmtFoo names and their flag characters to make understanding the
existing documentation slightly less confusing.

While here, add a new FmtFlag named type to represent these values.

Change-Id: I9631214b892557d094823f1ac575d0c43a84007b
Reviewed-on: https://go-review.googlesource.com/20717
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-15 22:08:05 +00:00
Wedson Almeida Filho
8e7072ca83 sync: new Cond implementation
Change Cond implementation to use a notification list such that waiters
can first register for a notification, release the lock, then actually
wait. Signalers never have to park anymore.

This is intended to address an issue in the previous implementation
where Broadcast could fail to signal all waiters.

Results of the existing benchmark are below.

                                          Original          New  Diff
BenchmarkCond1-48        2000000               745 ns/op    755 +1.3%
BenchmarkCond2-48        1000000              1545 ns/op   1532 -0.8%
BenchmarkCond4-48         300000              3833 ns/op   3896 +1.6%
BenchmarkCond8-48         200000             10049 ns/op  10257 +2.1%
BenchmarkCond16-48        100000             21123 ns/op  21236 +0.5%
BenchmarkCond32-48         30000             40393 ns/op  41097 +1.7%

Fixes #14064

Change-Id: I083466d61593a791a034df61f5305adfb8f1c7f9
Reviewed-on: https://go-review.googlesource.com/18892
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Caleb Spare <cespare@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-15 22:01:20 +00:00
David Crawshaw
f2772a4935 cmd/compile: compute second method type at runtime
The type information for a method includes two variants: a func
without the receiver, and a func with the receiver as the first
parameter. The former is used as part of the dynamic interface
checks, but the latter is only returned as a type in the
reflect.Method struct.

Instead of computing it at compile time, construct it at run time
with reflect.FuncOf.

Using cl/20701 as a baseline,

	cmd/go: -480KB, (4.4%)
	jujud:  -5.6MB, (7.8%)

For #6853.

Change-Id: I1b8c73f3ab894735f53d00cb9c0b506d84d54e92
Reviewed-on: https://go-review.googlesource.com/20709
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-15 19:57:40 +00:00
Matthew Dempsky
1b9f168f73 cmd/compile: use int for field index
All of a struct's fields have to fit into memory anyway, so index them
with int instead of int64.  This also makes it nicer for
cmd/compile/internal/gc to reuse the same NumFields function.

Change-Id: I210be804a0c33370ec9977414918c02c675b0fbe
Reviewed-on: https://go-review.googlesource.com/20691
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-15 19:56:43 +00:00
David Crawshaw
d06b0db5bd cmd/link: when pruning methods also prune funcType
Remove method type information for pruned methods from any program
that does not reflect on methods. This can be a significant saving:

	addr2line: -310KB (8.8%)

A future update might want to consider a more aggressive variant of
this: setting the Type and Func fields of reflect.Method to nil for
unexported methods. That would shrink cmd/go by 2% and jujud by 2.6%
but could be considered an API change. So this CL sticks to the
uncontroversial change.

For #6853.

Change-Id: I5d186d9f822dc118ee89dc572c4912a3b3c72577
Reviewed-on: https://go-review.googlesource.com/20701
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-15 19:41:17 +00:00
Keith Randall
41f9f6f471 cmd/compile: fix load-combining
Make sure symbol gets carried along by load-combining rule.
Add the new load into the right block where we know that
mem is live.

Use auxInt field to carry i along instead of an explicit ADDQ.

Incorporate LEA ops into MOVBQZX and friends.

Change-Id: I587f7c6120b98fd2a0d48ddd6ddd13345d4421b4
Reviewed-on: https://go-review.googlesource.com/20732
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-15 19:18:13 +00:00
Matthew Dempsky
f6fab93a46 cmd/compile: make Type.Field stricter about bounds checking
Turns out there were only two call sites that expected
t.Field(t.NumFields()) to return nil.

Change-Id: I4679988d38ee9d7c9d89883537a17046717b2a77
Reviewed-on: https://go-review.googlesource.com/20731
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-15 18:46:03 +00:00
Dave Cheney
cea5d26aa2 cmd/compile/internal/gc: remove Thearch.Linkarchinit
Change-Id: I8e990204c7a1e65d6b8e4262f6b5b9bd0cb3540c
Reviewed-on: https://go-review.googlesource.com/20725
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-15 15:29:39 +00:00
Dave Cheney
70090654de cmd/compile/internal/gc: tidy plive.go
Make boolean looking things boolean.

Change-Id: I8d1c0a32b471412b25a72908c7da6458d7bbe65b
Reviewed-on: https://go-review.googlesource.com/20723
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-15 15:27:21 +00:00
Shahar Kohanim
3648d2d4cd cmd/link, cmd/compile: Add symbol references to object file.
Symbols in the object file currently refer to each other using symbol name
and version. Referring to the same symbol many times in an object file takes
up space and causes redundant map lookups. Instead write out a list of unique
symbol references and have symbols refer to each other using indexes into this
list.

Credit to Michael Hudson-Doyle for kicking this off.

Reduces pkg/linux_amd64 size by 30% from 61MB to 43MB

name       old s/op   new s/op   delta
LinkCmdGo  0.74 ± 3%  0.63 ± 4%  -15.22%  (p=0.000 n=20+20)
LinkJuju   6.38 ± 6%  5.73 ± 6%  -10.16%  (p=0.000 n=20+19)

Change-Id: I7e101a0c80b8e673a3ba688295e6f80ea04e1cfb
Reviewed-on: https://go-review.googlesource.com/20099
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-15 13:00:07 +00:00
Dave Cheney
ac47f66abc cmd/compile/internal: clean up galign.go constants
Move the C header style architecture constants to the per arch Main
methods.

Change-Id: Ie7ff39baa275ceaa6680e7d16441ca9f0aa12597
Reviewed-on: https://go-review.googlesource.com/20722
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-15 07:13:04 +00:00
Dave Cheney
04f23b6428 cmd/internal/obj: remove dead code
Partial automatic cleanup driven by Dominik Honnef's unused tool.

As _lookup now only has one caller, merge it into the caller and remove
the conditional create logic.

Change-Id: I2ea354d9d4b32a19905271eca74725231b6d8a93
Reviewed-on: https://go-review.googlesource.com/20589
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-15 06:02:13 +00:00
Josh Bleecher Snyder
11a80860ad cmd/compile: move testdclstack out of the xdcl_list loop
This is a band-aid, but it fixes the problem
until a deeper fix is in place.

Testing with genpkg -n 50000, I see:

Before:

      154.67 real       184.66 user         3.15 sys

After:

       61.82 real        96.99 user         2.17 sys


Fixes #14781.

Change-Id: I24c7822d60c289bdd6a18a7840b984954c95f7d4
Reviewed-on: https://go-review.googlesource.com/20696
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-15 04:15:41 +00:00
Jeremy Jackins
80f2aff9ef cmd/compile: clean up C-style variable declarations in plive.go
Change-Id: I928f51a1fe4830a81d4f5d3eb572785e06a75b77
Reviewed-on: https://go-review.googlesource.com/20581
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-15 00:57:54 +00:00
Robert Griesemer
eb4d1be285 cmd/compile: keep variable numbering for inlineable exported functions
Another step towards hooking up exported inlined function bodies.

Change-Id: Ib8094b03ac7970fee0e51b5826b5f8aa232e23fb
Reviewed-on: https://go-review.googlesource.com/20605
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
2016-03-14 21:56:25 +00:00
Matthew Dempsky
2e9369067b cmd/compile: replace TFIELD kind with separate Field type
Allows removing a bunch of unnecessary fields.

Passes toolstash/buildall.

Change-Id: Iec2492920e1c3ef352a9bf4296c74a55d9cc9ad6
Reviewed-on: https://go-review.googlesource.com/20677
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-14 21:30:41 +00:00
Matthew Dempsky
2a46b08a02 cmd/dist: build bootstrap toolchain with -l
Workaround Go 1.4 compiler bugs.  See discussion at:
https://groups.google.com/d/msg/golang-dev/Ss7mCKsvk8w/Gsq7VYI0AwAJ

Change-Id: I842335fddffb67a6e21c000fe5bef258ea61c77a
Reviewed-on: https://go-review.googlesource.com/20690
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-14 21:30:33 +00:00
Matthew Dempsky
c278f9302e cmd/compile: stop storing TFIELD types in Node.Type
Currently, the only use for this is on the Left side of OKEY nodes
within struct literals.  esc and fmt only care so they can recognize
that the ONAME nodes are actually field names, which need special
handling.

sinit additionally needs to know the field's offset within the struct,
which we can provide via Xoffset.

Passes toolstash/buildall.

Change-Id: I362d965e161f4d80fcd9c9bae0dfacc657dc0b29
Reviewed-on: https://go-review.googlesource.com/20676
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-14 21:12:29 +00:00
Josh Bleecher Snyder
9bffcf382b cmd/compile: minor cleanup in sinit.go
Passes toolstash -cmp.

Change-Id: Id16009ef3ef1173eafe0f0c578dbf325b61aab3c
Reviewed-on: https://go-review.googlesource.com/20674
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-14 21:03:33 +00:00
Matthew Dempsky
0d2e92c2ca cmd/compile: add Fields field to Type
Switch TSTRUCT and TINTER to use Fields instead of Type, which wrings
out the remaining few direct uses of the latter.

Preparation for converting fields to use a separate "Field" type.

Passes toolstash/buildall.

Change-Id: I5a2ea7e159d0dde1be2c9afafc10a8f739d95743
Reviewed-on: https://go-review.googlesource.com/20675
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-14 20:44:45 +00:00
Josh Bleecher Snyder
7971864267 cmd/compile: simplify InitPlan
Passes toolstash -cmp.

Change-Id: Iaa0d78c2552efb29e67f6c99c7287f8566027add
Reviewed-on: https://go-review.googlesource.com/20673
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-14 20:44:02 +00:00
Josh Bleecher Snyder
e59c1729ba cmd/compile: convert data siz to int
Follow-up to CL 20645.

Passes toolstash -cmp.

Change-Id: Idc63c41b2be2d52e3a6ac59b3a12eb41aa2efbed
Reviewed-on: https://go-review.googlesource.com/20670
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-14 20:22:21 +00:00
Josh Bleecher Snyder
57faad6677 cmd/compile: fix CTNIL static data comments
Change-Id: I434f881c10dec41a802641db8873abf1353beba2
Reviewed-on: https://go-review.googlesource.com/20671
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-14 19:55:30 +00:00
Josh Bleecher Snyder
a0232ea0dd cmd/compile: allow deduplication of long strings
String symbols' names used to appear in the final binary.
Using a string's contents as it's symbol's name
was a thus a bad idea if the string's name was long.
Recent improvements by crawshaw have changed that.

Instead of placing long strings behind opaque names
in local packages, place them in the global string
package and make them content-addressable.
Symbol names still occur in the object files,
so use a hash to avoid needless length there.

Reduces the size of cmd/go by 30k.

Change-Id: Ifdbbaf47bf44352418c90ddd903d5106e48db4f1
Reviewed-on: https://go-review.googlesource.com/20524
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-14 19:54:58 +00:00
Alexandru Moșoi
13f74db304 cmd/compile: fix no-opt build after moving decomposing user functions
decompose-builtin pass requires an opt pass, but -N disables
late-opt, the only opt pass (out of two) that happens
after decompose-builtin.  This CL enables both 'opt' and 'late opt'
passes. The extra compile time for 'late opt' in negligible
since most rewrites were already done in the first 'opt'
(also measured before). We should put some effort in splitting the
generic rules into required and optional.

Also update generic.rules comments about lowering
of StringMake and SliceMake.

Tested with GO_GCFLAGS=-N ./all.bash

Change-Id: I92999681aaa02587b6dc6e32ce997a91f1fc9499
Reviewed-on: https://go-review.googlesource.com/20682
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-14 18:44:10 +00:00
Michael Pratt
a4e31d42ee cmd/compile: remove amd64 code from package gc and the core gen tool
Parts of the SSA compiler in package gc contain amd64-specific code,
most notably Prog generation. Move this code into package amd64, so that
other architectures can be added more easily.

In package gc, this change is just moving code. There are no functional
changes or even any larger structural changes beyond changing function
names (mostly for export).

In the cmd/compile/internal/ssa/gen tool, more information is included
in arch to remove the AMD64-specific behavior in the main portion of the
tool. The generated opGen.go is identical.

Change-Id: I8eb37c6e6df6de1b65fa7dab6f3bc32c29daf643
Reviewed-on: https://go-review.googlesource.com/20609
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-14 16:59:03 +00:00
Todd Neal
98b88de56f cmd/compile: change the type of ssa Warnl line number
Line numbers are always int32, so the Warnl function should take the
line number as an int32 as well.  This matches gc.Warnl and removes
a cast every place it's used.

Change-Id: I5d6201e640d52ec390eb7174f8fd8c438d4efe58
Reviewed-on: https://go-review.googlesource.com/20662
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-14 11:04:40 +00:00
Matthew Dempsky
2dcbbbd193 cmd/internal/obj, cmd/asm: get rid of obj.ADATA
Just recognize "DATA" as a special pseudo op word in the assembler
directly.

Change-Id: I508e111fd71f561efa600ad69567a7089a57adb2
Reviewed-on: https://go-review.googlesource.com/20648
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-03-14 05:13:47 +00:00
Matthew Dempsky
edde955d7f cmd/internal/obj: support arbitrarily sized string data
Updates #14786.

Change-Id: I5fe889886f772167386cd10390ac50abc1383937
Reviewed-on: https://go-review.googlesource.com/20607
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-03-14 05:13:31 +00:00
Josh Bleecher Snyder
4f753e77f1 cmd/all: stop generating ADATA Progs
The only remaining place that generated ADATA
Prog was the assembler. Stop, and delete some
now-dead code.

Passes toolstash -cmp.

Change-Id: I26578ff1b4868e98562b44f69d909c083e96f8d5
Reviewed-on: https://go-review.googlesource.com/20646
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-14 02:22:49 +00:00
Josh Bleecher Snyder
7c18f8cdc3 cmd/compile: write some static data directly
Instead of generating ADATA instructions for
static data, write that static data directly
into the linker sym.
This is considerably more efficient.
The assembler still generates
ADATA instructions, so the ADATA machinery
cannot be dismantled yet. (Future work.)
Skipping ADATA has a significant impact
compiling the unicode package, which has lots
of static data.

name     old time/op    new time/op    delta
Unicode     227ms ±10%     192ms ± 4%  -15.61%  (p=0.000 n=29+30)

name     old alloc/op   new alloc/op   delta
Unicode    51.0MB ± 0%    45.8MB ± 0%  -10.29%  (p=0.000 n=30+30)

name     old allocs/op  new allocs/op  delta
Unicode      610k ± 0%      578k ± 0%   -5.29%  (p=0.000 n=30+30)

This does not pass toolstash -cmp, because
this changes the order in which some relocations
get added, and thus it changes the output from
the compiler. It is not worth the execution time
to sort the relocs in the normal case.

However, compiling with -S -v generates identical
output if (1) you suppress printing of ADATA progs
in flushplist and (2) you suppress printing of
cpu timing. It is reasonable to suppress printing
the ADATA progs, since the data itself is dumped
later. I am therefore fairly confident that all
changes are superficial and non-functional.

Fixes #14786, although there's more to do
in general.

Change-Id: I8dfabe7b423b31a30e516cfdf005b62a2e9ccd82
Reviewed-on: https://go-review.googlesource.com/20645
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-14 02:21:43 +00:00
Matthew Dempsky
d1341d6cf3 cmd/compile, runtime: eliminate growslice_n
Fixes #11419.

Change-Id: I7935a253e3e96191a33f5041bab203ecc5f0c976
Reviewed-on: https://go-review.googlesource.com/20647
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-13 23:34:31 +00:00
Alexandru Moșoi
8ec80176d4 cmd/compile: move decompose builtin closer to late opt
* Shaves about 10k from pkg/tools/linux_amd64.
* Was suggested by drchase before
* Found by looking at ssa output of #14758

Change-Id: If2c4ddf3b2603d4dfd8fb4d9199b9a3dcb05b17d
Reviewed-on: https://go-review.googlesource.com/20570
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-13 22:12:01 +00:00
Josh Bleecher Snyder
fdc04223c5 cmd/compile: clean up savedata
Simplify function signature.
Remove unused Ctxt field Enforce_data_order.

Passes toolstash -cmp.

Change-Id: I5caa270ca9ae725708fe415b2c978b5f40780255
Reviewed-on: https://go-review.googlesource.com/20644
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-13 21:11:27 +00:00
Josh Bleecher Snyder
e8fab405cb cmd/compile: minor cleanup
Passes toolstash -cmp.

Change-Id: Ib8c76081956e1d4eecef16b82bc8d527d7849d7e
Reviewed-on: https://go-review.googlesource.com/20643
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-13 21:06:25 +00:00
Egon Elbre
69f49e1cbc cmd/pprof: fix crash with invalid source
pprof crashed when running with:

     go tool pprof %INVALID

Change-Id: I47c2a4da7273e3a97a833f320a650b8c6b59d6b9
Reviewed-on: https://go-review.googlesource.com/20632
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-13 20:38:16 +00:00
Josh Bleecher Snyder
af1c29c1c1 cmd/internal/obj: sort relocs by off when printing
This makes the output of compiling with -S more
stable in the face of unimportant variation in the
order in which relocs are generated.
It is also more pleasant to read the relocs when
they are sorted.

Also, do some minor cleanup.

For #14786

Change-Id: Id92020b13fd21777dfb5b29c2722c3b2eb27001b
Reviewed-on: https://go-review.googlesource.com/20641
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-13 20:31:40 +00:00
Matthew Dempsky
a2a48069fe cmd/compile: rework how fieldtrack is implemented
Shrinks gc.Type and gc.Func slightly.

Passes "GOEXPERIMENT=fieldtrack ./all.bash" and "go test -a
-toolexec='toolstash -cmp' -ldflags=-k=rsc.io/tmp/fieldtrack.tracked
rsc.io/tmp/fieldtrack".

Change-Id: I785fe8a18eb830d9867d34247e4cd41a6a7921d4
Reviewed-on: https://go-review.googlesource.com/20557
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-13 16:58:00 +00:00
Todd Neal
f6ceed2cab cmd/compile: const folding for float32/64
Split the auxFloat type into 32/64 bit versions and perform checking for
exactly representable float32 values.  Perform const folding on
float32/64.  Comment out some const negation rules that the frontend
already performs.

Change-Id: Ib3f8d59fa8b30e50fe0267786cfb3c50a06169d2
Reviewed-on: https://go-review.googlesource.com/20568
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-13 13:32:41 +00:00
Alexandru Moșoi
cd798dcb88 cmd/compile/internal/ssa: generalize prove to all booleans
* Refacts a bit saving and restoring parents restrictions
* Shaves ~100k from pkg/tools/linux_amd64,
but most of the savings come from the rewrite rules.
* Improves on the following artificial test case:
func f1(a4 bool, a6 bool) bool {
  return a6 || (a6 || (a6 || a4)) || (a6 || (a4 || a6 || (false || a6)))
}

Change-Id: I714000f75a37a3a6617c6e6834c75bd23674215f
Reviewed-on: https://go-review.googlesource.com/20306
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-13 12:05:41 +00:00
Todd Neal
40bfec0022 cmd/compile: reuse auto symbols during ssa construction
Reuse auto symbols so cse can eliminate OpAddrs that refer to
them.

Change-Id: I69e6a3f77a3a33946459cf8c6eccf223f6125048
Reviewed-on: https://go-review.googlesource.com/20569
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-12 13:44:49 +00:00
Shahar Kohanim
eb57a1dd75 cmd/link: use string map for symbols with single version
Reduces link time by ~3%

Results with gc on:
name       old s/op   new s/op   delta
LinkCmdGo  0.82 ± 2%  0.78 ± 2%  -3.90%  (p=0.000 n=17+17)
LinkJuju   7.11 ± 7%  6.87 ± 6%  -3.41%  (p=0.012 n=20+19)

Less noisy results with gc turned off:
name       old s/op   new s/op   delta
LinkCmdGo  0.66 ± 2%  0.64 ± 2%  -3.14%  (p=0.000 n=18+20)
LinkJuju   5.91 ± 1%  5.72 ± 2%  -3.17%  (p=0.000 n=20+20)

Change-Id: I4cac7933b0b22d0aee18255e1ab54550ad364593
Reviewed-on: https://go-review.googlesource.com/20478
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
2016-03-12 11:11:10 +00:00
Alex Brainman
bb48b864b1 cmd/link: rewrite pe symbol table generating code
Every go executable has COFF symbol table appended at the end. The table is
used by nm and addr2line and contains all symbols present in the executable.
The table is quite large. For example, my go.exe has 11736 records.

To generate symbol table:
1) we walk "all symbols" list to count symbols we want for the table;
2) we allocate large global array of COFFSym structs (32 bytes each)
   to fit our symbols;
3) we walk "all symbols" list again to fill our array with contents;
4) we iterate over our global array to write all records to the file.

This CL changes all these steps with single step:
- walk "all symbols" list and write each COFF symbol table record to
  the file as we go.

I hope new version is faster and uses less garbage, but I don't know
how to benchmark this.

Change-Id: Ie4870583250131ea4428e0e83a0696c9df1794e0
Reviewed-on: https://go-review.googlesource.com/20580
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
2016-03-12 07:07:48 +00:00
Keith Randall
77b527e283 cmd/compile: strength reduce *24
We use *24 a lot for pointer arithmetic when accessing slices
of slices ([][]T).  Rewrite to use an LEA and a shift.
The shift will likely be free, as it often gets folded into
an indexed load/store.

Update #14606

Change-Id: Ie0bf6dc1093876efd57e88ce5f62c26a9bf21cec
Reviewed-on: https://go-review.googlesource.com/20567
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2016-03-12 02:58:45 +00:00
Robert Griesemer
68c86a0096 cmd/compile: remove structpkg global variable
The structpkg global variable was only used to verify internal
consistency when declaring methods during import. Track the
value in the parser and binary importer directly and pass it
to the relevant function as an argument.

Change-Id: I7e5e006f9046d84f9a3959616f073798fda36c97
Reviewed-on: https://go-review.googlesource.com/20606
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-12 01:39:40 +00:00
David Crawshaw
7c546566c3 cmd/compile: compute number of arguments correctly
The outCount value includes a flag bit for dotdotdot.

If we have this count incorrect, then the offset for the
methodset *rtype are in the wrong place.

Fixes #14783

Change-Id: If5acb16af08d4ffe36c8c9ee389c32f2712ce757
Reviewed-on: https://go-review.googlesource.com/20566
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-12 01:23:25 +00:00
Ian Lance Taylor
1220ac27ce cmd/compile: don't copy all type nodes for builtin functions
Only copy the ones that actually change.  Also combine deep and substAny
functions into one.  The Type.Copyany field is now unused, so remove it.

Passes toolstash -cmp.

Change-Id: Id28a9bf144ecf3e522aad00496f8a21ae2b74680
Reviewed-on: https://go-review.googlesource.com/20600
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2016-03-12 00:30:44 +00:00
Matthew Dempsky
9d7b2b7b10 cmd/compile: move universe block code into new universe.go
Move lexinit, typeinit, lexinit1, and lexfini into new universe.go
file, and give them a more idiomatic and descriptive API. No code
changes.

Change-Id: I0e9b25dcc86ad10f4b990dc02bd33477b488cc85
Reviewed-on: https://go-review.googlesource.com/20604
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-11 23:56:56 +00:00
Robert Griesemer
76461c93a1 cmd/compile: move lexn and lexname into lex.go (cleanup)
Missed these two declarations in the previous cleanup.

Change-Id: I54ff3accd387dd90e12847daccf4477169797f81
Reviewed-on: https://go-review.googlesource.com/20603
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-11 23:26:59 +00:00
Robert Griesemer
998b6dd75c cmd/compile: move lexer into separate file (cleanup)
This is really moving all the non-lexer pieces out of lex.go
into main.go. It's always been confusing that the top-most
compiler entry point (Main) is in the same file with the
lexer. Both files remain of substantial size (> 1000 lines),
which justifies this even more.

No other changes.

Change-Id: I03895589d5e3cc2340580350bbc1420539893dfc
Reviewed-on: https://go-review.googlesource.com/20601
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-11 22:59:57 +00:00
Robert Griesemer
e78ff3823e cmd/compile: simplify lexer.ungetr
Change-Id: Id041c1b2d364aecd7a6613a53237f7de2c650a7e
Reviewed-on: https://go-review.googlesource.com/20599
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-11 22:17:01 +00:00
David Crawshaw
e2836935bb cmd/link: treat reflect.Value.Method like Call
Fixes #14740

Change-Id: Iad8d971c21977b0a1f4ef55a08bb180a8125e976
Reviewed-on: https://go-review.googlesource.com/20562
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-11 22:07:02 +00:00
David Crawshaw
5aa5db7593 cmd/compile: use bufio.Reader directly in lexer
Removes an intermediate layer of functions that was clogging up a
corner of the compiler's profile graph.

I can't measure a performance improvement running a large build
like jujud, but the profile reports less total time spent in
gc.(*lexer).getr.

Change-Id: I3000585cfcb0f9729d3a3859e9023690a6528591
Reviewed-on: https://go-review.googlesource.com/20565
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-11 21:27:23 +00:00
David Crawshaw
cc158403d6 cmd/compile: track reflect.Type.Method in deadcode
In addition to reflect.Value.Call, exported methods can be invoked
by the Func value in the reflect.Method struct. This CL has the
compiler track what functions get access to a legitimate reflect.Method
struct by looking for interface calls to either of:

	Method(int) reflect.Method
	MethodByName(string) (reflect.Method, bool)

This is a little overly conservative. If a user implements a type
with one of these methods without using the underlying calls on
reflect.Type, the linker will assume the worst and include all
exported methods. But it's cheap.

No change to any of the binary sizes reported in cl/20483.

For #14740

Change-Id: Ie17786395d0453ce0384d8b240ecb043b7726137
Reviewed-on: https://go-review.googlesource.com/20489
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-11 21:19:20 +00:00
Josh Bleecher Snyder
4112f0f7e6 cmd/compile: improve go.importpath.* docs
While we're here, remove a bit of dead code.

Change-Id: I1344bb41e5d368825ca5748189382f9e7023c59a
Reviewed-on: https://go-review.googlesource.com/20596
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-11 20:50:10 +00:00
Josh Bleecher Snyder
2ac8555d57 cmd/link: tidy up rdsym
Use an early return. Check errors. Deduplicate.

Change-Id: Iabefd563b5ef82a16fab4791277630804fd09003
Reviewed-on: https://go-review.googlesource.com/20597
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-11 20:49:53 +00:00
Matthew Dempsky
de4317cbd7 cmd/compile: eliminate uses of Type.Down in bexport.go
Change-Id: I298b9d389ac33a24365f4c06a122c3af989906c0
Reviewed-on: https://go-review.googlesource.com/20594
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-11 18:25:52 +00:00
Matthew Dempsky
d9bb693960 cmd/compile: sort interface methods in tointerface0
Might as well sort them while they're still in a slice.

Change-Id: I40c25ddc5c054dcb4da2aeefa79947967609d599
Reviewed-on: https://go-review.googlesource.com/20591
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-11 18:25:42 +00:00
Michael Munday
d05773ce73 cmd/internal/obj: fix nil pointer dereference in Dconv
p can be nil in Dconv so we need to do a check before dereferencing
it. Fixes a problem I was having running toolstash.

Change-Id: I34d6d278b319583d8454c2342ac88e054fc4b641
Reviewed-on: https://go-review.googlesource.com/20595
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-11 16:58:41 +00:00
Matthew Dempsky
f973e79d09 cmd/compile: move InitPlan and InitEntry into sinit.go
I don't know what they're used for, but that's the only file they're
referenced in.

Change-Id: Ie39d7d4621e2d5224408243b5789597ca0dc14be
Reviewed-on: https://go-review.googlesource.com/20593
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-03-11 09:09:51 +00:00
Matthew Dempsky
3621600c92 cmd/compile: give "magic" code its own source file
This code is an eye sore to keep scrolling past in subr.go, so move it
out of the way.

Change-Id: I8eafc1725d868a4924ee7ca9b7738cce309f9eff
Reviewed-on: https://go-review.googlesource.com/20592
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-03-11 09:09:33 +00:00
Robert Griesemer
def9c0b06d cmd/compile: remove Label.Link field and lastlabel global var
Change-Id: If2a174f482ecd56dee43f921d13fef98439872fc
Reviewed-on: https://go-review.googlesource.com/20559
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-11 06:13:06 +00:00
Matthew Dempsky
c7917de0bb cmd/compile: simplify transformclosure
Use idiomatic slicing operations instead of incrementally building a
linked list.

Passes toolstash -cmp.

Change-Id: Idb0e40c7b4d7d1110d23828afa8ae1d157ba905f
Reviewed-on: https://go-review.googlesource.com/20556
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-11 05:54:27 +00:00
Matthew Dempsky
501b1fc3f2 cmd/compile: cleanup unsafenmagic
In particular, make Alignof work more like Sizeof. Other idiomatic
cleanups while here.

Passes toolstash -cmp.

Change-Id: I4def20894f3d95e49ab6a50ddba189be36fdd258
Reviewed-on: https://go-review.googlesource.com/20555
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-11 05:42:59 +00:00
Matthew Dempsky
d3794f88e9 cmd/compile: eliminate uses of Type.Down in alg.go
This could be done by threading the Iter value down through memrun and
ispaddedfield, but that ends up a bit clunky. This way is also closer
to how we'll want the code to look once fields are kept in slices.

Passes toolstash -cmp.

Change-Id: I8a44445c85f921eb18d97199df2026c5ce0f4f67
Reviewed-on: https://go-review.googlesource.com/20558
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-11 05:30:49 +00:00
Keith Randall
369f4f5de5 cmd/compile: regalloc of two address instructions
x86 has a lot of instructions that require the output to be in the same
register as one of the inputs.  When allocating the output register,
allocate the same register as the input if it is available.

Improves the performance of golang.org/x/crypto/sha3 by
10% (from 6% slower than 1.6 to 4% faster).

Fixes #14745

Change-Id: I4d81785240c9368e4dc75107b45c959d200df8e6
Reviewed-on: https://go-review.googlesource.com/20488
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-03-11 04:13:07 +00:00
Robert Griesemer
157f069873 cmd/compile: call missing popdcl in various genxxx functions
Not calling popdcl doesn't have an impact on generated code but
the result is a growing (rather than empty) stack of symbols,
possibly causing more data to remain alive than necessary.

Also: minor cleanups.

Change-Id: Ic4fdbcd8843637d69ab1aa15e896a7e6339bc990
Reviewed-on: https://go-review.googlesource.com/20554
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
2016-03-11 04:12:31 +00:00
Matthew Dempsky
88a21ebb21 cmd/compile: rework checkdupfields
Use a map to detect duplicate symbols. Allows eliminating an otherwise
unneeded field from Sym and gets rid of a global variable.

Change-Id: Ic004bca7e9130a1261a1cddbc17244529a2a1df4
Reviewed-on: https://go-review.googlesource.com/20552
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2016-03-11 01:52:42 +00:00
Todd Neal
6b3d4a5353 cmd/compile: modify regalloc/stackalloc to use the cmd line debug args
Change the existing flags from compile time consts to be configurable
from the command line.

Change-Id: I4aab4bf3dfcbdd8e2b5a2ff51af95c2543967769
Reviewed-on: https://go-review.googlesource.com/20560
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-11 01:35:12 +00:00
Keith Randall
31d13f479a cmd/compile: don't use PPARAMOUT names for temps
The location of VARDEFs is incorrect for PPARAMOUT variables
which are also used as temporary locations.  We put in VARDEFs
when setting the variable at return time, but when the location
is also used as a temporary the lifetime values are wrong.

Fix copyelim to update the names map properly.  This is a
real name bug fix which, as a result, allows me to
write a reasonable test to trigger the PPARAMOUT bug.

This is kind of a band-aid fix for #14591.  A more pricipled
fix (which allows values to be stored in the return variable
earlier than the return point) will be harder.

Fixes #14591

Change-Id: I7df8ae103a982d1f218ed704c080d7b83cdcfdd9
Reviewed-on: https://go-review.googlesource.com/20457
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2016-03-11 00:56:04 +00:00
Matthew Dempsky
1c2bdfb7d9 cmd/compile: add Key, FieldSlice, and SetFields helpers
Allows safely eliminating more direct uses of Type's Type and Down
fields.

Passes toolstash -cmp.

Change-Id: I5c17fe541a0473c3cd2978d8314c4ab759079a61
Reviewed-on: https://go-review.googlesource.com/20541
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-10 23:34:22 +00:00
Matthew Dempsky
0b281872e6 cmd/compile: rename ssa.Type's Elem method to ElemType
I would like to add a

    func (t *Type) Elem() *Type

method to package gc, but that would collide with the existing

    func (t *Type) Elem() ssa.Type

method needed to make *gc.Type implement ssa.Type.  Because the latter
is much less widely used right now than the former will be, this CL
renames it to ElemType.

Longer term, hopefully gc and ssa will share a common Type interface,
and ElemType can go away.

Change-Id: I270008515dc4c01ef531cf715637a924659c4735
Reviewed-on: https://go-review.googlesource.com/20546
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-10 23:02:33 +00:00
Matthew Dempsky
e4571d33ac cmd/compile: simplify parser.compound_stmt
Eliminate "else_clause" parameter and move error messages about bad if
statements into the if_stmt parsing method.

Passes toolstash -cmp.

Change-Id: Ibc31619bdb2e7e0cf28712b14640f7d9b6124a40
Reviewed-on: https://go-review.googlesource.com/20543
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-10 22:51:47 +00:00
Ian Lance Taylor
e6ea01685f cmd/compile: remove global variables in inl.go
Change-Id: I06dedf4ebfa32b598f5545dc9354c8e4a95610b1
Reviewed-on: https://go-review.googlesource.com/20525
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-10 22:49:53 +00:00
Keith Randall
ddc6b64444 cmd/compile: fix defer/deferreturn
Make sure we do any just-before-return cleanup on all paths out of a
function, including when recovering.  Each exit path should include
deferreturn (if there are any defers) and then the exit
code (e.g. copying heap-escaping return values back to the stack).

Introduce a Defer SSA block type which has two outgoing edges - one the
fallthrough edge (the defer was queued successfully) and one which
immediately returns (the defer had a successful recover() call and
normal execution should resume at the return point).

Fixes #14725

Change-Id: Iad035c9fd25ef8b7a74dafbd7461cf04833d981f
Reviewed-on: https://go-review.googlesource.com/20486
Reviewed-by: David Chase <drchase@google.com>
2016-03-10 22:33:49 +00:00
Josh Bleecher Snyder
9c8f549abb cmd/compile: continue is the new goto loop
Passes toolstash -cmp.

Change-Id: I014613985005780d1a622c1981b35a94cda798bb
Reviewed-on: https://go-review.googlesource.com/20530
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-10 20:59:54 +00:00
Ian Lance Taylor
ed4a27a8dd cmd/compile: change Func.Inldcl from *[]*Node to Nodes
Change-Id: I055e986c3f27d5c07badcd1684f4fe1d65a917a9
Reviewed-on: https://go-review.googlesource.com/20523
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-10 19:56:55 +00:00
Matthew Dempsky
fe5b4a6503 cmd/compile: more use of IterXXX functions
This CL was mostly produced by a one-off automated rewrite tool
looking for statements like "for X := T.Type; X != nil; X = X.Down"
and a few minor variations.

Passes toolstash -cmp.

Change-Id: Ib22705e37d078ef97841ee2e08f60bdbcabb94ad
Reviewed-on: https://go-review.googlesource.com/20520
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-10 19:54:03 +00:00
Ian Lance Taylor
c63dbd87c1 cmd/compile: add Nodes.Set1 method and use it where possible
Passes toolstash -cmp.

Change-Id: I05322fb5afd213f13fb247ec1a5f655c17a58774
Reviewed-on: https://go-review.googlesource.com/20522
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-10 18:35:10 +00:00
Ian Lance Taylor
72655afb4e cmd/compile: remove NodeList type
That was easy.

Fixes #14473.

Change-Id: I9d1d20a5c5a9b1423e6c72c0460ee4a78130864f
Reviewed-on: https://go-review.googlesource.com/20521
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-10 18:22:07 +00:00
Ian Lance Taylor
f444b8a80e cmd/compile: remove all remaining nodeSeq code
Passes toolstash -cmp.

Update #14473.

Change-Id: I2ac5c595d7af7a8da1a7e3945e6a753299446250
Reviewed-on: https://go-review.googlesource.com/20497
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-10 17:57:00 +00:00
Lynn Boger
b4b2ddb867 math: improve sqrt for ppc64le,ppc64
The existing implementation uses code written in Go to
implement Sqrt; this adds the assembler to use the sqrt
instruction for Power and makes the necessary changes to
allow it to be inlined.

The following tests showed this relative improvement:

benchmark                 delta
BenchmarkSqrt             -97.91%
BenchmarkSqrtIndirect     -96.65%
BenchmarkSqrtGo           -35.93%
BenchmarkSqrtPrime        -96.94%

Fixes #14349

Change-Id: I8074f4dc63486e756587564ceb320aca300bf5fa
Reviewed-on: https://go-review.googlesource.com/19515
Reviewed-by: Minux Ma <minux@golang.org>
2016-03-10 15:01:21 +00:00
Todd Neal
6cb2e1d015 cmd/compile: remove values from const cache upon free
When calling freeValue for possible const values, remove them from the
cache as well.

Change-Id: I087ed592243e33c58e5db41700ab266fc70196d9
Reviewed-on: https://go-review.googlesource.com/20481
Run-TryBot: Todd Neal <tolchz@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-10 10:28:05 +00:00
Dave Cheney
dbe54d23fe cmd/compile/internal: peep.go cleanups
More cleanups after CL 20089

- copysub, take a bool rather than an int for the f (force) parameter.
- copysub returns a bool rather than an int.
- prevl, reg is now int16, which reduces type conversion in its callers.
- copy1, reduce the scope of t and p variables.
- small simplifications in copyau1, copyas, etc.
- {mips64,ppc64}/regzer returns a bool.
- apply CL 20181 to x86/peep.go which was missed in the last CL.
- various comment fixes.

Change-Id: Ib73ffb768c979ce86f1614e5366fd576dea50986
Reviewed-on: https://go-review.googlesource.com/20281
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-10 07:01:34 +00:00
Matthew Dempsky
211cc40b11 cmd/compile: change ignorecase param types to bool
Change-Id: I93b4821254c9b0a3cebd912f447ed58f20adeb58
Reviewed-on: https://go-review.googlesource.com/19937
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-10 06:34:05 +00:00
Matthew Dempsky
49dad0f571 cmd/compile: support arbitrarily deep embedded fields
Fixes #13337.

Change-Id: Ie74d00390111796619150287d3f7a147750ab456
Reviewed-on: https://go-review.googlesource.com/19932
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-10 06:33:52 +00:00
Matthew Dempsky
f91b832ab5 cmd/compile: rename Recv->Recvs and Recv0->Recv
Change-Id: Ice3aa807169f4fec85745a3991b1084a9f85c1b5
Reviewed-on: https://go-review.googlesource.com/20499
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-10 05:52:24 +00:00
Matthew Dempsky
0cff505871 cmd/compile: add Recv0 and Field helper methods for Type
Accessing the n'th field of a struct is fairly common, and in
particular accessing the 0'th field of the receiver parameter list is
very common. Add helper methods for both of these tasks and update
code to make use of them.

Change-Id: I81f551fecdca306b3800636caebcd0dc106f2ed7
Reviewed-on: https://go-review.googlesource.com/20498
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-03-10 05:34:37 +00:00
Matthew Dempsky
d20b92e07a cmd/compile: replace more unnecessary **Type with *Type
Also, more lazy variable declarations, and make Dijkstra happy by
replacing "goto loop" with a for loop.

Change-Id: Idf2cd779a92eb3f33bd3394e12c9a0be72002ff4
Reviewed-on: https://go-review.googlesource.com/20496
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-10 04:33:57 +00:00
Dave Cheney
9d77ad8d34 cmd/compile/internal/gc: type.go cleanup
Follow up to CL 20494 addressing Type.Copy and a few other tiny
cleanups.

Change-Id: I3d0913a9f50a22ac2fd802858b1a94c15c5cb1bc
Reviewed-on: https://go-review.googlesource.com/20501
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-10 03:53:53 +00:00
Matthew Dempsky
2339b131d6 cmd/compile: cleanup paramstoheap and returnsfromheap
Better documentation. Change parameter types from **Type and int to
just *Type and bool. Make use of short var declarations.

Change-Id: I909846ba0df65cd2bc05ee145b72d60e881588bd
Reviewed-on: https://go-review.googlesource.com/20495
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-03-10 03:48:33 +00:00
Matthew Dempsky
b014b55b82 cmd/compile: consolidate Type construction and copying code
This should is preparatory cleanup to make it easier to use separate
types to represent each kind of Go type, rather than a single omnibus
Type struct with heavily overloaded fields.

Also, add TODO comments marking assignments that change an existing
Type's kind, as they need to be removed before we can factor Type.

Change-Id: If4b551fdea4ae045b10b1a3de2ee98f5cf32a517
Reviewed-on: https://go-review.googlesource.com/20494
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-10 01:37:09 +00:00
Josh Bleecher Snyder
e0032df81e cmd/compile: make alg gen prologue/epilogue match
With this, the start and end of geneq and genhash
are parallel. This removes a few rare nilchecks
from generated hash functions, but nothing
to write home about.

Change-Id: I3b4836111d04daa6f6834a579bbec374a3f42c70
Reviewed-on: https://go-review.googlesource.com/20456
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-03-09 22:52:22 +00:00
Ian Lance Taylor
cd6619d2e6 cmd/compile: remove remaining nodeSeqIterate calls
Mix in several other minor cleanups, including adding some new methods
to Nodes: Index, Addr, SetIndex, SetNodes.

Passes toolstash -cmp.

Update #14473.

Change-Id: I8bd4ae3fde7c5e20ba66e7dd1654fbc70c3ddeb8
Reviewed-on: https://go-review.googlesource.com/20491
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-09 22:52:11 +00:00
David Crawshaw
862b9ddda7 cmd/link: prune unused methods
Today the linker keeps all methods of reachable types. This is
necessary if a program uses reflect.Value.Call. But while use of
reflection is widespread in Go for encoders and decoders, using
it to call a method is rare.

This CL looks for the use of reflect.Value.Call in a program, and
if it is absent, adopts a (reasonably conservative) method pruning
strategy as part of dead code elimination. Any method that is
directly called is kept, and any method that matches a used
interface's method signature is kept.

Whether or not a method body is kept is determined by the relocation
from its receiver's *rtype to its *rtype. A small change in the
compiler marks these relocations as R_METHOD so they can be easily
collected and manipulated by the linker.

As a bonus, this technique removes the text segment of methods that
have been inlined. Looking at the output of building cmd/objdump with
-ldflags=-v=2 shows that inlined methods like
runtime.(*traceAllocBlockPtr).ptr are removed from the program.

Relatively little work is necessary to do this. Linking two
examples, jujud and cmd/objdump show no more than +2% link time.

Binaries that do not use reflect.Call.Value drop 4 - 20% in size:

	addr2line: -793KB (18%)
	asm:       -346KB (8%)
	cgo:       -490KB (10%)
	compile:   -564KB (4%)
	dist:      -736KB (17%)
	fix:       -404KB (12%)
	link:      -328KB (7%)
	nm:        -827KB (19%)
	objdump:   -712KB (16%)
	pack:      -327KB (14%)
	yacc:      -350KB (10%)

Binaries that do use reflect.Call.Value see a modest size decrease
of 2 - 6% thanks to pruning of unexported methods:

	api:    -151KB (3%)
	cover:  -222KB (4%)
	doc:    -106KB (2.5%)
	pprof:  -314KB (3%)
	trace:  -357KB (4%)
	vet:    -187KB (2.7%)
	jujud:  -4.4MB (5.8%)
	cmd/go: -384KB (3.4%)

The trivial Hello example program goes from 2MB to 1.68MB:

	package main

	import "fmt"

	func main() {
		fmt.Println("Hello, 世界")
	}

Method pruning also helps when building small binaries with
"-ldflags=-s -w". The above program goes from 1.43MB to 1.2MB.

Unfortunately the linker can only tell if reflect.Value.Call has been
statically linked, not if it is dynamically used. And while use is
rare, it is linked into a very common standard library package,
text/template. The result is programs like cmd/go, which don't use
reflect.Value.Call, see limited benefit from this CL. If binary size
is important enough it may be possible to address this in future work.

For #6853.

Change-Id: Iabe90e210e813b08c3f8fd605f841f0458973396
Reviewed-on: https://go-review.googlesource.com/20483
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-09 22:22:46 +00:00
Brad Fitzpatrick
0ac0e22fa7 cmd/compile: shrink tables
Drops cmd/binary size from 14.41 MiB to 11.42 MiB.

Before:

   text    data     bss     dec     hex filename
8121210 3521696  737960 12380866         bceac2 ../pkg/tool/linux_amd64/compile

bradfitz@dev-bradfitz-debian2:~/go/src$ ls -l ../pkg/tool/linux_amd64/compile
-rwxr-xr-x 1 bradfitz bradfitz 15111272 Mar  8 23:32 ../pkg/tool/linux_amd64/compile

  a2afc0      51312 R html.statictmp_0085
  6753f0      56592 T cmd/internal/obj/x86.doasm
  625480      58080 T cmd/compile/internal/gc.typecheck1
  f34c40      65688 D runtime.trace
  be0a20     133552 D cmd/compile/internal/ppc64.varianttable
  c013e0     265856 D cmd/compile/internal/arm.progtable
  c42260     417280 D cmd/compile/internal/amd64.progtable
  ca8060     417280 D cmd/compile/internal/x86.progtable
  f44ce0     500640 D cmd/internal/obj/arm64.oprange
  d0de60     534208 D cmd/compile/internal/ppc64.progtable
  d90520     667520 D cmd/compile/internal/arm64.progtable
  e334a0     790368 D cmd/compile/internal/mips64.progtable
  a3e8c0    1579362 r runtime.pclntab

After:

   text    data     bss     dec     hex filename
8128226  375954  246432 8750612  858614 ../pkg/tool/linux_amd64/compile

-rwxr-xr-x 1 bradfitz bradfitz 11971432 Mar  8 23:35 ../pkg/tool/linux_amd64/compile

  6436d0      43936 T cmd/compile/internal/gc.walkexpr
  c13ca0      45056 D cmd/compile/internal/ssa.opcodeTable
  5d8ea0      50256 T cmd/compile/internal/gc.(*state).expr
  818c50      50448 T cmd/compile/internal/ssa.rewriteValueAMD64_OpMove
  a2d0e0      51312 R html.statictmp_0085
  6753d0      56592 T cmd/internal/obj/x86.doasm
  625460      58080 T cmd/compile/internal/gc.typecheck1
  c38fe0      65688 D runtime.trace
  a409e0    1578810 r runtime.pclntab

Fixes #14703

Change-Id: I2177596d5c7fd67db0a3c423cd90801cf52adb12
Reviewed-on: https://go-review.googlesource.com/20450
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-09 21:56:28 +00:00
Alexandru Moșoi
bbd3ffbd83 cmd/compile: constant fold more of IsInBounds and IsSliceInBounds
Fixes #14721

Change-Id: Id1d5a819e5c242b91a37c4e464ed3f00c691aff5
Reviewed-on: https://go-review.googlesource.com/20482
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-09 18:05:28 +00:00
Matthew Dempsky
b594b8b039 cmd/compile: switch Eqtype and (*Type).Compare to use recvParamsResults
Change-Id: I5365b94b815bfb4795db643415c2df51fc815ea1
Reviewed-on: https://go-review.googlesource.com/20459
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-03-09 17:08:30 +00:00
Alexandru Moșoi
dfcb853d9d cmd/compile/internal/ssa: lower builtins much later
* Move lowering into a separate pass.
* SliceLen/SliceCap is now available to various intermediate passes
which use useful for bounds checking.
* Add a second opt pass to handle the new opportunities

Decreases the code size of binaries in pkg/tool/linux_amd64
by ~45K.

Updates #14564 #14606

Change-Id: I5b2bd6202181c50623a3585fbf15c0d6db6d4685
Reviewed-on: https://go-review.googlesource.com/20172
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-03-09 11:08:59 +00:00
Matthew Dempsky
aa3650f019 cmd/compile: eliminate IterParams
It's only used once, so just make the caller responsible for iterating
both the receiver and input params.

Change-Id: Icb34f3f0cf96e80fbe27f3f49d12eddc26599b92
Reviewed-on: https://go-review.googlesource.com/20454
Reviewed-by: Dave Cheney <dave@cheney.net>
2016-03-09 09:13:43 +00:00
Ingo Oeser
33fd4535a4 cmd/compile: use range construct
so the code is more readable.

Also use n[i] = val instead of n = append(n, val),
because this avoids a function call to append.

NOTE: compiles, but I had trouble running toolstash -cmp and need sleep
now.

@Ian this might save you some grunt work :-)

Change-Id: I2a4c70396c58905f7d5aabf83f3020f11dea0e89
Reviewed-on: https://go-review.googlesource.com/20430
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-09 04:58:07 +00:00
Brady Catherman
9323de3da7 testing: implement 'Unordered Output' in Examples.
Adds a type of output to Examples that allows tests to have unordered
output. This is intended to help clarify when the output of a command
will produce a fixed return, but that return might not be in an constant
order.

Examples where this is useful would be documenting the rand.Perm()
call, or perhaps the (os.File).Readdir(), both of which can not guarantee
order, but can guarantee the elements of the output.

Fixes #10149

Change-Id: Iaf0cf1580b686afebd79718ed67ea744f5ed9fc5
Reviewed-on: https://go-review.googlesource.com/19280
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-09 04:34:41 +00:00
Josh Bleecher Snyder
903f096992 cmd/compile: superficial cleanup in alg.go
Passes toolstash -cmp.

Change-Id: I6ec2143a30c1f2c15f8ec74422c954ed6b9b1a0f
Reviewed-on: https://go-review.googlesource.com/20452
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-03-09 02:46:50 +00:00
Matthew Dempsky
4db3dde522 cmd/compile: small cleanups for structargs
Suggested by Dave Cheney in golang.org/cl/20405.

Change-Id: I581c11ae80034cb6ebef3de976e8ae9484472322
Reviewed-on: https://go-review.googlesource.com/20453
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-09 02:03:36 +00:00
Ian Lance Taylor
38921b36ba cmd/compile: rewrite code to omit many nodeSeq calls
This CL was automatically generated using a special-purpose AST
rewriting tool, followed by manual editing to put some comments back in
the right places and fix some bad line breaks.

The result is not perfect but it's a big step toward getting back to
sanity, and because it was automatically generated there is a decent
chance that it is correct.

Passes toolstash -cmp.

Update #14473.

Change-Id: I01c09078a6d78e2b008bc304d744b79469a38d3d
Reviewed-on: https://go-review.googlesource.com/20440
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-09 01:39:33 +00:00
Matthew Dempsky
db506fe98c cmd/compile: change get{this,inarg,outarg}x? into methods
More idiomatic naming (in particular, matches the naming used for
go/types.Signature).

Also, convert more code to use these methods and/or IterFields.
(Still more to go; only made a quick pass for low hanging fruit.)

Passes toolstash -cmp.

Change-Id: I61831bfb1ec2cd50d4c7efc6062bca4e0dcf267b
Reviewed-on: https://go-review.googlesource.com/20451
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-09 01:29:18 +00:00
David Crawshaw
8df733bd22 cmd/compile: remove slices from rtype.funcType
Alternative to golang.org/cl/19852. This memory layout doesn't have
an easy type representation, but it is noticeably smaller than the
current funcType, and saves significant extra space.

Some notes on the layout are in reflect/type.go:

// A *rtype for each in and out parameter is stored in an array that
// directly follows the funcType (and possibly its uncommonType). So
// a function type with one method, one input, and one output is:
//
//	struct {
//		funcType
//		uncommonType
//		[2]*rtype    // [0] is in, [1] is out
//		uncommonTypeSliceContents
//	}

There are three arbitrary limits introduced by this CL:

1. No more than 65535 function input parameters.
2. No more than 32767 function output parameters.
3. reflect.FuncOf is limited to 128 parameters.

I don't think these are limits in practice, but are worth noting.

Reduces godoc binary size by 2.4%, 330KB.

For #6853.

Change-Id: I225c0a0516ebdbe92d41dfdf43f716da42dfe347
Reviewed-on: https://go-review.googlesource.com/19916
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-09 01:25:18 +00:00
Matthew Dempsky
7758a9405f cmd/compile: simplify Iter
Passes toolstash -cmp.

Change-Id: I325b02dcc8412ded0dc304d43377c0bdf59c66a8
Reviewed-on: https://go-review.googlesource.com/20405
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-09 00:18:20 +00:00
David Crawshaw
a24b3ed753 cmd/compile: remove rtype *uncommonType field
Instead of a pointer on every rtype, use a bit flag to indicate that
the contents of uncommonType directly follows the rtype value when it
is needed.

This requires a bit of juggling in the compiler's rtype encoder. The
backing arrays for fields in the rtype are presently encoded directly
after the slice header. This packing requires separating the encoding
of the uncommonType slice headers from their backing arrays.

Reduces binary size of godoc by ~180KB (1.5%).
No measurable change in all.bash time.
For #6853.

Change-Id: I60205948ceb5c0abba76fdf619652da9c465a597
Reviewed-on: https://go-review.googlesource.com/19790
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-08 23:23:13 +00:00
David Chase
0321cabdfa cmd/compile: guard the &-to-<<>> opt against small constants
Converting an and-K into a pair of shifts for K that will
fit in a one-byte argument is probably not an optimization,
and it also interferes with other patterns that we want to
see fire, like (<< (AND K)) [for small K] and bounds check
elimination for masked indices.

Turns out that on Intel, even 32-bit signed immediates beat
the shift pair; the size reduction of tool binaries is 0.09%
vs 0.07% for only the 8-bit immediates.

RLH found this one working on the new/next GC.

Change-Id: I2414a8de1dd58d680d18587577fbadb7ff4f67d9
Reviewed-on: https://go-review.googlesource.com/20410
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2016-03-08 23:06:11 +00:00
Matthew Dempsky
4720f49e18 cmd/compile: relocate a bunch of Type-related code
Some cleaned up documentation, but no code changes.

Change-Id: I145398bb6d118c626ab3873ef75dbb64ebc286e9
Reviewed-on: https://go-review.googlesource.com/20404
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-08 22:58:01 +00:00
Alexandru Moșoi
fb2f99d5fd cmd/compile/internal/ssa: simplify nil checks in opt.
* Simplify the nilcheck generated by
for _, e := range a {}
* No effect on the generated code because these nil checks
don't end up in the generated code.
* Useful for other analysis, e.g. it'll remove one dependecy
on the induction variable.

Change-Id: I6ee66ddfdc010ae22aea8dca48163303d93de7a9
Reviewed-on: https://go-review.googlesource.com/20307
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2016-03-08 22:17:47 +00:00
Matthew Dempsky
e806cd9f95 cmd/compile: cleanup compile function
Make more idiomatic with a defer cleanup, which allows declaring
variables closer to their first use, rather than up front before the
first goto statement.

Also, split the legacy code generation code path into a separate
genlegacy function, analogous to the new genssa.

Passes toolstash -cmp.

Change-Id: I86c22838704f6861b75716ae64ba103b0e73b12f
Reviewed-on: https://go-review.googlesource.com/20353
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-08 21:34:51 +00:00
Matthew Dempsky
4fc02d175b cmd/internal/obj: more Optab range simplification
Same idea as golang.org/cl/20322.

Passes toolstash/buildall.

Change-Id: Ida5960e57ff6e1e8de75c2720f21aeae56a8e415
Reviewed-on: https://go-review.googlesource.com/20352
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-08 21:34:45 +00:00
Brad Fitzpatrick
b330987711 cmd/compile: fix old comment references to go.y
Change-Id: Iec323998133ef20ff962f06a46d15dd342a82f5f
Reviewed-on: https://go-review.googlesource.com/20390
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-08 20:59:41 +00:00
Ian Lance Taylor
2350ca5a41 cmd/compile: remove useless declaration of llit
Accidentally added in https://golang.org/cl/20242.

This is in preparation for transformation by an automated tool.

Passes toolstash -cmp.

Update #14473.

Change-Id: I28c637d220df3ccaa8e368bfbea7282a6e66662e
Reviewed-on: https://go-review.googlesource.com/20402
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-08 20:55:18 +00:00
Russ Cox
0c7ccbf601 cmd/go: ignore C files when CGO_ENABLED=0
Before, those C files might have been intended for the Plan 9 C compiler,
but that option was removed in Go 1.5. We can simplify the maintenance
of cgo packages now if we assume C files (and C++ and M and SWIG files)
should only be considered when cgo is enabled.

Also remove newly unnecessary build tags in runtime/cgo's C files.

Fixes #14123

Change-Id: Ia5a7fe62b9469965aa7c3547fe43c6c9292b8205
Reviewed-on: https://go-review.googlesource.com/19613
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-08 20:10:52 +00:00
Ian Lance Taylor
df035a8d86 cmd/compile: fix bug in vmatch1 list traversal nodeSeq change
Bug accidentally inserted in https://golang.org/cl/20210.  Doesn't seem
to make a difference, but restore original code anyhow.

Update #14473.

Change-Id: I9cf87987ff158e27c7231027819317cdde8c132c
Reviewed-on: https://go-review.googlesource.com/20401
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-08 20:00:03 +00:00
David Chase
4c8589c328 cmd/compile: attach correct line number for fallthru-return
Fixes #14646.

Change-Id: I0bb82ed6d3533633cd8369ba37aa467948bbe155
Reviewed-on: https://go-review.googlesource.com/20381
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-08 19:23:25 +00:00
Brad Fitzpatrick
1264f6e2d4 cmd/compile: gofmt
Change-Id: I754861147838d0f6c184d8deb8a028062a1d3214
Reviewed-on: https://go-review.googlesource.com/20400
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-08 19:17:24 +00:00