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

3928 Commits

Author SHA1 Message Date
Shenghou Ma
e487ea8421 cmd/vet: don't complain about Error()
Fixes #4598.

R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/7102050
2013-01-18 02:24:12 +08:00
Shenghou Ma
c2aee3c0bf cmd/godoc: when redirecting don't clear query string
so that http://golang.org/pkg/runtime?m=all works.

R=bradfitz
CC=golang-dev
https://golang.org/cl/7094046
2013-01-17 18:50:49 +08:00
Andrew Gerrand
be2596471f cmd/godoc: support m=text parameter for text files
It's possible to view the package docs in plain text, eg:
        http://golang.org/pkg/time/?m=text
and this CL introduces the ability to do the same for files:
        http://golang.org/src/pkg/time/time.go?m=text

R=golang-dev, dave, minux.ma
CC=golang-dev
https://golang.org/cl/7085054
2013-01-14 09:35:04 +11:00
Anthony Martin
1a9a63961b cmd/5l: fix invalid executable header on Plan 9
R=minux.ma, lucio.dere
CC=golang-dev
https://golang.org/cl/7094048
2013-01-12 03:13:55 -08:00
Rémy Oudompheng
c13866db7f cmd/5c: fix handling of side effects when assigning a struct literal.
Also undo revision a5b96b602690 used to workaround the bug.

Fixes #4643.

R=rsc, golang-dev, dave, minux.ma, lucio.dere, bradfitz
CC=golang-dev
https://golang.org/cl/7090043
2013-01-12 09:16:50 +01:00
Ryan Slade
3073a02b19 testing: in example, empty output not distinguished from missing output
Fixes #4485.

R=golang-dev, rsc, adg
CC=golang-dev
https://golang.org/cl/7071050
2013-01-12 11:05:53 +11:00
Daniel Morsing
b73a1a8e32 cmd/6g, cmd/8g: Allow optimization of return registers.
The peephole optimizer would keep hands off AX and X0 during returns, even though go doesn't return through registers.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/7030046
2013-01-11 15:44:42 +01:00
Shenghou Ma
9ae7f34084 cmd/gc, cmd/ld: update doc.go for -race
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/7066052
2013-01-11 12:35:58 +08:00
Shenghou Ma
bdd9f29780 cmd/5g: allow optimization of return registers.
Modeled after CL 7030046 by daniel.morsing.

example program:
func f(x int) int { x -= 10; return x }

5g -S difference:
 --- prog list "f" ---
 0011 (x.go:7) TEXT   	add+0(SB),$0-8
 0012 (x.go:7) MOVW   	x+0(FP),R0
-0013 (x.go:7) SUB    	$10,R0,R2
-0014 (x.go:7) MOVW   	R2,R0
-0015 (x.go:7) MOVW   	R2,.noname+4(FP)
-0016 (x.go:7) RET    	,
+0013 (x.go:7) SUB    	$10,R0
+0014 (x.go:7) MOVW   	R0,.noname+4(FP)
+0015 (x.go:7) RET    	,

R=dave, rsc
CC=golang-dev
https://golang.org/cl/7030047
2013-01-11 12:29:14 +08:00
Shenghou Ma
d5d4ee47ed cmd/5l: support -Z (zero stack frame at function entry)
also added appropriate docs to cmd/ld/doc.go
(largely copied from Russ's CL 6938073).

R=rsc
CC=golang-dev
https://golang.org/cl/7004049
2013-01-11 12:24:28 +08:00
Ian Lance Taylor
eee3dd1292 cmd/cgo: for gccgo: use intgo, don't use slice as void return type
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7057064
2013-01-09 15:25:46 -08:00
Anthony Martin
74c03cb814 cmd/ld: fix incompatible type signatures on Plan 9
Changeset f483bfe81114 moved ELF generation to the architecture
independent code and in doing so added a Section* to the Sym
type and an Elf64_Shdr* to the Section type.

This caused the Plan 9 compilers to complain about incompatible
type signatures in the many files that reference the Sym type.

R=rsc, dave
CC=golang-dev
https://golang.org/cl/7057058
2013-01-09 15:05:22 -08:00
Dave Cheney
593d8b0c14 cmd/go: remove $GOROOT as a go get target
Fixes #4186.

Back in the day, before the Go 1.0 release, $GOROOT was mandatory for building from source. Fast forward to now and $GOPATH is mandatory and $GOROOT is optional, and mainly used by those who use the binary distribution in uncommon places.

For example, most novices at least know about `sudo` as they would have used it to install the binary tarball into /usr/local. It is logical they would use the `sudo` hammer to `go get` other Go packages when faced with a permission error talking about the path they just had to use `sudo` on last time.

Even if they had read the documentation and set $GOPATH, go get will not work as expected as `sudo` masks most environment variables.

llucky(~) % ~/go/bin/go env | grep GOPATH
GOPATH="/home/dfc"
lucky(~) % sudo ~/go/bin/go env | grep GOPATH
GOPATH=""

This CL therefore proposes to remove support for using `go get` to download source into $GOROOT.

This CL also proposes an error when GOPATH=$GOROOT, as this is another place where new Go users can get stuck.

Further discussion: https://groups.google.com/d/topic/golang-nuts/VIg3fjHiHRI/discussion

R=rsc, adg, minux.ma
CC=golang-dev
https://golang.org/cl/6941058
2013-01-10 09:57:01 +11:00
Ian Lance Taylor
5ca4f5e483 cmd/go: get -m options from GOARCH when using gccgo
R=golang-dev, bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/7057063
2013-01-09 14:45:03 -08:00
Rémy Oudompheng
8fff2525cb cmd/gc: add space to export data to match linker expectations
The linker split PKGDEF into (prefix, name, def) pairs,
and defines def to begin after a space following the identifier.
This is totally wrong for the following export data:

        func "".FunctionName()
        var SomethingCompletelyUnrelated int

The linker would parse
    name=`"".FunctionName()\n\tvar`
    def=`SomethingCompletelyUnrelated int`
since there is no space after FunctionName.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7068051
2013-01-09 22:02:53 +01:00
Dave Cheney
4ba27df69c cmd/dist: drop unneeded clang flags
Our source no longer needs these flags set to build cleanly using clang.

Tested with

* Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0) on i386
* clang version 3.2 (tags/RELEASE_32/final) on amd64 cross compiling all platforms

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7058053
2013-01-10 08:00:03 +11:00
Jason Travis
f7320bf81b cmd/vet: fix doc typo.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7061050
2013-01-08 15:22:18 +11:00
Rémy Oudompheng
fba96e915d cmd/gc: fix uintptr(nil) issues.
A constant node of type uintptr with a nil literal could
happen in two cases: []int(nil)[1:] and
uintptr(unsafe.Pointer(nil)).

Fixes #4614.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7059043
2013-01-08 00:23:02 +01:00
Dave Cheney
77c343328e cmd/go: use filepath.SplitList when inspecting GOPATH
There exists a test case for this condition, but it only runs on unix systems, which neatly dovetails into the code always using ':' as the list separator.

R=adg, iant
CC=golang-dev
https://golang.org/cl/7057052
2013-01-08 10:00:21 +11:00
David Symonds
86aad668c0 cmd/vet: %#q is a valid format (uses raw quotes).
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7057051
2013-01-07 15:31:51 +11:00
Russ Cox
a091d2e676 cmd/gc, cmd/ld: rename -b to -race
There's no b in race detector.
The new flag matches the one in the go command
(go test -race math).

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7072043
2013-01-06 22:47:39 -05:00
Robin Eklind
f36a53cd5d cmd/gofmt, bufio, image: Consistency and error handling.
cmd/gofmt: Add error handling for ioutil.WriteFile.
bufio: Consistency, rename e to err.
image: Consistency, fix comment for asReader.

R=golang-dev, dave, minux.ma, adg
CC=golang-dev
https://golang.org/cl/7029056
2013-01-07 11:15:53 +11:00
Matthew Dempsky
46811d27ce src: Use bytes.Equal instead of bytes.Compare where possible.
bytes.Equal is simpler to read and should also be faster because
of short-circuiting and assembly implementations.

Change generated automatically using:
  gofmt -r 'bytes.Compare(a, b) == 0 -> bytes.Equal(a, b)'
  gofmt -r 'bytes.Compare(a, b) != 0 -> !bytes.Equal(a, b)'

R=golang-dev, dave, adg, rsc
CC=golang-dev
https://golang.org/cl/7038051
2013-01-07 10:03:49 +11:00
Russ Cox
cbbc6a102d cmd/5l, cmd/6l, cmd/8l, cmd/cc, cmd/gc: new flag parsing
This CL adds a flag parser that matches the semantics of Go's
package flag. It also changes the linkers and compilers to use
the new flag parser.

Command lines that used to work, like
        8c -FVw
        6c -Dfoo
        5g -I/foo/bar
now need to be split into separate arguments:
        8c -F -V -w
        6c -D foo
        5g -I /foo/bar
The new spacing will work with both old and new tools.

The new parser also allows = for arguments, as in
        6c -D=foo
        5g -I=/foo/bar
but that syntax will not work with the old tools.

In addition to matching standard Go binary flag parsing,
the new flag parser generates more detailed usage messages
and opens the door to long flag names.

The recently added gc flag -= has been renamed -complete.

R=remyoudompheng, daniel.morsing, minux.ma, iant
CC=golang-dev
https://golang.org/cl/7035043
2013-01-06 15:24:47 -05:00
Russ Cox
d37c572ad5 cmd/ld: move symtab, ELF generation to portable code
More cleanup in preparation for fixing issue 4069.

This CL replaces the three nearly identical copies of the
asmb ELF code with a single asmbelf function in elf.c.

In addition to the ELF code movement, remove the elfstr
array in favor of a simpler lookup, and identify sections by
name throughout instead of computing fragile indices.

The CL also replaces the three nearly identical copies of the
genasmsym code with a single genasmsym function in lib.c.

The ARM linker still compiles and generates binaries,
but I haven't tested the binaries. They may not work.

