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

4981 Commits

Author SHA1 Message Date
Rob Pike
74c9cc8394 cmd/ld: use count, not upper bound, in type of array
DWARF says only one is necessary.
The count is preferable because it admits 0-length arrays.
Update debug/dwarf to handle either form.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/111230044
2014-07-16 18:26:50 +00:00
Yasuhiro Matsumoto
59af2c647b cmd/go/doc: Fix example domain
code.org exists

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/95500043
2014-07-16 20:48:57 +10:00
Rob Pike
cddad8affe cmd/ld: change DWARF encoding for array lengths
They can be large, so use a varint encoding rather than only one byte.

LGTM=iant, rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/113180043
2014-07-15 21:18:18 +00:00
Matthew Dempsky
6012ac9b79 cmd/ld: consistently document flags that expect values
LGTM=minux, rsc
R=golang-codereviews, minux, rsc
CC=golang-codereviews
https://golang.org/cl/113970044
2014-07-15 17:05:35 -04:00
Matthew Dempsky
348a20548d objdump: remove out-of-date comment
LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/112320043
2014-07-15 06:03:36 -07:00
Dave Cheney
c213b8864f cmd/go: skip vcs tests on nacl and android
Fixes build failures on nacl/* and android/* platforms.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/113140043
2014-07-15 14:45:59 +10:00
Rob Pike
79b106ec62 cmd/ld: generate correct upper bound value for array types.
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/115820043
2014-07-15 01:38:05 +00:00
Chris McGee
fd7b82b4e4 go get: Support for IBM DevOps Services (hub.jazz.net) git repos
LGTM=adg
R=golang-codereviews, adg, minux
CC=golang-codereviews
https://golang.org/cl/106740044
2014-07-15 11:27:04 +10:00
Peter Collingbourne
8b836fa872 cmd/go: introduce support for $GCCGO env var
This variable allows users to select the compiler when using the
gccgo toolchain.

LGTM=rsc
R=rsc, iant, minux, aram
CC=axwalk, golang-codereviews
https://golang.org/cl/106700044
2014-07-14 09:51:20 -04:00
Russ Cox
e1821692ca cmd/ld: add go-specific dwarf type information
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/116720043
2014-07-11 23:10:00 -04:00
Rob Pike
125d1e9269 ld: change DWARF output for structs
The debug/dwarf package cannot parse the format generated here,
but the format can be changed so it does.
After this edit, tweaking the expression defining the offset
of a struct field, the dwarf package can parse the tables (again?).

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/105710043
2014-07-11 15:16:00 +00:00
Benny Siegert
0e694298e9 cmd/go: do not fail if libgcc does not exist
(This is a patch from the pkgsrc Go package.)

LGTM=iant
R=golang-codereviews, iant, joerg.sonnenberger, dave
CC=golang-codereviews, joerg
https://golang.org/cl/108340043
2014-07-10 14:35:04 -07:00
Shenghou Ma
366f88f3e4 cmd/dist: always use GOARM=7 for nacl/arm
LGTM=dave, rsc
R=rsc, iant, dave
CC=golang-codereviews
https://golang.org/cl/101590044
2014-07-10 15:15:24 -04:00
Shenghou Ma
783bcba84d cmd/5c, cmd/5g, cmd/5l, liblink: nacl/arm support
LGTM=dave, rsc
R=rsc, iant, dave
CC=golang-codereviews
https://golang.org/cl/108360043
2014-07-10 15:14:37 -04:00
Peter Collingbourne
5512f6f3b3 cmd/go: use $CC to build _cgo_defun.c
LGTM=dave, iant
R=iant, dave
CC=golang-codereviews
https://golang.org/cl/112000043
2014-07-09 10:04:38 -07:00
Aram Hăvărneanu
0a2083edd7 debug/plan9obj, cmd/addr2line: on Plan 9 use a.out header
size instead of abusing text symbol

cmd/addr2line needs to know the virtual address of the start
of the text segment (load address plus header size). For
this, it used the text symbol added by the linker. This is
wrong on amd64. Header size is 40 bytes, not 32 like on 386
and arm. Function alignment is 16 bytes causing text to be
at 0x200030.

debug/plan9obj now exports both the load address and the
header size; cmd/addr2line uses this new information and
doesn't rely on text anymore.

LGTM=0intro
R=0intro, gobot, ality
CC=ality, golang-codereviews, jas, mischief
https://golang.org/cl/106460044
2014-07-09 12:33:13 +02:00
Aram Hăvărneanu
fa113cf767 cmd/objdump: set goarch properly on non-386 Plan 9 systems
LGTM=0intro, r
R=0intro, r
CC=ality, golang-codereviews, jas, mischief
https://golang.org/cl/108420043
2014-07-09 12:32:49 +02:00
Dmitri Shuralyov
3e801416ce cmd/go: fix build -o panic when import path pattern matches 0 pkgs
Fixes #8165.

After this change, the panic is replaced by a message:

        $ go build -o out ...doesntexist
        warning: "...doesntexist" matched no packages
        no packages to build

The motivation to return 1 exit error code is to allow -o flag
to be used to guarantee that the output binary is written to
when exit status is 0. If someone uses an import path pattern
to specify a single package and suddenly that matches no packages,
it's better to return exit code 1 instead of silently doing nothing.
This is consistent with the case when -o flag is given and multiple
packages are matched.
It's also somewhat consistent with the current behavior with the
panic, except that gave return code 2. But it's similar in
that it's also non-zero (indicating failure).
I've changed the language to be similar to output of go test
when an import path pattern matches no packages (it also has a return status of
1):

        $ go test ...doesntexist
        warning: "...doesntexist" matched no packages
        no packages to test

LGTM=adg
R=golang-codereviews, josharian, gobot, adg
CC=golang-codereviews
https://golang.org/cl/107140043
2014-07-09 13:17:27 +10:00
David Crawshaw
331bf64d17 cmd/addr2line: skip test on android
LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/104600043
2014-07-08 13:45:31 -04:00
David Crawshaw
4e0214eb8e cmd/pack: skip test on android (no Go tool)
LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/107600043
2014-07-08 13:45:06 -04:00
David Crawshaw
b157077e34 cmd/nm: skip test on android (no Go tool)
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/107590043
2014-07-08 13:44:41 -04:00
David Crawshaw
8543ed3df5 cmd/objdump: skip test on android (no Go tool)
LGTM=minux, iant
R=golang-codereviews, minux, iant
CC=golang-codereviews
https://golang.org/cl/109570043
2014-07-08 13:43:22 -04:00
Rob Pike
7b0ee53429 cmd/ld: fix off-by-one in DWARF frame tables
The code generating the .debug_frame section emits pairs of "advance PC",
"set SP offset" pseudo-instructions. Before the fix, the PC advance comes
out before the SP setting, which means the emitted offset for a block is
actually the value at the end of the block, which is incorrect for the
block itself.

The easiest way to fix this problem is to emit the SP offset before the
PC advance.

One delicate point: the last instruction to come out is now an
"advance PC", which means that if there are padding intsructions after
the final RET, they will appear to have a non-zero offset. This is odd
but harmless because there is no legal way to have a PC in that range,
or to put it another way, if you get here the SP is certainly screwed up
so getting the wrong (virtual) frame pointer is the least of your worries.

LGTM=iant
R=rsc, iant, lvd
CC=golang-codereviews
https://golang.org/cl/112750043
2014-07-07 16:07:24 -07:00
David Crawshaw
12b990ba7d cmd/go, cmd/ld, runtime, os/user: TLS emulation for android
Based on cl/69170045 by Elias Naur.

There are currently several schemes for acquiring a TLS
slot to save the g register. None of them appear to work
for android. The closest are linux and darwin.

Linux uses a linker TLS relocation. This is not supported
by the android linker.

Darwin uses a fixed offset, and calls pthread_key_create
until it gets the slot it wants. As the runtime loads
late in the android process lifecycle, after an
arbitrary number of other libraries, we cannot rely on
any particular slot being available.

So we call pthread_key_create, take the first slot we are
given, and put it in runtime.tlsg, which we turn into a
regular variable in cmd/ld.

Makes android/arm cgo binaries work.

LGTM=minux
R=elias.naur, minux, dave, josharian
CC=golang-codereviews
https://golang.org/cl/106380043
2014-07-03 16:14:34 -04:00
Russ Cox
ebce79446d build: annotations and modifications for c2go
The main changes fall into a few patterns:

1. Replace #define with enum.

2. Add /*c2go */ comment giving effect of #define.
This is necessary for function-like #defines and
non-enum-able #defined constants.
(Not all compilers handle negative or large enums.)

