1
0
mirror of https://github.com/golang/go synced 2024-09-25 07:30:13 -06:00
Commit Graph

1867 Commits

Author SHA1 Message Date
Rémy Oudompheng
502958ffa6 cmd/gc: do not consider length zero arrays as comparable.
Array values are comparable if values of the array element type
are comparable.

Fixes #6526.

LGTM=khr
R=rsc, bradfitz, khr
CC=golang-codereviews
https://golang.org/cl/58580043
2014-01-31 00:30:56 +01:00
David du Colombier
45893ebdb8 test: skip SIGCHLD test on Plan 9
LGTM=bradfitz
R=jas, mikioh.mikioh, bradfitz
CC=golang-codereviews
https://golang.org/cl/51200045
2014-01-29 09:28:23 +01:00
Dmitriy Vyukov
1fa7029425 runtime: combine small NoScan allocations
Combine NoScan allocations < 16 bytes into a single memory block.
Reduces number of allocations on json/garbage benchmarks by 10+%.

json-1
allocated                 8039872      7949194      -1.13%
allocs                     105774        93776     -11.34%
cputime                 156200000    100700000     -35.53%
gc-pause-one              4908873      3814853     -22.29%
gc-pause-total            2748969      2899288      +5.47%
rss                      52674560     43560960     -17.30%
sys-gc                    3796976      3256304     -14.24%
sys-heap                 43843584     35192832     -19.73%
sys-other                 5589312      5310784      -4.98%
sys-stack                  393216       393216      +0.00%
sys-total                53623088     44153136     -17.66%
time                    156193436    100886714     -35.41%
virtual-mem             256548864    256540672      -0.00%

garbage-1
allocated                 2996885      2932982      -2.13%
allocs                      62904        55200     -12.25%
cputime                  17470000     17400000      -0.40%
gc-pause-one            932757485    925806143      -0.75%
gc-pause-total            4663787      4629030      -0.75%
rss                    1151074304   1133670400      -1.51%
sys-gc                   66068352     65085312      -1.49%
sys-heap               1039728640   1024065536      -1.51%
sys-other                38038208     37485248      -1.45%
sys-stack                 8650752      8781824      +1.52%
sys-total              1152485952   1135417920      -1.48%
time                     17478088     17418005      -0.34%
virtual-mem            1343709184   1324204032      -1.45%

LGTM=iant, bradfitz
R=golang-codereviews, dave, iant, rsc, bradfitz
CC=golang-codereviews, khr
https://golang.org/cl/38750047
2014-01-24 22:35:11 +04:00
Rémy Oudompheng
20137eb4b9 cmd/gc: preserve qualified names of unexported methods in imports.
Fixes #6295.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/20850043
2014-01-21 22:55:50 -05:00
Dominik Honnef
062ae45711 cmd/gc: do not typecheck nil types in multiple assignment
Fixes #6572.

LGTM=rsc, daniel.morsing, rsc
R=golang-codereviews, bradfitz, minux.ma, iant, rsc, gobot, daniel.morsing
CC=golang-codereviews
https://golang.org/cl/14516055
2014-01-21 22:44:54 -05:00
Russ Cox
ca9975a45e cmd/gc: handle non-escaping address-taken variables better
This CL makes the bitmaps a little more precise about variables
that have their address taken but for which the address does not
escape to the heap, so that the variables are kept in the stack frame
rather than allocated on the heap.

The code before this CL handled these variables by treating every
return statement as using every such variable and depending on
liveness analysis to essentially treat the variable as live during the
entire function. That approach has false positives and (worse) false
negatives. That is, it's both sloppy and buggy:

        func f(b1, b2 bool) {	// x live here! (sloppy)
                if b2 {
                        print(0) // x live here! (sloppy)
                        return
                }
                var z **int
                x := new(int)
                *x = 42
                z = &x
                print(**z) // x live here (conservative)
                if b2 {
                        print(1) // x live here (conservative)
                        return
                }
                for {
                        print(**z) // x not live here (buggy)
                }
        }

The first two liveness annotations (marked sloppy) are clearly
wrong: x cannot be live if it has not yet been declared.

The last liveness annotation (marked buggy) is also wrong:
x is live here as *z, but because there is no return statement
reachable from this point in the code, the analysis treats x as dead.

This CL changes the liveness calculation to mark such variables
live exactly at points in the code reachable from the variable
declaration. This keeps the conservative decisions but fixes
the sloppy and buggy ones.

The CL also detects ambiguously live variables, those that are
being marked live but may not actually have been initialized,
such as in this example:

        func f(b1 bool) {
                var z **int
                if b1 {
                        x := new(int)
                        *x = 42
                        z = &x
                } else {
                        y := new(int)
                        *y = 54
                        z = &y
                }
                print(**z) // x, y live here (conservative)
        }