R=ken2
CC=golang-dev
https://golang.org/cl/7062047
2013-01-06 14:32:45 -05:00
Dave Cheney
b006cd9bb0 cmd/go: avoid leaking timer if test process failed to start
R=rsc
CC=golang-dev
https://golang.org/cl/7034047
2013-01-05 21:15:51 +11:00
Russ Cox
4e2aa9bff0 cmd/ld: use native-endian symbol values in symbol table
The Plan 9 symbol table format defines big-endian symbol values
for portability, but we want to be able to generate an ELF object file
and let the host linker link it, as part of the solution to issue 4069.
The symbol table itself, since it is loaded into memory at run time,
must be filled in by the final host linker, using relocation directives
to set the symbol values. On a little-endian machine, the linker will
only fill in little-endian values during relocation, so we are forced
to use little-endian symbol values.

To preserve most of the original portability of the symbol table
format, we make the table itself say whether it uses big- or
little-endian values. If the table begins with the magic sequence
        fe ff ff ff 00 00
then the actual table begins after those six bytes and contains
little-endian symbol values. Otherwise, the table is in the original
format and contains big-endian symbol values. The magic sequence
looks like an "end of table" entry (the fifth byte is zero), so legacy
readers will see a little-endian table as an empty table.

All the gc architectures are little-endian today, so the practical
effect of this CL is to make all the generated tables little-endian,
but if a big-endian system comes along, ld will not generate
the magic sequence, and the various readers will fall back to the
original big-endian interpretation.

R=ken2
CC=golang-dev
https://golang.org/cl/7066043
2013-01-04 17:03:57 -05:00
Daniel Morsing
f1e4ee3f49 cmd/5g, cmd/6g, cmd/8g: flush return parameters in case of panic.
Fixes #4066.

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/7040044
2013-01-04 17:07:21 +01:00
Lucio De Re
62dfa9c47d cmd/5g, cmd/5l, cmd/ld: Small adjustments for the Plan 9 native tools
A few USED(xxx) additions and a couple of deletions of variable
initialisations that go unused.  One questionable correction,
mirrored in 8l/asm.c, where the result of invocation of a function
shouldn't be used.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6736054
2013-01-04 11:02:49 -05:00
Russ Cox
a4e08183d5 cmd/dist: sse auto-detect
R=golang-dev, dsymonds, minux.ma, iant, alex.brainman
CC=golang-dev
https://golang.org/cl/7035055
2013-01-04 10:59:10 -05:00
Rémy Oudompheng
cf77dd37e7 cmd/8g: extend elimination of temporaries to SSE2 code.
Before:
(erf.go:188)    TEXT     Erf+0(SB),$220
(erf.go:265)    TEXT     Erfc+0(SB),$204
(lgamma.go:174) TEXT     Lgamma+0(SB),$948

After:
(erf.go:188)    TEXT     Erf+0(SB),$84
(erf.go:265)    TEXT     Erfc+0(SB),$84
(lgamma.go:174) TEXT     Lgamma+0(SB),$44

SSE before vs. SSE after:

benchmark             old ns/op    new ns/op    delta
BenchmarkAcosh               81           49  -39.14%
BenchmarkAsinh              109          109   +0.00%
BenchmarkAtanh               73           74   +0.68%
BenchmarkLgamma             138           42  -69.20%
BenchmarkModf                24           15  -36.95%
BenchmarkSqrtGo             565          556   -1.59%

R=rsc
CC=golang-dev
https://golang.org/cl/7028048
2013-01-03 00:44:31 +01:00
Russ Cox
5e46d540c8 cmd/dist: use separate args for separate compiler flags
This makes dist safe for CL 7035043 (but keeps working now too).

R=golang-dev, remyoudompheng
CC=golang-dev
https://golang.org/cl/7029047
2013-01-02 17:52:54 -05:00
Rémy Oudompheng
15f2c01f44 cmd/8g: fix possibly uninitialized variable in foptoas.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7045043
2013-01-02 23:20:52 +01:00
Rémy Oudompheng
9afb34b42e cmd/dist, cmd/8g: implement GO386=387/sse to choose FPU flavour.
A new environment variable GO386 is introduced to choose between
code generation targeting 387 or SSE2. No auto-detection is
performed and the setting defaults to 387 to preserve previous
behaviour.

The patch is a reorganization of CL6549052 by rsc.

Fixes #3912.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6962043
2013-01-02 22:55:23 +01:00
Rémy Oudompheng
20c76f7f3f cmd/gc: mark wrapper methods for unnamed types as DUPOK.
Unnamed types like structs with embedded fields can have methods.
These methods are generated on-the-fly by the compiler and
it may happen for identical types in different packages.
The linker must accept these multiple definitions.

Fixes #4590.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/7030051
2013-01-02 21:42:26 +01:00
Russ Cox
ae2131ab3b cmd/gc: make redeclaration between import and func less confusing
Fixes #4510.

R=ken2
CC=golang-dev
https://golang.org/cl/7001054
2013-01-02 15:34:28 -05:00
Kamil Kisiel
267a55397b cmd/godoc: ignore misnamed examples and print a warning
Fixes #4211.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6970051
2013-01-02 16:00:41 +11:00
Russ Cox
6592456feb cmd/gc: do not generate code for var _ = ... unless necessary
Fixes #2443.

R=ken2
CC=golang-dev
https://golang.org/cl/6997048
2012-12-30 12:01:53 -05:00
Dave Cheney
0c6beb00fb cmd/dist: use -pipe during bootstrap
R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7025044
2012-12-30 10:33:33 +11:00
Dave Cheney
6535eb3a6d cmd/ld: fix valgrind warning in strnput
Fixes #4592.

Thanks to minux for the suggestion.

R=minux.ma, iant
CC=golang-dev
https://golang.org/cl/7017048
2012-12-28 15:32:24 +11:00
Rémy Oudompheng
ecbf99ad97 cmd/gc: fix race instrumentation of unaddressable arrays.
Fixes #4578.

R=dvyukov, golang-dev
CC=golang-dev
https://golang.org/cl/7005050
2012-12-24 12:14:41 +01:00
Russ Cox
3aed92f811 cmd/gc: add diagnostic for var, type, const named init
Before this CL, defining the variable worked fine, but then when
the implicit package-level init func was created, that caused a
name collision and a confusing error about the redeclaration.

Also add a test for issue 3705 (func init() needs body).

Fixes #4517.

R=ken2
CC=golang-dev
https://golang.org/cl/7008045
2012-12-22 17:23:33 -05:00
Russ Cox
3fc3597c9b cmd/go: remove debugging flag introduced in CL 6996054
R=remyoudompheng
CC=golang-dev
https://golang.org/cl/7002052
2012-12-22 17:04:56 -05:00
Russ Cox
04098d88fa cmd/gc: make forward declaration in pure Go package an error
An error during the compilation can be more precise
than an error at link time.

For 'func init', the error happens always: you can't forward
declare an init func because the name gets mangled.

For other funcs, the error happens only with the special
(and never used by hand) -= flag, which tells 6g the
package is pure go.

The go command now passes -= for pure Go packages.

Fixes #3705.

R=ken2
CC=golang-dev
https://golang.org/cl/6996054
2012-12-22 16:46:46 -05:00
Russ Cox
1b3244e0db cmd/gc: fix eval order in select
Ordinary variable load was assumed to be not worth saving,
but not if one of the function calls later might change
its value.

Fixes #4313.

R=ken2
CC=golang-dev
https://golang.org/cl/6997047
2012-12-22 16:46:01 -05:00
Russ Cox
b3bb4bd292 cmd/yacc: fix debug print of token name
The array skips the first TOKSTART entries.

Fixes #4410.

R=golang-dev, ken2, ken
CC=golang-dev
https://golang.org/cl/6999054
2012-12-22 16:45:35 -05:00
Rémy Oudompheng
9aef20e823 cmd/gc: fix wrong interaction between inlining and embedded builtins.
The patch makes the compile user an ordinary package-local
symbol for the name of embedded fields of builtin type.

This is incompatible with the fix delivered for issue 2687
(revision 3c060add43fb) but fixes it in a different way, because
the explicit symbol on the field makes the typechecker able to
find it in lookdot.

Fixes #3552.

R=lvd, rsc, daniel.morsing
CC=golang-dev
https://golang.org/cl/6866047
2012-12-22 19:16:31 +01:00
Rémy Oudompheng
ced8004a00 cmd/gc: do not accept (**T).Method expressions.
The typechecking code was doing an extra, unnecessary
indirection.

Fixes #4458.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6998051
2012-12-22 19:13:45 +01:00
Daniel Morsing
c956dcdc54 cmd/gc: Reject parenthesised .(type) expressions.
Fixes #4470.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6949073
2012-12-22 17:36:10 +01:00
Russ Cox
b9da27bed2 cmd/6l, cmd/8l: add -Z flag to zero stack frame on entry
Replacement for GOEXPERIMENT=zerostack, easier to use.
Does not require a separate toolchain.

R=ken2
CC=golang-dev
https://golang.org/cl/6996051
2012-12-22 11:20:17 -05:00
Russ Cox
e431398e09 undo CL 6938073 / 1542912cf09d
remove zerostack compiler experiment; will do at link time instead

««« original CL description
cmd/gc: add GOEXPERIMENT=zerostack to clear stack on function entry

This is expensive but it might be useful in cases where
people are suffering from false positives during garbage
collection and are willing to trade the CPU time for getting
rid of the false positives.

On the other hand it only eliminates false positives caused
by other function calls, not false positives caused by dead
temporaries stored in the current function call.

The 5g/6g/8g changes were pulled out of the history, from
the last time we needed to do this (to work around a goto bug).
The code in go.h, lex.c, pgen.c is new but tiny.

R=ken2
CC=golang-dev
https://golang.org/cl/6938073
»»»

R=ken2
CC=golang-dev
https://golang.org/cl/7002051
2012-12-22 11:18:04 -05:00
Russ Cox
407d0c5ab7 cmd/gc: fix error line in switch expr eval
Fixes #4562.

R=ken2
CC=golang-dev
https://golang.org/cl/7008044
2012-12-22 10:01:15 -05:00
Rémy Oudompheng
4d3cbfdefa cmd/8g: introduce temporaries in byte multiplication.
Also restore the smallintconst case for binary ops.

Fixes #3835.

R=daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6999043
2012-12-21 23:46:16 +01:00
Dave Cheney
3dcc63f750 cmd/5g: avoid temporaries in agen OINDEX
Most benchmarks are within the 3% margin of error. This code path is quite common in the fmt package.

linux/arm, Freescale iMX.53 (cortex-a8)

