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

635 Commits

Author SHA1 Message Date
Robert Griesemer
8f931e49f5 cmd/compile: remove dead code
Get rid of residue after removing old parser.

Change-Id: I0dace1037d50959071a082c276f9f374eef6edb2
Reviewed-on: https://go-review.googlesource.com/17179
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-24 03:30:02 +00:00
Robert Griesemer
b5fe07710f cmd/compile: remove yacc-based parser
- moved yySymType and token constants (L...) to lex.go
- removed oldparser flag and related code
- removed go generate that generated y.go

Fixes #13240.

Change-Id: I2576ec61ee1efe482f2a5132175725c9c02ef977
Reviewed-on: https://go-review.googlesource.com/17176
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-24 00:23:14 +00:00
Robert Griesemer
656a732a21 cmd/compile: simplify parsing of possibly absent type
Introduce a try_ntype function which doesn't return an error upon
not finding a type. Use it instead of having separate repeated
token checks. Simpler, less code, and more efficient.

Change-Id: I81e482158b71901eb179470269349688636aa0ba
Reviewed-on: https://go-review.googlesource.com/17157
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-23 21:29:27 +00:00
Robert Griesemer
aad18b849b cmd/compile: address several more 1.6 TODOs in parser
- fix/check location of popdcl calls where questioned
- remove unnecessary handling of ... (LDDD) in ntype (couldn't be reached)
- inlined and fnret_type and simplified fnres as a consequence
- leave handling of ... (LDDD) in arg_list alone (remove TODO)
- verify that parser requires a ';' after last statement in a case/default
  (added test case)

Fixes #13243.

Change-Id: Iad94b498591a5e85f4cb15bbc01e8e101415560d
Reviewed-on: https://go-review.googlesource.com/17155
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-21 07:21:23 +00:00
Robert Griesemer
0383bb473d cmd/compile: simplify tracing code (cleanup)
Change-Id: I7c084542996226f3ed464314a5622fcfaac02d61
Reviewed-on: https://go-review.googlesource.com/17103
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-21 07:20:39 +00:00
Robert Griesemer
af8cd3f6bd cmd/compile: fix TODO in tracing code
For #13243.

Change-Id: I214945278255a49f93120f9407f536a6c01a29fb
Reviewed-on: https://go-review.googlesource.com/17101
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-20 19:56:51 +00:00
Robert Griesemer
64cd86798b cmd/compile: better syntax error recovery
Use a combination of follow- and stop-token lists and nesting levels
to better synchronize parser after a syntax error.

Fixes #13319.

Change-Id: I9592e0b5b3ba782fb9f9315fea16163328e204f7
Reviewed-on: https://go-review.googlesource.com/17080
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-20 19:56:27 +00:00
Robert Griesemer
7218b79f23 cmd/compile: match markdcl and popdcl even in case of errors
Change-Id: I22a8a233bc157fa09cd0283fcd4bc14d90faed70
Reviewed-on: https://go-review.googlesource.com/17066
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-20 19:56:11 +00:00
Robert Griesemer
de2bc5722d cmd/compile: no need to keep ()'s for all pseudocalls
Minor internal optimization.

Change-Id: I229d4a9df3da542b77f830c2830f63ec23ec1d61
Reviewed-on: https://go-review.googlesource.com/17065
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-20 19:55:51 +00:00
Robert Griesemer
52f111fb34 cmd/compile: print regular error message in BOM corner-case
This never happens but for pathological input where a BOM sequence
is unfinished and ends in EOF (src: "package p\n\nfunc \xef\xef").
No test case added because the /test framework doesn't lend itself
easily to it in this case (file must end in EOF rather than comment).
Instead, tested manually.

Fixes #13268.

Change-Id: I049034e6dde7ad884b0a8c329921adac1866ff18
Reviewed-on: https://go-review.googlesource.com/17047
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-20 19:55:15 +00:00
Shenghou Ma
23791ee11d cmd/compile: set log prefix and suppress date
Fixes #13320.

Change-Id: I3a96a6707982629caf89656c479d096891783328
Reviewed-on: https://go-review.googlesource.com/17050
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-11-19 23:55:50 +00:00
Austin Clements
402e37d4a9 cmd/compile: special case nowritebarrierrec for allocm
allocm is a very unusual function: it is specifically designed to
allocate in contexts where m.p is nil by temporarily taking over a P.
Since allocm is used in many contexts where it would make sense to use
nowritebarrierrec, this commit teaches the nowritebarrierrec analysis
to stop at allocm.

Updates #10600.

Change-Id: I8499629461d4fe25712d861720dfe438df7ada9b
Reviewed-on: https://go-review.googlesource.com/17005
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-19 21:17:19 +00:00
Russ Cox
8b1b81f463 cmd/compile: fix crash with -race on large expr containing string->[]byte conversion
The assumption is that there are no nested function calls in complex expressions.
For the most part that assumption is true. It wasn't for these calls inserted during walk.
Fix that.

I looked through all the calls to mkcall in walk and these were the only cases
that emitted calls, that could be part of larger expressions (like not delete),
and that were not already handled.

Fixes #12225.

Change-Id: Iad380683fe2e054d480e7ae4e8faf1078cdd744c
Reviewed-on: https://go-review.googlesource.com/17034
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-19 19:54:55 +00:00
Michael Matloob
45c3cf68b0 cmd/compile: identify the runtime pkg using myimportpath
Because there are now multiple packages that compose the runtime
we need to distinguish between the case where a runtime package
is being compiled versus the case the "runtime" package is being
compiled. In golang.org/cl/14204 I mistakenly used
  localpkg.Name == "runtime"
to check against the "runtime" package, but doing this would treat
a package with the path "foo.org/bar/runtime" as the runtime package.
The correct check is
  myimportpath == "runtime"
.

Change-Id: If90e95cef768d91206f2df1c06e27be876722e4e
Reviewed-on: https://go-review.googlesource.com/17059
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-19 19:50:03 +00:00
Robert Griesemer
34cbccd341 cmd/compile/internal/gc: add line numbers for complit elts if needed (addresses TODO)
For #13243.

Change-Id: I802cef3dad5d1236e70d0cd52047008a6a7a311a
Reviewed-on: https://go-review.googlesource.com/17045
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:52:58 +00:00
Robert Griesemer
431c232842 cmd/compile/internal/gc: address TODO (better comment)
For #13243.

Change-Id: I544a8c44971fad126103157575e983ab528309bf
Reviewed-on: https://go-review.googlesource.com/17044
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:26:24 +00:00
Robert Griesemer
fe762b6466 cmd/compile/internal/gc: better error message for parenthesized go/defer exprs
Change-Id: Ie24d56422ae2196198a6c306716fa867c1442d6e
Reviewed-on: https://go-review.googlesource.com/17043
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:26:07 +00:00
Robert Griesemer
5500d46914 cmd/compile/internal/gc: fix incorrect parsing of &(T{}) when followed by {
Handling of &(T{}) assumed that the parser would not introduce ()'s.

Also: Better comments around handling of OPAREN syntax tree optimization.

Fixes #13261.

Change-Id: Ifc5047a0448f5e7d74cd42f6608b87dcc9c2f2fb
Reviewed-on: https://go-review.googlesource.com/17040
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:25:48 +00:00
Robert Griesemer
1a111ea2c7 cmd/compile/internal/gc: fix parsing of <-x (recv op vs recv-only chan)
Also:
- better error messages in some cases
- factored out function to produce syntax error at given line number

Fixes #13273.

Change-Id: I0192a94731cc23444680a26bd0656ef663e6da0b
Reviewed-on: https://go-review.googlesource.com/16992
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-18 22:22:56 +00:00
Russ Cox
918a2644f2 cmd/compile: fix Val vs Opt collision
Fixes #12686.

Change-Id: I7a9f49dbd1f60b1d0240de57787753b425f9548c
Reviewed-on: https://go-review.googlesource.com/17031
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 18:31:27 +00:00
Michael Hudson-Doyle
61da0e92d0 cmd/compile, cmd/compile/internal/x86: do not let regopt use CX in position independent code
We might be able to do better than this, but it's a start.

Change-Id: I80ebce9094e084a4746039106ccf1ad9c4b8bb7c
Reviewed-on: https://go-review.googlesource.com/16384
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-18 01:44:32 +00:00
Hyang-Ah Hana Kim
888aadfa60 cmd: enable android/386 build (buildmode=pie by default)
no buildmode=c-shared yet.

Update golang/go#9327.

Change-Id: I9989d954d574807bac105da401c3463607fe8a99
Reviewed-on: https://go-review.googlesource.com/16700
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-11-17 22:37:26 +00:00
Keith Randall
4304fbc4d0 [dev.ssa] Merge remote-tracking branch 'origin/master' into mergebranch
Conflicts:
	src/cmd/compile/internal/gc/racewalk.go
	src/cmd/internal/obj/stack.go
	src/cmd/internal/obj/x86/obj6.go
	src/runtime/stack.go
	test/nilptr3.go
	test/nosplit.go

Change-Id: Ie6053eb1577fd73e8243651f25c0f1fc765ae660
2015-11-16 17:19:42 -08:00
Robert Griesemer
662ab8be31 cmd/compile/internal/gc: add dropped line correction again
The line correction when reporting a missing package clause
was removed before since it wasn't clear that it was needed.
Added it again because of issue 13267.

No explicit test case has been added to test/fixedbugs because
it would require a file that contains a single byte and such a
file doesn't fit the existing test harness. Instead documented
the problematic line in the parser for future reference.

Fixes #13267.

Change-Id: I590fe8f358042aab73acf16c2ed9567872b174f4
Reviewed-on: https://go-review.googlesource.com/16975
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:06:11 +00:00
Robert Griesemer
0133d24c94 cmd/compile/internal/gc: don't ignore EOF in new parser
Fixes #13274.
Fixes #13272.

Change-Id: Ie67a2c4671ee2b49831898fff7677cd65d780942
Reviewed-on: https://go-review.googlesource.com/16972
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:05:39 +00:00
Robert Griesemer
a20556bf56 cmd/compile/internal/gc: correctly use internal call to error reporting
Fixes #13266.

Change-Id: I31da922e0599989e52acf346374c2077b157ebb7
Reviewed-on: https://go-review.googlesource.com/16971
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-17 01:05:07 +00:00
Russ Cox
2c11164db5 cmd/compile: fix value range check for complex constants
Fixes #11590.

Change-Id: I4144107334604a2cc98c7984df3b5d4cde3d30af
Reviewed-on: https://go-review.googlesource.com/16920
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:48:47 +00:00
Russ Cox
292ad59291 cmd/compile: do not emit args_stackmap for func _
Fixes #11699.

Change-Id: I01bf506d76260bcdf828bbde52791e328aa441a5
Reviewed-on: https://go-review.googlesource.com/16921
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:52 +00:00
Russ Cox
247959d9b8 cmd/compile: reject identifiers beginning with non-ASCII digit
Fixes #11359.

Change-Id: I0fdfa410939f7e42020cbb19d74a67e1cc3cd610
Reviewed-on: https://go-review.googlesource.com/16919
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:42 +00:00
Russ Cox
f2eb3de636 cmd/compile: document -trimpath
Fixes #8999.

Change-Id: I1390605bdf908f59b596975ea51eb04bd03bbae0
Reviewed-on: https://go-review.googlesource.com/16918
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-16 20:38:34 +00:00
Ian Lance Taylor
9aed0b7e3d cmd/compile: add special case for testing first field of struct variable
The change to the write barrier in https://golang.org/cl/16899 means
that the compiler now emits tests of the first field of a struct.  That
was using a register that was not used before.  This change fixes that
for amd64 by adding a special case for the first field of a struct.

Update #12416.

Change-Id: Ia57baa62cd741592fbeb9be82f1e846be73d6edd
Reviewed-on: https://go-review.googlesource.com/16933
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-16 18:39:40 +00:00
Ian Lance Taylor
be1ef46775 runtime: add optional expensive check for invalid cgo pointer passing
If you set GODEBUG=cgocheck=2 the runtime package will use the write
barrier to detect cases where a Go program writes a Go pointer into
non-Go memory.  In conjunction with the existing cgo checks, and the
not-yet-implemented cgo check for exported functions, this should
reliably detect all cases (that do not import the unsafe package) in
which a Go pointer is incorrectly shared with C code.  This check is
optional because it turns on the write barrier at all times, which is
known to be expensive.

Update #12416.

Change-Id: I549d8b2956daa76eac853928e9280e615d6365f4
Reviewed-on: https://go-review.googlesource.com/16899
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-16 18:39:06 +00:00
Didier Spezia
0624fd3f14 cmd/compile: regenerate builtin.go
Following a recent change, file builtin.go is not up-to-date.
Generate it again by running go generate.

Fixes #13203

Change-Id: Ib91c5ccc93665c043da95c7d3783ce5d94e48466
Reviewed-on: https://go-review.googlesource.com/16821
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-14 22:17:20 +00:00
Robert Griesemer
ac658a83c2 cmd/compile/internal/gc: consume at least one token in case of syntax error
Fixes #13248.

TBR: iant

Change-Id: Ic8b10704f945e6daef04bb38a00e249854b4ef19
Reviewed-on: https://go-review.googlesource.com/16930
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-11-14 05:40:52 +00:00
Robert Griesemer
12126752cc cmd/compile: associate tracking issue numbers with TODOs
Comment changes only.

Change-Id: Ib365b3cd16af9995cb0a2cce48fbe35d73899438
Reviewed-on: https://go-review.googlesource.com/16898
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-14 01:21:18 +00:00
Robert Griesemer
59dc25730b cmd/compile: cleanup in parser (3)
Factored out functionality of dotname (was inlined in 3 places).

Change-Id: Ica782737c8decbb757465830b25ba87faa9115a4
Reviewed-on: https://go-review.googlesource.com/16897
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-14 01:19:54 +00:00
Robert Griesemer
8d733ecafb cmd/compile: cleanup in parser.go (2)
Inlined fntype, othertype, recvchantype, ptrtype into ntype
and simplified callers. Minor cleanups elsewhere (better names).

Change-Id: I54924969996641a802de00c078b4cd0eabfda8c1
Reviewed-on: https://go-review.googlesource.com/16894
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-14 01:19:31 +00:00
Robert Griesemer
18160e0740 cmd/compile: cleanup in parser.go
Inlined non_dcl_stmt in stmt since it was called only from there.

Change-Id: I616c41332cfd86bbf3493d0ce7b1256384215220
Reviewed-on: https://go-review.googlesource.com/16893
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-11-14 00:33:27 +00:00
Robert Griesemer
c8bc7f1abd cmd/compile: better syntax error handling for new parser
- better error messages
- better error recovery by advancing to "follow" token after error
- make sure that we make progress after all errors
- minor cleanups

Change-Id: Ie43b8b02799618d70dc8fc227fab3e4e9e0d8e3a
Reviewed-on: https://go-review.googlesource.com/16892
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-14 00:32:57 +00:00
Robert Griesemer
b569b87ca1 cmd/compile/internal/gc: recursive-descent parser
This is a translation of the yacc-based parser with adjustements
to make the grammar work for a recursive-descent parser followed
by cleanups and simplifications.

The yacc actions were mostly literally copied for correctness
with better temporary names.

A few of the syntax tests were adjusted for slightly different
error messages (it is very difficult to match the yacc-based
error messages in all cases, and sometimes the new parser could
produce better errors).

The new parser is enabled by default.
To switch back to the yacc-based parser, set -oldparser.
To hardwire the switch back, uncomment "oldparser = 1" in lex.go.

- passes all.bash
- ~18% reduced parse time per file on average for make.bash
- ~3% reduced compile time for building cmd/compile

Change-Id: Icb5651bb9d8b9f66261762d2c94a03793050d4ce
Reviewed-on: https://go-review.googlesource.com/16665
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-13 14:53:57 +00:00
Michael Hudson-Doyle
368d548417 cmd/compile, cmd/link, runtime: on ppc64x, maintain the TOC pointer in R2 when compiling PIC
The PowerPC ISA does not have a PC-relative load instruction, which poses
obvious challenges when generating position-independent code. The way the ELFv2
ABI addresses this is to specify that r2 points to a per "module" (shared
library or executable) TOC pointer. Maintaining this pointer requires
cooperation between codegen and the system linker:

 * Non-leaf functions leave space on the stack at r1+24 to save the TOC pointer.
 * A call to a function that *might* have to go via a PLT stub must be followed
   by a nop instruction that the system linker can replace with "ld r1, 24(r1)"
   to restore the TOC pointer (only when dynamically linking Go code).
 * When calling a function via a function pointer, the address of the function
   must be in r12, and the first couple of instructions (the "global entry
   point") of the called function use this to derive the address of the TOC
   for the module it is in.
 * When calling a function that is implemented in the same module, the system
   linker adjusts the call to skip over the instructions mentioned above (the
   "local entry point"), assuming that r2 is already correctly set.

So this changeset adds the global entry point instructions, sets the metadata so
the system linker knows where the local entry point is, inserts code to save the
TOC pointer at 24(r1), adds a nop after any call not known to be local and copes
with the odd non-local code transfer in the runtime (e.g. the stuff around
jmpdefer). It does not actually compile PIC yet.

Change-Id: I7522e22bdfd2f891745a900c60254fe9e372c854
Reviewed-on: https://go-review.googlesource.com/15967
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 23:18:58 +00:00
Michael Matloob
87a65f6ce7 cmd/compile: delete the runtime_internal_atomic.go builtin defs file
The file was automatically placed in the cl by a tool I had built.
Since the compiler doesn't hook into the atomic package, it's unnecessary.

Change-Id: I631fd876813b381bb12604865b00fc5b268dce84
Reviewed-on: https://go-review.googlesource.com/16844
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-12 17:27:28 +00:00
Michael Matloob
432cb66f16 runtime: break out system-specific constants into package sys
runtime/internal/sys will hold system-, architecture- and config-
specific constants.

Updates #11647

Change-Id: I6db29c312556087a42e8d2bdd9af40d157c56b54
Reviewed-on: https://go-review.googlesource.com/16817
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-12 17:04:45 +00:00
Keith Randall
75102afce7 [dev.ssa] cmd/compile: better register allocation
Use a more precise computation of next use.  It properly
detects lifetime holes and deallocates values during those holes.
It also uses a more precise version of distance to next use which
affects which values get spilled.

Change-Id: I49eb3ebe2d2cb64842ecdaa7fb4f3792f8afb90b
Reviewed-on: https://go-review.googlesource.com/16760
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-12 15:31:11 +00:00
Yao Zhang
d5cd4ab46a cmd/compile: added support for mips64{,le}
It is based on ppc64 compiler.

Change-Id: I15a101df05f2919ba5292136957ba0009227d067
Reviewed-on: https://go-review.googlesource.com/14445
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12 04:44:20 +00:00
Michael Hudson-Doyle
9514285da9 cmd/compile/internal/x86: avoid CX in a couple of places in the int64 code
I want to use CX as a scratch register in position independent code and these
uses are easy to remove.

Change-Id: I9e3cb470d7f0000d85786c30bd769d9ec86d532a
Reviewed-on: https://go-review.googlesource.com/16382
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-11 23:44:50 +00:00
Keith Randall
7807bda91d [dev.ssa] cmd/compile: be safer about uintptr/unsafe.Pointer conversions
Make sure that when a pointer value is live across a function
call, we save it as a pointer.  (And similarly a uintptr
live across a function call should not be saved as a pointer.)

Add a nasty test case.

This is probably what is preventing the merge from master
to dev.ssa.  Signs point to something like this bug happening
in mallocgc.

Change-Id: Ib23fa1251b8d1c50d82c6a448cb4a4fc28219029
Reviewed-on: https://go-review.googlesource.com/16830
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-11 05:26:49 +00:00
Robert Griesemer
50fa646776 cmd/compile/internal/gc: avoid potential endless loop in float printing
The compiler should not usually call Fconv with an infinity, but if
it does, Fconv will end in an endless loop. Test for infinities early.

Change-Id: I48f366466538b0bd26a851e01258725025babaff
Reviewed-on: https://go-review.googlesource.com/16777
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-10 20:36:52 +00:00
Michael Matloob
67faca7d9c runtime: break atomics out into package runtime/internal/atomic
This change breaks out most of the atomics functions in the runtime
into package runtime/internal/atomic. It adds some basic support
in the toolchain for runtime packages, and also modifies linux/arm
atomics to remove the dependency on the runtime's mutex. The mutexes
have been replaced with spinlocks.

all trybots are happy!
In addition to the trybots, I've tested on the darwin/arm64 builder,
on the darwin/arm builder, and on a ppc64le machine.

Change-Id: I6698c8e3cf3834f55ce5824059f44d00dc8e3c2f
Reviewed-on: https://go-review.googlesource.com/14204
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-10 17:38:04 +00:00
Keith Randall
74e568f43a [dev.ssa] cmd/compile: Deduplicate panic{index,slice,divide} calls
Panics are only distinguished by their type and line number, so
if we can trigger two of those panics in the same line, use the
same panic call.  For example, in a[i]+b[j] we need only one
panicindex call that both bounds checks can use.

Change-Id: Ia2b6d3b1a67f2775df05fb72b8a1b149833572b7
Reviewed-on: https://go-review.googlesource.com/16772
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-10 16:56:11 +00:00
Keith Randall
170589ee1c [dev.ssa] cmd/compile: some SSA optimizations
Some optimizations of things I've seen looking at generated code.
  (x+y)-x == y
  x-0 == x
The ptr portion of the constant string "" can be nil.

Also update TODO with recent changes.

Change-Id: I02c41ca2f9e9e178bf889058d3e083b446672dbe
Reviewed-on: https://go-review.googlesource.com/16771
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-10 16:55:44 +00:00
Robert Griesemer
0bad50f2a4 cmd/compile/internal/gc: fix go.y to match y.go
In https://go-review.googlesource.com/#/c/16554/ y.go was modified
manually, but go.y (which is the source for y.go) was not changed.

Change-Id: I1273801bfd1ac65b875f4465033b0d062abff0b7
Reviewed-on: https://go-review.googlesource.com/16745
Reviewed-by: Austin Clements <austin@google.com>
2015-11-09 20:38:39 +00:00
Keith Randall
0bef88aa5f cmd/compile: mark duffzero as using X0, not AX
duffzero was changed to use X0 instead of AX in
CL 14408.  This was missed as part of that change.

Change-Id: I72fb0114cfbc035b83bfaa8631d27e6740da2652
Reviewed-on: https://go-review.googlesource.com/16717
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-11-08 04:57:30 +00:00
Keith Randall
ffb20631fc runtime: teach peephole optimizer that duffcopy clobbers X0
Duffcopy now uses X0, as of 5cf281a.  Teach the peephole
optimizer that duffcopy clobbers X0 so that it does not
rename registers use X0 across the duffcopy instruction.

Fixes #13171

Change-Id: I389cbf1982cb6eb2f51e6152ac96736a8589f085
Reviewed-on: https://go-review.googlesource.com/16715
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
2015-11-06 15:11:42 +00:00
Austin Clements
3a765430c1 cmd/compile: add go:nowritebarrierrec annotation
This introduces a recursive variant of the go:nowritebarrier
annotation that prohibits write barriers not only in the annotated
function, but in all functions it calls, recursively. The error
message gives the shortest call stack from the annotated function to
the function containing the prohibited write barrier, including the
names of the functions and the line numbers of the calls.

To demonstrate the annotation, we apply it to gcmarkwb_m, the write
barrier itself.

This is a new annotation rather than a modification of the existing
go:nowritebarrier annotation because, for better or worse, there are
many go:nowritebarrier functions that do call functions with write
barriers. In most of these cases this is benign because the annotation
was conservative, but it prohibits simply coopting the existing
annotation.

Change-Id: I225ca483c8f699e8436373ed96349e80ca2c2479
Reviewed-on: https://go-review.googlesource.com/16554
Reviewed-by: Keith Randall <khr@golang.org>
2015-11-04 14:42:04 +00:00
Ian Lance Taylor
9179c9cb5c cmd/compile: make sure instrumented call has type width
The width of the type of an external variable defined with a type
literal may not be set when the instrumentation pass is run.  There are
two cases in the standard library that fail without the call to dowidth:

../../../src/encoding/base32/base32.go:322: constant -1000000000 overflows uintptr
../../../src/encoding/base32/base32.go:329: constant -1000000000 overflows uintptr
../../../src/encoding/json/encode.go:385: constant -1000000000 overflows uintptr
../../../src/encoding/json/encode.go:387: constant -1000000000 overflows uintptr

Change-Id: I7c3334f7decdb7488595ffe4090cd262d7334283
Reviewed-on: https://go-review.googlesource.com/16331
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-03 23:42:06 +00:00
Keith Randall
d19bfc3b68 [dev.ssa] cmd/compile: Handle ONOT in conditionals as well
Might as well, for a && !(b && c) and the like.

Change-Id: I2548b6e6ee5870e074bcef6edd56a7db6e81d70f
Reviewed-on: https://go-review.googlesource.com/16600
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
2015-11-03 18:36:14 +00:00
Keith Randall
02f4d0a130 [dev.ssa] cmd/compile: start arguments as spilled
Declare a function's arguments as having already been
spilled so their use just requires a restore.

Allow spill locations to be portions of larger objects the stack.
Required to load portions of compound input arguments.

Rename the memory input to InputMem.  Use Arg for the
pre-spilled argument values.

Change-Id: I8fe2a03ffbba1022d98bfae2052b376b96d32dda
Reviewed-on: https://go-review.googlesource.com/16536
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-03 17:29:40 +00:00
Keith Randall
582baae22a [dev.ssa] cmd/compile: Do pointer arithmetic with int, not uintptr
Be more consistent about this.  There's no reason to do the
pointer arithmetic on a different type, as sizeof(int) >=
sizeof(ptr) on all of our platforms.  It simplifies our
rewrite rules also, except for a few that need duplication.

Add some more constant folding to get constant indexing and
slicing to fold down to nothing.

Change-Id: I3e56cdb14b3dc1a6a0514f0333e883f92c19e3c7
Reviewed-on: https://go-review.googlesource.com/16586
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-03 17:28:12 +00:00
Keith Randall
991873116e [dev.ssa] cmd/compile: better ANDAND and OROR in IF and FOR
For the statement

    if a && b { target }

the old code allocated a new variable v and did:

    v = a
    if a {
       v = b
    }
    if v { goto target }

The new code does:

    if a {
      if b { goto target }
    }

The new arrangement tends to generate much more efficient code.  In
particular, there is no temporary variable and there is only one join
point instead of two.

The old code is still used for ANDAND and OROR which are not
direct descendents of IF or FOR statements.

Change-Id: I082f246d27c823c6f32d1287300e4b0911607507
Reviewed-on: https://go-review.googlesource.com/16584
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-11-03 17:22:27 +00:00
David Chase
729abfa35c [dev.ssa] cmd/compile: default compile+test with SSA
Some tests disabled, some bifurcated into _ssa and not,
with appropriate logging added to compiler.

"tests/live.go" in particular needs attention.

SSA-specific testing removed, since it's all SSA now.

Added "-run_skips" option to tests/run.go to simplify
checking whether a test still fails (or how it fails)
on a skipped platform.

The compiler now compiles with SSA by default.
If you don't want SSA, specify GOSSAHASH=n (or N) as
an environment variable.  Function names ending in "_ssa"
are always SSA-compiled.

GOSSAFUNC=fname retains its "SSA for fname, log to ssa.html"
GOSSAPKG=pkg only has an effect when GOSSAHASH=n
GOSSAHASH=10101 etc retains its name-hash-matching behavior
for purposes of debugging.

See #13068

Change-Id: I8217bfeb34173533eaeb391b5f6935483c7d6b43
Reviewed-on: https://go-review.googlesource.com/16299
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2015-10-30 20:35:20 +00:00
Marvin Stenger
8e7a3ea11e cmd/compile/internal: named types for Etype and Op in struct Node
Type Op is enfored now.
Type EType will need further CLs.
Added TODOs where Node.EType is used as a union type.
The TODOs have the format `TODO(marvin): Fix Node.EType union type.`.

Furthermore:
-The flag of Econv function in fmt.go is removed, since unused.
-Some cleaning along the way, e.g. declare vars first when getting initialized.

Passes go build -toolexec 'toolstash -cmp' -a std.

Fixes #11846

Change-Id: I908b955d5a78a195604970983fb9194bd9e9260b
Reviewed-on: https://go-review.googlesource.com/14956
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Marvin Stenger <marvin.stenger94@gmail.com>
2015-10-30 20:12:37 +00:00
Robert Griesemer
ddbc802b07 cmd/compile/internal/gc: fix complex literal overflow
Change-Id: Ibb15282a2baeb58439b085d70b82797d8c71de36
Reviewed-on: https://go-review.googlesource.com/16502
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-30 18:40:31 +00:00
Todd Neal
cdc36252fe [dev.ssa] cmd/compile/internal/ssa: rewrite rules for const comparisons
Shaves ~8k off the go binary on darwin x64.

Change-Id: I73396af44ae28cd4cfc675290d6858f304d45b76
Reviewed-on: https://go-review.googlesource.com/16456
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-30 03:49:30 +00:00
Todd Neal
a92543e1a1 cmd/compile: add support for a go:noinline directive
Some tests need to disable inlining of a function.  It's currently done
in one of a few ways (adding a function call, an empty switch, or a
defer).  Add support for a less fragile 'go:noinline' directive that
prevents inlining.

Fixes #12312

Change-Id: Ife444e13361b4a927709d81aa41e448f32eec8d4
Reviewed-on: https://go-review.googlesource.com/13911
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-10-29 23:16:27 +00:00
Keith Randall
d04f38e3ee [dev.ssa] cmd/compile: flag recomputing: find original values correctly
We "spill" flag values by recomputing them from their original
inputs.  The "find original inputs" part of the algorithm was
a hack.  It was broken by rematerialization.  This change does
the real job of keeping track of original values for each
spill/restore/flagrecompute/rematerialization we issue.

Change-Id: I95088326a4ee4958c98148b063e518c80e863e4c
Reviewed-on: https://go-review.googlesource.com/16500
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-29 21:59:10 +00:00
Michael Hudson-Doyle
51586aadfb cmd/compile, cmd/go, cmd/link: enable -buildmode=shared and related flags on linux/arm64
Change-Id: Ibddbbf6f4a5bd336a8b234d40fad0fcea574cd6e
Reviewed-on: https://go-review.googlesource.com/13994
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-29 19:27:47 +00:00
David Crawshaw
ab7e82ef3b cmd/go: buildmode=c-shared support for linux/arm64
Change-Id: Ic826dc25b5203b2e9fc253d6fe997e4b41de3789
Reviewed-on: https://go-review.googlesource.com/16453
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-29 16:25:37 +00:00
Michael Hudson-Doyle
78c05b8657 cmd/compile, cmd/go: enable -buildmode=shared and related flags on linux/arm
Change-Id: I20840632771a250fb279df64d394135994482af8
Reviewed-on: https://go-review.googlesource.com/14186
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-10-28 23:46:56 +00:00
Todd Neal
74180dd7da [dev.ssa] cmd/compile/internal/ssa: reuse Aux values for PEXTERN
This improves cse and works correctly now that divide by zero is checked
explicitly.

Change-Id: If54fbe403ed5230b897afc5def644ba9f0056dfd
Reviewed-on: https://go-review.googlesource.com/16454
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-28 23:12:28 +00:00
Keith Randall
a347ab7cd1 [dev.ssa] cmd/compile: split op rewrites into separate functions
The single value rewrite function is too big.  Some compilers
fail on it (out of memory, branch offset too large).  Break it
up into a rewrite function per op.

Change-Id: Iede697c8a1a3a22b485cd0dc85d3e233160c89c2
Reviewed-on: https://go-review.googlesource.com/16347
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2015-10-28 20:07:22 +00:00
Keith Randall
e514021153 [dev.ssa] cmd/compile: fix printing of live information
SSA generates ACALL assembly with the target in a *Sym.
The old compiler generates both that *Sym and a *Node.
Use the *Sym to print the live info so it works with both compilers.

Change-Id: I0b12a161f83e76638604358c21b9f5abb31ce950
Reviewed-on: https://go-review.googlesource.com/16432
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-10-28 19:52:34 +00:00
David Chase
18559e2da7 [dev.ssa] cmd/compile: make zero-divide panic from div/mod explicit
Added an explicit compare-zero and branch-to-panic for
integer division and mod so that other optimizations will
not be fooled by their implicit panics.

Change-Id: Ibf96f636b541c0088861907c537a6beb4b99fa4c
Reviewed-on: https://go-review.googlesource.com/16450
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-28 19:31:11 +00:00
Keith Randall
c24681ae2e [dev.ssa] cmd/compile: remember names of values
For debugging, spill values to named variables instead of autotmp_
variables if possible.  We do this by keeping a name -> value map
for each function, keep it up-to-date during deadcode elim, and use
it to override spill decisions in stackalloc.

It might even make stack frames a bit smaller, as it makes it easy
to identify a set of spills which are likely not to interfere.

This just works for one-word variables for now.  Strings/slices
will be a separate CL.

Change-Id: Ie89eba8cab16bcd41b311c479ec46dd7e64cdb67
Reviewed-on: https://go-review.googlesource.com/16336
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-10-28 17:00:31 +00:00
Keith Randall
d43f2e37ed [dev.ssa] cmd/compile: introduce storeconst ops
Introduce opcodes that store a constant value.
AuxInt now needs to hold both the value to be stored and the
constant offset at which to store it.  Introduce a StoreConst
type to help encode/decode these parts to/from an AuxInt.

Change-Id: I1631883abe035cff4b16368683e1eb3d2ccb674d
Reviewed-on: https://go-review.googlesource.com/16170
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-10-28 03:09:55 +00:00
Michael Hudson-Doyle
3ae4dc8a75 cmd/compile, cmd/go, cmd/link: enable -buildmode=shared and related flags on linux/386
Change-Id: If3417135ca474468a480b08cf46334fda28f79b4
Reviewed-on: https://go-review.googlesource.com/16345
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-28 01:21:54 +00:00
Todd Neal
cd01c0be26 [dev.ssa] cmd/compile/internal/ssa: reorder fuse and dse
deadstore elimination currently works in a block, fusing before
performing dse eliminates ~1% more stores for make.bash

Change-Id: If5bbddac76bf42616938a8e8e84cb7441fa02f73
Reviewed-on: https://go-review.googlesource.com/16350
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-27 22:16:12 +00:00
Keith Randall
129261ae83 [dev.ssa] cmd/compile: give GetClosurePtr pointer type
If the closure pointer gets spilled, we need to spill it with
pointer type to make stack copy and GC happy.

Change-Id: Ic108748e6b9caecd45522141f02c9422567376e3
Reviewed-on: https://go-review.googlesource.com/16363
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-10-27 18:00:31 +00:00
Keith Randall
10462eb30f [dev.ssa] cmd/compile: better copying
Replace REP MOVSB with all the copying techniques used by the
old compiler.  Copy in chunks, DUFFCOPY, etc.

Introduces MOVO opcodes and an Int128 type to move around
16 bytes at a time.

Change-Id: I1e73e68ca1d8b3dd58bb4af2f4c9e5d9bf13a502
Reviewed-on: https://go-review.googlesource.com/16174
Reviewed-by: Todd Neal <todd@tneal.org>
Run-TryBot: Keith Randall <khr@golang.org>
2015-10-27 04:02:19 +00:00
Robert Griesemer
53d43cb556 cmd/compile/internal/gc: introduce type for untyped constant kinds
Change-Id: Ia34b6dd099d07d5e1d4bffe775a20fa92705fdb0
Reviewed-on: https://go-review.googlesource.com/16335
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-26 23:36:22 +00:00
Robert Griesemer
cd7d7382bb cmd/compile/internal/gc: introduce type for decl contexts/storage classes
Change-Id: I956e27fa07f16060b8f41b986d991c36557f7c12
Reviewed-on: https://go-review.googlesource.com/16332
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-26 22:18:42 +00:00
Robert Griesemer
e6ccfc1ad1 cmd/compile/internal/gc: escape binary export data so it contains no '$'
Necessary to ensure that subsequent tools can continue to find
then end of the export data section simply by searching for "$$".

Adjusted gcimporter used by go/types accordingly.

Also, fixed a bug in gcimporter related to reading export data
in debug format.

Change-Id: Iaea4ed05edd8a5bab28ebe5b19a4740f5e537d35
Reviewed-on: https://go-review.googlesource.com/16283
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-10-26 17:27:17 +00:00
Marcel van Lohuizen
afe9837b23 cmd/compile/internal/gc: make embedded unexported structs RO
gc will need to be rebuild.

Package that assume f.PkgPath != nil means a field is unexported and
must be ignored must be revised to check for
	f.PkgPath != nil && !f.Anonymous,
so that they do try to walk into the embedded fields to look for
exported fields contained within.

Closes #12367, fixes #7363, fixes #11007, and fixes #7247.

Change-Id: I16402ee21ccfede80f277f84b3995cf26e97433d
Reviewed-on: https://go-review.googlesource.com/14085
Reviewed-by: Russ Cox <rsc@golang.org>
2015-10-26 13:57:48 +00:00
Keith Randall
31115a5c98 [dev.ssa] cmd/compile: optimize nil checks
Use faulting loads instead of test/jeq to do nil checks.
Fold nil checks into a following load/store if possible.

Makes binaries about 2% smaller.

Change-Id: I54af0f0a93c853f37e34e0ce7e3f01dd2ac87f64
Reviewed-on: https://go-review.googlesource.com/16287
Reviewed-by: David Chase <drchase@google.com>
2015-10-25 20:34:28 +00:00
Keith Randall
a3180d8b1d [dev.ssa] cmd/compile: get rid of converts in unsafe.Pointer arithmetic
unsafe.Pointer->uintptr, add, then uintptr->unsafe.Pointer.
Do the add directly on the pointer type instead.

Change-Id: I5a3a32691d0a000e16975857974ed9a1039c6d28
Reviewed-on: https://go-review.googlesource.com/16281
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-10-23 21:43:38 +00:00
Håvard Haugen
9238cbd57a cmd/compile/internal/gc: remove "goto ret" in walkexpr
Passes go build -a -toolexec 'toolstash -cmp' std cmd.

Change-Id: Ib3d2c50601546495e7f1ab153d2978b1e3774101
Reviewed-on: https://go-review.googlesource.com/14800
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2015-10-23 20:07:52 +00:00
David Chase
e99dd52066 [dev.ssa] cmd/compile: enhance SSA filtering, add OpConvert
Modified GOSSA{HASH.PKG} environment variable filters to
make it easier to make/run with all SSA for testing.
Disable attempts at SSA for architectures that are not
amd64 (avoid spurious errors/unimplementeds.)

Removed easy out for unimplemented features.

Add convert op for proper liveness in presence of uintptr
to/from unsafe.Pointer conversions.

Tweaked stack sizes to get a pass on windows;
1024 instead 768, was observed to pass at least once.

Change-Id: Ida3800afcda67d529e3b1cf48ca4a3f0fa48b2c5
Reviewed-on: https://go-review.googlesource.com/16201
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2015-10-23 19:32:57 +00:00
David Chase
3abb844108 [dev.ssa] cmd/compile: repair ssa testing build and test
Calls to NewConfig required an extra parameter that
sometimes could not be nil.

Change-Id: I806dd53c045056a0c2d30d641a20fe27fb790539
Reviewed-on: https://go-review.googlesource.com/16272
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-23 17:30:09 +00:00
Jeremy Jackins
6327e8dc69 cmd/compile/internal/gc: update old c-style comments
Update old c-style comments to look like Go comments. Also replace some
lingering references to old .c files that don't exist anymore.

Change-Id: I72b2407a40fc76c23e9048643e0622fd70b4cf90
Reviewed-on: https://go-review.googlesource.com/16190
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-23 15:33:50 +00:00
Keith Randall
7d61246972 [dev.ssa] cmd/compile: implement reserved registers
BP for framepointer experiment
R15 for dynamic linking

Change-Id: I28e48be461d04a4d5c9b013f48fce5c0e58d6a08
Reviewed-on: https://go-review.googlesource.com/16231
Run-TryBot: Todd Neal <todd@tneal.org>
Reviewed-by: Todd Neal <todd@tneal.org>
2015-10-23 04:14:06 +00:00
Robert Griesemer
79a3b561b5 cmd/compile/internal/gc: remove special handling for -0.0
Per the latest spec change, Go doesn't have -0 constants.

Change-Id: Ic2bcdc3bf507d121ed204f30f6744bb8764202c0
Reviewed-on: https://go-review.googlesource.com/16232
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-10-22 21:19:43 +00:00
Robert Griesemer
ae2f54a771 cmd/compile/internal/gc: compact binary export format
The binary import/export format is significantly more
compact than the existing textual format. It should
also be faster to read and write (to be measured).

Use -newexport to enable, for instance:
export GO_GCFLAGS=-newexport; make.bash

The compiler can import packages using both the old
and the new format ("mixed mode").

Missing: export info for inlined functions bodies
(performance issue, does not affect correctness).

Disabled by default until we have inlined function
bodies and confirmation of no regression and equality
of binaries.

For #6110.
For #1909.

This change depends on:

   https://go-review.googlesource.com/16220
   https://go-review.googlesource.com/16222

(already submitted) for all.bash to work.

Some initial export data sizes for std lib packages. This data
is without exported functions with inlineable function bodies.

Package                                       old      new    new/old

archive/tar.................................13875.....3883    28%
archive/zip.................................19464.....5046    26%
bufio....................................... 7733.....2222    29%
bytes.......................................10342.....3347    32%
cmd/addr2line.................................242.......26    11%
cmd/api.....................................39305....10368    26%
cmd/asm/internal/arch.......................27732.....7939    29%
cmd/asm/internal/asm........................35264....10295    29%
cmd/asm/internal/flags........................629......178    28%
cmd/asm/internal/lex........................39248....11128    28%
cmd/asm.......................................306.......26     8%
cmd/cgo.....................................40197....10570    26%
cmd/compile/internal/amd64...................1106......214    19%
cmd/compile/internal/arm....................27891.....7710    28%
cmd/compile/internal/arm64....................891......153    17%
cmd/compile/internal/big....................21637.....8336    39%
cmd/compile/internal/gc....................109845....29727    27%
cmd/compile/internal/mips64...................972......168    17%
cmd/compile/internal/ppc64....................972......168    17%
cmd/compile/internal/x86.....................1104......195    18%
cmd/compile...................................329.......26     8%
cmd/cover...................................12986.....3749    29%
cmd/dist......................................477.......67    14%
cmd/doc.....................................23043.....6793    29%
cmd/expdump...................................167.......26    16%
cmd/fix......................................1190......208    17%
cmd/go......................................26399.....5629    21%
cmd/gofmt.....................................499.......26     5%
cmd/internal/gcprog..........................1342......490    37%
cmd/internal/goobj...........................2690......980    36%
cmd/internal/obj/arm........................32740....10057    31%
cmd/internal/obj/arm64......................46542....15364    33%
cmd/internal/obj/mips.......................42140....13731    33%
cmd/internal/obj/ppc64......................42140....13731    33%
cmd/internal/obj/x86........................52732....19015    36%
cmd/internal/obj............................36729....11690    32%
cmd/internal/objfile........................36365....10287    28%
cmd/link/internal/amd64.....................45893....12220    27%
cmd/link/internal/arm.........................307.......96    31%
cmd/link/internal/arm64.......................345.......98    28%
cmd/link/internal/ld.......................109300....46326    42%
cmd/link/internal/ppc64.......................344.......99    29%
cmd/link/internal/x86.........................334......107    32%
cmd/link......................................314.......26     8%
cmd/newlink..................................8110.....2544    31%
cmd/nm........................................210.......26    12%
cmd/objdump...................................244.......26    11%
cmd/pack....................................14248.....4066    29%
cmd/pprof/internal/commands..................5239.....1285    25%
cmd/pprof/internal/driver...................37967.....8860    23%
cmd/pprof/internal/fetch....................30962.....7337    24%
cmd/pprof/internal/plugin...................47734.....7719    16%
cmd/pprof/internal/profile..................22286.....6922    31%
cmd/pprof/internal/report...................31187.....7838    25%
cmd/pprof/internal/svg.......................4315......965    22%
cmd/pprof/internal/symbolizer...............30051.....7397    25%
cmd/pprof/internal/symbolz..................28545.....6949    24%
cmd/pprof/internal/tempfile.................12550.....3356    27%
cmd/pprof.....................................563.......26     5%
cmd/trace....................................1455......636    44%
cmd/vendor/golang.org/x/arch/arm/armasm....168035....64737    39%
cmd/vendor/golang.org/x/arch/x86/x86asm.....26871.....8578    32%
cmd/vet.....................................38980.....9913    25%
cmd/vet/whitelist.............................102.......49    48%
cmd/yacc.....................................2518......926    37%
compress/bzip2...............................6326......129     2%
compress/flate...............................7069.....2541    36%
compress/gzip...............................20143.....5069    25%
compress/lzw..................................828......295    36%
compress/zlib...............................10676.....2692    25%
container/heap................................523......181    35%
container/list...............................3517......740    21%
container/ring................................881......229    26%
crypto/aes....................................550......187    34%
crypto/cipher................................1966......825    42%
crypto.......................................1836......646    35%
crypto/des....................................632......235    37%
crypto/dsa..................................18718.....5035    27%
crypto/ecdsa................................23131.....6097    26%
crypto/elliptic.............................20790.....5740    28%
crypto/hmac...................................455......186    41%
crypto/md5...................................1375......171    12%
crypto/rand.................................18132.....4748    26%
crypto/rc4....................................561......240    43%
crypto/rsa..................................22094.....6380    29%
crypto/sha1..................................1416......172    12%
crypto/sha256.................................551......238    43%
crypto/sha512.................................839......378    45%
crypto/subtle................................1153......250    22%
crypto/tls..................................58203....17984    31%
crypto/x509/pkix............................29447.....8161    28%
database/sql/driver..........................3318.....1096    33%
database/sql................................11258.....3942    35%
debug/dwarf.................................18416.....7006    38%
debug/elf...................................57530....21014    37%
debug/gosym..................................4992.....2058    41%
debug/macho.................................23037.....6538    28%
debug/pe....................................21063.....6619    31%
debug/plan9obj...............................2467......802    33%
encoding/ascii85.............................1523......360    24%
encoding/asn1................................1718......527    31%
encoding/base32..............................2642......686    26%
encoding/base64..............................3077......800    26%
encoding/binary..............................4727.....1040    22%
encoding/csv................................12223.....2850    23%
encoding......................................383......217    57%
encoding/gob................................37563....10113    27%
encoding/hex.................................1327......390    29%
encoding/json...............................30897.....7804    25%
encoding/pem..................................595......200    34%
encoding/xml................................37798.....9336    25%
errors........................................274.......36    13%
expvar.......................................3155.....1021    32%
flag........................................19860.....2849    14%
fmt..........................................3137.....1263    40%
go/ast......................................44729....13422    30%
go/build....................................16336.....4657    29%
go/constant..................................3703......846    23%
go/doc.......................................9877.....2807    28%
go/format....................................5472.....1575    29%
go/importer..................................4980.....1301    26%
go/internal/gccgoimporter....................5587.....1525    27%
go/internal/gcimporter.......................8979.....2186    24%
go/parser...................................20692.....5304    26%
go/printer...................................7015.....2029    29%
go/scanner...................................9719.....2824    29%
go/token.....................................7933.....2465    31%
go/types....................................64569....19978    31%
hash/adler32.................................1176......176    15%
hash/crc32...................................1663......360    22%
hash/crc64...................................1587......306    19%
hash/fnv.....................................3964......260     7%
hash..........................................591......278    47%
html..........................................217.......74    34%
html/template...............................69623....12588    18%
image/color/palette...........................315.......98    31%
image/color..................................5565.....1036    19%
image/draw...................................6917.....1028    15%
image/gif....................................8894.....1654    19%
image/internal/imageutil.....................9112.....1476    16%
image/jpeg...................................6647.....1026    15%
image/png....................................6906.....1069    15%
image.......................................28992.....6139    21%
index/suffixarray...........................17106.....4773    28%
internal/singleflight........................1614......506    31%
internal/testenv............................12212.....3152    26%
internal/trace...............................2762.....1323    48%
io/ioutil...................................13502.....3682    27%
io...........................................6765.....2482    37%
log.........................................11620.....3317    29%
log/syslog..................................13516.....3821    28%
math/big....................................21819.....8320    38%
math/cmplx...................................2816......438    16%
math/rand....................................2317......929    40%
math.........................................7511.....2444    33%
mime/multipart..............................12679.....3360    27%
mime/quotedprintable.........................5458.....1235    23%
mime.........................................6076.....1628    27%
net/http/cgi................................59796....17173    29%
net/http/cookiejar..........................14781.....3739    25%
net/http/fcgi...............................57861....16426    28%
net/http/httptest...........................84100....24365    29%
net/http/httputil...........................67763....18869    28%
net/http/internal............................6907......637     9%
net/http/pprof..............................57945....16316    28%
net/http....................................95391....30210    32%
net/internal/socktest........................4555.....1453    32%
net/mail....................................14481.....3608    25%
net/rpc/jsonrpc.............................33335......988     3%
net/rpc.....................................79950....23106    29%
net/smtp....................................57790....16468    28%
net/textproto...............................11356.....3248    29%
net/url......................................3123.....1009    32%
os/exec.....................................20738.....5769    28%
os/signal.....................................437......167    38%
os..........................................24875.....6668    27%
path/filepath...............................11340.....2826    25%
path..........................................778......285    37%
reflect.....................................15469.....5198    34%
regexp......................................13627.....4661    34%
regexp/syntax................................5539.....2249    41%
runtime/debug................................9275.....2322    25%
runtime/pprof................................1355......477    35%
runtime/race...................................39.......17    44%
runtime/trace.................................228.......92    40%
runtime.....................................13498.....1821    13%
sort.........................................2848......842    30%
strconv......................................2947.....1252    42%
strings......................................7983.....2456    31%
sync/atomic..................................2666.....1149    43%
sync.........................................2568......845    33%
syscall.....................................81252....38398    47%
testing/iotest...............................2444......302    12%
testing/quick...............................18890.....5076    27%
testing.....................................16502.....4800    29%
text/scanner.................................6849.....2052    30%
text/tabwriter...............................6607.....1863    28%
text/template/parse.........................22978.....6183    27%
text/template...............................64153....11518    18%
time........................................12103.....3546    29%
unicode......................................9706.....3320    34%
unicode/utf16................................1055......148    14%
unicode/utf8.................................1118......513    46%
vendor/golang.org/x/net/http2/hpack..........8905.....2636    30%

All packages                              3518505  1017774    29%

Change-Id: Id657334f276383ff1e6fa91472d3d1db5a03349c
Reviewed-on: https://go-review.googlesource.com/13937
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-10-22 21:01:29 +00:00
Robert Griesemer
3319ea98cd cmd/compile/internal/gc: fixed comments (cosmetic change)
Change-Id: I9cbbfcf55ce3cccb6f14b9ffe6777567dcdad9c9
Reviewed-on: https://go-review.googlesource.com/16179
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-10-22 18:04:20 +00:00
Keith Randall
f206b16ff7 [dev.ssa] cmd/compile: assign unused registers to phi ops
Register phis are better than stack phis.  If we have
unused registers available, use them for phis.

Change-Id: I3045711c65caa1b6d0be29131b87b57466320cc2
Reviewed-on: https://go-review.googlesource.com/16080
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2015-10-22 17:06:10 +00:00
Ian Lance Taylor
0c69f1303f cmd/compile: add -msan option
The -msan option causes the compiler to add instrumentation for the
C/C++ memory sanitizer.  Every memory read/write will be preceded by
a call to msanread/msanwrite.

This CL passes tests but is not usable by itself.  The actual
implementation of msanread/msanwrite in the runtime package, and support
for -msan in the go tool and the linker, and tests, will follow in
subsequent CLs.

Change-Id: I3d517fb3e6e65d9bf9433db070a420fd11f57816
Reviewed-on: https://go-review.googlesource.com/16160
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-10-21 14:58:53 +00:00
Ian Lance Taylor
9e902f0f3a cmd/compile: generalize racewalk to instrument (naming change)
This is mechanical change that is a step toward reusing the racewalk
pass for a more general instrumentation pass.  The first use will be to
add support for the memory sanitizer.

Change-Id: I75b93b814ac60c1db1660e0b9a9a7d7977d86939
Reviewed-on: https://go-review.googlesource.com/16105
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-10-21 13:55:23 +00:00
Aaron Jacobs
d8c6bf916e cmd/compile: remove a stray word in the go:nosplit documentation
Change-Id: I7a85c0ad8aba2d50032c8faa58c83fb327f360cf
Reviewed-on: https://go-review.googlesource.com/16140
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-21 04:51:54 +00:00
acanino
b60c8203ea cmd/compile: "invalid variable name x in type switch", where x is a name of a constant
Small fix: looks like a short variable declaration with a type switch
checks to make sure the variable used had valid shape (ONAME, OTYPE, or
ONONAME) and rejects everything else. Then a new variable is declared.
If the symbol contained in the declaration was a named OLITERAL (still a
valid identifier obviously) it would be rejected, even though a new
variable would have been declared.

Fix adds this case to the check.

Added a test case from issue12413.

Fixes #12413

Change-Id: I150dadafa8ee5612c867d58031027f2dca8c6ebc
Reviewed-on: https://go-review.googlesource.com/15760
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-21 04:21:16 +00:00
Robert Griesemer
76285213b8 cmd/compile/internal/gc: there are no -0 floating-point constants
Fixes #12577.

Change-Id: Id469cd92f5f9436b0ef948ee1a252ed1842bc7aa
Reviewed-on: https://go-review.googlesource.com/16133
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2015-10-20 22:11:11 +00:00
Keith Randall
fbfc18c522 [dev.ssa] cmd/compile: don't issue nops for static data
It confuses live variable analysis to have a bunch of unreachable
no-ops at the end of a function.  Symptom is:
    gc/plive.go:483 panic: interface conversion: interface {} is nil, not *gc.BasicBlock

I don't see any reason why the old compiler needs these no-ops either.
all.bash passes with the equivalent code removed on master.

Change-Id: Ifcd2c3e139aa16314f08aebc9079b2fb7aa60556
Reviewed-on: https://go-review.googlesource.com/16132
Reviewed-by: David Chase <drchase@google.com>
2015-10-20 21:59:01 +00:00