3. Add extra braces in struct initializer.
(c2go does not implement the full rules.)

This is enough to let c2go typecheck the source tree.
There may be more changes once it is doing
other semantic analyses.

LGTM=minux, iant
R=minux, dave, iant
CC=golang-codereviews
https://golang.org/cl/106860045
2014-07-02 15:41:29 -04:00
David Crawshaw
a36348008c all: add GOOS=android
As android and linux have significant overlap, and
because build tags are a poor way to represent an
OS target, this CL introduces an exception into
go/build: linux is treated as a synonym for android
when matching files.

http://golang.org/s/go14android
https://groups.google.com/forum/#!topic/golang-dev/P1ATVp1mun0

LGTM=rsc, minux
R=golang-codereviews, mikioh.mikioh, dave, aram, minux, gobot, rsc, aram.h, elias.naur, iant
CC=golang-codereviews, rsc
https://golang.org/cl/105270043
2014-07-01 17:21:50 -04:00
Robert Griesemer
dddc8b193f cmd/gofmt: fix gofmt -s for 3-index slices
3-index slices of the form s[:len(s):len(s)]
cannot be simplified to s[::len(s)].

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/108330043
2014-07-01 10:40:27 -07:00
Simon Whitehead
138099ae96 gofmt/main: Added removal of empty declaration groups.
Fixes #7631.

LGTM=gri
R=golang-codereviews, bradfitz, gri
CC=golang-codereviews
https://golang.org/cl/101410046
2014-07-01 09:32:03 -07:00
Rémy Oudompheng
1ec56062ef cmd/8g: don't allocate a register early for cap(CHAN).
There is no reason to generate different code for cap and len.

Fixes #8025.
Fixes #8026.

LGTM=rsc
R=rsc, iant, khr
CC=golang-codereviews
https://golang.org/cl/93570044
2014-07-01 09:20:51 +02:00
Robert Griesemer
6a22823939 gofmt: remove redundant check in rewriter
If the actual types of two reflect values are
the same and the values are structs, they must
have the same number of fields.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/108280043
2014-06-30 14:40:12 -07:00
Andrew Gerrand
ea0fb5d8e2 cmd/go: build non-runnable examples in xtests
Include these files in the build,
even though they don't get executed.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/108180043
2014-06-28 07:15:22 +10:00
Evan Kroske
9e04ff7953 cmd/gc: moved usefield to correct section of go.h, from "reflect.c" to "walk.c".
LGTM=iant
R=golang-codereviews, gobot, iant, dave
CC=golang-codereviews
https://golang.org/cl/108990044
2014-06-26 10:02:16 -07:00
Russ Cox
89f185fe8a all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).

This CL removes the extern register m; code now uses g->m.

On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.

The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:

BenchmarkBinaryTree17              5491374955     5471024381     -0.37%
BenchmarkFannkuch11                4357101311     4275174828     -1.88%
BenchmarkGobDecode                 11029957       11364184       +3.03%
BenchmarkGobEncode                 6852205        6784822        -0.98%
BenchmarkGzip                      650795967      650152275      -0.10%
BenchmarkGunzip                    140962363      141041670      +0.06%
BenchmarkHTTPClientServer          71581          73081          +2.10%
BenchmarkJSONEncode                31928079       31913356       -0.05%
BenchmarkJSONDecode                117470065      113689916      -3.22%
BenchmarkMandelbrot200             6008923        5998712        -0.17%
BenchmarkGoParse                   6310917        6327487        +0.26%
BenchmarkRegexpMatchMedium_1K      114568         114763         +0.17%
BenchmarkRegexpMatchHard_1K        168977         169244         +0.16%
BenchmarkRevcomp                   935294971      914060918      -2.27%
BenchmarkTemplate                  145917123      148186096      +1.55%

Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.

Actual code changes by Minux.
I only did the docs and the benchmarking.

LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 11:54:39 -04:00
Russ Cox
2565b5c060 cmd/gc: drop parenthesization restriction for receiver types
Matches CL 101500044.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/110160044
2014-06-25 09:57:48 -04:00
Andrew Gerrand
da1c2b182a undo CL 107320046 / 97cd07dcb9d8
Breaks the build

««« original CL description
cmd/go: build test files containing non-runnable examples

Even if we can't run them, we should at least check that they compile.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/107320046
»»»

TBR=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/110140044
2014-06-25 12:04:36 +10:00
Andrew Gerrand
eb4c3455de cmd/go: build test files containing non-runnable examples
Even if we can't run them, we should at least check that they compile.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/107320046
2014-06-25 08:22:22 +10:00
Dmitriy Vyukov
f1f37f93d0 runtime/race: support freebsd
All tests pass except one test in regexp package.

LGTM=iant
R=golang-codereviews, iant, dave
CC=golang-codereviews
https://golang.org/cl/107270043
2014-06-20 20:20:56 -04:00
Keith Randall
5ce6d3e03e undo CL 105260044 / afd6f214cc81
The go:nosplit change wasn't the problem, reinstating.

««« original CL description
undo CL 93380044 / 7f0999348917