fmt:
benchmark                      old ns/op    new ns/op    delta
BenchmarkSprintfEmpty                925          785  -15.14%
BenchmarkSprintfString              5050         5039   -0.22%
BenchmarkSprintfInt                 4425         4406   -0.43%
BenchmarkSprintfIntInt              5802         5762   -0.69%
BenchmarkSprintfPrefixedInt         7029         6541   -6.94%
BenchmarkSprintfFloat              10278        10083   -1.90%
BenchmarkManyArgs                  18558        17606   -5.13%
BenchmarkScanInts               15592690     15415360   -1.14%
BenchmarkScanRecursiveInt       25155020     25050900   -0.41%

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6921056
2012-12-22 09:09:31 +11:00
Rémy Oudompheng
64eb7749bc cmd/gc: mapassign2 doesn't exist anymore.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6997043
2012-12-21 20:39:30 +01:00
Shenghou Ma
c9eb6267df cmd/dist: make GOARM detection better compatible with thumb toolchain
Fixes #4557.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/6946078
2012-12-22 02:39:54 +08:00
Dmitriy Vyukov
74dcfc9576 cmd/go: improve wording of race detector documentation
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7006043
2012-12-21 19:11:10 +04:00
David Symonds
bb57670470 cmd/vet: expand printf flags understood by %s and %q.
Fixes #4580.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7002043
2012-12-21 13:48:36 +11:00
Rémy Oudompheng
1dcf658f6d cmd/gc: remove an incorrect assertion in escape analysis.
A fatal error used to happen when escassign-ing a multiple
function return to a single node. However, the situation
naturally appears when using "go f(g())" or "defer f(g())",
because g() is escassign-ed to sink.

Fixes #4529.

R=golang-dev, lvd, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6920060
2012-12-20 23:27:28 +01:00
Andrew Gerrand
2874cc4eed cmd/godoc: redirect for file with trailing /
Fixes #4543.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6971050
2012-12-21 07:03:00 +11:00
Joel Sing
e6ca125f14 cmd/[568]l: do not generate PT_TLS on openbsd
The OpenBSD ld.so(1) does not currently support PT_TLS and refuses
to load ELF binaries that contain PT_TLS sections. Do not emit PT_TLS
sections - we will handle this appropriately in runtime/cgo instead.

R=golang-dev, minux.ma, iant
CC=golang-dev
https://golang.org/cl/6846064
2012-12-21 01:27:50 +11:00
Andrew Gerrand
ff5d47ebba testing: only capture stdout when running examples
Fixes #4550.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6973048
2012-12-20 10:48:33 +11:00
Shenghou Ma
d1ef9b56fb all: fix typos
caught by https://github.com/lyda/misspell-check.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/6949072
2012-12-19 03:04:09 +08:00
Shenghou Ma
326ccebec8 cmd/go: pass gccgoflags at the end of gccgo command line, warn if user passes the wrong toolchain options
R=iant
CC=golang-dev
https://golang.org/cl/6940082
2012-12-19 01:48:09 +08:00
Shenghou Ma
c0927a6797 cmd/5l, cmd/6l, cmd/8l: fix function symbol generation from gcc compiled source code
For CL 6853059.

R=jsing, rsc
CC=golang-dev
https://golang.org/cl/6938076
2012-12-18 23:17:39 +08:00
Rémy Oudompheng
81b46f1bcd cmd/6g: fix componentgen for funarg structs.
Fixes #4518.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6932045
2012-12-17 22:29:43 +01:00
Russ Cox
b7603cfc2c cmd/gc: add GOEXPERIMENT=zerostack to clear stack on function entry
This is expensive but it might be useful in cases where
people are suffering from false positives during garbage
collection and are willing to trade the CPU time for getting
rid of the false positives.

On the other hand it only eliminates false positives caused
by other function calls, not false positives caused by dead
temporaries stored in the current function call.

The 5g/6g/8g changes were pulled out of the history, from
the last time we needed to do this (to work around a goto bug).
The code in go.h, lex.c, pgen.c is new but tiny.

R=ken2
CC=golang-dev
https://golang.org/cl/6938073
2012-12-17 14:32:26 -05:00
Shenghou Ma
1b18a6072e cmd/cgo: access errno from void C function
Fixes #3729.

R=rsc
CC=golang-dev
https://golang.org/cl/6938052
2012-12-18 00:26:08 +08:00
Dmitriy Vyukov
ca4b868e9a cmd/gc: racewalk: fix compiler crash
The code:
func main() {
        v := make([]int64, 10)
        i := 1
        _ = v[(i*4)/3]
}
crashes compiler with:

Program received signal SIGSEGV, Segmentation fault.
0x000000000043c274 in walkexpr (np=0x7fffffffc9b8, init=0x0) at src/cmd/gc/walk.c:587
587			*init = concat(*init, n->ninit);
(gdb) bt
#0  0x000000000043c274 in walkexpr (np=0x7fffffffc9b8, init=0x0) at src/cmd/gc/walk.c:587
#1  0x0000000000432d15 in copyexpr (n=0x7ffff7f69a48, t=<optimized out>, init=0x0) at src/cmd/gc/subr.c:2020
#2  0x000000000043f281 in walkdiv (init=0x0, np=0x7fffffffca70) at src/cmd/gc/walk.c:2901
#3  walkexpr (np=0x7ffff7f69760, init=0x0) at src/cmd/gc/walk.c:956
#4  0x000000000043d801 in walkexpr (np=0x7ffff7f69bc0, init=0x0) at src/cmd/gc/walk.c:988
#5  0x000000000043cc9b in walkexpr (np=0x7ffff7f69d38, init=0x0) at src/cmd/gc/walk.c:1068
#6  0x000000000043c50b in walkexpr (np=0x7ffff7f69f50, init=0x0) at src/cmd/gc/walk.c:879
#7  0x000000000043c50b in walkexpr (np=0x7ffff7f6a0c8, init=0x0) at src/cmd/gc/walk.c:879
#8  0x0000000000440a53 in walkexprlist (l=0x7ffff7f6a0c8, init=0x0) at src/cmd/gc/walk.c:357
#9  0x000000000043d0bf in walkexpr (np=0x7fffffffd318, init=0x0) at src/cmd/gc/walk.c:566
#10 0x00000000004402bf in vmkcall (fn=<optimized out>, t=0x0, init=0x0, va=0x7fffffffd368) at src/cmd/gc/walk.c:2275
#11 0x000000000044059a in mkcall (name=<optimized out>, t=0x0, init=0x0) at src/cmd/gc/walk.c:2287
#12 0x000000000042862b in callinstr (np=0x7fffffffd4c8, init=0x7fffffffd568, wr=0, skip=<optimized out>) at src/cmd/gc/racewalk.c:478
#13 0x00000000004288b7 in racewalknode (np=0x7ffff7f68108, init=0x7fffffffd568, wr=0, skip=0) at src/cmd/gc/racewalk.c:287
#14 0x0000000000428781 in racewalknode (np=0x7ffff7f65840, init=0x7fffffffd568, wr=0, skip=0) at src/cmd/gc/racewalk.c:302
#15 0x0000000000428abd in racewalklist (l=0x7ffff7f65840, init=0x0) at src/cmd/gc/racewalk.c:97
#16 0x0000000000428d0b in racewalk (fn=0x7ffff7f5f010) at src/cmd/gc/racewalk.c:63
#17 0x0000000000402b9c in compile (fn=0x7ffff7f5f010) at src/cmd/6g/../gc/pgen.c:67
#18 0x0000000000419f86 in funccompile (n=0x7ffff7f5f010, isclosure=0) at src/cmd/gc/dcl.c:1414
#19 0x0000000000424161 in p9main (argc=<optimized out>, argv=<optimized out>) at src/cmd/gc/lex.c:431
#20 0x0000000000401739 in main (argc=<optimized out>, argv=<optimized out>) at src/lib9/main.c:35

The problem is nil init passed to mkcall().

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6940045
2012-12-17 12:55:41 +04:00
Christopher Cahoon
c00371eafd cmd/fix: Add keys to printer.Config composite literals.
Fixes #4499.

R=rsc
CC=golang-dev
https://golang.org/cl/6931046
2012-12-16 19:31:59 -05:00
Rémy Oudompheng
1947960a6f cmd/gc: fix defaultlit of shifts used in interface context.
Fixes #4545.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6937058
2012-12-15 19:37:59 +01:00
Alex Brainman
04f0d148e9 cmd/go: handle os signals
Ignore signals during "go run" and wait for running child
process to exit. Stop executing further tests during "go test",
wait for running tests to exit and report error exit code.

Original CL 6351053 by dfc.

Fixes #3572.
Fixes #3581.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6903061
2012-12-14 17:33:59 +11:00
Dave Cheney
b2797f2ae0 cmd/{5,6,8}g: reduce size of Prog and Addr
5g: Prog went from 128 bytes to 88 bytes
6g: Prog went from 174 bytes to 144 bytes
8g: Prog went from 124 bytes to 92 bytes

There may be a little more that can be squeezed out of Addr, but alignment will be a factor.

All: remove the unused pun field from Addr

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6922048
2012-12-14 06:20:24 +11:00
Daniel Morsing
bf59aafddc cmd/gc: Give better line numbers for errors in composite literals.
Credit to Russ for suggesting this fix.

Fixes #3925.

R=golang-dev, franciscossouza, rsc
CC=golang-dev
https://golang.org/cl/6920051
2012-12-12 16:43:54 +01:00
Dave Cheney
11d96dd7f5 go/build: give better explanation for "cannot find package"
Fixes #4079.

Some example output:

% go install foo/bar
can't load package: package foo/bar: cannot find package "foo/bar" in any of:
        /home/dfc/go/src/pkg/foo/bar (from $GOROOT)
        /home/dfc/src/foo/bar (from $GOPATH)
        /home/dfc/src2/src/foo/bar

% GOPATH= go install foo/bar
can't load package: package foo/bar: cannot find package "foo/bar" in any of:
	/home/dfc/go/src/pkg/foo/bar (from $GOROOT)
	($GOPATH not set)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6899057
2012-12-12 21:38:52 +11:00
Dave Cheney
5bdf40dcca cmd/5g: avoid temporary during OMINUS
Saves one MOVW and one register during the fast div/mod introduced in CL 6819123.

linux/arm (armv5)