Since the print statement is reachable from the declaration of x,
x must conservatively be marked live. The same goes for y.
Although both x and y are marked live at the print statement,
clearly only one of them has been initialized. They are both
"ambiguously live".

These ambiguously live variables cause problems for garbage
collection: the collector cannot ignore them but also cannot
depend on them to be initialized to valid pointer values.

Ambiguously live variables do not come up too often in real code,
but recent changes to the way map and interface runtime functions
are invoked has created a large number of ambiguously live
compiler-generated temporary variables. The next CL will adjust
the analysis to understand these temporaries better, to make
ambiguously live variables fairly rare.

Once ambiguously live variables are rare enough, another CL will
introduce code at the beginning of a function to zero those
slots on the stack. At that point the garbage collector and the
stack copying routines will be able to depend on the guarantee that
if a slot is marked as live in a liveness bitmap, it is initialized.

R=khr
CC=golang-codereviews, iant
https://golang.org/cl/51810043
2014-01-16 10:32:30 -05:00
Russ Cox
334056a7bc 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
2014-01-14 10:43:13 -05:00
Rémy Oudompheng
f739dae7db cmd/gc: mark OGOTO as a statement for formatters.
Nodes of goto statements were corrupted when written
to export data.

Fixes #7023.

R=rsc, dave, minux.ma
CC=golang-codereviews
https://golang.org/cl/46190043
2014-01-10 01:33:24 +01:00
Rémy Oudompheng
f303921251 cmd/gc: do not omit wrapper for expression (interface{...}).F
Fixes #6723.

