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

6157 Commits

Author SHA1 Message Date
Shenghou Ma
fd392ee52b cmd/internal/ld: generate correct .debug_frames on RISC architectures
With this patch, gdb seems to be able to corretly backtrace Go
process on at least linux/{arm,arm64,ppc64}.

Change-Id: Ic40a2a70e71a19c4a92e4655710f38a807b67e9a
Reviewed-on: https://go-review.googlesource.com/9822
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-05-08 00:34:27 +00:00
Josh Bleecher Snyder
a3dfcf51c6 cmd/internal/gc: unsafe.Pointer constants may only be converted to uintptr
Fixes #8927.

Change-Id: I638cddd439dd2d4eeef5474118cfcbde0c8a5a43
Reviewed-on: https://go-review.googlesource.com/9632
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
2015-05-07 23:54:28 +00:00
Keith Randall
0767461ecf [dev.ssa] Merge remote-tracking branch 'origin/master' into dev.ssa
Change-Id: I0f9b6777fd1cb121ad21bce0f2c52f142be2eb6f
2015-05-07 16:16:36 -07:00
Keith Randall
a9a37dab4a [dev.ssa] cmd/internal/ssa: Add register allocation
Add a simple register allocator.  It does only intra-basicblock
allocation.  It uses a greedy one-pass allocation treating the
register file as a cache.

Change-Id: Ib6b52f48270e08dfda98f2dd842b05afc3ab01ce
Reviewed-on: https://go-review.googlesource.com/9761
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-05-07 22:30:03 +00:00
Ian Lance Taylor
e45aebd6dd cmd/go: install headers for c-archive/c-shared cgo exports
When
  using -buildmode=c-archive or c-shared, and
  when installing packages that use cgo, and
  when those packages export some functions via //export comments,
then
  for each such package, install a pkg.h header file that declares the
  functions.

This permits C code to #include the header when calling the Go
functions.

This is a little awkward to use when there are multiple packages that
export functions, as you have to "go install" your c-archive/c-shared
object and then pull it out of the package directory.  When compiling
your C code you have to -I pkg/$GOOS_$GOARCH.  I haven't thought of
any more convenient approach.  It's simpler when only the main package
has exported functions.

When using c-shared you currently have to use a _shared suffix in the
-I option; it would be nice to fix that somehow.

Change-Id: I5d8cf08914b7d3c2b194120c77791d2732ffd26e
Reviewed-on: https://go-review.googlesource.com/9798
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-05-07 17:39:56 +00:00
David Chase
d4bb72b485 cmd/internal/gc: improve "type *X has no field or method M" message
Try to provide hints for common areas, either *interface
were interface would have been better, and note incorrect
capitalization (but don't be more ambitious than that, at
least not today).

Added code and test for cases

  ptrInterface.ExistingMethod
  ptrInterface.unexportedMethod
  ptrInterface.MissingMethod
  ptrInterface.withwRongcASEdMethod
  interface.withwRongcASEdMethod
  ptrStruct.withwRongcASEdMethod
  struct.withwRongcASEdMethod

also included tests for related errors to check for
unintentional changes and consistent wording.

Somewhat simplified from previous versions to avoid second-
guessing user errors, yet also biased to point out most-likely
root cause.

Fixes #10700

Change-Id: I16693e93cc8d8ca195e7742a222d640c262105b4
Reviewed-on: https://go-review.googlesource.com/9731
Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-07 16:21:57 +00:00
Ian Lance Taylor
5e94c65b5d cmd/cgo: add -exportheader option
The -exportheader option tells cgo to generate a header file declaring
expoted functions.  The header file is only created if there are, in
fact, some exported functions, so it also serves as a signal as to
whether there were any.

In future CLs the go tool will use this option to install header files
for packages that use cgo and export functions.

Change-Id: I5b04357d453a9a8f0e70d37f8f18274cf40d74c9
Reviewed-on: https://go-review.googlesource.com/9796
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-07 05:03:23 +00:00
Ian Lance Taylor
2bb6f76a05 cmd/cgo: add header guard for boilerplate in export header file
Change-Id: If53563f3477222fe7409011b8780bb0926567251
Reviewed-on: https://go-review.googlesource.com/9767
Reviewed-by: Minux Ma <minux@golang.org>
2015-05-07 00:05:08 +00:00
Ian Lance Taylor
2f9acc13c1 cmd/cgo: readability improvements to generated _cgo_export.h
Also copy doc comments from Go code to _cgo_export.h.

This is a step toward installing this generated file when using
-buildmode=c-archive or c-shared, so that C code can #include it.

Change-Id: I3a243f7b386b58ec5c5ddb9a246bb9f9eddc5fb8
Reviewed-on: https://go-review.googlesource.com/9790
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-06 22:33:24 +00:00
Rob Pike
da4fc529d9 cmd/doc: add type-bound vars to global vars list
Already done for constants and funcs, but I didn't realize that some
global vars were also not in the global list. This fixes

	go doc build.Default

Change-Id: I768bde13a400259df3e46dddc9f58c8f0e993c72
Reviewed-on: https://go-review.googlesource.com/9764
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-05-06 22:32:42 +00:00
Rob Pike
9de28cf547 cmd/doc: if no top-level symbols match, look for methods
Improving the usability further.

Before:

$ go doc bytes.Read
doc: symbol Read not present in package bytes installed in "bytes"
$

After:
$ go doc bytes.Read
func (b *Buffer) Read(p []byte) (n int, err error)
    Read reads the next len(p) bytes from the buffer or until the buffer is drained.
    The return value n is the number of bytes read. If the buffer has no data to
    return, err is io.EOF (unless len(p) is zero); otherwise it is nil.
func (r *Reader) Read(b []byte) (n int, err error)
$

Change-Id: I646511fada138bd09e9b39820da01a5ccef4a90f
Reviewed-on: https://go-review.googlesource.com/9656
Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-06 16:13:47 +00:00
Aram Hăvărneanu
83b25d9342 cmd/ld: make .rela and .rela.plt sections contiguous
ELF normally requires this and Solaris runtime loader will crash if we
don't do it.

Fixes Solaris build.

Change-Id: I0482eed890aff2d346136ae7f9caf8f094f502ed
Reviewed-on: https://go-review.googlesource.com/8216
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-05-06 11:37:13 +00:00
Aram Hăvărneanu
e481aac0e1 cmd/6l: use .plt instead of .got on Solaris
Solaris requires all external procedures to be accessed through the
PLT. If 6l won't do it, /bin/ld will, so all the code written with .GOT
in mind won't work with the external linker.

This CL makes external linking work, opening the path to cgo support
on Solaris.

This CL breaks the Solaris build, this is fixed in subsequent CLs in
this series.

Change-Id: If370a79f49fdbe66d28b89fa463b4f3e91685f69
Reviewed-on: https://go-review.googlesource.com/8214
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-05-06 11:36:39 +00:00
Michael Hudson-Doyle
96dad7ff3e cmd/internal/ld: recompute resoff after changing elfreserve
My last update to https://golang.org/cl/9710 missed this.

Change-Id: Ie042032ca307e1065fcf6c402a166f9ff74027e7
Reviewed-on: https://go-review.googlesource.com/9771
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-05-06 00:56:15 +00:00
Michael Hudson-Doyle
9f5d0bff41 cmd/6l, cmd/internal/ld: handle R_PCREL to function in other shared library
An ELF linker handles a PC-relative reference to an STT_FUNC defined in a
shared library by building a PLT entry and referring to that, so do the
same in 6l.

Fixes #10690

Change-Id: I061a96fd4400d957e301d0ac86760ce256910e1d
Reviewed-on: https://go-review.googlesource.com/9711
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-05-06 00:17:23 +00:00
Michael Hudson-Doyle
de6d5b0801 cmd/internal/ld: reserve space for package list note when -buildmode=shared
This makes the intermediate object file a little bigger but it doesn't waste
any space in the final shared library.

Fixes #10691

Change-Id: Ic51a571d60291f1ac2dad1b50dba4679643168ae
Reviewed-on: https://go-review.googlesource.com/9710
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-05-05 22:32:23 +00:00
Michael Hudson-Doyle
a1858e9cf0 cmd/go: rebuild stale shared objects before linking against them.
This changes the action graph when shared libraries are involved to always have
an action for the shared library (which does nothing when the shared library
is up to date).

Change-Id: Ibbc70fd01cbb3f4e8c0ef96e62a151002d446144
Reviewed-on: https://go-review.googlesource.com/8934
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-05-05 22:08:25 +00:00
Dave Cheney
21cb062540 cmd/go: fix linux-amd64-clang builder
Fixes #10660

Fix the clang only builder by passing -extld down to the linker when needed.
The build passed on most hosts because gcc is almost always present. The bug
was verified by symlinking bin/false in place of gcc in my $PATH and running
the build.

Also, resolve a TODO and move the support logic into its own function.

Tested manually

    env CC=clang-3.5 ./all.bash	# linux/amd64
    env CC=gcc-4.8 ./all.bash	# linux/amd64
    ./all.bash			# linux/amd64
    ./all.bash			# darwin/amd64

Change-Id: I4e27a1119356e295500a0d19ad7a4ec14207bf10
Reviewed-on: https://go-review.googlesource.com/9526
Run-TryBot: Dave Cheney <dave@cheney.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-05-05 21:29:57 +00:00
Minux Ma
8fb55f9d41 Revert "cmd/internal: disable OSQRT on GOARM=5"
I just submitted the real fix for #10641.

This reverts commit 3120adc212.

Change-Id: I55051515f697e27ca887ed21c2ac985f0b9b062b
Reviewed-on: https://go-review.googlesource.com/9720
Reviewed-by: Joel Sing <jsing@google.com>
2015-05-05 19:54:54 +00:00
Russ Cox
ceefebd795 runtime: rename ptrsize to ptrdata
I forgot there is already a ptrSize constant.
Rename field to avoid some confusion.

Change-Id: I098fdcc8afc947d6c02c41c6e6de24624cc1c8ff
Reviewed-on: https://go-review.googlesource.com/9700
Reviewed-by: Austin Clements <austin@google.com>
2015-05-05 19:27:47 +00:00
Joel Sing
3120adc212 cmd/internal: disable OSQRT on GOARM=5
OSQRT currently produces incorrect results when used on arm with softfloat.
Disable it on GOARM=5 until the actual problem is found and fixed.

Updates #10641

Change-Id: Ia6f6879fbbb05cb24399c2feee93c1be21113e73
Reviewed-on: https://go-review.googlesource.com/9524
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-05-05 05:57:09 +00:00
Keith Randall
135389d0ff cmd/internal/gc: Use shifts for powers-of-two indexing
Fixes #10638

Change-Id: I7bbaad7e5a599aa94d1d158e903596231c7e9897
Reviewed-on: https://go-review.googlesource.com/9535
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-05-05 02:17:55 +00:00
Dave Cheney
71274e4857 cmd/internal/ld: delete Biobuf
Update #10652

This proposal deletes cmd/internal/ld.Biobuf and replaces all uses with
cmd/internal/obj.Biobuf. As cmd/internal/ld already imported cmd/internal/obj
there are no additional dependencies created.

Notes:

- ld.Boffset included more checks, so it was merged into obj.Boffset
- obj.Bflush was removed in 8d16253c90, so replaced all calls to
  ld.Bflush, with obj.Biobuf.Flush.
- Almost all of this change was prepared with sed.

Change-Id: I814854d52f5729a5a40c523c8188e465246b88da
Reviewed-on: https://go-review.googlesource.com/9660
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Dave Cheney <dave@cheney.net>
2015-05-04 23:55:55 +00:00
Austin Clements
98a9d36837 runtime: add pointer size to type structure
This adds a field to the runtime type structure that records the size
of the prefix of objects of that type containing pointers. Any data
after this offset is scalar data.

This is necessary for shrinking the type bitmaps to 1 bit and will
help the garbage collector efficiently estimate the amount of heap
that needs to be scanned.

Change-Id: I1318d79e6360dca0ac980245016c562e61f52ff5
Reviewed-on: https://go-review.googlesource.com/9691
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-05-04 20:17:48 +00:00
Austin Clements
91938fd1ca cmd/internal/ld: put all type decoding in decodesym.go
Move the one instance of type structure decoding in the linker that
doesn't live decodesym.go in to decodesym.go.

Change-Id: Ic6a23500deb72f0e9c8227ab611511e9781fac70
Reviewed-on: https://go-review.googlesource.com/9690
Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-04 20:17:39 +00:00
David Symonds
10f6d30315 cmd/go: Update alldocs.go header to point to the correct shell script.
The script was renamed in b3000b6.

Change-Id: I45ecafff7400e4bff14f31906278609abf2bcb9f
Reviewed-on: https://go-review.googlesource.com/9667
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-05-04 00:39:45 +00:00
Rob Pike
d5ff441d9a cmd/internal/gc,ld: use new flag syntax
Followup to CL 9505

Change-Id: I1817b672723bd3d853283f388bc7cbaae2765acc
Reviewed-on: https://go-review.googlesource.com/9652
Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-03 00:44:41 +00:00
Shenghou Ma
931328b8b8 cmd/internal/gc: fix build on big endian systems
The siz argument to both runtime.newproc and runtime.deferproc is
int32, not uintptr. This problem won't manifest on little-endian
systems because that stack slot is uintptr sized anyway. However,
on big-endian systems, it will make a difference.

Change-Id: I2351d1ec81839abe25375cff95e327b80764c2b5
Reviewed-on: https://go-review.googlesource.com/9647
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-05-02 19:32:15 +00:00
Dave Cheney
8d16253c90 cmd/internal/obj: remove Biobuf unget
This change applies CL 9365 to the copy of Biobuf in cmd/internal/obj.

In the process I discovered that some of the methods that should have been
checking the unget buffer before reading were not and it was probably just
dumb luck that we handn't hit these issues before; Bungetc is only used in
one place in cmd/internal/gc and only an unlikely code path.

Change-Id: Ifa0c5c08442e9fe951a5078c6e9ec77a8a4dc2ff
Reviewed-on: https://go-review.googlesource.com/9529
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
2015-05-01 23:08:18 +00:00
Didier Spezia
8a072ada84 cmd/internal/gc,ld: use new flag argument syntax
The usage messages for the flags in gc and ld are using the old
flag argument syntax:
   "arg: description using arg"

Update them to the Go 1.5 flag package's syntax:
   "description using arg"

Fixes #10505