benchmark               old ns/op    new ns/op    delta
BenchmarkInt64Mod1             12           12   +7.50%
BenchmarkUint16Mod2             7            7   +0.28%
BenchmarkUint16Mod4             7            7   -0.28%
BenchmarkUint64Mod1            15           11  -23.72%
BenchmarkInt8Neg                8            7  -17.66%
BenchmarkInt16Neg               8            7  -17.66%
BenchmarkInt32Neg               5            5   -9.04%
BenchmarkUint8Neg               7            6  -14.35%
BenchmarkUint16Neg              8            7  -17.66%
BenchmarkUint32Neg              5            5   -9.04%

R=rsc
CC=golang-dev
https://golang.org/cl/6842045
2012-12-12 19:25:22 +11:00
Rémy Oudompheng
11999306df cmd/gc: don't import the same package multiple times.
Implementation suggested by DMorsing.

R=golang-dev, dave, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6903059
2012-12-12 08:47:09 +01:00
Rémy Oudompheng
a617d06252 cmd/6g, cmd/8g: simplify integer division code.
Change suggested by iant. The compiler generates
special code for a/b when a is -0x80...0 and b = -1.
A single instruction can cover the case where b is -1,
so only one comparison is needed.

Fixes #3551.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6922049
2012-12-12 08:35:08 +01:00
Miquel Sabaté Solà
0dd0e1ad0c cmd/gc: merge casep and casee labels
The code inside the casee and casep labels can perfectly be merged since
they essentially do the same. The character to be stored where cp points is
just the character contained by the c variable.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6845112
2012-12-11 12:23:04 -05:00
Daniel Morsing
0d22573f6e cmd/gc: remove bad check for BADWIDTH
This check for BADWIDTH might happen while in defercheckwidth, making it raise errors for non-erroneous situations.

Fixes #4495.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6927043
2012-12-11 17:36:10 +01:00
Dave Cheney
033e915481 cmd/go: add GOOS/GOARCH to go version output
Fixes #4492.

% go version
go version devel +6b602ab487d6 Sat Dec 08 14:43:00 2012 +0100 linux/amd64

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6906058
2012-12-10 07:05:17 +11:00
Rémy Oudompheng
10d14b63c2 cmd/gc: prevent ngotype from allocating.
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6904061
2012-12-09 19:27:23 +01:00
Rémy Oudompheng
45fe306ac8 cmd/[568]g: recycle ONAME nodes used in regopt to denote registers.
The reported decrease in memory usage is about 5%.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6902064
2012-12-09 19:10:52 +01:00
Rémy Oudompheng
561edbd63c cmd/gc: do not export useless private symbols.
Fixes #4252.

R=rsc, golang-dev, mirtchovski, daniel.morsing, dave, lvd
CC=golang-dev
https://golang.org/cl/6856126
2012-12-08 14:43:00 +01:00
Robert Griesemer
42a854b746 gofmt: test rewrite of (x.(type)) -> x.(type)
R=rsc
CC=golang-dev
https://golang.org/cl/6867062
2012-12-06 09:20:03 -08:00
Rémy Oudompheng
9146ac14ee cmd/gc: do not overflow parser stack on a long chain of else if.
Fixes #2615.

R=dave, minux.ma, iant, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6847078
2012-12-06 08:09:17 +01:00
Rémy Oudompheng
755e13877f cmd/8a: support XMM registers.
R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/6884046
2012-12-06 07:27:38 +01:00
Rémy Oudompheng
5cb1ed2189 cmd/6c, cmd/8c: add fixjmp step to regopt.
The fixjmp step eliminates redundant chains of JMP
instructions that are produced by the compiler during
code generation.

It is already implemented in gc, and can be adapted to 6c/8c with
the exception that JMPs refer to destination by pc instead of by
pointer. The algorithm is modified to operate on Regs instead of Progs
for this reason. The pcs are already restored later by regopt.

R=goalng-dev, rsc
CC=golang-dev
https://golang.org/cl/6865046
2012-12-06 07:20:03 +01:00
Dave Cheney
e4d2cd9d0a cmd/5g: fix fixedtests/issue4396b.go test failure on arm5
Add missing file that should have been included in CL 6854063 / 5eac1a2d6fc3

R=remyoudompheng, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6891049
2012-12-06 16:52:16 +11:00
Russ Cox
9d2b0e86c8 cmd/ld: skip 0-length write in cwrite
The 0-length part is fine, but some callers that write 0 bytes
also pass nil as the data pointer, and the Plan 9 kernel kills the
process with 'invalid address in sys call' in that case.

R=ken2
CC=golang-dev
https://golang.org/cl/6862051
2012-12-06 00:00:20 -05:00
David Symonds
82f2b36e74 vet: be less strict about number of arguments when a ... is present.
R=golang-dev
CC=golang-dev
https://golang.org/cl/6883046
2012-12-06 15:17:31 +11:00
Ian Lance Taylor
08918ba438 gc: avoid meaningless constant overflow error for inverted slice range
Used to say:

issue4251.go:12: inverted slice range
issue4251.go:12: constant -1 overflows uint64
issue4251.go:16: inverted slice range
issue4251.go:16: constant -1 overflows uint64
issue4251.go:20: inverted slice range
issue4251.go:20: constant -1 overflows uint64

With this patch, only gives the "inverted slice range" errors.

R=golang-dev, daniel.morsing
CC=golang-dev
https://golang.org/cl/6871058
2012-12-05 15:46:45 -08:00
Dave Cheney
54e8d504e8 cmd/5g: use MOVB for fixed array nil check
Fixes #4396.

For fixed arrays larger than the unmapped page, agenr would general a nil check by loading the first word of the array. However there is no requirement for the first element of a byte array to be word aligned, so this check causes a trap on ARMv5 hardware (ARMv6 since relaxed that restriction, but it probably still comes at a cost).

Switching the check to MOVB ensures alignment is not an issue. This check is only invoked in a few places in the code where large fixed arrays are embedded into structs, compress/lzw is the biggest offender, and switching to MOVB has no observable performance penalty.

Thanks to Rémy and Daniel Morsing for helping me debug this on IRC last night.

R=remyoudompheng, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6854063
2012-12-06 08:01:33 +11:00
Dave Cheney
3167c12eb2 cmd/dist: support building on debian/kFreeBSD
The debian/kFreeBSD project uses the FreeBSD kernel and the debian userspace. From our point of view, this is freebsd not linux as GOOS talks about the kernel syscall interface, not the userspace (although cgo alters that). As debian/kFreeBSD is experimental at this time, I do not think it is worth the effort of duplicating all the freebsd specific code so this is proposal represents a reasonable workaround.

Currently cgo is not supported, make.bash will detect this and disable cgo automatically during the build.

dfc@debian:~/go/src$ uname -a
GNU/kFreeBSD debian 8.1-1-686 #0 Sat Jul 21 17:02:04 UTC 2012 i686 i386 Intel(R) Core(TM) i5-2415M CPU @ 2.30GHz GNU/kFreeBSD
dfc@debian:~/go/src$ ../bin/go version
go version devel +d05272f402ec Sat Dec 01 15:15:14 2012 -0800

Tested with GOOS=freebsd GOARCH=386

R=golang-dev
CC=golang-dev
https://golang.org/cl/6868046
2012-12-04 08:27:30 +11:00
Rémy Oudompheng
bcea0dd1d0 cmd/gc: fix inlining internal error with T.Method calls.
The compiler was confused when inlining a T.Method(f()) call
where f returns multiple values: support for this was marked
as TODO.

Variadic calls are not supported but are not inlined either.
Add a test preventively for that case.

Fixes #4167.

R=golang-dev, rsc, lvd
CC=golang-dev
https://golang.org/cl/6871043
2012-12-03 13:39:40 +01:00
Shenghou Ma
279199ebcc cmd/godoc: fix godoc net/http on windows
`godoc net/http` used to complain "/target contains more than one package: http, main"

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6852100
2012-12-01 00:42:50 +08:00
Dmitriy Vyukov
c3c107f67c cmd/gc: racewalk: collect stack traces in sync and sync/atomic
W/o this change stack traces do not show from where sync.Once()
or atomic.XXX was called.
This change add funcenter/exit instrumentation to sync/sync.atomic
packages.

R=golang-dev
CC=golang-dev
https://golang.org/cl/6854112
2012-11-30 10:27:43 +04:00
Rémy Oudompheng
f134742f24 cmd/5g, cmd/8g: fix internal error on 64-bit indices statically bounded
Fixes #4448.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6855100
2012-11-27 21:37:38 +01:00
Robert Griesemer
e781b20ac9 go/format: Package format implements standard formatting of Go source.
Package format is a utility package that takes care of
parsing, sorting of imports, and formatting of .go source
using the canonical gofmt formatting parameters.

Use go/format in various clients instead of the lower-level components.

R=r, bradfitz, dave, rogpeppe, rsc
CC=golang-dev
https://golang.org/cl/6852075
2012-11-27 10:29:49 -08:00
Rémy Oudompheng
4cc9de9147 cmd/gc: add division rewrite to walk pass.
This allows 5g and 8g to benefit from the rewrite as shifts
or magic multiplies. The 64-bit arithmetic is not handled there,
and left in 6g.

Update #2230.

R=golang-dev, dave, mtj, iant, rsc
CC=golang-dev
https://golang.org/cl/6819123
2012-11-26 23:45:22 +01:00
Daniel Morsing
5188c0b59c cmd/gc: Make sure bools lose idealness when used with logical operators.
Bools from comparisons can be assigned to all bool types, but this idealness would propagate through logical operators when the result should have been lowered to a non-ideal form.

Fixes #3924.

R=golang-dev, remyoudompheng, r, rsc, mtj
CC=golang-dev
https://golang.org/cl/6855061
2012-11-26 22:23:13 +01:00
Rémy Oudompheng
2e73453aca cmd/6l, cmd/8l: emit no-ops to separate zero-stack funcs from nosplits.
The stack overflow checker in the linker uses the spadj field
to determine whether stack space will be large enough or not.
When spadj=0, the checker treats the function as a nosplit
and emits an error although the program is correct.

Also enable the stack checker in 8l.

Fixes #4316.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/6855088
2012-11-26 21:51:48 +01:00
Rémy Oudompheng
54023a94a6 cmd/8l: fix data corruption for MULB SI,
The 8l linker automatically inserts XCHG instructions
to support otherwise impossible byte registers
(only available on AX, BX, CX, DX).

Sometimes AX or DX is needed (for MUL and DIV) so
we need to avoid clobbering them.