Partial undo, just of go:nosplit annotation.  Somehow it
is breaking the windows builders.

TBR=bradfitz

««« original CL description
runtime: implement string ops in Go

Also implement go:nosplit annotation.  Not really needed
for now, but we'll definitely need it for other conversions.

benchmark                 old ns/op     new ns/op     delta
BenchmarkRuneIterate      534           474           -11.24%
BenchmarkRuneIterate2     535           470           -12.15%

LGTM=bradfitz
R=golang-codereviews, dave, bradfitz, minux
CC=golang-codereviews
https://golang.org/cl/93380044
»»»

TBR=bradfitz
CC=golang-codereviews
https://golang.org/cl/105260044
»»»

TBR=bradfitz
R=bradfitz, golang-codereviews
CC=golang-codereviews
https://golang.org/cl/103490043
2014-06-17 08:10:21 -07:00
Keith Randall
ee8e687874 undo CL 93380044 / 7f0999348917
Partial undo, just of go:nosplit annotation.  Somehow it
is breaking the windows builders.

TBR=bradfitz

««« original CL description
runtime: implement string ops in Go

Also implement go:nosplit annotation.  Not really needed
for now, but we'll definitely need it for other conversions.

benchmark                 old ns/op     new ns/op     delta
BenchmarkRuneIterate      534           474           -11.24%
BenchmarkRuneIterate2     535           470           -12.15%

LGTM=bradfitz
R=golang-codereviews, dave, bradfitz, minux
CC=golang-codereviews
https://golang.org/cl/93380044
»»»

TBR=bradfitz
CC=golang-codereviews
https://golang.org/cl/105260044
2014-06-16 23:51:18 -07:00
Shenghou Ma
e9da5fe279 cmd/5c, cmd/6c, cmd/8c, cmd/cc: remove unused global variable retok.
LGTM=bradfitz
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/107160046
2014-06-17 02:05:27 -04:00
Keith Randall
61dca94e10 runtime: implement string ops in Go
Also implement go:nosplit annotation.  Not really needed
for now, but we'll definitely need it for other conversions.

benchmark                 old ns/op     new ns/op     delta
BenchmarkRuneIterate      534           474           -11.24%
BenchmarkRuneIterate2     535           470           -12.15%

LGTM=bradfitz
R=golang-codereviews, dave, bradfitz, minux
CC=golang-codereviews
https://golang.org/cl/93380044
2014-06-16 23:03:03 -07:00
Russ Cox
f20e4d5ecb cmd/gc: fix &result escaping into result
There is a hierarchy of location defined by loop depth:

        -1 = the heap
        0 = function results
        1 = local variables (and parameters)
        2 = local variable declared inside a loop
        3 = local variable declared inside a loop inside a loop
        etc

In general if an address from loopdepth n is assigned to
something in loop depth m < n, that indicates an extended
lifetime of some form that requires a heap allocation.

Function results can be local variables too, though, and so
they don't actually fit into the hierarchy very well.
Treat the address of a function result as level 1 so that
if it is written back into a result, the address is treated
as escaping.

Fixes #8185.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/108870044
2014-06-11 14:21:06 -04:00
Russ Cox
775ab8eeaa cmd/gc: fix escape analysis for &x inside switch x := v.(type)
The analysis for &x was using the loop depth on x set
during x's declaration. A type switch creates a list of
implicit declarations that were not getting initialized
with loop depths.

Fixes #8176.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/108860043
2014-06-11 11:48:47 -04:00
Ian Lance Taylor
507afa68c5 cmd/ld: fix PC deltas in DWARF line number table
The putpclcdelta function set the DWARF line number PC to
s->value + pcline->pc, which is correct, but the code then set
the local variable pc to epc, which can be a different value.
This caused the next delta in the DWARF table to be wrong.

Fixes #8098.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/104950045
2014-06-10 14:11:39 -07:00
Russ Cox
ac0e12d158 cmd/6g: fix stack zeroing on native client
I am not sure what the rounding here was
trying to do, but it was skipping the first
pointer on native client.

The code above the rounding already checks
that xoffset is widthptr-aligned, so the rnd
was a no-op everywhere but on Native Client.
And on Native Client it was wrong.

Perhaps it was supposed to be rounding down,
not up, but zerorange handles the extra 32 bits
correctly, so the rnd does not seem to be necessary
at all.

This wouldn't be worth doing for Go 1.3 except
that it can affect code on the playground.

Fixes #8155.

LGTM=r, iant
R=golang-codereviews, r, iant
CC=dvyukov, golang-codereviews, khr
https://golang.org/cl/108740047
2014-06-05 16:40:23 -04:00
Ian Lance Taylor
c22ed1290c cmd/cgo: for typedef of untagged struct, use typedef name in C code
Fixes #8148.

LGTM=cookieo9, rsc
R=rsc, cookieo9
CC=golang-codereviews
https://golang.org/cl/103080043
2014-06-05 10:42:03 -07:00
Russ Cox
fe3c913443 cmd/gc: fix escape analysis of func returning indirect of parameter
I introduced this bug when I changed the escape
analysis to run in phases based on call graph
dependency order, in order to be more precise about
inputs escaping back to outputs (functions returning
their arguments).

Given

        func f(z **int) *int { return *z }

we were tagging the function as 'z does not escape
and is not returned', which is all true, but not
enough information.

If used as:

        var x int
        p := &x
        q := &p
        leak(f(q))

then the compiler might try to keep x, p, and q all
on the stack, since (according to the recorded
information) nothing interesting ends up being
passed to leak.

In fact since f returns *q = p, &x is passed to leak
and x needs to be heap allocated.

To trigger the bug, you need a chain that the
compiler wants to keep on the stack (like x, p, q
above), and you need a function that returns an
indirect of its argument, and you need to pass the
head of the chain to that function. This doesn't
come up very often: this bug has been present since
June 2012 (between Go 1 and Go 1.1) and we haven't
seen it until now. It helps that most functions that
return indirects are getters that are simple enough
to be inlined, avoiding the bug.

Earlier versions of Go also had the benefit that if
&x really wasn't used beyond x's lifetime, nothing
broke if you put &x in a heap-allocated structure
accidentally. With the new stack copying, though,
heap-allocated structures containing &x are not
updated when the stack is copied and x moves,
leading to crashes in Go 1.3 that were not crashes
in Go 1.2 or Go 1.1.

The fix is in two parts.