Change-Id: Ifa54ff91e1fd644cfc9a3b41e10176eac3654137
Reviewed-on: https://go-review.googlesource.com/9505
Reviewed-by: Rob Pike <r@golang.org>
2015-05-01 20:59:05 +00:00
Russ Cox
4d0f3a1c95 cmd/internal/gc, runtime: use 1-bit bitmap for stack frames, data, bss
The bitmaps were 2 bits per pointer because we needed to distinguish
scalar, pointer, multiword, and we used the leftover value to distinguish
uninitialized from scalar, even though the garbage collector (GC) didn't care.

Now that there are no multiword structures from the GC's point of view,
cut the bitmaps down to 1 bit per pointer, recording just live pointer vs not.

The GC assumes the same layout for stack frames and for the maps
describing the global data and bss sections, so change them all in one CL.

The code still refers to 4-bit heap bitmaps and 2-bit "type bitmaps", since
the 2-bit representation lives (at least for now) in some of the reflect data.

Because these stack frame bitmaps are stored directly in the rodata in
the binary, this CL reduces the size of the 6g binary by about 1.1%.

Performance change is basically a wash, but using less memory,
and smaller binaries, and enables other bitmap reductions.

name                                      old mean                new mean        delta
BenchmarkBinaryTree17                13.2s × (0.97,1.03)     13.0s × (0.99,1.01)  -0.93% (p=0.005)
BenchmarkBinaryTree17-2              9.69s × (0.96,1.05)     9.51s × (0.96,1.03)  -1.86% (p=0.001)
BenchmarkBinaryTree17-4              10.1s × (0.97,1.05)     10.0s × (0.96,1.05)  ~ (p=0.141)
BenchmarkFannkuch11                  4.35s × (0.99,1.01)     4.43s × (0.98,1.04)  +1.75% (p=0.001)
BenchmarkFannkuch11-2                4.31s × (0.99,1.03)     4.32s × (1.00,1.00)  ~ (p=0.095)
BenchmarkFannkuch11-4                4.32s × (0.99,1.02)     4.38s × (0.98,1.04)  +1.38% (p=0.008)
BenchmarkFmtFprintfEmpty            83.5ns × (0.97,1.10)    87.3ns × (0.92,1.11)  +4.55% (p=0.014)
BenchmarkFmtFprintfEmpty-2          81.8ns × (0.98,1.04)    82.5ns × (0.97,1.08)  ~ (p=0.364)
BenchmarkFmtFprintfEmpty-4          80.9ns × (0.99,1.01)    82.6ns × (0.97,1.08)  +2.12% (p=0.010)
BenchmarkFmtFprintfString            320ns × (0.95,1.04)     322ns × (0.97,1.05)  ~ (p=0.368)
BenchmarkFmtFprintfString-2          303ns × (0.97,1.04)     304ns × (0.97,1.04)  ~ (p=0.484)
BenchmarkFmtFprintfString-4          305ns × (0.97,1.05)     306ns × (0.98,1.05)  ~ (p=0.543)
BenchmarkFmtFprintfInt               311ns × (0.98,1.03)     319ns × (0.97,1.03)  +2.63% (p=0.000)
BenchmarkFmtFprintfInt-2             297ns × (0.98,1.04)     301ns × (0.97,1.04)  +1.19% (p=0.023)
BenchmarkFmtFprintfInt-4             302ns × (0.98,1.02)     304ns × (0.97,1.03)  ~ (p=0.126)
BenchmarkFmtFprintfIntInt            554ns × (0.96,1.05)     554ns × (0.97,1.03)  ~ (p=0.975)
BenchmarkFmtFprintfIntInt-2          520ns × (0.98,1.03)     517ns × (0.98,1.02)  ~ (p=0.153)
BenchmarkFmtFprintfIntInt-4          524ns × (0.98,1.02)     525ns × (0.98,1.03)  ~ (p=0.597)
BenchmarkFmtFprintfPrefixedInt       433ns × (0.97,1.06)     434ns × (0.97,1.06)  ~ (p=0.804)
BenchmarkFmtFprintfPrefixedInt-2     413ns × (0.98,1.04)     413ns × (0.98,1.03)  ~ (p=0.881)
BenchmarkFmtFprintfPrefixedInt-4     420ns × (0.97,1.03)     421ns × (0.97,1.03)  ~ (p=0.561)
BenchmarkFmtFprintfFloat             620ns × (0.99,1.03)     636ns × (0.97,1.03)  +2.57% (p=0.000)
BenchmarkFmtFprintfFloat-2           601ns × (0.98,1.02)     617ns × (0.98,1.03)  +2.58% (p=0.000)
BenchmarkFmtFprintfFloat-4           613ns × (0.98,1.03)     626ns × (0.98,1.02)  +2.15% (p=0.000)
BenchmarkFmtManyArgs                2.19µs × (0.96,1.04)    2.23µs × (0.97,1.02)  +1.65% (p=0.000)
BenchmarkFmtManyArgs-2              2.08µs × (0.98,1.03)    2.10µs × (0.99,1.02)  +0.79% (p=0.019)
BenchmarkFmtManyArgs-4              2.10µs × (0.98,1.02)    2.13µs × (0.98,1.02)  +1.72% (p=0.000)
BenchmarkGobDecode                  21.3ms × (0.97,1.05)    21.1ms × (0.97,1.04)  -1.36% (p=0.025)
BenchmarkGobDecode-2                20.0ms × (0.97,1.03)    19.2ms × (0.97,1.03)  -4.00% (p=0.000)
BenchmarkGobDecode-4                19.5ms × (0.99,1.02)    19.0ms × (0.99,1.01)  -2.39% (p=0.000)
BenchmarkGobEncode                  18.3ms × (0.95,1.07)    18.1ms × (0.96,1.08)  ~ (p=0.305)
BenchmarkGobEncode-2                16.8ms × (0.97,1.02)    16.4ms × (0.98,1.02)  -2.79% (p=0.000)
BenchmarkGobEncode-4                15.4ms × (0.98,1.02)    15.4ms × (0.98,1.02)  ~ (p=0.465)
BenchmarkGzip                        650ms × (0.98,1.03)     655ms × (0.97,1.04)  ~ (p=0.075)
BenchmarkGzip-2                      652ms × (0.98,1.03)     655ms × (0.98,1.02)  ~ (p=0.337)
BenchmarkGzip-4                      656ms × (0.98,1.04)     653ms × (0.98,1.03)  ~ (p=0.291)
BenchmarkGunzip                      143ms × (1.00,1.01)     143ms × (1.00,1.01)  ~ (p=0.507)
BenchmarkGunzip-2                    143ms × (1.00,1.01)     143ms × (1.00,1.01)  ~ (p=0.313)
BenchmarkGunzip-4                    143ms × (1.00,1.01)     143ms × (1.00,1.01)  ~ (p=0.312)
BenchmarkHTTPClientServer            110µs × (0.98,1.03)     109µs × (0.99,1.02)  -1.40% (p=0.000)
BenchmarkHTTPClientServer-2          154µs × (0.90,1.08)     149µs × (0.90,1.08)  -3.43% (p=0.007)
BenchmarkHTTPClientServer-4          138µs × (0.97,1.04)     138µs × (0.96,1.04)  ~ (p=0.670)
BenchmarkJSONEncode                 40.2ms × (0.98,1.02)    40.2ms × (0.98,1.05)  ~ (p=0.828)
BenchmarkJSONEncode-2               35.1ms × (0.99,1.02)    35.2ms × (0.98,1.03)  ~ (p=0.392)
BenchmarkJSONEncode-4               35.3ms × (0.98,1.03)    35.3ms × (0.98,1.02)  ~ (p=0.813)
BenchmarkJSONDecode                  119ms × (0.97,1.02)     117ms × (0.98,1.02)  -1.80% (p=0.000)
BenchmarkJSONDecode-2                115ms × (0.99,1.02)     114ms × (0.98,1.02)  -1.18% (p=0.000)
BenchmarkJSONDecode-4                116ms × (0.98,1.02)     114ms × (0.98,1.02)  -1.43% (p=0.000)
BenchmarkMandelbrot200              6.03ms × (1.00,1.01)    6.03ms × (1.00,1.01)  ~ (p=0.985)
BenchmarkMandelbrot200-2            6.03ms × (1.00,1.01)    6.02ms × (1.00,1.01)  ~ (p=0.320)
BenchmarkMandelbrot200-4            6.03ms × (1.00,1.01)    6.03ms × (1.00,1.01)  ~ (p=0.799)
BenchmarkGoParse                    8.63ms × (0.89,1.10)    8.58ms × (0.93,1.09)  ~ (p=0.667)
BenchmarkGoParse-2                  8.20ms × (0.97,1.04)    8.37ms × (0.97,1.04)  +1.96% (p=0.001)
BenchmarkGoParse-4                  8.00ms × (0.98,1.02)    8.14ms × (0.99,1.02)  +1.75% (p=0.000)
BenchmarkRegexpMatchEasy0_32         162ns × (1.00,1.01)     164ns × (0.98,1.04)  +1.35% (p=0.011)
BenchmarkRegexpMatchEasy0_32-2       161ns × (1.00,1.01)     161ns × (1.00,1.00)  ~ (p=0.185)
BenchmarkRegexpMatchEasy0_32-4       161ns × (1.00,1.00)     161ns × (1.00,1.00)  -0.19% (p=0.001)
BenchmarkRegexpMatchEasy0_1K         540ns × (0.99,1.02)     566ns × (0.98,1.04)  +4.98% (p=0.000)
BenchmarkRegexpMatchEasy0_1K-2       540ns × (0.99,1.01)     557ns × (0.99,1.01)  +3.21% (p=0.000)
BenchmarkRegexpMatchEasy0_1K-4       541ns × (0.99,1.01)     559ns × (0.99,1.01)  +3.26% (p=0.000)
BenchmarkRegexpMatchEasy1_32         139ns × (0.98,1.04)     139ns × (0.99,1.03)  ~ (p=0.979)
BenchmarkRegexpMatchEasy1_32-2       139ns × (0.99,1.04)     139ns × (0.99,1.02)  ~ (p=0.777)
BenchmarkRegexpMatchEasy1_32-4       139ns × (0.98,1.04)     139ns × (0.99,1.04)  ~ (p=0.771)
BenchmarkRegexpMatchEasy1_1K         890ns × (0.99,1.03)     885ns × (1.00,1.01)  -0.50% (p=0.004)
BenchmarkRegexpMatchEasy1_1K-2       888ns × (0.99,1.01)     885ns × (0.99,1.01)  -0.37% (p=0.004)
BenchmarkRegexpMatchEasy1_1K-4       890ns × (0.99,1.02)     884ns × (1.00,1.00)  -0.70% (p=0.000)
BenchmarkRegexpMatchMedium_32        252ns × (0.99,1.01)     251ns × (0.99,1.01)  ~ (p=0.081)
BenchmarkRegexpMatchMedium_32-2      254ns × (0.99,1.04)     252ns × (0.99,1.01)  -0.78% (p=0.027)
BenchmarkRegexpMatchMedium_32-4      253ns × (0.99,1.04)     252ns × (0.99,1.01)  -0.70% (p=0.022)
BenchmarkRegexpMatchMedium_1K       72.9µs × (0.99,1.01)    72.7µs × (1.00,1.00)  ~ (p=0.064)
BenchmarkRegexpMatchMedium_1K-2     74.1µs × (0.98,1.05)    72.9µs × (1.00,1.01)  -1.61% (p=0.001)
BenchmarkRegexpMatchMedium_1K-4     73.6µs × (0.99,1.05)    72.8µs × (1.00,1.00)  -1.13% (p=0.007)
BenchmarkRegexpMatchHard_32         3.88µs × (0.99,1.03)    3.92µs × (0.98,1.05)  ~ (p=0.143)
BenchmarkRegexpMatchHard_32-2       3.89µs × (0.99,1.03)    3.93µs × (0.98,1.09)  ~ (p=0.278)
BenchmarkRegexpMatchHard_32-4       3.90µs × (0.99,1.05)    3.93µs × (0.98,1.05)  ~ (p=0.252)
BenchmarkRegexpMatchHard_1K          118µs × (0.99,1.01)     117µs × (0.99,1.02)  -0.54% (p=0.003)
BenchmarkRegexpMatchHard_1K-2        118µs × (0.99,1.01)     118µs × (0.99,1.03)  ~ (p=0.581)
BenchmarkRegexpMatchHard_1K-4        118µs × (0.99,1.02)     117µs × (0.99,1.01)  -0.54% (p=0.002)
BenchmarkRevcomp                     991ms × (0.95,1.10)     989ms × (0.94,1.08)  ~ (p=0.879)
BenchmarkRevcomp-2                   978ms × (0.95,1.11)     962ms × (0.96,1.08)  ~ (p=0.257)
BenchmarkRevcomp-4                   979ms × (0.96,1.07)     974ms × (0.96,1.11)  ~ (p=0.678)
BenchmarkTemplate                    141ms × (0.99,1.02)     145ms × (0.99,1.02)  +2.75% (p=0.000)
BenchmarkTemplate-2                  135ms × (0.98,1.02)     138ms × (0.99,1.02)  +2.34% (p=0.000)
BenchmarkTemplate-4                  136ms × (0.98,1.02)     140ms × (0.99,1.02)  +2.71% (p=0.000)
BenchmarkTimeParse                   640ns × (0.99,1.01)     622ns × (0.99,1.01)  -2.88% (p=0.000)
BenchmarkTimeParse-2                 640ns × (0.99,1.01)     622ns × (1.00,1.00)  -2.81% (p=0.000)
BenchmarkTimeParse-4                 640ns × (1.00,1.01)     622ns × (0.99,1.01)  -2.82% (p=0.000)
BenchmarkTimeFormat                  730ns × (0.98,1.02)     731ns × (0.98,1.03)  ~ (p=0.767)
BenchmarkTimeFormat-2                709ns × (0.99,1.02)     707ns × (0.99,1.02)  ~ (p=0.347)
BenchmarkTimeFormat-4                717ns × (0.98,1.01)     718ns × (0.98,1.02)  ~ (p=0.793)

Change-Id: Ie779c47e912bf80eb918bafa13638bd8dfd6c2d9
Reviewed-on: https://go-review.googlesource.com/9406
Reviewed-by: Rick Hudson <rlh@golang.org>
2015-05-01 18:44:36 +00:00
Dave Cheney
e9ab343f0e cmd/internal/obj: clean up Biobuf
This is a follow up to rev 443a32e707 which reduces some of the
duplication between methods and functions that operate on obj.Biobuf.

obj.Biobuf has Flush and Write methods as well as helpers which duplicate
those methods, consolidate on the former and remove the latter.

Also, address a final comment from CL 9525.