R=golang-dev, dave, iant, iant, rsc
CC=golang-dev
https://golang.org/cl/6846057
2012-11-26 21:31:42 +01:00
Shenghou Ma
af375cde20 libmach, cmd/cc, cmd/cov, cmd/ld, cmd/prof: check malloc return value
Update #4415.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6856080
2012-11-27 03:05:46 +08:00
Dmitriy Vyukov
7f08218050 cnd/gc: fix build
R=golang-dev
CC=golang-dev
https://golang.org/cl/6856097
2012-11-26 22:14:43 +04:00
Dmitriy Vyukov
db8d7a292d cmd/go: racewalk: fix nested struct handling
Fixes #4424.
Fixes #4425.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6849093
2012-11-26 22:11:05 +04:00
Shenghou Ma
7c295f3f0c cmd/gc: fix invalid indirect error at statement level
Fixes #4429.

R=golang-dev, remyoudompheng, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6850097
2012-11-27 01:46:54 +08:00
Mikio Hara
e8cf49f701 net, cmd/fix: add IPv6 scoped addressing zone to INET, INET6 address structs
This CL starts to introduce IPv6 scoped addressing capability
into the net package.

The Public API changes are:
+pkg net, type IPAddr struct, Zone string
+pkg net, type IPNet struct, Zone string
+pkg net, type TCPAddr struct, Zone string
+pkg net, type UDPAddr struct, Zone string

Update #4234.

R=rsc, bradfitz, iant
CC=golang-dev
https://golang.org/cl/6849045
2012-11-27 00:45:42 +09:00
Joel Sing
5da5e8e02f cmd/gc: check malloc return value
Check the return value from malloc - do not assume that we were
allocated memory just because we asked for it.

Update #4415.

R=minux.ma, daniel.morsing, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6782100
2012-11-26 22:03:31 +11:00
Ian Lance Taylor
9017765a82 cmd/go: fix typo in comment
Fixes #4432.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6858064
2012-11-24 11:25:17 -08:00
Shenghou Ma
7171f533d0 cmd/go: fix data race on cgoLibGccFile
Fixes #4426.

R=dvyukov
CC=golang-dev
https://golang.org/cl/6851099
2012-11-23 19:58:46 +08:00
Shenghou Ma
f142deee95 cmd/go: show -race if necessary when giving "go test -i" hint
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6851100
2012-11-23 19:29:22 +08:00
Vladimir Nikishenko
dd01e9281d cmd/cgo: fix alignment of bool.
Fixes #4417.

R=golang-dev, iant, minux.ma, bradfitz
CC=golang-dev, vova616
https://golang.org/cl/6782097
2012-11-21 13:04:38 -08:00
Rémy Oudompheng
1bd4a7dbcb cmd/8g: fix erroneous LEAL nil.
Fixes #4399.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/6845053
2012-11-21 08:39:45 +01:00
Brad Fitzpatrick
aeca7a7cd2 cmd/api: speed up API check by 2x, caching parser.ParseFile calls
Saves 5 seconds on my machine. If Issue 4380 is fixed this
clone can be removed.

Update #4380

R=golang-dev, remyoudompheng, minux.ma, gri
CC=golang-dev
https://golang.org/cl/6845058
2012-11-19 13:50:20 -08:00
Robert Griesemer
8f3b703323 cmd/gc: complain about invalid whitespace chars
Fixes #4405.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/6855060
2012-11-19 09:09:04 -08:00
Robert Griesemer
80dcc434a8 go/doc: fix identifier blank import handling for examples
Replacement CL for 6813061; thanks to minux for prototyping.

Fixes #4300.

R=minux.ma
CC=golang-dev
https://golang.org/cl/6782082
2012-11-17 10:40:11 -08:00
Shenghou Ma
3513d84068 runtime/cgo: fix compilation on Windows with CFLAGS -Wall -Werror
also fix one out-of-date comment in cmd/ld/pe.c as well.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/6843061
2012-11-18 02:06:08 +08:00
Dmitriy Vyukov
89bfddbf67 cmd/gc: racewalk: handle OEFACE/OCONVIFACE
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6821096
2012-11-14 16:30:53 +04:00
Dmitriy Vyukov
96833d3a25 cmd/gc: racewalk: fix instrumentation of structs
+ do not instrument go.itab.*

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6819106
2012-11-14 16:26:00 +04:00
Russ Cox
2e77bc48aa cmd/ld: fix build on elf systems
TBR=iant
CC=golang-dev
https://golang.org/cl/6843050
2012-11-13 13:12:11 -05:00
Russ Cox
1120982590 reflect: add ArrayOf, ChanOf, MapOf, SliceOf
In order to add these, we need to be able to find references
to such types that already exist in the binary. To do that, introduce
a new linker section holding a list of the types corresponding to
arrays, chans, maps, and slices.

To offset the storage cost of this list, and to simplify the code,
remove the interface{} header from the representation of a
runtime type. It was used in early versions of the code but was
made obsolete by the kind field: a switch on kind is more efficient
than a type switch.

In the godoc binary, removing the interface{} header cuts two
words from each of about 10,000 types. Adding back the list of pointers
to array, chan, map, and slice types reintroduces one word for
each of about 500 types. On a 64-bit machine, then, this CL *removes*
a net 156 kB of read-only data from the binary.

This CL does not include the needed support for precise garbage
collection. I have created issue 4375 to track that.

This CL also does not set the 'algorithm' - specifically the equality
and copy functions - for a new array correctly, so I have unexported
ArrayOf for now. That is also part of issue 4375.

Fixes #2339.

R=r, remyoudompheng, mirtchovski, iant
CC=golang-dev
https://golang.org/cl/6572043
2012-11-13 13:06:29 -05:00
Brad Fitzpatrick
0eb42fa6e4 cmd/api: use one token.FileSet for all contexts
Prep for future CL.

R=gri
CC=golang-dev
https://golang.org/cl/6843048
2012-11-13 09:59:46 -08:00
Rémy Oudompheng
fa316ba4d8 cmd/8g: eliminate obviously useless temps before regopt.
This patch introduces a sort of pre-regopt peephole optimization.
When a temporary is introduced that just holds a value for the
duration of the next instruction and is otherwise unused, we
elide it to make the job of regopt easier.

Since x86 has very few registers, this situation happens very
often. The result is large savings in stack variables for
arithmetic-heavy functions.

crypto/aes

benchmark                 old ns/op    new ns/op    delta
BenchmarkEncrypt               1301          392  -69.87%
BenchmarkDecrypt               1309          368  -71.89%
BenchmarkExpand                2913         1036  -64.44%
benchmark                  old MB/s     new MB/s  speedup
BenchmarkEncrypt              12.29        40.74    3.31x
BenchmarkDecrypt              12.21        43.37    3.55x

crypto/md5

benchmark                 old ns/op    new ns/op    delta
BenchmarkHash8Bytes            1761          914  -48.10%
BenchmarkHash1K               16912         5570  -67.06%
BenchmarkHash8K              123895        38286  -69.10%
benchmark                  old MB/s     new MB/s  speedup
BenchmarkHash8Bytes            4.54         8.75    1.93x
BenchmarkHash1K               60.55       183.83    3.04x
BenchmarkHash8K               66.12       213.97    3.24x

bench/go1

benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    8364835000   8303154000   -0.74%
BenchmarkFannkuch11      7511723000   6381729000  -15.04%
BenchmarkGobDecode         27764090     27103270   -2.38%
BenchmarkGobEncode         11240880     11184370   -0.50%
BenchmarkGzip            1470224000    856668400  -41.73%
BenchmarkGunzip           240660800    201697300  -16.19%
BenchmarkJSONEncode       155225800    185571900  +19.55%
BenchmarkJSONDecode       243347900    282123000  +15.93%
BenchmarkMandelbrot200     12240970     12201880   -0.32%
BenchmarkParse              8837445      8765210   -0.82%
BenchmarkRevcomp         2556310000   1868566000  -26.90%
BenchmarkTemplate         389298000    379792000   -2.44%
benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            27.64        28.32    1.02x
BenchmarkGobEncode            68.28        68.63    1.01x
BenchmarkGzip                 13.20        22.65    1.72x
BenchmarkGunzip               80.63        96.21    1.19x
BenchmarkJSONEncode           12.50        10.46    0.84x
BenchmarkJSONDecode            7.97         6.88    0.86x
BenchmarkParse                 6.55         6.61    1.01x
BenchmarkRevcomp              99.43       136.02    1.37x
BenchmarkTemplate              4.98         5.11    1.03x

Fixes #4035.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6828056
2012-11-13 07:39:18 +01:00
Rémy Oudompheng
0a47d2eff1 cmd/gc: fix typos in clearslim.
Fixes build failure.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6847043
2012-11-13 07:08:29 +01:00
Rémy Oudompheng
16072c7497 cmd/6g: extend componentgen to small arrays and structs.
Fixes #4092.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6819083
2012-11-13 00:08:04 +01:00
Rémy Oudompheng
eb4f4d16ae cmd/5g, cmd/6g: pass the full torture test.
The patch adds more cases to agenr to allocate registers later,
and makes 6g generate addresses for sgen in something else than
SI and DI. It avoids a complex save/restore sequence that
amounts to allocate a register before descending in subtrees.

Fixes #4207.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6817080
2012-11-12 23:56:11 +01:00
Dave Cheney
3f26c5e124 cmd/5g: enable xtramodes optimisation
xtramodes' C_PBIT optimisation transforms:

MOVW          0(R3),R1
ADD           $4,R3,R3

into:

MOVW.P        4(R3),R1

and the AADD optimisation tranforms:

ADD          R0,R1
MOVBU        0(R1),R0

into:

MOVBU        R0<<0(R1),R0

5g does not appear to generate sequences that
can be transformed by xtramodes' AMOVW.

R=remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6817085
2012-11-11 07:51:20 +11:00
Rémy Oudompheng
cc224c004d cmd/6c, cmd/8c: use signed char explicitly in mul.c
On ARM, char is unsigned, and the code generation for
multiplication gets totally broken.

Fixes #4354.

R=golang-dev, dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6826079
2012-11-09 21:06:45 +01:00
Dmitriy Vyukov
4ef91fc854 cmd/go: fix selection of packages for testing
Currently it works incorrectly if user specifies own build tags
and with race detection (e.g. runtime/race is not selected,
because it contains only test files with +build race).

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6814107
2012-11-09 14:00:41 +04:00
Russ Cox
761830f481 cmd/gc: fix export of inlined function body with type guard
When exporting a body containing
        x, ok := v.(Type)

