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

3986 Commits

Author SHA1 Message Date
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
Ian Lance Taylor
32316bba5b cmd/ld: add -B option to set build ID
Background on build ID:
http://fedoraproject.org/wiki/RolandMcGrath/BuildID

R=rsc
CC=golang-dev
https://golang.org/cl/6625072
2012-10-09 15:29:43 -07:00
Shenghou Ma
d901808869 cmd/5l: generate FreeBSD compatible ELF
1. correctly initialize .plt.got entries (point to the 1st entry)
2. add section .rel.plt (FreeBSD insists PLT relocs to be there)
3. put relocs of .got.plt into .rel.plt
4. set ELFOSABI_FREEBSD in ELF header

R=rsc
CC=golang-dev
https://golang.org/cl/6643050
2012-10-10 01:02:49 +08:00
Shenghou Ma
fa563ae82e cmd/ld, cmd/6l, cmd/8l: sort exported dynamic symbols for Darwin
Also corrected cmd/8l's .dynsym handling (differentiate between exported symbols and imported symbols)

        Fixes #4029.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6620075
2012-10-10 00:55:48 +08:00
Russ Cox
f76f120324 cmd/ld: use 64-bit alignment for large data and bss objects
Check for specific, important misalignment in garbage collector.
Not a complete fix for issue 599 but an important workaround.

Update #599.

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/6641049
2012-10-09 12:50:06 -04:00
Dmitriy Vyukov
3aae5a0e7e cmd/fix: disable reflect test under race detector (very slow)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6642045
2012-10-09 20:21:39 +04:00
Dmitriy Vyukov
6cab8aa4e4 cmd/go: fix handling of build tags for standard commands
Otherwise if I add '+build !race' to e.g. src/cmd/fix/reflect_test.go,
it does not work.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6642044
2012-10-09 19:54:14 +04:00
Andrew Gerrand
4fb89c9d6a godoc: support Playground examples on App Engine
Updates setup-godoc-app.bash to produce a working godoc app
by substituting the go1.0.x go/... packages with those from tip.

R=gri
CC=golang-dev
https://golang.org/cl/6587080
2012-10-09 09:57:51 +11:00
David Symonds
f8b5838123 testing: change -test.benchtime to a flag.Duration.
Fixes #3902.

R=golang-dev, minux.ma, rsc, r
CC=golang-dev
https://golang.org/cl/6611059
2012-10-09 08:57:29 +11:00
Dave Cheney
905e8dfa27 cmd/5g: avoid temporaries during gcmp(reg, constant)
Address several instances of unneeded temporaries when using gcmp.

func M(m map[int]bool) int {
        return len(m)
}

--- prog list "M" ---
0000 (/home/dfc/src/map.go:3) TEXT      M+0(SB),$0-8
0001 (/home/dfc/src/map.go:4) MOVW      m+0(FP),R0
0002 (/home/dfc/src/map.go:4) MOVW      $0,R1
0003 (/home/dfc/src/map.go:4) CMP       R1,R0,
0004 (/home/dfc/src/map.go:4) BEQ       ,6(APC)
0005 (/home/dfc/src/map.go:4) MOVW      0(R0),R0
0006 (/home/dfc/src/map.go:4) MOVW      R0,.noname+4(FP)
0007 (/home/dfc/src/map.go:4) RET       ,

after:

--- prog list "M" ---
0000 (/home/dfc/src/map.go:3) TEXT      M+0(SB),$0-8
0001 (/home/dfc/src/map.go:4) MOVW      m+0(FP),R0
0002 (/home/dfc/src/map.go:4) CMP       $0,R0,
0003 (/home/dfc/src/map.go:4) BEQ       ,5(APC)
0004 (/home/dfc/src/map.go:4) MOVW      0(R0),R0
0005 (/home/dfc/src/map.go:4) MOVW      R0,.noname+4(FP)
0006 (/home/dfc/src/map.go:4) RET       ,

func C(c chan int) int {
        return cap(c)
}

--- prog list "C" ---
0000 (/home/dfc/src/map.go:3) TEXT      C+0(SB),$0-8
0001 (/home/dfc/src/map.go:4) MOVW      c+0(FP),R0
0002 (/home/dfc/src/map.go:4) MOVW      $0,R1
0003 (/home/dfc/src/map.go:4) CMP       R1,R0,
0004 (/home/dfc/src/map.go:4) BEQ       ,6(APC)
0005 (/home/dfc/src/map.go:4) MOVW      4(R0),R0
0006 (/home/dfc/src/map.go:4) MOVW      R0,.noname+4(FP)
0007 (/home/dfc/src/map.go:4) RET       ,

after:

--- prog list "C" ---
0000 (/home/dfc/src/map.go:3) TEXT      C+0(SB),$0-8
0001 (/home/dfc/src/map.go:4) MOVW      c+0(FP),R0
0002 (/home/dfc/src/map.go:4) CMP       $0,R0,
0003 (/home/dfc/src/map.go:4) BEQ       ,5(APC)
0004 (/home/dfc/src/map.go:4) MOVW      4(R0),R0
0005 (/home/dfc/src/map.go:4) MOVW      R0,.noname+4(FP)
0006 (/home/dfc/src/map.go:4) RET       ,

R=rsc, minux.ma, remyoudompheng
CC=golang-dev
https://golang.org/cl/6618054
2012-10-08 09:51:04 +11:00
Russ Cox
5da37c0901 cmd/8a: add SSE2 instructions
R=ken
CC=golang-dev
https://golang.org/cl/6614063
2012-10-07 16:36:29 -04:00
Russ Cox
c1d06cef12 cmd/8l: add SSE2 instructions
R=ken
CC=golang-dev
https://golang.org/cl/6610065
2012-10-07 16:36:14 -04:00
Russ Cox
d749783f70 cmd/gc: skip over reported BOMs
This keeps the BOM runes from causing other errors.

R=golang-dev, remyoudompheng
CC=golang-dev
https://golang.org/cl/6625062
2012-10-07 16:35:45 -04:00
Shenghou Ma
65b782e951 cmd/ld, cmd/5l: support R_ARM_PC24 and R_ARM_JUMP24, fix R_ARM_CALL
1. R_ARM_CALL can also be used to call a PLT entry
2. add support for R_ARM_PC24 and R_ARM_JUMP24
3. refactor, remove D_PLT32 in favor of D_CALL

Fixes #4006.

R=rsc, dave
CC=fullung, golang-dev
https://golang.org/cl/6622057
2012-10-08 04:20:17 +08:00
Rémy Oudompheng
caff439820 cmd/gc: more graceful handling of invalid fields in widstruct.
The protection against segfaults does not completely solve
crashes and breaks test/fixedbugs/bug365.go

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6615058
2012-10-07 21:46:10 +02:00
Russ Cox
54191126e4 cmd/gc: avoid crash in %N print
R=ken2
CC=golang-dev
https://golang.org/cl/6609052
2012-10-07 15:35:01 -04:00
Rémy Oudompheng
892fa3ae6c cmd/gc: replace "typechecking loop" by nicer errors in some cases.
For issue 3757:
BEFORE:  test/fixedbugs/bug463.go:12: typechecking loop involving a
             test/fixedbugs/bug463.go:12 a
             test/fixedbugs/bug463.go:12 <node DCLCONST>
AFTER:   test/fixedbugs/bug463.go:12: constant definition loop
             test/fixedbugs/bug463.go:12: a uses a

For issue 3937:
BEFORE: test/fixedbugs/bug464.go:12: typechecking loop involving foo
            test/fixedbugs/bug464.go:12 <T>
            test/fixedbugs/bug464.go:12 foo
            test/fixedbugs/bug464.go:12 <node DCLFUNC>
AFTER:  test/fixedbugs/bug464.go:12: foo is not a type

Fixes #3757.
Fixes #3937.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6614058
2012-10-07 17:35:21 +02:00
Daniel Morsing
87c35d8df1 cmd/gc: Don't accept qualified names as literal keys
Fixes #4067.

R=golang-dev, minux.ma, dave, rsc
CC=golang-dev
https://golang.org/cl/6622056
2012-10-07 16:47:53 +02:00
Shenghou Ma
9224b4c873 cmd/gc: fix output filename generation on Windows
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6610060
2012-10-07 14:14:46 +08:00
Akshat Kumar
51e8fe5b1b cmd/gc: don't dereference a nil Type pointer in widstruct
The nil dereference in the next few lines doesn't seem
to cause a segmentation fault on Unix, but does seem
to halt the Go compiler.