Change-Id: I67deaf3a163bb489a9bb21bb39524785d7a2f6c5
Reviewed-on: https://go-review.googlesource.com/9527
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-05-01 18:37:04 +00:00
David Chase
bc44b818a6 cmd/internal/gc: Toughen escape analysis against some bugs.
Ensures that parameter flow bits are not set for tags EscScope, EscHeap, EscNever;
crash the compiler earl to expose faulty logic, rather than flake out silently downstream.

Change-Id: I1428129980ae047d02975f033d56cbbd04f49579
Reviewed-on: https://go-review.googlesource.com/9601
Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-01 16:17:16 +00:00
Keith Randall
a55b131393 cmd/dist, runtime: Make stack guard larger for non-optimized builds
Kind of a hack, but makes the non-optimized builds pass.

Fixes #10079

Change-Id: I26f41c546867f8f3f16d953dc043e784768f2aff
Reviewed-on: https://go-review.googlesource.com/9552
Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-01 15:41:55 +00:00
David Chase
7fbb1b36c3 cmd/internal/gc: improve flow of input params to output params
This includes the following information in the per-function summary:

outK = paramJ   encoded in outK bits for paramJ
outK = *paramJ  encoded in outK bits for paramJ
heap = paramJ   EscHeap
heap = *paramJ  EscContentEscapes

Note that (currently) if the address of a parameter is taken and
returned, necessarily a heap allocation occurred to contain that
reference, and the heap can never refer to stack, therefore the
parameter and everything downstream from it escapes to the heap.

The per-function summary information now has a tuneable number of bits
(2 is probably noticeably better than 1, 3 is likely overkill, but it
is now easy to check and the -m debugging output includes information
that allows you to figure out if more would be better.)

A new test was  added to check pointer flow through struct-typed and
*struct-typed parameters and returns; some of these are sensitive to
the number of summary bits, and ought to yield better results with a
more competent escape analysis algorithm.  Another new test checks
(some) correctness with array parameters, results, and operations.

The old analysis inferred a piece of plan9 runtime was non-escaping by
counteracting overconservative analysis with buggy analysis; with the
bug fixed, the result was too conservative (and it's not easy to fix
in this framework) so the source code was tweaked to get the desired
result.  A test was added against the discovered bug.

The escape analysis was further improved splitting the "level" into
3 parts, one tracking the conventional "level" and the other two
computing the highest-level-suffix-from-copy, which is used to
generally model the cancelling effect of indirection applied to
address-of.

With the improved escape analysis enabled, it was necessary to
modify one of the runtime tests because it now attempts to allocate
too much on the (small, fixed-size) G0 (system) stack and this
failed the test.

