Commit graph

2296 commits

Author SHA1 Message Date
Ian Lance Taylor 607d5158c1 test: add gcc65755.go for http://gcc.gnu.org/PR65755
Change-Id: Ic35dff4c9a7fc6716ef9d5553a7b1769bed9be01
Reviewed-on: https://go-review.googlesource.com/8892
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-13 23:24:30 +00:00
Shenghou Ma 399b3e3230 test: add gccgo test case for #10407
Change-Id: I8d17e2b0fbc529ca7958c75222964a5e419aa3db
Reviewed-on: https://go-review.googlesource.com/8717
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-04-10 22:51:46 +00:00
Dmitry Vyukov 7647741246 test: add -update_errors flag to run script
The flag updates error annotations in test files from actual compiler output.
This is useful when doing compiler changes that add/remove/change lots of errors,
or when adding lots of new tests.
Also I noticed at least 2 cases where annotation were sub-optimal:
1. The annotation was "leaking param p" when the actual error is
"leaking param p to result ~r1".
2. The annotation was "leaking param m" when the actual errors
are "leaking param m" and "leaking param mv1".

For now it works only for errorcheck mode.

Also, apply the update to escape and liveness tests.
Some files have gccgo-specific errors of the form "gc error|gccgo error",
so it is risky to run update on all files. Gccgo-specific error
does not necessary contain '|', it can be just truncated.

Change-Id: Iaaae767f859dcb8321a8cb4970b2b70969e8a345
Reviewed-on: https://go-review.googlesource.com/5310
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-10 11:33:42 +00:00
Dmitry Vyukov 878a86a129 cmd/gc: fix escape analysis of closures
Fixes #10353

See test/escape2.go:issue10353. Previously new(int) did not escape to heap,
and so heap-allcated closure was referencing a stack var. This breaks
the invariant that heap must not contain pointers to stack.

Look at the following program:

package main

func main() {
	foo(new(int))
	bar(new(int))
}

func foo(x *int) func() {
	return func() {
		println(*x)
	}
}

// Models what foo effectively does.
func bar(x *int) *C {
	return &C{x}
}

type C struct {
	x *int
}

Without this patch escape analysis works as follows:

$ go build -gcflags="-m -m -m -l" esc.go
escflood:1: dst ~r1 scope:foo[0]
escwalk: level:0 depth:0  func literal( l(9) f(1) esc(no) ld(1)) scope:foo[1]
/tmp/live2.go:9: func literal escapes to heap
escwalk: level:0 depth:1 	 x( l(8) class(PPARAM) f(1) esc(no) ld(1)) scope:foo[1]
/tmp/live2.go:8: leaking param: x to result ~r1

escflood:2: dst ~r1 scope:bar[0]
escwalk: level:0 depth:0  &C literal( l(15) esc(no) ld(1)) scope:bar[1]
/tmp/live2.go:15: &C literal escapes to heap
escwalk: level:-1 depth:1 	 &C literal( l(15)) scope:bar[0]
escwalk: level:-1 depth:2 		 x( l(14) class(PPARAM) f(1) esc(no) ld(1)) scope:bar[1]
/tmp/live2.go:14: leaking param: x

/tmp/live2.go:5: new(int) escapes to heap
/tmp/live2.go:4: main new(int) does not escape

new(int) does not escape while being captured by the closure.
With this patch escape analysis of foo and bar works similarly:

$ go build -gcflags="-m -m -m -l" esc.go
escflood:1: dst ~r1 scope:foo[0]
escwalk: level:0 depth:0  &(func literal)( l(9)) scope:foo[0]
escwalk: level:-1 depth:1 	 func literal( l(9) f(1) esc(no) ld(1)) scope:foo[1]
/tmp/live2.go:9: func literal escapes to heap
escwalk: level:-1 depth:2 		 x( l(8) class(PPARAM) f(1) esc(no) ld(1)) scope:foo[1]
/tmp/live2.go:8: leaking param: x

escflood:2: dst ~r1 scope:bar[0]
escwalk: level:0 depth:0  &C literal( l(15) esc(no) ld(1)) scope:bar[1]
/tmp/live2.go:15: &C literal escapes to heap
escwalk: level:-1 depth:1 	 &C literal( l(15)) scope:bar[0]
escwalk: level:-1 depth:2 		 x( l(14) class(PPARAM) f(1) esc(no) ld(1)) scope:bar[1]
/tmp/live2.go:14: leaking param: x

/tmp/live2.go:4: new(int) escapes to heap
/tmp/live2.go:5: new(int) escapes to heap

Change-Id: Ifd14b7ae3fc11820e3b5eb31eb07f35a22ed0932
Reviewed-on: https://go-review.googlesource.com/8408
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-09 09:56:27 +00:00
Shenghou Ma 63d72f6901 cmd/7g: enable peephole optimizer
Based on cmd/9g/peep.go.

Go 1 benchmark comparison:
benchmark                          old ns/op       new ns/op       delta
BenchmarkBinaryTree17              24328574000     18351639000     -24.57%
BenchmarkFannkuch11                17029365000     10817758000     -36.48%
BenchmarkFmtFprintfEmpty           291             223             -23.37%
BenchmarkFmtFprintfString          1073            799             -25.54%
BenchmarkFmtFprintfInt             1024            778             -24.02%
BenchmarkFmtFprintfIntInt          1654            1277            -22.79%
BenchmarkFmtFprintfPrefixedInt     1360            1083            -20.37%
BenchmarkFmtFprintfFloat           2272            1415            -37.72%
BenchmarkFmtManyArgs               5933            4742            -20.07%
BenchmarkGobDecode                 53166003        38584736        -27.43%
BenchmarkGobEncode                 37930156        30074874        -20.71%
BenchmarkGzip                      1880638900      1286832100      -31.57%
BenchmarkGunzip                    386343633       292194480       -24.37%
BenchmarkHTTPClientServer          237077          179776          -24.17%
BenchmarkJSONEncode                101731690       73116925        -28.13%
BenchmarkJSONDecode                344655360       241277600       -29.99%
BenchmarkMandelbrot200             28329778        12950809        -54.29%
BenchmarkGoParse                   21670755        16554244        -23.61%
BenchmarkRegexpMatchEasy0_32       557             484             -13.11%
BenchmarkRegexpMatchEasy0_1K       4687            4832            +3.09%
BenchmarkRegexpMatchEasy1_32       539             483             -10.39%
BenchmarkRegexpMatchEasy1_1K       5100            5080            -0.39%
BenchmarkRegexpMatchMedium_32      796             651             -18.22%
BenchmarkRegexpMatchMedium_1K      233099          182047          -21.90%
BenchmarkRegexpMatchHard_32        13202           9897            -25.03%
BenchmarkRegexpMatchHard_1K        401027          303602          -24.29%
BenchmarkRevcomp                   3837679666      2816546600      -26.61%
BenchmarkTemplate                  440608300       324831040       -26.28%
BenchmarkTimeParse                 1460            1019            -30.21%
BenchmarkTimeFormat                1609            1174            -27.04%

benchmark                         old MB/s     new MB/s     speedup
BenchmarkGobDecode                14.44        19.89        1.38x
BenchmarkGobEncode                20.24        25.52        1.26x
BenchmarkGzip                     10.32        15.08        1.46x
BenchmarkGunzip                   50.23        66.41        1.32x
BenchmarkJSONEncode               19.07        26.54        1.39x
BenchmarkJSONDecode               5.63         8.04         1.43x
BenchmarkGoParse                  2.67         3.50         1.31x
BenchmarkRegexpMatchEasy0_32      57.38        66.05        1.15x
BenchmarkRegexpMatchEasy0_1K      218.47       211.91       0.97x
BenchmarkRegexpMatchEasy1_32      59.29        66.21        1.12x
BenchmarkRegexpMatchEasy1_1K      200.76       201.54       1.00x
BenchmarkRegexpMatchMedium_32     1.26         1.53         1.21x
BenchmarkRegexpMatchMedium_1K     4.39         5.62         1.28x
BenchmarkRegexpMatchHard_32       2.42         3.23         1.33x
BenchmarkRegexpMatchHard_1K       2.55         3.37         1.32x
BenchmarkRevcomp                  66.23        90.24        1.36x
BenchmarkTemplate                 4.40         5.97         1.36x

Fixes #10105.

Change-Id: I353cc9fdf922e431821508c9dbbe4d9a85d64bd4
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8471
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-04-08 08:16:54 +00:00
Matthew Dempsky 4f2a73011f cmd/internal/gc, cmd/yacc: restore remaining custom error messages
This CL extends cmd/yacc to expose a yyErrorVerbose variable that
changes the error messages from just "syntax error" to "syntax error:
unexpected ${tokname}".

It also moves the yyToknames table generation to after rules have been
processed so that entries can be generated for tokens that aren't
mentioned in the preamble (e.g., '.' in the case of go.y).

Lastly, it restores gc's old code for applying yytfix to yyToknames,
except that substituting "LLITERAL" with litbuf happens in Yyerror.

Fixes #9968.

Change-Id: Icec188d11fdabc1dae31b8a471c35b5c7f6deec7
Reviewed-on: https://go-review.googlesource.com/8432
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-03 23:40:40 +00:00
David Crawshaw ca0adeddd5 cmd/7g: reserve registers R26 to R32
These registers are not available for programs to use. Prior to this
change, the compiler would crash attempting to use ZR as a general
purpose register. Other programs would compile but on execution would
overwrite the G register and cause havoc.

Fixes linux/arm64 build.
Fixes #10304
Fixes #10320

Change-Id: I5cf51d3b77cfe3db7dd6377324950cafb02f8d8b
Reviewed-on: https://go-review.googlesource.com/8456
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-03 18:25:09 +00:00
Robert Griesemer a51d5f27e8 cmd/internal/gc: use 512 bits (rather than 464) for multi-precision arithmetic
The original implementation used 16 int "words" but only 29 bits per word
for a total of 16*29 = 464 bits, with a space consumption of 16*64 = 1024
bits on a 64 bit machine. Switching to 512 bits increases precision while
still using (in the worst case) half the amount of memory per mp value on
a 64 bit machine.

Also: Decreased permitted number of least-significant mantissa bits which
may be incorrect when considering if a precise floating-point constant is
an integer from 29 to 16 bits.

Change-Id: Iee9287056f0e9aa4f06ceac0724ff4674f710c53
Reviewed-on: https://go-review.googlesource.com/8429
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-03 17:13:07 +00:00
Robert Griesemer 5bb89eb009 cmd/internal/gc: use big.Float to represent Mpflt bits
All multi-precision arithmetic is now based on math/big.

- passes all.bash
- added test cases for fixed bugs