First, in the analysis of a function, recognize when
a value obtained via indirect of a parameter ends up
being returned. Mark those parameters as having
content escape back to the return results (but we
don't bother to write down which result).

Second, when using the analysis to analyze, say,
f(q), mark parameters with content escaping as
having any indirections escape to the heap. (We
don't bother trying to match the content to the
return value.)

The fix could be less precise (simpler).
In the first part we might mark all content-escaping
parameters as plain escaping, and then the second
part could be dropped. Or we might assume that when
calling f(q) all the things pointed at by q escape
always (for any f and q).

The fix could also be more precise (more complex).
We might record the specific mapping from parameter
to result along with the number of indirects from the
parameter to the thing being returned as the result,
and then at the call sites we could set up exactly the
right graph for the called function. That would make
notleaks(f(q)) be able to keep x on the stack, because
the reuslt of f(q) isn't passed to anything that leaks it.

The less precise the fix, the more stack allocations
become heap allocations.

This fix is exactly as precise as it needs to be so that
none of the current stack allocations in the standard
library turn into heap allocations.

Fixes #8120.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, khr, r
https://golang.org/cl/102040046
2014-06-03 11:35:59 -04:00
Russ Cox
eb54079264 cmd/gc: fix liveness for address-taken variables in inlined functions
The 'address taken' bit in a function variable was not
propagating into the inlined copies, causing incorrect
liveness information.

LGTM=dsymonds, bradfitz
R=golang-codereviews, bradfitz
CC=dsymonds, golang-codereviews, iant, khr, r
https://golang.org/cl/96670046
2014-06-02 21:26:32 -04:00
Rob Pike
8195ce2b4f cmd/gc: don't generate zillions of linehists for wrapper functions
This is a workaround - the code should be better than this - but the
fix avoids generating large numbers of linehist entries for the wrapper
functions that enable interface conversions. There can be many of
them, they all happen at the end of compilation, and they can all
share a linehist entry.
Avoids bad n^2 behavior in liblink.
Test case in issue 8135 goes from 64 seconds to 2.5 seconds (still bad
but not intolerable).

Fixes #8135.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/104840043
2014-06-02 16:01:53 -07:00
Ian Lance Taylor
4e65f18cae cmd/cgo: use same Go type for typedef to anonymous struct
If we see a typedef to an anonymous struct more than once,
presumably in two different Go files that import "C", use the
same Go type name.

Fixes #8133.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/102080043
2014-06-02 12:55:43 -07:00
Brad Fitzpatrick
98b6410f13 api: add go1.3.txt
Update #8112

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/104790045
2014-06-02 11:45:00 +09:00
Russ Cox
9f2dfb856e cmd/objdump: add arm disassembler
Fixes #7452.

LGTM=minux, iant
R=minux, iant
CC=golang-codereviews
https://golang.org/cl/104770046
2014-06-01 18:53:59 -04:00
Andrew Gerrand
300f3c4913 cmd/dist: only use beta tag in version string for the exact revision
Right now, any revision on the default branch after go1.3beta2 is
described by "go verson" as go1.3beta2 plus some revision.
That's OK for now, but once go1.3 is released, that will seem wrong.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/98650046
2014-06-02 08:48:20 +10:00
Russ Cox
e56dc99665 cmd/gc: fix handling of for post-condition in -race mode
Fixes #8102.

LGTM=bradfitz, dvyukov
R=golang-codereviews, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/100870046
2014-05-31 09:35:54 -04:00
Shenghou Ma
3f66c0c07b cmd/cgo: document the cgo types also follow Go name space rules.
Fixes #7958.

LGTM=rsc
R=golang-codereviews, rsc, r, gobot
CC=golang-codereviews
https://golang.org/cl/91520043
2014-05-31 00:51:46 -07:00
Russ Cox
1afbceb599 cmd/6g: treat vardef-initialized fat variables as live at calls
This CL forces the optimizer to preserve some memory stores
that would be redundant except that a stack scan due to garbage
collection or stack copying might look at them during a function call.
As such, it forces additional memory writes and therefore slows
down the execution of some programs, especially garbage-heavy
programs that are already limited by memory bandwidth.

The slowdown can be as much as 7% for end-to-end benchmarks.

These numbers are from running go1.test -test.benchtime=5s three times,
taking the best (lowest) ns/op for each benchmark. I am excluding
benchmarks with time/op < 10us to focus on macro effects.
All benchmarks are on amd64.

Comparing tip (a27f34c771cb) against this CL on an Intel Core i5 MacBook Pro:

benchmark                          old ns/op      new ns/op      delta
BenchmarkBinaryTree17              3876500413     3856337341     -0.52%
BenchmarkFannkuch11                2965104777     2991182127     +0.88%
BenchmarkGobDecode                 8563026        8788340        +2.63%
BenchmarkGobEncode                 5050608        5267394        +4.29%
BenchmarkGzip                      431191816      434168065      +0.69%
BenchmarkGunzip                    107873523      110563792      +2.49%
BenchmarkHTTPClientServer          85036          86131          +1.29%
BenchmarkJSONEncode                22143764       22501647       +1.62%
BenchmarkJSONDecode                79646916       85658808       +7.55%
BenchmarkMandelbrot200             4720421        4700108        -0.43%
BenchmarkGoParse                   4651575        4712247        +1.30%
BenchmarkRegexpMatchMedium_1K      71986          73490          +2.09%
BenchmarkRegexpMatchHard_1K        111018         117495         +5.83%
BenchmarkRevcomp                   648798723      659352759      +1.63%
BenchmarkTemplate                  112673009      112819078      +0.13%

Comparing tip (a27f34c771cb) against this CL on an Intel Xeon E5520:

BenchmarkBinaryTree17              5461110720     5393104469     -1.25%
BenchmarkFannkuch11                4314677151     4327177615     +0.29%
BenchmarkGobDecode                 11065853       11235272       +1.53%
BenchmarkGobEncode                 6500065        6959837        +7.07%
BenchmarkGzip                      647478596      671769097      +3.75%
BenchmarkGunzip                    139348579      141096376      +1.25%
BenchmarkHTTPClientServer          69376          73610          +6.10%
BenchmarkJSONEncode                30172320       31796106       +5.38%
BenchmarkJSONDecode                113704905      114239137      +0.47%
BenchmarkMandelbrot200             6032730        6003077        -0.49%
BenchmarkGoParse                   6775251        6405995        -5.45%
BenchmarkRegexpMatchMedium_1K      111832         113895         +1.84%
BenchmarkRegexpMatchHard_1K        161112         168420         +4.54%
BenchmarkRevcomp                   876363406      892319935      +1.82%
BenchmarkTemplate                  146273096      148998339      +1.86%

Just to get a sense of where we are compared to the previous release,
here are the same benchmarks comparing Go 1.2 to this CL.

Comparing Go 1.2 against this CL on an Intel Core i5 MacBook Pro:

BenchmarkBinaryTree17              4370077662     3856337341     -11.76%
BenchmarkFannkuch11                3347052657     2991182127     -10.63%
BenchmarkGobDecode                 8791384        8788340        -0.03%
BenchmarkGobEncode                 4968759        5267394        +6.01%
BenchmarkGzip                      437815669      434168065      -0.83%
BenchmarkGunzip                    94604099       110563792      +16.87%
BenchmarkHTTPClientServer          87798          86131          -1.90%
BenchmarkJSONEncode                22818243       22501647       -1.39%
BenchmarkJSONDecode                97182444       85658808       -11.86%
BenchmarkMandelbrot200             4733516        4700108        -0.71%
BenchmarkGoParse                   5054384        4712247        -6.77%
BenchmarkRegexpMatchMedium_1K      67612          73490          +8.69%
BenchmarkRegexpMatchHard_1K        107321         117495         +9.48%
BenchmarkRevcomp                   733270055      659352759      -10.08%
BenchmarkTemplate                  109304977      112819078      +3.21%

Comparing Go 1.2 against this CL on an Intel Xeon E5520:

BenchmarkBinaryTree17              5986953594     5393104469     -9.92%
BenchmarkFannkuch11                4861139174     4327177615     -10.98%
BenchmarkGobDecode                 11830997       11235272       -5.04%
BenchmarkGobEncode                 6608722        6959837        +5.31%
BenchmarkGzip                      661875826      671769097      +1.49%
BenchmarkGunzip                    138630019      141096376      +1.78%
BenchmarkHTTPClientServer          71534          73610          +2.90%
BenchmarkJSONEncode                30393609       31796106       +4.61%
BenchmarkJSONDecode                139645860      114239137      -18.19%
BenchmarkMandelbrot200             5988660        6003077        +0.24%
BenchmarkGoParse                   6974092        6405995        -8.15%
BenchmarkRegexpMatchMedium_1K      111331         113895         +2.30%
BenchmarkRegexpMatchHard_1K        165961         168420         +1.48%
BenchmarkRevcomp                   995049292      892319935      -10.32%
BenchmarkTemplate                  145623363      148998339      +2.32%

Fixes #8036.

LGTM=khr
R=golang-codereviews, josharian, khr
CC=golang-codereviews, iant, r
https://golang.org/cl/99660044
2014-05-30 16:41:58 -04:00
Russ Cox
89d46fed2c cmd/gc: fix x=x crash
[Same as CL 102820043 except applied changes to 6g/gsubr.c
also to 5g/gsubr.c and 8g/gsubr.c. The problem I had last night
trying to do that was that 8g's copy of nodarg has different
(but equivalent) control flow and I was pasting the new code
into the wrong place.]

Description from CL 102820043:

The 'nodarg' function is used to obtain a Node*
representing a function argument or result.
It returned a brand new Node*, but that violates
the guarantee in most places in the compiler that
two Node*s refer to the same variable if and only if
they are the same Node* pointer. Reestablish that
invariant by making nodarg return a preexisting
named variable if present.

Having fixed that, avoid any copy during x=x in
componentgen, because the VARDEF we emit
before the copy marks the lhs x as dead incorrectly.

The change in walk.c avoids modifying the result
of nodarg. This was the only place in the compiler
that did so.

Fixes #8097.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, iant, khr, r
https://golang.org/cl/103750043
2014-05-29 13:47:31 -04:00
Russ Cox
9dd062b82e undo CL 102820043 / b0ce6dbafc18
Breaks 386 and arm builds.
The obvious reason is that this CL only edited 6g/gsubr.c
and failed to edit 5g/gsubr.c and 8g/gsubr.c.
However, the obvious CL applying the same edit to those
files (CL 101900043) causes mysterious build failures
in various of the standard package tests, usually involving
reflect. Something deep and subtle is broken but only on
the 32-bit systems.

Undo this CL for now.

««« original CL description
cmd/gc: fix x=x crash

The 'nodarg' function is used to obtain a Node*
representing a function argument or result.
It returned a brand new Node*, but that violates
the guarantee in most places in the compiler that
two Node*s refer to the same variable if and only if
they are the same Node* pointer. Reestablish that
invariant by making nodarg return a preexisting
named variable if present.

Having fixed that, avoid any copy during x=x in
componentgen, because the VARDEF we emit
before the copy marks the lhs x as dead incorrectly.

The change in walk.c avoids modifying the result
of nodarg. This was the only place in the compiler
that did so.

Fixes #8097.

LGTM=r, khr
R=golang-codereviews, r, khr
CC=golang-codereviews, iant
https://golang.org/cl/102820043
»»»

TBR=r
CC=golang-codereviews, khr
https://golang.org/cl/95660043
2014-05-28 21:46:20 -04:00
Russ Cox
948b2c722b cmd/gc: fix x=x crash
The 'nodarg' function is used to obtain a Node*
representing a function argument or result.
It returned a brand new Node*, but that violates
the guarantee in most places in the compiler that
two Node*s refer to the same variable if and only if
they are the same Node* pointer. Reestablish that
invariant by making nodarg return a preexisting
named variable if present.

Having fixed that, avoid any copy during x=x in
componentgen, because the VARDEF we emit
before the copy marks the lhs x as dead incorrectly.

The change in walk.c avoids modifying the result
of nodarg. This was the only place in the compiler
that did so.

Fixes #8097.

LGTM=r, khr
R=golang-codereviews, r, khr
CC=golang-codereviews, iant
https://golang.org/cl/102820043
2014-05-28 19:50:19 -04:00
Russ Cox
0782ee3ad5 cmd/cgo: given typedef struct S T, make C.T and C.struct_S interchangeable
For incomplete struct S, C.T and C.struct_S were interchangeable in Go 1.2
and earlier, because all incomplete types were interchangeable
(even C.struct_S1 and C.struct_S2).

CL 76450043, which fixed issue 7409, made different incomplete types
different from Go's point of view, so that they were no longer completely
interchangeable.

However, imprecision about C.T and C.struct_S - really the same
underlying C type - is the one behavior enabled by the bug that
is most likely to be depended on by existing cgo code.
Explicitly allow it, to keep that code working.

Fixes #7786.

LGTM=iant, r
R=golang-codereviews, iant, r
CC=golang-codereviews
https://golang.org/cl/98580046
2014-05-28 14:04:31 -04:00
Russ Cox
8a2db409c4 cmd/gc: fix race compilation failure 'non-orig name'
CL 51010045 fixed the first one of these:

        cmd/gc: return canonical Node* from temp

        For historical reasons, temp was returning a copy
        of the created Node*, not the original Node*.
        This meant that if analysis recorded information in the
        returned node (for example, n->addrtaken = 1), the
        analysis would not show up on the original Node*, the
        one kept in fn->dcl and consulted during liveness
        bitmap creation.

        Correct this, and watch for it when setting addrtaken.

        Fixes #7083.

        R=khr, dave, minux.ma
        CC=golang-codereviews
        https://golang.org/cl/51010045

CL 53200043 fixed the second:

        cmd/gc: fix race build

        Missed this case in CL 51010045.

        TBR=khr
        CC=golang-codereviews
        https://golang.org/cl/53200043

This CL fixes the third. There are only three nod(OXXX, ...)
calls in sinit.c, so maybe we're done. Embarassing that it
took three CLs to find all three.

Fixes #8028.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, iant
https://golang.org/cl/100800046
2014-05-27 23:59:27 -04:00
Russ Cox
ceb982e004 cmd/gc: fix defer copy(x, <-c)
In the first very rough draft of the reordering code
that was introduced in the Go 1.3 cycle, the pre-allocated
temporary for a ... argument was held in n->right.
It moved to n->alloc but the code avoiding n->right
was left behind in order.c. In copy(x, <-c), the receive
is in n->right and must be processed. Delete the special
case code, removing the bug.

Fixes #8039.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/100820044
2014-05-27 23:59:06 -04:00
Russ Cox
daf9308066 cmd/gc: fix infinite loop in nil check removal
Fixes #8076.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/93610043
2014-05-27 23:58:49 -04:00
Russ Cox
6c0bcb1863 cmd/gc: fix method value closures on nacl amd64p32
The code was assuming that pointer alignment is the
maximum alignment, but on NaCl uint64 alignment is
even more strict.

Brad checked in the test earlier today; this fixes the build.

Fixes #7863.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/98630046
2014-05-27 23:58:36 -04:00
Jan Ziak
eeb87c3660 cmd/go: do not miss an error if import path contains "cmd/something"
Fixes #7638

LGTM=rsc
R=rsc, adg, robert.hencke, bradfitz
CC=golang-codereviews
https://golang.org/cl/89280043
2014-05-27 23:58:03 -04:00
Russ Cox
74ce581b06 cmd/gc: fix conversion of runtime constant
The code cannot have worked before, because it was
trying to use the old value in a range check for the new
type, which might have a different representation
(hence the 'internal compiler error').

Fixes #8073.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/98630045
2014-05-27 21:38:19 -04:00
Rob Pike
7f638e9023 cmd/go: improve error message when import path contains http://
Common mistake (at least for me) because hg etc. require the prefix
while the go command forbids it.

Before:
% go get http://code.google.com/p/go.text/unicode/norm
package http:/code.google.com/p/go.text/unicode/norm: unrecognized import path "http:/code.google.com/p/go.text/unicode/norm"

After:
% go get http://code.google.com/p/go.text/unicode/norm
package http:/code.google.com/p/go.text/unicode/norm: "http://" not allowed in import path

LGTM=ruiu, rsc
R=rsc, ruiu
CC=golang-codereviews
https://golang.org/cl/97630046
2014-05-27 14:37:36 -07:00
Pietro Gagliardi
5eb585f211 cmd/cgo: explicitly state that #cgo directives across multiple files are concatenated
This is a quick documentation change/clarification, as this
confused me before: in my own cgo-based projects, I currently have
identical #cgo directives in each relevant source file, and I notice
with go build -x that cgo is combining the directives, leading to
pkg-config invocations with the same package name (gtk+-3.0, in my
case) repeated several times, or on Mac OS X, LDFLAGS listing
-framework Foundation -framework AppKit multiple times. Since I am
about to add a CFLAGS as well, I checked the source to cmd/cgo and
go/build (where the work is actually done) to see if that still holds
true there. Hopefully other people who have made the same mistake I
have (I don't know if anyone has) can remove the excess declarations
now; this should make things slightly easier to manage as well.

LGTM=iant
R=golang-codereviews, gobot, iant
CC=golang-codereviews
https://golang.org/cl/91520046
2014-05-21 16:01:54 -07:00
Keith Randall
cee8bcabfa runtime: provide gc maps for the reflect.callXX frames.
Update #8030

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/100620045
2014-05-21 14:28:34 -07:00
Anthony Martin
eb34288ad1 cmd/objdump: fix dissasembly of Plan 9 object files
Ignore symbols that aren't text, data, or bss since they cause
problems when dissassembling instructions with small immediate
values.

Before:
        build.go:142    0x10ee  83ec50      SUBL $text/template/parse.autotmp_1293(SB), SP

After:
        build.go:142    0x10ee  83ec50      SUBL $0x50, SP

Fixes #7947.

LGTM=rsc
R=rsc, 0intro
CC=golang-codereviews
https://golang.org/cl/93520045
2014-05-21 23:24:38 +02:00
Russ Cox
1be479df92 cmd/gc: fix floating point rounding again
Passes the expanded test in CL 100660044,
which gives me some confidence that it
might be right.

(The old code failed by not considering all the
low bits.)

LGTM=r
R=golang-codereviews, r, bradfitz
CC=golang-codereviews, iant, khr
https://golang.org/cl/99410051
2014-05-21 17:11:52 -04:00
Russ Cox
f9c6ad9b6b cmd/go: fix coverage for 'package foo_test' tests
Fixes #8062.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/91610046
2014-05-21 13:59:14 -04:00
Ian Lance Taylor
708304bea2 cmd/go: check for SWIG version that is too old to use
Fixes #7983.

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews, rsc
https://golang.org/cl/96540044
2014-05-21 10:39:23 -07:00
Benny Siegert
775719c600 cmd/ld: correctly compute note size on NetBSD.
Patch from http://gnats.NetBSD.org/48811.

LGTM=iant
R=golang-codereviews, minux.ma, iant
CC=golang-codereviews, tk
https://golang.org/cl/94670047
2014-05-21 06:18:45 -07:00
Ian Lance Taylor
f85600859d cmd/ld: really import runtime/cgo for external link
Fixes #8032.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/95580043
2014-05-20 21:36:50 -07:00
Shenghou Ma
ca6be91cbc all: fix "the the" typos.
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/93470043
2014-05-20 14:42:07 -04:00
Shenghou Ma
dfbb2a95bf undo CL 84040045 / 5302b4c58aa0
This idea was rejected in CL 5731059. We should fix the
runtime docs instead.

««« original CL description
cmd/dist: reflect local changes to tree in goversion

runtime.Version() requires a trailing "+" when
tree had local modifications at time of build.

Fixes #7701

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/84040045

»»»

LGTM=rsc, mra
R=iant, rsc, mra
CC=golang-codereviews
https://golang.org/cl/100520043
2014-05-20 14:02:57 -04:00
Rob Pike
294f9b88c4 cmd/go: document file types
Explain which files the go command looks at, and what they represent.
Fixes #6348.

LGTM=rsc
R=rsc, minux.ma
CC=golang-codereviews
https://golang.org/cl/96480043
2014-05-20 10:46:44 -07:00
Russ Cox
0c2a727477 build: make nacl pass
Add nacl.bash, the NaCl version of all.bash.
It's a separate script because it builds a variant of package syscall
with a large zip file embedded in it, containing all the input files
needed for tests.

Disable various tests new since the last round, mostly the ones using os/exec.

Fixes #7945.

LGTM=dave
R=golang-codereviews, remyoudompheng, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/100590044
2014-05-20 12:10:19 -04:00
Russ Cox
a4a1fadfa2 cmd/ld: make lldb happy with Mach-O 6.out files
Apparently all the __DWARF sections need addresses
even though they are marked as "do not load from disk".
Continue the address numbering from the data segment.

With this change:

g% lldb helloworld
Current executable set to 'helloworld' (x86_64).
(lldb) b main.main
Breakpoint 1: where = helloworld`main.main + 25 at helloworld.go:12, address = 0x0000000000002019
(lldb) r
Process 68509 launched: '/Users/rsc/g/go/src/cmd/6l/helloworld' (x86_64)
1 location added to breakpoint 1
(lldb)
Process 68509 stopped
* thread #1: tid = 0x8b7a27, 0x0000000000002019 helloworld`main.main + 25 at helloworld.go:12, stop reason = breakpoint 1.2
    frame #0: 0x0000000000002019 helloworld`main.main + 25 at helloworld.go:12
   9   	package main
   10
   11  	func main() {
-> 12  		print("hello, world\n")
   13  	}
(lldb) bt
* thread #1: tid = 0x8b7a27, 0x0000000000002019 helloworld`main.main + 25 at helloworld.go:12, stop reason = breakpoint 1.2
  * frame #0: 0x0000000000002019 helloworld`main.main + 25 at helloworld.go:12
(lldb) disas
helloworld`main.main at helloworld.go:11:
   0x2000:  movq   %gs:0x8a0, %rcx
   0x2009:  cmpq   (%rcx), %rsp
   0x200c:  ja     0x2015                    ; main.main + 21 at helloworld.go:11
   0x200e:  callq  0x20da0                   ; runtime.morestack00_noctxt at atomic_amd64x.c:28
   0x2013:  jmp    0x2000                    ; main.main at helloworld.go:11
   0x2015:  subq   $0x10, %rsp
-> 0x2019:  leaq   0x2c2e0, %rbx
   0x2021:  leaq   (%rsp), %rbp
   0x2025:  movq   %rbp, %rdi
   0x2028:  movq   %rbx, %rsi
   0x202b:  movsq
   0x202d:  movsq
   0x202f:  callq  0x10300                   ; runtime.printstring at compiler.go:1
   0x2034:  addq   $0x10, %rsp
   0x2038:  ret
   0x2039:  addb   %al, (%rax)
   0x203b:  addb   %al, (%rax)
   0x203d:  addb   %al, (%rax)
(lldb) quit
Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] y
g%

Fixes #7070.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/93510043
2014-05-20 11:35:20 -04:00
Elias Naur
88d07b2cbc cmd/cgo: document CC_FOR_TARGET and CXX_FOR_TARGET
Update #4714

LGTM=iant, minux.ma, rsc
R=rsc, iant, r, minux.ma
CC=golang-codereviews
https://golang.org/cl/100390043
2014-05-20 01:32:31 -04:00
Russ Cox
60be4a2450 cmd/gc: fix float32 const conversion and printing of big float consts
The float32 const conversion used to round to float64
and then use the hardware to round to float32.
Even though there was a range check before this
conversion, the double rounding introduced inaccuracy:
the round to float64 might round the value further away
from the float32 range, reaching a float64 value that
could not actually be rounded to float32. The hardware
appears to give us 0 in that case, but it is probably undefined.
Double rounding also meant that the wrong value might
be used for certain border cases.

Do the rounding the float32 ourselves, just as we already
did the rounding to float64. This makes the conversion
precise and also makes the conversion match the range check.

Finally, add some code to print very large (bigger than float64)
floating point constants in decimal floating point notation instead
of falling back to the precise but human-unreadable binary floating
point notation.

Fixes #8015.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/100580044
2014-05-19 22:57:59 -04:00
Shenghou Ma
661298358c cmd/ld: abort if (32-bit) address relocation is negative on amd64.
Update #7980
This CL make the linker abort for the example program. For Go 1.4,
we need to find a general way to handle large memory model programs.

LGTM=dave, josharian, iant
R=iant, dave, josharian
CC=golang-codereviews
https://golang.org/cl/91500046
2014-05-19 22:39:42 -04:00
Russ Cox
a663e0a038 cmd/gc: fix <-<-expr
The temporary-introducing pass was not recursing
into the argumnt of a receive operation.

Fixes #8011.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant, khr
https://golang.org/cl/91540043
2014-05-19 15:08:04 -04:00
David du Colombier
23e8c0d281 cmd/addr2line, cmd/objdump: handle Plan 9 a.out object files
Update #7947.

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/91500044
2014-05-16 16:51:27 +02:00
Anthony Martin
c6aa2e5ac8 cmd/pack: buffer writes in TestLargeDefs
TestLargeDefs was issuing over one million small writes to
create a 7MB file (large.go). This is quite slow on Plan 9
since our disk file systems aren't very fast and they're
usually accessed over the network.

Buffering the writes makes the test about six times faster.
Even on Linux, it's about 1.5 times faster.

Here are the results on a slow Plan 9 machine:

Before:
        % ./pack.test -test.v -test.run TestLargeDefs
        === RUN TestLargeDefs
        --- PASS: TestLargeDefs (125.11 seconds)
        PASS

After:
        % ./pack.test -test.v -test.run TestLargeDefs
        === RUN TestLargeDefs
        --- PASS: TestLargeDefs (20.835 seconds)
        PASS

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/95040044
2014-05-15 20:12:06 -07:00
Russ Cox
1357f548b0 cmd/gc: fix two select temporary bugs
The introduction of temporaries in order.c was not
quite right for two corner cases:

1) The rewrite that pushed new variables on the lhs of
a receive into the body of the case was dropping the
declaration of the variables. If the variables escape,
the declaration is what allocates them.
Caught by escape analysis sanity check.
In fact the declarations should move into the body
always, so that we only allocate if the corresponding
case is selected. Do that. (This is an optimization that
was already present in Go 1.2. The new order code just
made it stop working.)

Fixes #7997.

2) The optimization to turn a single-recv select into
an ordinary receive assumed it could take the address
of the destination; not so if the destination is _.

Fixes #7998.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/100480043
2014-05-15 19:16:18 -04:00
Russ Cox
68aaf2ccda runtime: make scan of pointer-in-interface same as scan of pointer
The GC program describing a data structure sometimes trusts the
pointer base type and other times does not (if not, the garbage collector
must fall back on per-allocation type information stored in the heap).
Make the scanning of a pointer in an interface do the same.
This fixes a crash in a particular use of reflect.SliceHeader.

Fixes #8004.

LGTM=khr
R=golang-codereviews, khr
CC=0xe2.0x9a.0x9b, golang-codereviews, iant, r
https://golang.org/cl/100470045
2014-05-15 15:53:36 -04:00
Russ Cox
f5184d3437 cmd/gc: correct handling of globals, func args, results
Globals, function arguments, and results are special cases in
registerization.

Globals must be flushed aggressively, because nearly any
operation can cause a panic, and the recovery code must see
the latest values. Globals also must be loaded aggressively,
because nearly any store through a pointer might be updating a
global: the compiler cannot see all the "address of"
operations on globals, especially exported globals. To
accomplish this, mark all globals as having their address
taken, which effectively disables registerization.

If a function contains a defer statement, the function results
must be flushed aggressively, because nearly any operation can
cause a panic, and the deferred code may call recover, causing
the original function to return the current values of its
function results. To accomplish this, mark all function
results as having their address taken if the function contains
any defer statements. This causes not just aggressive flushing
but also aggressive loading. The aggressive loading is
overkill but the best we can do in the current code.

Function arguments must be considered live at all safe points
in a function, because garbage collection always preserves
them: they must be up-to-date in order to be preserved
correctly. Accomplish this by marking them live at all call
sites. An earlier attempt at this marked function arguments as
having their address taken, which disabled registerization
completely, making programs slower. This CL's solution allows
registerization while preserving safety. The benchmark speedup
is caused by being able to registerize again (the earlier CL
lost the same amount).

benchmark                old ns/op     new ns/op     delta
BenchmarkEqualPort32     61.4          56.0          -8.79%

benchmark                old MB/s     new MB/s     speedup
BenchmarkEqualPort32     521.56       570.97       1.09x

Fixes #1304. (again)
Fixes #7944. (again)
Fixes #7984.
Fixes #7995.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, iant, r
https://golang.org/cl/97500044
2014-05-15 15:34:53 -04:00
Russ Cox
ec38c6f5e3 cmd/gc: fix duplicate map key check
Do not compare nil and true.

Fixes #7996.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/91470043
2014-05-15 15:34:37 -04:00
Alex Brainman
435ba1295a cmd/addr2line,cmd/objdump: test that commands accept addresses with 0x prefix and without
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/100440045
2014-05-15 15:55:31 +10:00
Alex Brainman
6c7bef551b cmd/addr2line, cmd/objdump: fix pe text section starting address
fixes windows build

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/97500043
2014-05-15 12:44:29 +10:00
Russ Cox
8e22903b46 cmd/nm, cmd/objdump: fix elf symbol types
Turns out elf.File.Sections is indexed by the actual
section number, not the number minus one.
I don't know why I thought the -1 was necessary.

Fixes objdump test (and therefore build) on ELF systems.

While we're here, fix bounds on gnuDump so that we
don't crash when asked to disassemble outside
the text segment. May fix Windows build or at least
make the failure more interesting.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/92390043
2014-05-14 17:45:13 -07:00
Russ Cox
79fb16d32c objdump: implement disassembly
There is some duplication here with cmd/nm.
There is a TODO to address that after 1.3 is out.

Update #7452

x86 disassembly works and is tested.

The arm disassembler does not exist yet
and is therefore not yet hooked up.

LGTM=crawshaw, iant
R=crawshaw, iant
CC=golang-codereviews
https://golang.org/cl/91360046
2014-05-14 19:51:15 -04:00
Russ Cox
e7ad1ebeac cmd/objdump: import x86 disassembler
The x86 disassembler lives in rsc.io/x86/x86asm for now.
We need to figure out what should live where in the long term,
but not before the 1.3 release.

The completed code reviews for the disassembler are at:
https://golang.org/cl/95350044
https://golang.org/cl/95300044
https://golang.org/cl/97100047
https://golang.org/cl/93110044
https://golang.org/cl/99000043
https://golang.org/cl/98990043

LGTM=crawshaw
R=crawshaw, jacek.masiulaniec
CC=golang-codereviews
https://golang.org/cl/92360043
2014-05-14 19:46:53 -04:00
Dmitriy Vyukov
8c2fefe89c cmd/gc: fix out of bounds access
AddressSanitizer says:

AddressSanitizer: heap-buffer-overflow on address 0x60200001b6f3
READ of size 6 at 0x60200001b6f3 thread T0
    #0 0x46741b in __interceptor_memcmp asan_interceptors.cc:337
    #1 0x4b5794 in compile src/cmd/6g/../gc/pgen.c:177
    #2 0x509b81 in funccompile src/cmd/gc/dcl.c:1457
    #3 0x520fe2 in p9main src/cmd/gc/lex.c:489
    #4 0x5e2e01 in main src/lib9/main.c:57
    #5 0x7fab81f7976c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
    #6 0x4b16dc in _start (pkg/tool/linux_amd64/6g+0x4b16dc)

0x60200001b6f3 is located 0 bytes to the right of 3-byte region [0x60200001b6f0,0x60200001b6f3)
allocated by thread T0 here:
    #0 0x493ec8 in __interceptor_malloc asan_malloc_linux.cc:75
    #1 0x54d64e in mal src/cmd/gc/subr.c:459
    #2 0x5260d5 in yylex src/cmd/gc/lex.c:1605
    #3 0x52078f in p9main src/cmd/gc/lex.c:402
    #4 0x5e2e01 in main src/lib9/main.c:57

If the memory block happens to be at the end of hunk and page bounadry,
this out-of-bounds can lead to a crash.

LGTM=dave, iant
R=golang-codereviews, dave, iant
CC=golang-codereviews
https://golang.org/cl/93370043
2014-05-14 19:24:00 +04:00
Russ Cox
95e4181b0c cmd/go: fix go test again
Fixes subrepo builds.

LGTM=iant, mikioh.mikioh
R=golang-codereviews, iant, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/96310043
2014-05-13 01:38:10 -04:00
Russ Cox
2d1a9510ed cmd/cgo: omit misaligned struct fields, like we omit bitfields
Fixes #7560.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/96300045
2014-05-12 23:48:20 -04:00
Russ Cox
41e5c398d9 cmd/go: fix 'go test foo_test.go'
Fixes race build.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/100410044
2014-05-12 20:45:31 -04:00
Russ Cox
26ad5d4ff0 cmd/gc: fix liveness vs regopt mismatch for input variables
The inputs to a function are marked live at all times in the
liveness bitmaps, so that the garbage collector will not free
the things they point at and reuse the pointers, so that the
pointers shown in stack traces are guaranteed not to have
been recycled.

Unfortunately, no one told the register optimizer that the
inputs need to be preserved at all call sites. If a function
is done with a particular input value, the optimizer will stop
preserving it across calls. For single-word values this just
means that the value recorded might be stale. For multi-word
values like slices, the value recorded could be only partially stale:
it can happen that, say, the cap was updated but not the len,
or that the len was updated but not the base pointer.
Either of these possibilities (and others) would make the
garbage collector misinterpret memory, leading to memory
corruption.

This came up in a real program, in which the garbage collector's
'slice len ≤ slice cap' check caught the inconsistency.

Fixes #7944.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, khr
https://golang.org/cl/100370045
2014-05-12 17:19:02 -04:00