Compiling src/std after touching src/runtime/*.go with -m logging
turned on shows 420 fewer heap allocation sites (10538 vs 10968).

Profiling allocations in src/html/template with
for i in {1..5} ;
  do go tool 6g -memprofile=mastx.${i}.prof  -memprofilerate=1 *.go;
  go tool pprof -alloc_objects -text  mastx.${i}.prof ;
done

showed a 15% reduction in allocations performed by the compiler.

Update #3753
Update #4720
Fixes #10466

Change-Id: I0fd97d5f5ac527b45f49e2218d158a6e89951432
Reviewed-on: https://go-review.googlesource.com/8202
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-01 13:47:20 +00:00
David Crawshaw
4044adedf7 runtime/cgo, cmd/dist: turn off exc_bad_access handler by default
App Store policy requires programs do not reference the exc_server
symbol. (Some public forum threads show that Unity ran into this
several years ago and it is a hard policy rule.) While some research
suggests that I could write my own version of exc_server, the
expedient course is to disable the exception handler by default.

Go programs only need it when running under lldb, which is primarily
used by tests. So enable the exception handler in cmd/dist when we
are running the tests.

Fixes #10646

Change-Id: I853905254894b5367edb8abd381d45585a78ee8b
Reviewed-on: https://go-review.googlesource.com/9549
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-05-01 13:19:39 +00:00
Dave Cheney
ffd334493c cmd/cover: fix build
Fix the various builds which don't have a real filesystem or don't support forking.

Change-Id: I3075c662fe6191ecbe70ba359b73d9a88bb06f35
Reviewed-on: https://go-review.googlesource.com/9528
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-05-01 03:32:37 +00:00
Rob Pike
bc1410a4f9 cmd/cover: try once again to fix the build
Forgot to update the references to the old cover package. No excuse.

Change-Id: If17b7521f0bf70bc0c8da9c5adf246d90f644637
Reviewed-on: https://go-review.googlesource.com/9564
Reviewed-by: Rob Pike <r@golang.org>
2015-05-01 02:15:46 +00:00
Rob Pike
e0820ac8d1 cmd/cover: fix build
TBR=rsc

Change-Id: I6ec69013027213c5e7adedd2edb89dea6af876d9
Reviewed-on: https://go-review.googlesource.com/9563
Reviewed-by: Rob Pike <r@golang.org>
2015-05-01 02:12:17 +00:00
Dave Cheney
443a32e707 cmd/8g: don't call gc.Fatal during initalisation
Fixes #10592

Calling gc.Fatal before gc.Main has been called ends up flushing gc.bstdout before
it is properly set up. Ideally obj.Bflush would handle this case, but that type
and its callers are rather convoluted, so take the simpler route and avoid calling
gc.Fatal altogether.

Change-Id: I338b469e86edba558b6bedff35bb904bfc3d6990
Reviewed-on: https://go-review.googlesource.com/9525
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-05-01 01:33:55 +00:00
Rob Pike
5eddc5bae3 cmd/cover: copy to standard repository from golang.org/x/tools/cmd/cover
This required dealing with the ill-advised split of the profile code
into a separate package. I just copied it over unchanged. The package
does not deserve to be in the standard repository. We can cope
with the duplication.

Also update the go command to know about the new location.

Fixes #10528.

Change-Id: I05170ef3663326d57b9c18888d01163acd9256b6
Reviewed-on: https://go-review.googlesource.com/9560
Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-01 00:40:09 +00:00
Ian Lance Taylor
6c0f9c9e30 cmd/go: support -buildmode=c-shared for gccgo
Change-Id: I4cdfd5a59e0468e9e5400aa06334b21cc80913cd
Reviewed-on: https://go-review.googlesource.com/9550
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-30 21:03:07 +00:00
Michael Hudson-Doyle
7556948ebf cmd/internal/ld: put the list of packages built into a shared library into an ELF note
Change-Id: I611f7dec2109dc7e2f090ced0a1dca3d4b577134
Reviewed-on: https://go-review.googlesource.com/9520
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-30 18:04:43 +00:00
Dave Cheney
ccaaf1f134 misc/cgo/testcshared, misc/cgo/testshared: fix clang warnings and errors
Fix several warnings generated on the linux-amd64-clang builder
and make it clear to clang that -znow is a linker only flag.

Tested with

    env CC=clang-3.5 ./all.bash
    env CC=gcc-4.8 ./all.bash

Change-Id: I5ca7366ba8bf6221a36d25a2157dda4b4f3e16fa
Reviewed-on: https://go-review.googlesource.com/9523
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-30 17:08:15 +00:00
Ian Lance Taylor
42bb59a372 cmd/go, cmd/cgo: support -buildmode=c-archive for gccgo
This extends the cgo changes in http://golang.org/cl/8094 to gccgo.
It also adds support for setting runtime_iscgo correctly for gccgo;
the gc runtime bases the variable on the runtime/cgo package, but
gccgo has no equivalent to that package.

The go tool supports -buildmode=c-archive for gccgo by linking all the
Go objects together using -r.  For convenience this object is then put
into an archive file.

The go tool now passes -fsplit-stack when building C code for gccgo on
386 and amd64.  This is required for using -r and will also cut down
on unnecessary stack splits.

The go tool no longer applies standard package cgo LDFLAGS when using
gccgo.  This is mainly to avoid getting confused by the LDFLAGS in the
runtime/cgo package that gccgo does not use.

Change-Id: I1d0865b2a362818a033ca9e9e901d0ce250784e7
Reviewed-on: https://go-review.googlesource.com/9511
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-30 16:54:14 +00:00
Alex Brainman
89454b1c39 mime, time, internal/syscall/windows/registry: use new registry package to simplify code
This CL copies golang.org/x/sys/windows/registry into
internal/syscall/windows/registry (minus KeyInfo.ModTime to prevent
dependency cycles). New registry package is used in mime and time
packages instead of calling Windows API directly.

Change-Id: I965a5a41d4739b3ba38e539a7b8d96d3223e3d56
Reviewed-on: https://go-review.googlesource.com/9271
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-30 04:33:42 +00:00
Ian Lance Taylor
edcc8f9ef1 cmd/dist: rename buildmode method to supportedBuildmode
Change-Id: Ie36fd46ad3c0799200fdf4240483a207335570d8
Reviewed-on: https://go-review.googlesource.com/9531
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-30 01:19:22 +00:00
Michael Hudson-Doyle
0774f6dbfd misc/cgo/testshared: add basic test for -buildmode=shared/-linkshared
Just a first basic test, I'll extend this to test more but want to get an
opinion on basic approach first.

Change-Id: Idab9ebd7d9960b000b81a01a1e53258bf4bce755
Reviewed-on: https://go-review.googlesource.com/9386
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-29 23:47:47 +00:00
Josh Bleecher Snyder
e64764c8d0 cmd/internal/gc: cache commonly used Ptrto types
Reduces allocations in the compiler by ~1.5%.

No functional changes. Passes toolstash -cmp.

Change-Id: I2416f7fb0aaf9b7d6783c79e840039ad8fa7b5a3
Reviewed-on: https://go-review.googlesource.com/9419
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-29 23:18:54 +00:00
Rob Pike
1ab60c2930 cmd/doc: show the true import path rather than "."
Change-Id: I7b15c027c15eefc2a004eb61491e828a7fbefc54
Reviewed-on: https://go-review.googlesource.com/9513
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-29 23:01:37 +00:00
Rob Pike
06946aad19 cmd/go: better UI for go doc
Print it out much like godoc so there isn't a single block of text.
Print the symbol before its comment and indent the comment so
individual symbols separate visually.

Buffer the output.

Add a -c option to force case-sensitive matching.

Allow two arguments, like godoc, to help disambiguate cases
where path and symbol may be confused.

Improve the documentation printed by go help doc.

Change-Id: If687aad04bbacdf7dbe4bf7636de9fe96f756fd0
Reviewed-on: https://go-review.googlesource.com/9471
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-29 19:12:53 +00:00
David Crawshaw
ea426dcae1 cmd/internal/ld: use a simpler cout writer
Removes the unused *bufio.Reader from the object controlling the
linker's primary output.

Change-Id: If91d9f60752f3dc4b280f35d6eb441f3c47574b2
Reviewed-on: https://go-review.googlesource.com/9362
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-29 17:13:18 +00:00
Joel Sing
282db6273e cmd/objdump: disable external linking test on openbsd/arm
Disable disassembly with external linking test on openbsd/arm, since this
platform does not currently support cgo/external linking.

Change-Id: I6eab6fcaac21407ce05075a4a1407fbfe0e6142b
Reviewed-on: https://go-review.googlesource.com/9481
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-29 15:47:51 +00:00
Shenghou Ma
73e791a38a cmd/internal/obj: do not generate data for $f32. and $f64. symbols at assemble time
When reading the object files for linking, liblink takes care of
generate the data for them.

This is a port of https://golang.org/cl/3101 to Go.

Change-Id: Ie3e2d6515bd7d253a8c1e25c70ef8fed064436d8
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8383
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-29 04:48:55 +00:00
Michael Hudson-Doyle
4b23b50fb4 cmd/internal/obj: Delete Link.Symmorestack
This started out as trying to remove Bool2int calls, which it does a bit, but
mostly it ended up being removing the Link.Symmorestack array which seemed a
pointless bit of caching.

Change-Id: I91a51eb08cb4b08f3f9f093b575306499267b67a
Reviewed-on: https://go-review.googlesource.com/9239
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-29 03:32:28 +00:00
Shenghou Ma
da11a9dda3 cmd/internal/ld, runtime: unify stack reservation in PE header and runtime
With 128KB stack reservation, on 32-bit Windows, the maximum number
threads is ~9000.

The original 65535-byte stack commit is causing problem on Windows
XP where it makes the stack reservation to be 1MB despite the fact
that the runtime specified 128KB.

While we're at here, also fix the extra spacings in the unable to
create more OS thread error message: println will insert a space
between each argument.

See #9457 for more information.

Change-Id: I3a82f7d9717d3d55211b6eb1c34b00b0eaad83ed
Reviewed-on: https://go-review.googlesource.com/2237
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Minux Ma <minux@golang.org>
2015-04-29 03:27:10 +00:00
Shenghou Ma
2b7505e28a cmd/internal/gc: fix write barrier fast path on RISC architectures
They have to read the boolean into a register first and then do
the comparison.

Fixes #10598.

Change-Id: I2b808837a8c6393e1e0778296b6592aaab2b04bf
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/9453
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-04-29 00:29:44 +00:00
Shenghou Ma
e7dd28891e cmd/internal/gc, cmd/[56789]g: rename stackcopy to blockcopy
To avoid confusion with the runtime concept of copying stack.

Change-Id: I33442377b71012c2482c2d0ddd561492c71e70d0
Reviewed-on: https://go-review.googlesource.com/8639
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-29 00:28:01 +00:00
Rob Pike
d3bd6b6ae7 cmd/doc: print documentation for all matches in a package, not just the first
Change-Id: Id0d4ac7169f741dfeec7b1e67bdc21e49ae37b9e
Reviewed-on: https://go-review.googlesource.com/9430
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-28 19:42:57 +00:00
Rob Pike
a88994c137 cmd/asm: add comments back for aliases on jumps for x86
These were lost in the transition from 8a/6a to asm.
Also, in the process, discover more aliases. I'm betting the missing
ones were a casualty of the recent merge of 386 and amd64.

Update #10385.

Change-Id: I1681034b25af3ffc103f75e5fc57baca5feb3fcd
Reviewed-on: https://go-review.googlesource.com/9431
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-28 19:41:19 +00:00
David Crawshaw
05d53165ce cmd/internal/ld: remove Biobuf unget
The underlying *bufio.Reader does everything that's needed here.

Change-Id: If0712a5b4d3142ae4bceaa2efe287eaf2b91e54e
Reviewed-on: https://go-review.googlesource.com/9365
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-28 11:01:42 +00:00
Josh Bleecher Snyder
45ccea71a1 Revert "Revert "cmd/dist: consolidate runtime CPU tests""
This reverts commit 81c2233b4a.

Change-Id: Ie7024f04dba6352ae79ba68d4da5c0c25844cd8c
Reviewed-on: https://go-review.googlesource.com/9397
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-28 02:44:27 +00:00
Russ Cox
2a73559023 cmd/internal/gc: emit typedmemmove write barrier from sgen
Emitting it here instead of rewriting the tree earlier sets us up
to generate an inline check, like we do for single pointers.
But even without the inline check, generating at this level lets
us generate significantly more efficient code, probably due to
having fewer temporaries and less complex high-level code
for the compiler to churn through.

Revcomp is worse, almost certainly due to register pressure.

name                                       old                     new          delta
BenchmarkBinaryTree17              18.0s × (0.99,1.01)     18.0s × (0.99,1.01)  ~
BenchmarkFannkuch11                4.43s × (1.00,1.00)     4.36s × (1.00,1.00)  -1.44%
BenchmarkFmtFprintfEmpty           114ns × (0.95,1.05)      86ns × (0.97,1.06)  -24.12%
BenchmarkFmtFprintfString          468ns × (0.99,1.01)     420ns × (0.99,1.02)  -10.16%
BenchmarkFmtFprintfInt             433ns × (1.00,1.01)     386ns × (0.99,1.02)  -10.74%
BenchmarkFmtFprintfIntInt          748ns × (0.99,1.01)     647ns × (0.99,1.01)  -13.56%
BenchmarkFmtFprintfPrefixedInt     547ns × (0.99,1.01)     499ns × (0.99,1.02)  -8.78%
BenchmarkFmtFprintfFloat           756ns × (1.00,1.01)     689ns × (1.00,1.00)  -8.86%
BenchmarkFmtManyArgs              2.79µs × (1.00,1.01)    2.53µs × (1.00,1.00)  -9.30%
BenchmarkGobDecode                39.6ms × (0.99,1.00)    39.2ms × (0.98,1.01)  -1.07%
BenchmarkGobEncode                37.6ms × (1.00,1.01)    37.5ms × (0.99,1.01)  ~
BenchmarkGzip                      663ms × (0.99,1.02)     660ms × (0.98,1.01)  ~
BenchmarkGunzip                    142ms × (1.00,1.00)     143ms × (1.00,1.00)  ~
BenchmarkHTTPClientServer          132µs × (0.99,1.01)     133µs × (0.99,1.02)  ~
BenchmarkJSONEncode               56.2ms × (0.99,1.01)    54.0ms × (0.98,1.01)  -3.97%
BenchmarkJSONDecode                138ms × (1.00,1.00)     134ms × (0.99,1.02)  -2.70%
BenchmarkMandelbrot200            6.03ms × (1.00,1.01)    6.00ms × (1.00,1.01)  ~
BenchmarkGoParse                  9.82ms × (0.93,1.10)   10.35ms × (0.88,1.11)  ~
BenchmarkRegexpMatchEasy0_32       207ns × (1.00,1.00)     163ns × (0.99,1.01)  -21.26%
BenchmarkRegexpMatchEasy0_1K       581ns × (1.00,1.01)     566ns × (0.99,1.00)  -2.50%
BenchmarkRegexpMatchEasy1_32       185ns × (0.99,1.01)     138ns × (1.00,1.01)  -25.41%
BenchmarkRegexpMatchEasy1_1K       975ns × (1.00,1.01)     892ns × (1.00,1.00)  -8.51%
BenchmarkRegexpMatchMedium_32      328ns × (0.99,1.00)     252ns × (1.00,1.00)  -23.17%
BenchmarkRegexpMatchMedium_1K     88.6µs × (1.00,1.01)    73.0µs × (1.00,1.01)  -17.66%
BenchmarkRegexpMatchHard_32       4.69µs × (0.95,1.03)    3.85µs × (1.00,1.01)  -17.91%
BenchmarkRegexpMatchHard_1K        133µs × (1.00,1.01)     117µs × (1.00,1.00)  -12.34%
BenchmarkRevcomp                   902ms × (0.99,1.05)    1001ms × (0.94,1.01)  +11.04%
BenchmarkTemplate                  174ms × (0.99,1.01)     160ms × (0.99,1.01)  -7.70%
BenchmarkTimeParse                 639ns × (1.00,1.00)     622ns × (1.00,1.00)  -2.66%
BenchmarkTimeFormat                736ns × (1.00,1.01)     736ns × (1.00,1.02)  ~

Change-Id: Ib3bbeb379f5f4819e6f5dcf69bc88a2b7ed41460
Reviewed-on: https://go-review.googlesource.com/9225
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-04-28 01:38:18 +00:00
Russ Cox
653d56075d cmd/internal/gc: inline writeBarrierEnabled check before calling writebarrierptr
I believe the benchmarks that get slower are under register pressure,
and not making the call unconditionally makes the pressure worse,
and the register allocator doesn't do a great job. But part of the point
of this sequence is to get the write barriers out of the way so I can work
on the register allocator, so that's okay.

name                                       old                     new          delta
BenchmarkBinaryTree17              17.9s × (1.00,1.01)     18.0s × (0.99,1.01)  ~
BenchmarkFannkuch11                4.43s × (1.00,1.00)     4.43s × (1.00,1.00)  ~
BenchmarkFmtFprintfEmpty           110ns × (1.00,1.06)     114ns × (0.95,1.05)  ~
BenchmarkFmtFprintfString          487ns × (0.99,1.00)     468ns × (0.99,1.01)  -4.00%
BenchmarkFmtFprintfInt             450ns × (0.99,1.00)     433ns × (1.00,1.01)  -3.88%
BenchmarkFmtFprintfIntInt          762ns × (1.00,1.00)     748ns × (0.99,1.01)  -1.84%
BenchmarkFmtFprintfPrefixedInt     584ns × (0.99,1.01)     547ns × (0.99,1.01)  -6.26%
BenchmarkFmtFprintfFloat           738ns × (1.00,1.00)     756ns × (1.00,1.01)  +2.37%
BenchmarkFmtManyArgs              2.80µs × (1.00,1.01)    2.79µs × (1.00,1.01)  ~
BenchmarkGobDecode                39.0ms × (0.99,1.00)    39.6ms × (0.99,1.00)  +1.54%
BenchmarkGobEncode                37.8ms × (0.98,1.01)    37.6ms × (1.00,1.01)  ~
BenchmarkGzip                      661ms × (0.99,1.01)     663ms × (0.99,1.02)  ~
BenchmarkGunzip                    142ms × (1.00,1.00)     142ms × (1.00,1.00)  ~
BenchmarkHTTPClientServer          132µs × (0.99,1.01)     132µs × (0.99,1.01)  ~
BenchmarkJSONEncode               56.3ms × (0.99,1.01)    56.2ms × (0.99,1.01)  ~
BenchmarkJSONDecode                138ms × (0.99,1.01)     138ms × (1.00,1.00)  ~
BenchmarkMandelbrot200            6.01ms × (1.00,1.00)    6.03ms × (1.00,1.01)  +0.23%
BenchmarkGoParse                  10.2ms × (0.87,1.05)     9.8ms × (0.93,1.10)  ~
BenchmarkRegexpMatchEasy0_32       208ns × (1.00,1.00)     207ns × (1.00,1.00)  ~
BenchmarkRegexpMatchEasy0_1K       588ns × (1.00,1.00)     581ns × (1.00,1.01)  -1.27%
BenchmarkRegexpMatchEasy1_32       182ns × (0.99,1.01)     185ns × (0.99,1.01)  +1.65%
BenchmarkRegexpMatchEasy1_1K       986ns × (1.00,1.01)     975ns × (1.00,1.01)  -1.17%
BenchmarkRegexpMatchMedium_32      323ns × (1.00,1.01)     328ns × (0.99,1.00)  +1.55%
BenchmarkRegexpMatchMedium_1K     89.9µs × (1.00,1.00)    88.6µs × (1.00,1.01)  -1.38%
BenchmarkRegexpMatchHard_32       4.72µs × (0.95,1.01)    4.69µs × (0.95,1.03)  ~
BenchmarkRegexpMatchHard_1K        133µs × (1.00,1.01)     133µs × (1.00,1.01)  ~
BenchmarkRevcomp                   900ms × (1.00,1.05)     902ms × (0.99,1.05)  ~
BenchmarkTemplate                  168ms × (0.99,1.01)     174ms × (0.99,1.01)  +3.30%
BenchmarkTimeParse                 637ns × (1.00,1.00)     639ns × (1.00,1.00)  +0.31%
BenchmarkTimeFormat                738ns × (1.00,1.00)     736ns × (1.00,1.01)  ~

Change-Id: I03ce152852edec404538f6c20eb650fac82e2aa2
Reviewed-on: https://go-review.googlesource.com/9224
Reviewed-by: Austin Clements <austin@google.com>
2015-04-28 01:38:06 +00:00
Russ Cox
2050f57141 runtime: change unused argument in fat write barriers from pointer to scalar
The argument is unused, only present for alignment of the
following argument. The compiler today always passes a zero
but I'd rather not write anything there during the call sequence,
so mark it as a scalar so the garbage collector won't look at it.

As expected, no significant performance change.

name                                       old                     new          delta
BenchmarkBinaryTree17              17.9s × (0.99,1.00)     17.9s × (0.99,1.01)  ~
BenchmarkFannkuch11                4.35s × (1.00,1.00)     4.35s × (1.00,1.00)  ~
BenchmarkFmtFprintfEmpty           120ns × (0.94,1.05)     120ns × (0.93,1.06)  ~
BenchmarkFmtFprintfString          477ns × (1.00,1.00)     479ns × (0.99,1.00)  ~
BenchmarkFmtFprintfInt             450ns × (0.99,1.01)     452ns × (0.99,1.02)  ~
BenchmarkFmtFprintfIntInt          765ns × (0.99,1.01)     766ns × (0.99,1.01)  ~
BenchmarkFmtFprintfPrefixedInt     569ns × (0.99,1.01)     576ns × (0.98,1.01)  ~
BenchmarkFmtFprintfFloat           728ns × (1.00,1.00)     730ns × (1.00,1.01)  ~
BenchmarkFmtManyArgs              2.82µs × (0.99,1.01)    2.84µs × (0.99,1.00)  ~
BenchmarkGobDecode                39.1ms × (0.99,1.01)    39.3ms × (0.98,1.01)  ~
BenchmarkGobEncode                39.4ms × (0.99,1.01)    39.5ms × (0.99,1.01)  ~
BenchmarkGzip                      661ms × (0.99,1.01)     663ms × (1.00,1.01)  ~
BenchmarkGunzip                    143ms × (1.00,1.00)     143ms × (1.00,1.00)  ~
BenchmarkHTTPClientServer          133µs × (0.99,1.01)     132µs × (0.99,1.01)  ~
BenchmarkJSONEncode               57.3ms × (0.99,1.04)    57.4ms × (0.99,1.01)  ~
BenchmarkJSONDecode                139ms × (0.99,1.00)     139ms × (0.99,1.00)  ~
BenchmarkMandelbrot200            6.02ms × (1.00,1.00)    6.03ms × (1.00,1.00)  ~
BenchmarkGoParse                  9.72ms × (0.92,1.11)   10.31ms × (0.89,1.14)  ~
BenchmarkRegexpMatchEasy0_32       209ns × (1.00,1.01)     209ns × (1.00,1.00)  ~
BenchmarkRegexpMatchEasy0_1K       592ns × (0.99,1.00)     591ns × (0.99,1.00)  ~
BenchmarkRegexpMatchEasy1_32       183ns × (0.98,1.01)     184ns × (0.99,1.02)  ~
BenchmarkRegexpMatchEasy1_1K      1.01µs × (1.00,1.01)    1.01µs × (1.00,1.00)  ~
BenchmarkRegexpMatchMedium_32      330ns × (1.00,1.00)     330ns × (1.00,1.00)  ~
BenchmarkRegexpMatchMedium_1K     92.4µs × (1.00,1.00)    92.6µs × (1.00,1.00)  ~
BenchmarkRegexpMatchHard_32       4.77µs × (0.95,1.01)    4.80µs × (0.95,1.00)  ~
BenchmarkRegexpMatchHard_1K        136µs × (1.00,1.00)     136µs × (1.00,1.00)  ~
BenchmarkRevcomp                   906ms × (0.99,1.05)     900ms × (0.99,1.04)  ~
BenchmarkTemplate                  171ms × (0.99,1.01)     172ms × (1.00,1.00)  ~
BenchmarkTimeParse                 638ns × (1.00,1.00)     637ns × (1.00,1.00)  ~
BenchmarkTimeFormat                745ns × (0.99,1.02)     744ns × (1.00,1.01)  ~

Change-Id: I0aeac5dc7adfd75e2223e3aabfedc7818d339f9b
Reviewed-on: https://go-review.googlesource.com/9320
Reviewed-by: Austin Clements <austin@google.com>
2015-04-28 01:37:45 +00:00
Russ Cox
6c328efc4c cmd/internal/gc: accept comma-separated list of name=value for -d
This should obviously have no performance impact.
Listing numbers just as a sanity check for the benchmark
comparison program: it should (and does) find nothing
to report.

name                                       old                     new          delta
BenchmarkBinaryTree17              18.0s × (0.99,1.01)     17.9s × (0.99,1.00)  ~
BenchmarkFannkuch11                4.36s × (1.00,1.00)     4.35s × (1.00,1.00)  ~
BenchmarkFmtFprintfEmpty           120ns × (0.99,1.06)     120ns × (0.94,1.05)  ~
BenchmarkFmtFprintfString          480ns × (0.99,1.01)     477ns × (1.00,1.00)  ~
BenchmarkFmtFprintfInt             451ns × (0.99,1.01)     450ns × (0.99,1.01)  ~
BenchmarkFmtFprintfIntInt          766ns × (0.99,1.01)     765ns × (0.99,1.01)  ~
BenchmarkFmtFprintfPrefixedInt     569ns × (0.99,1.01)     569ns × (0.99,1.01)  ~
BenchmarkFmtFprintfFloat           728ns × (1.00,1.01)     728ns × (1.00,1.00)  ~
BenchmarkFmtManyArgs              2.81µs × (1.00,1.01)    2.82µs × (0.99,1.01)  ~
BenchmarkGobDecode                39.4ms × (0.99,1.01)    39.1ms × (0.99,1.01)  ~
BenchmarkGobEncode                39.4ms × (0.99,1.00)    39.4ms × (0.99,1.01)  ~
BenchmarkGzip                      660ms × (1.00,1.01)     661ms × (0.99,1.01)  ~
BenchmarkGunzip                    143ms × (1.00,1.00)     143ms × (1.00,1.00)  ~
BenchmarkHTTPClientServer          132µs × (0.99,1.01)     133µs × (0.99,1.01)  ~
BenchmarkJSONEncode               57.1ms × (0.99,1.01)    57.3ms × (0.99,1.04)  ~
BenchmarkJSONDecode                138ms × (1.00,1.01)     139ms × (0.99,1.00)  ~
BenchmarkMandelbrot200            6.02ms × (1.00,1.00)    6.02ms × (1.00,1.00)  ~
BenchmarkGoParse                  9.79ms × (0.92,1.07)    9.72ms × (0.92,1.11)  ~
BenchmarkRegexpMatchEasy0_32       210ns × (1.00,1.01)     209ns × (1.00,1.01)  ~
BenchmarkRegexpMatchEasy0_1K       593ns × (0.99,1.01)     592ns × (0.99,1.00)  ~
BenchmarkRegexpMatchEasy1_32       182ns × (0.99,1.01)     183ns × (0.98,1.01)  ~
BenchmarkRegexpMatchEasy1_1K      1.01µs × (1.00,1.01)    1.01µs × (1.00,1.01)  ~
BenchmarkRegexpMatchMedium_32      331ns × (1.00,1.00)     330ns × (1.00,1.00)  ~
BenchmarkRegexpMatchMedium_1K     92.6µs × (1.00,1.01)    92.4µs × (1.00,1.00)  ~
BenchmarkRegexpMatchHard_32       4.58µs × (0.99,1.05)    4.77µs × (0.95,1.01)  ~
BenchmarkRegexpMatchHard_1K        136µs × (1.00,1.01)     136µs × (1.00,1.00)  ~
BenchmarkRevcomp                   900ms × (0.99,1.06)     906ms × (0.99,1.05)  ~
BenchmarkTemplate                  171ms × (1.00,1.01)     171ms × (0.99,1.01)  ~
BenchmarkTimeParse                 637ns × (1.00,1.00)     638ns × (1.00,1.00)  ~
BenchmarkTimeFormat                742ns × (1.00,1.00)     745ns × (0.99,1.02)  ~

Change-Id: I59ec875715cb176bbffa709546370a6a7fc5a75d
Reviewed-on: https://go-review.googlesource.com/9309
Reviewed-by: Austin Clements <austin@google.com>
2015-04-28 01:37:34 +00:00
Russ Cox
0f0bc0f016 cmd/internal/gc: use MOV R0, R1 instead of LEA 0(R0), R1 in Agen
Minor code generation optimization I've been meaning to do
for a while and noticed while working on the emitted write
barrier code. Using MOV lets the compiler and maybe the
processor do copy propagation.

name                                       old                     new          delta
BenchmarkBinaryTree17              17.9s × (0.99,1.01)     18.0s × (0.99,1.01)  ~
BenchmarkFannkuch11                4.42s × (1.00,1.00)     4.36s × (1.00,1.00)  -1.39%
BenchmarkFmtFprintfEmpty           118ns × (0.96,1.02)     120ns × (0.99,1.06)  ~
BenchmarkFmtFprintfString          486ns × (0.99,1.01)     480ns × (0.99,1.01)  -1.34%
BenchmarkFmtFprintfInt             457ns × (0.99,1.01)     451ns × (0.99,1.01)  -1.31%
BenchmarkFmtFprintfIntInt          768ns × (1.00,1.01)     766ns × (0.99,1.01)  ~
BenchmarkFmtFprintfPrefixedInt     584ns × (0.99,1.03)     569ns × (0.99,1.01)  -2.57%
BenchmarkFmtFprintfFloat           739ns × (0.99,1.00)     728ns × (1.00,1.01)  -1.49%
BenchmarkFmtManyArgs              2.77µs × (1.00,1.00)    2.81µs × (1.00,1.01)  +1.53%
BenchmarkGobDecode                39.3ms × (0.99,1.01)    39.4ms × (0.99,1.01)  ~
BenchmarkGobEncode                39.4ms × (0.99,1.00)    39.4ms × (0.99,1.00)  ~
BenchmarkGzip                      661ms × (0.99,1.01)     660ms × (1.00,1.01)  ~
BenchmarkGunzip                    142ms × (1.00,1.00)     143ms × (1.00,1.00)  +0.20%
BenchmarkHTTPClientServer          133µs × (0.98,1.01)     132µs × (0.99,1.01)  ~
BenchmarkJSONEncode               56.5ms × (0.99,1.01)    57.1ms × (0.99,1.01)  +0.94%
BenchmarkJSONDecode                143ms × (1.00,1.00)     138ms × (1.00,1.01)  -3.22%
BenchmarkMandelbrot200            6.01ms × (1.00,1.00)    6.02ms × (1.00,1.00)  ~
BenchmarkGoParse                  9.63ms × (0.94,1.07)    9.79ms × (0.92,1.07)  ~
BenchmarkRegexpMatchEasy0_32       210ns × (1.00,1.00)     210ns × (1.00,1.01)  ~
BenchmarkRegexpMatchEasy0_1K       596ns × (0.99,1.01)     593ns × (0.99,1.01)  ~
BenchmarkRegexpMatchEasy1_32       184ns × (0.99,1.01)     182ns × (0.99,1.01)  ~
BenchmarkRegexpMatchEasy1_1K      1.01µs × (0.99,1.01)    1.01µs × (1.00,1.01)  ~
BenchmarkRegexpMatchMedium_32      327ns × (1.00,1.01)     331ns × (1.00,1.00)  +1.22%
BenchmarkRegexpMatchMedium_1K     93.0µs × (1.00,1.02)    92.6µs × (1.00,1.01)  ~
BenchmarkRegexpMatchHard_32       4.76µs × (0.95,1.01)    4.58µs × (0.99,1.05)  ~
BenchmarkRegexpMatchHard_1K        136µs × (1.00,1.01)     136µs × (1.00,1.01)  ~
BenchmarkRevcomp                   892ms × (1.00,1.01)     900ms × (0.99,1.06)  ~
BenchmarkTemplate                  175ms × (0.99,1.00)     171ms × (1.00,1.01)  -2.36%
BenchmarkTimeParse                 638ns × (1.00,1.00)     637ns × (1.00,1.00)  ~
BenchmarkTimeFormat                772ns × (1.00,1.00)     742ns × (1.00,1.00)  -3.95%

Change-Id: I6504e310cb9cf48a73d539c478b4dbcacde208b2
Reviewed-on: https://go-review.googlesource.com/9308
Reviewed-by: Austin Clements <austin@google.com>
2015-04-28 01:37:33 +00:00
Russ Cox
0ad4f8b1f7 cmd/internal/gc: emit write barriers at lower level
This is primarily preparation for inlining, not an optimization by itself,
but it still helps some.

name                                       old                     new          delta
BenchmarkBinaryTree17              18.2s × (0.99,1.01)     17.9s × (0.99,1.01)  -1.57%
BenchmarkFannkuch11                4.44s × (1.00,1.00)     4.42s × (1.00,1.00)  -0.40%
BenchmarkFmtFprintfEmpty           119ns × (0.95,1.02)     118ns × (0.96,1.02)  ~
BenchmarkFmtFprintfString          501ns × (0.99,1.02)     486ns × (0.99,1.01)  -2.89%
BenchmarkFmtFprintfInt             474ns × (0.99,1.00)     457ns × (0.99,1.01)  -3.59%
BenchmarkFmtFprintfIntInt          792ns × (1.00,1.00)     768ns × (1.00,1.01)  -3.03%
BenchmarkFmtFprintfPrefixedInt     574ns × (1.00,1.01)     584ns × (0.99,1.03)  +1.83%
BenchmarkFmtFprintfFloat           749ns × (1.00,1.00)     739ns × (0.99,1.00)  -1.34%
BenchmarkFmtManyArgs              2.94µs × (1.00,1.01)    2.77µs × (1.00,1.00)  -5.76%
BenchmarkGobDecode                39.5ms × (0.99,1.01)    39.3ms × (0.99,1.01)  ~
BenchmarkGobEncode                39.4ms × (1.00,1.01)    39.4ms × (0.99,1.00)  ~
BenchmarkGzip                      658ms × (1.00,1.01)     661ms × (0.99,1.01)  ~
BenchmarkGunzip                    142ms × (1.00,1.00)     142ms × (1.00,1.00)  +0.22%
BenchmarkHTTPClientServer          134µs × (0.99,1.01)     133µs × (0.98,1.01)  ~
BenchmarkJSONEncode               57.1ms × (0.99,1.01)    56.5ms × (0.99,1.01)  ~
BenchmarkJSONDecode                141ms × (1.00,1.00)     143ms × (1.00,1.00)  +1.09%
BenchmarkMandelbrot200            6.01ms × (1.00,1.00)    6.01ms × (1.00,1.00)  ~
BenchmarkGoParse                  10.1ms × (0.91,1.09)     9.6ms × (0.94,1.07)  ~
BenchmarkRegexpMatchEasy0_32       207ns × (1.00,1.01)     210ns × (1.00,1.00)  +1.45%
BenchmarkRegexpMatchEasy0_1K       592ns × (0.99,1.00)     596ns × (0.99,1.01)  +0.68%
BenchmarkRegexpMatchEasy1_32       184ns × (0.99,1.01)     184ns × (0.99,1.01)  ~
BenchmarkRegexpMatchEasy1_1K      1.01µs × (1.00,1.00)    1.01µs × (0.99,1.01)  ~
BenchmarkRegexpMatchMedium_32      327ns × (0.99,1.00)     327ns × (1.00,1.01)  ~
BenchmarkRegexpMatchMedium_1K     92.5µs × (1.00,1.00)    93.0µs × (1.00,1.02)  +0.48%
BenchmarkRegexpMatchHard_32       4.79µs × (0.95,1.00)    4.76µs × (0.95,1.01)  ~
BenchmarkRegexpMatchHard_1K        136µs × (1.00,1.00)     136µs × (1.00,1.01)  ~
BenchmarkRevcomp                   900ms × (0.99,1.01)     892ms × (1.00,1.01)  ~
BenchmarkTemplate                  170ms × (0.99,1.01)     175ms × (0.99,1.00)  +2.95%
BenchmarkTimeParse                 645ns × (1.00,1.00)     638ns × (1.00,1.00)  -1.16%
BenchmarkTimeFormat                740ns × (1.00,1.00)     772ns × (1.00,1.00)  +4.39%

Change-Id: I0be905e32791e0cb70ff01f169c4b309a971d981
Reviewed-on: https://go-review.googlesource.com/9159
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-28 01:37:05 +00:00
Rob Pike
a5de54a870 cmd/go,cmd/doc: add "go doc"
Add the new go doc command to the go command, installed in
the tool directory.

(Still to do: tests)

Fix cmd/dist to remove old "package documentation" code that was
stopping it from including cmd/go/doc.go in the build.

Implement the doc command. Here is the help info from "go help doc":

===
usage: go doc [-u] [package|[package.]symbol[.method]]

Doc accepts at most one argument, indicating either a package, a symbol within a
package, or a method of a symbol.

	go doc
	go doc <pkg>
	go doc <sym>[.<method>]
	go doc [<pkg>].<sym>[.<method>]

Doc interprets the argument to see what it represents, determined by its syntax
and which packages and symbols are present in the source directories of GOROOT and
GOPATH.

The first item in this list that succeeds is the one whose documentation is printed.
For packages, the order of scanning is determined by the file system, however the
GOROOT tree is always scanned before GOPATH.

If there is no package specified or matched, the package in the current directory
is selected, so "go doc" shows the documentation for the current package and
"go doc Foo" shows the documentation for symbol Foo in the current package.

Doc prints the documentation comments associated with the top-level item the
argument identifies (package, type, method) followed by a one-line summary of each
of the first-level items "under" that item (package-level declarations for a
package, methods for a type, etc.)

The package paths must be either a qualified path or a proper suffix of a path
(see examples below). The go tool's usual package mechanism does not apply: package
path elements like . and ...  are not implemented by go doc.

When matching symbols, lower-case letters match either case but upper-case letters
match exactly.

Examples:
	go doc
		Show documentation for current package.
	go doc Foo
		Show documentation for Foo in the current package.
		(Foo starts with a capital letter so it cannot match a package path.)
	go doc json
		Show documentation for the encoding/json package.
	go doc json
		Shorthand for encoding/json assuming only one json package
		is present in the tree.
	go doc json.Number (or go doc json.number)
		Show documentation and method summary for json.Number.
	go doc json.Number.Int64 (or go doc json.number.int64)
		Show documentation for the Int64 method of json.Number.

Flags:
	-u
		Show documentation for unexported as well as exported
		symbols and methods.

===

Still to do:

Tests.
Disambiguation when there is both foo and Foo.
Flag for case-sensitive matching.

Change-Id: I83d409a68688a5445f54297a7e7c745f749b9e66
Reviewed-on: https://go-review.googlesource.com/9227
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-27 23:22:26 +00:00
Josh Bleecher Snyder
00d4a6b35d cmd/internal/gc, cmd/internal/ld: add memprofilerate flag
Also call runtime.GC before exit to ensure
that the profiler picks up all allocations.

Fixes #10537.

Change-Id: Ibfbfc88652ac0ce30a6d1ae392f919df6c1e8126
Reviewed-on: https://go-review.googlesource.com/9261
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-27 22:21:40 +00:00
Josh Bleecher Snyder
81c2233b4a Revert "cmd/dist: consolidate runtime CPU tests"
This reverts commit a9e50a6b35.

Change-Id: I3c5e459f1030e36bc249910facdae12303a44151
Reviewed-on: https://go-review.googlesource.com/9394
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-27 17:56:04 +00:00
Josh Bleecher Snyder
a9e50a6b35 cmd/dist: consolidate runtime CPU tests
Instead of running:

go test -short runtime -cpu=1
go test -short runtime -cpu=2
go test -short runtime -cpu=4

Run just:

go test -short runtime -cpu=1,2,4

This is a return to the Go 1.4.2 behavior.

We lose incremental display of progress and
per-cpu timing information, but we don't have
to recompile and relink the runtime test,
which is slow.

This cuts about 10s off all.bash.

Updates #10571.

Change-Id: I6e8c7149780d47439f8bcfa888e6efc84290c60a
Reviewed-on: https://go-review.googlesource.com/9350
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-04-27 17:36:18 +00:00
Josh Bleecher Snyder
2692f48330 cmd/internal/ld: remove pointless allocs
Reduces allocs linking cmd/go and runtime.test
by ~13%. No functional changes.

The most easily addressed sources of allocations
after this are expandpkg, rdstring, and symbuf
string conversion.

These can be reduced by interning strings,
but that increases the overall memory footprint.

Change-Id: Ifedefc9f2a0403bcc75460d6b139e8408374e058
Reviewed-on: https://go-review.googlesource.com/9391
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-27 17:08:56 +00:00
Håvard Haugen
14a4649fe2 cmd/pprof: handle empty profile gracefully
The command "go tool pprof -top $GOROOT/bin/go /dev/null" now logs that
profile is empty instead of panicking.

Fixes #9207

Change-Id: I3d55c179277cb19ad52c8f24f1aca85db53ee08d
Reviewed-on: https://go-review.googlesource.com/2571
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-26 20:12:17 +00:00
Michael Hudson-Doyle
c20ff36fe2 cmd/internal/ld: R_TLS_LE is fine on Darwin too
Sorry about this.

Fixes #10575

Change-Id: I2de23be68e7d822d182e5a0d6a00c607448d861e
Reviewed-on: https://go-review.googlesource.com/9341
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-26 04:53:51 +00:00
Michael Hudson-Doyle
264858c46e cmd/8l, cmd/internal/ld, cmd/internal/obj/x86: stop incorrectly using the term "inital exec"
The long comment block in obj6.go:progedit talked about the two code sequences
for accessing g as "local exec" and "initial exec", but really they are both forms
of local exec. This stuff is confusing enough without using the wrong words for
things, so rewrite it to talk about 2-instruction and 1-instruction sequences.
Unfortunately the confusion has made it into code, with the R_TLS_IE relocation
now doing double duty as meaning actual initial exec when externally linking and
boring old local exec when linking internally (half of this is my fault). So this
stops using R_TLS_IE in the local exec case. There is a chance this might break
plan9 or windows, but I don't think so. Next step is working out what the heck is
going on on ARM...

Change-Id: I09da4388210cf49dbc99fd25f5172bbe517cee57
Reviewed-on: https://go-review.googlesource.com/9273
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-25 18:13:15 +00:00
Michael Hudson-Doyle
ccc76dba60 cmd/internal/ld: fix R_TLS handling now Xsym is not read from object file
I think this should fix the arm build. A proper fix involves making the handling
of tlsg less fragile, I'll try that tomorrow.

Update #10557

Change-Id: I9b1b666737fb40aebb6f284748509afa8483cce5
Reviewed-on: https://go-review.googlesource.com/9272
Reviewed-by: Dave Cheney <dave@cheney.net>
Run-TryBot: Dave Cheney <dave@cheney.net>
2015-04-24 20:57:49 +00:00
Rob Pike
b3000b6f6a cmd/go: rename doc.go to alldocs.go in preparation for "go doc"
Also rename and update mkdoc.sh to mkalldocs.sh

Change-Id: Ief3673c22d45624e173fc65ee279cea324da03b5
Reviewed-on: https://go-review.googlesource.com/9226
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-24 18:29:59 +00:00
Hyang-Ah Hana Kim
8566979972 misc/cgo/testcshared: add a c-shared test for android/arm.
- main3.c tests main.main is exported when compiled for GOOS=android.
- wait longer for main2.c (it's slow on android/arm)
- rearranged test.bash

Fixes #10070.

Change-Id: I6e5a98d1c5fae776afa54ecb5da633b59b269316
Reviewed-on: https://go-review.googlesource.com/9296
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-24 16:32:31 +00:00
Michael Hudson-Doyle
029c7bbdfe cmd/internal/gc, cmd/internal/ld, cmd/internal/obj: teach compiler about local symbols
This lets us avoid loading string constants via the GOT and (together with
http://golang.org/cl/9102) results in the fannkuch benchmark having very similar
register usage with -dynlink as without.

Change-Id: Ic3892b399074982b76773c3e547cfbba5dabb6f9
Reviewed-on: https://go-review.googlesource.com/9103
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-24 16:19:41 +00:00
Russ Cox
9406f68e6a cmd/internal/gc: add and test write barrier debug output
We can expand the test cases as we discover problems.
This is some basic tests plus all the things I got wrong
in some recent work.

Change-Id: Id875fcfaf74eb087ae42b441fe47a34c5b8ccb39
Reviewed-on: https://go-review.googlesource.com/9158
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2015-04-24 14:39:49 +00:00
Shenghou Ma
7579867fec cmd/dist: allow $GO_TEST_TIMEOUT_SCALE to override timeoutScale
Some machines are so slow that even with the default timeoutScale,
they still timeout some tests. For example, currently some linux/arm
builders and the openbsd/arm builder are timing out the runtime
test and CL 8397 was proposed to skip some tests on openbsd/arm
to fix the build.

Instead of increasing timeoutScale or skipping tests, this CL
introduces an environment variable $GO_TEST_TIMEOUT_SCALE that
could be set to manually set a larger timeoutScale for those
machines/builders.

Fixes #10314.

Change-Id: I16c9a9eb980d6a63309e4cacd79eee2fe05769ee
Reviewed-on: https://go-review.googlesource.com/9223
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-24 05:45:36 +00:00
Srdjan Petrovic
5c8fbc6f1e runtime: signal forwarding
Forward signals to signal handlers installed before Go installs its own,
under certain circumstances.  In particular, as iant@ suggests, signals are
forwarded iff:
   (1) a non-SIG_DFL signal handler existed before Go, and
   (2) signal is synchronous (i.e., one of SIGSEGV, SIGBUS, SIGFPE), and
   	(3a) signal occured on a non-Go thread, or
   	(3b) signal occurred on a Go thread but in CGo code.

Supported only on Linux, for now.

Change-Id: I403219ee47b26cf65da819fb86cf1ec04d3e25f5
Reviewed-on: https://go-review.googlesource.com/8712
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-24 05:19:39 +00:00
Josh Bleecher Snyder
04829a4138 cmd/9g, etc: remove // fallthrough comments
They are vestiges of the c2go transition.

Change-Id: I22672e40373ef77d7a0bf69cfff8017e46353055
Reviewed-on: https://go-review.googlesource.com/9265
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-23 23:46:19 +00:00
Josh Bleecher Snyder
c231228085 cmd/internal/gc: remove /*untyped*/ comments
They are vestiges of the c2go translation.

