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

5812 Commits

Author SHA1 Message Date
Dave Cheney
7ce0261387 cmd/dist: respect runtime.NumCPU when bootstrapping arm hosts
This is a reproposal of CL 2957. This reproposal restricts the
scope of this change to just arm systems.

With respect to rsc's comments on 2957, on all my arm hosts they perform
the build significantly faster with this change in place.

Change-Id: Ie09be1a73d5bb777ec5bca3ba93ba73d5612d141
Reviewed-on: https://go-review.googlesource.com/5834
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-25 00:15:12 +00:00
Rob Pike
aff84b171c cmd/asm: fix build for new aliases
Missing leading A on names.

Change-Id: I6f3a66bdd3a21220f45a898f0822930b6a7bfa38
Reviewed-on: https://go-review.googlesource.com/5801
Reviewed-by: Rob Pike <r@golang.org>
2015-02-24 20:31:30 +00:00
Rob Pike
90590a0cd2 cmd/asm: add alias for MOVOA=MOVO on amd64
The alias should exist for both 386 and amd64.
There were a few others missing as well. Add them.

Change-Id: Ia0c3e71abc79f67a7a66941c0d932a8d5d6e9989
Reviewed-on: https://go-review.googlesource.com/5800
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-24 20:01:21 +00:00
David Crawshaw
291bf1f03f cmd/go: limit default darwin/arm parallelism
iOS devices can only run tests serially.

Change-Id: I3f4e7abddf812a186895d9d5138999c8bded698f
Reviewed-on: https://go-review.googlesource.com/5751
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-02-24 17:28:53 +00:00
Russ Cox
a91c2e0d2d [dev.cc] cmd/internal/obj: set ctxt.Windows != 0 on windows
May fix windows build.

Change-Id: Ic4e32a4478caf758da6b02bc9126ddacb0fc07e0
Reviewed-on: https://go-review.googlesource.com/5650
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-02-23 21:49:27 +00:00
Russ Cox
382b44eb7c [dev.cc] cmd/5g etc: code cleanup: delay var decls and eliminate dead code
Ran rsc.io/grind rev 6f0e601 on the source files.

The cleanups move var declarations as close to the use
as possible, splitting disjoint uses of the var into separate
variables. They also remove dead code (especially in
func sudoaddable), which helps with the var moving.

There's more cleanup to come, but this alone cuts the
time spent compiling html/template on my 2013 MacBook Pro
from 3.1 seconds to 2.3 seconds.

Change-Id: I4de499f47b1dd47a560c310bbcde6b08d425cfd6
Reviewed-on: https://go-review.googlesource.com/5637
Reviewed-by: Rob Pike <r@golang.org>
2015-02-23 21:36:06 +00:00
Russ Cox
3af0d791be [dev.cc] cmd/6a, cmd/6g etc: replace C implementations with Go implementations
Change-Id: I58e00a39cf63df07813d21453f91e68eef6a413c
Reviewed-on: https://go-review.googlesource.com/5635
Reviewed-by: Rob Pike <r@golang.org>
2015-02-23 19:56:40 +00:00
Russ Cox
d10ede5ede [dev.cc] cmd/dist, cmd/go: stop building C implementations of compilers, assemblers
Also stop building objwriter, which was only used by them.

Change-Id: Ia2353abd9426026a81a263cb46a72dd39c360ce4
Reviewed-on: https://go-review.googlesource.com/5634
Reviewed-by: Rob Pike <r@golang.org>
2015-02-23 19:56:31 +00:00
Russ Cox
9c8c0e729d [dev.cc] cmd/internal/gc: reconvert to pick up bug fixes
Convert using rsc.io/c2go rev a97ff47.

Notable changes:
- %% in format string now correctly preserved
- reintroduce "signal handler" to hide internal faults
  after errors have been printed

Change-Id: Ic5a94f1c3a8015a9054e21c8969b52d964a36c45
Reviewed-on: https://go-review.googlesource.com/5633
Reviewed-by: Rob Pike <r@golang.org>
2015-02-23 19:56:18 +00:00
Rob Pike
9d6ed4af66 [dev.cc] cmd/asm: add end to end test for amd64
Change-Id: I40839c2d1c0c105a5ba9aadcb55a13693bf4afa6
Reviewed-on: https://go-review.googlesource.com/5592
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-23 19:54:39 +00:00
Russ Cox
264c099ba7 [dev.cc] cmd/go: do not install tools while executing them
Change-Id: I3417efc203f555a0a6101701f387ead84f9a08d1
Reviewed-on: https://go-review.googlesource.com/5577
Reviewed-by: Rob Pike <r@golang.org>
2015-02-23 19:30:08 +00:00
Russ Cox
e8d9c8d163 [dev.cc] all: merge master (6a10f72) into dev.cc
To pick up darwin/arm fix and hopefully fix build.

Change-Id: I06996d0b13b777e476f65405aee031482fc76439
2015-02-23 14:28:54 -05:00
David Crawshaw
2f9c9e552d cmd/go: link cgo into tests on darwin/arm
We currently have only one supported darwin/arm device, a locked iOS
machine. It requires cgo binaries.

Change-Id: If36a152e6a743e4a58ea3470e62cccb742630a5d
Reviewed-on: https://go-review.googlesource.com/5443
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-23 17:17:49 +00:00
Russ Cox
53d4123fbc [dev.cc] cmd/new6g, etc: reconvert to add profiling
Converted from rsc.io/c2go rev a9bc7f2.
Adds profiling support.

Change-Id: Ie04f86b71e0713c7294416c77d349e0d93798403
Reviewed-on: https://go-review.googlesource.com/5574
Reviewed-by: Rob Pike <r@golang.org>
2015-02-23 16:52:11 +00:00
Russ Cox
de50bad121 [dev.cc] all: merge master (48469a2) into dev.cc
Change-Id: I10f7950d173b302151f2a31daebce297b4306ebe
2015-02-23 10:16:29 -05:00
Russ Cox
7cec2157b8 [dev.cc] cmd/go: fix expansion of cmd
This was supposed to be in the previous CL, but I forgot to 'git rw' it down.

Change-Id: Ia5e14ca2c7640f08abbbed1a777a6cf04d71d0e7
Reviewed-on: https://go-review.googlesource.com/5570
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-23 15:14:57 +00:00
Russ Cox
096b294f21 [dev.cc] cmd/go: fix expansion of 'std', add 'cmd'
The wildcard 'std' is defined in documentation to be all the packages
in the Go standard library. It has also historically matched commands
in the main repo, but as we implement core commands in Go, that
becomes problematic. We need a wildcard that means just the library,
and since 'std' is already documented to have that definition, make it so.

Add a new wildcard 'cmd' for the commands in the main repo ($GOROOT).
Commands that want both can say 'std cmd' (or 'cmd std') to get the
effect of the old 'std'.

Update make.bash etc to say both std and cmd most of the time.

Exception: in race.bash, do not install race-enabled versions of
the actual commands. This avoids trying to write binaries while
using them, but more importantly it avoids enabling the race
detector and its associated memory overhead for the already
memory-hungry compilers.

Change-Id: I26bb06cb13b636dfbe71a015ee0babeb270a0275
Reviewed-on: https://go-review.googlesource.com/5550
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-02-23 15:13:17 +00:00
David du Colombier
48469a2c86 cmd/ld: fix warning on Plan 9
cpp: src/cmd/ld/lib.h:349 No newline at end of file

Change-Id: Id21851963f7778364ba9337da3bacd312443f51f
Reviewed-on: https://go-review.googlesource.com/5520
Reviewed-by: Minux Ma <minux@golang.org>
2015-02-23 07:54:13 +00:00
Russ Cox
6406acf338 [dev.cc] cmd/asm/internal/asm: fix test on windows
Change-Id: Ia6cf3204d71740bc2b6e26c53ac5206e8a33a180
Reviewed-on: https://go-review.googlesource.com/5540
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-21 17:54:38 +00:00
Russ Cox
c80ff3cb87 [dev.cc] cmd/go: reenable verifyCompiler
Change-Id: Ic7367f2c6e6d4e6b802ce8436022412a1862ca58
Reviewed-on: https://go-review.googlesource.com/5472
Reviewed-by: Rob Pike <r@golang.org>
2015-02-21 14:03:14 +00:00
Russ Cox
f6791da7ad [dev.cc] cmd/new6g etc: reconvert from C
Reconvert using rsc.io/c2go rev 27b3f59.
(Same as last conversion, but C sources have changed
due to merging master into this branch.)

Change-Id: Ib314bb9ac14a726ceb83e2ecf4d1ad2d0b331c38
Reviewed-on: https://go-review.googlesource.com/5471
Reviewed-by: Rob Pike <r@golang.org>
2015-02-21 14:03:04 +00:00
Rob Pike
1996f276d2 [dev.cc] cmd/asm: fix build: broken end to end test
This time for sure.

Change-Id: I77ed6b70d82a6f4ba371afba2f53c8b146ac110f
Reviewed-on: https://go-review.googlesource.com/5530
Reviewed-by: Rob Pike <r@golang.org>
2015-02-21 03:33:09 +00:00
Rob Pike
7ed429d99c [dev.cc] cmd/asm: fix build
Representation in printout of MRC instruction differs between
32- and 64-bit machines. It's just a hex dump. Fix this one day,
but for now just comment out the instruction.

Change-Id: I4709390659e2e0f2d18ff6f8e762f97cdbfb4c16
Reviewed-on: https://go-review.googlesource.com/5424
Reviewed-by: Rob Pike <r@golang.org>
2015-02-21 02:16:37 +00:00
Rob Pike
634049dbe6 [dev.cc] cmd/asm: add end-to-end test
Add trivial golden test that verifies output matches expectation.
The input is based on the old grammar and is intended to cover
the space of the input language.

PPC64 and ARM only for now; others to follow.

Change-Id: Ib5957822bcafd5b9d4c1dea1c03cc6ee1238f7ef
Reviewed-on: https://go-review.googlesource.com/5421
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-21 02:02:23 +00:00
Rob Pike
5d111b898a [dev.cc] cm/asm: fix up arm after cross-check with 5a
As with the previous round for ppc64, this CL fixes a couple of things
that 5a supported but asm did not, both simple.

1) Allow condition code on MRC instruction; this was marked as a TODO.
2) Allow R(n) notation in ARM register shifts.  The code needs a rethink
but the tests we're leading toward will make the rewrite easier to test and
trust.

Change-Id: I5b52ad25d177a74cf07e089dddfeeab21863c424
Reviewed-on: https://go-review.googlesource.com/5422
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-21 01:53:30 +00:00
Russ Cox
9c0c050773 [dev.cc] cmd/asm: add ppc64le support
Change-Id: I780ed76c9217d387a73fd7530af2f40948aa1fe4
Reviewed-on: https://go-review.googlesource.com/5452
Reviewed-by: Rob Pike <r@golang.org>
2015-02-20 18:42:54 +00:00
Russ Cox
cf6a77b36d [dev.cc] cmd/go: install cmd/asm as a tool
cmd/dist was doing the right thing, but not cmd/go.

Change-Id: I5412140cfc07e806152915cc49db7f63352d01ca
Reviewed-on: https://go-review.googlesource.com/5451
Reviewed-by: Rob Pike <r@golang.org>
2015-02-20 18:42:49 +00:00
Dmitry Vyukov
edadffa2f3 cmd/trace: add new command
Trace command allows to visualize and analyze traces.
Run as:
$ go tool trace binary trace.file
The commands opens web browser with the main page,
which contains links for trace visualization,
blocking profiler, network IO profiler and per-goroutine
traces.

Also move trace parser from runtime/pprof/trace_parser_test.go
to internal/trace/parser.go, so that it can be shared between
tests and the command.

Change-Id: Ic97ed59ad6e4c7e1dc9eca5e979701a2b4aed7cf
Reviewed-on: https://go-review.googlesource.com/3601
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-02-20 18:31:25 +00:00
Rob Pike
adff896e4c [dev.cc] cmd/asm: implement FMADD for ppc64
Missed this one instruction in the previous pass.

Change-Id: Ic8cdae4d3bfd626c6bbe0ce49fce28b53db2ad1c
Reviewed-on: https://go-review.googlesource.com/5420
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-20 16:34:15 +00:00
Russ Cox
b4a7806724 [dev.cc] all: merge master (5868ce3) into dev.cc
This time for sure!

Change-Id: I7e7ea24edb7c2f711489e162fb97237a87533089
2015-02-20 10:28:36 -05:00
Russ Cox
d90bbf91d4 [dev.cc] cmd/go: disable verifyCompiler
The merge brought in new C sources without Go updates.

Change-Id: Iad08b58f894173a7b34396275b72db34f3031fe3
Reviewed-on: https://go-review.googlesource.com/5352
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-20 15:26:21 +00:00
Ingo Oeser
668762c570 cmd/go: simplify/fix handling private github repos
Before Go 1.4, the traditional way to work with a private Github
repository was to run something similar the following:

```
git config --global url."git@github.com:".insteadOf "https://github.com/"
```

It would allow go get and friends to transparently work as expected,
automatically rewriting https URLs to use SSH for auth. This worked both
when pushing and pulling.

In Go 1.4 this broke, now requiring the use of `go get -f` instead of `go get`
in order to fetch private repositories. This seems neither intended nor
practical, as it requires changing a lot of tooling.

So just use `git config remote.origin.url` instead of `git remote -v` as
this reflects the actual substitution intended in the `insteadOf` config
directive.

Also remove now useless parsing.

Also add a check against supported schemes to avoid errors in later
commands using this URL and expecting such a scheme.

Fixes #9697

Change-Id: I907327f83504302288f913a68f8222a5c2d673ee
Reviewed-on: https://go-review.googlesource.com/3504
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-02-20 03:21:29 +00:00
Rob Pike
5b9429d122 [dev.cc] cmd/asm: bring asm on ppc64 in sync with 9a
I created a .s file that covered every instruction and operand production
in 9a/a.y and made sure that 9a and asm give bit-identical results for it.
I found a few things, including one addressing mode (R1+R2) that was
not present in the source we use. Fixed those

I also found quite a few things where 9a's grammar accepts the instruction
but liblink rejects it. These need to be sorted out, and I will do that separately.
Once that's done, I'll turn my test file into a proper test.

Change-Id: Ib093271b0f7ffd64ffed164ed2a820ebf2420e34
Reviewed-on: https://go-review.googlesource.com/5361
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-20 00:42:09 +00:00
Russ Cox
dc7b54bed2 [dev.cc] cmd/internal/obj, cmd/internal/gc, new6g: reconvert
Reconvert using rsc.io/c2go rev 27b3f59.

Changes to converter:
 - fatal does not return, so no fallthrough after fatal in switch
 - many more function results and variables identified as bool
 - simplification of negated boolean expressions

Change-Id: I3bc67da5e46cb7ee613e230cf7e9533036cc870b
Reviewed-on: https://go-review.googlesource.com/5171
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-02-20 00:17:03 +00:00
Russ Cox
786825c5e8 [dev.cc] cmd/gc: tweak default fatal in ordersafeexpr for c2go
c2go was putting a fallthrough after the fatal call.
Changed c2go to know that fatal doesn't return,
but then there is a missing return at the end of
the translated Go function.
Move code around a little to make C and Go agree.

Change-Id: Icef3d55ccdde0709c02dd0c2b78826f6da33a146
Reviewed-on: https://go-review.googlesource.com/5170
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-02-20 00:16:53 +00:00
Andrew Gerrand
5f84238444 cmd/dist: show friendlier error message when building outside a Git repo
Fixes #9932

Change-Id: I7943470a1784278a5c6e99c3b66c59d4953734ba
Reviewed-on: https://go-review.googlesource.com/5340
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-19 22:33:45 +00:00
Rob Pike
caf2bf26f8 [dev.cc] cmd/go: enable verifyAsm for all architectures
Change-Id: Ia1ba28c81e31d149c59a48d5f71628ac0ff14d8e
Reviewed-on: https://go-review.googlesource.com/5283
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-19 21:10:27 +00:00
Rob Pike
f60fb5c5ad [dev.cc] cmd/asm: accept #define A /* nothing */
Was rejected but should be legal.

Change-Id: I0189e3bef6b67c6ba390c75a48a8d9d8f39b7636
Reviewed-on: https://go-review.googlesource.com/5286
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-19 21:06:51 +00:00
Dmitry Vyukov
d384545a45 cmd/pprof: add -runtime flag
The flag disables stripping of runtime frames in profiles.
This is useful when analyzing runtime itself.

Before:
$ go tool pprof --text --alloc_objects --lines fmt.test /tmp/mprof
      flat  flat%   sum%        cum   cum%
      2768 79.65% 79.65%      32768 79.65%  fmt_test.TestComplexFormatting fmt/fmt_test.go:744
      6554 15.93% 95.58%       6554 15.93%  regexp/syntax.(*compiler).rune regexp/syntax/compile.go:267
      1820  4.42%   100%       1820  4.42%  runtime.malg runtime/proc1.go:1977