R=rsc
CC=golang-codereviews
https://golang.org/cl/41570047
2014-01-07 13:26:48 +01:00
Daniel Morsing
f2e94b58a0 cmd/gc: silence assignment errors to undefined symbols
Fixes #6406.

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/46900043
2014-01-03 21:03:20 +01:00
Martin Olsson
5499034a71 all: fix a few spelling errors in source comments
R=golang-codereviews, dave, iant
CC=golang-codereviews
https://golang.org/cl/45750044
2013-12-27 08:59:02 -08:00
Shenghou Ma
f85ba7d50a cmd/gc: fix comparison order of parameters in mpcmpfltc(a, b)
It should compare a - b to 0, not b - a to 0.
Fixes #6964.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/39020044
2013-12-16 16:54:10 -05:00
Ian Lance Taylor
d270e6f28c test: match gccgo import error messages
Gccgo doesn't have the same equivalent of file name and
package as the gc compiler, so the error messages are
necessarily different.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/40510048
2013-12-12 19:02:11 -08:00
Ian Lance Taylor
5ddc6bd84d test: match gccgo error messages
fixedbugs/issue4510.dir/f2.go:7: error: 'fmt' defined as both imported name and global name
f1.go:7: note: 'fmt' imported here

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/41530044
2013-12-12 17:18:37 -08:00
Ian Lance Taylor
161a45afdf test: match gccgo error messages
const1.go:33: error: integer constant overflow
<similar errors omitted>
const1.go:64: error: division by zero
const1.go:67: error: floating point constant overflow
const1.go:68: error: floating point constant overflow
const1.go:69: error: floating point constant overflow
const1.go:70: error: division by zero
const1.go:71: error: expected integer type
const1.go:77: error: argument 1 has incompatible type (cannot use type int8 as type int)
const1.go:78: error: argument 1 has incompatible type (cannot use type int8 as type int)
const1.go:79: error: argument 1 has incompatible type (cannot use type uint8 as type int)
const1.go:81: error: argument 1 has incompatible type (cannot use type float32 as type int)
const1.go:82: error: argument 1 has incompatible type (cannot use type float64 as type int)
const1.go:83: error: floating point constant truncated to integer
const1.go:85: error: argument 1 has incompatible type (cannot use type float64 as type int)
const1.go:86: error: argument 1 has incompatible type (cannot use type string as type int)
const1.go:87: error: argument 1 has incompatible type (cannot use type bool as type int)
const1.go:90: error: const initializer cannot be nil
const1.go:91: error: expression is not constant
const1.go:92: error: expression is not constant
const1.go:93: error: invalid constant type
const1.go:94: error: invalid constant type
fixedbugs/bug462.go:17: error: unknown field 'os.File' in 'T'
fixedbugs/issue3705.go:9: error: cannot declare init - must be func
fixedbugs/issue4251.go:12: error: inverted slice range
fixedbugs/issue4251.go:16: error: inverted slice range
fixedbugs/issue4251.go:20: error: inverted slice range
fixedbugs/issue4405.go:11: error: invalid character 0x7 in identifier
fixedbugs/issue4405.go:12: error: invalid character 0x8 in identifier
fixedbugs/issue4405.go:13: error: invalid character 0xb in identifier
fixedbugs/issue4405.go:14: error: invalid character 0xc in identifier
fixedbugs/issue4429.go:15: error: expected pointer
fixedbugs/issue4517d.go:9: error: cannot import package as init
fixedbugs/issue4545.go:17: error: invalid context-determined non-integer type for left operand of shift
fixedbugs/issue4545.go:16: error: incompatible types in binary expression
fixedbugs/issue4610.go:15: error: expected ';' or '}' or newline
fixedbugs/issue4610.go:16: error: expected declaration
fixedbugs/issue4654.go:15: error: value computed is not used
<similar errors omitted>
fixedbugs/issue4776.go:9: error: program must start with package clause
fixedbugs/issue4776.go:9: error: expected ';' or newline after package clause
fixedbugs/issue4813.go:31: error: index must be integer
<similar errors omitted>
fixedbugs/issue4847.go:22: error: initialization expression for 'matchAny' depends upon itself
fixedbugs/issue5089.go:13: error: redefinition of 'bufio.Buffered': receiver name changed
fixedbugs/issue5089.go:11: note: previous definition of 'bufio.Buffered' was here
fixedbugs/issue5172.go:17: error: reference to undefined field or method 'bar'
fixedbugs/issue5172.go:18: error: reference to undefined field or method 'bar'
fixedbugs/issue5172.go:12: error: use of undefined type 'bar'
fixedbugs/issue5358.go:16: error: argument 2 has incompatible type
fixedbugs/issue5581.go:29: error: use of undefined type 'Blah'
funcdup.go:10: error: redefinition of 'i'
funcdup.go:10: note: previous definition of 'i' was here
<similar errors omitted>
funcdup2.go:10: error: redefinition of 'i'
funcdup2.go:10: note: previous definition of 'i' was here
<similar errors omitted>
slice3err.go:20: error: middle index required in 3-index slice
<similar errors omitted>
slice3err.go:20: error: final index required in 3-index slice
<similar errors omitted>
slice3err.go:21: error: final index required in 3-index slice
slice3err.go:46: error: invalid 3-index slice of string
<similar errors omitted>
slice3err.go:57: error: inverted slice range
<similar errors omitted>
slice3err.go:62: error: invalid slice index: capacity less than length
slice3err.go:64: error: invalid slice index: capacity less than start
slice3err.go:65: error: invalid slice index: capacity less than start
slice3err.go:66: error: invalid slice index: capacity less than start
slice3err.go:68: error: invalid slice index: capacity less than length
slice3err.go:70: error: invalid slice index: capacity less than start
slice3err.go:80: error: invalid slice index: capacity less than length
slice3err.go:82: error: invalid slice index: capacity less than start
slice3err.go:83: error: invalid slice index: capacity less than start
slice3err.go:84: error: invalid slice index: capacity less than start
slice3err.go:86: error: invalid slice index: capacity less than length
slice3err.go:88: error: invalid slice index: capacity less than start
slice3err.go:99: error: array index out of bounds
<similar errors omitted>
slice3err.go:106: error: invalid slice index: capacity less than length
slice3err.go:107: error: invalid slice index: capacity less than start
slice3err.go:118: error: invalid slice index: capacity less than length
slice3err.go:119: error: invalid slice index: capacity less than start
syntax/semi1.go:10: error: missing '{' after if clause
syntax/semi1.go:10: error: reference to undefined name 'x'
syntax/semi1.go:10: error: reference to undefined name 'y'
syntax/semi1.go:12: error: reference to undefined name 'z'
syntax/semi2.go:10: error: missing '{' after switch clause
syntax/semi2.go:10: error: reference to undefined name 'x'
syntax/semi3.go:10: error: missing '{' after for clause
syntax/semi3.go:10: error: reference to undefined name 'x'
syntax/semi3.go:10: error: reference to undefined name 'y'
syntax/semi3.go:10: error: reference to undefined name 'z'
syntax/semi3.go:12: error: reference to undefined name 'z'
syntax/semi4.go:11: error: missing '{' after for clause
syntax/semi4.go:10: error: reference to undefined name 'x'
syntax/semi4.go:12: error: reference to undefined name 'z'
typecheck.go:12: error: reference to undefined name 'b'
typecheck.go:17: error: reference to undefined name 'c'
typecheck.go:11: error: use of undefined type 'b'
typecheck.go:16: error: not enough arguments
typecheck.go:17: error: not enough arguments

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/41520044
2013-12-12 17:18:12 -08:00
Ian Lance Taylor
936665f641 test: add []rune case to string_lit.go
Gccgo managed to get this case wrong.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/41490044
2013-12-12 17:17:02 -08:00
Ian Lance Taylor
bbf762582f test: adjust issue4618 for gccgo allocation behaviour
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/41550044
2013-12-12 17:14:05 -08:00
Ian Lance Taylor
3ddd2eaebc test: disable large type/stack frame tests for gccgo
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/40370052
2013-12-12 17:13:46 -08:00
Ian Lance Taylor
d12b08d228 test: disable a couple of precise GC tests for gccgo
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/41610043
2013-12-12 17:13:27 -08:00
Ian Lance Taylor
6ae3780503 test: don't rely on order of unrelated imports in bug191
There is no necessary relationship between the imports of the
packages a and b, and gccgo happens to import them in a
different order, leading to different output.  This ordering
is not the purpose of the test in any case.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/40400043
2013-12-10 12:05:37 -08:00
Russ Cox
de8549dfd3 test/run: make -v output look like go test output
Among other things, it makes it easier to scan to
see what is slow.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/40040044
2013-12-10 14:02:42 -05:00
Ian Lance Taylor
9bea6f3b2c test: add some test cases that were miscompiled by gccgo
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/40310043
2013-12-10 10:47:30 -08:00
Carl Shapiro
f574726f16 runtime: check for signed zero in printfloat
Fixes #6899