the definition for Type was not being included, so when the body
was actually used, it would cause an "unknown type" compiler error.

Fixes #4370.

R=ken2
CC=golang-dev
https://golang.org/cl/6827064
2012-11-08 16:07:05 -05:00
Brad Fitzpatrick
a384b5b9c3 cmd/api: bug fix for goapi's lame type checker
This is blocking me submitting the net fd timeout
CL, since goapi chokes on my constant.

The much more extensive fix to goapi's type checker
in pending review in https://golang.org/cl/6742050

But I'd rather get this quick fix in first.

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6818104
2012-11-08 10:34:54 -06:00
Alex Brainman
122c154c60 cmd/go: say that -race flag can be used on windows/amd64
R=golang-dev, r
CC=dvyukov, golang-dev
https://golang.org/cl/6810099
2012-11-08 13:00:54 +11:00
Ian Lance Taylor
e3977f0d3a cmd/gc: warn about slice indexes larger than int in typecheck pass
Fixes GOARCH=386 build.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6810098
2012-11-07 17:34:06 -08:00
Rémy Oudompheng
c208a3a263 cmd/gc: fix internal compiler error with broken structs.
Fixes #4359.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6834043
2012-11-07 23:09:01 +01:00
Rémy Oudompheng
7c0cbbfa18 cmd/6g, cmd/8g: mark used registers in indirect addressing.
Fixes #4094.
Fixes #4353.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6810090
2012-11-07 21:36:15 +01:00
Russ Cox
71282131a1 cmd/gc: fix escape analysis bug
The code assumed that the only choices were EscNone, EscScope, and EscHeap,
so that it makes sense to set EscScope only if the current setting is EscNone.
Now that we have the many variants of EscReturn, this logic is false, and it was
causing important EscScopes to be ignored in favor of EscReturn.

Fixes #4360.

R=ken2
CC=golang-dev, lvd
https://golang.org/cl/6816103
2012-11-07 15:15:21 -05:00
Dmitriy Vyukov
1ebf2d85ba runtime/race: add Windows support
This is copy of https://golang.org/cl/6810080
but sent from another account (dvyukov@gmail.com is not in CONTRIBUTORS).

R=rsc
CC=golang-dev
https://golang.org/cl/6827060
2012-11-07 23:59:09 +04:00
Russ Cox
cb856adea9 cmd/gc: annotate local variables with unique ids for inlining
Avoids problems with local declarations shadowing other names.
We write a more explicit form than the incoming program, so there
may be additional type annotations. For example:

        int := "hello"
        j := 2

would normally turn into

        var int string = "hello"
        var j int = 2

but the int variable shadows the int type in the second line.

This CL marks all local variables with a per-function sequence number,
so that this would instead be:

        var int·1 string = "hello"
        var j·2 int = 2

Fixes #4326.

R=ken2
CC=golang-dev
https://golang.org/cl/6816100
2012-11-07 09:59:19 -05:00
Russ Cox
c6f363b22a cmd/gc: fix go:nointerface export comment
R=ken
CC=golang-dev
https://golang.org/cl/6815073
2012-11-07 09:14:21 -05:00
Dmitriy Vyukov
a3a7244779 cmd/gc: racewalk: instrument returnsfromheap params
Fixes #4307.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6822073
2012-11-07 12:10:35 +04:00
Dmitriy Vyukov
abb313f8c8 cmd/gc: racewalk: do not double function calls
Current racewalk transformation looks like:
x := <-makeChan().c
\/\/\/\/\/\/\/\/\/
runtime.raceread(&makeChan().c)
x := <-makeChan().c
and so makeChan() is called twice.
With this CL the transformation looks like:
x := <-makeChan().c
\/\/\/\/\/\/\/\/\/
chan *tmp = &(makeChan().c)
raceread(&*tmp)
x := <-(*tmp)
Fixes #4245.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6822075
2012-11-07 12:06:27 +04:00
Dmitriy Vyukov
703043c8dc cmd/gc: refactor racewalk
It is refactoring towards generic walk
+ it handles mode nodes.
Partially fixes 4228 issue.

R=golang-dev, lvd, rsc
CC=golang-dev
https://golang.org/cl/6775098
2012-11-07 12:01:31 +04:00
Rémy Oudompheng
1e233ad075 cmd/6g: fix use of large integers as indexes or array sizes.
A check for smallintconst was missing before generating the
comparisons.

Fixes #4348.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6815088
2012-11-06 22:53:57 +01:00
Shenghou Ma
3e80f9ce7b cmd/go: invoke gcc -print-libgcc-file-name only once
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6741051
2012-11-07 05:09:54 +08:00
Péter Surányi
91651c1844 cmd/godoc: initialize filesystem and metadata for -url
Unlike when using -http, godoc -url didn't initialize the "filesystem"
and metadata that are used when generating responses. This CL adds this
initialization, so that -url provides the same results as an HTTP
request when using -http.

Fixes #4335.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6817075
2012-11-07 04:59:21 +08:00
Daniel Morsing
d098bffd84 cmd/gc, runtime: avoid unnecessary copy on type assertion.
When the first result of a type assertion is blank, the compiler would still copy out a potentially large non-interface type.

Fixes #1021.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6812079
2012-11-06 20:40:40 +01:00
Ian Lance Taylor
2355409988 cmd/gc: don't require that slice index constants be small ints
The test for this is test/index.go, which is not run by
default.

R=remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6812089
2012-11-06 11:36:59 -08:00
Ian Lance Taylor
72bf3bc176 cmd/gc: check for array bounds overflow in slice expression
The test for this is test/index.go, which is not run by
default.  That test does not currently pass even after this is
applied, due to issue 4348.

Fixes #4344.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6815085
2012-11-06 11:35:58 -08:00
Dmitriy Vyukov
fb9706d3be cmd/go: use correct paths with race detector
Currently the build fails with -race if a package in GOPATH
imports another package in GOPATH.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6811083
2012-11-06 20:11:49 +04:00
Andrew Gerrand
c1c136d0c4 cmd/godoc: use normal gofmt printer settings for playground fmt
R=gri
CC=golang-dev
https://golang.org/cl/6815081
2012-11-05 22:46:28 +01:00
Dave Cheney
d8008a9eef cmd/5g: improve shift code generation
This CL is a backport of 6012049 which improves code
generation for shift operations.

benchmark       old ns/op    new ns/op    delta
BenchmarkLSL            9            5  -49.67%
BenchmarkLSR            9            4  -50.00%

R=golang-dev, minux.ma, r, rsc
CC=golang-dev
https://golang.org/cl/6813045
2012-11-04 20:06:37 +11:00
Rémy Oudompheng
c46f1f40da cmd/gc: instrument blocks for race detection.
It happens that blocks are used for function calls in a
quite low-level way so they cannot be instrumented as
usual.

Blocks are also used for inlined functions.

R=golang-dev, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/6821068
2012-11-03 00:11:06 +01:00
Shenghou Ma
31f8b07e55 runtime/cgo, go/build: cgo support for FreeBSD/ARM
This is the last CL for FreeBSD/ARM support.
Also update cmd/ld/doc.go for 5l support of -Hfreebsd.

R=rsc
CC=golang-dev
https://golang.org/cl/6650051
2012-11-03 02:22:37 +08:00
Rémy Oudompheng
0b2353edcb cmd/5g, cmd/6g: fix out of registers with array indexing.
Compiling expressions like:
    s[s[s[s[s[s[s[s[s[s[s[s[i]]]]]]]]]]]]
make 5g and 6g run out of registers. Such expressions can arise
if a slice is used to represent a permutation and the user wants
to iterate it.

This is due to the usual problem of allocating registers before
going down the expression tree, instead of allocating them in a
postfix way.

The functions cgenr and agenr (that generate a value to a newly
allocated register instead of an existing location), are either
introduced or modified when they already existed to allocate
the new register as late as possible, and sudoaddable is disabled
for OINDEX nodes so that igen/agenr is used instead.

Update #4207.

R=dave, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6733055
2012-11-02 07:50:59 +01:00
Russ Cox
3d40062c68 cmd/gc, cmd/ld: struct field tracking
This is an experiment in static analysis of Go programs
to understand which struct fields a program might use.
It is not part of the Go language specification, it must
be enabled explicitly when building the toolchain,
and it may be removed at any time.

After building the toolchain with GOEXPERIMENT=fieldtrack,
a specific field can be marked for tracking by including
`go:"track"` in the field tag:

        package pkg

        type T struct {
                F int `go:"track"`
                G int // untracked
        }

To simplify usage, only named struct types can have
tracked fields, and only exported fields can be tracked.

The implementation works by making each function begin
with a sequence of no-op USEFIELD instructions declaring
which tracked fields are accessed by a specific function.
After the linker's dead code elimination removes unused
functions, the fields referred to by the remaining
USEFIELD instructions are the ones reported as used by
the binary.

The -k option to the linker specifies the fully qualified
symbol name (such as my/pkg.list) of a string variable that
should be initialized with the field tracking information
for the program. The field tracking string is a sequence
of lines, each terminated by a \n and describing a single
tracked field referred to by the program. Each line is made
up of one or more tab-separated fields. The first field is
the name of the tracked field, fully qualified, as in
"my/pkg.T.F". Subsequent fields give a shortest path of
reverse references from that field to a global variable or
function, corresponding to one way in which the program
might reach that field.

A common source of false positives in field tracking is
types with large method sets, because a reference to the
type descriptor carries with it references to all methods.
To address this problem, the CL also introduces a comment
annotation

        //go:nointerface

that marks an upcoming method declaration as unavailable
for use in satisfying interfaces, both statically and
dynamically. Such a method is also invisible to package
reflect.

Again, all of this is disabled by default. It only turns on
if you have GOEXPERIMENT=fieldtrack set during make.bash.