Fixes #7740.
Fixes #6866.

Change-Id: I67268b91766970ced3b928260053ccdce8753d58
Reviewed-on: https://go-review.googlesource.com/7912
Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-02 22:49:47 +00:00
Matthew Dempsky 398bf9d5a0 cmd/internal/gc, cmd/yacc: restore custom syntax error messages
This restores go.errors from before 3af0d79 along with a fixed up
version of the bisonerrors AWK script, translated to Go.

However, this means Yyerror needs access to the yacc parser's state,
which is currently private.  To workaround that, add a "state"
accessor method like the Lookahead method added in c7fa3c6.

Update issue #9968.

Change-Id: Ib868789e92fdb7d135442120a392457923e50121
Reviewed-on: https://go-review.googlesource.com/7270
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-02 21:56:24 +00:00
David Crawshaw 33448d963c cmd/7g: fix ACMP entry in progtable
On arm64, CMP $foo, R is encoded as from=$foo, reg=R, not as from=$foo,
to=R. The progtable entry for ACMP incorrectly described the latter
form. Because of this, the registerizer was not accounting the registers
used in CMP instructions and was incorrectly re-assigning those registers.

This was an old problem, but it only became apparent after b115c35
(cmd/internal/gc: move cgen, regalloc, et al to portable code). Previous
to this commit, the compiler used a slightly larger register set for the
temps than it used for register variables. Since it had plenty registers
dedicated to temps, the registers used in CMP instruction never clashed
with registers assigned to register variables.

Fixes #10253

Change-Id: Iedf4bd882bd59440dff310ac0f81e0f53d80d7ed
Reviewed-on: https://go-review.googlesource.com/8387
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-02 20:18:28 +00:00
Shenghou Ma 73c026e6fe test: add testcase for gccgo-specific issue 10284
Change-Id: I624b336a9eb27fbbc8ef13f141023b4f60966245
Reviewed-on: https://go-review.googlesource.com/8240
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-30 19:31:35 +00:00
David Chase 2270133981 cmd/gc: allocate backing storage for non-escaping interfaces on stack
Extend escape analysis to convT2E and conT2I. If the interface value
does not escape supply runtime with a stack buffer for the object copy.

This is a straight port from .c to .go of Dmitry's patch

Change-Id: Ic315dd50d144d94dd3324227099c116be5ca70b6
Reviewed-on: https://go-review.googlesource.com/8201
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-03-30 16:11:22 +00:00
Dmitry Vyukov d593f4a4d5 test: add tests for escape analysis of function parameters
False positives (var incorrectly escapes) are marked with BAD.

Change-Id: I002ac5965ec6748adafa2c4c657c97d8f7ff75d0
Reviewed-on: https://go-review.googlesource.com/5311
Reviewed-by: Keith Randall <khr@golang.org>
2015-03-30 10:12:05 +00:00
Dmitry Vyukov edcc062bdc test: add tests for escape analysis of interface conversions
The false positives (var incorrectly escapes) are marked with BAD.

Change-Id: If64fabb6ea96de44a1177d9ab12e2ccc579fe0c4
Reviewed-on: https://go-review.googlesource.com/5294
Reviewed-by: Keith Randall <khr@golang.org>
2015-03-28 16:15:27 +00:00
Dmitry Vyukov 8a2545744b test: add tests for escape analysis of closure arguments
10 false positives (var incorrectly escapes to heap) are marked with BAD.

Change-Id: I773b13a18ff55aaa499a2a28a979118422cc5322
Reviewed-on: https://go-review.googlesource.com/5293
Reviewed-by: Keith Randall <khr@golang.org>
2015-03-28 15:08:09 +00:00
Dmitry Vyukov 8205bfb566 test: fix build
Fix build after http://golang.org/cl/5297
The compiler was changed to not print implicit map capacity in error messages.

Change-Id: I852f668680c3c69c5eecc7964e46202a97014d6a
Reviewed-on: https://go-review.googlesource.com/8212
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-03-28 15:02:39 +00:00
Dmitry Vyukov 6d9fd7e65b test: add tests for indirection level computation in escape analysis
The false positive (var incorrectly escapes to heap) is marked with BAD.

Change-Id: I11877fa8e976094b31a221abd88ae32d351c85ee
Reviewed-on: https://go-review.googlesource.com/5292
Reviewed-by: Keith Randall <khr@golang.org>
2015-03-28 13:43:27 +00:00
Dmitry Vyukov 130538bb9a test: add escape analysis tests form maps
False positives (var incorrectly escapes) are marked with BAD.

Change-Id: I8383fa3f77e2156d781d994968636ba9a17bb975
Reviewed-on: https://go-review.googlesource.com/5297
Reviewed-by: Keith Randall <khr@golang.org>
2015-03-28 13:41:09 +00:00
Dmitry Vyukov a21537ff74 test: add tests for escape analysis when assigning to indirections
False positives (var incorrectly escapes) are marked with BAD.

Change-Id: I0114d87ee467fe1e3b27642f8c5a04d4a9664211
Reviewed-on: https://go-review.googlesource.com/5295
Reviewed-by: Keith Randall <khr@golang.org>
2015-03-28 13:38:45 +00:00
Dmitry Vyukov 097b1e0b73 test: add escape analysis tests for fields
False positives (var incorrectly escapes) are marked with BAD.

Change-Id: I3027b6e0f5b48325e6169599400cc59e1394809f
Reviewed-on: https://go-review.googlesource.com/5431
Reviewed-by: Keith Randall <khr@golang.org>
2015-03-28 13:31:26 +00:00
Dmitry Vyukov 0558f12123 test: add tests for escape analysis of slices
False positives (var incorrectly escapes) are marked with BAD.

Change-Id: I9e9a3f71b060520103bcf289829a2efdf6f2b517
Reviewed-on: https://go-review.googlesource.com/5298
Reviewed-by: Keith Randall <khr@golang.org>
2015-03-28 13:18:42 +00:00
Dmitry Vyukov 1f5617e37c test: add additional ... tests for escape analysis
False positives (var incorrectly escapes) are marked with BAD.

Change-Id: I646a29ffe24d963c63db09cba81dbc101d7c7242
Reviewed-on: https://go-review.googlesource.com/5296
Reviewed-by: Keith Randall <khr@golang.org>
2015-03-28 13:07:19 +00:00
Russ Cox 4224d81fae cmd/internal/gc: inline x := y.(*T) and x, ok := y.(*T)
These can be implemented with just a compare and a move instruction.
Do so, avoiding the overhead of a call into the runtime.

These assertions are a significant cost in Go code that uses interface{}
as a safe alternative to C's void* (or unsafe.Pointer), such as the
current version of the Go compiler.

*T here includes pointer to T but also any Go type represented as
a single pointer (chan, func, map). It does not include [1]*T or struct{*int}.
That requires more work in other parts of the compiler; there is a TODO.

Change-Id: I7ff681c20d2c3eb6ad11dd7b3a37b1f3dda23965
Reviewed-on: https://go-review.googlesource.com/7862
Reviewed-by: Rob Pike <r@golang.org>
2015-03-20 20:05:37 +00:00
Dave Cheney 1f3fe91066 test: fix recover4 test on 64kb systems
Fix recover4.go to work on 64kb systems.

Change-Id: I211cb048de1268a8bbac77c6f3a1e0b8c8277594
Reviewed-on: https://go-review.googlesource.com/7673
Reviewed-by: Minux Ma <minux@golang.org>
2015-03-17 05:25:01 +00:00
Dave Cheney 3eaea873b4 Revert "test: disable recover4 test to fix ppc64 builds"
This reverts commit 1313e7982f.

Change-Id: I96cc58baf71156fdfbf8fd61332744bcc3ea52e5
Reviewed-on: https://go-review.googlesource.com/7670
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-03-17 03:38:38 +00:00
Dave Cheney 1313e7982f test: disable recover4 test to fix ppc64 builds
Updates #10180

Temporarily disable this test on ppc64 systems as all our builders use 64k page size.

We need a portable way to get the page size of the host so we can correctly size the mmap hole.

Change-Id: Ibd36ebe2f54cf75a44667e2070c385f0daaca481
Reviewed-on: https://go-review.googlesource.com/7652
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-03-17 02:58:17 +00:00
Russ Cox 0c31992eb3 test: add test that variables captured by deferred funcs are current on fault
This came up in private mail.
It works today and I want to make sure it stays working.

Change-Id: I13ebdc2dfadb3c72d7f179be89883137320c05d0
Reviewed-on: https://go-review.googlesource.com/7390
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Rob Pike <r@golang.org>
2015-03-16 23:07:06 +00:00
Aram Hăvărneanu ddf6d8005d test: fix nosplit test, and disable nilptr3 test on arm64
Change-Id: I5d40e04395de743a8fdcfa8bdc0e580729bc66a3
Reviewed-on: https://go-review.googlesource.com/7147
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-16 18:46:35 +00:00
Ian Lance Taylor 362f7bfa68 test: add test that gccgo failed to compile
Change-Id: I9ea6d4d8a9c1c63de36f2f3871dd5ac9201c0aac
Reviewed-on: https://go-review.googlesource.com/7523
Reviewed-by: Minux Ma <minux@golang.org>
2015-03-13 22:05:23 +00:00
Shenghou Ma 0d6a0d6c3f runtime: don't return a slice with nil ptr but non-zero len from growslice
Fixes #10135.

Change-Id: Ic4c5ab15bcb7b9c3fcc685a788d3b59c60c26e1e
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7400
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-12 00:08:38 +00:00
Chris Manghane 09b49bf18d test: add testcase for gccgo-specific issue 10047.
Change-Id: Ia5115b15a79e1b2b53036646f1ed4b08225b220f
Reviewed-on: https://go-review.googlesource.com/7051
Run-TryBot: Chris Manghane <cmang@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-06 22:29:08 +00:00
Shenghou Ma f09887cdce cmd/internal/gc: do not show original expression for constants in export data
Fixes #10066.

Change-Id: I43c423793dd094989e921e163a06b12181a35719
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/6750
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-03-05 03:40:42 +00:00
Russ Cox 77ccb16eb1 cmd/internal/gc: transitive inlining
Inlining refuses to inline bodies containing an actual function call, so that
if that call or a child uses runtime.Caller it cannot observe
the inlining.

However, inlining was also refusing to inline bodies that contained
function calls that were themselves inlined away. For example:

	func f() int {
		return f1()
	}

	func f1() int {
		return f2()
	}

	func f2() int {
		return 2
	}

The f2 call in f1 would be inlined, but the f1 call in f would not,
because f1's call to f2 blocked the inlining, despite itself eventually
being inlined away.