After:
$ go tool pprof --text --alloc_objects --lines --runtime fmt.test /tmp/mprof
      flat  flat%   sum%        cum   cum%
     32768 79.65% 79.65%      32768 79.65%  runtime.convT2E runtime/iface.go:139
      6554 15.93% 95.58%       6554 15.93%  runtime.growslice runtime/slice.go:89
      1820  4.42%   100%       1820  4.42%  runtime.malg runtime/proc1.go:1977

Change-Id: If468dfa5c5bbd0809c45a58d912d3115fac009ed
Reviewed-on: https://go-review.googlesource.com/5291
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-02-19 19:46:20 +00:00
Rob Pike
e559c5cce2 [dev.cc] cmd/asm: add ppc64
Fairly straightforward. A couple of unusual addressing tricks.
Also added the ability to write R(10) to mean R10. PPC64 uses
this for a couple of large register spaces. It appears for ARM now
as well, since I saw some uses of that before, although I rewrote
them in our source. I could put it in for 386 and amd64 but it's
not worth it.

Change-Id: I3ffd7ffa62d511b95b92c3c75b9f1d621f5393b6
Reviewed-on: https://go-review.googlesource.com/5282
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-19 05:12:20 +00:00
Rob Pike
43a01db9a4 [dev.cc] cmd/9a,new9a: set v=1 on static names
Oversight in 9a: did not set the static bit in the assembler for
symbols with <>.

Change-Id: Id508dcd3ed07733e60395aefa86d0035faab14a9
Reviewed-on: https://go-review.googlesource.com/5280
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-19 04:00:19 +00:00
Russ Cox
d0c21af7d3 [dev.cc] cmd/9a, cmd/new9a: fix line numbers
Fixed for the other assemblers in CL 2297042 in 2010.

Change-Id: I6cf41c569e884d98d295369e60e550ff8c0884e6
Reviewed-on: https://go-review.googlesource.com/5173
Reviewed-by: Rob Pike <r@golang.org>
2015-02-18 18:49:21 +00:00
Russ Cox
09d7db3bbb [dev.cc] cmd/dist, cmd/go: build new6g etc and verify against 6g
Change-Id: Ide7cff506274ec76d26bdffe7890ca2c28737f2b
Reviewed-on: https://go-review.googlesource.com/4852
Reviewed-by: Rob Pike <r@golang.org>
2015-02-18 15:09:04 +00:00
David du Colombier
2bcfe8b935 cmd/gc: replace NULL by nil
In CL 3964, NULL was used instead of nil.
However, Plan 9 doesn't declare NULL.

Change-Id: Ied3850aca5c8bca5974105129a37d575df33f6ec
Reviewed-on: https://go-review.googlesource.com/5150
Reviewed-by: Minux Ma <minux@golang.org>
2015-02-18 07:49:04 +00:00
Dmitry Vyukov
3a0fbfab57 cmd/gc: generate simpler names for closures
Fixes #8291

There were several complaints about closure names in the issue tracker.
The first problem is that you see names like net/http.func·001
in profiles, traces, etc. And there is no way to figure out what
is that function.
Another issue is non-US-ascii symbols. All programs out there
should accept UTF-8. But unfortunately it is not true in reality.
For example, less does not render middle dot properly.

This change prepends outer function name to closure name and
replaces middle dot with dot. Now names look like:

main.glob.func1
main.glob.func2
main.glob.func2.1
main.init.1
main.init.1.func1
main.init.1.func1.1
main.main.func1
main.main.func1.1

Change-Id: I725726af88f2ad3ced2e3450f0f06bf459fd91c0
Reviewed-on: https://go-review.googlesource.com/3964
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-18 07:09:50 +00:00
Rob Pike
575bdd6753 [dev.cc] cmd/internal/obj/ppc64: set Ctxt when allocating Progs
This will get fixed properly upstream, but this will serve for now.

Change-Id: I25e5210d190bc7a06a5b9f80724e3360d1a6b10c
Reviewed-on: https://go-review.googlesource.com/5121
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-18 05:01:25 +00:00
Rob Pike
345350bf07 [dev.cc] cmd/asm: make 4(SP) illegal except on 386
Require a name to be specified when referencing the pseudo-stack.
If you want a real stack offset, use the hardware stack pointer (e.g.,
R13 on arm), not SP.

Fix affected assembly files.

Change-Id: If3545f187a43cdda4acc892000038ec25901132a
Reviewed-on: https://go-review.googlesource.com/5120
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-02-18 03:41:29 +00:00
Russ Cox
c7fa3c625e [dev.cc] cmd/yacc: introduce yyParser to expose parser state
Historically, yacc has supported various kinds of inspections
and manipulations of the parser state, exposed as global variables.
The Go implementation of yacc puts that state (properly) in local
stack variables, so it can only be exposed explicitly.

There is now an explicit parser type, yyParser, returned by a
constructor, yyNewParser.

	type yyParser interface {
		Parse(yyLexer) int
		Lookahead() int
	}

Parse runs a parse. A call to the top-level func Parse
is equivalent to calling yyNewParser().Parse, but constructing
the parser explicitly makes it possible to access additional
parser methods, such as Lookahead.

Lookahead can be called during grammar actions to read
(but not consume) the value of the current lookahead token,
as returned by yylex.Lex. If there is no current lookahead token,
Lookahead returns -1. Invoking Lookahead corresponds to
reading the global variable yychar in a traditional Unix yacc grammar.

To support Lookahead, the internal parsing code now separates
the return value from Lex (yychar) from the reencoding used
by the parsing tables (yytoken). This has the effect that grammars
that read yychar directly in the action (possible since the actions
are in the same function that declares yychar) now correctly see values
from the Lex return value space, not the internal reencoding space.
This can fix bugs in ported grammars not even using SetParse and Lookahead.
(The reencoding was added on Plan 9 for large character sets.
No Plan 9 programs using yacc looked at yychar.)

Other methods may be added to yyParser later as needed.
Obvious candidates include equivalents for the traditional
yyclearin and yyerrok macros.

Change-Id: Iaf7649efcf97e09f44d1f5bc74bb563a11f225de
Reviewed-on: https://go-review.googlesource.com/4850
Reviewed-by: Rob Pike <r@golang.org>
2015-02-18 02:39:48 +00:00
Rob Pike
2633f2aad4 [dev.cc] cmd/asm/internal/asm: add operand parsing tests for 386 and arm
Change-Id: If2aafc4dd3f91650fc7727ea7d534ad7aa627c8c
Reviewed-on: https://go-review.googlesource.com/5090
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-18 01:49:41 +00:00
Russ Cox
8c195bdf12 [dev.cc] cmd/internal/gc, cmd/new6g etc: convert from cmd/gc, cmd/6g etc
First draft of converted Go compiler, using rsc.io/c2go rev 83d795a.

Change-Id: I29f4c7010de07d2ff1947bbca9865879d83c32c3
Reviewed-on: https://go-review.googlesource.com/4851
Reviewed-by: Rob Pike <r@golang.org>
2015-02-17 23:28:51 +00:00
Russ Cox
c11882bc3e [dev.cc] cmd/go: install new6g etc (once they are committed) to tool directory
Change-Id: I2853535ab6c79d14f430c780161e4c35c52d9fb3
Reviewed-on: https://go-review.googlesource.com/4839
Reviewed-by: Rob Pike <r@golang.org>
2015-02-17 23:28:41 +00:00
Russ Cox
2286989912 [dev.cc] cmd/gc, cmd/ld, runtime: minor tweaks for c2go
Change-Id: I3be69a4ebf300ad24b55b5f43fd7ad1f001c762e
Reviewed-on: https://go-review.googlesource.com/4838
Reviewed-by: Rob Pike <r@golang.org>
2015-02-17 23:28:32 +00:00
Russ Cox
535f29c68e [dev.cc] cmd/dist: write default GO386 for cmd/internal/obj
Change-Id: Ida60c30041505c321fbfc48b22b8ff5af1a3f474
Reviewed-on: https://go-review.googlesource.com/4837
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-02-17 23:28:24 +00:00
Rob Pike
aa55bd44b9 [dev.cc] cmd/asm: clean up jumps
Set TYPE_BRANCH for x(PC) in the parser and the assembler has less work to do.
This also makes the operand test handle -4(PC) correctly.

Also add a special test case for AX:DX, which should be fixed in obj really.

Change-Id: If195e3a8cf3454a73508633e9b317d66030da826
Reviewed-on: https://go-review.googlesource.com/5071
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-17 23:17:51 +00:00
Rob Pike
f14020a64e [dev.cc] cmd/asm/internal/asm: add operand parsing test
Generated by reducing all the amd64 operands in the core.
Will add 386 and ARM later; this is a trial balloon.

NOTE: There is at least one anomaly: AX:DX doesn't print correctly in this situation.

Change-Id: I9f327c1890b100e3edb7b1b2a1c01f3e4b798f43
Reviewed-on: https://go-review.googlesource.com/4967
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-17 20:23:52 +00:00
Rob Pike
09ce5d38d0 [dev.cc] cmd/asm: fix build: handle g in register lists on ARM
Handle the special name of R10 on the ARM - it's g - when it appears
in a register list [R0, g, R3]. Also simplify the pseudo-register parsing
a little.

Should fix the ARM build.

Change-Id: Ifcafc8195dcd3622653b43663ced6e4a144a3e51
Reviewed-on: https://go-review.googlesource.com/4965
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-17 17:23:10 +00:00
David Crawshaw
04774336b1 cmd/go: skip stat check when using -toolexec
Change-Id: Idc88b1ee950e33cfe757a27e9a3383d879793af7
Reviewed-on: https://go-review.googlesource.com/4934
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-17 12:21:45 +00:00
Rob Pike
412ce1f7d6 [dev.cc] cmd/go: enable verifyAsm for asm on ARM
Change-Id: I182ea770110255a5ac1c91cf30dd650696a8f1db
Reviewed-on: https://go-review.googlesource.com/4961
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-17 05:10:18 +00:00
Rob Pike
68bcc13291 [dev.cc] cmd/asm: fix build for x86 architectures
Mishandled the complex addressing mode in masks<>(SB)(CX*8)
as a casualty of the ARM work. Fix by backing all the flows up to
the state where registerIndirect is always called with the input
sitting on the opening paren.

With this, build passes for me with linux-arm, linux-386, and linux-amd64.

Change-Id: I7cae69a6fa9b635c79efd93850bd1e744b22bc79
Reviewed-on: https://go-review.googlesource.com/4964
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-17 04:55:38 +00:00
Rob Pike
188296e5bf [dev.cc] cmd/internal/asm: fix build: was mishandling SP reference on amd64
A consequence of the ARM work overlooked that SP is a real register
on x86, so we need to detect it specially.

This will be done better soon, but this is a fast fix for the build.

Change-Id: Ia30d111c3f42a5f0b5f4eddd4cc4d8b10470c14f
Reviewed-on: https://go-review.googlesource.com/4963
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-17 04:20:19 +00:00
Rob Pike
bf2d611a85 [dev.cc] cmd/internal/obj/arm: delete trailing space from AND instruction
The tools have been fixed to not do this, but verifyAsm depends on this
being fixed.

TBR=rsc

Change-Id: Ia8968cc803b3498dfa2f98188c6ed1cf2e11c66d
Reviewed-on: https://go-review.googlesource.com/4962
Reviewed-by: Rob Pike <r@golang.org>
2015-02-17 03:52:58 +00:00
Rob Pike
581c309d8f [dev.cc] cmd/internal/obj/arm: add a couple of missing settings of Ctxt
Change-Id: Ic33431cdcc93db300fc2c3467eafdb5340ee4896
Reviewed-on: https://go-review.googlesource.com/4924
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-17 03:37:27 +00:00
Rob Pike
c497349a5b [dev.cc] cmd/asm: support ARM
There are many peculiarites of the ARM architecture that require work:
condition codes, new instructions, new instruction arg counts, and more.

Rewrite the parser to do a cleaner job, flowing left to right through the
sequence of elements of an operand.

Add ARM to arch.
Add ARM-specific details to the arch in a new file, internal/arch/arm.
These are probably better kept away from the "portable" asm. However
there are some pieces, like MRC, that are hard to disentangle. They
can be cleaned up later.

Change-Id: I8c06aedcf61f8a3960a406c094e168182d21b972
Reviewed-on: https://go-review.googlesource.com/4923
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-17 03:37:17 +00:00
Rob Pike
ae2b145da2 [dev.cc] cmd/asm: fix macro definition bug in the lexer
Because text/scanner hides the spaces, the lexer treated
	#define A(x)
and
	#define A (x)