R=golang-dev, r, cshapiro, iant, rsc
CC=golang-dev
https://golang.org/cl/38120043
2013-12-09 17:51:30 -08:00
dvyukov
b3d400c35e test: revert unintentional commits
I thought I am in a different repo...
2013-11-19 15:36:13 +04:00
dvyukov
aa9d2cb2c7 - 2013-11-19 15:31:01 +04:00
dvyukov
24be1b2b29 13+ 2013-11-19 12:55:12 +04:00
Russ Cox
08a5614597 test/mapnan: use time.Now instead of syscall.Getrusage
Avoids a dependency on a somewhat nonstandard part of package syscall.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/15570046
2013-10-22 18:33:37 -04:00
Alan Donovan
bab2a5416c test: revert changes made for Go SSA interpreter test.
R=r, gri
CC=golang-dev
https://golang.org/cl/14552044
2013-10-08 14:36:20 -04:00
Rémy Oudompheng
8d6bc666fb cmd/gc: qualified embedded fields with owner package.
R=rsc
CC=golang-dev
https://golang.org/cl/14188044
2013-10-02 12:27:33 -04:00
Ian Lance Taylor
4da408f676 test: match gccgo error messages for blank1.go
blank1.go:10:9: error: invalid package name _
blank1.go:17:2: error: cannot use _ as value
blank1.go:18:7: error: cannot use _ as value
blank1.go:20:8: error: invalid use of ‘_’

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/14088044
2013-09-28 15:19:05 -07:00
Ian Lance Taylor
bdafe73ce4 test: recognize gccgo error message in index.go
When a floating point constant is used as an array/slice
index, gccgo prints "error: index must be integer"; gc prints
"constant 2.1 truncated to integer".

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/14044044
2013-09-27 20:38:52 -07:00
Carl Shapiro
1c45f98fa3 test/chan: avoid wrap-around in memstats comparison
The select2.go test assumed that the memory allocated between
its two samplings of runtime.ReadMemStats is strictly
increasing.  To avoid failing the tests when this is not true,
a greater-than check is introduced before computing the
difference in allocated memory.

R=golang-dev, r, cshapiro
CC=golang-dev
https://golang.org/cl/13701046
2013-09-20 17:27:56 -07:00
Russ Cox
8ce9a4fd26 test/run: print command line for running an individual test
Fixes #5087.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/13812043
2013-09-20 15:25:59 -04:00
Russ Cox
5be1821a31 cmd/gc: fix imported and not used error for import .
Fixes issues 6420.

R=ken2
CC=golang-dev
https://golang.org/cl/13703044
2013-09-20 15:25:43 -04:00
Robert Griesemer
81dc0b65b2 test/fixedbugs/bug295.go: fix test in anticipation of future gc fix
See also issue 6428.