The following is a test case:

>>>
package main

func mine(int b) int {
        return b + 2
}

func main() {
        mine()

        c = mine()
}
<<<

Without this change only the following is caught:

typecheck.go:3: undefined: b
typecheck.go:4: undefined: b

with it, we catch all the errors:

typecheck.go:3: undefined: b
typecheck.go:4: undefined: b
typecheck.go:10: undefined: c
typecheck.go:10: cannot assign to c .

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6542060
2012-10-07 14:11:59 +08:00
Daniel Morsing
a45777fe99 cmd/gc: Don't export embedded builtins
Fixes #4124.

R=golang-dev, dave, minux.ma, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6543057
2012-10-07 06:53:57 +02:00
Dave Cheney
01ddc8bd9a cmd/5g: avoid temporary in slice bounds check
before

func addr(s[]int) *int {
        return &s[2]
   10c1c:       e28d0008        add     r0, sp, #8
   10c20:       e5901004        ldr     r1, [r0, #4]
   10c24:       e3a02002        mov     r2, #2
   10c28:       e1510002        cmp     r1, r2
   10c2c:       8a000000        bhi     10c34 <main.addr+0x34>
   10c30:       eb0035e6        bl      1e3d0 <runtime.panicindex>
   10c34:       e5900000        ldr     r0, [r0]
   10c38:       e2800008        add     r0, r0, #8
   10c3c:       e58d0014        str     r0, [sp, #20]
   10c40:       e49df004        pop     {pc}            ; (ldr pc, [sp], #4)

after

func addr(s[]int) *int {
	return &s[2]
   10c1c:       e28d0008        add     r0, sp, #8
   10c20:       e5901004        ldr     r1, [r0, #4]
   10c24:       e3510002        cmp     r1, #2
   10c28:       8a000000        bhi     10c30 <main.addr+0x30>
   10c2c:       eb0035e6        bl      1e3cc <runtime.panicindex>
   10c30:       e5900000        ldr     r0, [r0]
   10c34:       e2800008        add     r0, r0, #8
   10c38:       e58d0014        str     r0, [sp, #20]
   10c3c:       e49df004        pop     {pc}            ; (ldr pc, [sp], #4)

Also, relax gcmp restriction that 2nd operand must be a register. A followup
CL will address the remaining TODO items.

R=rsc, remyoudompheng, minux.ma
CC=golang-dev
https://golang.org/cl/6620064
2012-10-07 11:37:14 +11:00
Rémy Oudompheng
0b2ca9e62f cmd/gc: avoid clobbering the AST in cgen_callmeth.
It confused the detection of init loops when involving
method calls.

Fixes #3890.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6620067
2012-10-07 00:52:40 +02:00
Rémy Oudompheng
46fcfdaa7d cmd/6g: fix out of registers when chaining integer divisions.
Fixes #4201.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6622055
2012-10-07 00:30:29 +02:00
Rémy Oudompheng
94acfde22e cmd/gc: make rnd() more 64-bit-friendly.
Fixes #4200.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6619057
2012-10-07 00:29:55 +02:00
Dave Cheney
bbccfddb84 cmd/5g: avoid temporary during constant asop
func add() int {
        var a int
        a += 10
        a += 20
        a += 30
        a -= 10
        a -= 20
        a -= 30
        return a
}

before

--- prog list "add" ---
0000 (/home/dfc/src/add.go:5) TEXT      add+0(SB),$0-4
0001 (/home/dfc/src/add.go:6) MOVW      $0,R2
0002 (/home/dfc/src/add.go:7) MOVW      $10,R0
0003 (/home/dfc/src/add.go:7) ADD       R0,R2,R1
0004 (/home/dfc/src/add.go:8) MOVW      $20,R0
0005 (/home/dfc/src/add.go:8) ADD       R0,R1
0006 (/home/dfc/src/add.go:9) MOVW      $30,R0
0007 (/home/dfc/src/add.go:9) ADD       R0,R1
0008 (/home/dfc/src/add.go:10) MOVW     $10,R0
0009 (/home/dfc/src/add.go:10) SUB      R0,R1
0010 (/home/dfc/src/add.go:11) MOVW     $20,R0
0011 (/home/dfc/src/add.go:11) SUB      R0,R1
0012 (/home/dfc/src/add.go:12) MOVW     $30,R0
0013 (/home/dfc/src/add.go:12) SUB      R0,R1,R2
0014 (/home/dfc/src/add.go:12) MOVW     R2,R0
0015 (/home/dfc/src/add.go:13) MOVW     R2,R1
0016 (/home/dfc/src/add.go:13) MOVW     R2,.noname+0(FP)
0017 (/home/dfc/src/add.go:13) RET      ,

after

--- prog list "add" ---
0000 (/home/dfc/src/add.go:5) TEXT      add+0(SB),$0-4
0001 (/home/dfc/src/add.go:6) MOVW      $0,R0
0002 (/home/dfc/src/add.go:7) ADD       $10,R0
0003 (/home/dfc/src/add.go:8) ADD       $20,R0
0004 (/home/dfc/src/add.go:9) ADD       $30,R0
0005 (/home/dfc/src/add.go:10) SUB      $10,R0
0006 (/home/dfc/src/add.go:11) SUB      $20,R0
0007 (/home/dfc/src/add.go:12) SUB      $30,R0,R2
0008 (/home/dfc/src/add.go:13) MOVW     R2,R0
0009 (/home/dfc/src/add.go:13) MOVW     R2,.noname+0(FP)
0010 (/home/dfc/src/add.go:13) RET      ,

R=rsc, minux.ma, remyoudompheng
CC=golang-dev
https://golang.org/cl/6584056
2012-10-06 21:01:49 +10:00
Dmitriy Vyukov
4cc7bf326a pprof: add goroutine blocking profiling
The profiler collects goroutine blocking information similar to Google Perf Tools.
You may see an example of the profile (converted to svg) attached to
http://code.google.com/p/go/issues/detail?id=3946
The public API changes are:
+pkg runtime, func BlockProfile([]BlockProfileRecord) (int, bool)
+pkg runtime, func SetBlockProfileRate(int)
+pkg runtime, method (*BlockProfileRecord) Stack() []uintptr
+pkg runtime, type BlockProfileRecord struct
+pkg runtime, type BlockProfileRecord struct, Count int64
+pkg runtime, type BlockProfileRecord struct, Cycles int64
+pkg runtime, type BlockProfileRecord struct, embedded StackRecord

R=rsc, dave, minux.ma, r
CC=gobot, golang-dev, r, remyoudompheng
https://golang.org/cl/6443115
2012-10-06 12:56:04 +04:00
Jan Ziak
16bea49ede cmd/cc: map C int to int32 in Go defs
R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6621052
2012-10-06 13:56:12 +08:00
Dave Cheney
ed0c5dd11f cmd/5g: avoid temporary during constant OINDEX
func addr(s[]int) *int {
	return &s[2]
}

--- prog list "addr" ---
0000 (/home/dfc/src/addr.go:5) TEXT     addr+0(SB),$0-16
0001 (/home/dfc/src/addr.go:6) MOVW     $s+0(FP),R0
0002 (/home/dfc/src/addr.go:6) MOVW     4(R0),R1
0003 (/home/dfc/src/addr.go:6) MOVW     $2,R2
0004 (/home/dfc/src/addr.go:6) CMP      R2,R1,
0005 (/home/dfc/src/addr.go:6) BHI      ,7(APC)
0006 (/home/dfc/src/addr.go:6) BL       ,runtime.panicindex+0(SB)
0007 (/home/dfc/src/addr.go:6) MOVW     0(R0),R0
0008 (/home/dfc/src/addr.go:6) MOVW     $8,R1
0009 (/home/dfc/src/addr.go:6) ADD      R1,R0
0010 (/home/dfc/src/addr.go:6) MOVW     R0,.noname+12(FP)
0011 (/home/dfc/src/addr.go:6) RET      ,

becomes

--- prog list "addr" ---
0000 (/home/dfc/src/addr.go:5) TEXT     addr+0(SB),$0-16
0001 (/home/dfc/src/addr.go:6) MOVW     $s+0(FP),R0
0002 (/home/dfc/src/addr.go:6) MOVW     4(R0),R1
0003 (/home/dfc/src/addr.go:6) MOVW     $2,R2
0004 (/home/dfc/src/addr.go:6) CMP      R2,R1,
0005 (/home/dfc/src/addr.go:6) BHI      ,7(APC)
0006 (/home/dfc/src/addr.go:6) BL       ,runtime.panicindex+0(SB)
0007 (/home/dfc/src/addr.go:6) MOVW     0(R0),R0
0008 (/home/dfc/src/addr.go:6) ADD      $8,R0
0009 (/home/dfc/src/addr.go:6) MOVW     R0,.noname+12(FP)
0010 (/home/dfc/src/addr.go:6) RET      ,

R=rsc, remyoudompheng, minux.ma
CC=golang-dev
https://golang.org/cl/6590056
2012-10-06 11:51:06 +10:00
Rémy Oudompheng
3a4e156ae1 cmd/5g: fix out of registers in nested calls, add compiler torture test.
R=golang-dev, dave, daniel.morsing, rsc
CC=golang-dev, remy
https://golang.org/cl/6586072
2012-10-05 23:30:49 +02:00
Andrew Gerrand
3fd5e0be9d godoc: make examples editable and runnable in playground
R=dsymonds
CC=golang-dev
https://golang.org/cl/6523045
2012-10-04 16:53:05 +10:00
Shenghou Ma
7e2e4a732d cmd/go: add support for -test.benchmem
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6587074
2012-10-04 13:20:18 +08:00
Rob Pike
d87d488953 cmd/api: add exception file
Fixes build.

R=golang-dev, adg, bradfitz, dsymonds, dave
CC=golang-dev
https://golang.org/cl/6586074
2012-10-04 11:35:17 +10:00
Rémy Oudompheng
2de064b63c cmd/8g: do not take the address of string/slice for &s[i]
A similar change was made in 6g recently.

LEALs in cmd/go: 31440 before, 27867 after.

benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    7065794000   6723617000   -4.84%
BenchmarkFannkuch11      7767395000   7477945000   -3.73%
BenchmarkGobDecode         34708140     34857820   +0.43%
BenchmarkGobEncode         10998780     10960060   -0.35%
BenchmarkGzip            1603630000   1471052000   -8.27%
BenchmarkGunzip           242573900    240650400   -0.79%
BenchmarkJSONEncode       120842200    117966100   -2.38%
BenchmarkJSONDecode       247254900    249103100   +0.75%
BenchmarkMandelbrot200     29237330     29241790   +0.02%
BenchmarkParse              8111320      8096865   -0.18%
BenchmarkRevcomp         2595780000   2694153000   +3.79%
BenchmarkTemplate         276679600    264497000   -4.40%

benchmark                              old ns/op    new ns/op    delta
BenchmarkAppendFloatDecimal                  429          416   -3.03%
BenchmarkAppendFloat                         780          740   -5.13%
BenchmarkAppendFloatExp                      746          700   -6.17%
BenchmarkAppendFloatNegExp                   752          694   -7.71%
BenchmarkAppendFloatBig                     1228         1108   -9.77%
BenchmarkAppendFloat32Integer                457          416   -8.97%
BenchmarkAppendFloat32ExactFraction          662          631   -4.68%
BenchmarkAppendFloat32Point                  771          735   -4.67%
BenchmarkAppendFloat32Exp                    722          672   -6.93%
BenchmarkAppendFloat32NegExp                 724          659   -8.98%
BenchmarkAppendFloat64Fixed1                 429          400   -6.76%
BenchmarkAppendFloat64Fixed2                 463          442   -4.54%

Update #1914.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6574043
2012-10-02 08:19:27 +02:00
Dmitriy Vyukov
041fc8bf96 race: gc changes
This is the first part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044
This change makes gc compiler instrument memory accesses when supplied with -b flag.

R=rsc, nigeltao, lvd
CC=golang-dev
https://golang.org/cl/6497074
2012-10-02 10:05:46 +04:00
Dave Cheney
7b36acc4ac cmd/5g: avoid temporary during constant binary op
This CL is an attempt to backport the abop code generation from 6g. This improves the generation of the range offset if the increment can be encoded directly via Operand2 shift encoding.

0023 (/home/dfc/src/range.go:7) BGE     ,29(APC)
0024 (/home/dfc/src/range.go:7) MOVW    0(R3),R5
0025 (/home/dfc/src/range.go:7) MOVW    $4,R1
0026 (/home/dfc/src/range.go:7) ADD     R1,R3,R3
0027 (/home/dfc/src/range.go:8) ADD     R5,R4,R4
0028 (/home/dfc/src/range.go:7) B       ,17(APC)

becomes

0023 (/home/dfc/src/range.go:7) BGE     ,28(APC)
0024 (/home/dfc/src/range.go:7) MOVW    0(R3),R0
0025 (/home/dfc/src/range.go:7) ADD     $4,R3,R3
0026 (/home/dfc/src/range.go:8) ADD     R0,R4,R4
0027 (/home/dfc/src/range.go:7) B       ,17(APC)

Benchmarks are unimpressive

dfc@qnap:~/go/test/bench/go1$ ~/go/misc/benchcmp {old,new}.txt
benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    2147483647   2147483647   +0.93%
BenchmarkFannkuch11      2147483647   2147483647   -2.52%
BenchmarkGobDecode        196135200    195842000   -0.15%
BenchmarkGobEncode         78581650     76734450   -2.35%
BenchmarkGzip            2147483647   2147483647   -0.47%
BenchmarkGunzip          1087243000   1070254000   -1.56%
BenchmarkJSONEncode      1107558000   1146077000   +3.48%
BenchmarkJSONDecode      2147483647   2147483647   -0.07%
BenchmarkMandelbrot200   2147483647   2147483647   -0.77%
BenchmarkParse             74328550     71653400   -3.60%
BenchmarkRevcomp          111123900    109325950   -1.62%
BenchmarkTemplate        2147483647   2147483647   -0.82%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode             3.91         3.92    1.00x
BenchmarkGobEncode             9.77        10.00    1.02x
BenchmarkGzip                  3.65         3.66    1.00x
BenchmarkGunzip               17.85        18.13    1.02x
BenchmarkJSONEncode            1.75         1.69    0.97x
BenchmarkJSONDecode            0.83         0.83    1.00x
BenchmarkParse                 0.78         0.81    1.04x
BenchmarkRevcomp              22.87        23.25    1.02x
BenchmarkTemplate              0.84         0.85    1.01x

R=remyoudompheng, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6564067
2012-10-02 08:12:39 +10:00
Robert Griesemer
5a03cd56a1 cmd/godoc: clearer comments in FormatSelections
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6561073
2012-10-01 14:17:25 -07:00
Akshat Kumar
48bd5c5010 cmd/go/build: Add magic data for Plan 9 binaries.
This change allows the Go build and install tools to
recognize Plan 9 i386 and amd64 binaries.

R=rsc, r, rminnich
CC=golang-dev
https://golang.org/cl/6575064
2012-10-01 15:04:52 -04:00
Luuk van Dijk
78ba449a3c cmd/gc: Missing break in esc switch.
R=rsc
CC=golang-dev
https://golang.org/cl/6594053
2012-10-01 16:33:06 +02:00
Shenghou Ma
9a3bc51c81 test/fixedbugs/bug454.go: add a test for CL 6564052
Also mention that ignoring second blank identifier of range is required by the spec in the code.

   Fixes #4173.

R=daniel.morsing, remyoudompheng, r
CC=golang-dev
https://golang.org/cl/6594043
2012-09-29 23:23:56 +08:00
Paul Chang
7c8e26ee2f cmd/godoc: fix minor bug in FormatSelections.
FormatSelections tries to call a nil function value if lw is nil
and the final entry in the selections array is non-nil. Luckily,
this doesn't actually happen in practice since godoc doesn't use
this combination (no line numbers, but with selections).

R=gri
CC=gobot, golang-dev
https://golang.org/cl/6488106
2012-09-28 14:19:43 -07:00
Rémy Oudompheng
617b7cf166 cmd/[568]g: header cleanup.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6573059
2012-09-27 08:34:00 +02:00
Rob Pike
b46dd48dd3 cmd/api: delete redundant text from deletion message
R=bradfitz, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6543064
2012-09-27 15:39:56 +10:00
Rémy Oudompheng
6feb61325a cmd/6g, cmd/8g: fix two "out of fixed registers" cases.
In two cases, registers were allocated too early resulting
in exhausting of available registers when nesting these
operations.

The case of method calls was due to missing cases in igen,
which only makes calls but doesn't allocate a register for
the result.

The case of 8-bit multiplication was due to a wrong order
in register allocation when Ullman numbers were bigger on the
RHS.

Fixes #3907.
Fixes #4156.

R=rsc
CC=golang-dev, remy
https://golang.org/cl/6560054
2012-09-26 21:17:11 +02:00
Daniel Morsing
7936ab58f7 cmd/gc: Don't calculate second value in range if it is blank.
Low hanging fruit optimization. Will remove an expensive copy if the range variable is an array.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6564052
2012-09-26 21:10:29 +02:00
Shenghou Ma
e039c405c8 cmd/6a, cmd/6l: add support for AES-NI instrutions and PSHUFD
This CL adds support for the these 7 new instructions to 6a/6l in
preparation of the upcoming CL for AES-NI accelerated crypto/aes:
AESENC, AESENCLAST, AESDEC, AESDECLAST, AESIMC, AESKEYGENASSIST,
and PSHUFD.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5970055
2012-09-27 01:53:08 +08:00
Shenghou Ma
5490814c30 cmd/go, cmd/ld: fix libgcc order and add __image_base__ symbol for windows
Fixes #4063.

R=alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/6543066
2012-09-26 22:34:25 +08:00
Joel Sing
e80fccb441 cmd/go: assume that code in $GOROOT is up to date
Do not check compiler/linker timestamps for packages that are in the
$GOROOT. Avoids trying to rebuild non-writable standard packages when
timestamps have not been retained on the Go binaries.

Fixes #4106.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6533053
2012-09-27 00:00:50 +10:00
Shenghou Ma
f2fadfefaf cmd/5c: fix dataflag annotation
file        old_size     new_size    base@c1ce95068533
bin/go      14717392     6287824     5918236

this huge size difference is due to GC data for runtime.mheap
(NOPTR dataflag is not obeyed).

R=rsc, dave
CC=golang-dev
https://golang.org/cl/6547051
2012-09-25 14:42:44 +08:00
Russ Cox
5c4e2570c1 cmd/dist: new version for string for development branch
Remove VERSION, which was forcing version to 'devel'.

Old:
$ go version
go version devel

New:
$ go version
go version devel +0a3866d6cc6b Mon Sep 24 20:08:05 2012 -0400

The date and time (and time zone) is that of the most recent commit,
not the time of the build itself. With some effort we could normalize
the zone, but I don't think it's worth the effort (more C coding,
since Mercurial is unhelpful).

R=r, dsymonds
CC=golang-dev
https://golang.org/cl/6569049
2012-09-24 21:35:20 -04:00
Russ Cox
10ea6519e4 build: make int 64 bits on amd64
The assembly offsets were converted mechanically using
code.google.com/p/rsc/cmd/asmlint. The instruction
changes were done by hand.

Fixes #2188.

R=iant, r, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/6550058
2012-09-24 20:57:01 -04:00
Rémy Oudompheng
33cceb09e2 cmd/{5g,6g,8g,6c}: remove unused macro, use %E to print etype.
R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/6569044
2012-09-24 23:44:00 +02:00
Rémy Oudompheng
f4e76d5e02 cmd/6g, cmd/8g: add OINDREG, ODOT, ODOTPTR cases to igen.
Apart from reducing the number of LEAL/LEAQ instructions by about
30%, it gives 8g easier registerization in several cases,
for example in strconv. Performance with 6g is not affected.

Before (386):
src/pkg/strconv/decimal.go:22   TEXT  (*decimal).String+0(SB),$240-12
src/pkg/strconv/extfloat.go:540 TEXT  (*extFloat).ShortestDecimal+0(SB),$584-20

After (386):
src/pkg/strconv/decimal.go:22   TEXT  (*decimal).String+0(SB),$196-12
src/pkg/strconv/extfloat.go:540 TEXT  (*extFloat).ShortestDecimal+0(SB),$420-20

Benchmarks with GOARCH=386 (on a Core 2).

benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    7110191000   7079644000   -0.43%
BenchmarkFannkuch11      7769274000   7766514000   -0.04%
BenchmarkGobDecode         33454820     34755400   +3.89%
BenchmarkGobEncode         11675710     11007050   -5.73%
BenchmarkGzip            2013519000   1593855000  -20.84%
BenchmarkGunzip           253368200    242667600   -4.22%
BenchmarkJSONEncode       152443900    120763400  -20.78%
BenchmarkJSONDecode       304112800    247461800  -18.63%
BenchmarkMandelbrot200     29245520     29240490   -0.02%
BenchmarkParse              8484105      8088660   -4.66%
BenchmarkRevcomp         2695688000   2841263000   +5.40%
BenchmarkTemplate         363759800    277271200  -23.78%

benchmark                       old ns/op    new ns/op    delta
BenchmarkAtof64Decimal                127          129   +1.57%
BenchmarkAtof64Float                  166          164   -1.20%
BenchmarkAtof64FloatExp               308          300   -2.60%
BenchmarkAtof64Big                    584          571   -2.23%
BenchmarkAppendFloatDecimal           440          430   -2.27%
BenchmarkAppendFloat                  995          776  -22.01%
BenchmarkAppendFloatExp               897          746  -16.83%
BenchmarkAppendFloatNegExp            900          752  -16.44%
BenchmarkAppendFloatBig              1528         1228  -19.63%
BenchmarkAppendFloat32Integer         443          453   +2.26%
BenchmarkAppendFloat32ExactFraction   812          661  -18.60%
BenchmarkAppendFloat32Point          1002          773  -22.85%
BenchmarkAppendFloat32Exp             858          725  -15.50%
BenchmarkAppendFloat32NegExp          848          728  -14.15%
BenchmarkAppendFloat64Fixed1          447          431   -3.58%
BenchmarkAppendFloat64Fixed2          480          462   -3.75%
BenchmarkAppendFloat64Fixed3          461          457   -0.87%
BenchmarkAppendFloat64Fixed4          509          484   -4.91%

Update #1914.

R=rsc, nigeltao
CC=golang-dev, remy
https://golang.org/cl/6494107
2012-09-24 23:07:44 +02:00
Russ Cox
54af752865 cmd/gc: fix escape analysis bug
Was not handling &x.y[0] and &x.y.z correctly where
y is an array or struct-valued field (not a pointer).

R=ken2
CC=golang-dev
https://golang.org/cl/6551059
2012-09-24 15:53:12 -04:00
Rémy Oudompheng
14f3276c9d cmd/8g: don't create redundant temporaries in bgen.
Comparisons used to create temporaries for arguments
even if they were already variables or addressable.
Removing the extra ones reduces pressure on regopt.

benchmark                 old ns/op    new ns/op    delta
BenchmarkGobDecode         50787620     49908980   -1.73%
BenchmarkGobEncode         19870190     19473030   -2.00%
BenchmarkGzip            3214321000   3067929000   -4.55%
BenchmarkGunzip           496792800    465828600   -6.23%
BenchmarkJSONEncode       232524800    263864400  +13.48%
BenchmarkJSONDecode       622038400    506600600  -18.56%
BenchmarkMandelbrot200     23937310     45913060  +91.81%
BenchmarkParse             14364450     13997010   -2.56%
BenchmarkRevcomp         6919028000   6480009000   -6.35%
BenchmarkTemplate         594458800    539528200   -9.24%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            15.11        15.38    1.02x
BenchmarkGobEncode            38.63        39.42    1.02x
BenchmarkGzip                  6.04         6.33    1.05x
BenchmarkGunzip               39.06        41.66    1.07x
BenchmarkJSONEncode            8.35         7.35    0.88x
BenchmarkJSONDecode            3.12         3.83    1.23x
BenchmarkParse                 4.03         4.14    1.03x
BenchmarkRevcomp              36.73        39.22    1.07x
BenchmarkTemplate              3.26         3.60    1.10x

R=mtj, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6547064
2012-09-24 21:29:24 +02:00
Russ Cox
650160e36a cmd/gc: prepare for 64-bit ints
This CL makes the compiler understand that the type of
the len or cap of a map, slice, or string is 'int', not 'int32'.
It does not change the meaning of int, but it should make
the eventual change of the meaning of int in 6g a bit smoother.

Update #2188.

R=ken, dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6542059
2012-09-24 14:59:44 -04:00
Russ Cox
0bf46d0cf3 cmd/ld: prepare for 64-bit ints
Use explicit IntSize constant instead of 4.

This CL does not change the meaning of int, but it should make
the eventual change of the meaning of int on amd64 a bit
smoother.

Update #2188.

R=ken, dave
CC=golang-dev
https://golang.org/cl/6554076
2012-09-24 14:59:09 -04:00
Russ Cox
5501a097a9 cmd/cgo: prepare for 64-bit ints
This CL makes the size of an int controlled by a variable
in cgo instead of hard-coding 4 (or 32 bits) in various places.

Update #2188.

R=iant, r, dave
CC=golang-dev
https://golang.org/cl/6548061
2012-09-24 14:58:57 -04:00
Russ Cox
0b08c9483f runtime: prepare for 64-bit ints
This CL makes the runtime understand that the type of
the len or cap of a map, slice, or string is 'int', not 'int32',
and it is also careful to distinguish between function arguments
and results of type 'int' vs type 'int32'.

In the runtime, the new typedefs 'intgo' and 'uintgo' refer
to Go int and uint. The C types int and uint continue to be
unavailable (cause intentional compile errors).

This CL does not change the meaning of int, but it should make
the eventual change of the meaning of int on amd64 a bit
smoother.

Update #2188.

R=iant, r, dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6551067
2012-09-24 14:58:34 -04:00
Rémy Oudompheng
5e3fb887a3 cmd/[568]g: explain the purpose of various Reg fields.
R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6554062
2012-09-24 20:55:11 +02:00
Russ Cox
031b389ac1 cmd/gc: fix comment for caninl
Was describing an old implementation.

R=ken2
CC=golang-dev
https://golang.org/cl/6553066
2012-09-24 12:30:32 -04:00
Akshat Kumar
e42788628a cmd/dist, pkg/runtime: Plan 9, 64-bit: Get PID from TLS; remove use of `_tos'.
Using offsets from Tos is cumbersome and we've had problems
in the past. Since it's only being used to grab the PID, we'll just
get that from the default TLS instead.

R=rsc, rminnich, npe
CC=golang-dev
https://golang.org/cl/6543049
2012-09-24 12:24:45 -04:00
Rémy Oudompheng
36df358a30 cmd/6g: fix internal error with SSE registers.
Revision 63f7abcae015 introduced a bug caused by
code assuming registers started at X5, not X0.

Fixes #4138.

R=rsc
CC=golang-dev, remy
https://golang.org/cl/6558043
2012-09-23 18:22:03 +02:00
Shenghou Ma
ca5e9bfabc cmd/5g: fix build
R=rsc, r
CC=golang-dev
https://golang.org/cl/6552061
2012-09-23 15:05:44 +08:00
Russ Cox
05ac300830 cmd/gc: fix use of nil interface, slice
Fixes #3670.

R=ken2
CC=golang-dev
https://golang.org/cl/6542058
2012-09-22 20:42:11 -04:00
Russ Cox
658482d70f cmd/5g: fix register opt bug
The width was not being set on the address, which meant
that the optimizer could not find variables that overlapped
with it and mark them as having had their address taken.
This let to the compiler believing variables had been set
but never used and then optimizing away the set.

Fixes #4129.

R=ken2
CC=golang-dev
https://golang.org/cl/6552059
2012-09-22 10:01:35 -04:00
Joel Sing
49aa74ef7f cmd/cgo: use debug data for enums on windows
Use the debug data for enums on windows.

Fixes #4120.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/6545047
2012-09-22 17:57:54 +10:00
Russ Cox
c29f4e00a1 cmd/gc: fix a spurious -u compile error
Fixes #4082.

R=dsymonds
CC=golang-dev
https://golang.org/cl/6545055
2012-09-21 21:12:41 -04:00
Rob Pike
f934bb8eba cgo: set alignment to 1 for unions and classes; avoids crash from divide-by-zero
Fixes #4114.

R=golang-dev, iant, rsc, iant, devon.odell
CC=golang-dev
https://golang.org/cl/6553050
2012-09-22 07:25:41 +10:00
Rémy Oudompheng
413fbed341 cmd/6g: cosmetic improvements to regopt debugging.
R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/6528044
2012-09-21 20:20:26 +02:00
Russ Cox
57ad05db15 cmd/6g: use all 16 float registers, optimize float moves
Fixes #2446.

R=ken2
CC=golang-dev
https://golang.org/cl/6557044
2012-09-21 13:39:09 -04:00
Joel Sing
31758b2c1a cmd/{ld,5l,6l,8l}: add support for OpenBSD ELF signatures
OpenBSD now requires ELF binaries to have a PT_NOTE that identifies
it as an OpenBSD binary. Refactor the existing NetBSD ELF signature
code and implement support for OpenBSD ELF signatures.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6489131
2012-09-21 12:51:39 +10:00
Lucio De Re
091388d8e9 cmd/ld: remove unused assignment
The calculation of datsize is redundant.

R=golang-dev, seed, rsc
CC=golang-dev
https://golang.org/cl/6503122
2012-09-20 14:58:33 -04:00
Joel Sing
9536480edc cgo: process DWARF info even when debug data is used for value
Always process the DWARF info, even when the const value is determined
using the debug data block. This ensures that the injected enum is
removed and future loads of the same constant do not trigger
inconsistent definitions.

Add tests for issues 2470 and 4054.
Fixes #4054.

R=golang-dev, fullung, dave, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6501101
2012-09-20 13:20:33 +10:00
David Symonds
5a93fea08e vet: fix rangeloop.
In a range loop, the presence of a value implies the presence of a key.
However, the presence of a value as an *ast.Ident does not imply that
the key is also an *ast.Ident, thus leading to a panic any time the
two argument form is used where the key is not an identifier.

R=golang-dev, adg, r
CC=golang-dev
https://golang.org/cl/6540045
2012-09-20 08:12:47 +10:00
Robert Griesemer
83601807af gofmt: added testcase for files containing \r\n line endings
(see also issue 3961).

hexdump -c testdata/crlf.input
0000000   /   *  \r  \n  \t   S   o   u   r   c   e       c   o   n   t
0000010   a   i   n   i   n   g       C   R   /   L   F       l   i   n
0000020   e       e   n   d   i   n   g   s   .  \r  \n  \t   T   h   e
0000030       g   o   f   m   t   '   e   d       o   u   t   p   u   t
0000040       m   u   s   t       o   n   l   y       h   a   v   e
0000050   L   F  \r  \n  \t   l   i   n   e       e   n   d   i   n   g
0000060   s   .  \r  \n   *   /  \r  \n   p   a   c   k   a   g   e
0000070   m   a   i   n  \r  \n  \r  \n   f   u   n   c       m   a   i
0000080   n   (   )       {  \r  \n  \t   /   /       l   i   n   e
0000090   c   o   m   m   e   n   t  \r  \n  \t   p   r   i   n   t   l
00000a0   n   (   "   h   e   l   l   o   ,       w   o   r   l   d   !
00000b0   "   )       /   /       a   n   o   t   h   e   r       l   i
00000c0   n   e       c   o   m   m   e   n   t  \r  \n  \t   p   r   i
00000d0   n   t   l   n   (   )  \r  \n   }  \r  \n
00000db

hexdump -c testdata/crlf.golden
0000000   /   *  \n  \t   S   o   u   r   c   e       c   o   n   t   a
0000010   i   n   i   n   g       C   R   /   L   F       l   i   n   e
0000020       e   n   d   i   n   g   s   .  \n  \t   T   h   e       g
0000030   o   f   m   t   '   e   d       o   u   t   p   u   t       m
0000040   u   s   t       o   n   l   y       h   a   v   e       L   F
0000050  \n  \t   l   i   n   e       e   n   d   i   n   g   s   .  \n
0000060   *   /  \n   p   a   c   k   a   g   e       m   a   i   n  \n
0000070  \n   f   u   n   c       m   a   i   n   (   )       {  \n  \t
0000080   /   /       l   i   n   e       c   o   m   m   e   n   t  \n
0000090  \t   p   r   i   n   t   l   n   (   "   h   e   l   l   o   ,
00000a0       w   o   r   l   d   !   "   )       /   /       a   n   o
00000b0   t   h   e   r       l   i   n   e       c   o   m   m   e   n
00000c0   t  \n  \t   p   r   i   n   t   l   n   (   )  \n   }  \n
00000cf

R=rsc
CC=golang-dev
https://golang.org/cl/6526052
2012-09-19 14:14:21 -07:00
Shenghou Ma
4d7c81bc67 cmd/ld: consistent binary for cgo programs
We use pkg path instead of file name (which contains $WORK) in section symbols names.

R=golang-dev, fullung, rsc, iant
CC=golang-dev
https://golang.org/cl/6445085
2012-09-20 00:18:41 +08:00
Mikio Hara
1ad5f87635 cmd/api: fix signatures like func(x, y, z int)
Fixes writing of function parameter, result lists which
consist of multiple named or unnamed items with same type.

Fixes #4011.

R=golang-dev, bsiegert, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6475062
2012-09-19 07:04:12 +09:00
Andrew Gerrand
51e85612f9 vet: add range variable misuse detection
R=fullung, r, remyoudompheng, minux.ma, gri, rsc
CC=golang-dev
https://golang.org/cl/6494075
2012-09-18 14:19:31 -07:00
Dmitriy Vyukov
cc8cfefd8a race: linker changes
This is the second part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044
This change makes the linker emit dependency on runtime/race package when supplied with -b flag.

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6488074
2012-09-19 01:05:25 +04:00
Russ Cox
a29f3136b4 cmd/api: allow extension of interfaces with unexported methods
Fixes #4061.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6525047
2012-09-18 15:57:03 -04:00
Dmitriy Vyukov
8ed026e783 race: build system changes
This is the first part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044
Adds -race flag to go command.
API change:
+pkg go/build, type Context struct, InstallTag string

R=rsc
CC=golang-dev
https://golang.org/cl/6488075
2012-09-18 23:47:15 +04:00
Dmitriy Vyukov
99b6e9f73b race: cmd/cgo changes
This is a part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044
This change breaks circular dependency between runtime/race and syscall packages.

R=rsc
CC=golang-dev
https://golang.org/cl/6498079
2012-09-18 23:42:18 +04:00
Daniel Morsing
804a43ca76 cmd/gc: fix double evaluation in interface comparison
During interface compare, the operands will be evaluated twice. The operands might include function calls for conversion, so make them cheap before comparing them.

R=rsc
CC=golang-dev
https://golang.org/cl/6498133
2012-09-18 17:40:53 +02:00
Dave Cheney
55ca5ab0be runtime: arm: abort if VFPv3 support missing
Fixes #3456.

This proposal is a reformulation of CL 5987063. This CL resets
the default GOARM value to 6 and allows the use of the VFPv3
optimisation if GOARM=7. Binaries built with this CL in place
will abort if GOARM=7 was used and the target host does not
support VFPv3.

R=minux.ma, rsc, ajstarks
CC=golang-dev
https://golang.org/cl/6501099
2012-09-18 09:55:07 +10:00
Lucio De Re
b29ed23ab5 build: fix various 'set and not used' for Plan 9
R=dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6501134
2012-09-17 17:25:26 -04:00
Francisco Souza
916ccbf165 cmd/go: reject relative values for GOPATH
Fixes #4062.

R=rsc, dave, r
CC=golang-dev, nicksaika
https://golang.org/cl/6488129
2012-09-17 13:44:55 -07:00
Daniel Morsing
551e263823 cmd/gc: add missing conversion from bool to interface in switches.
In switches without an expression, the compiler would not convert the implicit true to an interface, causing codegen errors.

Fixes #3980.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6497147
2012-09-17 21:29:10 +02:00
Russ Cox
ae42beafd3 cmd/go: fix build
TBR=r

TBR=r
CC=golang-dev
https://golang.org/cl/6496124
2012-09-14 12:21:57 -04:00
Russ Cox
ca75fdf972 cmd/go: treat all commands in exp/ as tools
Nothing in exp should get installed directly in bin,
at least not by default.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6497138
2012-09-14 12:06:21 -04:00
Rob Pike
f269f9a3c7 cmd/yacc: allow utf-8 token values
Also clean up the code and allow \U.
Fixes #3007.

R=golang-dev, rsc, 0xjnml
CC=golang-dev
https://golang.org/cl/6492105
2012-09-13 13:59:00 -07:00
Jan Ziak
032e5bfb30 ld: add .gcdata and .gcbss sections
R=rsc
CC=golang-dev
https://golang.org/cl/6281048
2012-09-13 15:59:34 -04:00
Daniel Morsing
d06dcd4595 cmd/gc: Specify which package import caused an redeclaration error.
Fixes #4012.

R=dave, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6490082
2012-09-13 18:40:50 +02:00
Russ Cox
6ee91ced92 cmd/pack: rename __.SYMDEF to __.GOSYMDEF
This fixes a problem with ELF tools thinking they know the
format of the symbol table, as we do not use any of the
standard formats for that table.

This change will probably annoy the Plan 9 users, but I
believe there are other incompatibilities already that mean
they have to use a Go-specific nm.

Fixes #3473.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6500117
2012-09-13 10:26:21 -04:00
Jan Ziak
d09afc2efb gc: generate garbage collection info for types
R=rsc, nigeltao, minux.ma
CC=golang-dev
https://golang.org/cl/6290043
2012-09-12 12:08:27 -04:00
Russ Cox
792518c656 cmd/dist: emit \r in env -w output
go tool dist env -w is supposed to print a Windows batch file.
Normally Windows will execute batch files without \r before \n,
but issue 3060 reports that if the file ends up containing paths
written in Chinese, Windows 7 cannot execute it without the \r.
So add the \r.

Fixes #3060.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6498120
2012-09-12 12:05:34 -04:00
Nigel Tao
a9a675ec35 cmd/6g, cmd/8g: clean up unnecessary switch code in componentgen.
Code higher up in the function already catches these cases.

R=remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6496106
2012-09-12 21:47:05 +10:00
Daniel Morsing
8fd65b0e1d cmd/gc: Inline pointer sized T2I interface conversions
This CL also adds support for marking the likelyness of IF nodes in the AST being true. This feature is being used here to mark the slow path as unlikely.

src/pkg/runtime:
benchmark                  old ns/op    new ns/op    delta
BenchmarkConvT2IUintptr           16            1  -91.63%

test/bench/go1:
benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    5416917000   5461355000   +0.82%
BenchmarkFannkuch11      3810355000   3842609000   +0.85%
BenchmarkGobDecode         19950950     19855420   -0.48%
BenchmarkGobEncode         11301220     11308530   +0.06%
BenchmarkGzip             548119600    546869200   -0.23%
BenchmarkGunzip           176145400    180208300   +2.31%
BenchmarkJSONEncode        93117400     70163100  -24.65%
BenchmarkJSONDecode       406626800    409999200   +0.83%
BenchmarkMandelbrot200      6300992      6317866   +0.27%
BenchmarkParse              7664396      7451625   -2.78%
BenchmarkRevcomp         1189424000   1412332000  +18.74%
BenchmarkTemplate         491308400    458654200   -6.65%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            38.47        38.66    1.00x
BenchmarkGobEncode            67.92        67.87    1.00x
BenchmarkGzip                 35.40        35.48    1.00x
BenchmarkGunzip              110.16       107.68    0.98x
BenchmarkJSONEncode           20.84        27.66    1.33x
BenchmarkJSONDecode            4.77         4.73    0.99x
BenchmarkParse                 7.56         7.77    1.03x
BenchmarkRevcomp             213.69       179.96    0.84x
BenchmarkTemplate              3.95         4.23    1.07x

R=rsc, dave, nigeltao
CC=golang-dev
https://golang.org/cl/6351090
2012-09-11 21:42:30 +02:00
Nigel Tao
0184081eb9 cmd/gc: recognize small TPTR64 values as small integer constants.
Given the following Go program:

func sum(s []int) int {
        ret := 0
        for _, x := range s {
                ret += x
        }
        return ret
}

6g would previously generate:

--- prog list "sum" ---
0000 (main.go:3) TEXT    sum+0(SB),$0-24
0001 (main.go:5) MOVQ    s+0(FP),CX
0002 (main.go:5) MOVL    s+8(FP),DI
0003 (main.go:5) MOVL    s+12(FP),BX
0004 (main.go:4) MOVL    $0,SI
0005 (main.go:5) MOVL    $0,AX
0006 (main.go:5) JMP     ,8
0007 (main.go:5) INCL    ,AX
0008 (main.go:5) CMPL    AX,DI
0009 (main.go:5) JGE     $0,16
0010 (main.go:5) MOVL    (CX),DX
0011 (main.go:5) MOVQ    $4,BX
0012 (main.go:5) ADDQ    CX,BX
0013 (main.go:5) MOVQ    BX,CX
0014 (main.go:6) ADDL    DX,SI
0015 (main.go:5) JMP     ,7
0016 (main.go:8) MOVL    SI,.noname+16(FP)
0017 (main.go:8) RET     ,

and now generates:

--- prog list "sum" ---
0000 (main.go:3) TEXT    sum+0(SB),$0-24
0001 (main.go:5) MOVQ    s+0(FP),CX
0002 (main.go:5) MOVL    s+8(FP),DI
0003 (main.go:5) MOVL    s+12(FP),BX
0004 (main.go:4) MOVL    $0,SI
0005 (main.go:5) MOVL    $0,AX
0006 (main.go:5) JMP     ,8
0007 (main.go:5) INCL    ,AX
0008 (main.go:5) CMPL    AX,DI
0009 (main.go:5) JGE     $0,14
0010 (main.go:5) MOVL    (CX),BP
0011 (main.go:5) ADDQ    $4,CX
0012 (main.go:6) ADDL    BP,SI
0013 (main.go:5) JMP     ,7
0014 (main.go:8) MOVL    SI,.noname+16(FP)
0015 (main.go:8) RET     ,

The key difference is that
0011 (main.go:5) MOVQ    $4,BX
0012 (main.go:5) ADDQ    CX,BX
0013 (main.go:5) MOVQ    BX,CX
has changed to
0011 (main.go:5) ADDQ    $4,CX

R=rsc, dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6506089
2012-09-11 19:45:28 +10:00
Rémy Oudompheng
b45b6fd1c7 cmd/6g, cmd/8g: do not LEA[LQ] interfaces when calling methods.
It is enough to load directly the data word and the itab word
from memory, so we save a LEA instruction for each method call,
and allow elimination of some extra temporaries.

Update #1914.

R=daniel.morsing, rsc
CC=golang-dev, remy
https://golang.org/cl/6501110
2012-09-11 08:45:23 +02:00
Rémy Oudompheng
ff642e290f cmd/6g, cmd/8g: eliminate extra agen for nil comparisons.
Removes an extra LEAL/LEAQ instructions there and usually saves
a useless temporary in the idiom
    if err := foo(); err != nil {...}

Generated code is also less involved:
    MOVQ err+n(SP), AX
    CMPQ AX, $0
(potentially CMPQ n(SP), $0) instead of
    LEAQ err+n(SP), AX
    CMPQ (AX), $0

Update #1914.

R=daniel.morsing, nigeltao, rsc
CC=golang-dev, remy
https://golang.org/cl/6493099
2012-09-11 08:08:40 +02:00
Rob Pike
6ce4930365 gc: initial BOM is legal.
Fixes #4040.

R=rsc
CC=golang-dev
https://golang.org/cl/6497098
2012-09-10 13:03:07 -07:00
Adam Langley
2c5b53866c undo CL 6498092 / 4ff71bc1a199
Broke tests on 386.

««« original CL description
6l/8l: emit correct opcodes to F(SUB|DIV)R?D.

When the destination was not F0, 6l and 8l swapped FSUBD/FSUBRD and
FDIVD/FDIVRD.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6498092
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/6492100
2012-09-10 15:52:36 -04:00
Adam Langley
72fa142fc5 6l/8l: emit correct opcodes to F(SUB|DIV)R?D.
When the destination was not F0, 6l and 8l swapped FSUBD/FSUBRD and
FDIVD/FDIVRD.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6498092
2012-09-10 15:35:39 -04:00
Nigel Tao
5d7ece6f44 6g: delete unnecessary OXXX initialization.
No longer necessary after https://golang.org/cl/6497073/
removed the `if(n5.op != OXXX) { regfree(&n5); }`.

R=remy, r
CC=golang-dev, rsc
https://golang.org/cl/6498101
2012-09-10 11:24:34 +10:00
Rémy Oudompheng
ae0862c1ec cmd/8g: import componentgen from 6g.
This makes the compilers code more similar and improves
code generation a lot.

The number of LEAL instructions generated for cmd/go drops
by 60%.

% GOARCH=386 go build -gcflags -S -a cmd/go | grep LEAL | wc -l
Before:       89774
After:        47548

benchmark                              old ns/op    new ns/op    delta
BenchmarkAppendFloatDecimal                  540          444  -17.78%
BenchmarkAppendFloat                        1160         1035  -10.78%
BenchmarkAppendFloatExp                     1060          922  -13.02%
BenchmarkAppendFloatNegExp                  1053          920  -12.63%
BenchmarkAppendFloatBig                     1773         1558  -12.13%
BenchmarkFormatInt                         13065        12481   -4.47%
BenchmarkAppendInt                         10981         9900   -9.84%
BenchmarkFormatUint                         3804         3650   -4.05%
BenchmarkAppendUint                         3506         3303   -5.79%
BenchmarkUnquoteEasy                         714          683   -4.34%
BenchmarkUnquoteHard                        5117         2915  -43.03%

Update #1914.

R=nigeltao, rsc, golang-dev
CC=golang-dev, remy
https://golang.org/cl/6489067
2012-09-09 20:30:08 +02:00
Rob Pike
cbc9ab75cb cmd/yacc: allow leading underscore in token name
Fixes #4037.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6488093
2012-09-07 09:31:51 -07:00
Rémy Oudompheng
acbe6c94d7 cmd/6g: avoid taking the address of slices unnecessarily.
The main case where it happens is when evaluating &s[i] without
bounds checking, which usually happens during range loops (i=0).

This allows registerization of the corresponding variables,
saving 16 bytes of stack frame for each such range loop and a
LEAQ instruction.

R=golang-dev, rsc, dave
CC=golang-dev, remy
https://golang.org/cl/6497073
2012-09-07 06:54:42 +02:00
Joel Sing
4cfcb4a04b cgo: use debug data section for ELF
When generating enums use the debug data section instead of the
DWARF debug info, if it is available in the ELF file. This allows
mkerrors.sh to work correctly on OpenBSD/386 and NetBSD/386.

Fixes #2470.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6495090
2012-09-07 13:32:40 +10:00
Rob Pike
a225eaf9b7 cmd/yacc: always import fmt, safely
The parser depends on it but the client might not import it, so make sure it's there.
Fixes #4038.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6497094
2012-09-06 14:58:37 -07:00
Nigel Tao
481e5c6ad0 cmd/gc: re-order some OFOO constants. Rename ORRC to ORROTC to be
consistent with OLROT. Delete unused OBAD, OLRC.

R=rsc, dave
CC=golang-dev
https://golang.org/cl/6489082
2012-09-06 10:47:25 +10:00
Nigel Tao
1c675ac89d cmd/gc: add commentary to the OXXX constants.
R=rsc, daniel.morsing
CC=golang-dev
https://golang.org/cl/6495074
2012-09-05 09:34:52 +10:00
Shenghou Ma
88ba4de152 cmd/5l: embed $GOARM value into binary as runtime.goarm
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6449127
2012-09-03 03:51:13 +08:00
Russ Cox
a96c2b8c1a cmd/gc: fix PkgPath of byte, rune types
Fixes #3853.

R=ken2
CC=golang-dev
https://golang.org/cl/6492071
2012-09-01 19:55:55 -04:00
Shenghou Ma
c5444a8937 cmd/ld: support zero-filled section for Mach-O files
R=golang-dev, r, dave, rsc
CC=golang-dev
https://golang.org/cl/6492069
2012-09-02 04:50:58 +08:00
Daniel Morsing
1c2021ca14 cmd/gc: Suggest *T in error for x.(T) if it would work.
Accomplished by synchronizing the formatting of conversion errors between typecheck.c and subr.c

Fixes #3984.

R=golang-dev, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6500064
2012-09-01 13:52:55 -04:00
Rémy Oudompheng
8f3c2055bd cmd/6g, cmd/8g: eliminate short integer arithmetic when possible.
Fixes #3909.
Fixes #3910.

R=rsc, nigeltao
CC=golang-dev
https://golang.org/cl/6442114
2012-09-01 16:40:54 +02:00
Russ Cox
508bfda6d3 cmd/go: be clear that import loops are bad
There was mail on golang-nuts a few weeks ago
from someone who understood the message perfectly
and knew he had a cyclic dependency but assumed
that Go, like Python or Java, was supposed to handle it.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6488069
2012-09-01 10:34:58 -04:00
Rémy Oudompheng
ba97d52b85 cmd/gc: fix escape analysis bug with variable capture in loops.
Fixes #3975.

R=rsc, lvd
CC=golang-dev, remy
https://golang.org/cl/6475061
2012-08-31 22:23:37 +02:00
Akshat Kumar
a72bebf6e1 src: Add support for 64-bit version of Plan 9
This set of changes extends the Plan 9 support
to include the AMD64 architecture and should
work on all versions of Plan 9.

R=golang-dev, rminnich, noah.evans, rsc, minux.ma, npe
CC=akskuma, golang-dev, jfflore, noah.evans
https://golang.org/cl/6479052
2012-08-31 13:21:13 -04:00
Daniel Morsing
85ce3c7241 cmd/gc: mark broken type declarations as broken.
This fixes a spurious 'invalid recursive type' error, and stops the compiler from emitting errors on uses of the invalid type.

Fixes #3766.

R=golang-dev, dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6443100
2012-08-31 13:02:29 -04:00
Andrew Balholm
bdf6a43e23 cmd/yacc/units.txt: fix exchange rates
In the example "units" program for goyacc, the exchange rates were
        reciprocals of the correct amounts. Turn them right-side-up
        and update them to current figures.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6495053
2012-08-29 10:06:37 -07:00
Shenghou Ma
e607380ff6 cmd/ld: handle a special case of scattered relocation 2/1 on Darwin/386
Fixes #1635.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/6496043
2012-08-29 23:42:05 +08:00
Shenghou Ma
f653dfeb49 cmd/api: recognize version "devel" as dev. branch and apply -next
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6476066
2012-08-28 04:03:27 +08:00
Shenghou Ma
e80f6a4de1 cmd/6g: fix float32/64->uint64 conversion
CVTSS2SQ's rounding mode is controlled by the RC field of MXCSR;
as we specifically need truncate semantic, we should use CVTTSS2SQ.

    Fixes #3804.

R=rsc, r
CC=golang-dev
https://golang.org/cl/6352079
2012-08-23 14:35:26 +08:00
Shenghou Ma
1cf27acfed cmd/ld: set ELF header flags for our Linux/ARM binary
To make it more compliant.
This won't affect the behavior of running on OABI-only kernels.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6475044
2012-08-23 14:33:41 +08:00
Nigel Tao
251199c430 cmd/8g: roll back the small integer constant optimizations introduced
in 13416:67c0b8c8fb29 "faster code, mainly for rotate" [1]. The codegen
can run out of registers if there are too many small-int arithmetic ops.

An alternative approach is to copy 6g's sbop/abop codegen to 8g, but
this change is less risky.

Fixes #3835.

[1] http://code.google.com/p/go/source/diff?spec=svn67c0b8c8fb29b1b7b6221977af6b89cae787b941&name=67c0b8c8fb29&r=67c0b8c8fb29b1b7b6221977af6b89cae787b941&format=side&path=/src/cmd/8g/cgen.c

R=rsc, remyoudompheng, r
CC=golang-dev
https://golang.org/cl/6450163
2012-08-23 16:17:22 +10:00
Joel Sing
2281c3294b cmd/go: fix cgo linking on netbsd
NetBSD's built-in linker script for 'ld -r' does not provide a
SEARCH_DIR. As a result libgcc.a is not found when -lgcc is used.

Work around this by determining the path to libgcc (by invoking
gcc with the -print-libgcc-file-name option) and explicitly
referencing the resulting library.

R=golang-dev, iant, aram, lucio.dere, minux.ma
CC=golang-dev
https://golang.org/cl/6470044
2012-08-22 22:23:56 +10:00
Shenghou Ma
b1532344ef cmd/ld: skip R_*_NONE relocations, fix Linux/386 build again
The last fix was wrong w.r.t C's operator precedence,
and it also failed to really skip the NONE relocation.

The offending R_386_NONE relocation is a absolute
relocation in section .eh_frame.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/6463058
2012-08-21 00:34:06 +08:00
Alex Brainman
58064a7cab pprof: make it work on windows again
- pprof is a perl script, so go command should invoke
  perl instead of trying to run pprof directly;
- pprof should use "go tool nm" unconditionally on windows,
  no one else can extract symbols from Go program;
- pprof should use "go tool nm" instead of "6nm".

Fixes #3879.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6445082
2012-08-18 17:03:32 +10:00
Shenghou Ma
93fac8859c cmd/ld: explicitly ignore R_*_NONE relocation to fix build
I don't know why this relocation is used.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6464070
2012-08-17 09:11:58 +08:00
Shenghou Ma
551d8b9ff5 cmd/go: new cgo build procedure
This CL adds a step to the build procedure for cgo programs. It uses 'ld -r'
to combine all gcc compiled object file and generate a relocatable object file
for our ld. Additionally, this linking step will combine some static linking
gcc library into the relocatable object file, so that we can use libgcc,
libmingwex and libmingw32 without problem.

   Fixes #3261.
   Fixes #1741.
   Added a testcase for linking in libgcc.

TODO:
1. still need to fix the INDIRECT_SYMBOL_LOCAL problem on Darwin/386.
2. still need to enable the libgcc test on Linux/ARM, because 5l can't deal
with thumb libgcc.

Tested on Darwin/amd64, Darwin/386, FreeBSD/amd64, FreeBSD/386, Linux/amd64,
Linux/386, Linux/ARM, Windows/amd64, Windows/386

R=iant, rsc, bradfitz, coldredlemur
CC=golang-dev
https://golang.org/cl/5822049
2012-08-17 03:42:34 +08:00
Daniel Morsing
b04c890a89 cmd/gc: Don't claim type assertion would help when it wont.
Fixes #3465.

R=golang-dev, rsc, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/6448097
2012-08-15 16:53:06 -07:00
Francisco Souza
34976b985a cmd/go: skipping relative paths on go test -i ./...
Fixes #3896.

R=rsc, rogpeppe, r
CC=golang-dev
https://golang.org/cl/6457075
2012-08-15 07:32:49 -07:00
Robert Hencke
16a82828a2 5l: trivial whitespace cleanup
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6446131
2012-08-15 10:32:44 +10:00
Robert Griesemer
f597fa67c1 godoc: report error for directories with multiple packages
Fixes #3922.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/6453094
2012-08-09 16:10:46 -07:00
Shenghou Ma
af92b29fe6 cmd/5l: add PT_PAX_FLAGS ELF header
Although I don't use PAX enabled ARM kernels, PAX
does have support for ARM, so we're better off add
PT_PAX_FLAGS now in case people use PAX kernels.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6453092
2012-08-09 08:47:43 +08:00
Shenghou Ma
0cb04168d3 cmd/5l: dwarf line number support for Linux/ARM
Part of issue 3747.

R=dave, lvd, rsc
CC=golang-dev
https://golang.org/cl/6084044
2012-08-07 10:09:24 +08:00
Shenghou Ma
df623d03ab cmd/go: remove $WORK paths in generated binaries
Fixes #3748.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6357064
2012-08-07 10:00:58 +08:00
Rémy Oudompheng
77f3e189d2 runtime: faster string equality.
benchmark                                old ns/op    new ns/op    delta
BenchmarkCompareStringEqual                     51           35  -30.20%
BenchmarkCompareStringIdentical                 51            7  -85.71%
BenchmarkCompareStringSameLength                25           18  -28.29%
BenchmarkCompareStringDifferentLength            2            2   +1.46%

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6450092
2012-08-05 21:35:41 +02:00
Dmitriy Vyukov
2f2df2aceb cmd/go: allow to use syso files with cgo
I have C functions implemented in .syso file (rather than .so or inlined in .go file).
W/o this change the gcc invocation fails with undefined symbols.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6352076
2012-08-04 18:02:12 +03:00
Dmitriy Vyukov
8be5e8a419 cmd/cc: allow to call nested packages from within C code
E.g. sync/atomic.LoadInt32() can be called as sync»atomic·LoadInt32()

R=rsc
CC=golang-dev
https://golang.org/cl/6448057
2012-08-04 16:11:53 +04:00
Ian Lance Taylor
6fa38e5e0a cmd/go, go/build, misc/swig: add SWIG support to Go tool
R=adg, rsc, franciscossouza, seb.binet, gen.battle
CC=golang-dev
https://golang.org/cl/5845071
2012-08-03 18:08:43 -07:00