R=iant, ken
CC=golang-dev
https://golang.org/cl/6749064
2012-11-02 00:17:21 -04:00
Dmitriy Vyukov
936498e5dc cmd/gc: fix build
R=golang-dev
CC=golang-dev
https://golang.org/cl/6826047
2012-11-01 22:59:53 +04:00
Dmitriy Vyukov
de10a23db1 cmd/gc: racewalk: fix a bunch of minor issues
1. Prepend racefuncenter() to fn->enter -- fn->enter can contain new() calls,
and we want them to be in the scope of the function.
2. Dump fn->enter and fn->exit.
3. Add TODO that OTYPESW expression can contain interesting memory accesses.
4. Ignore only _ names instead of all names starting with _.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6822048
2012-11-01 22:56:04 +04:00
Rémy Oudompheng
ce287933d6 cmd/gc, runtime: pass PC directly to racefuncenter.
go test -race -run none -bench . encoding/json
benchmark                      old ns/op    new ns/op    delta
BenchmarkCodeEncoder          3207689000   1716149000  -46.50%
BenchmarkCodeMarshal          3206761000   1715677000  -46.50%
BenchmarkCodeDecoder          8647304000   4482709000  -48.16%
BenchmarkCodeUnmarshal        8032217000   3451248000  -57.03%
BenchmarkCodeUnmarshalReuse   8016722000   3480502000  -56.58%
BenchmarkSkipValue           10340453000   4560313000  -55.90%

benchmark                       old MB/s     new MB/s  speedup
BenchmarkCodeEncoder                0.60         1.13    1.88x
BenchmarkCodeMarshal                0.61         1.13    1.85x
BenchmarkCodeDecoder                0.22         0.43    1.95x
BenchmarkCodeUnmarshal              0.24         0.56    2.33x
BenchmarkCodeUnmarshalReuse         0.24         0.56    2.33x
BenchmarkSkipValue                  0.19         0.44    2.32x

Fixes #4248.

R=dvyukov, golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6815066
2012-11-01 19:43:29 +01:00
Ian Lance Taylor
3b04d23cbf cmd/cgo: improve gccgo support
Use wrapper functions to tell scheduler what we are doing.

With this patch, and a separate patch to the go tool, all the
cgo tests pass with gccgo.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6812058
2012-11-01 11:21:30 -07:00
Ian Lance Taylor
f284a3ff4d cmd/go: fixes to gccgo support
* Use -fgo-pkgpath and -gccgopkgpath rather than -fgo-prefix
  and -gccgoprefix.
* Define GOPKGPATH when compiling .c or .s files for gccgo.
* Use -fgo-relative-import-path.
* Produce .o files for gccgo, not .[568] files.
* Pass -E when linking if using cgo.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6820064
2012-11-01 11:13:50 -07:00
Dmitriy Vyukov
b11f85a8aa cmd/gc: racewalk: fix instrumentation of ninit lists
The idea is to (1) process ninit of all nodes,
and (2) put instrumentation of ninit into the nodes themselves (not the top-level statement ninit).
Fixes #4304.

R=golang-dev, rsc
CC=golang-dev, lvd
https://golang.org/cl/6818049
2012-11-01 22:11:12 +04:00
Rémy Oudompheng
8d95245d0d cmd/gc: fix incomplete export data when inlining with local variables.
When local declarations needed unexported types, these could
be missing in the export data.

Fixes build with -gcflags -lll, except for exp/gotype.

R=golang-dev, rsc, lvd
CC=golang-dev
https://golang.org/cl/6813067
2012-11-01 19:06:52 +01:00
Rémy Oudompheng
76500b14a1 cmd/gc: fix inlining bug with local variables.
Fixes #4323.

R=rsc, lvd, golang-dev
CC=golang-dev
https://golang.org/cl/6815061
2012-11-01 18:59:32 +01:00
Daniel Morsing
85d60a727c cmd/gc: do simple bounds checking of constant indices/slices in typecheck.
This should make the compiler emit errors specific to the bounds checking instead of overflow errors on the underlying types.

Updates #4232.

R=rsc
CC=golang-dev
https://golang.org/cl/6783054
2012-11-01 18:45:19 +01:00
Russ Cox
e4cef96be6 cmd/gc: avoid %#x of 0
Plan 9 and Go's lib9/fmt disagree on whether %#x includes the 0x prefix
when printing 0, because ANSI C gave bad advice long ago.

Avoiding that case makes binaries compiled on different systems compatible.

R=ken2
CC=akumar, golang-dev
https://golang.org/cl/6814066
2012-11-01 12:55:21 -04:00
Rémy Oudompheng
022b361ae2 cmd/5g, cmd/6g, cmd/8g: remove width check for componentgen.
The move to 64-bit ints in 6g made componentgen ineffective.
In componentgen, the code already selects which values it can handle.

On amd64:
benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    9477970000   9582314000   +1.10%
BenchmarkFannkuch11      5928750000   5255080000  -11.36%
BenchmarkGobDecode         37103040     31451120  -15.23%
BenchmarkGobEncode         16042490     16844730   +5.00%
BenchmarkGzip             811337400    741373600   -8.62%
BenchmarkGunzip           197928700    192844500   -2.57%
BenchmarkJSONEncode       224164100    140064200  -37.52%
BenchmarkJSONDecode       258346800    231829000  -10.26%
BenchmarkMandelbrot200      7561780      7601615   +0.53%
BenchmarkParse             12970340     11624360  -10.38%
BenchmarkRevcomp         1969917000   1699137000  -13.75%
BenchmarkTemplate         296182000    263117400  -11.16%

R=nigeltao, dave, daniel.morsing
CC=golang-dev
https://golang.org/cl/6821052
2012-11-01 14:36:08 +01:00
Robert Griesemer
0cbca268d8 gofmt: simplify slices of the form s[a : len(s)] to s[a:]
Fixes #4314.

R=r, rsc
CC=golang-dev
https://golang.org/cl/6822059
2012-10-31 11:48:55 -07:00
Robert Griesemer
465b9c35e5 gofmt: apply gofmt -w src misc
Remove trailing whitespace in comments.
No other changes.

R=r
CC=golang-dev
https://golang.org/cl/6815053
2012-10-30 13:38:01 -07:00
Robert Griesemer
db2b6ed854 go/printer, gofmt: trim trailing whitespace in comments
Also: updated go fix testcases to pass tests.

Fixes #4310.

R=r
CC=golang-dev
https://golang.org/cl/6810055
2012-10-30 13:09:47 -07:00
Shenghou Ma
78a6f75241 cmd/ld: handle weak symbols
compiler_rt introduces a weak and hidden symbol compilerrt_abort_impl
into our pre-linked _all.o object, we have to handle it.

Fixes #4273.

R=iant, rsc, r
CC=golang-dev
https://golang.org/cl/6783050
2012-10-30 23:58:43 +08:00
Brad Fitzpatrick
71d9e956a0 cmd/api: handle contexts re-converging
Fixes #4303

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6816058
2012-10-30 13:12:59 +01:00
Brad Fitzpatrick
e53a2c40b1 cmd/api: add more tests
Feature extraction was tested before, but not the final diffs.

This CL breaks function main into a smaller main + testable
compareAPI.

No functional changes.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6820057
2012-10-30 11:23:44 +01:00
Luuk van Dijk
530147e870 cmd/gc: inlining functions with local variables
- make sure dclcontext == PAUTO only in function bodies
- introduce PDISCARD to discard declarations in bodies of repeated imports
- skip printing initializing OAS'es in export mode, assuming they only occur after ODCL's
- remove ODCL and the initializing OAS from inl.c:ishairy
- fix confused use of ->typecheck in typecheckinl: it's about the ->inl, not about the fn.
- debuging aids: print ntype on ONAMEs too and -Emm instead of -Ell.

fixes #2812

R=rsc
CC=golang-dev
https://golang.org/cl/6800043
2012-10-29 13:55:27 +01:00
Luuk van Dijk
507fcf37d2 cmd/gc: escape analysis to track flow of in to out parameters.
includes step 0: synthesize outparams, from 6600044
includes step 1,2: give outparams loopdepth 0 and verify unchanged results
         generate esc:$mask tags, but still tie to sink if a param has mask != 0
from 6610054

adds final steps:
- have esccall generate n->escretval, a list of nodes the function results flow to
- use these in esccall and ORETURN/OAS2FUNC/and f(g())
- only tie parameters to sink if tag is absent, otherwise according to mask, tie them to escretval

R=rsc, bradfitz
CC=dave, gobot, golang-dev, iant, rsc
https://golang.org/cl/6741044
2012-10-29 13:38:21 +01:00
Rémy Oudompheng
ee3e2ac1a6 cmd/5g: introduce componentgen for better registerization.
It is essentially identical to the version in 6g.

R=dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6710043
2012-10-28 20:11:21 +01:00
Dave Cheney
542dd8b9fb cmd/5g: peep.c: reactivate some optimisations
Thanks to Minux and Remy for their advice.

The EOR optimisation is applied to a few places in the stdlib.

// hash/crc32/crc32.go
func update(crc uint32, tab *Table, p []byte) uint32 {
	crc = ^crc
	for _, v := range p {
        	crc = tab[byte(crc)^v] ^ (crc >> 8)
	}
	return ^crc
}

before:

--- prog list "update" ---
0164 (/home/dfc/go/src/pkg/hash/crc32/crc32.go:101) TEXT        update+0(SB),$12-24
0165 (/home/dfc/go/src/pkg/hash/crc32/crc32.go:101) MOVW        tab+4(FP),R8
0166 (/home/dfc/go/src/pkg/hash/crc32/crc32.go:102) MOVW        crc+0(FP),R0
0167 (/home/dfc/go/src/pkg/hash/crc32/crc32.go:102) EOR         $-1,R0,R5
0168 (/home/dfc/go/src/pkg/hash/crc32/crc32.go:103) MOVW        p+8(FP),R0
0169 (/home/dfc/go/src/pkg/hash/crc32/crc32.go:103) MOVW        R0,autotmp_0019+-12(SP)

after:

--- prog list "update" ---
0164 (/home/dfc/go/src/pkg/hash/crc32/crc32.go:101) TEXT        update+0(SB),$12-24
0165 (/home/dfc/go/src/pkg/hash/crc32/crc32.go:101) MOVW        tab+4(FP),R8
0166 (/home/dfc/go/src/pkg/hash/crc32/crc32.go:102) MOVW        crc+0(FP),R0
0167 (/home/dfc/go/src/pkg/hash/crc32/crc32.go:102) MVN         R0,R5
0168 (/home/dfc/go/src/pkg/hash/crc32/crc32.go:103) MOVW        p+8(FP),R0
0169 (/home/dfc/go/src/pkg/hash/crc32/crc32.go:103) MOVW        R0,autotmp_0019+-12(SP)