Change-Id: I9a10536f5986b751a35cc7d84b5ba69ae0c2ede7
Reviewed-on: https://go-review.googlesource.com/9262
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-23 01:21:44 +00:00
Michael Hudson-Doyle
68f5570032 cmd/link, cmd/internal/goobj: update constants, regenerate testdata
The constants in cmd/internal/goobj had gone stale (we had three copies of
these constants, working on reducing that was what got me to noticing this).

Some of the changes to link.hello.darwin.amd64 are the change from absolute
to %rip-relative addressing, a change which happened quite a while ago...

Depends on http://golang.org/cl/9113.

Fixes #10501.

Change-Id: Iaa1511f458a32228c2df2ccd0076bb9ae212a035
Reviewed-on: https://go-review.googlesource.com/9105
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-22 20:32:16 +00:00
Michael Hudson-Doyle
91318dc76c cmd/go: refactor creation of top-level actions for -buildmode=shared
Change-Id: I429402dd91243cd9415b054ee17bfebccc68ed57
Reviewed-on: https://go-review.googlesource.com/9197
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-22 19:28:03 +00:00
Michael Hudson-Doyle
7820d27049 cmd/internal/gc, cmd/internal/ld: fixes for global vars of types from other modules
To make the gcprog for global data containing variables of types defined in other shared
libraries, we need to know a lot about those types. So read the value of any symbol with
a name starting with "type.". If a type uses a mask, the name of the symbol defining the
mask unfortunately cannot be predicted from the type name so I have to keep track of the
addresses of every such symbol and associate them with the type symbols after the fact.