the same, but they are not: the first is an argument with macros, the
second is a simple one-word macro whose definition contains parentheses.
Fix this by noticing the relative column number as we move from A to (.
Hacky but simple.

Also add a helper to recognize the peculiar ARM shifted register operators.

Change-Id: I2cad22f5f1e11d8dad40ad13955793d178afb3ae
Reviewed-on: https://go-review.googlesource.com/4872
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-17 03:37:01 +00:00
Mikio Hara
18f273ff92 cmd/dist: don't use "uname -v" to recognize GOHOSTARCH
We can use processor architecture or hardware platform as part of
hostname and it leads to misconfiguration of GOHOSARCH.

For example,

$ uname -m -v
FreeBSD 10.1-RELEASE-p5 #0: Tue Jan 27 08:52:50 UTC 2015 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC i386

Change-Id: I499efd98338beff6a27c03f03273331ecb6fd698
Reviewed-on: https://go-review.googlesource.com/4944
Reviewed-by: Minux Ma <minux@golang.org>
2015-02-16 18:58:34 +00:00
Dmitry Vyukov
52dadc1f31 cmd/gc: fix noscan maps
Change 85e7bee introduced a bug:
it marks map buckets as noscan when key and val do not contain pointers.
However, buckets with large/outline key or val do contain pointers.

This change takes key/val size into consideration when
marking buckets as noscan.

Change-Id: I7172a0df482657be39faa59e2579dd9f209cb54d
Reviewed-on: https://go-review.googlesource.com/4901
Reviewed-by: Keith Randall <khr@golang.org>
2015-02-15 08:52:14 +00:00
Shenghou Ma
788f78ad08 cmd/go: remove script and script.txt
Fixes #9824.

Change-Id: Id318c61b6884e4fd294f7b0946dcc306f746ee0a
Reviewed-on: https://go-review.googlesource.com/4891
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-14 20:07:08 +00:00
David du Colombier
ad73dc349b cmd/gc: replace NULL by nil
In CL 4050, NULL was used instead of nil.
However, Plan 9 doesn't declare NULL.

Change-Id: I8295a3102509a1ce417278f23a37cbf65938cce1
Reviewed-on: https://go-review.googlesource.com/4814
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-13 22:13:42 +00:00
David Crawshaw
ae3229ae5c cmd/ld: always mark tlsg STLSBSS
Android apps build again.

Defining TLSG in runtime/tls_arm.s gives it the type SNOPTRBSS, so its
type was never being set when GOOS=android. I considered modifying the
if statement, but I no longer understand the intention of the original
change (in d738c6b0ca). We were always setting it before, what
platform is this not valid for?

Fixes #9829

Change-Id: I3eaa4a9590893eff67695797eb22547a170cdbcd
Reviewed-on: https://go-review.googlesource.com/4834
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
2015-02-13 21:27:21 +00:00
Shenghou Ma
855145d5c0 cmd/ld: set alignment for the .rel.plt section on 32-bit architectures
Fixes #9802.

Change-Id: I22c52a37bdb23a14cc4615c9519431bb14ca81ca
Reviewed-on: https://go-review.googlesource.com/4170
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-13 20:09:34 +00:00
Russ Cox
87de9ce212 [dev.cc] all: merge master (5f1efe7) into dev.cc
Conflicts:
	src/cmd/dist/build.go

Change-Id: I98a4b5e010bee91507b85bb8efd9c74e1a1f649c
2015-02-13 12:51:56 -05:00
Russ Cox
5f1efe738b cmd/ld: make cmd/ld a real library
Make cmd/ld a real library invoked by the individual linkers.
There are no reverse symbol references anymore
(symbols referred to in cmd/ld but defined in cmd/5l etc).

This means that in principle we could do an automatic
conversion of these to Go, as a stopgap until cmd/link is done
or as a replacement for cmd/link.

Change-Id: I4a94570257a3a7acc31601bfe0fad9dea0aea054
Reviewed-on: https://go-review.googlesource.com/4649
Reviewed-by: Rob Pike <r@golang.org>
2015-02-13 17:31:38 +00:00
Russ Cox
892286419e cmd/dist: avoid trailing space in instruction name strings
Change-Id: I2db4db852492eaddaf09dd7bae2fbd49f916e78a
Reviewed-on: https://go-review.googlesource.com/4648
Reviewed-by: Rob Pike <r@golang.org>
2015-02-13 17:31:29 +00:00
Russ Cox
5c87cf7608 cmd/gc: minor adjustments for C to Go translation
- remove a few uses of ? :
- rename variables named len
- rewrite a few gotos as nested switches
- move goto targets to scope allowed by Go
- use consistent return type of anyregalloc
  (was int or int32 in different places)
- remove unused nr variable in agen
- include proper headers in generated builtin1.c
- avoid strange sized %E formats (%-6E, %2E)
- change gengcmask argument from uint8[16] to uint8*
  (diagnosed by c2go; not an array in any real sense).
- replace #ifdef XXX with comment block in 5g/peep.c
- expand and remove FAIL macro from 5g
- expand and remove noimpl macro from 9g
- print regalloc errors to stdout in 8g
  (only use of fprint(2, ...) in all compilers)

Still producing bit-for-bit identical output.

Change-Id: Id46efcd2a89241082b234f63f375b66f2754d695
Reviewed-on: https://go-review.googlesource.com/4646
Reviewed-by: Austin Clements <austin@google.com>
2015-02-13 17:31:16 +00:00
Russ Cox
acba34e45f cmd/gc: eliminate some pointer arithmetic
In mparith, all the a1-- are problematic. Rewrite it all without pointers.
It's clearer anyway.

In popt, v is problematic because it is used both as a fixed pointer
(v = byvar[i]) and as a moving pointer (v = var; v++) aka slice.
Eliminate pointer movement.

Tested that this still produces bit-for-bit output for 'go build -a std'
compared to d260756 (current master).

Change-Id: I1a1bed0f98b594c3864fe95075dd95f9b52113e0
Reviewed-on: https://go-review.googlesource.com/4645
Reviewed-by: Austin Clements <austin@google.com>
2015-02-13 17:31:04 +00:00
Russ Cox
ff81c14fb2 cmd/gc: rename arch to thearch
Otherwise the exported variable collides with the type Arch.

While we're here, remove arch.dumpit (now in portable code)
and add arch.defframe (forgotten originally, somehow).

Change-Id: I1b3a7dd7e96c5f632dba7cd6c1217b42a2004d72
Reviewed-on: https://go-review.googlesource.com/4644
Reviewed-by: Austin Clements <austin@google.com>
2015-02-13 17:30:55 +00:00
Russ Cox
4b27c9d72e cmd/gc: add .y to error about missing x in x.y
If the Go source says x.y, and x is undefined, today we get

	undefined: x

Change to:

	undefined: x in x.y

Change-Id: I8ea95503bd469ea933c6bcbd675b7122a5d454f3
Reviewed-on: https://go-review.googlesource.com/4643
Reviewed-by: Austin Clements <austin@google.com>
2015-02-13 17:30:37 +00:00
Russ Cox
fa7efa2cb0 cmd/gc: add debugging to liveness analysis
Even with debugmerge = 1, the debugging output only happens
with the -v command-line flag. This is useful because it gets added
in automatically when debugging things like registerization with -R -v.

Change-Id: I9a5c7f562507b72e8e2fe2686fd07d069721345a
Reviewed-on: https://go-review.googlesource.com/4641
Reviewed-by: Austin Clements <austin@google.com>
2015-02-13 17:30:24 +00:00
Russ Cox
bed481d683 cmd/gc: correct errors in constant parsing
Change-Id: I36f77e7ac7f727d8f3b51133f4b3ef93c35b09f6
Reviewed-on: https://go-review.googlesource.com/4640
Reviewed-by: Austin Clements <austin@google.com>
2015-02-13 17:30:14 +00:00
Russ Cox
be4ecd9815 cmd/gc: avoid writing past end of region array
Noticed last week.
Just saw a strange build failure in the revised rcmp (called by qsort on region)
and this fixed it.

Submitting first to avoid finding out which of my pending CLs tickled the
problem.

Change-Id: I4cafd611e2bf8e813e57ad0025e48bde5ae54359
Reviewed-on: https://go-review.googlesource.com/4830
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-13 17:30:05 +00:00
Russ Cox
2e78447baf cmd/yacc: adjust expansion of $n to be more useful in errors
When the compiler echoes back an expression, it shows the
generated yacc expression. Change the generated code to
use a slice so that $3 shows up as yyDollar[3] in such messages.

Consider changing testdata/expr/expr.y to say:

	$$.Sub(float64($1), $3)

(The float64 conversion is incorrect.)

Before:
expr.y:70[expr.go:486]: cannot convert exprS[exprpt - 2].num (type *big.Rat) to type float64

After:
expr.y:70[expr.go:492]: cannot convert exprDollar[1].num (type *big.Rat) to type float64

Change-Id: I74e494069df588e62299d1fccb282f3658d8f8f4
Reviewed-on: https://go-review.googlesource.com/4630
Reviewed-by: Rob Pike <r@golang.org>
2015-02-13 17:29:36 +00:00
Dmitry Vyukov
c4ee44b7b9 cmd/gc: transform closure calls to function calls
Currently we always create context objects for closures that capture variables.
However, it is completely unnecessary for direct calls of closures
(whether it is func()(), defer func()() or go func()()).
This change transforms any OCALLFUNC(OCLOSURE) to normal function call.
Closed variables become function arguments.
This transformation is especially beneficial for go func(),
because we do not need to allocate context object on heap.
But it makes direct closure calls a bit faster as well (see BenchmarkClosureCall).

On implementation level it required to introduce yet another compiler pass.
However, the pass iterates only over xtop, so it should not be an issue.
Transformation consists of two parts: closure transformation and call site
transformation. We can't run these parts on different sides of escape analysis,
because tree state is inconsistent. We can do both parts during typecheck,
we don't know how to capture variables and don't have call site.
We can't do both parts during walk of OCALLFUNC, because we can walk
OCLOSURE body earlier.
So now capturevars pass only decides how to capture variables
(this info is required for escape analysis). New transformclosure
pass, that runs just before order/walk, does all transformations
of a closure. And later walk of OCALLFUNC(OCLOSURE) transforms call site.

benchmark                            old ns/op     new ns/op     delta
BenchmarkClosureCall                 4.89          3.09          -36.81%
BenchmarkCreateGoroutinesCapture     1634          1294          -20.81%

benchmark                            old allocs     new allocs     delta
BenchmarkCreateGoroutinesCapture     6              2              -66.67%

benchmark                            old bytes     new bytes     delta
BenchmarkCreateGoroutinesCapture     176           48            -72.73%

Change-Id: Ic85e1706e18c3235cc45b3c0c031a9c1cdb7a40e
Reviewed-on: https://go-review.googlesource.com/4050
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-13 12:12:18 +00:00
Shenghou Ma
3813799931 cmd/go: make consistent use of leading Tabs
The only remaining uses of four spaces instead of a tab is
when the line is too long (e.g. type Package).

Fixes #9809

Change-Id: Ifffd3639aa9264e795686ef1879a7686f182d2e5
Reviewed-on: https://go-review.googlesource.com/4182
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-02-13 07:29:28 +00:00
Dmitry Vyukov
612d78d681 cmd/gc: restore amd64p32 hack for bucket size
This was accidentially removed in:
https://go-review.googlesource.com/#/c/3508/8/src/cmd/gc/reflect.c

Change-Id: I06dd5bb0cb3e2811bd4ef605d7a5225cfa033fe0
Reviewed-on: https://go-review.googlesource.com/4731
Reviewed-by: Keith Randall <khr@golang.org>
2015-02-13 07:02:54 +00:00
Josh Bleecher Snyder
01ef6dbfa5 cmd/5g, cmd/6g, cmd/8g, cmd/9g: use a register to zero in componentgen
Using a zero register results in shorter, faster code.
5g already did this. Bring 6g, 8g, and 9g up to speed.
Reduces godoc binary size by 0.29% using 6g.

This CL includes cosmetic changes to 5g and 8g.
With those cosmetic changes included, componentgen is now
character-for-character equivalent across the four architectures.

Change-Id: I0e13dd48374bad830c725b117a1c86d4197d390c
Reviewed-on: https://go-review.googlesource.com/2606
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-02-13 01:37:52 +00:00
Josh Bleecher Snyder
8f734d4e2f cmd/5g, cmd/6g, cmd/8g, cmd/9g: zero more in componentgen
Fix a flipped nil check.
The flipped check prevented componentgen
from zeroing a non-cadable nl.
This fix reduces the number of non-SB LEAQs
in godoc from 35323 to 34920 (-1.1%).

Update #1914

Change-Id: I15ea303068835f606f883ddf4a2bb4cb2287e9ae
Reviewed-on: https://go-review.googlesource.com/2605
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-02-13 01:17:38 +00:00
Josh Bleecher Snyder
77a2113925 cmd/gc: evaluate concrete == interface without allocating
Consider an interface value i of type I and concrete value c of type C.

Prior to this CL, i==c was evaluated as
	I(c) == i

Evaluating I(c) can allocate.

This CL changes the evaluation of i==c to
	x, ok := i.(C); ok && x == c

The new generated code is shorter and does not allocate directly.

If C is small, as it is in every instance in the stdlib,
the new code also uses less stack space
and makes one runtime call instead of two.

If C is very large, the original implementation is used.
The cutoff for "very large" is 1<<16,
following the stack vs heap cutoff used elsewhere.

This kind of comparison occurs in 38 places in the stdlib,
mostly in the net and os packages.

benchmark                     old ns/op     new ns/op     delta
BenchmarkEqEfaceConcrete      29.5          7.92          -73.15%
BenchmarkEqIfaceConcrete      32.1          7.90          -75.39%
BenchmarkNeEfaceConcrete      29.9          7.90          -73.58%
BenchmarkNeIfaceConcrete      35.9          7.90          -77.99%

Fixes #9370.

Change-Id: I7c4555950bcd6406ee5c613be1f2128da2c9a2b7
Reviewed-on: https://go-review.googlesource.com/2096
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-02-12 22:23:38 +00:00
Josh Bleecher Snyder
747c849833 cmd/6g, cmd/8g: make 2/3 word sgen more efficient
When compiling the stdlib most of the calls
to sgen are for exactly 2 or 3 words:
85% for 6g and 70% for 8g.
Special case them for performance.
This optimization is not relevant to 5g and 9g.

6g

benchmark                old ns/op     new ns/op     delta
BenchmarkCopyFat16       3.25          0.82          -74.77%
BenchmarkCopyFat24       5.47          0.95          -82.63%

8g

benchmark               old ns/op     new ns/op     delta
BenchmarkCopyFat8       3.84          2.42          -36.98%
BenchmarkCopyFat12      4.94          2.15          -56.48%

Change-Id: I8bc60b453f12597dfd916df2d072a7d5fc33ab85
Reviewed-on: https://go-review.googlesource.com/2607
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-02-12 22:19:38 +00:00
Josh Bleecher Snyder
c1c3ce6b36 cmd/6g: allocate fewer new registers in sgen
When possible, generate nodl/nodr directly into DI/SI
rather than going through a temporary register.

CX has already been saved; use it during trailing bytes cleanup.

Change-Id: I4ec6209bcc5d3bfdc927c5c132009bd8d791ada3
Reviewed-on: https://go-review.googlesource.com/2608
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-02-12 22:16:08 +00:00
Dmitry Vyukov
b3be360f16 cmd/gc: allocate non-escaping maps on stack
Extend escape analysis to make(map[k]v).
If it does not escape, allocate temp buffer for hmap and one bucket on stack.

There are 75 cases of non-escaping maps in std lib.

benchmark                                    old allocs     new allocs     delta
BenchmarkConcurrentStmtQuery                 16161          15161          -6.19%
BenchmarkConcurrentTxQuery                   17658          16658          -5.66%
BenchmarkConcurrentTxStmtQuery               16157          15156          -6.20%
BenchmarkConcurrentRandom                    13637          13114          -3.84%
BenchmarkManyConcurrentQueries               22             20             -9.09%
BenchmarkDecodeComplex128Slice               250            188            -24.80%
BenchmarkDecodeFloat64Slice                  250            188            -24.80%
BenchmarkDecodeInt32Slice                    250            188            -24.80%
BenchmarkDecodeStringSlice                   2250           2188           -2.76%
BenchmarkNewEmptyMap                         1              0              -100.00%
BenchmarkNewSmallMap                         2              0              -100.00%

benchmark                old ns/op     new ns/op     delta
BenchmarkNewEmptyMap     124           55.7          -55.08%
BenchmarkNewSmallMap     317           148           -53.31%

benchmark                old allocs     new allocs     delta
BenchmarkNewEmptyMap     1              0              -100.00%
BenchmarkNewSmallMap     2              0              -100.00%

benchmark                old bytes     new bytes     delta
BenchmarkNewEmptyMap     48            0             -100.00%
BenchmarkNewSmallMap     192           0             -100.00%

Fixes #5449

Change-Id: I24fa66f949d2f138885d9e66a0d160240dc9e8fa
Reviewed-on: https://go-review.googlesource.com/3508
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
2015-02-12 09:53:52 +00:00
Dmitry Vyukov
aed88be021 cmd/gc: restore stack frame debugging
Dump frames of functions.
Add function name and var width to output.

Change-Id: Ida06b8def96178fa550ca90836eb4a2509b9e13f
Reviewed-on: https://go-review.googlesource.com/3870
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-12 08:58:26 +00:00
Dmitry Vyukov
ed8cc5cf9b runtime: fix race instrumentation of append
typedslicecopy is another write barrier that is not
understood by racewalk. It seems quite complex to handle it
in the compiler, so instead just instrument it in runtime.

Update #9796

Change-Id: I0eb6abf3a2cd2491a338fab5f7da22f01bf7e89b
Reviewed-on: https://go-review.googlesource.com/4370
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-12 08:51:49 +00:00
Dmitry Vyukov
c1bbf0a2ea cmd/gc: remove several copies of outervalue
Walk calls it outervalue, racewalk calls it basenod,
isstack does it manually and slightly differently.

Change-Id: Id5b5d32b8faf143fe9d34bd08457bfab6fb33daa
Reviewed-on: https://go-review.googlesource.com/3745
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-12 08:31:05 +00:00
Dmitry Vyukov
9568126f35 cmd/gc: allocate buffers for non-escaping string conversions on stack
Support the following conversions in escape analysis:
[]rune("foo")
[]byte("foo")
string([]rune{})

If the result does not escape, allocate temp buffer on stack
and pass it to runtime functions.

Change-Id: I1d075907eab8b0109ad7ad1878104b02b3d5c690
Reviewed-on: https://go-review.googlesource.com/3590
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-12 08:29:53 +00:00
Russ Cox
01925bd3f3 [dev.cc] liblink, cmd/internal/obj: fix printing of TYPE_REGREG and TYPE_REGREG2
Now:

	0x0000 00000 (/tmp/x.s:2)	MULLU	R6,R3,(R7, R6)

The space is a little odd but I'd rather fix the usual printing to add spaces
than delete that one. But in a different CL, once C is gone.

Change-Id: I344e0b06eedaaf53cd79d370fa13c444a1e69c81
Reviewed-on: https://go-review.googlesource.com/4647
Reviewed-by: Rob Pike <r@golang.org>
2015-02-12 03:15:41 +00:00
Russ Cox
f58a5cb9e2 cmd/gc: avoid %#016x, which really means Go's %#014x
(In non-Go print formats, the 016 includes the leading 0x prefix.
No one noticed, but we were printing hex numbers with a minimum
of 30 digits, not 32.)

Change-Id: I10ff7a51a567ad7c8440418ac034be9e4b2d6bc1
Reviewed-on: https://go-review.googlesource.com/4592
Reviewed-by: Austin Clements <austin@google.com>
2015-02-11 21:45:32 +00:00
Russ Cox
7c3eeda66f cmd/gc: use go.builtin as package prefix, not go%2ebuiltin
This matches all the other pseudo-packages.
The line was simply forgotten.

Change-Id: I278f6cbcfc883ea7efad07f99fc8c853b9b5d274
Reviewed-on: https://go-review.googlesource.com/4591
Reviewed-by: Austin Clements <austin@google.com>
2015-02-11 21:45:22 +00:00
Russ Cox
90965718a8 cmd/gc: make qsort comparisons totally ordered
Otherwise different qsort implementations might result
in different sort orders and therefore different compiled
object files.

Change-Id: Ie783ba55a55af06941307e150b0c406e0a8128b0
Reviewed-on: https://go-review.googlesource.com/4590
Reviewed-by: Austin Clements <austin@google.com>
2015-02-11 21:44:46 +00:00
Russ Cox
1250d2e374 cmd/gc: remove C subclassing trick from popt.c
It does not convert to Go well.

Being able to do this just once, instead of 4 times, was the primary
motivation for all the recent refactoring (not that it wasn't overdue).

Still bit-for-bit identical.

Change-Id: Ia01f17948441bf64fa78ec4226f0bb40af0bbaab
Reviewed-on: https://go-review.googlesource.com/3962
Reviewed-by: Austin Clements <austin@google.com>
2015-02-11 20:46:16 +00:00
Russ Cox
ad88fd1d4a cmd/gc: move reg.c into portable code
Now there is only one registerizer shared among all the systems.
There are some unfortunate special cases based on arch.thechar
in reg.c, to preserve bit-for-bit compatibility during the refactoring.
Most are probably bugs one way or another and should be revisited.

Change-Id: I153b435c0eaa05bbbeaf8876822eeb6dedaae3cf
Reviewed-on: https://go-review.googlesource.com/3883
Reviewed-by: Austin Clements <austin@google.com>
2015-02-11 20:37:38 +00:00
Russ Cox
b8a3e88ea7 cmd/gc: remove cgen_asop, no longer used
gc/order.c rewrites OASOP nodes into ordinary assignments.
The back ends never see them anymore.

Change-Id: I268ac8bdc92dccd7123110a21f99ada3ceeb2baa
Reviewed-on: https://go-review.googlesource.com/3882
Reviewed-by: Austin Clements <austin@google.com>
2015-02-11 20:36:37 +00:00
Russ Cox
eb1774fa19 cmd/gc: factor newly-portable code into gc directory
This isn't everything, but it's a start.
Still producing bit-identical compiler output.

The semantics of the old back ends is preserved,
even when they are probably buggy.
There are some TODOs in gc/gsubr.c to
remove special cases to preserve bugs in 5g and 8g.

Change-Id: I28ae295fbfc94ef9df43e13ab96bd6fc2f194bc4
Reviewed-on: https://go-review.googlesource.com/3802
Reviewed-by: Austin Clements <austin@google.com>
2015-02-11 20:36:27 +00:00
Russ Cox
fbd17986ea [dev.cc] liblink: fix printing of SHRL CX, DX:AX
Change-Id: I6a119109c8dea7fecb32de2c4b1b5ba54bc485be
Reviewed-on: https://go-review.googlesource.com/4100
Reviewed-by: Rob Pike <r@golang.org>
2015-02-11 19:18:17 +00:00
Austin Clements
f3b73e040c cmd/dist: fetch version when needed, instead of at init
Currently, if there is a VERSION.cache, running make.bash will set
runtime.theVersion to the revision as of the *last* make.bash run
instead of the current make.bash run.

For example,

$ git rev-parse --short HEAD
5c4a86d
$ ./make.bash
...
$ cat ../VERSION.cache
devel +5c4a86d Tue Feb 10 01:46:30 2015 +0000
$ git checkout a1dbb92
$ ./make.bash
...
$ go version
go version devel +5c4a86d Tue Feb 10 01:46:30 2015 +0000 linux/amd64
$ ./make.bash
...
$ go version
go version devel +a1dbb92 Tue Feb 10 02:31:27 2015 +0000 linux/amd64

This happens because go tool dist reads the potentially stale
VERSION.cache into goversion during early initialization; then cleans,
which deletes VERSION.cache; then builds the runtime using the stale
revision read in to goversion.  It isn't until make later in the build
process, when make.bash invokes go tool dist again, that VERSION.cache
gets updated with the current revision.

To address this, simply don't bother fetching the version until go
tool dist needs it and don't bother caching the value in memory.  This
is more robust since it interacts with cleaning in the expected ways.
Futhermore, there's no downside to eliminating the in-memory cache;
the file system cache is perfectly reasonable for the whole three
times make.bash consults it.

Change-Id: I8c480100e56bb2db0816e8a088177004d9e87973
Reviewed-on: https://go-review.googlesource.com/4540
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-11 05:20:58 +00:00
Rob Pike
e90a91eac4 [dev.cc] cmd/asm: fix dev.cc 386 build: implement CALL *x(SB)
Also clean up the branch code a bit

TBR=rsc

Change-Id: I209dea750db3a6769e7ccd79bb65c4d809aba152
Reviewed-on: https://go-review.googlesource.com/4530
Reviewed-by: Rob Pike <r@golang.org>
2015-02-11 04:24:14 +00:00
Rob Pike
7c604b0b7d [dev.cc] cmd/go: add veryifyAsm test for the new assembler.
Enabled for adm64 and 386 only.

Depends on https://go-review.googlesource.com/4502

Change-Id: I61caf15f91297c12197b825dd70f750c4df02d3d
Reviewed-on: https://go-review.googlesource.com/4503
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-11 03:44:34 +00:00
Rob Pike
e59ed477c3 [dev.cc] cmd/asm: final fixups for correct assembly of runtime, the last package to verify
- obj: add a missing setting of the context for a generated JMP instruction
- asm:  correct the encoding of mode (R)(R*scale)
- asm: fix a silly bug in the test for macro recursion.
- asm: accept address mode sym(R)(R*8); was an oversight

Change-Id: I27112eaaa1faa0d2ba97e414f0571b70733ea087
Reviewed-on: https://go-review.googlesource.com/4502
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-11 03:44:19 +00:00
Keith Randall
6dd31660b0 runtime: don't put container symbols in functab
Container symbols shouldn't be considered as functions in the functab.
Having them present probably messes up function lookup, as you might get
the descriptor of the container instead of the descriptor of the actual
function on the stack.  It also messed up the findfunctab because these
entries caused off-by-one errors in how functab entries were counted.

Normal code is not affected - it only changes (& hopefully fixes) the
behavior for libraries linked as a unit, like:
  net
  runtime/cgo
  runtime/race

Fixes #9804

Change-Id: I81e036e897571ac96567d59e1f1d7f058ca75e85
Reviewed-on: https://go-review.googlesource.com/4290
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-10 23:42:19 +00:00
Ian Lance Taylor
85cae5d7b8 cmd/pprof/internal/report: fix typo in recognized output unit
Fixes #9814.

Change-Id: I1be49efae0648038f590eeca1262037bf1af3df5
Reviewed-on: https://go-review.googlesource.com/4240
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-10 19:32:59 +00:00
Andrew Gerrand
a1dbb9201d cmd/go: use current go source code when generating doc.go
Change-Id: Iad1764707d173a09467fd36e8c49a58147f12219
Reviewed-on: https://go-review.googlesource.com/4320
Reviewed-by: Minux Ma <minux@golang.org>
2015-02-10 02:31:27 +00:00
Rob Pike
1e5d8bb544 cmd/go: document that -run isn't implemented
I am an idiot but the failure to implement this means we can decide
exactly what its design should be for 1.5

Change-Id: Ie2b025fcd899d306ddeddd09d1d0e8f9a99ab7a8
Reviewed-on: https://go-review.googlesource.com/4291
Reviewed-by: Minux Ma <minux@golang.org>
2015-02-10 00:56:24 +00:00
Dave Cheney
e6fbce3596 cmd/dist: reactivate vfp detection on linux/arm
Fixes #9732
Fixes #9819

Rather than detecting vfp support via catching SIGILL signals,
parse the contents of /proc/cpuinfo.

As the GOARM values for NaCl and freebsd are hard coded, this parsing
logic only needs to support linux/arm.

This change also fixes the nacl/arm build which is broken because the
first stage of nacltest.bash is executed with GOARM=5, embedding that
into 5g.

The second stage of nacltest.bash correctly detects GOARM=7, but this is
ignored as we pass --no-clean at that point, and thus do not replace
the compiler.

Lastyly, include a fix to error message in nacltest.bash

Change-Id: I13f306ff07a99b44b493fade72ac00d0d5097e1c
Reviewed-on: https://go-review.googlesource.com/3981
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-10 00:17:06 +00:00
Rob Pike
b6fd455c0d [dev.cc] cmd/asm: add a couple of error messages for things like $exit
These illegal addressing modes were caught downstream in the assembler
or link library, but we can give a better error message upstream.

Change-Id: Ib30ef4d94d5d8d44900276592edd7997e6f91e55
Reviewed-on: https://go-review.googlesource.com/4260
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-09 21:08:32 +00:00
Rob Pike
cb19a20121 [dev.cc] cmd/asm: rewrite to work with new obj API
Considerable rewriting of the parser and assembler (code generator)
but it's simpler and shorter now. The internal Addr type is gone; so
is the package that held it. Parsing of operands goes directly into
obj.Addrs now.

There is a horrible hack regarding register pairs. It uses the Class
field to store the second register since it needs _some_ place to
put it but none is provided in the API. An alternative would be nice
but this works for now.

Once again creates identical .6 and .8 files as the old assembler.

Change-Id: I8207d6dfdfdb5bbed0bd870cb34ee0fe61c2fbfd
Reviewed-on: https://go-review.googlesource.com/4062
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-09 18:48:19 +00:00
Rahul Chaudhry
f8176f8111 cmd/go: stream test output if parallelism is set to 1.
"go test -v" buffers output if more than one package is
being tested to avoid mixing the outputs from multiple
tests running in parallel. It currently enables streaming
if there's only a single package under test.

It is ok to stream output from multiple tests if we know
that they're not going to be running in parallel.

To see the difference: go test -v -p=1 runtime fmt -short

Change-Id: Idc24575c899eac30d553e0bf52b86f90e189392d
Reviewed-on: https://go-review.googlesource.com/4153
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-09 18:20:28 +00:00
Dmitry Vyukov
8ffc450049 cmd/gc: remove dead code
Change-Id: Ib46a42fc873066b1cc00368fe43648f08dce48bd
Reviewed-on: https://go-review.googlesource.com/4200
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-09 08:30:32 +00:00
Shenghou Ma
2978ebbc7b cmd/5g, cmd/6g, cmd/8g, cmd/9g: clear Addr parameter in sudoaddable
The Addr might be a stack variable with uninitialized fields.

Fixes #9777.

Change-Id: I799786e3d8b2e17e069725bc66a076cf9ca11f93
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/3932
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Keith Randall <khr@golang.org>
2015-02-09 01:56:16 +00:00
David Symonds
c71b3e0e88 Revert "cmd/api: treat a hex-y VERSION as devel and permit API changes"
This reverts commit 11d1c05.
See #9296 for details.

Change-Id: I89a36351cb007836662f28a611af5616818b95fe
Reviewed-on: https://go-review.googlesource.com/1536
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-08 20:44:22 +00:00
mattyw
906aefb038 gofmt/doc: gofmt -s output may not be backward compatible
Change-Id: If697ab554e6cb5545d99c6b103ed8bc54f69ed48
Reviewed-on: https://go-review.googlesource.com/4161
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-02-08 05:13:00 +00:00
Shenghou Ma
810a499bda cmd/ld: restore .debug_gdb_script section after runtime reorganization
On some systems, gdb refuses to load Python plugin from arbitrary
paths, so we have to add $GOROOT/src/runtime to auto-load-safe-path
in the gdb script test.

Change-Id: Icc44baab8d04a65bd21ceac2ab8ddb13c8d083e8
Reviewed-on: https://go-review.googlesource.com/2905
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-02-06 19:21:59 +00:00
Josh Bleecher Snyder
4ce06f4b5c cmd/gc: eliminate dead code in switch statements
Ordinary switch statements are rewritten
into a sequence of if statements.
Staticly dead cases were not being eliminated
because the rewrite introduced a temporary,
which hid the fact that the case was a constant.
Stop doing that.

This eliminates dead code in the standard library at:

runtime/cgocall.go:219
runtime/cgocall.go:269
debug/gosym/pclntab.go:175
debug/macho/file.go:208
math/big/nat.go:635
math/big/nat.go:850
math/big/nat.go:1058
cmd/pprof/internal/commands/commands.go:86
net/sock_bsd.go:19
cmd/go/build.go:2657
cmd/go/env.go:90

Fixes #9608.

Change-Id: Ic23a05dfbb1ad91d5f62a6506b35a13e51b33e38
Reviewed-on: https://go-review.googlesource.com/3980
Reviewed-by: Keith Randall <khr@golang.org>
2015-02-06 19:05:47 +00:00
Josh Bleecher Snyder
135ef49fde runtime: speed up eqstring
eqstring does not need to check the length of the strings.

6g

benchmark                              old ns/op     new ns/op     delta
BenchmarkCompareStringEqual            7.03          6.14          -12.66%
BenchmarkCompareStringIdentical        3.36          3.04          -9.52%

5g

benchmark                                 old ns/op     new ns/op     delta
BenchmarkCompareStringEqual               238           232           -2.52%
BenchmarkCompareStringIdentical           90.8          80.7          -11.12%

The equivalent PPC changes are in a separate commit
because I don't have the hardware to test them.

Change-Id: I292874324b9bbd9d24f57a390cfff8b550cdd53c
Reviewed-on: https://go-review.googlesource.com/3955
Reviewed-by: Keith Randall <khr@golang.org>
2015-02-06 18:51:00 +00:00
Péter Surányi
9b6ccb1323 all: don't refer to code.google.com/p/go{,-wiki}/
Only documentation / comment changes. Update references to
point to golang.org permalinks or go.googlesource.com/go.
References in historical release notes under doc are left as is.

Change-Id: Icfc14e4998723e2c2d48f9877a91c5abef6794ea
Reviewed-on: https://go-review.googlesource.com/4060
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-06 14:41:47 +00:00
Shenghou Ma
3d1ccf8964 cmd/dist, make.bash: darwin/arm support
cmd/dist: recognize darwin/arm as (host) goos/goarches. also hard
          code GOARM=7 for darwin/arm.
make.bash: don't pass -mmacosx-version-min=10.6 when building for
           darwin/arm.

Change-Id: If0ecd84a5179cd9bb61b801ac1899adc45f12f75
Reviewed-on: https://go-review.googlesource.com/2126
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-02-06 05:49:58 +00:00
Shenghou Ma
1083715b7f liblink, cmd/ld, cmd/5l: darwin/arm support
liblink:
 - set dummy value for ctxt->tlsoffset.
cmd/ld:
 - always do external linking when using cgo on darwin/arm,
   as our linker might not generate codesign-compatible binary.
cmd/5l:
 - support generate ARM Mach-O binaries
 - add machoreloc1() that translate our internal relocation to
   macho relocations used by external linking.

Change-Id: Ic5454aeb87009aaf8f1453ec7fe33e6da55d5f06
Reviewed-on: https://go-review.googlesource.com/3273
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-02-06 05:41:15 +00:00
Shenghou Ma
d738c6b0ca liblink, cmd/ld, runtime: set the type of runtime.tlsg in runtime
In the old code, liblink, cmd/ld and runtime all have code determine
whether runtime.tlsg is an actual variable or a placeholder for TLS
relocation. This change consolidate them into one: the runtime/tls_arm.s
will ultimately determine the type of that variable.

Change-Id: I3b3f80791a1db4c2b7318f81a115972cd2237e43
Reviewed-on: https://go-review.googlesource.com/2118
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-02-06 05:39:51 +00:00
Shenghou Ma
3819907a55 cmd/cgo: detect misuse of generated _cgo_export.h
Fixes #9742.

Change-Id: Ifedf7ff9465bc49534b708d414c8e435ee9ce6cd
Reviewed-on: https://go-review.googlesource.com/3970
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-06 05:37:02 +00:00
Russ Cox
1fc330d8fe [dev.cc] cmd/internal/obj: reconvert from liblink
cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.

- Brings in new, more regular Prog, Addr definitions

- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).

- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
  They need to be updated for the changes.

- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.

All architectures build successfully again.

Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963
Reviewed-by: Rob Pike <r@golang.org>
2015-02-05 19:13:12 +00:00
Russ Cox
7e3b30aea6 cmd/5a: prepare reglist correctly
This was working when 5a was built on x86 because REG_R0 = 32,
and a 32-bit shift on x86 uses only the low 32 bits of the shift count.

On ARM, the shift clamping is different.

Moving to Go will avoid these differing shift semantics.
I tripped over and fixed this bug in new5a the same way earlier tonight.

Change-Id: Id56aa0bb1830ccf250960f843e0acb8a0409e87d
Reviewed-on: https://go-review.googlesource.com/3961
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-02-05 16:05:13 +00:00
Russ Cox
cb4b28e013 Revert "liblink, cmd/5a: fix reglist parsing/printing after changing REG_R0 to 32"
This reverts commit da4abda2a1.

Change-Id: Ifd09b3dae0af0c7cef5fbbc332c63e78dc90d6b1
Reviewed-on: https://go-review.googlesource.com/3960
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-05 10:23:35 +00:00
Shenghou Ma
98376204e8 cmd/ld: always set timestamp in PE header to 0
Fixes #9756.

Change-Id: If4ee6fe10f8f90294ff9c5e7480371494094b111
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/3740
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-02-05 02:45:03 +00:00
Shenghou Ma
da4abda2a1 liblink, cmd/5a: fix reglist parsing/printing after changing REG_R0 to 32
Fixes #9759.

Change-Id: I263f1251b9401371231374551c4f71c70cb6e359
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/3931
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-02-05 02:40:09 +00:00
Rob Pike
706cc13b21 cmd/pack: simplify the testing logic slightly
Followup to https://go-review.googlesource.com/3910

We only need 1000 iteratinons.

Change-Id: Ib63ae53105176abec77bad9609d638aeda7bcd61
Reviewed-on: https://go-review.googlesource.com/3901
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-05 00:28:00 +00:00
Russ Cox
8db173b85e [dev.cc] all: merge master (b8fcae0) into dev.cc
Change-Id: I2aa1d0b0c4cf7632a54e843810959b468e3812ab
2015-02-04 16:12:58 -05:00
Russ Cox
25c140aaa0 [dev.cc] cmd/go, liblink: turn off verification against Go code
The upcoming merge is going to break the synchrony.
Will restore separately.

Change-Id: I90946119a0901e24063b190d1a074594af7654c7
Reviewed-on: https://go-review.googlesource.com/3888
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-04 21:07:06 +00:00
Brad Fitzpatrick
878d00b65c cmd/pack: make a test less disk-intensive in short mode
Fixes #9656

Change-Id: I1158636683492ef12eeafb12e257d205026adc3f
Reviewed-on: https://go-review.googlesource.com/3175
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/3910
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-02-04 21:04:46 +00:00
Rob Pike
ef664199cb [dev.cc] cmd/asm: make 386 work
An editing error prevented the tables from being set up correctly.
With that fixed, asm is now compatible with 8a.

Change-Id: Ieb20e6dcaf4c05bd448ea748a010ee1f58ef4807
Reviewed-on: https://go-review.googlesource.com/3867
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-04 19:17:54 +00:00
Russ Cox
1f2d7bf44f liblink: require use of TYPE_ADDR, not TYPE_CONST
Add Addr-checking for all Progs on input to liblink, in liblink/pass.c,
including requiring use of TYPE_ADDR, not TYPE_CONST.
Update compilers and assemblers to satisfy checks.

Change-Id: Idac36b9f6805f0451cb541d2338992ca5eaf3963
Reviewed-on: https://go-review.googlesource.com/3801
Reviewed-by: Austin Clements <austin@google.com>
2015-02-04 16:50:06 +00:00
Josh Bleecher Snyder
22f337656d cmd/go, make: remove ccflags
cc is no more.

Change-Id: I8d1bc0d2e471cd9357274204c9bc1fa67cbc272d
Reviewed-on: https://go-review.googlesource.com/3833
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-02-04 16:15:00 +00:00
Josh Bleecher Snyder
3fa90ea964 cmd/go: add 9g and 9l to documentation
Change-Id: I274c438ab168278dfbb34ada3ed9a7f7c66b66ef
Reviewed-on: https://go-review.googlesource.com/3834
Reviewed-by: Minux Ma <minux@golang.org>
2015-02-04 16:10:28 +00:00
Dmitry Vyukov
71be013842 cmd/gc: don't copy string in range []byte(str)
Using benchmark from the issue:

benchmark                    old ns/op     new ns/op     delta
BenchmarkRangeStringCast     2162          1152          -46.72%

benchmark                    old allocs     new allocs     delta
BenchmarkRangeStringCast     1              0              -100.00%

Fixes #2204

Change-Id: I92c5edd2adca4a7b6fba00713a581bf49dc59afe
Reviewed-on: https://go-review.googlesource.com/3790
Reviewed-by: Keith Randall <khr@golang.org>
2015-02-04 04:37:21 +00:00
Josh Bleecher Snyder
16e933c266 cmd/dist: fix whitespace and comment typo in arm vfp detection
Follow-up to cl 2682.

Change-Id: I06a589e782af821e4fa46a7c34d9a549de47fa60
Reviewed-on: https://go-review.googlesource.com/3830
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-02-04 00:04:09 +00:00
Rob Pike
eeebcd9db3 [dev.cc] asm: fix handling of statics (data<>) and symbols
A typo limited the number of center-dot substitutions to one. Fixed.

With these changes, plus a recent fix to 6a, the are no differences,
down to the bit level, in object code for any assembly files in std
between asm and 6a. (Runtime has not been checked yet, but I
expect no errors.)

Change-Id: I0e8045b4414223d937e7f8919c8768860554b7d5
Reviewed-on: https://go-review.googlesource.com/3820
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-03 20:43:37 +00:00
Russ Cox
2e5b065ac2 liblink: define fixed A-numbers for common instructions
This makes names like ANOP, ATEXT, AGLOBL, ACALL, AJMP, ARET
available for use by architecture-independent processing passes.

On arm and ppc64, the alternate names are now aliases for the
official ones (ABL for ACALL, AB or ABR for AJMP, ARETURN for ARET).

Change-Id: Id027771243795af2b3745199c645b6e1bedd7d18
Reviewed-on: https://go-review.googlesource.com/3577
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Austin Clements <austin@google.com>
2015-02-03 18:23:05 +00:00
Russ Cox
3ac37c72ae liblink: place DATA size in from3.offset always
Like the TEXT/GLOBL flags, this was split between from.scale and reg,
neither of which is appropriate.

Change-Id: I2a16ef066a53b6edb7afb16cce108c0d1d26389c
Reviewed-on: https://go-review.googlesource.com/3576
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Austin Clements <austin@google.com>
2015-02-03 18:22:57 +00:00
Russ Cox
76fed5426c liblink: the zero Prog is now valid and ready for use
Use AXXX instead of AGOK (neither is a valid instruction but AXXX is zero)
for the initial setting of Prog.as, and now there are no non-zero default
field settings.

Remove the arch-specific zprog/zprg in favor of a single global zprog.
Remove the arch-specific prg constructor in favor of emallocz(sizeof(Prog)).

Change-Id: Ia73078726768333d7cdba296f548170c1bea9498
Reviewed-on: https://go-review.googlesource.com/3575
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Austin Clements <austin@google.com>
2015-02-03 18:22:45 +00:00
Russ Cox
e66ad16ddb liblink: renumber ARM conditions to make C_SCOND_NONE == 0
A step toward making the zero Prog useful.

Change-Id: I427b98b1ce9bd8f093da825aa4bb83244fc01903
Reviewed-on: https://go-review.googlesource.com/3573
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Austin Clements <austin@google.com>
2015-02-03 18:22:26 +00:00
Russ Cox
77a415e5a6 liblink: place TEXT/GLOBL flags in p->from3 always
Before, amd64 and 386 stored the flags in p->from.scale
and arm and ppc64 stored the flags in p->reg.
Both caused special cases in printing and in handling of the
addresses.

To avoid possible conflicts with the real meaning of p->from
and to avoid storing a non-register value in a reg field,
use from3 to hold a TYPE_CONST value giving the flags.

There is still a special case for printing, because the flags
are specified without a $, and normally a TYPE_CONST prints
with a $. But that's much less special than what came before.

This allows us to remove the textflag and settextflag methods
from LinkArch. They are no longer architecture-specific.

Change-Id: I931da8e1ecd92e127cd9aa44ef5a73c42e730110
Reviewed-on: https://go-review.googlesource.com/3572
Reviewed-by: Austin Clements <austin@google.com>
2015-02-03 18:22:15 +00:00
Russ Cox
72521319c7 liblink: use same TEXT $frame-arg encoding for all architectures
Change-Id: I3417a8c5ddd7f405939edc9fdef086e4741495a1
Reviewed-on: https://go-review.googlesource.com/3571
Reviewed-by: Austin Clements <austin@google.com>
2015-02-03 18:22:07 +00:00
Russ Cox
a293c7e68f cmd/9a: fix GLOBL instruction
Because it was lumped in with the TEXT instruction,
the high 32 bits of the 64-bit constant holding the size
were always set to 0x80000000 (ArgsSizeUnknown).
This only worked because cmd/9l was reading the 64-bit
value into an int32.

While we're here, fix 5a.
It wasn't as much of a problem there because
the two values were being stored in two different fields.
But it was still wrong.

Change-Id: I69a2214c7be939530d499e29cfdc3b26720ac05a
Reviewed-on: https://go-review.googlesource.com/3570
Reviewed-by: Austin Clements <austin@google.com>
2015-02-03 18:21:54 +00:00
Russ Cox
975c82fd9b [dev.cc] cmd/6a, etc: fix line number accounting during #ifdef
Lines beginning with #ifdef, #else, #endif were not incrementing
the line number, resulting in bad line number information for
assembly files with #ifdefs.

Example:

	#ifndef GOARCH_ppc64
	#endif
	#ifdef GOARCH_ppc64le
	#endif

	TEXT ·use(SB),7,$0
		RET

Before this change, the line number recorded for use in 6a -S output
(and in the runtime information in the binary) was 4 too low.

Change-Id: I23e599112ec9919f72e53ac82d9bebbbae3439ed
Reviewed-on: https://go-review.googlesource.com/3783
Reviewed-by: Rob Pike <r@golang.org>
2015-02-03 17:41:25 +00:00
Dmitry Vyukov
eaa872009d cmd/gc: fix capturing by value for range statements
Kindly detected by race builders by failing TestRaceRange.
ORANGE typecheck does not increment decldepth around body.

Change-Id: I0df5f310cb3370a904c94d9647a9cf0f15729075
Reviewed-on: https://go-review.googlesource.com/3507
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-03 15:48:48 +00:00
Dmitry Vyukov
8e2423a67d cmd/gc: typecheck type switch variables
Type switch variables was not typechecked.
Previously it lead only to a minor consequence:

switch unsafe.Sizeof = x.(type) {

generated an inconsistent error message.
But capturing by value functionality now requries typechecking of all ONAMEs.

Fixes #9731

Change-Id: If037883cba53d85028fb97b1328696091b3b7ddd
Reviewed-on: https://go-review.googlesource.com/3600
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-03 15:44:06 +00:00
Rob Pike
68475da68d [dev.cc] cmd/asm: fix a few minor issues
Fix one place where semicolons were not recognized and fix the
pattern match for the syntax of some pseudo ops.
Also clean up a couple of unreachable code pieces.

There is still an undiagnosed bit difference betwen old and new .6
files. TBD.

With these fixes, asm can successfully compile and test the entire tree.
(Verified by
	turn off verifyAsm in cmd/go
	make.bash
	cp $GOROOT/bin/asm $GOROOT/pkg/tool/darwin_amd64/6a
	go test -short std
)

Change-Id: I91ea892098f76ef4f129fd2530e0c63ffd8745a9
Reviewed-on: https://go-review.googlesource.com/3688
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-02 20:04:45 +00:00
Austin Clements
3c0fee10db cmd/6g, liblink, runtime: support saving base pointers
This adds a "framepointer" GOEXPERIMENT that that makes the amd64
toolchain maintain base pointer chains in the same way that gcc
-fno-omit-frame-pointer does.  Go doesn't use these saved base
pointers, but this does enable external tools like Linux perf and
VTune to unwind Go stacks when collecting system-wide profiles.

This requires support in the compilers to not clobber BP, support in
liblink for generating the BP-saving function prologue and unwinding
epilogue, and support in the runtime to save BPs across preemption, to
skip saved BPs during stack unwinding and, and to adjust saved BPs
during stack moving.

As with other GOEXPERIMENTs, everything from the toolchain to the
runtime must be compiled with this experiment enabled.  To do this,
run make.bash (or all.bash) with GOEXPERIMENT=framepointer.

Change-Id: I4024853beefb9539949e5ca381adfdd9cfada544
Reviewed-on: https://go-review.googlesource.com/2992
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-02 19:36:05 +00:00
Austin Clements
36f879780a cmd/9g: note suboptimal copy code
9g generates needlessly complex code for small copies.  There are a
few other things that need to be improved about the copy code, so for
now just note the problem.

Change-Id: I0f1de4b2f9197a2635e27cc4b91ecf7a6c11f457
Reviewed-on: https://go-review.googlesource.com/3665
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-02 19:32:42 +00:00
Shenghou Ma
3bf005cea3 cmd/gc: always treat the output parameters as having been assigned in capturevars.
Fixes #9738.

Change-Id: Iab75de2d78335d4e31c3dce6a0e1826d8cddf5f3
Reviewed-on: https://go-review.googlesource.com/3690
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-02-02 14:14:21 +00:00
Rob Pike
5beec6a699 [dev.cc] cmd/asm: handle the case where a macro is named without arguments
Given
	#define X() foo
	X()
	X
cpp produces
	foo
	X
Asm does now as well.

Change-Id: Ia36b88a23ce1660e6a02559c4f730593d62066f1
Reviewed-on: https://go-review.googlesource.com/3611
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-30 21:19:49 +00:00
Rob Pike
d6eb21e331 [dev.cc] cmd/asm: rewrite the macro processor
The previous one was too broken, so just rewrite the code that invokes
a macro. Basically it was evaluating things too early, and mishandling
nested invocations. It's also easier to understand now.

Keep backslash-newline around in macro definitions. They get
processed when the body is evaluated.

Write some golden tests.

Change-Id: I27435f77f258a0873f80932bdc8d13ad39821ac1
Reviewed-on: https://go-review.googlesource.com/3550
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-30 16:38:25 +00:00
Brad Fitzpatrick
7980779374 cmd/pack: make a test less disk-intensive in short mode
Fixes #9656

Change-Id: I1158636683492ef12eeafb12e257d205026adc3f
Reviewed-on: https://go-review.googlesource.com/3175
Reviewed-by: Minux Ma <minux@golang.org>
2015-01-30 15:40:20 +00:00
Dave Cheney
ea2f3f9e7a liblink: fix arm build again
Another attempt to fix the arm build by moving the include of signal.h
to cmd/lex.c, unless we are building on plan9.

Obviously if we had a plan9/arm builder this would probably not work, but
this is only a temporary measure until the c2go transition is complete.

Change-Id: I7f8ae27349b2e7a09c55db03e02a01939159a268
Reviewed-on: https://go-review.googlesource.com/3566
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-30 14:45:37 +00:00
Russ Cox
01b6b4b43a cmd/5l, cmd/9l: more ucontext.h fixes
Change-Id: I32cad7358f5bfd8e107179653bdc55a69fbe772a
Reviewed-on: https://go-review.googlesource.com/3579
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-30 05:02:25 +00:00
Russ Cox
dc3961cfdc cmd/5l, cmd/8g: fix build failures
REG_R0 etc are defined in <ucontext.h> on ARM systems.
Possible use of uninitialized n in 8g/reg.c.

Change-Id: I6e8ce83a6515ca2b779ed8a344a25432db629cc2
Reviewed-on: https://go-review.googlesource.com/3578
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-30 04:54:37 +00:00
Russ Cox
d968bda66f cmd/dist: update for portable Prog, Addr
There are no D_ names anymore.

Change-Id: Id3f1ce5efafb93818e5fd16c47ff48bbf61b5339
Reviewed-on: https://go-review.googlesource.com/3520
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
2015-01-30 03:16:39 +00:00
Russ Cox
da47902d02 cmd/9a, cmd/9g, cmd/9l, liblink: update for portable Prog, Addr
Change-Id: I55afed0eabf3c38e72ff105294782ac36446b66b
Reviewed-on: https://go-review.googlesource.com/3519
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
2015-01-30 03:16:28 +00:00
Russ Cox
a5b1baeed7 cmd/8a, cmd/8g, cmd/8l, liblink: update for portable Prog, Addr
Change-Id: I19ed283962aa0221cf806307bde9ea0773a1bfd4
Reviewed-on: https://go-review.googlesource.com/3518
Reviewed-by: Austin Clements <austin@google.com>
2015-01-30 03:16:19 +00:00
Russ Cox
604138e87b cmd/6a, cmd/6g, cmd/6l, liblink: update for portable Prog, Addr
Change-Id: I5535582660da3504663c6cba2637da132c65a400
Reviewed-on: https://go-review.googlesource.com/3517
Reviewed-by: Austin Clements <austin@google.com>
2015-01-30 03:16:10 +00:00
Russ Cox
0d599909e9 cmd/5a, cmd/5g, cmd/5l, liblink: update for portable Prog, Addr
Change-Id: I06762d4fb3bb2616087339b6ae1eb5267a39c46a
Reviewed-on: https://go-review.googlesource.com/3516
Reviewed-by: Austin Clements <austin@google.com>
2015-01-30 03:15:58 +00:00
Russ Cox
5a2771e286 cmd/gc, cmd/ld, liblink: update for portable Prog, Addr changes
Change-Id: Ia6f8badca56565b9df80c8dbe28c47f6cf7e653f
Reviewed-on: https://go-review.googlesource.com/3515
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
2015-01-30 03:15:44 +00:00
Russ Cox
1d0664ef0d cmd/9g: use nopout in excise
In addition to duplicating the logic, the old code was
clearing the line number, which led to missing source line
information in the -S output.

Also fix nopout, which was incomplete.

Change-Id: Ic2b596a2f9ec2fe85642ebe125cca8ef38c83085
Reviewed-on: https://go-review.googlesource.com/3512
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-01-30 02:49:52 +00:00
Rob Pike
b528063099 [dev.cc] cmd/asm: delete overflow checking, make labels function-scoped
The overflow checking was causing more problems than it was avoiding,
so get rid of it. But because arithmetic is done with uint64s, to simplify
dealing with large constants, complain about right shift and divide with
huge numbers to avoid ambiguity about signed shifts.

Change-Id: I5b5ea55d8e8c02846605f4a3f8fd7a176b1e962b
Reviewed-on: https://go-review.googlesource.com/3531
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-29 20:26:26 +00:00
Rob Pike
36e5f4d53f [dev.cc] cmd/asm: set the flags to production settings (turn off debug)
Set -S to false and add -debug to control the other debugging print.

Change-Id: I864866c3d264a33e6dd0ce12a86a050a5fe0f875
Reviewed-on: https://go-review.googlesource.com/3453
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-29 19:08:26 +00:00
Russ Cox
83c10b204d cmd/go: add build flag -toolexec
Like the -exec flag, which specifies a program to use to run a built executable,
the -toolexec flag specifies a program to use to run a tool like 5a, 5g, or 5l.

This flag enables running the toolchain under common testing environments,
such as valgrind.

This flag also enables the use of custom testing environments or the substitution
of alternate tools. See https://godoc.org/rsc.io/toolstash for one possibility.

Change-Id: I256aa7af2d96a4bc7911dc58151cc2155dbd4121
Reviewed-on: https://go-review.googlesource.com/3351
Reviewed-by: Rob Pike <r@golang.org>
2015-01-29 16:25:53 +00:00
Dmitry Vyukov
0e80b2e082 cmd/gc: capture variables by value
Language specification says that variables are captured by reference.
And that is what gc compiler does. However, in lots of cases it is
possible to capture variables by value under the hood without
affecting visible behavior of programs. For example, consider
the following typical pattern:

	func (o *Obj) requestMany(urls []string) []Result {
		wg := new(sync.WaitGroup)
		wg.Add(len(urls))
		res := make([]Result, len(urls))
		for i := range urls {
			i := i
			go func() {
				res[i] = o.requestOne(urls[i])
				wg.Done()
			}()
		}
		wg.Wait()
		return res
	}

Currently o, wg, res, and i are captured by reference causing 3+len(urls)
allocations (e.g. PPARAM o is promoted to PPARAMREF and moved to heap).
But all of them can be captured by value without changing behavior.

This change implements simple strategy for capturing by value:
if a captured variable is not addrtaken and never assigned to,
then it is captured by value (it is effectively const).
This simple strategy turned out to be very effective:
~80% of all captures in std lib are turned into value captures.
The remaining 20% are mostly in defers and non-escaping closures,
that is, they do not cause allocations anyway.

benchmark                                    old allocs     new allocs     delta
BenchmarkCompressedZipGarbage                153            126            -17.65%
BenchmarkEncodeDigitsSpeed1e4                91             69             -24.18%
BenchmarkEncodeDigitsSpeed1e5                178            129            -27.53%
BenchmarkEncodeDigitsSpeed1e6                1510           1051           -30.40%
BenchmarkEncodeDigitsDefault1e4              100            75             -25.00%
BenchmarkEncodeDigitsDefault1e5              193            139            -27.98%
BenchmarkEncodeDigitsDefault1e6              1420           985            -30.63%
BenchmarkEncodeDigitsCompress1e4             100            75             -25.00%
BenchmarkEncodeDigitsCompress1e5             193            139            -27.98%
BenchmarkEncodeDigitsCompress1e6             1420           985            -30.63%
BenchmarkEncodeTwainSpeed1e4                 109            81             -25.69%
BenchmarkEncodeTwainSpeed1e5                 211            151            -28.44%
BenchmarkEncodeTwainSpeed1e6                 1588           1097           -30.92%
BenchmarkEncodeTwainDefault1e4               103            77             -25.24%
BenchmarkEncodeTwainDefault1e5               199            143            -28.14%
BenchmarkEncodeTwainDefault1e6               1324           917            -30.74%
BenchmarkEncodeTwainCompress1e4              103            77             -25.24%
BenchmarkEncodeTwainCompress1e5              190            137            -27.89%
BenchmarkEncodeTwainCompress1e6              1327           919            -30.75%
BenchmarkConcurrentDBExec                    16223          16220          -0.02%
BenchmarkConcurrentStmtQuery                 17687          16182          -8.51%
BenchmarkConcurrentStmtExec                  5191           5186           -0.10%
BenchmarkConcurrentTxQuery                   17665          17661          -0.02%
BenchmarkConcurrentTxExec                    15154          15150          -0.03%
BenchmarkConcurrentTxStmtQuery               17661          16157          -8.52%
BenchmarkConcurrentTxStmtExec                3677           3673           -0.11%
BenchmarkConcurrentRandom                    14000          13614          -2.76%
BenchmarkManyConcurrentQueries               25             22             -12.00%
BenchmarkDecodeComplex128Slice               318            252            -20.75%
BenchmarkDecodeFloat64Slice                  318            252            -20.75%
BenchmarkDecodeInt32Slice                    318            252            -20.75%
BenchmarkDecodeStringSlice                   2318           2252           -2.85%
BenchmarkDecode                              11             8              -27.27%
BenchmarkEncodeGray                          64             56             -12.50%
BenchmarkEncodeNRGBOpaque                    64             56             -12.50%
BenchmarkEncodeNRGBA                         67             58             -13.43%
BenchmarkEncodePaletted                      68             60             -11.76%
BenchmarkEncodeRGBOpaque                     64             56             -12.50%
BenchmarkGoLookupIP                          153            139            -9.15%
BenchmarkGoLookupIPNoSuchHost                508            466            -8.27%
BenchmarkGoLookupIPWithBrokenNameServer      245            226            -7.76%
BenchmarkClientServer                        62             59             -4.84%
BenchmarkClientServerParallel4               62             59             -4.84%
BenchmarkClientServerParallel64              62             59             -4.84%
BenchmarkClientServerParallelTLS4            79             76             -3.80%
BenchmarkClientServerParallelTLS64           112            109            -2.68%
BenchmarkCreateGoroutinesCapture             10             6              -40.00%
BenchmarkAfterFunc                           1006           1005           -0.10%

Fixes #6632.

Change-Id: I0cd51e4d356331d7f3c5f447669080cd19b0d2ca
Reviewed-on: https://go-review.googlesource.com/3166
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-29 13:07:30 +00:00
Dominik Vogt
b49c3ac2d5 cmd/cgo: add support for s390 and s390x
This patch was previously sent for review using hg:
golang.org/cl/173930043

Change-Id: I559a2f2ee07990d0c23d2580381e32f8e23077a5
Reviewed-on: https://go-review.googlesource.com/3033
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-29 00:51:31 +00:00
Rob Pike
29428e322d [dev.cc] cmd/asm: check for overflow on multiply and left shift
The internal size of integers is not part of the definition of the assembler,
so if bits roll out the top it's a portability problem at best.

If you need to use shift to create a mask, use & to restrict the bit count
before shifting. That will make it portable, too.

Change-Id: I24f9a4d2152c3f9f253e22ff75270fe50c18612b
Reviewed-on: https://go-review.googlesource.com/3451
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28 22:26:41 +00:00
Rob Pike
0012b83507 [dev.cc] cmd/asm: fix the expression parser and add tests
Rewrite the grammar to have one more production so it parses
	~0*0
correctly and write tests to prove it.

Change-Id: I0dd652baf65b48a3f26c9287c420702db4eaec59
Reviewed-on: https://go-review.googlesource.com/3443
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28 20:39:39 +00:00
Dmitry Vyukov
4ce4d8b2c4 cmd/gc: allocate stack buffer for ORUNESTR
If result of string(i) does not escape,
allocate a [4]byte temp on stack for it.

Change-Id: If31ce9447982929d5b3b963fd0830efae4247c37
Reviewed-on: https://go-review.googlesource.com/3411
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28 20:37:20 +00:00
Rob Pike
ad82238653 [dev.cc] cmd/asm: the text flag argument to TEXT psudo-op is optional
Allow TEXT to have two or three operands.
In
	TEXT foo(SB),flag,$0
the flag can be missing, in which case we take it to be zero.

Change-Id: I7b88543b52019f7890baac4b95f9e63884d43c83
Reviewed-on: https://go-review.googlesource.com/3440
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28 20:34:40 +00:00
Dmitry Vyukov
e6fac08146 cmd/gc: allocate buffers for non-escaped strings on stack
Currently we always allocate string buffers in heap.
For example, in the following code we allocate a temp string
just for comparison:

	if string(byteSlice) == "abc" { ... }

This change extends escape analysis to cover []byte->string
conversions and string concatenation. If the result of operations
does not escape, compiler allocates a small buffer
on stack and passes it to slicebytetostring and concatstrings.
Then runtime uses the buffer if the result fits into it.

Size of the buffer is 32 bytes. There is no fundamental theory
behind this number. Just an observation that on std lib
tests/benchmarks frequency of string allocation is inversely
proportional to string length; and there is significant number
of allocations up to length 32.

benchmark                                    old allocs     new allocs     delta
BenchmarkFprintfBytes                        2              1              -50.00%
BenchmarkDecodeComplex128Slice               318            316            -0.63%
BenchmarkDecodeFloat64Slice                  318            316            -0.63%
BenchmarkDecodeInt32Slice                    318            316            -0.63%
BenchmarkDecodeStringSlice                   2318           2316           -0.09%
BenchmarkStripTags                           11             5              -54.55%
BenchmarkDecodeGray                          111            102            -8.11%
BenchmarkDecodeNRGBAGradient                 200            188            -6.00%
BenchmarkDecodeNRGBAOpaque                   165            152            -7.88%
BenchmarkDecodePaletted                      319            309            -3.13%
BenchmarkDecodeRGB                           166            157            -5.42%
BenchmarkDecodeInterlacing                   279            268            -3.94%
BenchmarkGoLookupIP                          153            135            -11.76%
BenchmarkGoLookupIPNoSuchHost                508            466            -8.27%
BenchmarkGoLookupIPWithBrokenNameServer      245            226            -7.76%
BenchmarkClientServerParallel4               62             61             -1.61%
BenchmarkClientServerParallel64              62             61             -1.61%
BenchmarkClientServerParallelTLS4            79             78             -1.27%
BenchmarkClientServerParallelTLS64           112            111            -0.89%

benchmark                                    old ns/op      new ns/op      delta
BenchmarkFprintfBytes                        381            311            -18.37%
BenchmarkStripTags                           2615           2351           -10.10%
BenchmarkDecodeNRGBAGradient                 3715887        3635096        -2.17%
BenchmarkDecodeNRGBAOpaque                   3047645        2928644        -3.90%
BenchmarkGoLookupIP                          153            135            -11.76%
BenchmarkGoLookupIPNoSuchHost                508            466            -8.27%

Change-Id: I9ec01da816945c3329d7be3c7794b520418c3f99
Reviewed-on: https://go-review.googlesource.com/3120
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28 20:12:38 +00:00
Dmitry Vyukov
69cd91a598 cmd/gc: don't copy []byte during string comparison
Currently we allocate a new string during []byte->string conversion
in string comparison expressions. String allocation is unnecessary in
this case, because comparison does memorize the strings for later use.
This change uses slicebytetostringtmp to construct temp string directly
from []byte buffer and passes it to runtime.eqstring.

Change-Id: If00f1faaee2076baa6f6724d245d5b5e0f59b563
Reviewed-on: https://go-review.googlesource.com/3410
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28 19:36:50 +00:00
Rob Pike
92e5120c77 [dev.cc] cmd/asm: rewrite parsing of TEXT $3-2
It was too complicated, assuming the syntax is more general than reality.
It must be a possibly negative integer followed by an optional minus sign
and positive integer. Literals only, no expresssions.

Also put in a TODO about address parsing and clean up a couple of types.

Change-Id: If8652249c742e42771ccf2e3024f77307b2e5d9a
Reviewed-on: https://go-review.googlesource.com/3370
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28 18:17:13 +00:00
Dmitry Vyukov
22c16b4b92 cmd/gc: ignore re-slicing in escape analysis
Escape analysis treats everything assigned to OIND/ODOTPTR as escaping.
As the result b escapes in the following code:

	func (b *Buffer) Foo() {
		n, m := ...
		b.buf = b.buf[n:m]
	}

This change recognizes such assignments and ignores them.

Update issue #9043.
Update issue #7921.

There are two similar cases in std lib that benefit from this optimization.
First is in archive/zip:

type readBuf []byte
func (b *readBuf) uint32() uint32 {
	v := binary.LittleEndian.Uint32(*b)
	*b = (*b)[4:]
	return v
}

Second is in time:

type data struct {
	p     []byte
	error bool
}

func (d *data) read(n int) []byte {
	if len(d.p) < n {
		d.p = nil
		d.error = true
		return nil
	}
	p := d.p[0:n]
	d.p = d.p[n:]
	return p
}

benchmark                         old ns/op     new ns/op     delta
BenchmarkCompressedZipGarbage     32431724      32217851      -0.66%

benchmark                         old allocs     new allocs     delta
BenchmarkCompressedZipGarbage     153            143            -6.54%

Change-Id: Ia6cd32744e02e36d6d8c19f402f8451101711626
Reviewed-on: https://go-review.googlesource.com/3162
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28 17:37:55 +00:00
Dmitry Vyukov
1b87f01239 cmd/gc: improve escape analysis for &T{...}
Currently all PTRLIT element initializers escape. There is no reason for that.
This change links STRUCTLIT to PTRLIT; STRUCTLIT element initializers are
already linked to the STRUCTLIT. As the result, PTRLIT element initializers
escape when PTRLIT itself escapes.

Change-Id: I89ecd8677cbf81addcfd469cd2fd461c0e9bf7dd
Reviewed-on: https://go-review.googlesource.com/3031
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28 16:59:01 +00:00
Dmitry Vyukov
6488b217c2 cmd/go: add tracing support
cmd/go part of tracing functionality:
https://docs.google.com/document/u/1/d/1FP5apqzBgr7ahCCgFO-yoVhk4YZrNIDNf9RybngBc14/pub
Full change:
https://codereview.appspot.com/146920043

Change-Id: If346e11b8029c475b01fbf7172ce1c88171fb1b2
Reviewed-on: https://go-review.googlesource.com/1460
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28 16:44:18 +00:00
Dmitry Vyukov
fd85a6c640 cmd/gc: fix condition for fast pathed interface conversions
For some reason the current conditions require the type to be "uintptr-shaped".
This cuts off structs and arrays with a pointer.
isdirectiface and width==widthptr is sufficient condition to enable the fast paths.

Change-Id: I11842531e7941365413606cfd6c34c202aa14786
Reviewed-on: https://go-review.googlesource.com/3414
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28 15:33:10 +00:00
Dmitry Vyukov
b581ca5956 cmd/gc: allow map index expressions in for range statements
Fixes #9691.

Change-Id: I22bfc82e05497e91a7b18a668913aed6c723365d
Reviewed-on: https://go-review.googlesource.com/3282
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28 15:14:04 +00:00
Dmitry Vyukov
205ae07cd3 cmd/gc: don't copy []byte during string concatenation
Consider the following code:

s := "(" + string(byteSlice) + ")"

Currently we allocate a new string during []byte->string conversion,
and pass it to concatstrings. String allocation is unnecessary in
this case, because concatstrings does memorize the strings for later use.
This change uses slicebytetostringtmp to construct temp string directly
from []byte buffer and passes it to concatstrings.

I've found few such cases in std lib:

	s += string(msg[off:off+c]) + "."
	buf.WriteString("Sec-WebSocket-Accept: " + string(c.accept) + "\r\n")
	bw.WriteString("Sec-WebSocket-Key: " + string(nonce) + "\r\n")
	err = xml.Unmarshal([]byte("<Top>"+string(data)+"</Top>"), &logStruct)
	d.err = d.syntaxError("invalid XML name: " + string(b))
	return m, ProtocolError("malformed MIME header line: " + string(kv))

But there are much more in our internal code base.

Change-Id: I42f401f317131237ddd0cb9786b0940213af16fb
Reviewed-on: https://go-review.googlesource.com/3163
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-27 18:15:42 +00:00
Dmitry Vyukov
a7bb393628 cmd/gc: don't emit write barriers for *tmp if tmp=&PAUTO
This is another case where we can say that the address refers to stack.
We create such temps for OSTRUCTLIT initialization.

This eliminates a handful of write barriers today.
But this come up a prerequisite for another change (capturing vars by value),
otherwise we emit writebarriers in writebarrier itself when
capture writebarrier arguments by value.

Change-Id: Ibba93acd0f5431c5a4c3d90ef1e622cb9a7ff50e
Reviewed-on: https://go-review.googlesource.com/3285
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-27 18:09:29 +00:00
Dmitry Vyukov
9a36beb2af cmd/gc: fix range typecheck order
Typecheck for range variables before typechecking for range body.
Body can refer to new vars declared in for range,
so it is preferable to typecheck them before the body.
Makes typecheck order consistent between ORANGE and OFOR.

This come up during another change that computes some predicates
on variables during typechecking.

Change-Id: Ic975db61b1fd5b7f9ee78896d4cc7d93c593c532
Reviewed-on: https://go-review.googlesource.com/3284
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-27 18:07:52 +00:00
Dmitry Vyukov
85e7bee19f runtime: do not scan maps when k/v do not contain pointers
Currently we scan maps even if k/v does not contain pointers.
This is required because overflow buckets are hanging off the main table.
This change introduces a separate array that contains pointers to all
overflow buckets and keeps them alive. Buckets themselves are marked
as containing no pointers and are not scanned by GC (if k/v does not
contain pointers).

This brings maps in line with slices and chans -- GC does not scan
their contents if elements do not contain pointers.

Currently scanning of a map[int]int with 2e8 entries (~8GB heap)
takes ~8 seconds. With this change scanning takes negligible time.

Update #9477.

Change-Id: Id8a04066a53d2f743474cad406afb9f30f00eaae
Reviewed-on: https://go-review.googlesource.com/3288
Reviewed-by: Keith Randall <khr@golang.org>
2015-01-27 17:47:49 +00:00
Russ Cox
891d344cd0 cmd/go: on arm, all binaries depend on math
Change-Id: I10b781927245a3e9822f9cffe254f226a5b93213
Reviewed-on: https://go-review.googlesource.com/3279
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-26 20:01:54 +00:00
Russ Cox
8d44ede0dc cmd/gc: simplify code for c2go (more)
- Remove more ? : expressions.
- Use uint32 **hash instead of uint32 *hash[] in function argument.
- Change array.c API to use int, not int32, to match Go's slices.
- Rename strlit to newstrlit, to avoid case-insensitive collision with Strlit.
- Fix a few incorrect printf formats.
- Rename a few variables from 'len' to n or length.
- Eliminate direct string editing building up names like convI2T.

Change-Id: I754cf553402ccdd4963e51b7039f589286219c29
Reviewed-on: https://go-review.googlesource.com/3278
Reviewed-by: Rob Pike <r@golang.org>
2015-01-26 20:00:44 +00:00
Russ Cox
349ecfb0d6 cmd/gc: make cmd/gc a real library
cmd/gc contains symbol references into the back end dirs like 6g.
It also contains a few files that include the back end header files and
are compiled separately for each back end, despite being in cmd/gc.
cmd/gc also defines main, which makes at least one reverse symbol
reference unavoidable. (Otherwise you can't get into back-end code.)

This was all expedient, but it's too tightly coupled, especially for a
program written Go.

Make cmd/gc into a true library, letting the back end define main and
call into cmd/gc after making the necessary references available.
cmd/gc being a real library will ease the transition to Go.

Change-Id: I4fb9a0e2b11a32f1d024b3c56fc3bd9ee458842c
Reviewed-on: https://go-review.googlesource.com/3277
Reviewed-by: Rob Pike <r@golang.org>
2015-01-26 20:00:38 +00:00
Russ Cox
e82003e750 cmd/gc: simplify code for c2go
- Change forward reference to struct Node* to void* in liblink.
- Use explicit (Node*) casts in cmd/gc to get at that field.
- Define struct Array in go.h instead of hiding it in array.c.
- Remove some sizeof(uint32), sizeof(uint64) uses.
- Remove some ? : expressions.
- Rewrite some problematic mid-expression assignments.

Change-Id: I308c70140238a0cfffd90e133f86f442cd0e17d4
Reviewed-on: https://go-review.googlesource.com/3276
Reviewed-by: Rob Pike <r@golang.org>
2015-01-26 20:00:30 +00:00
Rob Pike
89162307cd [dev.cc] cmd/asm: changes to get identical output as new6a
Fix up a couple of minor things pointed out in the last review.
Also:

1. If the symbol starts with center dot, prefix the name with "".
2. If there is no locals size specified, use ArgsSizeUnknown (sic).
3. Do not emit a history point at the start of a macro invocation,
since we do not pop it at the end, behavior consistent with the
old code.

With these changes, old and new assemblers produce identical
output at least for my simple test case, so that provides a verifiable
check for future cleanups.

Change-Id: Iaa91d8e453109824b4be44321ec5e828f39f0299
Reviewed-on: https://go-review.googlesource.com/3242
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-24 03:28:26 +00:00
Russ Cox
07a27ce09e [dev.cc] cmd/dist: show bootstrap build progress in real time
Change-Id: I97bbf7a276c8f99554f0e3a9bcc8d3792a5e0f65
Reviewed-on: https://go-review.googlesource.com/3221
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-23 17:13:33 +00:00
Rob Pike
fdeee3a538 [dev.cc] cmd/asm: the assembler proper
Add main.go, the simple driver for the assembler, and the
subdirectory internal/asm, which contains the parser and
instruction generator.

It's likely that much of the implementation is superstition,
or at best experimental phenomenology, but it does generate
working binaries.

Change-Id: I322a9ae8a20174b6693153f30e39217ba68f8032
Reviewed-on: https://go-review.googlesource.com/3196
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-23 04:54:05 +00:00
Rob Pike
8642639575 [dev.cc] cmd/asm: add lex internal package
Add the lexing code for the new portable assembler.
It is internal to the assembler, so lives in a subdirectory of cmd/asm/internal.

Its only new dependency is the flags package for the assembler, so
add that too; it's trivial. That package manages the command-line
flags in a central place.

The lexer builds on text/scanner to lex the input, including doing a
Plan 9-level implementation of the C preprocessor.

Change-Id: I262e8717b8c797010afaa5051920839906c0dd19
Reviewed-on: https://go-review.googlesource.com/3195
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-23 04:24:57 +00:00
Rob Pike
40eb0ed0d8 [dev.cc] cmd/asm: add addr package
This simple package holds the definition of the Addr (address) type
that represents addresses inside the assembler.

It has no dependencies.

Change-Id: I7573fd70f1847ef68e3d6b663dc4c39eb2ebf8b3
Reviewed-on: https://go-review.googlesource.com/3193
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-23 03:30:37 +00:00
Rob Pike
6017f68029 [dev.cc] cmd/asm: add arch package
This package builds the representation of the machine architecture
for the new assembler.

Almost nothing in it is likely to last but this will get things running.

Change-Id: I8edd891f927a81f76d2dbdcd7484b9c87ac0fb2e
Reviewed-on: https://go-review.googlesource.com/3194
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-23 03:18:55 +00:00
Michael Matloob
afe6668216 cmd/ld: s/specificaly/specifically/ in comment
Change-Id: I849b8046daaec97ae631d59f1870cd5f1cd72f22
Reviewed-on: https://go-review.googlesource.com/3176
Reviewed-by: Minux Ma <minux@golang.org>
2015-01-22 07:08:46 +00:00
Ian Lance Taylor
ec0ebc2281 cmd/gc: treat non-local vars inlined into wrapper as escaping
The compiler has a phase ordering problem.  Escape analysis runs
before wrapper generation.  When a generated wrapper calls a method
defined in a different package, if that call is inlined, there will be
no escape information for the variables defined in the inlined call.
Those variables will be placed on the stack, which fails if they
actually do escape.

There are probably various complex ways to fix this.  This is a simple
way to avoid it: when a generated wrapper calls a method defined in a
different package, treat all local variables as escaping.

Fixes #9537.

Change-Id: I530f39346de16ad173371c6c3f69cc189351a4e9
Reviewed-on: https://go-review.googlesource.com/3092
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-22 03:25:12 +00:00
Russ Cox
67e7ded029 [dev.cc] cmd/internal/obj, cmd/new9a: use ctxt.NewProg
cmd/internal/obj reconverted using rsc.io/c2go rev 40275b8.

All Prog*s need Ctxt field set so that the printer can tell
which architecture the Prog belongs to.
Use ctxt.NewProg consistently for this.

Change-Id: Ic981b3d68f24931ffae74a772e83a3dc2fdf518a
Reviewed-on: https://go-review.googlesource.com/3152
Reviewed-by: Rob Pike <r@golang.org>
2015-01-22 03:22:04 +00:00
Russ Cox
ebaf8db4f6 [dev.cc] cmd/internal/obj: export more symbols, rename Type_ to Type
For new assembler, reconvert using rsc.io/c2go rev f9db76e.
- Removes trailing _ from Go keywords that are exported.
- Export regstr as Register, anames[5689] as Anames.

Also update clients.

Change-Id: I41c8fd2d14490236f548b4aa0ed0b9bd7571d2d7
Reviewed-on: https://go-review.googlesource.com/3151
Reviewed-by: Rob Pike <r@golang.org>
2015-01-21 21:24:40 +00:00
Russ Cox
5282e3ab26 [dev.cc] cmd/go: run C and Go assemblers side by side and verify matching output
When an assembly file must be assembled, cmd/go now runs
both (say) 6a and new6a and checks that they write identical
output files.

This serves as a build-time test that the new assemblers are accurate
conversions of the old ones. As long as they are producing identical
bytes, there's no need for run-time testing.

Once the C conversion is done, we'll throw away the C code
and this checking.

Change-Id: I0216dad56b7e79011eecd27f1aff4fe79bfe720b
Reviewed-on: https://go-review.googlesource.com/3145
Reviewed-by: Rob Pike <r@golang.org>
2015-01-21 19:43:24 +00:00
Russ Cox
f4d2d71752 [dev.cc] cmd/dist: build new5a etc during bootstrap
The change to the bootstrap import conversion is
for the a.y files, which use import dot.

While we're editing the tool list, add "cmd/dist".
Right now 'go install cmd/dist' installs to $GOROOT/bin/dist.
(A new bug since cmd/dist has been rewritten in Go.
When cmd/dist was a C program, go install cmd/dist just didn't work.)

Change-Id: I362208dcfb4ae64c987f60b95dc946829fa506d8
Reviewed-on: https://go-review.googlesource.com/3144
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-01-21 19:43:09 +00:00
Russ Cox
4ca2fc4d8b [dev.cc] cmd/new5a etc, cmd/internal/asm: edit to produce working Go code
These assemblers produce byte-for-byte identical output
to the ones written in C.

They are primarily a proof that cmd/internal/obj can be used
standalone to produce working object files. (The use via objwriter
starts by deserializing an already-constructed internal representation,
so objwriter does not exercise the code in cmd/internal/obj that
creates such a representation from scratch.)

Change-Id: I1793d8d010046cfb9d8b4d2d4469e7f47a3d3ac7
Reviewed-on: https://go-review.googlesource.com/3143
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-21 19:42:58 +00:00
Russ Cox
9e2f8fdb6f [dev.cc] cmd/new5a etc, cmd/internal/asm: initial C → Go conversion
This is the raw output of c2go. It needs fixes to make it compile.
Rather than make c2go do a 100% conversion (like we're doing for
liblink and the Go compilers), since this is so trivial I'm going to
make the remaining changes by hand in a followup CL.
This CL makes the next CL's diffs useful.

Also copy unmodified .y files (5a/a.y → new5a/a.y and so on)

The converted 6a/lex.c has been written to new6a/lex.go
but also to internal/asm/asm.go, because I'm going to factor
out some common code rather than convert it four times.

Change-Id: I01d5dfd6a9be3ef6191581560bdddd0ac0e8bc58
Reviewed-on: https://go-review.googlesource.com/3142
Reviewed-by: Rob Pike <r@golang.org>
2015-01-21 19:42:48 +00:00
Russ Cox
24dfaba6d1 [dev.cc] cmd/internal/obj: reconvert from liblink
Using rsc.io/c2go repo revision 60c9302.

- Export a few symbols needed by assemblers.
- Implement Getgoroot etc directly, and add Getgoversion.
- Removes dependency on Go 1.4 go/build.
- Change magic history name <no name> to <pop>

The <pop> change requires adjustment to the liblink serializer.

Change-Id: If5fb52ac9e91d50805263070b3fc5cc05d8b7632
Reviewed-on: https://go-review.googlesource.com/3141
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-01-21 19:06:31 +00:00
Russ Cox
a8e5e803e6 [dev.cc] cmd/dist: write cmd/internal/obj/zbootstrap.go
cmd/internal/obj needs information about the default
values of GOROOT, GOARM, GOEXPERIMENT, Version, and so on.
It cannot ask package runtime, because during bootstrap
package runtime comes from Go 1.4.
So it must have its own copy.

Change-Id: I73d3e75a3d47210b3184a51a810ebb44826b81e5
Reviewed-on: https://go-review.googlesource.com/3140
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-01-21 19:06:21 +00:00
Russ Cox
35d3987dbc [dev.cc] cmd/objwriter: implement using cmd/internal/obj
New code but nothing interesting.
It's nearly all parsing code for the format written by liblink.
The interesting part is the call to obj.Writeobjdirect, which
is the Go translation of the C liblink writeobjdirect function.

Change-Id: I2e9e755e7a3c999302e2ef2c7475c0af9c5acdd2
Reviewed-on: https://go-review.googlesource.com/3047
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-21 03:02:35 +00:00
Russ Cox
d6f6e420fc [dev.cc] cmd/internal/obj: convert liblink C to Go
This CL adds the real cmd/internal/obj packages.
Collectively they correspond to the liblink library.
The conversion was done using rsc.io/c2go's run script
at rsc.io/c2go repo version 706fac7.

This is not the final conversion, just the first working draft.
There will be more updates, but this works well enough
to use with go tool objwriter and pass all.bash.

Change-Id: I9359e835425f995a392bb2fcdbebf29511477bed
Reviewed-on: https://go-review.googlesource.com/3046
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-21 03:02:27 +00:00
Russ Cox
328ace91e6 [dev.cc] cmd/dist: bootstrap Go toolchain using Go 1.4
Bootstrap the Go parts of the Go toolchain using Go 1.4,
as described in https://golang.org/s/go15bootstrap.

The first Go part of the Go toolchain will be cmd/objwriter,
but for now that's just an empty program to test that this
new code works.

Once the build dashboard is okay with this change,
we'll make objwriter a real program depended upon by the build.

Change-Id: Iad3dce675571cbdb5ab6298fe6f98f53ede47d5c
Reviewed-on: https://go-review.googlesource.com/3044
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-21 00:45:03 +00:00
Russ Cox
283b23297a [dev.cc] cmd/objwriter: add placeholder program
cmd/internal/obj is the name for the Go translation of the C liblink library.

cmd/objwriter is the name of a Go binary that runs liblink's writeobj function.
When the bulk of liblink has been converted to Go but the assemblers and
compilers are still written in C, the C writeobj will shell out to the Go objwriter
to actually write the object file. This lets us manage the transition in smaller
pieces.

The objwriter tool is purely transitional.
It will not ship in any release (enforced in cmd/dist).

Adding a dummy program and some dummy imports here so that we
can work on the bootstrap mechanisms that will be necessary to build it.
Once the build process handles objwriter properly,
we'll work on the actual implementation.

Change-Id: I675c818b3a513c26bb91c6dba564c6ace3b7fcd4
Reviewed-on: https://go-review.googlesource.com/3043
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-21 00:44:56 +00:00
Russ Cox
c4dd7fac89 [dev.cc] cmd/dist, lib9: make GOHOSTARCH, GOHOSTOS available to C programs
Needed for invoking a Go subprocess in the C code.
The Go tools live in $GOROOT/pkg/tool/$GOHOSTARCH_$GOHOSTOS.

Change-Id: I961b6b8a07de912de174b758b2fb87d77080546d
Reviewed-on: https://go-review.googlesource.com/3042
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-21 00:44:50 +00:00
Russ Cox
dba9eb3369 build: implement GOEXPERIMENT again in runtime, and add to liblink
For Austin's framepointer experiment.

Change-Id: I81b6f414943b3578924f853300b9193684f79bf4
Reviewed-on: https://go-review.googlesource.com/2994
Reviewed-by: Austin Clements <austin@google.com>
2015-01-21 00:44:18 +00:00
Chris Manghane
f5b8813e93 cmd/gc: don't unpack struct arguments to append
Fixes #9634.

Change-Id: I7b18f26c2fb812978fc7adc5bfd39ebfffe48701
Reviewed-on: https://go-review.googlesource.com/3080
Reviewed-by: Minux Ma <minux@golang.org>
2015-01-20 22:55:56 +00:00
Mikio Hara
9ccbd027dd cmd/go: make use of Runnable method
Reported via unsupported Github pull request: #9299

Change-Id: I0e98dd68cbc68fcc6bcec15c5b33f20b6a861ec6
Reviewed-on: https://go-review.googlesource.com/3025
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-19 22:20:41 +00:00
Russ Cox
73a10bfcbb cmd/dist: fix deadlock when compilation command fails
Can't use bgwait, both because it can only be used from
one goroutine at a time and because it ends up queued
behind all the other pending commands. Use a separate
signaling mechanism so that we can notice we're dying
sooner.

Change-Id: I8652bfa2f9bb5725fa5968d2dd6a745869d01c01
Reviewed-on: https://go-review.googlesource.com/3010
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-19 16:27:13 +00:00
Russ Cox
e832043e72 cmd/go: set $GOROOT during 'go tool' invocations
cmd/dist now requires $GOROOT to be set explicitly.
Set it when invoking via 'go tool dist' so that users are unaffected.

Also, change go tool -n to drop trailing space in output
for 'go tool -n <anything>'.

Change-Id: I9b2c020e0a2f3fa7c9c339fadcc22cc5b6cb7cac
Reviewed-on: https://go-review.googlesource.com/3011
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-19 02:19:01 +00:00
Shenghou Ma
dca54d7cdd cmd/dist: do not leave go-tool-dist-* temporary directories behind
Change-Id: I3f6ba5591130b2c4762d33bd4553220765ad9fc5
Reviewed-on: https://go-review.googlesource.com/2996
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-01-19 00:50:50 +00:00
Michael Matloob
020637daa9 cmd/dist: produce a properly formatted zversion.go
gofmt inserts a blank line line between const and var declarations

Change-Id: I3f2ddbd9e66a74eb3f37a2fe641b93820b02229e
Reviewed-on: https://go-review.googlesource.com/3022
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-19 00:35:40 +00:00
Russ Cox
9af454c588 all: merge dev.cc (929f321) into master
This brings in cmd/dist written in Go, which is working on the primary builders.

If this breaks your build, you need to get Go 1.4 and put it in $HOME/go1.4
(or, if you want to use some other directory, set $GOROOT_BOOTSTRAP
to that directory).

To build Go 1.4 from source:

	git clone -b release-branch.go1.4 $GOROOT $HOME/go1.4
	cd $HOME/go1.4/src
	./make.bash

Or use a binary release: https://golang.org/dl/.

See https://golang.org/s/go15bootstrap for more information.

Change-Id: Ie4ae834c76ea35e39cc54e9878819a9e51b284d9
2015-01-16 18:57:33 -05:00
Keith Randall
daa64ddfe6 cmd/5g: make sure we normalize after unary ops on small types
We were failing ^uint16(0xffff) == 0, as we computed 0xffff0000 instead.

I could only trigger a failure for the above case, the other two tests
^uint16(0xfffe) == 1 and -uint16(0xffff) == 1 didn't seem to fail
previously.  Somehow they get MOVHUs inserted for other reasons (used
by CMP instead of TST?).  I fixed OMINUS anyway, better safe than
sorry.

Fixes #9604

Change-Id: I4c2d5bdc667742873ac029fdbe3db0cf12893c27
Reviewed-on: https://go-review.googlesource.com/2940
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-01-15 23:50:01 +00:00
Russ Cox
929f3210ac [dev.cc] all: merge master (d1210ac) into dev.cc
Change-Id: I068d617175776c2f5df00b17ff0d404a584ab570
2015-01-14 19:40:28 -05:00
Russ Cox
3be0a0ef6f liblink: adjustments for c2go conversion
Mostly this is using uint32 instead of int32 for unsigned values
like instruction encodings or float32 bit representations,
removal of ternary operations, and removal of #defines.

Delete sched9.c, because it is not compiled (it is still in the history
if we ever need it).

Change-Id: I68579cfea679438a27a80416727a9af932b088ae
Reviewed-on: https://go-review.googlesource.com/2658
Reviewed-by: Austin Clements <austin@google.com>
2015-01-14 19:18:05 +00:00
Russ Cox
b8d67596f6 cmd/go: adjust error for custom import checkout mismatch
Before:

	...
	imports golang.org/x/net/context: /Users/rsc/g/src/golang.org/x/net is from https://code.google.com/p/go.net, should be from https://go.googlesource.com/net

After:

	...
	imports golang.org/x/net/context: golang.org/x/net is a custom import path for https://go.googlesource.com/net, but /Users/rsc/g/src/golang.org/x/net is checked out from https://code.google.com/p/go.net

Change-Id: I93c35b85f955c7de684f71fbd4baecc717405318
Reviewed-on: https://go-review.googlesource.com/2808
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-01-14 15:01:55 +00:00
David du Colombier
b46b9429f0 build: bootstrap on Plan 9
This change implements the requirement of
old Go to build new Go on Plan 9. Also fix
the build of the new cmd/dist written in Go.

This is similar to the make.bash change in
CL 2470, but applied to make.rc for Plan 9.

Change-Id: Ifd9a3bd8658e2cee6f92b4c7f29ce86ee2a93c53
Reviewed-on: https://go-review.googlesource.com/2662
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-13 07:50:32 +00:00
Brad Fitzpatrick
afeca5c22d build: update Windows make.bat for Go-based dist
These are corresponding Windows changes for the GOROOT_BOOTSTRAP and
dist changes in https://golang.org/cl/2470

Change-Id: I21da2d63a60d8ae278ade9bb71ae0c314a2cf9b5
Reviewed-on: https://go-review.googlesource.com/2674
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-01-12 23:01:37 +00:00
Shenghou Ma
16993f2485 cmd/cgo: also rewrite C.var in selector expressions
While we're here, rename TestIssue7234 to Test7234 for consistency
with other tests.

Fixes #9557.

Change-Id: I22b0a212b31e7b4f199f6a70deb73374beb80f84
Reviewed-on: https://go-review.googlesource.com/2654
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-12 21:48:57 +00:00
Dave Cheney
d369f97342 cmd/dist: fix arm vfp detection
* Use WORD declaration so 5a can't rewrite the instruction or complain
  about forms it doesn't know about.
* Add the interpunct to function declaration.

Change-Id: I8494548db21b3ea52f0e1e0e547d9ead8b93dfd1
Reviewed-on: https://go-review.googlesource.com/2682
Reviewed-by: Minux Ma <minux@golang.org>
2015-01-12 21:07:26 +00:00
Shenghou Ma
fcff3ba740 cmd/gc: don't recurse infinitely when a recursive type references itself more than once
Fixes #9432

Change-Id: I08c92481afa7c7fac890aa780efc1cb2fabad528
Reviewed-on: https://go-review.googlesource.com/2115
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-12 02:09:50 +00:00
Daniel Morsing
301ad790a2 cmd/gc: fix racewalk after writebarrierfat was renamed to typedmemmove
Renaming the function broke the race detector since it looked for the
name, didn't find it anymore and didn't insert the necessary
instrumentation.

Change-Id: I11fed6e807cc35be5724d26af12ceff33ebf4f7b
Reviewed-on: https://go-review.googlesource.com/2661
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-01-11 09:34:53 +00:00
Russ Cox
20a10e7ddd build: require old Go to build new Go (and convert cmd/dist to Go)
This CL introduces the bootstrap requirement that in order to
build the current release (or development version) of Go, you
need an older Go release (1.4 or newer) already installed.
This requirement is the whole point of this CL.

To enforce the requirement, convert cmd/dist from C to Go.

With this bootstrapping out of the way, we can move on to
replacing other, larger C programs like the Go compiler,
the assemblers, and the linker.

See golang.org/s/go15bootstrap for details.

Change-Id: I53fd08ddacf3df9fae94fe2c986dba427ee4a21d
Reviewed-on: https://go-review.googlesource.com/2470
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-01-10 19:16:00 +00:00
Russ Cox
ad6ee36cac cmd/dist: remove C sources, rename some to Go files
This CL makes the next one have nice cross-file diffs.

Change-Id: I9ce897dc505dea9923be4e823bae31f4f7fa2ee2
Reviewed-on: https://go-review.googlesource.com/2471
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-10 19:15:37 +00:00
Shenghou Ma
0d4d582c68 cmd/5a, cmd/6a, cmd/8a, cmd/9a: check nerrors before exit
Also fix one unaligned stack size for nacl that is caught
by this change.

Fixes #9539.

Change-Id: Ib696a573d3f1f9bac7724f3a719aab65a11e04d3
Reviewed-on: https://go-review.googlesource.com/2600
Reviewed-by: Keith Randall <khr@golang.org>
2015-01-09 23:56:28 +00:00
Josh Bleecher Snyder
2feff0038b cmd/gc: fix ARM build
CL 2520 omitted to set the type for an OCONVNOP node.
Typechecking obviously cannot do it for us.

5g inserts float64 <--> [u]int64 conversions at walk time.
The missing type caused it to crash.

Change-Id: Idce381f219bfef2e3a3be38d3ba3c258b71310ae
Reviewed-on: https://go-review.googlesource.com/2640
Reviewed-by: Keith Randall <khr@golang.org>
2015-01-09 23:33:51 +00:00
Josh Bleecher Snyder
f03c9202c4 cmd/gc: optimize memclr of slices and arrays
Recognize loops of the form

for i := range a {
	a[i] = zero
}

in which the evaluation of a is free from side effects.
Replace these loops with calls to memclr.
This occurs in the stdlib in 18 places.

The motivating example is clearing a byte slice:

benchmark                old ns/op     new ns/op     delta
BenchmarkGoMemclr5       3.31          3.26          -1.51%
BenchmarkGoMemclr16      13.7          3.28          -76.06%
BenchmarkGoMemclr64      50.8          4.14          -91.85%
BenchmarkGoMemclr256     157           6.02          -96.17%

Update #5373.

Change-Id: I99d3e6f5f268e8c6499b7e661df46403e5eb83e4
Reviewed-on: https://go-review.googlesource.com/2520
Reviewed-by: Keith Randall <khr@golang.org>
2015-01-09 22:35:25 +00:00
Shenghou Ma
5664eda733 cmd/go: document import path checking
This is a replay of CL 189760043 that is in release-branch.go1.4,
but not in master branch somehow.

Change-Id: I11eb40a24273e7be397e092ef040e54efb8ffe86
Reviewed-on: https://go-review.googlesource.com/2541
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-01-08 23:24:59 +00:00
Keith Randall
6f07ac2f28 cmd/gc: pad structs which end in zero-sized fields
For a non-zero-sized struct with a final zero-sized field,
add a byte to the size (before rounding to alignment).  This
change ensures that taking the address of the zero-sized field
will not incorrectly leak the following object in memory.

reflect.funcLayout also needs this treatment.

Fixes #9401

Change-Id: I1dc503dc5af4ca22c8f8c048fb7b4541cc957e0f
Reviewed-on: https://go-review.googlesource.com/2452
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-08 21:05:10 +00:00
Matthew Dempsky
ee94cd1dff cmd/cgo, go/build: finish a cleanup TODO
Removing #cgo directive parsing from cmd/cgo was done in
https://golang.org/cl/8610044.

Change-Id: Id1bec58c6ec1f932df0ce0ee84ff253655bb73ff
Reviewed-on: https://go-review.googlesource.com/2501
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-08 00:59:37 +00:00
Matthew Dempsky
b2aab72d9a cmd/cgo: remove obsolete -cdefs flag
Now that there's no 6c compiler anymore, there's no need for cgo to
generate C headers that are compatible with it.

Fixes #9528

Change-Id: I43f53869719eb9a6065f1b39f66f060e604cbee0
Reviewed-on: https://go-review.googlesource.com/2482
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-07 22:49:59 +00:00
Josh Bleecher Snyder
43e6923131 cmd/gc: optimize existence-only map lookups
The compiler converts 'val, ok = m[key]' to

        tmp, ok = <runtime call>
        val = *tmp

For lookups of the form '_, ok = m[key]',
the second statement is unnecessary.
By not generating it we save a nil check.

Change-Id: I21346cc195cb3c62e041af8b18770c0940358695
Reviewed-on: https://go-review.googlesource.com/1975
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-07 22:36:06 +00:00
Josh Bleecher Snyder
43c87aa481 cmd/6g, cmd/8g, liblink: improve handling of float constants
* Enable basic constant propagation for floats.
  The constant propagation is still not as aggressive as it could be.
* Implement MOVSS $(0), Xx and MOVSD $(0), Xx as XORPS Xx, Xx.

Sample code:

func f32() float32 {
	var f float32
	return f
}

func f64() float64 {
	var f float64
	return f
}

Before:

"".f32 t=1 size=32 value=0 args=0x8 locals=0x0
	0x0000 00000 (demo.go:3)	TEXT	"".f32+0(SB),4,$0-8
	0x0000 00000 (demo.go:3)	FUNCDATA	$0,gclocals·a7a3692b8e27e823add69ec4239ba55f+0(SB)
	0x0000 00000 (demo.go:3)	FUNCDATA	$1,gclocals·3280bececceccd33cb74587feedb1f9f+0(SB)
	0x0000 00000 (demo.go:3)	MOVSS	$f32.00000000+0(SB),X0
	0x0008 00008 (demo.go:4)	MOVSS	$f32.00000000+0(SB),X0
	0x0010 00016 (demo.go:5)	MOVSS	X0,"".~r0+8(FP)
	0x0016 00022 (demo.go:5)	RET	,
"".f64 t=1 size=32 value=0 args=0x8 locals=0x0
	0x0000 00000 (demo.go:8)	TEXT	"".f64+0(SB),4,$0-8
	0x0000 00000 (demo.go:8)	FUNCDATA	$0,gclocals·a7a3692b8e27e823add69ec4239ba55f+0(SB)
	0x0000 00000 (demo.go:8)	FUNCDATA	$1,gclocals·3280bececceccd33cb74587feedb1f9f+0(SB)
	0x0000 00000 (demo.go:8)	MOVSD	$f64.0000000000000000+0(SB),X0
	0x0008 00008 (demo.go:9)	MOVSD	$f64.0000000000000000+0(SB),X0
	0x0010 00016 (demo.go:10)	MOVSD	X0,"".~r0+8(FP)
	0x0016 00022 (demo.go:10)	RET	,

After:

"".f32 t=1 size=16 value=0 args=0x8 locals=0x0
	0x0000 00000 (demo.go:3)	TEXT	"".f32+0(SB),4,$0-8
	0x0000 00000 (demo.go:3)	FUNCDATA	$0,gclocals·a7a3692b8e27e823add69ec4239ba55f+0(SB)
	0x0000 00000 (demo.go:3)	FUNCDATA	$1,gclocals·3280bececceccd33cb74587feedb1f9f+0(SB)
	0x0000 00000 (demo.go:3)	XORPS	X0,X0
	0x0003 00003 (demo.go:5)	MOVSS	X0,"".~r0+8(FP)
	0x0009 00009 (demo.go:5)	RET	,
"".f64 t=1 size=16 value=0 args=0x8 locals=0x0
	0x0000 00000 (demo.go:8)	TEXT	"".f64+0(SB),4,$0-8
	0x0000 00000 (demo.go:8)	FUNCDATA	$0,gclocals·a7a3692b8e27e823add69ec4239ba55f+0(SB)
	0x0000 00000 (demo.go:8)	FUNCDATA	$1,gclocals·3280bececceccd33cb74587feedb1f9f+0(SB)
	0x0000 00000 (demo.go:8)	XORPS	X0,X0
	0x0003 00003 (demo.go:10)	MOVSD	X0,"".~r0+8(FP)
	0x0009 00009 (demo.go:10)	RET	,

Change-Id: Ie9eb65e324af4f664153d0a7cd22bb16b0fba16d
Reviewed-on: https://go-review.googlesource.com/2053
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-07 22:26:55 +00:00
Keith Randall
d5e4c4061b runtime: remove size argument from hash and equal algorithms
The equal algorithm used to take the size
   equal(p, q *T, size uintptr) bool
With this change, it does not
   equal(p, q *T) bool
Similarly for the hash algorithm.

The size is rarely used, as most equal functions know the size
of the thing they are comparing.  For instance f32equal already
knows its inputs are 4 bytes in size.

For cases where the size is not known, we allocate a closure
(one for each size needed) that points to an assembly stub that
reads the size out of the closure and calls generic code that
has a size argument.

Reduces the size of the go binary by 0.07%.  Performance impact
is not measurable.

Change-Id: I6e00adf3dde7ad2974adbcff0ee91e86d2194fec
Reviewed-on: https://go-review.googlesource.com/2392
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-07 21:57:01 +00:00
Keith Randall
63116de558 runtime: faster version of findfunc
Use a lookup table to find the function which contains a pc.  It is
faster than the old binary search.  findfunc is used primarily for
stack copying and garbage collection.

benchmark              old ns/op     new ns/op     delta
BenchmarkStackCopy     294746596     255400980     -13.35%

(findfunc is one of several tasks done by stack copy, the findfunc
time itself is about 2.5x faster.)

The lookup table is built at link time.  The table grows the binary
size by about 0.5% of the text segment.

We impose a lower limit of 16 bytes on any function, which should not
have much of an impact.  (The real constraint required is <=256
functions in every 4096 bytes, but 16 bytes/function is easier to
implement.)

Change-Id: Ic315b7a2c83e1f7203cd2a50e5d21a822e18fdca
Reviewed-on: https://go-review.googlesource.com/2097
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-07 21:24:21 +00:00
Austin Clements
af7ca8dce4 cmd/cgo, runtime/cgo: support ppc64
This implements support for calls to and from C in the ppc64 C ABI, as
well as supporting functionality such as an entry point from the
dynamic linker.

Change-Id: I68da6df50d5638cb1a3d3fef773fb412d7bf631a
Reviewed-on: https://go-review.googlesource.com/2009
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-07 20:36:27 +00:00
Austin Clements
bbd2127909 cmd/9g: don't use R13
R13 is the C TLS pointer.  Once we're calling to and from C code, if
we clobber R13 in our code, sigtramp won't know whether to get the
current g from REGG or from C TLS.  The simplest solution is for Go
code to preserve the C TLS pointer.  This is equivalent to what other
platforms do, except that on other platforms the TLS pointer is in a
special register.

Change-Id: I076e9cb83fd78843eb68cb07c748c4705c9a4c82
Reviewed-on: https://go-review.googlesource.com/2007
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-07 20:36:08 +00:00
Austin Clements
db923390a0 cmd/9l: support internal linking
This implements the ELF relocations and dynamic linking tables
necessary to support internal linking on ppc64.  It also marks ppc64le
ELF files as ABI v2; failing to do this doesn't seem to confuse the
loader, but it does confuse libbfd (and hence gdb, objdump, etc).

Change-Id: I559dddf89b39052e1b6288a4dd5e72693b5355e4
Reviewed-on: https://go-review.googlesource.com/2006
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-07 20:35:54 +00:00