After 5l has done its work,

        crc = ^crc
   3d710:       e59d0014        ldr     r0, [sp, #20]
   3d714:       e3e0b000        mvn     fp, #0
   3d718:       e020500b        eor     r5, r0, fp

becomes

        crc = ^crc
   3d710:       e59d0014        ldr     r0, [sp, #20]
   3d714:       e1e05000        mvn     r5, r0

The MOVB optimisation has a small impact on the stdlib, in strconv
and gzip.

// GZIP (RFC 1952) is little-endian, unlike ZLIB (RFC 1950).
func put2(p []byte, v uint16) {
        p[0] = uint8(v >> 0)
        p[1] = uint8(v >> 8)
}

before:

--- prog list "put2" ---
1369 (/home/dfc/go/src/pkg/compress/gzip/gzip.go:76) TEXT       put2+0(SB),$0-16
1370 (/home/dfc/go/src/pkg/compress/gzip/gzip.go:76) MOVHU      v+12(FP),R4
1371 (/home/dfc/go/src/pkg/compress/gzip/gzip.go:77) MOVHU      R4,R0
1372 (/home/dfc/go/src/pkg/compress/gzip/gzip.go:77) MOVHU      R0,R0
1373 (/home/dfc/go/src/pkg/compress/gzip/gzip.go:77) MOVBU      R0,R1
1374 (/home/dfc/go/src/pkg/compress/gzip/gzip.go:77) MOVBU      R1,R3
1375 (/home/dfc/go/src/pkg/compress/gzip/gzip.go:77) MOVW       $p+0(FP),R1

after:

--- prog list "put2" ---
1369 (/home/dfc/go/src/pkg/compress/gzip/gzip.go:76) TEXT       put2+0(SB),$0-16
1370 (/home/dfc/go/src/pkg/compress/gzip/gzip.go:76) MOVHU      v+12(FP),R4
1371 (/home/dfc/go/src/pkg/compress/gzip/gzip.go:77) MOVHU      R4,R0
1372 (/home/dfc/go/src/pkg/compress/gzip/gzip.go:77) MOVBU      R0,R1
1373 (/home/dfc/go/src/pkg/compress/gzip/gzip.go:77) MOVBU      R1,R3
1374 (/home/dfc/go/src/pkg/compress/gzip/gzip.go:77) MOVW       $p+0(FP),R1

R=remyoudompheng, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6674048
2012-10-26 18:19:10 +11:00
Rémy Oudompheng
335eef85c3 cmd/6g: fix crash in cgen_bmul.
Used to print:
../test/torture.go:116: internal compiler error: bad width: 0463 (../test/torture.go:116) MOVB    ,BX (0, 8)

R=nigeltao, rsc
CC=golang-dev
https://golang.org/cl/6736068
2012-10-26 00:29:44 +02:00
Russ Cox
80dbe74360 cmd/gc, cmd/ld: use go.weak instead of weak as the weak symbol prefix
Also defend our symbol prefixes (now just "go" and "type")
from use as import paths.

Fixes #4257.

R=ken2
CC=golang-dev
https://golang.org/cl/6744072
2012-10-23 11:16:08 -04:00
Daniel Morsing
48af64b295 cmd/gc: Mark use of builtin functions as calls.
Fixes #4097.

R=rsc
CC=golang-dev, gri
https://golang.org/cl/6749059
2012-10-22 19:14:30 +02:00
Shenghou Ma
3dbbb6eb4c cmd/5l, cmd/6l, cmd/8l: put floating point numbers in .rodata section
R=golang-dev, rsc
CC=0xe2.0x9a.0x9b, golang-dev
https://golang.org/cl/6742063
2012-10-23 00:59:53 +08:00
Luuk van Dijk
75692424d2 cmd/gc: escape analysis to track flow of in to out parameters.
includes step 0: synthesize outparams, from 6600044
step 1: give outparams loopdepth 0 and verify unchanged results
step 2: generate esc:$mask tags, but still tie to sink if a param has mask != 0
next step: use in esccall (and ORETURN with implicit OAS2FUNC) to avoid tying to sink

R=rsc
CC=golang-dev
https://golang.org/cl/6610054
2012-10-22 10:18:17 +02:00
Luuk van Dijk
976ca1a47d cmd/gc: track parameter flow, step 0: synthesize name nodes for anonymous PPARAMOUTs without breaking anything.
further work on parameter flow tracking for escape analysis depends on this.

R=rsc
CC=golang-dev
https://golang.org/cl/6600044
2012-10-22 10:09:52 +02:00
Luuk van Dijk
e7f89fcb1c cmd/gc: fix strict tree property for AST for OAS2RECV nodes.
in typecheck and walk, conversion from OAS2RECV to OAS2
and to OSELRECV2 duplicated the ->rlist->n to ->right
thereby destroying the strict tree-ness of the AST (up to
ONAMES) of course.  Several recursions in esc.c and inl.c
and probably elsewhere assume nodes of the tree aren't duplicated.
rather than defensively code around this, i'd rather assert
these cases away and fix their cause.

(this was tripped in 6741044)

R=rsc
CC=golang-dev
https://golang.org/cl/6750043
2012-10-22 10:01:14 +02:00
Roger Peppe
9714691a3f cmd/go: add join template function.
It's common to use the go list command in shell scripts, but
currently it's awkward to print a string slice from the Package
type in a way that's easily parseable by the shell.  For example:

        go list -f '{{range .Deps}}{{.}}
        {{end}}'

(and even that prints an unwanted new line at the end|).

To make this easier, this CL adds a "join" function to the
format template.

        go list -f '{{join .Deps "\n"}}'

R=rsc, dsymonds, minux.ma, remyoudompheng, r
CC=golang-dev
https://golang.org/cl/6680044
2012-10-22 08:58:27 +01:00
Rémy Oudompheng
319131f295 cmd/gc: fix inlining bug for composite literals in if statements.
Fixes #4230.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6640056
2012-10-22 08:38:23 +02:00
Shenghou Ma
77e42e2108 lib9, cmd/dist, cmd/5l: embed GOARM into cmd/5l and auto detect GOARM
R=rsc, dave
CC=golang-dev
https://golang.org/cl/6638043
2012-10-22 14:26:36 +08:00
Russ Cox
922c0b4755 cmd/gc: rebuild builtin.c
Was not in sync with runtime.go, but the diffs
didn't really matter, so nothing broke.

R=ken2
CC=golang-dev
https://golang.org/cl/6733057
2012-10-21 17:15:56 -04:00
Daniel Morsing
d7a3407e3d cmd/gc: fix confusing error when using variable as type.
Fixes #3783.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6737053
2012-10-21 20:50:31 +02:00
Daniel Morsing
a7a3fe7238 cmd/gc: Friendlier errors on oversized arrays.
Someone new to the language may not know the connection between ints and arrays, which was the only thing that the previous error told you anything about.

Fixes #4256.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6739048
2012-10-21 19:22:51 +02:00
Shenghou Ma
6a3ad481cd cmd/go: make package list order predicable
also add a cleanup phase to cmd/go/test.bash.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6741050
2012-10-20 17:25:13 +08:00
Rémy Oudompheng
a4682348c2 cmd/gc: don't squash complex literals when inlining.
Since this patch changes the way complex literals are written
in export data, there are a few other glitches.

Fixes #4159.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6674047
2012-10-17 20:33:44 +02:00
Daniel Morsing
a2659aa6a1 cmd/go: Dedup package arguments before building.
Fixes #4104.

R=golang-dev, dave, minux.ma
CC=golang-dev
https://golang.org/cl/6639051
2012-10-17 17:23:47 +02:00
Rémy Oudompheng
7e144bcab0 cmd/5g, cmd/6g, cmd/8g: fix out of registers.
This patch is enough to fix compilation of
exp/types tests but only passes a stripped down
version of the appripriate torture test.

Update #4207.

R=dave, nigeltao, rsc, golang-dev
CC=golang-dev
https://golang.org/cl/6621061
2012-10-16 07:22:33 +02:00
Shenghou Ma
1e9f308545 cmd/5l: reorder some struct fields to reduce memory consumption
Valgrind Massif result when linking godoc:
On amd64:
                    old          new         -/+
mem_heap_B       185844612    175358047    -5.7%
mem_heap_extra_B    773404       773137    -0.0%

On 386/ARM:
                    old          new         -/+
mem_heap_B       141775701    131289941    -7.4%
mem_heap_extra_B    737011       736955    -0.0%

R=golang-dev, r, dave
CC=golang-dev
https://golang.org/cl/6655045
2012-10-12 13:39:12 +08:00
Shenghou Ma
19dc7bb18f cmd/dist: fix superfluous and confusing "binaries ... to be copied or moved" message
Also, to aid debugging cmd/dist, make make.bat support --dist-tool flag.

Fixes #3100.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/6637061
2012-10-12 13:35:05 +08:00
Shenghou Ma
bf7d229eb8 cmd/go: don't ignore error when 'go clean'
Fixes #4208.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6635064
2012-10-11 01:34:26 +08:00
Dmitriy Vyukov
21b2ce724a cmd/gc: fix compiler crash during race instrumentation
The compiler is crashing on the following code:

type TypeID int
func (t *TypeID) encodeType(x int) (tt TypeID, err error) {
        switch x {
        case 0:
                return t.encodeType(x * x)
        }
        return 0, nil
}
The pass marks "return struct" {tt TypeID, err error} as used,
and this causes internal check failure.
I've added the test to:
https://golang.org/cl/6525052/diff/7020/src/pkg/runtime/race/regression_test.go

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6611049
2012-10-10 18:09:23 +04:00
Andrew Gerrand
8438641629 godoc: add dropdown playground to nav bar
R=gri, dsymonds, skybrian
CC=golang-dev
https://golang.org/cl/6631057
2012-10-10 11:17:47 +11:00
Robert Griesemer
af79568fde gofmt: apply gofmt -w -s src misc
Preparation for forthcoming CL 6624051: Will make it
easier to see if/what changes are incurred by it.

The alignment changes in this CL are due to CL 6610051
(fix to alignment heuristic) where it appears that an
old version of gofmt was run (and thus the correct
alignment updates were not done).

R=r
CC=golang-dev
https://golang.org/cl/6639044
2012-10-09 17:01:28 -07:00