I'm not very happy about this change, but something like this is needed and this is as
pleasant as I know how to make it.

Change-Id: I408d831b08b3b31e0610688c41367b23998e975c
Reviewed-on: https://go-review.googlesource.com/8334
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-22 19:07:34 +00:00
Michael Hudson-Doyle
ac1cdd13e0 cmd/5g, etc, cmd/internal/gc, cmd/internal/obj, etc: coalesce bool2int implementations
There were 10 implementations of the trivial bool2int function, 9 of which
were the only thing in their file.  Remove all of them in favor of one in
cmd/internal/obj.

Change-Id: I9c51d30716239df51186860b9842a5e9b27264d3
Reviewed-on: https://go-review.googlesource.com/9230
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-22 18:50:07 +00:00
Ian Lance Taylor
af161c577c cmd/go: depend on runtime/cgo if external linking mode is forced
In external linking mode, the linker automatically imports
runtime/cgo.  When the user uses non-standard compilation options,
they have to know to run go install runtime/cgo.  When the go tool
adds non-standard compilation options itself, we can't force the user
to do that.  So add the dependency ourselves.

Bad news: we don't currently have a clean way to know whether we are
going to use external linking mode.  This CL duplicates logic split
between cmd/6l and cmd/internal/ld.

Good news: adding an unnecessary dependency on runtime/cgo does no
real harm.  We aren't going to force the linker to pull it in, we're
just going to build it so that its available if the linker wants it.

Change-Id: Ide676339d4e8b1c3d9792884a2cea921abb281b7
Reviewed-on: https://go-review.googlesource.com/9115
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-21 17:35:33 +00:00
Josh Bleecher Snyder
873483c682 cmd/internal/obj: reuse the varint encoding buffer
This reduces the number of allocations in the compiler
while building the stdlib by 15.66%.

No functional changes. Passes toolstash -cmp.

Change-Id: Ia21b37134a8906a4e23d53fdc15235b4aa7bbb34
Reviewed-on: https://go-review.googlesource.com/9085
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-21 17:20:52 +00:00
Michael Hudson-Doyle
0088ddc3a0 cmd/6l, cmd/internal/ld, cmd/internal/obj: remove Xsym/Xadd from compiler's Reloc
They don't really make any sense on this side of the compiler/linker divide.

Some of the code touching these fields was the support for R_TLS when
thechar=='6' which turns out to be dead and so I just removed all of that.

Change-Id: I4e265613c4e7fcc30a965fffb7fd5f45017f06f3
Reviewed-on: https://go-review.googlesource.com/9107
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-21 03:00:19 +00:00
Michael Hudson-Doyle
f9bc9a7a2e cmd/internal/ld: set moduledatasize correctly when -linkshared
Change-Id: I1ea4175466c9113c1f41b012ba8266ee2b06e3a3
Reviewed-on: https://go-review.googlesource.com/8522
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-20 23:21:38 +00:00
Michael Hudson-Doyle
8a3132dd5e cmd/6g: let the compiler use R15 when it is not needed for GOT indirection
Thanks to Russ for the hints.

Change-Id: Ie35a71d432b9d68bd30c7a364b4dce1bd3db806e
Reviewed-on: https://go-review.googlesource.com/9102
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-20 23:20:15 +00:00
Brad Fitzpatrick
88c08b06b9 cmd/internal: C->Go printf cleanup
Change-Id: I1cf94377c613fb51ae77f4fe1e3439268b1606a9
Reviewed-on: https://go-review.googlesource.com/9161
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-20 22:36:59 +00:00
Matthew Dempsky
e7ffafdb6e cmd/internal/obj: remove useless Trimpath field and fix users
http://golang.org/cl/7623 refactored how line history works and
introduced a new TrimPathPrefix field to replace the existing Trimpath
field, but never removed the latter or updated its users.

Fixes #10503.

Change-Id: Ief90a55b6cef2e8062b59856a4c7dcc0df01d3f2
Reviewed-on: https://go-review.googlesource.com/9113
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2015-04-20 20:46:06 +00:00
Russ Cox
35b1dcc25f cmd/internal/gc: clean up componentgen
This is primarily about making the code clearer, but as part of the cleanup
componentgen is now much more consistent about what it does and does
not attempt.

The new limit is to 8 move instructions.

The old limit was either 3 or 4 small things but in the details it was
quite inconsistent: ints, interfaces, strings, and slices all counted as small;
it handled a struct containing two ints, but not a struct containing a struct
containing two ints; it handled slices and interfaces and a struct containing
a slice but not a struct containing an interface; and so on.

The new code runs at about the same speed as the old code if limited to 4 moves,
but that's much more restrictive when the pieces are strings or interfaces.
With the limit raised to 8 moves, this CL is sometimes a significant improvement:

benchmark                          old ns/op      new ns/op      delta
BenchmarkBinaryTree17              4361174290     4362870005     +0.04%
BenchmarkFannkuch11                3008201483     2974408533     -1.12%
BenchmarkFmtFprintfEmpty           79.0           79.5           +0.63%
BenchmarkFmtFprintfString          281            261            -7.12%
BenchmarkFmtFprintfInt             264            262            -0.76%
BenchmarkFmtFprintfIntInt          447            443            -0.89%
BenchmarkFmtFprintfPrefixedInt     354            361            +1.98%
BenchmarkFmtFprintfFloat           500            452            -9.60%
BenchmarkFmtManyArgs               1688           1693           +0.30%
BenchmarkGobDecode                 11718456       11741179       +0.19%
BenchmarkGobEncode                 10144620       10161627       +0.17%
BenchmarkGzip                      437631642      435271877      -0.54%
BenchmarkGunzip                    109468858      110173606      +0.64%
BenchmarkHTTPClientServer          76248          75362          -1.16%
BenchmarkJSONEncode                24160474       23753091       -1.69%
BenchmarkJSONDecode                84470041       82902026       -1.86%
BenchmarkMandelbrot200             4676857        4687040        +0.22%
BenchmarkGoParse                   4954602        4923965        -0.62%
BenchmarkRegexpMatchEasy0_32       151            151            +0.00%
BenchmarkRegexpMatchEasy0_1K       450            452            +0.44%
BenchmarkRegexpMatchEasy1_32       131            130            -0.76%
BenchmarkRegexpMatchEasy1_1K       713            695            -2.52%
BenchmarkRegexpMatchMedium_32      227            218            -3.96%
BenchmarkRegexpMatchMedium_1K      63911          62966          -1.48%
BenchmarkRegexpMatchHard_32        3163           3026           -4.33%
BenchmarkRegexpMatchHard_1K        93985          90266          -3.96%
BenchmarkRevcomp                   650697093      649211600      -0.23%
BenchmarkTemplate                  107049170      106804076      -0.23%
BenchmarkTimeParse                 448            452            +0.89%
BenchmarkTimeFormat                468            460            -1.71%