Account properly for this kind of transitive inlining and enable.

Also bump the inlining budget a bit, so that the runtime's
heapBits.next is inlined.

This reduces the time for '6g *.go' in html/template by around 12% (!).
(For what it's worth, closing Chrome reduces the time by about 17%.)

Change-Id: If1aa673bf3e583082dcfb5f223e67355c984bfc1
Reviewed-on: https://go-review.googlesource.com/5952
Reviewed-by: Austin Clements <austin@google.com>
2015-02-26 17:36:00 +00:00
Chris Manghane 77d7771a82 cmd/internal/gc: omit non-explicit capacity in errors with map/chan make
Fixes #9083.

Change-Id: Ifbdebafb39a73a1dacf7e67171e8e88028d1f10b
Reviewed-on: https://go-review.googlesource.com/1219
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Chris Manghane <cmang@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-02-25 20:04:22 +00:00
Chris Manghane c7e1453e3d cmd/internal/gc: do not show computed value in type error
Fixes #9076.

Change-Id: Ib41a452fa9aa9fecf19f65c36d13715923548041
Reviewed-on: https://go-review.googlesource.com/1250
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Chris Manghane <cmang@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-02-25 19:49:49 +00:00
Chris Manghane b59dd94f33 cmd/internal/gc: method selector should not auto-deref named pointer type
Fixes #9017.

Change-Id: I26cb1e7d6e137ff145773169cfe2d8bd4e1b339c
Reviewed-on: https://go-review.googlesource.com/1252
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Chris Manghane <cmang@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-02-25 19:27:30 +00:00
Russ Cox 5b94a47b7f [dev.cc] test: disable syntax error tests
These don't work with the new compiler, because the
new compiler doesn't have the custom syntax errors
that I built for the old compiler. It will, just not yet.
(Issue #9968.)

Change-Id: I658f7dab2c7f855340a501f9ae4479c097b28cd3
Reviewed-on: https://go-review.googlesource.com/5632
Reviewed-by: Rob Pike <r@golang.org>
2015-02-23 19:56:11 +00:00
Russ Cox b4a7806724 [dev.cc] all: merge master (5868ce3) into dev.cc
This time for sure!

Change-Id: I7e7ea24edb7c2f711489e162fb97237a87533089
2015-02-20 10:28:36 -05:00
Russ Cox d7eb51e70e [dev.cc] test: disable rotate tests
They use too much memory in the current Go compiler draft.
This should fix some builders.

Reenabling is #9933.

Change-Id: Ib5ef348b2c55d2012ffed765f2a6df99dec171f4
Reviewed-on: https://go-review.googlesource.com/5302
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-19 20:14:21 +00:00
Ian Lance Taylor 5aa448ff8c test: add test case for issue 4365
This is an update of http://golang.org/cl/151410043 by Tim Shen.

Change-Id: I43ab7fcedd785059c535f45a3c8cdb7b618c1499
Reviewed-on: https://go-review.googlesource.com/4873
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-02-14 16:02:10 +00:00
Brad Fitzpatrick b5b11bdbc6 test: deflake init1.go test, tighten its bounds
Per the comment at top, this test is about whether the GC runs during
init, but it was testing more than that, and testing how much the GC
collected in a certain amount of time.

Instead, loosen this test to just see whether it ran at all and not
how well it did.

Fixes #9848

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

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

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

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

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

Change-Id: Ic85e1706e18c3235cc45b3c0c031a9c1cdb7a40e
Reviewed-on: https://go-review.googlesource.com/4050
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-13 12:12:18 +00:00
Josh Bleecher Snyder 77a2113925 cmd/gc: evaluate concrete == interface without allocating
Consider an interface value i of type I and concrete value c of type C.

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

Evaluating I(c) can allocate.

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

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

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

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

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

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

Fixes #9370.

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

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

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

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

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

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

Fixes #5449

Change-Id: I24fa66f949d2f138885d9e66a0d160240dc9e8fa
Reviewed-on: https://go-review.googlesource.com/3508
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
2015-02-12 09:53:52 +00:00
Dmitry Vyukov 9568126f35 cmd/gc: allocate buffers for non-escaping string conversions on stack
Support the following conversions in escape analysis:
[]rune("foo")
[]byte("foo")
string([]rune{})

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

Change-Id: I1d075907eab8b0109ad7ad1878104b02b3d5c690
Reviewed-on: https://go-review.googlesource.com/3590
Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-12 08:29:53 +00:00
Josh Bleecher Snyder 4ce06f4b5c cmd/gc: eliminate dead code in switch statements
Ordinary switch statements are rewritten
into a sequence of if statements.
Staticly dead cases were not being eliminated
because the rewrite introduced a temporary,
which hid the fact that the case was a constant.
Stop doing that.

This eliminates dead code in the standard library at:

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

Fixes #9608.

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

Change-Id: Icfc14e4998723e2c2d48f9877a91c5abef6794ea
Reviewed-on: https://go-review.googlesource.com/4060
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-06 14:41:47 +00:00
Rahul Chaudhry 8581d48c15 test: check for build constraints only upto the first blank line
The main issue is that the misc/cgo/{stdio,life} tests are silently
getting skipped when invoked from run.bash.

run.go should ignore any build tags after the first blank line in
source file. It already checks for test actions only upto the first
blank line. Build tags must be specified in the same block.

See http://golang.org/cl/3675 for background.

Change-Id: Id8abf000119e3335f7250d8ef34aac7811fc9dff
Reviewed-on: https://go-review.googlesource.com/3812
Reviewed-by: Minux Ma <minux@golang.org>
2015-02-06 05:36:26 +00:00
Rahul Chaudhry d81cc374be test: chdir before running go tool, cleanup afterwards.
issue9355 generated a file a.[568] in test/ directory and left it there.
For tests like these, it is best to chdir to a test specific directory
before generating any temporary files, since the tests are running
in parallel and might otherwise race with each other for the same files.

Change-Id: I58d96256d4d8ee3fda70d81077f19006064a7425
Reviewed-on: https://go-review.googlesource.com/3813
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-06 05:16:34 +00:00
Dmitry Vyukov eaa872009d cmd/gc: fix capturing by value for range statements
Kindly detected by race builders by failing TestRaceRange.
ORANGE typecheck does not increment decldepth around body.

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

switch unsafe.Sizeof = x.(type) {

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

Fixes #9731

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

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

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

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

Change-Id: Iab75de2d78335d4e31c3dce6a0e1826d8cddf5f3
Reviewed-on: https://go-review.googlesource.com/3690
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-02-02 14:14:21 +00:00
Robert Griesemer 4a1756824f test/closure2.go: correctly "use" tmp
cmd/go doesn't complain (this is an open issue), but go/types does

Change-Id: I2caec1f7aec991a9500d2c3504c29e4ab718c138
Reviewed-on: https://go-review.googlesource.com/3541
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-01-29 22:22:14 +00:00
Dmitry Vyukov 0e80b2e082 cmd/gc: capture variables by value
Language specification says that variables are captured by reference.
And that is what gc compiler does. However, in lots of cases it is
possible to capture variables by value under the hood without
affecting visible behavior of programs. For example, consider
the following typical pattern:

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

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

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

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

Fixes #6632.

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

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

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

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

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

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

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

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

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

This change recognizes such assignments and ignores them.

Update issue #9043.
Update issue #7921.

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

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

Second is in time:

type data struct {
	p     []byte
	error bool
}

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

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

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

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

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

Change-Id: I22bfc82e05497e91a7b18a668913aed6c723365d
Reviewed-on: https://go-review.googlesource.com/3282
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28 15:14:04 +00:00
Ian Lance Taylor ec0ebc2281 cmd/gc: treat non-local vars inlined into wrapper as escaping
The compiler has a phase ordering problem.  Escape analysis runs
before wrapper generation.  When a generated wrapper calls a method
defined in a different package, if that call is inlined, there will be
no escape information for the variables defined in the inlined call.
Those variables will be placed on the stack, which fails if they
actually do escape.

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

Fixes #9537.

Change-Id: I530f39346de16ad173371c6c3f69cc189351a4e9
Reviewed-on: https://go-review.googlesource.com/3092
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-22 03:25:12 +00:00
Chris Manghane f5b8813e93 cmd/gc: don't unpack struct arguments to append
Fixes #9634.

Change-Id: I7b18f26c2fb812978fc7adc5bfd39ebfffe48701
Reviewed-on: https://go-review.googlesource.com/3080
Reviewed-by: Minux Ma <minux@golang.org>
2015-01-20 22:55:56 +00:00
Keith Randall c3b459d328 test: generate tests for arithmetic on narrow types
Fixes #9607
Related to #9604
Inadvertently found #9609

Change-Id: I8a8ddf84ac72d3e18986fd8e9288734459f3f174
Reviewed-on: https://go-review.googlesource.com/2962
Reviewed-by: Minux Ma <minux@golang.org>
2015-01-17 21:00:15 +00:00
Keith Randall daa64ddfe6 cmd/5g: make sure we normalize after unary ops on small types
We were failing ^uint16(0xffff) == 0, as we computed 0xffff0000 instead.

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

Fixes #9604

Change-Id: I4c2d5bdc667742873ac029fdbe3db0cf12893c27
Reviewed-on: https://go-review.googlesource.com/2940
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2015-01-15 23:50:01 +00:00
Rob Pike 3b63b69d2f test: comment the behavior and use of cmplxdivide*
The various files are confusingly named and their operation
not easy to see. Add a comment to cmplxdivide.c, one of the few
C files that will endure in the repository, to explain how to build
and run the test.

Change-Id: I1fd5c564a14217e1b9815b09bc24cc43c54c096f
Reviewed-on: https://go-review.googlesource.com/2850
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-15 00:00:06 +00:00
Shenghou Ma fcff3ba740 cmd/gc: don't recurse infinitely when a recursive type references itself more than once
Fixes #9432

Change-Id: I08c92481afa7c7fac890aa780efc1cb2fabad528
Reviewed-on: https://go-review.googlesource.com/2115
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-12 02:09:50 +00:00
Josh Bleecher Snyder f03c9202c4 cmd/gc: optimize memclr of slices and arrays
Recognize loops of the form

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

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

The motivating example is clearing a byte slice:

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

Update #5373.

Change-Id: I99d3e6f5f268e8c6499b7e661df46403e5eb83e4
Reviewed-on: https://go-review.googlesource.com/2520
Reviewed-by: Keith Randall <khr@golang.org>
2015-01-09 22:35:25 +00:00
Rick Hudson db7fd1c142 runtime: increase GC concurrency.
run GC in its own background goroutine making the
caller runnable if resources are available. This is
critical in single goroutine applications.
Allow goroutines that allocate a lot to help out
the GC and in doing so throttle their own allocation.
Adjust test so that it only detects that a GC is run
during init calls and not whether the GC is memory
efficient. Memory efficiency work will happen later
in 1.5.

Change-Id: I4306f5e377bb47c69bda1aedba66164f12b20c2b
Reviewed-on: https://go-review.googlesource.com/2349
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2015-01-08 20:34:56 +00:00
Keith Randall fcfbeb3adf test: shorten test runtime
This test was taking a long time, reduce its zealousness.

Change-Id: Ib824247b84b0039a9ec690f72336bef3738d4c44
Reviewed-on: https://go-review.googlesource.com/2502
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
2015-01-08 04:49:43 +00:00
Josh Bleecher Snyder 43e6923131 cmd/gc: optimize existence-only map lookups
The compiler converts 'val, ok = m[key]' to

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

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

Change-Id: I21346cc195cb3c62e041af8b18770c0940358695
Reviewed-on: https://go-review.googlesource.com/1975
Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-07 22:36:06 +00:00
Josh Bleecher Snyder 60801c4853 test: delete testlib
It is unused as of e7173dfd.

Change-Id: I3e4ea3fc66cf0a768ff28172a151b244952eefc9
Reviewed-on: https://go-review.googlesource.com/2093
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-07 21:48:48 +00:00
Matthew Dempsky 537ddc9456 runtime: fix slicecopy return value for zero-width elements
Fixes #8620

Change-Id: Idb49e586919d21d07e94a39ed9ebb0562f403460
Reviewed-on: https://go-review.googlesource.com/2221
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-04 01:59:59 +00:00
Josh Bleecher Snyder 8bbd80063b cmd/go: put user ldflags at the end of the linker invocation
If the user provided a key but no value via -ldflag -X,
another linker flag was used as the value.

Placing the user's flags at the end avoids this problem.
It also provides the user the opportunity to
override existing linker flags.

Fixes #8810.

Change-Id: I96f4190713dc9a9c29142e56658446fba7fb6bc8
Reviewed-on: https://go-review.googlesource.com/2242
Reviewed-by: Minux Ma <minux@golang.org>
2015-01-02 18:36:44 +00:00
Shenghou Ma cb1897a58c cmd/gc: give an error if only one argument is given to complex()
Fixes #8501

Change-Id: I0dbbdded7f7924351c3d1841d60cb5c934b295b7
Reviewed-on: https://go-review.googlesource.com/2143
Reviewed-by: Chris Manghane <cmang@golang.org>
2015-01-02 02:52:56 +00:00
Chris Manghane 5cc29ab95e cmd/gc: logical operators should produce untyped bool for untyped
operands

Fixes #6671 for cmd/gc.

Change-Id: I4907655b6e243960f2ceb544c63ea16513c7bd68
Reviewed-on: https://go-review.googlesource.com/1251
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-29 23:36:30 +00:00
Chris Manghane edf7258416 test: add fixed GoSmith bugs reported on the gcc Bugzilla
Change-Id: I36b57f3e299a4f96b8b5aa55c9c224d888229684
Reviewed-on: https://go-review.googlesource.com/1790
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-29 23:21:10 +00:00
Shenghou Ma 958e0792b5 test/fixedbugs/issue9355: fix build on arm and power64
Change-Id: I1ef770184ad1d42bcb58714d559f2cc866a919ab
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/1880
Reviewed-by: Keith Randall <khr@golang.org>
2014-12-24 00:07:46 +00:00
David du Colombier fbdf59a7c4 test: disable bug248 and bug345 tests on Plan 9
These tests were enabled as part of change 1774.
They depend on the errchk tool, which is a Perl
script. However, Perl is not available on Plan 9.

Change-Id: I82707aae16013acc9a3800d39b0084588b852b53
Reviewed-on: https://go-review.googlesource.com/2031
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-23 10:28:39 +00:00
Josh Bleecher Snyder 209dd4cdc1 test: fix windows build
Broken by e7173dfdfd

Fix by simply disabling the relevant tests.

* bug248 and bug345 require errchk, but we can't
  rely on perl being available.
* bug369 is disabled anyway.

Change-Id: Idf73ebccb066943e3fe17c2f662b37238ec74dfe
Reviewed-on: https://go-review.googlesource.com/2052
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2014-12-23 01:12:30 +00:00
Ian Lance Taylor 02f56bfb5c test: add test case that gccgo failed to link
Gccgo creates a struct to hold the arguments for the deferred
function.  In this example the struct holds a type defined in a
different package.  The bug was that gccgo tried to create an equality
function for this struct, and it implemented that function by calling
the equality function for the type defined in the other package.
Since that type is not exported, the reference to the equality
function failed at link time.  Normally it is impossible for a struct
to directly contain a member that is an unexported type from another
package, but in this specific case it was possible.  Fixed in gccgo
with https://codereview.appspot.com/183500043 .

Change-Id: I8ec3a33631225b9ac2a4ac060cb4d10b4635e60b
Reviewed-on: https://go-review.googlesource.com/1690
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-22 23:07:10 +00:00
Josh Bleecher Snyder e7173dfdfd test: migrate remaining tests to run.go
* bug248, bug345, bug369, and bug429 were ported from bash commands to run scripts. bug369 remains disabled.
* bug395 is a test for issue 1909, which is still open. It is marked as skip now and will be usable with compile with run.go when issue 1909 is fixed.

Fixes #4139

Updates #1909

Change-Id: Ibb5fbfb5cf72ddc285829245318eeacd3fb5a636
Reviewed-on: https://go-review.googlesource.com/1774
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-22 22:41:34 +00:00
Shenghou Ma c5089a7a81 test/fixedbugs/issue9355: fix build on windows and skip on nacl
Change-Id: If367cc1e8c2d744569513bc71da6e6c454c74e9a
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/1802
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2014-12-19 01:06:33 +00:00
Keith Randall 2fc29a83ae cmd/gc: resolve static addresses of the form &x.f at link time
When we do y = &x for global variables x and y, y gets initialized
at link time.  Do the same for y = &x.f if x is a struct and y=&x[5]
if x is an array.

fixes #9217
fixes #9355

Change-Id: Iea3c0ce2ce1b309e2b760e345608fd95460b5713
Reviewed-on: https://go-review.googlesource.com/1691
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 21:53:03 +00:00
Josh Bleecher Snyder 8e0686a071 test: add missing linkx test
This test was added in CL 151000043.
It got lost in CL 144630044.

Change-Id: I318ab11be8e3e7489fc1395457c029c8bdb2aa41
Reviewed-on: https://go-review.googlesource.com/1773
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-18 17:41:27 +00:00
Ian Lance Taylor 6cd4d59db6 test: add bug494: test case miscompiled by gccgo
Gccgo incorrectly executed functions multiple times when they appeared
in a composite literal that required a conversion between different
interface types.

Change-Id: I7b40e76ed23fa8440ffa03b262041265c109adf7
Reviewed-on: https://go-review.googlesource.com/1710
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
2014-12-18 02:45:00 +00:00
Ian Lance Taylor 60ea2c594b test: add test that gccgo failed to compile
Gccgo failed to create the type descriptor for the type used to
allocate the nil value passed to append as the second argument when
append is called with only one argument.  Calling append with only one
argument is unusual but obviously should not cause a compiler crash.

Change-Id: I530821847dfd68f0302de6ca6a84dfbc79653935
Reviewed-on: https://go-review.googlesource.com/1692
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-12-17 02:22:57 +00:00
Keith Randall 50bc3d5bbc runtime: fix deadlock in runtime.Stack
It shouldn't semacquire() inside an acquirem(), the runtime
thinks that means deadlock.  It actually isn't a deadlock, but it
looks like it because acquirem() does m.locks++.

Candidate for inclusion in 1.4.1.  runtime.Stack with all=true
is pretty unuseable in GOMAXPROCS>1 environment.

fixes #9321

Change-Id: Iac6b664217d24763b9878c20e49229a1ecffc805
Reviewed-on: https://go-review.googlesource.com/1600
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2014-12-16 17:04:45 +00:00
Shenghou Ma e8f13700b7 test/fixedbugs/bug302: fix test on windows.
Change-Id: I74c2578d1620b37a6486eca00a774b9a736a8899
Reviewed-on: https://go-review.googlesource.com/1222
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-09 05:23:35 +00:00
Ian Lance Taylor c5de72b213 test: write Go wrapper code so that bug302 can be run by run.go
Issue #4139.

Change-Id: I50d85a65b22c0cfb4d2a078cee45cf7adb23ba77
Reviewed-on: https://go-review.googlesource.com/1210
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2014-12-09 01:07:27 +00:00
Robert Griesemer 779682107f Fix whitespace (use blanks consistently).
Change-Id: I73ecfe8f1e46e4821dafc6ed5788f48a1f0deeea
Reviewed-on: https://go-review.googlesource.com/1213
Reviewed-by: Alan Donovan <adonovan@google.com>
2014-12-08 22:22:58 +00:00
Keith Randall 212914f573 runtime: test for linear enqueue/dequeue behavior
Make sure dequeueing from a channel queue does not exhibit quadratic time behavior.

Change-Id: Ifb7c709b026f74c7e783610d4914dd92909a441b
Reviewed-on: https://go-review.googlesource.com/1212
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-08 22:18:17 +00:00
Robert Griesemer 8d5fe682b0 test/fibo: a stand-alone bignum/allocation benchmark and test
Usage:
fibo <n>        compute fibonacci(n), n must be >= 0
fibo -bench     benchmark fibonacci computation (takes about 1 min)

Additional flags:
-half           add values using two half-digit additions
-opt            optimize memory allocation through reuse
-short          only print the first 10 digits of very large fibonacci numbers

This change was reviewed in detail as https://codereview.appspot.com/168480043 .

Change-Id: I7c86d49c5508532ea6206d00f424cf2117d2fe41
Reviewed-on: https://go-review.googlesource.com/1211
Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-08 20:57:31 +00:00
Russ Cox 31457cef6d all: merge dev.garbage (d1238958d4ae) into default branch
When we start work on Gerrit, ppc64 and garbage collection
work will continue in the master branch, not the dev branches.

(We may still use dev branches for other things later, but
these are ready to be merged, and doing it now, before moving
to Git means we don't have to have dev branches working
in the Gerrit workflow on day one.)

TBR=rlh
CC=golang-codereviews
https://golang.org/cl/183140043
2014-12-05 20:34:45 -05:00
Russ Cox db40624110 [dev.garbage] runtime: raise StackGuard limit for Windows (again)
640 bytes ought to be enough for anybody.

We'll bring this back down before Go 1.5. That's issue 9214.

TBR=rlh
CC=golang-codereviews
https://golang.org/cl/188730043
2014-12-05 19:50:09 -05:00
Russ Cox 09d92b6bbf all: power64 is now ppc64
Fixes #8654.

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/180600043
2014-12-05 19:13:20 -05:00
Russ Cox b8540fc288 [dev.garbage] all: merge dev.cc (493ad916c3b1) into dev.garbage
TBR=austin
CC=golang-codereviews
https://golang.org/cl/179290043
2014-11-24 12:07:11 -05:00
Russ Cox 50e0749f87 [dev.cc] all: merge default (e4ab8f908aac) into dev.cc
TBR=austin
CC=golang-codereviews
https://golang.org/cl/179040044
2014-11-20 11:48:08 -05:00
Russ Cox b3932baba4 runtime: fix sudog leak
The SudoG used to sit on the stack, so it was cheap to allocated
and didn't need to be cleaned up when finished.

For the conversion to Go, we had to move sudog off the stack
for a few reasons, so we added a cache of recently used sudogs
to keep allocation cheap. But we didn't add any of the necessary
cleanup before adding a SudoG to the new cache, and so the cached
SudoGs had stale pointers inside them that have caused all sorts
of awful, hard to debug problems.

CL 155760043 made sure SudoG.elem is cleaned up.
CL 150520043 made sure SudoG.selectdone is cleaned up.

This CL makes sure SudoG.next, SudoG.prev, and SudoG.waitlink
are cleaned up. I should have done this when I did the other two
fields; instead I wasted a week tracking down a leak they caused.

A dangling SudoG.waitlink can point into a sudogcache list that
has been "forgotten" in order to let the GC collect it, but that
dangling .waitlink keeps the list from being collected.
And then the list holding the SudoG with the dangling waitlink
can find itself in the same situation, and so on. We end up
with lists of lists of unusable SudoGs that are still linked into
the object graph and never collected (given the right mix of
non-trivial selects and non-channel synchronization).

More details in golang.org/issue/9110.

Fixes #9110.

LGTM=r
R=r
CC=dvyukov, golang-codereviews, iant, khr
https://golang.org/cl/177870043
2014-11-16 16:44:45 -05:00
Russ Cox 3e804631d9 [dev.cc] all: merge dev.power64 (7667e41f3ced) into dev.cc
This is to reduce the delta between dev.cc and dev.garbage to just garbage collector changes.

These are the files that had merge conflicts and have been edited by hand:
        malloc.go
        mem_linux.go
        mgc.go
        os1_linux.go
        proc1.go
        panic1.go
        runtime1.go

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/174180043
2014-11-14 12:10:52 -05:00
Russ Cox 9ef4e56108 [dev.garbage] all: merge dev.power64 (7667e41f3ced) into dev.garbage
Now the only difference between dev.cc and dev.garbage
is the runtime conversion on the one side and the
garbage collection on the other. They both have the
same set of changes from default and dev.power64.

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/172570043
2014-11-14 12:09:42 -05:00
Russ Cox 3dcc62e1da [dev.garbage] all: merge default (f38460037b72) into dev.garbage
This is the revision that dev.cc is branched from.

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/169590043
2014-11-14 11:37:54 -05:00
Russ Cox c99616fc67 test: fix nacl build
Disable linkx_run.go and sinit_run.go, because they
exec subprocesses, which NaCl cannot.

TBR=r
CC=golang-codereviews
https://golang.org/cl/171350043
2014-11-09 21:10:49 -05:00
Josh Bleecher Snyder 9b5444420c test: move linkx and sinit to run.go
The remaining run-only tests will be migrated to run.go in another CL.

This CL will break the build due to issues 8746 and 8806.

Update #4139
Update #8746
Update #8806

LGTM=rsc
R=rsc, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/144630044
2014-11-06 15:14:08 -05:00
Russ Cox 75d3f62b3c [dev.garbage] cmd/gc, runtime: add locks around print statements
Now each C printf, Go print, or Go println is guaranteed
not to be interleaved with other calls of those functions.
This should help when debugging concurrent failures.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/169120043
2014-11-05 14:42:54 -05:00
Ian Lance Taylor c6e53fea10 test: comment out failing cases from sinit.go
One failing case this removes is:

var bytes = []byte("hello, world")
var copy_bytes = bytes

We could handle this in the compiler, but it requires special
case for a variable that is initialized to the value of a
variable that is initialized to a string literal converted to
[]byte.  This seems an unlikely case--it never occurs in the
standrd library--and it seems unnecessary to write the code to
handle it.

If we do want to support this case, one approach is
https://golang.org/cl/171840043.

The other failing cases are of the form

var bx bool
var copy_bx = bx

The compiler used to initialize copy_bx to false.  However,
that led to issue 7665, since bx may be initialized in non-Go
code.  The compiler no longer assumes that bx must be false,
so copy_bx can not be statically initialized.

We can fix these with https://golang.org/cl/169040043
if we also pass -complete to the compiler as part of this
test.  This is OK but it's too late in the release cycle.

Fixes #8746.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/165400043
2014-11-04 10:20:35 -08:00
Austin Clements a5e1e1599c [dev.power64] test: "fix" live.go test on power64x
On power64x, this one line in live.go reports that t is live
because of missing optimization passes.  This isn't what this
test is trying to test, so shuffle bad40 so that it still
accomplishes the intent of the test without also depending on
optimization.

LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/167110043
2014-11-03 17:25:36 -05:00
Austin Clements d10a115ef9 [dev.power64] test: disable nilptr3 test on power64x
The remaining failures in this test are because of incomplete
optimization support on power64x.  Tracked in issue 9058.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/168130043
2014-11-03 17:25:03 -05:00
Austin Clements 31b1207fde [dev.power64] all: merge default into dev.power64
Trivial merge except for src/runtime/asm_power64x.s and
src/runtime/signal_power64x.c

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/168950044
2014-11-03 10:53:11 -05:00
Austin Clements 6e86003651 [dev.power64] 9g: fix under-zeroing in clearfat
All three cases of clearfat were wrong on power64x.

The cases that handle 1032 bytes and up and 32 bytes and up
both use MOVDU (one directly generated in a loop and the other
via duffzero), which leaves the pointer register pointing at
the *last written* address.  The generated code was not
accounting for this, so the byte fill loop was re-zeroing the
last zeroed dword, rather than the bytes following the last
zeroed dword.  Fix this by simply adding an additional 8 byte
offset to the byte zeroing loop.

The case that handled under 32 bytes was also wrong.  It
didn't update the pointer register at all, so the byte zeroing
loop was simply re-zeroing the beginning of region.  Again,
the fix is to add an offset to the byte zeroing loop to
account for this.

LGTM=dave, bradfitz
R=rsc, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/168870043
2014-10-31 11:08:27 -04:00
Russ Cox a22c11b995 runtime: fix line number in first stack frame in printed stack trace
Originally traceback was only used for printing the stack
when an unexpected signal came in. In that case, the
initial PC is taken from the signal and should be used
unaltered. For the callers, the PC is the return address,
which might be on the line after the call; we subtract 1
to get to the CALL instruction.

Traceback is now used for a variety of things, and for
almost all of those the initial PC is a return address,
whether from getcallerpc, or gp->sched.pc, or gp->syscallpc.
In those cases, we need to subtract 1 from this initial PC,
but the traceback code had a hard rule "never subtract 1
from the initial PC", left over from the signal handling days.

Change gentraceback to take a flag that specifies whether
we are tracing a trap.

Change traceback to default to "starting with a return PC",
which is the overwhelmingly common case.

Add tracebacktrap, like traceback but starting with a trap PC.

Use tracebacktrap in signal handlers.

Fixes #7690.

LGTM=iant, r
R=r, iant
CC=golang-codereviews
https://golang.org/cl/167810044
2014-10-29 15:14:24 -04:00
Russ Cox 599199fd9f [dev.power64] all: merge default (dd5014ed9b01) into dev.power64
Still passes on amd64.

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/165110043
2014-10-29 11:45:01 -04:00
Russ Cox 6b54cc93d0 cmd/gc: fix internal compiler error in struct compare
Fixes #9006.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/167800043
2014-10-28 23:22:46 -04:00
Russ Cox 0f698be547 test: make maplinear more robust
The test just doubled a certain number of times
and then gave up. On a mostly fast but occasionally
slow machine this may never make the test run
long enough to see the linear growth.

Change test to keep doubling until the first round
takes at least a full second, to reduce the effect of
occasional scheduling or other jitter.

The failure we saw had a time for the first round
of around 100ms.

Note that this test still passes once it sees a linear
effect, even with a very small total time.
The timeout here only applies to how long the execution
must be to support a reported failure.

LGTM=khr
R=khr
CC=golang-codereviews, rlh
https://golang.org/cl/164070043
2014-10-27 18:59:02 -04:00
Austin Clements 5a653089ef [dev.power64] all: merge default into dev.power64
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/164110043
2014-10-27 17:17:06 -04:00
Russ Cox 5225854b74 cmd/gc: synthesize zeroed value for non-assignment context
CL 157910047 introduced code to turn a node representing
a zeroed composite literal into N, the nil Node* pointer
(which represents any zero, not the Go literal nil).

That's great for assignments like x = T{}, but it doesn't work
when T{} is used in a value context like T{}.v or x == T{}.
Fix those.

Should have no effect on performance; confirmed.
The deltas below are noise (compare ns/op):

benchmark                          old ns/op      new ns/op      delta
BenchmarkBinaryTree17              2902919192     2915228424     +0.42%
BenchmarkFannkuch11                2597417605     2630363685     +1.27%
BenchmarkFmtFprintfEmpty           73.7           74.8           +1.49%
BenchmarkFmtFprintfString          196            199            +1.53%
BenchmarkFmtFprintfInt             213            217            +1.88%
BenchmarkFmtFprintfIntInt          336            356            +5.95%
BenchmarkFmtFprintfPrefixedInt     289            294            +1.73%
BenchmarkFmtFprintfFloat           415            416            +0.24%
BenchmarkFmtManyArgs               1281           1271           -0.78%
BenchmarkGobDecode                 10271734       10307978       +0.35%
BenchmarkGobEncode                 8985021        9079442        +1.05%
BenchmarkGzip                      410233227      412266944      +0.50%
BenchmarkGunzip                    102114554      103272443      +1.13%
BenchmarkHTTPClientServer          45297          44993          -0.67%
BenchmarkJSONEncode                19499741       19498489       -0.01%
BenchmarkJSONDecode                76436733       74247497       -2.86%
BenchmarkMandelbrot200             4273814        4307292        +0.78%
BenchmarkGoParse                   4024594        4028937        +0.11%
BenchmarkRegexpMatchEasy0_32       131            135            +3.05%
BenchmarkRegexpMatchEasy0_1K       328            333            +1.52%
BenchmarkRegexpMatchEasy1_32       115            117            +1.74%
BenchmarkRegexpMatchEasy1_1K       931            948            +1.83%
BenchmarkRegexpMatchMedium_32      216            217            +0.46%
BenchmarkRegexpMatchMedium_1K      72669          72857          +0.26%
BenchmarkRegexpMatchHard_32        3818           3809           -0.24%
BenchmarkRegexpMatchHard_1K        121398         121945         +0.45%
BenchmarkRevcomp                   613996550      615145436      +0.19%
BenchmarkTemplate                  93678525       93267391       -0.44%
BenchmarkTimeParse                 414            411            -0.72%
BenchmarkTimeFormat                396            399            +0.76%

Fixes #8947.

LGTM=r
R=r, dave
CC=golang-codereviews
https://golang.org/cl/162130043
2014-10-24 10:27:39 -04:00
Austin Clements f0bd539c59 [dev.power64] all: merge default into dev.power64
This brings dev.power64 up-to-date with the current tip of
default.  go_bootstrap is still panicking with a bad defer
when initializing the runtime (even on amd64).

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/152570049
2014-10-22 15:51:54 -04:00
Austin Clements 2bd616b1a7 build: merge the great pkg/ rename into dev.power64
This also removes pkg/runtime/traceback_lr.c, which was ported
to Go in an earlier commit and then moved to
runtime/traceback.go.

Reviewer: rsc@golang.org
          rsc: LGTM
2014-10-22 13:25:37 -04:00
Austin Clements 3208250185 [dev.power64] build: merge default into dev.power64
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/160200044
2014-10-22 11:21:16 -04:00
Ian Lance Taylor 18051c0860 test: add more cases to recover.go
test16 used to fail with gccgo.  The withoutRecoverRecursive
test would have failed in some possible implementations.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/151630043
2014-10-22 08:06:15 -07:00
Russ Cox 93fcb92257 cmd/gc: disallow call of *T method using **T variable
This brings cmd/gc in line with the spec on this question.
It might break existing code, but that code was not conformant
with the spec.

Credit to Rémy for finding the broken code.

Fixes #6366.

LGTM=r
R=golang-codereviews, r
CC=adonovan, golang-codereviews, gri
https://golang.org/cl/129550043
2014-10-20 22:04:12 -04:00
Daniel Morsing 0edafefc36 cmd/gc: emit code for extern = <N>
https://golang.org/cl/152700045/ made it possible for struct literals assigned to globals to use <N> as the RHS. Normally, this is to zero out variables on first use. Because globals are already zero (or their linker initialized value), we just ignored this.

Now that <N> can occur from non-initialization code, we need to emit this code. We don't use <N> for initialization of globals any more, so this shouldn't cause any excessive zeroing.

Fixes #8961.

LGTM=rsc
R=golang-codereviews, rsc
CC=bradfitz, golang-codereviews
https://golang.org/cl/154540044
2014-10-20 15:59:10 +01:00
Chris Manghane db4dad7fd7 cmd/gc: blank methods are not permitted in interface types
Fixes #6606.

LGTM=rsc
R=rsc
CC=golang-codereviews, gri
https://golang.org/cl/156210044
2014-10-15 09:55:13 -07:00
Chris Manghane fe8f799ef7 cmd/gc: check for initialization cycles in method values
Fixes #7960.

LGTM=rsc
R=rsc
CC=golang-codereviews, gri
https://golang.org/cl/159800045
2014-10-14 19:12:10 -07:00
Chris Manghane d83e43ccc6 test: add test for gccgo-specific issue 8079
LGTM=gri
R=gri
CC=golang-codereviews, iant
https://golang.org/cl/159850044
2014-10-13 12:33:45 -07:00
Evan Kroske 55df81d37f cmd/gc: prohibit short variable declarations containing duplicate symbols
Fixes #6764.
Fixes #8435.

LGTM=rsc
R=golang-codereviews, r, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/116440046
2014-10-06 17:16:39 -04:00
Russ Cox 454d1b0e8b cmd/gc: fix call order in array literal of slice literal of make chan
Fixes #8761.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/144530045
2014-09-30 12:48:47 -04:00
Ian Lance Taylor f6fc14094a cmd/ld: don't automatically mark symbols created by -X as reachable
This fixes the bug in which the linker reports "missing Go
type information" when a -X option refers to a symbol that is
not used.

Fixes #8821.

LGTM=rsc
R=rsc, r
CC=golang-codereviews
https://golang.org/cl/151000043
2014-09-28 08:27:05 -07:00
Russ Cox 870f4e190c cmd/gc: emit error for out-of-bounds slice of constant string
Fixes #7200.

LGTM=gri, iant
R=golang-codereviews, gri, iant
CC=golang-codereviews, r
https://golang.org/cl/150020044
2014-09-25 13:24:43 -04:00
Russ Cox 52e9bcafe1 cmd/gc: print x++ (not x += 1) in errors about x++
Fixes #8311.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/146270043
2014-09-25 13:13:02 -04:00
Russ Cox 53c66543e0 cmd/gc: avoid infinite recursion on invalid recursive type
Fixes #8507.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/144560043
2014-09-25 13:08:37 -04:00
Russ Cox 43c4287b25 cmd/gc: fix import of package with var func returning _
Fixes #8280.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/146240043
2014-09-24 16:53:34 -04:00
Russ Cox 00d2f916ad cmd/gc: run escape analysis always (even in -N mode)
Fixes #8585.
Removes some little-used code paths.

LGTM=josharian
R=golang-codereviews, minux, josharian
CC=golang-codereviews, iant, r
https://golang.org/cl/132970043
2014-09-24 15:20:03 -04:00
Russ Cox 653fb6d872 liblink: make GO_ARGS the default for functions beginning with ·
If there is a leading ·, assume there is a Go prototype and
attach the Go prototype information to the function.
If the function is not called from Go and does not need a
Go prototype, it can be made file-local instead (using name<>(SB)).

This fixes the current BSD build failures, by giving functions like
sync/atomic.StoreUint32 argument stack map information.

Fixes #8753.

LGTM=khr, iant
R=golang-codereviews, iant, khr, bradfitz
CC=golang-codereviews, r, rlh
https://golang.org/cl/142150043
2014-09-16 17:39:55 -04:00
Russ Cox 8d61334dd5 cmd/gc: say 'non-constant array bound' instead of 'invalid array bound'
Fixes #8196.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/141510044
2014-09-16 10:21:54 -04:00
Josh Bleecher Snyder c3dbf56a14 cmd/ld: document that -X overwrites initialized variables
Fixes #7626.

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/144870045
2014-09-15 18:16:45 -07:00
Josh Bleecher Snyder f197988ca5 test: make maplinear iterdelete test less flaky
iterdelete's run time varies; occasionally we get unlucky. To reduce spurious failures, average away some of the variation.

On my machine, 8 of 5000 runs (0.15%) failed before this CL. After this CL, there were no failures after 35,000 runs.

I confirmed that this adjusted test still fails before CL 141270043.

LGTM=khr
R=khr
CC=bradfitz, golang-codereviews
https://golang.org/cl/140610043
2014-09-15 10:56:37 -07:00
Rémy Oudompheng e024ed5ca4 cmd/gc: don't walk static nodes generated by anylit.
During anylit run, nodes such as SLICEARR(statictmp, [:])
may be generated and are expected to be found unchanged by
gen_as_init.

In some walks (in particular walkselect), the statement
may be walked again and lowered to its usual form, leading to a
crash.

Fixes #8017.
Fixes #8024.
Fixes #8058.

LGTM=rsc
R=golang-codereviews, dvyukov, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/112080043
2014-09-15 18:31:47 +02:00
Rémy Oudompheng 8d47b08255 cmd/gc: generate type alg after calling dowidth.
Previously it might happen before calling dowidth and
result in a compiler crash.

Fixes #8060.

LGTM=dvyukov, rsc
R=golang-codereviews, dvyukov, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/110980044
2014-09-15 18:24:16 +02:00
Josh Bleecher Snyder 8cc6cb2f17 test: return errors earlier in run.go
Fixes #8184.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/137510043
2014-09-11 12:47:17 -07:00
Russ Cox fcb4cabba4 cmd/gc: emit write barriers
A write *p = x that needs a write barrier (not all do)
now turns into runtime.writebarrierptr(p, x)
or one of the other variants.

The write barrier implementations are trivial.
The goal here is to emit the calls in the correct places
and to incur the cost of those function calls in the Go 1.4 cycle.

Performance on the Go 1 benchmark suite below.
Remember, the goal is to slow things down (and be correct).

We will look into optimizations in separate CLs, as part of
the process of comparing Go 1.3 against tip in order to make
sure Go 1.4 runs at least as fast as Go 1.3.

benchmark                          old ns/op      new ns/op      delta
BenchmarkBinaryTree17              3118336716     3452876110     +10.73%
BenchmarkFannkuch11                3184497677     3211552284     +0.85%
BenchmarkFmtFprintfEmpty           89.9           107            +19.02%
BenchmarkFmtFprintfString          236            287            +21.61%
BenchmarkFmtFprintfInt             246            278            +13.01%
BenchmarkFmtFprintfIntInt          395            458            +15.95%
BenchmarkFmtFprintfPrefixedInt     343            378            +10.20%
BenchmarkFmtFprintfFloat           477            525            +10.06%
BenchmarkFmtManyArgs               1446           1707           +18.05%
BenchmarkGobDecode                 14398047       14685958       +2.00%
BenchmarkGobEncode                 12557718       12947104       +3.10%
BenchmarkGzip                      453462345      472413285      +4.18%
BenchmarkGunzip                    114226016      115127398      +0.79%
BenchmarkHTTPClientServer          114689         112122         -2.24%
BenchmarkJSONEncode                24914536       26135942       +4.90%
BenchmarkJSONDecode                86832877       103620289      +19.33%
BenchmarkMandelbrot200             4833452        4898780        +1.35%
BenchmarkGoParse                   4317976        4835474        +11.98%
BenchmarkRegexpMatchEasy0_32       150            166            +10.67%
BenchmarkRegexpMatchEasy0_1K       393            402            +2.29%
BenchmarkRegexpMatchEasy1_32       125            142            +13.60%
BenchmarkRegexpMatchEasy1_1K       1010           1236           +22.38%
BenchmarkRegexpMatchMedium_32      232            301            +29.74%
BenchmarkRegexpMatchMedium_1K      76963          102721         +33.47%
BenchmarkRegexpMatchHard_32        3833           5463           +42.53%
BenchmarkRegexpMatchHard_1K        119668         161614         +35.05%
BenchmarkRevcomp                   763449047      706768534      -7.42%
BenchmarkTemplate                  124954724      134834549      +7.91%
BenchmarkTimeParse                 517            511            -1.16%
BenchmarkTimeFormat                501            514            +2.59%

benchmark                         old MB/s     new MB/s     speedup
BenchmarkGobDecode                53.31        52.26        0.98x
BenchmarkGobEncode                61.12        59.28        0.97x
BenchmarkGzip                     42.79        41.08        0.96x
BenchmarkGunzip                   169.88       168.55       0.99x
BenchmarkJSONEncode               77.89        74.25        0.95x
BenchmarkJSONDecode               22.35        18.73        0.84x
BenchmarkGoParse                  13.41        11.98        0.89x
BenchmarkRegexpMatchEasy0_32      213.30       191.72       0.90x
BenchmarkRegexpMatchEasy0_1K      2603.92      2542.74      0.98x
BenchmarkRegexpMatchEasy1_32      254.00       224.93       0.89x
BenchmarkRegexpMatchEasy1_1K      1013.53      827.98       0.82x
BenchmarkRegexpMatchMedium_32     4.30         3.31         0.77x
BenchmarkRegexpMatchMedium_1K     13.30        9.97         0.75x
BenchmarkRegexpMatchHard_32       8.35         5.86         0.70x
BenchmarkRegexpMatchHard_1K       8.56         6.34         0.74x
BenchmarkRevcomp                  332.92       359.62       1.08x
BenchmarkTemplate                 15.53        14.39        0.93x

LGTM=rlh
R=rlh
CC=dvyukov, golang-codereviews, iant, khr, r
https://golang.org/cl/136380043
2014-09-11 12:17:45 -04:00
Keith Randall 689dc60c14 runtime: add timing test for iterate/delete map idiom.
LGTM=bradfitz, iant
R=iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/140510043
2014-09-10 22:54:07 -07:00
Russ Cox 220a6de47e build: adjustments for move from src/pkg to src
This CL adjusts code referring to src/pkg to refer to src.

Immediately after submitting this CL, I will submit
a change doing 'hg mv src/pkg/* src'.
That change will be too large to review with Rietveld
but will contain only the 'hg mv'.

This CL will break the build.
The followup 'hg mv' will fix it.

For more about the move, see golang.org/s/go14nopkg.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/134570043
2014-09-08 00:06:45 -04:00
Russ Cox b6951bcc0b runtime: increase stack split limit again
Increase NOSPLIT reservation from 192 to 384 bytes.
The problem is that the non-Unix systems (Solaris and Windows)
just can't make system calls in a small amount of space,
and then worse they do things that are complex enough
to warrant calling runtime.throw on failure.
We don't have time to rewrite the code to use less stack.

I'm not happy about this, but it's still a small amount.

The good news is that we're doing this to get to only
using copying stacks for stack growth. Once that is true,
we can drop the default stack size from 8k to 4k, which
should more than make up for the bytes we're losing here.

LGTM=r
R=iant, r, bradfitz, aram.h
CC=golang-codereviews
https://golang.org/cl/140350043
2014-09-06 21:16:13 -04:00
Russ Cox 8473695797 runtime: fix panic/wrapper/recover math
The gp->panicwrap adjustment is just fatally flawed.
Now that there is a Panic.argp field, update that instead.
That can be done on entry only, so that unwinding doesn't
need to worry about undoing anything. The wrappers
emit a few more instructions in the prologue but everything
else in the system gets much simpler.

It also fixes (without trying) a broken test I never checked in.

Fixes #7491.

LGTM=khr
R=khr
CC=dvyukov, golang-codereviews, iant, r
https://golang.org/cl/135490044
2014-09-06 13:19:08 -04:00
Russ Cox f8f630f5ec runtime: use reflect.call during panic instead of newstackcall
newstackcall creates a new stack segment, and we want to
be able to throw away all that code.

LGTM=khr
R=khr, iant
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139270043
2014-09-05 16:51:45 -04:00
Keith Randall 8217b4a203 runtime: convert panic/recover to Go
created panic1.go just so diffs were available.
After this CL is in, I'd like to move panic.go -> defer.go
and panic1.go -> panic.go.

LGTM=rsc
R=rsc, khr
CC=golang-codereviews
https://golang.org/cl/133530045
2014-09-05 10:04:16 -04:00
Russ Cox 397bdb216f runtime: increase nosplit area to 192
In CL 131450043, which raised it to 160,
I'd raise it to 192 if necessary.
Apparently it is necessary on windows/amd64.

One note for those concerned about the growth:
in the old segmented stack world, we wasted this much
space at the bottom of every stack segment.
In the new contiguous stack world, each goroutine has
only one stack segment, so we only waste this much space
once per goroutine. So even raising the limit further might
still be a net savings.

Fixes windows/amd64 build.

TBR=r
CC=golang-codereviews
https://golang.org/cl/132480043
2014-08-30 00:56:52 -04:00
Ian Lance Taylor de7fea0d61 test: add test that caused gccgo to crash on valid code
Update #8612

LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/135170043
2014-08-28 19:51:21 -07:00
Russ Cox fe91006a02 runtime: give nosplit functions 32 more bytes of headroom
The Go calling convention uses more stack space than C.
On 64-bit systems we've been right up against the limit
(128 bytes, so only 16 words) and doing awful things to
our source code to work around it. Instead of continuing
to do awful things, raise the limit to 160 bytes.
I am prepared to raise the limit to 192 bytes if necessary,
but I think this will be enough.

Should fix current link-time stack overflow errors on
        - nacl/arm
        - netbsd/amd64
        - openbsd/amd64
        - solaris/amd64
        - windows/amd64

TBR=r
CC=golang-codereviews, iant
https://golang.org/cl/131450043
2014-08-27 14:08:26 -04:00
Russ Cox 613383c765 cmd/gc, runtime: treat slices and strings like pointers in garbage collection
Before, a slice with cap=0 or a string with len=0 might have its
base pointer pointing beyond the actual slice/string data into
the next block. The collector had to ignore slices and strings with
cap=0 in order to avoid misinterpreting the base pointer.

Now, a slice with cap=0 or a string with len=0 still has a base
pointer pointing into the actual slice/string data, no matter what.
The collector can now always scan the pointer, which means
strings and slices are no longer special.

Fixes #8404.

LGTM=khr, josharian
R=josharian, khr, dvyukov
CC=golang-codereviews
https://golang.org/cl/112570044
2014-08-25 14:38:19 -04:00
Russ Cox 20e97677fd cmd/gc: fix order of channel evaluation of receive channels
Normally, an expression of the form x.f or *y can be reordered
with function calls and communications.

Select is stricter than normal: each channel expression is evaluated
in source order. If you have case <-x.f and case <-foo(), then if the
evaluation of x.f causes a panic, foo must not have been called.
(This is in contrast to an expression like x.f + foo().)

Enforce this stricter ordering.

Fixes #8336.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews, r
https://golang.org/cl/126570043
2014-08-25 07:05:45 -04:00
Russ Cox 1806a5732b cmd/gc, runtime: refactor interface inlining decision into compiler
We need to change the interface value representation for
concurrent garbage collection, so that there is no ambiguity
about whether the data word holds a pointer or scalar.

This CL does NOT make any representation changes.

Instead, it removes representation assumptions from
various pieces of code throughout the tree.
The isdirectiface function in cmd/gc/subr.c is now
the only place that decides that policy.
The policy propagates out from there in the reflect
metadata, as a new flag in the internal kind value.

A follow-up CL will change the representation by
changing the isdirectiface function. If that CL causes
problems, it will be easy to roll back.

Update #8405.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews, r
https://golang.org/cl/129090043
2014-08-18 21:13:11 -04:00
Matthew Dempsky 7f40e5e6e5 cmd/gc: disallow pointer constants
Fixes #7760.

LGTM=iant
R=iant, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/130720043
2014-08-15 11:33:31 -07:00
Russ Cox ed68c7df55 [dev.power64] cmd/ld, runtime: detect, fix nosplit overflows
LGTM=minux
R=minux
CC=golang-codereviews
https://golang.org/cl/121690043
2014-08-14 15:29:37 -04:00
Shenghou Ma 80e76e272a [dev.power64] test/nosplit.go: add power64 support
LGTM=rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/125210043
2014-08-14 13:59:58 -04:00
Chris Manghane 897f7a31fa cmd/gc: comma-ok assignments produce untyped bool as 2nd result
LGTM=rsc
R=gri, rsc
CC=golang-codereviews
https://golang.org/cl/127950043
2014-08-11 16:11:55 -07:00
Russ Cox 5b63ce4e19 cmd/6g, cmd/8g: fix, test byte-sized magic multiply
Credit to Rémy for finding and writing test case.

Fixes #8325.

LGTM=r
R=golang-codereviews, r
CC=dave, golang-codereviews, iant, remyoudompheng
https://golang.org/cl/124950043
2014-08-11 15:24:36 -04:00
Ian Lance Taylor f69f45c538 test: add another test case that gccgo crashed on
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/124020044
2014-08-08 10:43:44 -07:00
Alan Donovan 161ba662b1 test/mapnan.go: add regression test for non-empty interfaces.
LGTM=rsc, khr
R=rsc, khr, bradfitz
CC=golang-codereviews
https://golang.org/cl/126720043
2014-08-06 17:02:55 -04:00
Ian Lance Taylor aac1eabcee test: add test for function type in function literal
The gccgo compiler used to fail this test.  This was the root
cause of http://gcc.gnu.org/PR61308 .  The fix for the gccgo
compiler is https://golang.org/cl/122020043 .

LGTM=dave, bradfitz
R=golang-codereviews, dave, bradfitz
CC=golang-codereviews
https://golang.org/cl/121200043
2014-08-04 19:50:49 -07:00
David du Colombier 6d20e72587 test/run: go fmt
LGTM=josharian, r
R=golang-codereviews, josharian, r
CC=golang-codereviews
https://golang.org/cl/120160043
2014-08-01 22:34:36 +02:00
Keith Randall 721c8735df runtime: move built-in print routines to go.
Fixes #8297

LGTM=bradfitz
R=golang-codereviews, bradfitz, khr, dave, dvyukov
CC=golang-codereviews
https://golang.org/cl/119240043
2014-07-31 13:48:48 -07:00
Keith Randall 4aa50434e1 runtime: rewrite malloc in Go.
This change introduces gomallocgc, a Go clone of mallocgc.
Only a few uses have been moved over, so there are still
lots of uses from C. Many of these C uses will be moved
over to Go (e.g. in slice.goc), but probably not all.
What should remain of C's mallocgc is an open question.

LGTM=rsc, dvyukov
R=rsc, khr, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/108840046
2014-07-30 09:01:52 -07:00
David du Colombier 748e5db96d test/run: always set goos and goarch
Following CL 68150047, the goos and goarch
variables are not currently set when the GOOS
and GOARCH environment variables are not set.

This made the content of the build tag to be
ignored in this case.

This CL sets goos and goarch to runtime.GOOS
and runtime.GOARCH when the GOOS and GOARCH
environments variables are not set.

LGTM=aram, bradfitz
R=golang-codereviews, aram, gobot, rsc, dave, bradfitz
CC=golang-codereviews, rsc
https://golang.org/cl/112490043
2014-07-24 23:18:54 +02:00
Ian Lance Taylor 8259b0136e test: avoid "declared but not used" errors in shift1.go
I'm improving gccgo's detection of variables that are only set
but not used, and it triggers additional errors on this code.
The new gccgo errors are correct; gc seems to suppress them
due to the other, expected, errors.  This change uses the
variables so that no compiler will complain.

gccgo change is https://golang.org/cl/119920043 .

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/116050043
2014-07-20 12:25:24 -07:00
Ian Lance Taylor 6eb5eb398b test: add test for confusion with dot imports
The gccgo compiler would fail this test.  The fix for gccgo is
https://golang.org/cl/116960043 .

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/118000043
2014-07-20 10:28:51 -07:00
Dmitriy Vyukov 40d7d5a656 cmd/gc: allocate select descriptor on stack
benchmark                      old ns/op     new ns/op     delta
BenchmarkSelectUncontended     220           165           -25.00%
BenchmarkSelectContended       209           161           -22.97%
BenchmarkSelectProdCons        1042          904           -13.24%

But more importantly this change will allow
to get rid of free function in runtime.

Fixes #6494.

LGTM=rsc, khr
R=golang-codereviews, rsc, dominik.honnef, khr
CC=golang-codereviews, remyoudompheng
https://golang.org/cl/107670043
2014-07-20 15:07:10 +04:00
Ian Lance Taylor e315fac7af test: add some tests for mismatches between call results and uses
LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/111360045
2014-07-19 01:12:42 -07:00
Shenghou Ma 2296928fe7 test: add test for issue8347
Fixes #8347.

LGTM=dave
R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/109600044
2014-07-18 20:59:55 -04:00
Russ Cox 8d504c4e97 cmd/gc: implement 'for range x {'
Fixes #6102.

LGTM=gri
R=ken, r, gri
CC=golang-codereviews
https://golang.org/cl/113120043
2014-07-16 19:27:10 -04:00
Ian Lance Taylor f2b59a3483 test: add test for gccgo comment lexing failure
http://gcc.gnu.org/PR61746

http://code.google.com/p/gofrontend/issues/detail?id=35

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

Fixes #8025.
Fixes #8026.

LGTM=rsc
R=rsc, iant, khr
CC=golang-codereviews
https://golang.org/cl/93570044
2014-07-01 09:20:51 +02:00
Dave Cheney 3e692becfe test/fixedbugs: fix typo in comment
Fix copy paste error pointed out by rsc, https://golang.org/cl/107290043/diff/60001/test/fixedbugs/issue8074.go#newcode7

LGTM=ruiu, r
R=golang-codereviews, ruiu, r
CC=golang-codereviews
https://golang.org/cl/106210047
2014-06-29 20:34:35 +10:00
Russ Cox 2565b5c060 cmd/gc: drop parenthesization restriction for receiver types
Matches CL 101500044.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/110160044
2014-06-25 09:57:48 -04:00
Dave Cheney 5b342f7804 test: add test case for issue 8074.
Fixes #8074.

The issue was not reproduceable by revision

go version devel +e0ad7e329637 Thu Jun 19 22:19:56 2014 -0700 linux/arm

But include the original test case in case the issue reopens itself.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/107290043
2014-06-22 17:33:00 +10:00
Josh Bleecher Snyder 63393faedf test: speed up chan/select5
No functional changes.

Generating shorter functions improves compilation time. On my laptop, this test's running time goes from 5.5s to 1.5s; the wall clock time to run all tests goes down 1s. On Raspberry Pi, this CL cuts 50s off the wall clock time to run all tests.

Fixes #7503.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/72590045
2014-06-17 09:07:18 -07:00
Russ Cox 36207a91d3 runtime: fix defer of nil func
Fixes #8047.

LGTM=r, iant
R=golang-codereviews, r, iant
CC=dvyukov, golang-codereviews, khr
https://golang.org/cl/105140044
2014-06-12 16:34:36 -04:00
Keith Randall aa04caa759 runtime: add test for issue 8047.
Make sure stack copier doesn't barf on a nil defer.
Bug was fixed in https://golang.org/cl/101800043
This change just adds a test.

Fixes #8047

LGTM=dvyukov, rsc
R=dvyukov, rsc
CC=golang-codereviews
https://golang.org/cl/108840043
2014-06-11 20:34:46 -04:00
Russ Cox f20e4d5ecb cmd/gc: fix &result escaping into result
There is a hierarchy of location defined by loop depth:

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

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

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

Fixes #8185.

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

Fixes #8176.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/108860043
2014-06-11 11:48:47 -04:00
Russ Cox 4534fdb144 runtime: fix panic stack during runtime.Goexit during panic
A runtime.Goexit during a panic-invoked deferred call
left the panic stack intact even though all the stack frames
are gone when the goroutine is torn down.
The next goroutine to reuse that struct will have a
bogus panic stack and can cause the traceback routines
to walk into garbage.

Most likely to happen during tests, because t.Fatal might
be called during a deferred func and uses runtime.Goexit.

This "not enough cleared in Goexit" failure mode has
happened to us multiple times now. Clear all the pointers
that don't make sense to keep, not just gp->panic.

Fixes #8158.

LGTM=iant, dvyukov
R=iant, dvyukov
CC=golang-codereviews
https://golang.org/cl/102220043
2014-06-06 16:52:14 -04:00
Russ Cox ac0e12d158 cmd/6g: fix stack zeroing on native client
I am not sure what the rounding here was
trying to do, but it was skipping the first
pointer on native client.

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

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

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

Fixes #8155.

LGTM=r, iant
R=golang-codereviews, r, iant
CC=dvyukov, golang-codereviews, khr
https://golang.org/cl/108740047
2014-06-05 16:40:23 -04:00
Russ Cox fe3c913443 cmd/gc: fix escape analysis of func returning indirect of parameter
I introduced this bug when I changed the escape
analysis to run in phases based on call graph
dependency order, in order to be more precise about
inputs escaping back to outputs (functions returning
their arguments).

Given

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

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

If used as:

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

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

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

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

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

The fix is in two parts.

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

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

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

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

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

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

Fixes #8120.

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

LGTM=dsymonds, bradfitz
R=golang-codereviews, bradfitz
CC=dsymonds, golang-codereviews, iant, khr, r
https://golang.org/cl/96670046
2014-06-02 21:26:32 -04:00
Russ Cox d646040fd1 runtime: fix 1-byte return during x.(T) for 0-byte T
The 1-byte write was silently clearing a byte on the stack.
If there was another function call with more arguments
in the same stack frame, no harm done.
Otherwise, if the variable at that location was already zero,
no harm done.
Otherwise, problems.

Fixes #8139.

LGTM=dsymonds
R=golang-codereviews, dsymonds
CC=golang-codereviews, iant, r
https://golang.org/cl/100940043
2014-06-02 21:06:30 -04:00
Russ Cox bcfe519d58 runtime: fix correctness test at end of traceback
We were requiring that the defer stack and the panic stack
be completely processed, thinking that if any were left over
the stack scan and the defer stack/panic stack must be out
of sync. It turns out that the panic stack may well have
leftover entries in some situations, and that's okay.

Fixes #8132.

LGTM=minux, r
R=golang-codereviews, minux, r
CC=golang-codereviews, iant, khr
https://golang.org/cl/100900044
2014-06-01 13:57:46 -04:00
Russ Cox 14d2ee1d00 runtime: make continuation pc available to stack walk
The 'continuation pc' is where the frame will continue
execution, if anywhere. For a frame that stopped execution
due to a CALL instruction, the continuation pc is immediately
after the CALL. But for a frame that stopped execution due to
a fault, the continuation pc is the pc after the most recent CALL
to deferproc in that frame, or else 0. That is where execution
will continue, if anywhere.

The liveness information is only recorded for CALL instructions.
This change makes sure that we never look for liveness information
except for CALL instructions.

Using a valid PC fixes crashes when a garbage collection or
stack copying tries to process a stack frame that has faulted.

Record continuation pc in heapdump (format change).

Fixes #8048.

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

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

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

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

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

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

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

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

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

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

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

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

Fixes #8036.

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

Description from CL 102820043:

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

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

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

Fixes #8097.

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

Undo this CL for now.

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

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

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

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

Fixes #8097.

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

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

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

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

Fixes #8097.

LGTM=r, khr
R=golang-codereviews, r, khr
CC=golang-codereviews, iant
https://golang.org/cl/102820043
2014-05-28 19:50:19 -04:00
Russ Cox 4895f0dc5e test/run: limit parallelism to 1 for cross-exec builds
This matters for NaCl, which seems to swamp my 4-core MacBook Pro otherwise.
It's not a correctness problem, just a usability problem.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/98600046
2014-05-28 01:01:08 -04:00
Russ Cox d432238fad test: expand issue7863 test
This was sitting in my client but I forgot hg add.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/101800045
2014-05-27 21:53:39 -07:00
Russ Cox 8a2db409c4 cmd/gc: fix race compilation failure 'non-orig name'
CL 51010045 fixed the first one of these:

        cmd/gc: return canonical Node* from temp

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

        Correct this, and watch for it when setting addrtaken.

        Fixes #7083.

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

CL 53200043 fixed the second:

        cmd/gc: fix race build

        Missed this case in CL 51010045.

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

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

Fixes #8028.

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

Fixes #8039.

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

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

Fixes #8073.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/98630045
2014-05-27 21:38:19 -04:00
Brad Fitzpatrick bd401baef2 test: add test for fixed issue 7863
Fixes #7863

LGTM=rsc
R=rsc, ruiu
CC=golang-codereviews
https://golang.org/cl/98610045
2014-05-27 16:01:43 -07:00
Russ Cox cab54408da test: fix two typos in float_lit2.go
Noted by gri in CL 100660044 review but I missed them.

TBR=gri
CC=golang-codereviews
https://golang.org/cl/97570049
2014-05-21 17:19:12 -04:00