R=r, rsc
CC=golang-dev
https://golang.org/cl/13794043
2013-09-20 09:40:56 -07:00
Ian Lance Taylor
1325732ab9 test: add a test that causes gccgo to get a failure at link time
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13788043
2013-09-19 15:20:39 -07:00
Ian Lance Taylor
4182889a09 test: add a test that gccgo failed to compile
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13632057
2013-09-18 16:30:38 -07:00
Ian Lance Taylor
45e214fb62 test: add a test that gccgo failed to compile
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13451045
2013-09-18 15:47:50 -07:00
Alan Donovan
3ddf5a655e test: disable failing tests under ssa/interp.
R=gri
CC=golang-dev
https://golang.org/cl/13471045
2013-09-18 14:44:57 -04:00
Ian Lance Taylor
e27b0cdfc4 test: add a test that crashed gccgo
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13683046
2013-09-17 18:06:58 -07:00
Robert Griesemer
99d87720ad test: avoid future 'declared and not used' error
See also issue 6414.

R=r
CC=golang-dev
https://golang.org/cl/13683044
2013-09-17 15:24:54 -07:00
Russ Cox
aa0439ba65 cmd/gc: eliminate redundant &x.Field nil checks
This eliminates ~75% of the nil checks being emitted,
on all architectures. We can do better, but we need
a bit more general support from the compiler, and
I don't want to do that so close to Go 1.2.
What's here is simple but effective and safe.

A few small code generation cleanups were required
to make the analysis consistent on all systems about
which nil checks are omitted, at least in the test.

Fixes #6019.

R=ken2
CC=golang-dev
https://golang.org/cl/13334052
2013-09-17 16:54:22 -04:00
Russ Cox
51266761fd cmd/gc: fix divide by zero error in compiler
Fixes #6399.

R=ken2
CC=golang-dev
https://golang.org/cl/13253055
2013-09-16 14:22:37 -04:00
Russ Cox
b2794a1c2e runtime: make ARM integer div-by-zero traceback-friendly
The implementation of division in the 5 toolchain is a bit too magical.
Hide the magic from the traceback routines.

Also add a test for the results of the software divide routine.

Fixes #5805.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/13239052
2013-09-16 14:04:45 -04:00
Russ Cox
7276c02b41 runtime, cmd/gc, cmd/ld: ignore method wrappers in recover
Bug #1:

Issue 5406 identified an interesting case:
        defer iface.M()
may end up calling a wrapper that copies an indirect receiver
from the iface value and then calls the real M method. That's
two calls down, not just one, and so recover() == nil always
in the real M method, even during a panic.

[For the purposes of this entire discussion, a wrapper's
implementation is a function containing an ordinary call, not
the optimized tail call form that is somtimes possible. The
tail call does not create a second frame, so it is already
handled correctly.]

Fix this bug by introducing g->panicwrap, which counts the
number of bytes on current stack segment that are due to
wrapper calls that should not count against the recover
check. All wrapper functions must now adjust g->panicwrap up
on entry and back down on exit. This adds slightly to their
expense; on the x86 it is a single instruction at entry and
exit; on the ARM it is three. However, the alternative is to
make a call to recover depend on being able to walk the stack,
which I very much want to avoid. We have enough problems
walking the stack for garbage collection and profiling.
Also, if performance is critical in a specific case, it is already
faster to use a pointer receiver and avoid this kind of wrapper
entirely.

Bug #2:

The old code, which did not consider the possibility of two
calls, already contained a check to see if the call had split
its stack and so the panic-created segment was one behind the
current segment. In the wrapper case, both of the two calls
might split their stacks, so the panic-created segment can be
two behind the current segment.

Fix this by propagating the Stktop.panic flag forward during
stack splits instead of looking backward during recover.

Fixes #5406.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13367052
2013-09-12 14:00:16 -04:00
Rémy Oudompheng
9c21ce54dd cmd/6g: handle very wide offsets.
Fixes #6036.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/12992043
2013-09-09 20:36:19 +02:00
Russ Cox
933d7129c0 cmd/gc: squelch spurious "invalid recursive type" error
R=ken2
CC=golang-dev
https://golang.org/cl/13512047
2013-09-09 13:03:59 -04:00
Russ Cox
903c2fda18 cmd/gc: diagnose '_ = nil' better
Fixes #6004.

R=ken2
CC=golang-dev
https://golang.org/cl/13616044
2013-09-09 12:49:39 -04:00
Russ Cox
8d530f2472 cmd/gc: show package name in 'imported and not used' error
Fixes #5957.

R=ken2
CC=golang-dev
https://golang.org/cl/13250046
2013-09-09 12:21:09 -04:00
Russ Cox
a7d8b35aac cmd/gc: fix 'internal error: typename ideal bool'
Fixes #6298.

R=ken2
CC=golang-dev
https://golang.org/cl/13624043
2013-09-09 12:00:16 -04:00