Change-Id: I08563133883e88bb9db9e9e4dee438a5af2787da
Reviewed-on: https://go-review.googlesource.com/9004
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-20 20:26:57 +00:00
Matthew Dempsky
c776592a4f cmd/internal/ld: prefer constants from cmd/internal/obj
The majority of this CL was prepared via scripted invocations of
`gofmt -w -r "$SYM -> obj.$SYM" cmd/internal/ld/*.go` and `gofmt -w -r
"ld.$SYM -> obj.$SYM" cmd/?l/*.go`.

Because of issue #7417, that was followed by repeatedly running an AWK
script to identify lines that differed other than whitespace changes
or "ld." or "obj." prefixes and manually restoring comments.

Finally, the redundant constants from cmd/internal/ld/link.go were
removed, and "goimports -w" was used to cleanup import lines.

Passes rsc.io/toolstash/buildall, even when modified to also build cmd.

Fixes #10055.

Change-Id: Icd5dbe819a3b6520ce883748e60017dc8e9a2e85
Reviewed-on: https://go-review.googlesource.com/9112
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-20 20:05:13 +00:00
Russ Cox
6e221a9038 cmd/dist: run commands in $GOROOT/src not $GOROOT when possible
The go command prints paths in errors relative to its current directory.
Since all.bash and run.bash are run in $GOROOT/src, prefer to run
the go command, so that the relative paths are correct.

Before this CL, running all.bash in $GOROOT/src:

	##### Testing race detector
	# net/http
	src/net/http/transport.go:1257: cannot take the address of <node EFACE>

This is wrong (or at least less useful) because there is no $GOROOT/src/src/net/http directory.

Change-Id: I0c0d52c22830d79b3715f51a6329a3d33de52a72
Reviewed-on: https://go-review.googlesource.com/9157
Reviewed-by: Rob Pike <r@golang.org>
2015-04-20 19:54:01 +00:00
Brad Fitzpatrick
a13cf8c104 cmd/internal/obj: manual C->Go cleanups
Change-Id: I5964fc55157dc1df7be400dfa0df591d6163e25e
Reviewed-on: https://go-review.googlesource.com/9084
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-20 16:54:22 +00:00
David Crawshaw
3f4de49d0a cmd/dist: enable c-archive test on darwin/arm64
Turns out all the necessary pieces have already been submitted.

Change-Id: I19c8d614cd756821ce400ca7a338029002780b18
Reviewed-on: https://go-review.googlesource.com/9076
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-20 15:56:56 +00:00
David Crawshaw
98f610fe09 misc/cgo/testcarchive: enable test on darwin/arm
Change-Id: I0d3f9841500e0a41f1c427244869bf3736a31e18
Reviewed-on: https://go-review.googlesource.com/9075
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-20 15:16:16 +00:00
Hyang-Ah Hana Kim
983a490ee9 cmd/dist: include misc/cgo/testcshared test for linux/amd64
Change-Id: Ia2c0c617df523482ba1a25b7492267eb80f0819a
Reviewed-on: https://go-review.googlesource.com/9033
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-20 02:27:43 +00:00
Michael Hudson-Doyle
b92a0a8969 cmd/internal/gc, cmd/go: fix value of importpath symbol
In https://golang.org/cl/7797 I attempted to use myimportpath to set the value
of the go.importpath.$foo. symbol for the module being compiled, but I messed
it up and only set the name (which the linker rewrites anyway). This lead to
the importpath for the module being compiled being "". This was hard to notice,
because all modules that import another define the importpath for their
imported modules correctly -- but main is not imported, and this meant that the
reflect module saw all fields of all types defined in the main module as
exported.

The fix is to do what I meant to do the first time, add a test and change the
go tool to compile main packages with -p main and not -p
command-line-arguments.

Fixes #10332

Change-Id: I5fc6e9b1dc2b26f058641e382f9a56a526eca291
Reviewed-on: https://go-review.googlesource.com/8481
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-19 20:14:59 +00:00
Josh Bleecher Snyder
951f74c4d0 cmd/...: fix vet issues and cull dead code
Change-Id: Ied0eab872950793b34dd2268055b29c702b07e99
Reviewed-on: https://go-review.googlesource.com/9081
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-18 01:47:28 +00:00
Matthew Dempsky
93402383ea cmd/cgo: more robust detection of clang
Fixes #10453.

Change-Id: I77470279865d4c954df615d6594c69edf68c28ca
Reviewed-on: https://go-review.googlesource.com/9090
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-18 01:11:44 +00:00
Brad Fitzpatrick
05efc18c20 cmd/6g, etc: cleanup, moving code out of near-empty gg.go files
Clear out gg.go files, and move things into consistent places between
the cmd/?g directories.

Change-Id: I81e04180613b806e0bfbb88519e66111ce9f74a3
Reviewed-on: https://go-review.googlesource.com/9080
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-18 00:11:23 +00:00
David Crawshaw
7816a096d9 cmd/internal/ld: replace Diag;Errorexit with Exitf
I have left the Diag calls in place where I believe Ctxt.Cursym != nil
which means this CL is not the improvement I had hoped for. However
it is now safe to call Exitf whereever you are in the linker, which
makes it easier to reason about some code.

Change-Id: I8261e761ca9719f7d216e2747314adfe464e3337
Reviewed-on: https://go-review.googlesource.com/8668
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-17 22:50:25 +00:00
Rob Pike
9c3bf097c8 cmd/go: add $GOLINE to generate
Also use os.Expand for variable substitution so ${x}y works.

Fixes #9960.

Change-Id: Ic8239b2e737d1f41910dde8ee9524ac48907cb03
Reviewed-on: https://go-review.googlesource.com/9007
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17 20:33:01 +00:00
Josh Bleecher Snyder
13cb62c764 cmd/internal/gc, cmd/6g: generate boolean values without jumps
Use SETcc instructions instead of Jcc to generate boolean values.
This generates shorter, jump-free code, which may in turn enable other
peephole optimizations.

For example, given

func f(i, j int) bool {
	return i == j
}

Before

"".f t=1 size=32 value=0 args=0x18 locals=0x0
	0x0000 00000 (x.go:3)	TEXT	"".f(SB), $0-24
	0x0000 00000 (x.go:3)	FUNCDATA	$0, gclocals·b4c25e9b09fd0cf9bb429dcefe91c353(SB)
	0x0000 00000 (x.go:3)	FUNCDATA	$1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0000 00000 (x.go:4)	MOVQ	"".i+8(FP), BX
	0x0005 00005 (x.go:4)	MOVQ	"".j+16(FP), BP
	0x000a 00010 (x.go:4)	CMPQ	BX, BP
	0x000d 00013 (x.go:4)	JEQ	21
	0x000f 00015 (x.go:4)	MOVB	$0, "".~r2+24(FP)
	0x0014 00020 (x.go:4)	RET
	0x0015 00021 (x.go:4)	MOVB	$1, "".~r2+24(FP)
	0x001a 00026 (x.go:4)	JMP	20

After

"".f t=1 size=32 value=0 args=0x18 locals=0x0
	0x0000 00000 (x.go:3)	TEXT	"".f(SB), $0-24
	0x0000 00000 (x.go:3)	FUNCDATA	$0, gclocals·b4c25e9b09fd0cf9bb429dcefe91c353(SB)
	0x0000 00000 (x.go:3)	FUNCDATA	$1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)
	0x0000 00000 (x.go:4)	MOVQ	"".i+8(FP), BX
	0x0005 00005 (x.go:4)	MOVQ	"".j+16(FP), BP
	0x000a 00010 (x.go:4)	CMPQ	BX, BP
	0x000d 00013 (x.go:4)	SETEQ	"".~r2+24(FP)
	0x0012 00018 (x.go:4)	RET

regexp benchmarks, best of 12 runs:

benchmark                                 old ns/op      new ns/op      delta
BenchmarkNotOnePassShortB                 782            733            -6.27%
BenchmarkLiteral                          180            171            -5.00%
BenchmarkNotLiteral                       2855           2721           -4.69%
BenchmarkMatchHard_32                     2672           2557           -4.30%
BenchmarkMatchHard_1K                     80182          76732          -4.30%
BenchmarkMatchEasy1_32M                   76440180       73304748       -4.10%
BenchmarkMatchEasy1_32K                   68798          66350          -3.56%
BenchmarkAnchoredLongMatch                482            465            -3.53%
BenchmarkMatchEasy1_1M                    2373042        2292692        -3.39%
BenchmarkReplaceAll                       2776           2690           -3.10%
BenchmarkNotOnePassShortA                 1397           1360           -2.65%
BenchmarkMatchClass_InRange               3842           3742           -2.60%
BenchmarkMatchEasy0_32                    125            122            -2.40%
BenchmarkMatchEasy0_32K                   11414          11164          -2.19%
BenchmarkMatchEasy0_1K                    668            654            -2.10%
BenchmarkAnchoredShortMatch               260            255            -1.92%
BenchmarkAnchoredLiteralShortNonMatch     164            161            -1.83%
BenchmarkOnePassShortB                    623            612            -1.77%
BenchmarkOnePassShortA                    801            788            -1.62%
BenchmarkMatchClass                       4094           4033           -1.49%
BenchmarkMatchEasy0_32M                   14078800       13890704       -1.34%
BenchmarkMatchHard_32K                    4095844        4045820        -1.22%
BenchmarkMatchEasy1_1K                    1663           1643           -1.20%
BenchmarkMatchHard_1M                     131261708      129708215      -1.18%
BenchmarkMatchHard_32M                    4210112412     4169292003     -0.97%
BenchmarkMatchMedium_32K                  2460752        2438611        -0.90%
BenchmarkMatchEasy0_1M                    422914         419672         -0.77%
BenchmarkMatchMedium_1M                   78581121       78040160       -0.69%
BenchmarkMatchMedium_32M                  2515287278     2498464906     -0.67%
BenchmarkMatchMedium_32                   1754           1746           -0.46%
BenchmarkMatchMedium_1K                   52105          52106          +0.00%
BenchmarkAnchoredLiteralLongNonMatch      185            185            +0.00%
BenchmarkMatchEasy1_32                    107            107            +0.00%
BenchmarkOnePassLongNotPrefix             505            505            +0.00%
BenchmarkOnePassLongPrefix                147            147            +0.00%

The godoc binary is ~0.12% smaller after this CL.

Updates #5729.

toolstash -cmp passes for all architectures other than amd64 and amd64p32.

Other architectures can be done in follow-up CLs.

Change-Id: I0e167e259274b722958567fc0af83a17ca002da7
Reviewed-on: https://go-review.googlesource.com/2284
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17 20:12:18 +00:00
Ian Lance Taylor
9c1868d06d runtime: add -buildmode=c-archive/c-shared support for linux/386
Change-Id: I87147ca6bb53e3121cc4245449c519509f107638
Reviewed-on: https://go-review.googlesource.com/9009
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-17 19:31:37 +00:00
Russ Cox
17228f44b2 cmd/internal/gc: make use of new String methods in prints
$ sam -d cmd/internal/gc/*.{go,y} cmd/?g/*.go
X ,s/, (gc\.)?[BFHNST]conv\(([^()]+), 0\)/, \2/g
X/'/w
q
$

Change-Id: Ic28a4807d237b8ae53ceca1e4e7fdb43580ab560
Reviewed-on: https://go-review.googlesource.com/9032
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2015-04-17 19:29:25 +00:00
Russ Cox
96c91fa9db cmd/internal/gc: add String methods to *Mpint, *Mpflt, *Node, *NodeList, *Sym, *Type
The next CL will remove unnecessary conv calls.

Change-Id: I0e8dbd1756cdec1ef6095ae67629cd3fae0fb4a4
Reviewed-on: https://go-review.googlesource.com/9031
Reviewed-by: Austin Clements <austin@google.com>
2015-04-17 19:29:15 +00:00
Ian Lance Taylor
449969a4ac cmd/internal/ld, cmd/dist: support -buildmode=c-archive on linux
Change-Id: I8c97751a79b57197428b0f0b66fc9575708a2eb0
Reviewed-on: https://go-review.googlesource.com/8979
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-17 18:35:53 +00:00
Rob Pike
2807572ab0 cmd/go: implement the long-promised -run flag for go generate
Trivial to do, but overlooked for 1.4, which is good because I prefer
the new design, which is just to match against the source code of
the line rather than the command word alone.

Change-Id: Idcf7c4479e97bb7cd732f0d058012321b6057628
Reviewed-on: https://go-review.googlesource.com/9005
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17 17:49:14 +00:00
Brad Fitzpatrick
27067df9db cmd/internal/obj: cleanups from C transition and delete dead code
Change-Id: Id1ecad2565edd5937a764dcf56b89263353f47c2
Reviewed-on: https://go-review.googlesource.com/8947
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-17 17:28:17 +00:00
Russ Cox
a5e48cf023 cmd/internal/gc: fix node print
Change-Id: I0d2b909ceeba9da86c77de4ce23d7c6063f8f10f
Reviewed-on: https://go-review.googlesource.com/9017
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-17 14:57:51 +00:00
Josh Bleecher Snyder
4a7e5bca3c cmd/internal/gc: clean up bgen
This cleanup is in anticipation of implementing
jump-free booleans (CL 2284) and zero-aware
comparisons (issue 10381).

No functional changes. Passes toolstash -cmp.

Change-Id: I50f394c60fa2927e177d7fc85b75085060a9e912
Reviewed-on: https://go-review.googlesource.com/8738
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17 03:25:21 +00:00
Keith Randall
d2fd43aa77 [dev.ssa] cmd/internal/gc: convert standard IR into SSA.
Hook into the current compiler to convert the existing
IR (after walk) into SSA.  Any function ending in "_ssa"
will take this path.  The resulting assembly is printed
and then discarded.

Use gc.Type directly in ssa instead of a wrapper for go types.
It makes the IR->SSA rewrite a lot simpler.

Only a few opcodes are implemented in this change.  It is
enough to compile simple examples like
    func f(p *int) int { return *p }
    func g(a []int, i int) int { return a[i] }

Change-Id: I5e18841b752a83ca0519aa1b2d36ef02ce1de6f9
Reviewed-on: https://go-review.googlesource.com/8971
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-04-16 22:31:05 +00:00
David Crawshaw
46b4f675bf cmd/internal/ld: use usual flooding for c-archive
I said I removed this from cl/8711 in response to your comment, but
apparently I did not.

misc/cgo/testcarchive continues to pass on darwin/amd64.

Change-Id: I6410782f2a78bf117741628fb71cac56e289b590
Reviewed-on: https://go-review.googlesource.com/9010
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-16 20:01:13 +00:00
Michael Hudson-Doyle
62353ff876 cmd/go: have go run, go list respect -buildmode/-linkshared
Change-Id: I749fd91cd3c7581cdcc97a15e8eeee0c20f0b259
Reviewed-on: https://go-review.googlesource.com/8805
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-16 19:25:32 +00:00
Michael Hudson-Doyle
2f0828ef7c reflect, cmd/internal/gc: look for pointer types by string before synthesizing
The ptrto field of the type data cannot be relied on when dynamic linking: a
type T may be defined in a module that makes no use of pointers to that type,
but another module can contain a package that imports the first one and does use
*T pointers.  The second module will end up defining type data for *T and a
type.*T symbol pointing at it. It's important that calling .PtrTo() on the
refect.Type for T returns this type data and not some synthesized object, so we
need reflect to be able to find it!

Fortunately, the reflect package already has a mechanism for doing this sort of
thing: ChanOf/MapOf/etc look for pre-existing type data by name.  So this change
just extends PtrTo() to consult this too, and changes the compiler to include
pointer types in the data consulted when compiling for dynamic linking.

Change-Id: I3773c066fd0679a62e9fc52a84bf64f1d67662b7
Reviewed-on: https://go-review.googlesource.com/8232
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-04-16 16:11:07 +00:00
Josh Bleecher Snyder
e040fd4654 cmd/internal/gc: registerize more in 7g and 9g
7g and 9g disagree with componentgen
about what type len and cap have.

This results in an etype mismatch,
which inhibits registerization.

Fixing this results in 7406 more registerizations
while building the stdlib.
There are still 1512 missed opportunities.

This should improve the performance benefit
to 7g of enabling componentgen (CL 8636).

This CL reduces the size of godoc by 203k (-1.177%).

This was discovered by using the diagnostics
added in CL 8732 and running:

GOARCH=arm64 GOOS=linux go build -gcflags="-d registerization" std

See CL 91850043 for similar earlier fixes for 6g and 8g.

Change-Id: I57f478228a000ad7529d4136bad94a51343c4daa
Reviewed-on: https://go-review.googlesource.com/8733
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Keith Randall <khr@golang.org>
2015-04-16 15:50:37 +00:00
Aram Hăvărneanu
8262a8fbef cmd/7g: change CHECKNIL sequence
We can use CBNZ instruction and make it one instruction shorter.

Saves 66kB in godoc.

Change-Id: Ie71fe7cf31e7f73644ee926f4f9624c009c3eb1a
Reviewed-on: https://go-review.googlesource.com/8634
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-16 13:31:16 +00:00
Aram Hăvărneanu
a6bade60b0 cmd/7g: remove loads that only load an immediate to be later used by ADD/SUB
Optimize the sequence:
	MOV $imm, Rt
	ADD Rt, Rs, Rd

into:
	ADD $imm, Rs, Rd

Saves 66k in godoc.

Change-Id: I27b4aaa0ec80a59472fe2e5816efdf3db9c901ee
Reviewed-on: https://go-review.googlesource.com/8632
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-16 13:31:02 +00:00
Shenghou Ma
4fd9a3fdbb cmd/internal/obj, cmd/internal/ld, cmd/7l: external linking for darwin/arm64
Change-Id: I3b3f80791a1db4c2b7318f81a115972cd2237f02
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8781
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-16 05:13:06 +00:00
Shenghou Ma
909bdf56d6 cmd/7g: disable duff's device on darwin
ld64 cannot handle BR26 reloc with non-zero addend. It incorrectly
thinks that non-zero addend for BR26 means the code is not PIC, but
those BR26 relocs should be fully resolved at link time.

Change-Id: I3b3f80791a1db4c2b7318f81a115972cd2237f01
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8780
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-16 05:12:45 +00:00
Shenghou Ma
72f8102244 cmd/internal/obj/arm64: add SVC to unary destination list
To support "SVC $0x80", which is needed for darwin/arm64.

Change-Id: I3b3f80791a1db4c2b7318f81a115972cd2237f00
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8769
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-16 05:12:28 +00:00
Dave Day
e1c1fa2919 reflect: add FuncOf function
This also involves adding functions to typelinks along with a minor
change to ensure they are sorted correctly.

Change-Id: I054a79b6498a634cbccce17579f52c299733c2cf
Reviewed-on: https://go-review.googlesource.com/1996
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-16 01:38:50 +00:00
Michael Hudson-Doyle
f616af23e0 cmd/6l: call runtime.addmoduledata from .init_array
Change-Id: I09e84161d106960a69972f5fc845a1e40c28e58f
Reviewed-on: https://go-review.googlesource.com/8331
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-15 23:54:20 +00:00
Michael Hudson-Doyle
725cd2ea72 cmd/go: support -buildmode=shared
You can now do 'go install -buildmode=shared std' and get yourself
a nice (33 meg) libstd.so (which is not useful until there is -linkshared
support as well, of course).

Change-Id: Ie9b7e7f72abc7d369a6e3ecc98903a9d197bd6e6
Reviewed-on: https://go-review.googlesource.com/8300
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-15 23:53:32 +00:00
David Crawshaw
07f00cf11e cmd/test: require external linking for c-archive
Change-Id: I9ceceb29291ea9f5d7b675dfabd665c5e3618471
Reviewed-on: https://go-review.googlesource.com/8955
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-15 22:46:47 +00:00
Michael Hudson-Doyle
5f41819593 cmd/go, go/build: add build.Package.PkgTargetRoot
This is $GOPATH/pkg/linux_amd64 or similar.  cmd/go already had a grotty calculation
of this and I need to add another one for -buildmode=shared.

Change-Id: Ied28c9b7cce671da8d45920e124a3e0c2501258a
Reviewed-on: https://go-review.googlesource.com/8930
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-15 22:45:43 +00:00
Michael Hudson-Doyle
fd0419b344 cmd/internal/ld: allow -r to override rpath when -linkshared
Including having -r "" preventing rpath from being set at all.

Change-Id: Ib40d7bf93a6e9ef21985c4a05b5703e4fbd1cd1b
Reviewed-on: https://go-review.googlesource.com/8806
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-15 22:06:04 +00:00
Josh Bleecher Snyder
7e0c11c32f cmd/6g, runtime: improve duffzero throughput
It is faster to execute

	MOVQ AX,(DI)
	MOVQ AX,8(DI)
	MOVQ AX,16(DI)
	MOVQ AX,24(DI)
	ADDQ $32,DI

than

	STOSQ
	STOSQ
	STOSQ
	STOSQ

However, in order to be able to jump into
the middle of a block of MOVQs, the call
site needs to pre-adjust DI.

If we're clearing a small area, the cost
of that DI pre-adjustment isn't repaid.

This CL switches the DUFFZERO implementation
to use a hybrid strategy, in which small
clears use STOSQ as before, but large clears
use mostly MOVQ/ADDQ blocks.

benchmark                 old ns/op     new ns/op     delta
BenchmarkClearFat8        0.55          0.55          +0.00%
BenchmarkClearFat12       0.82          0.83          +1.22%
BenchmarkClearFat16       0.55          0.55          +0.00%
BenchmarkClearFat24       0.82          0.82          +0.00%
BenchmarkClearFat32       2.20          1.94          -11.82%
BenchmarkClearFat40       1.92          1.66          -13.54%
BenchmarkClearFat48       2.21          1.93          -12.67%
BenchmarkClearFat56       3.03          2.20          -27.39%
BenchmarkClearFat64       3.26          2.48          -23.93%
BenchmarkClearFat72       3.57          2.76          -22.69%
BenchmarkClearFat80       3.83          3.05          -20.37%
BenchmarkClearFat88       4.14          3.30          -20.29%
BenchmarkClearFat128      5.54          4.69          -15.34%
BenchmarkClearFat256      9.95          9.09          -8.64%
BenchmarkClearFat512      18.7          17.9          -4.28%
BenchmarkClearFat1024     36.2          35.4          -2.21%

Change-Id: Ic786406d9b3cab68d5a231688f9e66fcd1bd7103
Reviewed-on: https://go-review.googlesource.com/2585
Reviewed-by: Keith Randall <khr@golang.org>
2015-04-15 19:17:07 +00:00
Josh Bleecher Snyder
5ed90cbbb0 cmd/internal/gc, cmd/gc: move Reg from Val to Node
Val is used to hold constant values.
Reg was the odd duck out.

Generated using eg.

No functional changes. Passes toolstash -cmp.

Change-Id: Ic1de769a1f92bb02e09a4428d998b716f307e2f6
Reviewed-on: https://go-review.googlesource.com/8912
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-15 19:02:10 +00:00
Michael Hudson-Doyle
f7be77e5b6 cmd/dist: fix bootstrapping with gccgo on 386
We forgot to add the !gccgo tag to cpuid_386.s.

Change-Id: I2de2ed92ac9686c9365cb37cd29121fa98c2bf37
Reviewed-on: https://go-review.googlesource.com/8960
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-15 16:58:19 +00:00
Dave Cheney
888d44d3c1 cmd/internal/gc, cmd/7g: use zero register in Componentgen
Fixes #9855

Use an architectural zero register as the source for zeroing, if available.

Change-Id: Ie5b4ba4e3d356c6f892bfd1cebd14d5152bdeeb0
Reviewed-on: https://go-review.googlesource.com/8722
Reviewed-by: Keith Randall <khr@golang.org>
2015-04-15 12:26:24 +00:00
Robert Griesemer
e5b76747c9 go/importer: added go/importer package, adjusted go/types
- The go/importer package provides access to compiler-specific importers.
- Adjusted go/internal/gcimporter and go/types as needed.
- types.Check was removed - not much simpler than calling types.Config.Check.
- Package "unsafe" is now handled by the type checker; importers are not
  called for it anymore.
- In std lib tests, re-use importer for faster testing
  (no need to re-import previously imported packages).
- Minor cleanups.

The code still needs cleanups before submitting.

Change-Id: Idd456da2e9641688fe056504367348926feb0755
Reviewed-on: https://go-review.googlesource.com/8767
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
2015-04-15 02:28:53 +00:00
Josh Bleecher Snyder
e7fe9f56ea cmd/internal/gc: convert Bval to bool
No functional changes. Passes toolstash -cmp.

Change-Id: I4fba0c248645c3910ee3f7fc99dacafb676c5dc2
Reviewed-on: https://go-review.googlesource.com/8911
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-14 23:55:51 +00:00
Rob Pike
eba38fd780 cmd/go: do not cover package unsafe
Even if requested, there is no .go file for unsafe - it comes from the
compiler - so referencing its cover variables will break the compilation
in a command like
	go test -coverpkg=all fmt

Fixes #10408.

Change-Id: If92658ef6c29dc020f66ba30b02eaa796f7205e0
Reviewed-on: https://go-review.googlesource.com/8891
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-14 17:07:34 +00:00
Dmitry Vyukov
24f246c1b6 cmd/gc: fix crash during escape analysis
Fixes #10441

Compiler crashed as:

panic: runtime error: invalid memory address or nil pointer dereference
goroutine 1 [running]:
cmd/internal/gc.haspointers(0x0, 0xffffffffffffffff)
    src/cmd/internal/gc/reflect.go:623 +0x1f
cmd/internal/gc.escwalk(0x20c82dc00, 0xffffffffffffffff, 0x20c82dda0, 0x20c835520)
    src/cmd/internal/gc/esc.go:1291 +0x14aa
cmd/internal/gc.escwalk(0x20c82dc00, 0xffffffffffffffff, 0x20c82dda0, 0x20beac340)
    src/cmd/internal/gc/esc.go:1386 +0x836

while evaluating haspointers of the fake OADDR node here:

	leaks = level <= 0 && dst.Escloopdepth < src.Escloopdepth || level < 0 && dst == &e.funcParam && haspointers(src.Type)

Change-Id: I13c23fced52e8fcd0ae1df81b374df8632eb7790
Reviewed-on: https://go-review.googlesource.com/8932
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-14 15:45:26 +00:00
Brad Fitzpatrick
8b27d28ed4 cmd/5g, etc: remove outdated float type alias comment
Change-Id: Ie5fe5cf3e2926ba4f91271bd47f3f998c26e003e
Reviewed-on: https://go-review.googlesource.com/8914
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-14 04:41:20 +00:00
Shenghou Ma
ce43e1fec8 cmd/dist: detect sse2 even with gccgo
Change-Id: Idfb20bfe130d9a54d9f5aae8eab8a34655d30610
Reviewed-on: https://go-review.googlesource.com/8865
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-13 23:27:35 +00:00
Srdjan Petrovic
41e9f8c4ed cmd: -buildmode=c-shared for linux/arm
Already supported platforms are linux/amd64 and android/arm.

Running -buildmode=c-shared on linux/arm is equivalent to:
  -ldflags "-shared" -asmflags "-shared"

Change-Id: Ifdb267f1d6508157f236be912fa369440172d161
Reviewed-on: https://go-review.googlesource.com/8895
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-13 23:25:12 +00:00
Dave Cheney
67805eaa95 cmd/dist: use gccgo as bootstrap compiler
Fixes #10092

This change makes it possible to use gccgo 5 as the GOROOT_BOOTSTRAP
compiler.

Change-Id: Ie3a312781ac1a09ea77f95b5a78c9488d437e0aa
Reviewed-on: https://go-review.googlesource.com/8809
Run-TryBot: Dave Cheney <dave@cheney.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-13 19:10:16 +00:00
David Crawshaw
fdab2f92ea misc/cgo/testcarchive: test -buildmode=c-archive
Change-Id: I1668a6885c45180ff88fe673d04cec7eba395ee7
Reviewed-on: https://go-review.googlesource.com/8861
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-13 18:31:07 +00:00
David Crawshaw
9725f2258b cmd/go: -buildmode=c-archive support
Change-Id: I469254384b0f4e5b5f08a18658934e19259935f9
Reviewed-on: https://go-review.googlesource.com/8718
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-13 13:21:20 +00:00
David Crawshaw
4c1ee3ea88 cmd/objdump: skip fork test on darwin/arm64
Just like darwin/arm.

Change-Id: Ibaba67980db6e05aa71568199b2dac2fcaa86fd6
Reviewed-on: https://go-review.googlesource.com/8824
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-13 12:03:36 +00:00
David Crawshaw
d5bb4380c8 cmd/pack: skip fork test on darwin/arm64
Just like darwin/arm.

Change-Id: I5ed26975670d4189a46b585a56c66c199905d168
Reviewed-on: https://go-review.googlesource.com/8823
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-13 11:58:27 +00:00