1
0
mirror of https://github.com/golang/go synced 2024-10-01 16:38:34 -06:00
Commit Graph

1994 Commits

Author SHA1 Message Date
Ian Lance Taylor
8990dc8ca0 test: add test for issue 4468 (go/defer expr may not be parenthesized)
R=gri
CC=golang-dev
https://golang.org/cl/6870053
2012-12-03 18:49:14 -08:00
Rémy Oudompheng
bcea0dd1d0 cmd/gc: fix inlining internal error with T.Method calls.
The compiler was confused when inlining a T.Method(f()) call
where f returns multiple values: support for this was marked
as TODO.

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

Fixes #4167.

R=golang-dev, rsc, lvd
CC=golang-dev
https://golang.org/cl/6871043
2012-12-03 13:39:40 +01:00
Ian Lance Taylor
0304a48595 test: add a test that caused gccgo to crash
R=golang-dev
CC=golang-dev
https://golang.org/cl/6849129
2012-11-30 14:14:51 -08:00
Rémy Oudompheng
f134742f24 cmd/5g, cmd/8g: fix internal error on 64-bit indices statically bounded
Fixes #4448.

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

Fixes #3924.

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

Also enable the stack checker in 8l.

Fixes #4316.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/6855088
2012-11-26 21:51:48 +01:00
Shenghou Ma
7c295f3f0c cmd/gc: fix invalid indirect error at statement level
Fixes #4429.

R=golang-dev, remyoudompheng, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6850097
2012-11-27 01:46:54 +08:00
Ian Lance Taylor
76fa4f430a test: add test for floating point rounding of constants
Failed with gccgo.

R=golang-dev, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6855053
2012-11-26 08:31:15 -08:00
Ian Lance Taylor
be5c445909 test: add bug469, a case where gccgo gaves an incorrect error
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6856084
2012-11-24 16:53:08 -08:00
Rémy Oudompheng
1bd4a7dbcb cmd/8g: fix erroneous LEAL nil.
Fixes #4399.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/6845053
2012-11-21 08:39:45 +01:00
Robert Griesemer
8f3b703323 cmd/gc: complain about invalid whitespace chars
Fixes #4405.

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

Fixes #4207.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6817080
2012-11-12 23:56:11 +01:00
Ian Lance Taylor
3e50372f1f test: change index.go to test size of int, not GOARCH == "amd64"
Fixes the test to work correctly on other platforms with
64-bit ints, like Alpha.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6822099
2012-11-08 15:43:28 -08:00
Russ Cox
761830f481 cmd/gc: fix export of inlined function body with type guard
When exporting a body containing
        x, ok := v.(Type)

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

Fixes #4370.

R=ken2
CC=golang-dev
https://golang.org/cl/6827064
2012-11-08 16:07:05 -05:00
Ian Lance Taylor
6694f14b67 test: run some more tests by default
R=golang-dev, remyoudompheng, iant, rsc
CC=golang-dev
https://golang.org/cl/6833043
2012-11-08 09:04:27 -08:00
Rémy Oudompheng
c208a3a263 cmd/gc: fix internal compiler error with broken structs.
Fixes #4359.

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

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6810090
2012-11-07 21:36:15 +01:00
Ian Lance Taylor
e08008e8c5 test: run index test by default
Running this test via "bash run" uncovered three different
bugs (4344, 4348, 4353).  We need to run it by default.

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

Fixes #4360.

R=ken2
CC=golang-dev, lvd
https://golang.org/cl/6816103
2012-11-07 15:15:21 -05:00
Ian Lance Taylor
f8614a6645 reflect: fix test of whether structs are identical
The old code worked with gc, I assume because the linker
unified identical strings, but it failed with gccgo.

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

        int := "hello"
        j := 2

would normally turn into

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

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

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

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

Fixes #4326.

R=ken2
CC=golang-dev
https://golang.org/cl/6816100
2012-11-07 09:59:19 -05:00
Rémy Oudompheng
1e233ad075 cmd/6g: fix use of large integers as indexes or array sizes.
A check for smallintconst was missing before generating the
comparisons.

Fixes #4348.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6815088
2012-11-06 22:53:57 +01:00
Ian Lance Taylor
433b2f17ee test: fix index.go to pass with recent index checks
The compiler now gives an error for out of bounds constant
indexes for arrays, and for negative constant indexes for both
arrays and slices.

With this change the index.go test passes if CLs 6815085,
6815088, and 6812089 are committed.

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

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

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

Update #4207.

R=dave, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6733055
2012-11-02 07:50:59 +01:00
Rémy Oudompheng
8d95245d0d cmd/gc: fix incomplete export data when inlining with local variables.
When local declarations needed unexported types, these could
be missing in the export data.

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

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

R=rsc, lvd, golang-dev
CC=golang-dev
https://golang.org/cl/6815061
2012-11-01 18:59:32 +01:00
Ian Lance Taylor
7dc1182c27 test: match gccgo error messages for bug358.go
I fixed a bug in gccgo that was causing it to only give an
error for the first package that was imported and not used.

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

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

R=rsc, bradfitz
CC=dave, gobot, golang-dev, iant, rsc
https://golang.org/cl/6741044
2012-10-29 13:38:21 +01:00
Rémy Oudompheng
335eef85c3 cmd/6g: fix crash in cgen_bmul.
Used to print:
../test/torture.go:116: internal compiler error: bad width: 0463 (../test/torture.go:116) MOVB    ,BX (0, 8)

R=nigeltao, rsc
CC=golang-dev
https://golang.org/cl/6736068
2012-10-26 00:29:44 +02:00
Daniel Morsing
48af64b295 cmd/gc: Mark use of builtin functions as calls.
Fixes #4097.

R=rsc
CC=golang-dev, gri
https://golang.org/cl/6749059
2012-10-22 19:14:30 +02:00
Rémy Oudompheng
319131f295 cmd/gc: fix inlining bug for composite literals in if statements.
Fixes #4230.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6640056
2012-10-22 08:38:23 +02:00
Daniel Morsing
d7a3407e3d cmd/gc: fix confusing error when using variable as type.
Fixes #3783.

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

Fixes #4256.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6739048
2012-10-21 19:22:51 +02:00
Rémy Oudompheng
a4682348c2 cmd/gc: don't squash complex literals when inlining.
Since this patch changes the way complex literals are written
in export data, there are a few other glitches.

Fixes #4159.

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

Update #4207.

R=dave, nigeltao, rsc, golang-dev
CC=golang-dev
https://golang.org/cl/6621061
2012-10-16 07:22:33 +02:00
Rémy Oudompheng
dda1b560ec test: convert tests to run.go whenever possible.
The other tests either need a complex procedure
or are architecture- or OS-dependent.

Update #4139.

R=golang-dev, daniel.morsing, iant
CC=golang-dev
https://golang.org/cl/6618062
2012-10-10 22:35:27 +02:00
David Symonds
f8b5838123 testing: change -test.benchtime to a flag.Duration.
Fixes #3902.

R=golang-dev, minux.ma, rsc, r
CC=golang-dev
https://golang.org/cl/6611059
2012-10-09 08:57:29 +11:00
Daniel Morsing
c81293ada7 test: Make run.go's errorcheck behave like testlib.
testlib will complain about any unmatched errors left in errorchecks while run.go will not.

Fixes #4141.

R=golang-dev, minux.ma, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6614060
2012-10-08 16:36:45 +02:00
Rémy Oudompheng
46bce2ac27 test: convert more tests to rundir/compiledir conventions
Update #4139.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6609051
2012-10-07 23:22:01 +02:00
Rémy Oudompheng
5497787d35 test/testlib: don't forget stderr for rundircmpout.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6620071
2012-10-07 23:14:20 +02:00
Rémy Oudompheng
9844e4cd7c test: correct type in declbad.go
The test is not about type mismatches and it causes
an extra error to appear.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6614062
2012-10-07 21:52:57 +02:00
Russ Cox
c4c4b3b467 test/bench/shootout: match gcc architecture to GOARCH
If we're benchmarking 8g, use gcc -m32.
If we're benchmarking 6g, use gcc -m64.

R=golang-dev, bradfitz, minux.ma, remyoudompheng
CC=golang-dev
https://golang.org/cl/6625061
2012-10-07 15:49:56 -04:00
Shenghou Ma
e824656907 test/run.go: use correct executable filename on Windows, fix build
R=golang-dev, daniel.morsing
CC=golang-dev
https://golang.org/cl/6624060
2012-10-08 01:54:56 +08:00
Rémy Oudompheng
d9953c9dde test: use rundir and errorcheckdir for a few more tests.
Update #4139.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6620070
2012-10-07 18:37:05 +02:00
Rémy Oudompheng
892fa3ae6c cmd/gc: replace "typechecking loop" by nicer errors in some cases.
For issue 3757:
BEFORE:  test/fixedbugs/bug463.go:12: typechecking loop involving a
             test/fixedbugs/bug463.go:12 a
             test/fixedbugs/bug463.go:12 <node DCLCONST>
AFTER:   test/fixedbugs/bug463.go:12: constant definition loop
             test/fixedbugs/bug463.go:12: a uses a

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

Fixes #3757.
Fixes #3937.

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

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

The following is a test case:

>>>
package main

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

func main() {
        mine()

        c = mine()
}
<<<

Without this change only the following is caught:

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

with it, we catch all the errors:

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

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

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

Fixes #3890.

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

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

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6619057
2012-10-07 00:29:55 +02:00
Rémy Oudompheng
782464aea5 runtime: fix a panic when growing zero-width-element slices.
Fixes #4197.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6611056
2012-10-06 12:05:52 +02:00
Daniel Morsing
ebb0e5db75 test: Add rundir, rundircmpout and errorcheckdir commands to testlib and run.go
rundir will compile each file in the directory in lexicographic order, link the last file as the main package and run the resulting program. rundircmpout is an related command, that will compare the output of the program to an corresponding .out file

errorcheckdir will compile each file in a directory in lexicographic order, running errorcheck on each file as it compiles. All compilations are assumed to be successful except for the last file. However, If a -0 flag is present on the command, the last compilation will also be assumed successful

This CL also includes a small refactoring of run.go. It was getting unwieldy and the meaning of the run commands was hidden behind argument line formatting.

Fixes #4058.

R=rsc, minux.ma, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/6554071
2012-10-06 09:23:31 +02:00
Rémy Oudompheng
3a4e156ae1 cmd/5g: fix out of registers in nested calls, add compiler torture test.
R=golang-dev, dave, daniel.morsing, rsc
CC=golang-dev, remy
https://golang.org/cl/6586072
2012-10-05 23:30:49 +02:00
Rémy Oudompheng
4bb75cd9ad test/fixedbugs: forgotten test cases for issues 3907 and 4156.
Update #3907.
Update #4156.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6595044
2012-09-30 10:35:09 +02:00
Shenghou Ma
9a3bc51c81 test/fixedbugs/bug454.go: add a test for CL 6564052
Also mention that ignoring second blank identifier of range is required by the spec in the code.

   Fixes #4173.

R=daniel.morsing, remyoudompheng, r
CC=golang-dev
https://golang.org/cl/6594043
2012-09-29 23:23:56 +08:00
Ian Lance Taylor
6ed800c01d test: match gccgo error messages
const1.go:31:12: error: integer constant overflow
const1.go:31:12: error: integer constant overflow
const1.go:33:12: error: integer constant overflow
const1.go:33:12: error: integer constant overflow
const1.go:34:14: error: integer constant overflow
const1.go:35:17: error: integer constant overflow
const1.go:35:17: error: integer constant overflow
const1.go:35:17: error: integer constant overflow
const1.go:35:17: error: integer constant overflow
const1.go:35:17: error: integer constant overflow
const1.go:36:19: error: integer constant overflow
const1.go:37:15: error: integer constant overflow
const1.go:37:15: error: integer constant overflow
const1.go:37:24: error: integer constant overflow
const1.go:37:15: error: integer constant overflow
const1.go:37:15: error: integer constant overflow
const1.go:37:15: error: integer constant overflow
const1.go:37:24: error: integer constant overflow
const1.go:37:15: error: integer constant overflow
const1.go:38:12: error: integer constant overflow
const1.go:38:12: error: integer constant overflow
const1.go:38:12: error: integer constant overflow
const1.go:38:12: error: integer constant overflow
const1.go:41:20: error: integer constant overflow
const1.go:41:20: error: integer constant overflow
const1.go:42:20: error: integer constant overflow
const1.go:42:20: error: integer constant overflow
const1.go:44:28: error: integer constant overflow
const1.go:44:28: error: integer constant overflow
const1.go:45:14: error: integer constant overflow
const1.go:49:14: error: integer constant overflow
const1.go:50:14: error: integer constant overflow
const1.go:51:14: error: integer constant overflow
const1.go:54:23: error: integer constant overflow
const1.go:54:23: error: integer constant overflow
const1.go:54:23: error: integer constant overflow
const1.go:54:23: error: integer constant overflow
const1.go:56:14: error: integer constant overflow
const1.go:57:24: error: integer constant overflow
const1.go:57:24: error: integer constant overflow
const1.go:58:24: error: integer constant overflow
const1.go:58:24: error: integer constant overflow
const1.go:59:22: error: integer constant overflow
const1.go:59:22: error: integer constant overflow
const1.go:61:24: error: integer constant overflow
const1.go:62:20: error: division by zero
const1.go:65:19: error: floating point constant overflow
const1.go:65:19: error: floating point constant overflow
const1.go:66:28: error: floating point constant overflow
const1.go:66:28: error: floating point constant overflow
const1.go:67:19: error: floating point constant overflow
const1.go:67:19: error: floating point constant overflow
const1.go:68:19: error: division by zero
const1.go:33:14: error: integer constant overflow
const1.go:35:19: error: integer constant overflow
const1.go:42:22: error: integer constant overflow
const1.go:53:17: error: integer constant overflow
const1.go:55:14: error: integer constant overflow
const1.go:59:24: error: integer constant overflow
const1.go:69:20: error: expected integer type
const1.go:75:4: error: argument 1 has incompatible type (cannot use type int8 as type int)
const1.go:76:4: error: argument 1 has incompatible type (cannot use type int8 as type int)
const1.go:77:4: error: argument 1 has incompatible type (cannot use type uint8 as type int)
const1.go:79:4: error: argument 1 has incompatible type (cannot use type float32 as type int)
const1.go:80:4: error: argument 1 has incompatible type (cannot use type float64 as type int)
const1.go:81:4: error: floating point constant truncated to integer
const1.go:83:4: error: argument 1 has incompatible type (cannot use type float64 as type int)
const1.go:84:4: error: argument 1 has incompatible type (cannot use type string as type int)
const1.go:85:4: error: argument 1 has incompatible type (cannot use type bool as type int)
const1.go:88:7: error: const initializer cannot be nil

const2.go:14:8: error: expected ‘=’

const5.go:27:7: error: expression is not constant
const5.go:28:7: error: expression is not constant
const5.go:30:7: error: expression is not constant
const5.go:31:7: error: expression is not constant

ddd1.go:57:23: error: invalid use of ‘...’ in type conversion
ddd1.go:59:6: error: invalid use of ‘...’ in type conversion
ddd1.go:60:12: error: use of ‘[...]’ outside of array literal
ddd1.go:21:15: error: argument 1 has incompatible type
ddd1.go:22:10: error: argument 1 has incompatible type
ddd1.go:30:6: error: invalid use of ‘...’ with non-slice
ddd1.go:30:6: error: invalid use of ‘...’ with non-slice
ddd1.go:46:2: error: invalid use of %<...%> with builtin function
ddd1.go:47:2: error: invalid use of %<...%> with builtin function
ddd1.go:49:2: error: invalid use of %<...%> with builtin function
ddd1.go:50:6: error: invalid use of %<...%> with builtin function
ddd1.go:51:6: error: invalid use of %<...%> with builtin function
ddd1.go:53:6: error: invalid use of %<...%> with builtin function
ddd1.go:58:13: error: invalid use of %<...%> with builtin function
ddd1.go:20:10: error: floating point constant truncated to integer
ddd1.go:32:6: error: invalid use of ‘...’ calling non-variadic function

declbad.go:20:3: error: variables redeclared but no variable is new
declbad.go:38:3: error: variables redeclared but no variable is new
declbad.go:44:3: error: variables redeclared but no variable is new
declbad.go:51:3: error: variables redeclared but no variable is new
declbad.go:57:3: error: variables redeclared but no variable is new
declbad.go:63:3: error: variables redeclared but no variable is new
declbad.go:26:3: error: incompatible types in assignment (cannot use type float32 as type int)
declbad.go:32:3: error: incompatible types in assignment (cannot use type int as type float32)
declbad.go:44:3: error: incompatible types in assignment (different number of results)

fixedbugs/bug223.go:21:5: error: initialization expression for ‘m’ depends upon itself

fixedbugs/bug412.go:10:2: error: duplicate field name ‘x’

fixedbugs/bug413.go:11:5: error: initialization expression for ‘i’ depends upon itself

fixedbugs/bug416.go:13:1: error: method ‘X’ redeclares struct field name

fixedbugs/bug435.go:15:49: error: missing ‘)’
fixedbugs/bug435.go:15:2: error: reference to undefined name ‘bar’

fixedbugs/bug451.go:9:9: error: expected package

typeswitch3.go:39:9: error: no new variables on left side of ‘:=’
typeswitch3.go:24:2: error: impossible type switch case (type has no methods)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6560063
2012-09-28 08:30:30 -07:00
Rob Pike
4391abfb1d test/bench/shootout: new data after 64-bit ints for amd64
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6564046
2012-09-25 14:14:26 +10:00
Russ Cox
10ea6519e4 build: make int 64 bits on amd64
The assembly offsets were converted mechanically using
code.google.com/p/rsc/cmd/asmlint. The instruction
changes were done by hand.

Fixes #2188.

R=iant, r, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/6550058
2012-09-24 20:57:01 -04:00
Russ Cox
54af752865 cmd/gc: fix escape analysis bug
Was not handling &x.y[0] and &x.y.z correctly where
y is an array or struct-valued field (not a pointer).

R=ken2
CC=golang-dev
https://golang.org/cl/6551059
2012-09-24 15:53:12 -04:00
Russ Cox
0d82e69811 test: prepare for 64-bit ints
Minor tweaks to avoid assuming that int is always 32 bits.

Update #2188.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6553062
2012-09-24 00:06:41 -04:00
Russ Cox
3cd890dd5a test: minor fixes in run and testlib
Can tell this doesn't get run very often, but it is still important
for when you've broken everything else.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6547065
2012-09-24 00:06:31 -04:00
Russ Cox
cd22afa07b test: expand run.go's errorcheck, make clear which bugs run
Today, if run.go doesn't understand a test header line it just ignores
the test, making it too easy to write or edit tests that are not actually
being run.

- expand errorcheck to accept flags, so that bounds.go and escape*.go can run.
- create a whitelist of skippable tests in run.go; skipping others is an error.
- mark all skipped tests at top of file.

Update #4139.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6549054
2012-09-23 13:16:14 -04:00
Rémy Oudompheng
36df358a30 cmd/6g: fix internal error with SSE registers.
Revision 63f7abcae015 introduced a bug caused by
code assuming registers started at X5, not X0.

Fixes #4138.

R=rsc
CC=golang-dev, remy
https://golang.org/cl/6558043
2012-09-23 18:22:03 +02:00
Russ Cox
05ac300830 cmd/gc: fix use of nil interface, slice
Fixes #3670.

R=ken2
CC=golang-dev
https://golang.org/cl/6542058
2012-09-22 20:42:11 -04:00
Shenghou Ma
674bbafce6 misc/cgo/stdio: make it work on Windows and also test it
use a function to get stdout and stderr, instead of depending
on a specific libc implementation.
also make test/run.go replace \r\n by \n before comparing
output.

        Fixes #2121.
        Part of issue 1741.

R=alex.brainman, rsc, r, remyoudompheng
CC=golang-dev
https://golang.org/cl/5847068
2012-09-20 00:27:23 +08:00
Daniel Morsing
551e263823 cmd/gc: add missing conversion from bool to interface in switches.
In switches without an expression, the compiler would not convert the implicit true to an interface, causing codegen errors.

Fixes #3980.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6497147
2012-09-17 21:29:10 +02:00
Rob Pike
6ce4930365 gc: initial BOM is legal.
Fixes #4040.

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

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

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

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

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

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6498092
2012-09-10 15:35:39 -04:00
Daniel Morsing
1c2021ca14 cmd/gc: Suggest *T in error for x.(T) if it would work.
Accomplished by synchronizing the formatting of conversion errors between typecheck.c and subr.c

Fixes #3984.

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

R=rsc, nigeltao
CC=golang-dev
https://golang.org/cl/6442114
2012-09-01 16:40:54 +02:00
Rémy Oudompheng
ba97d52b85 cmd/gc: fix escape analysis bug with variable capture in loops.
Fixes #3975.

R=rsc, lvd
CC=golang-dev, remy
https://golang.org/cl/6475061
2012-08-31 22:23:37 +02:00
Russ Cox
6d0e3242eb test: restore nigel's bug451 as bug452.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6497066
2012-08-31 15:43:27 -04:00
Daniel Morsing
85ce3c7241 cmd/gc: mark broken type declarations as broken.
This fixes a spurious 'invalid recursive type' error, and stops the compiler from emitting errors on uses of the invalid type.

Fixes #3766.

R=golang-dev, dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6443100
2012-08-31 13:02:29 -04:00
Rob Pike
363ec80dec cmd/gc: string conversion for surrogates
This is required by the spec to produce the replacement char.
The fix lies in lib9's rune code.

R=golang-dev, nigeltao, rsc
CC=golang-dev
https://golang.org/cl/6443109
2012-08-30 11:16:55 -07:00
Rob Pike
d199c34cf0 test/bench/shootout: pidigits is much faster
Also fix a bug in the script (s/runonly/run/)

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6501051
2012-08-28 15:33:05 -07:00
Rémy Oudompheng
a85fa33ece test: use run.go for more tests.
R=golang-dev, alex.brainman, minux.ma
CC=golang-dev
https://golang.org/cl/6443110
2012-08-25 10:16:02 +02:00
Shenghou Ma
e80f6a4de1 cmd/6g: fix float32/64->uint64 conversion
CVTSS2SQ's rounding mode is controlled by the RC field of MXCSR;
as we specifically need truncate semantic, we should use CVTTSS2SQ.

    Fixes #3804.

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

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

Fixes #3835.

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

R=rsc, remyoudompheng, r
CC=golang-dev
https://golang.org/cl/6450163
2012-08-23 16:17:22 +10:00
Alex Brainman
42534cbc29 test: change run.go to ignore \r in compiler output (fixes windows build)
R=golang-dev, dave, minux.ma, remyoudompheng
CC=golang-dev
https://golang.org/cl/6460093
2012-08-16 16:46:59 +10:00
Daniel Morsing
b04c890a89 cmd/gc: Don't claim type assertion would help when it wont.
Fixes #3465.

R=golang-dev, rsc, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/6448097
2012-08-15 16:53:06 -07:00
Rob Pike
c48b77b1b5 all: make Unicode surrogate halves illegal as UTF-8
Surrogate halves are part of UTF-16 and should never appear in UTF-8.
(The rune that two combined halves represent in UTF-16 should
be encoded directly.)

Encoding: encode as RuneError.
Decoding: convert to RuneError, consume one byte.

This requires changing:
        package unicode/utf8
        runtime for range over string
Also added utf8.ValidRune and fixed bug in utf.RuneLen.

Fixes #3927.

R=golang-dev, rsc, bsiegert
CC=golang-dev
https://golang.org/cl/6458099
2012-08-08 14:01:23 -07:00
Shenghou Ma
1e95429c3f misc/cgo/{life,stdio}, test/run.go: use test/run.go to do the cgo tests
Enhances test/run.go to support testing other directories
   Will enable stdio tests on Windows in a follow-up CL.

R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/6220049
2012-08-07 09:38:35 +08:00
Alex Brainman
1df9ee0322 test/run: ignore all but .go file during compiledir action
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6454091
2012-08-06 14:56:39 +10:00
Rémy Oudompheng
823962c521 cmd/8g: fix miscompilation due to BADWIDTH.
Fixes #3899.

R=rsc
CC=golang-dev, remy
https://golang.org/cl/6453084
2012-08-03 22:05:51 +02:00
Rémy Oudompheng
f4f1ba2b1e cmd/gc: accept switches on comparable arrays.
The compiler is incorrectly rejecting switches on arrays of
comparable types. It also doesn't catch incomparable structs
when typechecking the switch, leading to unreadable errors
during typechecking of the generated code.

Fixes #3894.

R=rsc
CC=gobot, golang-dev, r, remy
https://golang.org/cl/6442074
2012-08-03 21:47:26 +02:00
Shenghou Ma
8dbeb0ad07 test/run.go: fix compiledir test on windows
we can't import "./bug0" on windows, as it will trigger
"import path contains invalid character ':'" error.
    instead, we pass "-D." and "-I." to gc to override this
behavior. this idea is due to remyoudompheng.

R=golang-dev, r, alex.brainman, remyoudompheng
CC=golang-dev
https://golang.org/cl/6441074
2012-07-31 23:26:33 -04:00
Shenghou Ma
e07958f7df runtime: round return value address in runtime.equal
Fixes #3866.

R=rsc, r, nigeltao
CC=golang-dev
https://golang.org/cl/6452046
2012-07-31 23:02:46 -04:00
Rémy Oudompheng
b6ea905ed9 cmd/gc: fix inlining bug with receive operator.
The receive operator was given incorrect precedence
resulting in incorrect deletion of parentheses.

Fixes #3843.

R=rsc
CC=golang-dev, remy
https://golang.org/cl/6442049
2012-08-01 00:45:26 +02:00
Rémy Oudompheng
adc9337262 test: add a compiledir pattern in run.go
The compiledir pattern compiles all files xxx.dir/*.go
in lexicographic order (which is assumed to coincide with
the topological order of dependencies).

R=rsc
CC=golang-dev, remy
https://golang.org/cl/6440048
2012-07-30 21:12:05 +02:00
Rémy Oudompheng
6cbf35c172 cmd/gc: fix initialization order involving method calls.
They were previously ignored when deciding order and
detecting dependency loops.
Fixes #3824.

R=rsc, golang-dev
CC=golang-dev, remy
https://golang.org/cl/6455055
2012-07-30 09:14:49 +02:00
Daniel Morsing
dd166b9437 cmd/gc: point "no new variables" error at right line number.
Fixes #3856.

R=dsymonds, rsc
CC=golang-dev
https://golang.org/cl/6455056
2012-07-29 22:24:19 -04:00
Rémy Oudompheng
656b192c16 cmd/gc: reject use of ... with multiple-valued expressions.
Fixes #3334.

R=golang-dev, r
CC=golang-dev, remy
https://golang.org/cl/6350103
2012-07-13 08:05:41 +02:00
Nigel Tao
18e86644a3 cmd/gc: cache itab lookup in convT2I.
There may be further savings if convT2I can avoid the function call
if the cache is good and T is uintptr-shaped, a la convT2E, but that
will be a follow-up CL.

src/pkg/runtime:
benchmark                  old ns/op    new ns/op    delta
BenchmarkConvT2ISmall             43           15  -64.01%
BenchmarkConvT2IUintptr           45           14  -67.48%
BenchmarkConvT2ILarge            130          101  -22.31%

test/bench/go1:
benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    8588997000   8499058000   -1.05%
BenchmarkFannkuch11      5300392000   5358093000   +1.09%
BenchmarkGobDecode         30295580     31040190   +2.46%
BenchmarkGobEncode         18102070     17675650   -2.36%
BenchmarkGzip             774191400    771591400   -0.34%
BenchmarkGunzip           245915100    247464100   +0.63%
BenchmarkJSONEncode       123577000    121423050   -1.74%
BenchmarkJSONDecode       451969800    596256200  +31.92%
BenchmarkMandelbrot200     10060050     10072880   +0.13%
BenchmarkParse             10989840     11037710   +0.44%
BenchmarkRevcomp         1782666000   1716864000   -3.69%
BenchmarkTemplate         798286600    723234400   -9.40%

R=rsc, bradfitz, go.peter.90, daniel.morsing, dave, uriel
CC=golang-dev
https://golang.org/cl/6337058
2012-07-03 09:09:05 +10:00
Shenghou Ma
a732cbb593 cmd/gc: add missing case for OCOM in defaultlit()
Fixes #3765.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6349064
2012-07-02 09:33:22 +08:00
Dmitriy Vyukov
91e56e6486 test: enforce 1 proc in the test
otherwise it fails spuriously with "newfunc allocated unexpectedly" message
when run with GOMAXPROCS>1 (other goroutine allocates).

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6347056
2012-07-01 21:59:50 +04:00
Jan Ziak
13802f5654 test/bench/shootout: remove dependency on C libraries in test mode
Fixes #3732.

R=golang-dev
CC=golang-dev
https://golang.org/cl/6335053
2012-06-24 19:23:09 -04:00
Nigel Tao
8f84328fdc cmd/gc: inline convT2E when T is uintptr-shaped.
GOARCH=amd64 benchmarks

src/pkg/runtime
benchmark                  old ns/op    new ns/op    delta
BenchmarkConvT2ESmall             10           10   +1.00%
BenchmarkConvT2EUintptr            9            0  -92.07%
BenchmarkConvT2EBig               74           74   -0.27%
BenchmarkConvT2I                  27           26   -3.62%
BenchmarkConvI2E                   4            4   -7.05%
BenchmarkConvI2I                  20           19   -2.99%

test/bench/go1
benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    5930908000   5937260000   +0.11%
BenchmarkFannkuch11      3927057000   3933556000   +0.17%
BenchmarkGobDecode         21998090     21870620   -0.58%
BenchmarkGobEncode         12725310     12734480   +0.07%
BenchmarkGzip             567617600    567892800   +0.05%
BenchmarkGunzip           178284100    178706900   +0.24%
BenchmarkJSONEncode        87693550     86794300   -1.03%
BenchmarkJSONDecode       314212600    324115000   +3.15%
BenchmarkMandelbrot200      7016640      7073766   +0.81%
BenchmarkParse              7852100      7892085   +0.51%
BenchmarkRevcomp         1285663000   1286147000   +0.04%
BenchmarkTemplate         566823800    567606200   +0.14%

I'm not entirely sure why the JSON* numbers have changed, but
eyeballing the profile suggests that it could be spending less
and more time in runtime.{new,old}stack, so it could simply be
stack-split boundary noise.

R=rsc, dave, bsiegert, dsymonds
CC=golang-dev
https://golang.org/cl/6280049
2012-06-14 10:43:20 +10:00
Shenghou Ma
97300640ca test/bench/shoutout: fix compliation
-lm must come after the source file, versions of gcc insist this strict order.
On standard compliant systems, we no longer need malloc.h for malloc.
Use pkg-config(1) to get correct glib cflags and libs.
Fix compiler warning in threadring.c and k-nucleotide.c.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6198076
2012-06-08 02:56:23 +08:00
Russ Cox
2a9410c19c cmd/gc: fix LEAQ $0, SI bug
Cannot take effective address of constant.

Fixes #3670.

R=ken2
CC=golang-dev
https://golang.org/cl/6299055
2012-06-07 11:59:18 -04:00
Russ Cox
6363fc5aa6 cmd/gc: fix type checking loop
CL 4313064 fixed its test case but did not address a
general enough problem:

type T1 struct { F *T2 }
type T2 T1
type T3 T2

could still end up copying the definition of T1 for T2
before T1 was done being evaluated, or T3 before T2
was done.

In order to propagate the updates correctly,
record a copy of an incomplete type for re-execution
once the type is completed. Roll back CL 4313064.

Fixes #3709.

R=ken2
CC=golang-dev, lstoakes
https://golang.org/cl/6301059
2012-06-07 03:06:40 -04:00
Russ Cox
744b23fe48 cmd/gc: do not crash on struct with _ field
Fixes #3607.

R=ken2
CC=golang-dev
https://golang.org/cl/6296052
2012-06-07 02:05:08 -04:00
Russ Cox
ee5f59ab4f cmd/gc: preserve side effects during inlining of function with _ argument
Fixes #3593.

R=ken2
CC=golang-dev, lvd
https://golang.org/cl/6305061
2012-06-07 01:54:07 -04:00
Dave Cheney
6423682019 test/bench/go1: add go/parser benchmark
As discussed in

https://groups.google.com/d/msg/golang-dev/Na9XE6mcQyY/zbeBI7R-vnoJ

Here is a static copy of the go/parser benchmark. I ended up using
fancy encodings because the original parser.go had a number of `s
scattered throughout which made it hard to embed the source directly.

Curiously on my laptop this benchmark always scores roughly 10% higher
than the standalone benchmark. This may be down to the generation of
the fasta data set triggering the cpu governor to raise the cpu speed.
However the benchmark is consistent with itself across multiple runs.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6305055
2012-06-07 10:23:45 +10:00
Dave Cheney
166dab6993 test/bench/go1: reduce fasta data size for linux/arm
As discussed on golang-dev, reduce the size of the fasta
dataset to make it possible to run the go1 benchmarks on
small ARM systems.

Also, remove the 25m suffix from fasta data and Revcomp.

linux/arm: pandaboard OMAP4

BenchmarkBinaryTree17          1        70892426000 ns/op
BenchmarkFannkuch11            1        35712066000 ns/op
BenchmarkGobDecode            10         137146000 ns/op           5.60 MB/s
BenchmarkGobEncode            50          64953000 ns/op          11.82 MB/s
BenchmarkGzip          1        5675690000 ns/op           3.42 MB/s
BenchmarkGunzip        1        1207001000 ns/op          16.08 MB/s
BenchmarkJSONEncode            5         860424800 ns/op           2.26 MB/s
BenchmarkJSONDecode            1        3321839000 ns/op           0.58 MB/s
BenchmarkMandelbrot200        50          45893560 ns/op
BenchmarkRevcomp              10         135220300 ns/op          18.80 MB/s
BenchmarkTemplate              1        6385681000 ns/op           0.30 MB/s

R=rsc, minux.ma, dsymonds
CC=golang-dev
https://golang.org/cl/6278048
2012-06-06 07:49:58 +10:00
Rémy Oudompheng
7ab62b0bac test: avoid interface conversion in rotate.go
It is not necessary for the test to be effective and uses a
lot of resources in the compiler. Memory usage is halved and
compilation around 8x faster.

R=golang-dev, r, rsc, r
CC=golang-dev
https://golang.org/cl/6290044
2012-06-04 23:31:31 +02:00
Shenghou Ma
6b4ae1d28e test/bench/go1: fix gzip test
We can't depend on init() order, and certainly we don't want to
register all future benchmarks that use jsonbytes or jsondata to init()
in json_test.go, so we use a more general solution: make generation of
jsonbytes and jsondata their own function so that the compiler will take
care of the order.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6282046
2012-06-05 00:14:39 +08:00
Nigel Tao
947a3ddf87 cmd/gc: recognize u<<1 op u>>31 as a rotate when op is ^, not just |.
R=rsc
CC=golang-dev
https://golang.org/cl/6249071
2012-06-04 20:53:32 +10:00
Rob Pike
6f3ffd4d79 test/bench/shootout: more speedups
Most significant in mandelbrot, from avoiding MOVSD between registers,
but there are others.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6258063
2012-05-30 12:31:28 -07:00
Russ Cox
eb056dbea7 shootout: make mandelbrot.go more like mandelbrot.c
Surprise! The C code is using floating point values for its counters.
Its off the critical path, but the Go code and C code are supposed to
be as similar as possible to make comparisons meaningful.

It doesn't have a significant effect.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6260058
2012-05-30 14:40:59 -04:00
Rob Pike
ec4d213594 test/bench/shootout/timing.log: mandelbrot is restored
R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6259054
2012-05-30 10:35:47 -07:00
Russ Cox
cb9759d067 test/bench/go1: add mandelbrot for floating point
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6244063
2012-05-30 10:26:59 -04:00
Rob Pike
90d59c5861 test/bench/shootout/timing.log: update after recent compiler changes
Moving panic out of line speeds up fannkuch almost a factor of two.
Changes to bitwhacking code affect mandelbrot badly.

R=golang-dev, bradfitz, rsc, r
CC=golang-dev
https://golang.org/cl/6258056
2012-05-29 11:01:50 -07:00
Russ Cox
51072eb1fb cmd/gc: fix parallel assignment in range
for expr1, expr2 = range slice
was assigning to expr1 and expr2 in sequence
instead of in parallel.  Now it assigns in parallel,
as it should.  This matters for things like
for i, x[i] = range slice.

Fixes #3464.

R=ken2
CC=golang-dev
https://golang.org/cl/6252048
2012-05-24 23:05:36 -04:00
Russ Cox
bf18d57d4a runtime: handle and test large map values
This is from CL 5451105 but was dropped from that CL.
See also CL 6137051.

The only change compared to 5451105 is to check for
h != nil in reflect·mapiterinit; allowing use of nil maps
must have happened after that original CL.

Fixes #3573.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/6215078
2012-05-24 22:41:07 -04:00
Russ Cox
c6ce44822c cmd/gc: faster code, mainly for rotate
* Eliminate bounds check on known small shifts.
* Rewrite x<<s | x>>(32-s) as a rotate (constant s).
* More aggressive (but still minimal) range analysis.

R=ken, dave, iant
CC=golang-dev
https://golang.org/cl/6209077
2012-05-24 17:20:07 -04:00
Russ Cox
ce69666273 exp/locale/collate: avoid 16-bit math
There's no need for the 16-bit arithmetic here,
and it tickles a long-standing compiler bug.
Fix the exp code not to use 16-bit math and
create an explicit test for the compiler bug.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6256048
2012-05-24 14:50:36 -04:00
Russ Cox
c44768cb1c cmd/gc: fix small integer bounds check bug
R=ken2
CC=golang-dev
https://golang.org/cl/6254046
2012-05-24 14:01:39 -04:00
Ian Lance Taylor
6f6bbdf9b7 test: add bug439, valid code that caused a gccgo crash
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6198075
2012-05-15 13:29:46 -07:00
Ian Lance Taylor
dc6ec74f07 test/bench/shootout: fix gccgo binary-list-freelist test
R=r
CC=golang-dev
https://golang.org/cl/6202046
2012-05-07 10:14:50 -07:00
Ian Lance Taylor
6c8447d429 test: add bug438, a valid test case that gccgo used to fail to compile
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6196047
2012-05-04 13:14:09 -07:00
Ian Lance Taylor
890be5ced0 test: add bug437, a test that used to fail with gccgo at link time
Updates #3391.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6177045
2012-05-03 14:25:11 -07:00
Ian Lance Taylor
df64448932 test: add bug436, valid code that crashed gccgo
R=golang-dev, bsiegert, rsc
CC=golang-dev
https://golang.org/cl/6158046
2012-05-03 10:33:10 -07:00
Luuk van Dijk
81d9621534 cmd/gc: test for issue 3552
R=rsc
CC=golang-dev
https://golang.org/cl/6128051
2012-05-02 16:56:26 +02:00
Anthony Martin
42aa9abae9 gc: use correct line number for EOF syntax error
I also added some debugging code that's turned
on with -xx.

Fixes #3392.

R=rsc, lvd
CC=golang-dev
https://golang.org/cl/5909058
2012-04-26 02:57:23 -07:00
Ian Lance Taylor
76490cffaf test: add test for order of evaluation of map index on left of =
Gccgo used to get this wrong.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6121044
2012-04-24 10:17:26 -07:00
Ian Lance Taylor
f14a5347e6 test: test handling of negative float constants
This used to panic when compiled by gccgo.

Updates #2876.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6100055
2012-04-23 15:47:34 -07:00
Luuk van Dijk
5583060c4c cmd/gc: fix addresses escaping through closures called in-place.
Fixes #3545.

R=rsc
CC=golang-dev
https://golang.org/cl/6061043
2012-04-23 15:39:01 -04:00
Shenghou Ma
dda6d6aa70 test: use testlib in a few more cases (part 2)
Introduced "runoutput" cmd for running generated program

R=golang-dev, iant, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/5869049
2012-04-20 23:45:43 +08:00
Rob Pike
caedc603d4 test/bench/shootout: update timing.log to Go 1
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5989063
2012-04-10 16:46:06 +10:00
Dmitriy Vyukov
77e1227a02 test/bench/garbage: fix parser benchmark
+add standard bench output to tree2
+print GOMAXPROCS as go test does

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5992044
2012-04-05 20:35:54 +04:00
Ryan Hitchman
8a686792e0 gc: improve error message for composite literals with unexpected newlines
R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/5857045
2012-04-02 11:00:55 -04:00
Ian Lance Taylor
373f1a95b0 test: add some tests of valid code that failed with gccgo
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5971044
2012-03-30 08:42:21 -07:00
Russ Cox
5eb007dede runtime: work around false negative in deadlock detection
Not a complete fix for issue 3342, but fixes the trivial case.
There may still be a race in the instants before and after
a scavenger-induced garbage collection.

Intended to be "obviously safe": a call to runtime·gosched
before main.main is no different than a call to runtime.Gosched
at the beginning of main.main, and it is (or had better be)
safe to call runtime.Gosched at any point during main.

Update #3342.

R=iant
CC=golang-dev
https://golang.org/cl/5919052
2012-03-27 12:22:19 -04:00
Mikio Hara
4c2614c57c undo CL 5844051 / 5d0322034aa8
Breaks closure test when GOMAXPROCS=2 or more.

««« original CL description
runtime: restore deadlock detection in the simplest case.

Fixes #3342.

R=iant, r, dave, rsc
CC=golang-dev, remy
https://golang.org/cl/5844051

»»»

R=rsc
CC=golang-dev
https://golang.org/cl/5924045
2012-03-27 13:05:17 +09:00
Rémy Oudompheng
84bb2547fb runtime: restore deadlock detection in the simplest case.
Fixes #3342.

R=iant, r, dave, rsc
CC=golang-dev, remy
https://golang.org/cl/5844051
2012-03-26 23:06:20 -04:00
Ian Lance Taylor
d12f1ff7ad test: fix run.bash by spelling out the commands to use for bug424.go
R=golang-dev, gri, iant
CC=golang-dev
https://golang.org/cl/5882046
2012-03-22 12:48:41 -07:00
Ian Lance Taylor
47b6197a01 cmd/gc: when expanding append inline, preserve arguments
Fixes #3369.

R=golang-dev, gri, lvd, r
CC=golang-dev
https://golang.org/cl/5876044
2012-03-22 09:44:31 -07:00
Shenghou Ma
e2662835b8 test: use testlib in a few more cases
Introduce a new skip cmd.

R=golang-dev, bradfitz, iant, iant
CC=golang-dev
https://golang.org/cl/5868048
2012-03-22 02:14:44 +08:00
Anthony Martin
e1f22bdcc5 gc: fix struct and array comparisons for new bool rules
The two optimizations for small structs and arrays
were missing the implicit cast from ideal bool.

Fixes #3351.

R=rsc, lvd
CC=golang-dev
https://golang.org/cl/5848062
2012-03-19 15:57:28 -07:00
Russ Cox
c978a5a3a9 test: skip . files in directory
Xcode generates ._foo.go files.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5786055
2012-03-08 14:03:40 -05:00
Russ Cox
d4fb568e04 cmd/gc: implement len(array) / cap(array) rule
The spec is looser than the current implementation.
The spec edit was made in CL 4444050 (May 2011)
but I never implemented it.

Fixes #3244.

R=ken2
CC=golang-dev
https://golang.org/cl/5785049
2012-03-07 22:43:28 -05:00
Shenghou Ma
90010f8f63 build: re-enable some broken tests in run.bash
Updates #2982.

R=rsc, rsc
CC=golang-dev
https://golang.org/cl/5759064
2012-03-08 06:23:56 +08:00
Ian Lance Taylor
b514f0b906 test: enable method expression tests in ddd.go
R=golang-dev, gri, rsc
CC=golang-dev
https://golang.org/cl/5769044
2012-03-07 11:17:26 -08:00
Ian Lance Taylor
72faa0303e test: fix testlib to not pass an empty argument to 6g
This change is necessary to make the run shell script work
again, but it is not sufficient as bug424.go's execution line
does not name the package that it imports.

R=golang-dev, gri, rsc
CC=golang-dev
https://golang.org/cl/5771043
2012-03-07 11:16:58 -08:00
Ian Lance Taylor
e54ad64ff3 test: add inherited interface test to ddd.go
The gccgo compiler incorrectly gave an error for this code.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5767043
2012-03-07 08:24:10 -08:00
Russ Cox
08854b022f test: fix typo
R=ken2
CC=golang-dev
https://golang.org/cl/5752073
2012-03-07 10:21:56 -05:00
Russ Cox
4267974c0b cmd/gc: unnamed struct types can have methods
Fixes #3143.

R=ken2
CC=golang-dev
https://golang.org/cl/5752070
2012-03-07 02:27:15 -05:00
Russ Cox
712473612f test/run: fix builders
Let the outer environment filter down to the commands being run.

TBR=r
CC=golang-dev
https://golang.org/cl/5758066
2012-03-07 02:22:08 -05:00
Russ Cox
987a580b9f cmd/gc: do not confuse unexported methods of same name
Fixes #3146.

R=ken2
CC=golang-dev
https://golang.org/cl/5756074
2012-03-07 01:55:17 -05:00
Russ Cox
105c5fa666 test: invoke go command in run.go
Lets us run multifile tests and tests with arguments.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5753068
2012-03-07 01:54:39 -05:00
Shenghou Ma
47ee98253e test/run: use all available cores on ARM system
R=rsc
CC=golang-dev
https://golang.org/cl/5753054
2012-03-07 12:43:25 +08:00
Rob Pike
905cb4881b all: remove some references to Make.inc etc.
There are a few more but these are the easiest ones.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5756067
2012-03-07 13:51:49 +11:00
Russ Cox
5e41fe0e45 build: use run.go for running tests
Also, tweak run.go to use no more than 2x the
number of CPUs, and only one on ARM.

53.85u 13.33s 53.69r 	 ./run
50.68u 12.13s 18.85r 	 go run run.go

Fixes #2833.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5754047
2012-03-05 22:47:23 -05:00
Ian Lance Taylor
06b7024462 test: match gccgo error messages for bug388.go
As runtime.UintType is no longer defined, the gccgo error
messages have changed.

bug388.go:12:10: error: reference to undefined identifier ‘runtime.UintType’
bug388.go:12:10: error: invalid named/anonymous mix
bug388.go:13:21: error: reference to undefined identifier ‘runtime.UintType’
bug388.go:17:10: error: reference to undefined identifier ‘runtime.UintType’
bug388.go:18:18: error: reference to undefined identifier ‘runtime.UintType’
bug388.go:22:9: error: non-name on left side of ‘:=’
bug388.go:27:10: error: expected type
bug388.go:32:9: error: expected type
bug388.go:23:14: error: reference to field ‘i’ in object which has no fields or methods

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5755044
2012-03-05 16:21:46 -08:00
Russ Cox
6e3a7930eb cmd/gc: if $GOROOT_FINAL is set, rewrite file names in object files
GOROOT_FINAL is a build parameter that means "eventually
the Go tree will be installed here".  Make the file name information
match that eventual location.

Fixes #3180.

R=ken, ken
CC=golang-dev
https://golang.org/cl/5742043
2012-03-05 16:13:33 -05:00
Shenghou Ma
eb5af840d5 test/run.go: fix build
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5727068
2012-03-06 03:34:53 +08:00
Russ Cox
cae604f734 cmd/gc: must not inline panic, recover
R=lvd, gri
CC=golang-dev
https://golang.org/cl/5731061
2012-03-05 13:51:44 -05:00
Ian Lance Taylor
b14a6643dc test: add test of calling recover in a varargs function
gccgo did not handle this correctly.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5714050
2012-03-01 08:24:03 -08:00
Ian Lance Taylor
532c1b451b test: add bug426.go: a gccgo crash on valid code
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5715044
2012-02-29 21:51:21 -08:00
Ian Lance Taylor
f0886ab7e2 test: add a couple of cases to const1.go that crashed gccgo
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5713045
2012-02-29 17:39:02 -08:00
Anthony Martin
564a1f3358 gc: fix string comparisons for new bool rules
The two string comparison optimizations were
missing the implicit cast from ideal bool.

Fixes #3119.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5696071
2012-02-29 13:55:50 -08:00
Russ Cox
d0d251f858 gc: disallow absolute import paths
They are broken and hard to make work.

They have never worked: if you import "/tmp/x"
from "/home/rsc/p.c" then the compiler rewrites
this into import "/home/rsc/tmp/x", which is
clearly wrong.

Also we just disallowed the : character in import
paths, so import "c:/foo" is already not allowed.

Finally, in order to support absolute paths well in
a build tool we'd have to provide a mechanism to
instruct the compiler to resolve absolute imports
by looking in some other tree (where the binaries live)
and provide a mapping from absolute path to location
in that tree.  This CL avoids adding that complexity.

This is not part of the language spec (and should not be),
so no spec change is needed.

If we need to make them work later, we can.

R=ken2
CC=golang-dev
https://golang.org/cl/5712043
2012-02-29 15:28:36 -05:00
Robert Griesemer
69015b6fc4 test: bug424: wrong embedded method called
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5695083
2012-02-27 18:52:40 -08:00
Rob Pike
e303eeb75b go/test/chan1.go: fix typo
Found by Lucio De Re

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5694071
2012-02-25 08:47:04 +11:00
Anthony Martin
dc38756ce1 gc: reject import paths containing special characters
Also allow multiple invalid import statements in a
single file.

Fixes #3021. The changes to go/parser and the
language specifcation have already been committed.

R=rsc, gri
CC=golang-dev
https://golang.org/cl/5672084
2012-02-24 14:48:36 -05:00
Rob Pike
832dcecc99 test/bench/shootout: update post-Makefile
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5696054
2012-02-24 16:59:09 +11:00
Rob Pike
eb37b5b744 test: document ken/*.go
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5694065
2012-02-24 16:24:24 +11:00
Russ Cox
075eef4018 gc: fix escape analysis + inlining + closure bug
R=ken2
CC=golang-dev, lvd
https://golang.org/cl/5693056
2012-02-23 23:09:53 -05:00
Rob Pike
d45ee4cb5f test: fix the fix of the rename tests.
Now they actually test again instead of just setting iota to zero.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5700058
2012-02-24 15:06:32 +11:00
Brad Fitzpatrick
e014cf0e54 test: add cmpout to testlib
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5699060
2012-02-24 13:17:26 +11:00
Brad Fitzpatrick
a55a5c8df3 test: add temporary show_skips flag.
To find test files with legacy headers.

We can remove this flag once everything is converted.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5694060
2012-02-24 12:52:15 +11:00
Rob Pike
80a9783f84 test/[n-z]*.go: add documentation
R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/5700056
2012-02-24 11:48:19 +11:00
Rob Pike
19bab1dc78 test/[n-r]*.go: add documentation
The rename ones needed redoing.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/5698054
2012-02-24 10:30:39 +11:00
Rob Pike
501f0b578f test: commentary for [h-m]*.go
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5674112
2012-02-23 18:47:26 +11:00
Russ Cox
e29d3dfc49 gc: new, less strict bool rules
R=ken2
CC=golang-dev
https://golang.org/cl/5688064
2012-02-22 00:29:37 -05:00
Russ Cox
a457fa500d gc: return of ideal bool
This is a manual undo of CL 5674098.
It does not implement the even less strict spec
that we just agreed on, but it gets us back where
we were at the last weekly.

R=ken2
CC=golang-dev
https://golang.org/cl/5683069
2012-02-21 22:54:07 -05:00
Rémy Oudompheng
fc3797a491 test: use testlib in a few more cases.
R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/5688057
2012-02-22 00:19:59 +01:00
Rémy Oudompheng
9666a959cf test: fix bug423.go to actually fail with older releases.
The supposedly overflowing variable was registerized.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5687061
2012-02-21 07:50:10 +01:00
Rob Pike
b888671f4c test: fix broken test
TBR=bradfitz

R=golang-dev
CC=golang-dev
https://golang.org/cl/5684050
2012-02-21 16:47:42 +11:00
Rémy Oudompheng
f2ad374ae6 cmd/gc: don't believe that variables mentioned 256 times are unused.
Such variables would be put at 0(SP), leading to serious
corruptions at zero initialization.
Fixes #3084.

R=golang-dev, r
CC=golang-dev, remy
https://golang.org/cl/5683052
2012-02-21 16:38:01 +11:00
Brad Fitzpatrick
ce837b308f test: rewrite test/run shell script + errchk (perl) in Go
This doesn't run all ~750 of the tests, but most.

Progress on issue 2833

R=golang-dev, ality, rsc, r, r
CC=golang-dev
https://golang.org/cl/5625044
2012-02-21 14:28:49 +11:00
Rob Pike
f03a5796e3 test/initsyscall.go: delete
It's testing an old property of the language and is no longer relevant.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5676104
2012-02-20 07:44:41 +11:00
Rob Pike
c9b36a87eb test/initcomma.go: restore what it's supposed to be testing
which is trailing commas in literals. They were gofmted away at some point.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5673103
2012-02-20 07:44:24 +11:00
Rob Pike
f5ff5b4fcb test/hashmap.go: delete
It's in an odd style and it's unclear what true purpose it serves as
a test other than to be another Go program.

R=gri
CC=golang-dev
https://golang.org/cl/5674111
2012-02-20 07:43:16 +11:00
Rob Pike
3fb5f329b9 test/chan: document tests
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5677094
2012-02-19 17:44:02 +11:00
Rob Pike
13514d4e0b test/interface: document tests
Most already had comments (yay); adjusted for consistency.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5676102
2012-02-19 17:33:41 +11:00
Brad Fitzpatrick
efacb2a1b4 os: remove Getenverror
Fixes #3065

R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/5675094
2012-02-18 21:18:13 -08:00
Russ Cox
83feedf7bf gc: fix error for floating-point constant %
R=ken2
CC=golang-dev
https://golang.org/cl/5674108
2012-02-19 00:12:31 -05:00
Russ Cox
03f2289f7e runtime: API
Delete Alloc, Free, Lookup, Semacquire, Semrelease

Fixes #2955.

R=golang-dev, r, bradfitz
CC=golang-dev
https://golang.org/cl/5675093
2012-02-19 00:11:44 -05:00
Rob Pike
83976e3ac8 test: explanatory comments [c-g]*
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5656103
2012-02-19 14:28:53 +11:00
Rob Pike
fc0dc04095 test: [a-c]: add introductory comments to tests
Very few of the compiler regression tests include a comment
saying waht they do. Many are obvious, some are anything but.
I've started with a-c in the top directory. More will follow once
we agree on the approach, correctness, and thoroughness here.
zerodivide.go sneaked in too.

R=rsc, r
CC=golang-dev
https://golang.org/cl/5656100
2012-02-19 13:19:43 +11:00
Russ Cox
126d475a43 gc: drop ideal bool
R=golang-dev, ken2
CC=golang-dev
https://golang.org/cl/5674098
2012-02-18 21:07:08 -05:00
Rémy Oudompheng
2ece2f58ee test: use testlib (another bunch).
Apply sed with:

1s,^// $G $D/$F.go && $L $F.$A && ./$A.out || echo.*,// run,
1s,^// $G $D/$F.go || echo.*,// compile,

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5656099
2012-02-18 22:15:42 +01:00
Shenghou Ma
6154f146af test/run: honor $TMPDIR
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5676094
2012-02-18 16:15:12 -05:00
Ian Lance Taylor
292bd04a43 test: change bug040 to use errorcheck
Because bug040.go was ignoring all error messages, the fact
that it got an error about fuction main was being ignored.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5675085
2012-02-17 20:35:40 -08:00
Ian Lance Taylor
f228ed1a90 test: remove a couple of bad tests that duplicate declbad.go
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5673089
2012-02-17 20:35:18 -08:00
Ian Lance Taylor
7737e19b15 test: add some tests that gccgo failed to handle correctly
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5671090
2012-02-17 17:52:05 -08:00
Russ Cox
c4c92ebeb6 cmd/gc: fix comparison of struct with _ field
Fixes #2989.

R=ken2
CC=golang-dev
https://golang.org/cl/5674091
2012-02-17 14:45:29 -05:00
Russ Cox
57eb06fe93 test: use testlib (final 61)
X ,s;^// \$G (\$D/)?\$F\.go *$;// compile;g
X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A *$;// build;g
X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A && \./\$A\.out *$;// run;g
X ,s;^// errchk \$G( -e)? (\$D/)?\$F\.go *$;// errorcheck;g

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5671080
2012-02-16 23:51:04 -05:00
Russ Cox
d2cc988429 test: use testlib (fourth 100)
X ,s;^// \$G (\$D/)?\$F\.go *$;// compile;g
X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A *$;// build;g
X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A && \./\$A\.out *$;// run;g
X ,s;^// errchk \$G( -e)? (\$D/)?\$F\.go *$;// errorcheck;g

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5673079
2012-02-16 23:50:37 -05:00
Russ Cox
8080384a68 test: use testlib (third 100)
X ,s;^// \$G (\$D/)?\$F\.go *$;// compile;g
X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A *$;// build;g
X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A && \./\$A\.out *$;// run;g
X ,s;^// errchk \$G( -e)? (\$D/)?\$F\.go *$;// errorcheck;g

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5656083
2012-02-16 23:49:59 -05:00
Russ Cox
2b1c9b4be2 test: use testlib (second 100)
X ,s;^// \$G (\$D/)?\$F\.go *$;// compile;g
X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A *$;// build;g
X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A && \./\$A\.out *$;// run;g
X ,s;^// errchk \$G( -e)? (\$D/)?\$F\.go *$;// errorcheck;g

R=golang-dev
CC=golang-dev
https://golang.org/cl/5673078
2012-02-16 23:49:30 -05:00
Russ Cox
0b477ef17e test: use testlib (first 100)
X ,s;^// \$G (\$D/)?\$F\.go *$;// compile;g
X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A *$;// build;g
X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A && \./\$A\.out *$;// run;g
X ,s;^// errchk \$G( -e)? (\$D/)?\$F\.go *$;// errorcheck;g

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5656082
2012-02-16 23:48:57 -05:00
Russ Cox
a0c13b9d49 test: add testlib
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5676077
2012-02-16 23:48:24 -05:00
Rob Pike
56069f0333 os: delete os.EINVAL and so on
The set of errors forwarded by the os package varied with system and
was therefore non-portable.
Three helpers added for portable error checking: IsExist, IsNotExist, and IsPermission.
One or two more may need to come, but let's keep the set very small to discourage
thinking about errors that way.

R=mikioh.mikioh, gustavo, r, rsc
CC=golang-dev
https://golang.org/cl/5672047
2012-02-17 10:04:29 +11:00
Rémy Oudompheng
1d3ca9236e cmd/gc: correctly typecheck expression lists in returns.
Invalid return statements were accidentally compiling or
triggering internal errors.
Fixes #3044.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/5673074
2012-02-16 23:42:19 +01:00
Rob Pike
21be71a419 all: errors caught by go vet
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5674069
2012-02-16 17:21:21 +11:00
Rémy Oudompheng
79db6ada48 cmd/gc: error on constant shift overflows.
Fixes #3019.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/5674044
2012-02-16 00:19:42 +01:00
Ian Lance Taylor
aef23cc49e test: add new test of indirect type references
Similar to bug190, but without recursive reference.  Crashed
gccgo.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5672053
2012-02-15 07:39:46 -08:00
Russ Cox
7b848c6964 cmd/dist: cross-compiling fixes
This CL makes it possible to run make.bash with
GOOS and GOARCH set to something other than
the native host GOOS and GOARCH.

As part of the CL, the tool directory moves from bin/tool/
to pkg/tool/goos_goarch where goos and goarch are
the values for the host system (running the build), not
the target.  pkg/ is not technically appropriate, but C objects
are there now tool (pkg/obj/) so this puts all the generated
binaries in one place (rm -rf $GOROOT/pkg cleans everything).
Including goos_goarch in the name allows different systems
to share a single $GOROOT on a shared file system.

Fixes #2920.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5645093
2012-02-13 22:31:51 -05:00
Russ Cox
7dd90621f8 gc: diagnose field+method of same name
Fixes #2828.

R=ken2
CC=golang-dev
https://golang.org/cl/5653065
2012-02-11 01:21:12 -05:00
Russ Cox
337547d1c9 gc: make constant arith errors a little more friendly
Fixes #2804.

R=ken2
CC=golang-dev
https://golang.org/cl/5652067
2012-02-11 00:50:56 -05:00
Russ Cox
77aaa3555d gc: fix import of struct type in struct literal
Fixes #2716.

R=ken2
CC=golang-dev
https://golang.org/cl/5652065
2012-02-11 00:34:01 -05:00
Russ Cox
12fab9d122 gc: add test case for issue 1743
Fixes #1743.
(Actually was fixed earlier, but now we have proof.)

R=ken2
CC=golang-dev
https://golang.org/cl/5649064
2012-02-10 23:20:00 -05:00
Russ Cox
896f0c61c8 gc: diagnose init loop involving func
Fixes #2295.

R=ken2
CC=golang-dev
https://golang.org/cl/5655057
2012-02-10 23:10:45 -05:00
Russ Cox
7ae1fe420e gc: eliminate duplicate ambiguous selector message
Also show actual expression in message when possible.

Fixes #2599.

R=ken2
CC=golang-dev
https://golang.org/cl/5654059
2012-02-10 22:46:56 -05:00
Russ Cox
5340510203 8g: fix opt bug
Was trying to optimize a duplicate float64 move
by registerizing an int64.

Fixes #2588.

R=ken2
CC=golang-dev
https://golang.org/cl/5645086
2012-02-10 22:32:02 -05:00
Russ Cox
ca5da31f83 6g: fix out of registers bug
Fix it twice: reuse registers more aggressively in cgen abop,
and also release R14 and R15, which are no longer m and g.

Fixes #2669.

R=ken2
CC=golang-dev
https://golang.org/cl/5655056
2012-02-10 22:19:34 -05:00
Luuk van Dijk
e0b2ce3401 cmd/gc: suspend safemode during typecheck of inlined bodies.
Should be obviously correct.  Includes minimal test case.
A future CL should clear up the logic around typecheckok and importpkg != nil someday.

R=rsc, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/5652057
2012-02-10 22:50:55 +01:00
Russ Cox
5c52404aca gc: implicit type bug fix in export data
TBR=lvd
CC=golang-dev
https://golang.org/cl/5644064
2012-02-09 00:26:08 -05:00
Jamie Gennis
fff732ea2c 6g,8g: make constant propagation inlining-friendly.
This changes makes constant propagation compare 'from' values using node
pointers rather than symbol names when checking to see whether a set
operation is redundant. When a function is inlined multiple times in a
calling function its arguments will share symbol names even though the values
are different. Prior to this fix the bug409 test would hit a case with 6g
where an LEAQ instruction was incorrectly eliminated from the second inlined
function call. 8g appears to have had the same bug, but the test did not fail
there.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5646044
2012-02-08 10:25:13 -05:00
Rob Pike
c5de9b773f bug408: delete
It's disabled and unreproducible.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5642053
2012-02-08 10:52:54 +11:00
Russ Cox
e3755434b8 5l, 6l, 8l: implement -X flag
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5643050
2012-02-07 16:46:33 -05:00
Russ Cox
2cc58e93d6 test: disable bug408
Fixes #2902.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/5641047
2012-02-07 15:50:26 -05:00
Rémy Oudompheng
0d07600de3 cgo: print line numbers in fatal errors when relevant.
Signatures of fatalf and error_ helpers have been matched for
consistency.
Fixes #1800.

R=rsc
CC=golang-dev, remy
https://golang.org/cl/5593049
2012-02-06 20:38:54 +01:00
Rémy Oudompheng
842c906e2e runtime: delete UpdateMemStats, replace with ReadMemStats(&stats).
Unexports runtime.MemStats and rename MemStatsType to MemStats.
The new accessor requires passing a pointer to a user-allocated
MemStats structure.

Fixes #2572.

R=bradfitz, rsc, bradfitz, gustavo
CC=golang-dev, remy
https://golang.org/cl/5616072
2012-02-06 19:16:26 +01:00
Russ Cox
74ee51ee92 cmd/gc: disallow switch _ := v.(type)
Fixes #2827.

R=ken2
CC=golang-dev
https://golang.org/cl/5638045
2012-02-06 12:35:29 -05:00
Luuk van Dijk
0b9f090861 cmd/gc: another special (%hhS) case for method names.
Fixes #2877

R=rsc
CC=golang-dev
https://golang.org/cl/5637047
2012-02-06 16:38:59 +01:00
Luuk van Dijk
5efd5624cc cmd/gc: fix codegen reordering for expressions involving && and ||
Fixes #2821.

R=rsc
CC=golang-dev
https://golang.org/cl/5606061
2012-02-06 15:41:01 +01:00
Luuk van Dijk
419c53af30 gc: don't print implicit type on struct literal in export
As pointed out in the discussion around 2678.

R=rsc
CC=golang-dev
https://golang.org/cl/5534077
2012-02-06 12:19:59 +01:00
Russ Cox
8290536864 build: use cmd/dist
R=bradfitz, ality, r, r, iant, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/5615058
2012-02-04 00:54:08 -05:00
Ian Lance Taylor
f25a3873b7 test: fix copyright year in new test case
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5631044
2012-02-03 17:36:48 -08:00
Ian Lance Taylor
59e7a0295a test: test method expressions with parameters, and with import
The gccgo compiler had two different bugs triggered by this
test case.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5606052
2012-02-03 16:38:59 -08:00
Russ Cox
3fe3ae7476 test: fix bug headers
The letter is $A, not $O.
($O is set accidentally, but not for long.)

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5629045
2012-02-03 15:22:19 -05:00
Brad Fitzpatrick
040fe32119 test: don't use package main for files without a main function
Part of issue 2833, but works fine with current test runner.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5606056
2012-02-03 11:43:24 -08:00
Ian Lance Taylor
1493bf58f3 test: add test for receiver named _
Was miscompiled by gccgo.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5622054
2012-02-03 07:19:25 -08:00
Ian Lance Taylor
450c955bd9 test: test slice beyond len
When slicing a slice, the bounds may be > len as long as they
are <= cap.  Interestingly, gccgo got that wrong and still
passed the testsuite and all the library tests.

R=golang-dev, rsc, iant
CC=golang-dev
https://golang.org/cl/5622053
2012-02-03 06:29:30 -08:00
Russ Cox
b3750ff52d build: rename $GOROOT/bin/go-tool to $GOROOT/bin/tool.
The go- is redundant now that the directory is required
to be inside $GOROOT.  Rob LGTMed the idea.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5618044
2012-02-02 23:32:41 -05:00
Brad Fitzpatrick
69a5b23dc5 test: make map nan timing test more robust
take 2

R=rsc
CC=golang-dev
https://golang.org/cl/5617045
2012-02-02 11:49:28 -08:00
Ian Lance Taylor
cdabb3d315 test: add import test that caused an incorrect gccgo error
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5622048
2012-02-02 11:04:09 -08:00
Ian Lance Taylor
3692726f32 test: test append with two different named types with same element type
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5615045
2012-02-01 15:24:15 -08:00
Ian Lance Taylor
4e77e0f294 test: test that x := <-c accepts a general expression
The gccgo compiler used to fail to parse this.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5610051
2012-02-01 07:31:00 -08:00
Ian Lance Taylor
f6f83e4938 test: add test which crashed gccgo compiler
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5605046
2012-01-31 16:19:25 -08:00
Russ Cox
33f3afa7af gc: diagnose \ in import path
R=ken2
CC=golang-dev
https://golang.org/cl/5609044
2012-01-31 17:29:59 -05:00
Ian Lance Taylor
2d7495d287 test: float to integer test case
gccgo currently fails this test:

fixedbugs/bug402.go:12:9: error: floating point constant truncated to integer
fixedbugs/bug402.go:13:8: error: floating point constant truncated to integer

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5600050
2012-01-30 21:39:38 -08:00
Russ Cox
2050a9e478 build: remove Make.pkg, Make.tool
Consequently, remove many package Makefiles,
and shorten the few that remain.

gomake becomes 'go tool make'.

Turn off test phases of run.bash that do not work,
flagged with $BROKEN.  Future CLs will restore these,
but this seemed like a big enough CL already.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5601057
2012-01-30 23:43:46 -05:00
Brad Fitzpatrick
0eb647e71c test: attempt at making a test more robust
A current theory is that this test is too fast for the
time resolution on the VMs where our builders run.

R=rsc
CC=golang-dev
https://golang.org/cl/5581056
2012-01-30 20:17:34 -08:00
Rob Pike
91cb3489ab go: move compilers into the go-tool directory
Also delete gotest, since it's messy to fix and slated for deletion anyway.
A couple of things outside src can't be tested any more. "go test" will be
fixed and these tests will be re-enabled. They're noisy for now.

Fixes #284.

R=rsc
CC=golang-dev
https://golang.org/cl/5598049
2012-01-30 14:46:31 -08:00
Russ Cox
6ebf8a6400 test: add test of NaN in map
R=iant, r
CC=golang-dev
https://golang.org/cl/5576071
2012-01-30 13:41:38 -05:00
Rob Pike
ff8133d42e gopack: rename pack, move to go-tool directory
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5598045
2012-01-30 10:30:46 -08:00
Rémy Oudompheng
21f1769519 gc: use original constant expression in error messages.
Fixes #2768.

R=golang-dev, lvd, iant
CC=golang-dev, remy
https://golang.org/cl/5572081
2012-01-29 10:35:11 +01:00
Ian Lance Taylor
d5b7c5157e test: match gccgo error messages
complit1.go:37:34: error: may only omit types within composite literals of slice, array, or map type
complit1.go:38:19: error: may only omit types within composite literals of slice, array, or map type
complit1.go:18:21: error: slice of unaddressable value
complit1.go:19:10: error: slice of unaddressable value
complit1.go:20:9: error: slice of unaddressable value

convert1.go:28:13: error: invalid type conversion
convert1.go:32:12: error: invalid type conversion (cannot use type string as type Tint64)
convert1.go:36:12: error: invalid type conversion
convert1.go:37:13: error: invalid type conversion
convert1.go:40:11: error: invalid type conversion
convert1.go:41:12: error: invalid type conversion
convert1.go:44:12: error: invalid type conversion
convert1.go:46:13: error: invalid type conversion
convert1.go:48:11: error: invalid type conversion
convert1.go:50:12: error: invalid type conversion
convert1.go:52:6: error: invalid type conversion
convert1.go:53:12: error: invalid type conversion
convert1.go:54:12: error: invalid type conversion
convert1.go:56:13: error: invalid type conversion
convert1.go:57:11: error: invalid type conversion
convert1.go:58:11: error: invalid type conversion
convert1.go:64:13: error: invalid type conversion
convert1.go:68:12: error: invalid type conversion (cannot use type Tstring as type Tint64)
convert1.go:72:12: error: invalid type conversion
convert1.go:73:13: error: invalid type conversion
convert1.go:76:11: error: invalid type conversion (cannot use type Tbyte as type Trune)
convert1.go:77:12: error: invalid type conversion (cannot use type Tbyte as type Tint64)
convert1.go:80:12: error: invalid type conversion
convert1.go:82:13: error: invalid type conversion
convert1.go:84:11: error: invalid type conversion (cannot use type Trune as type Tbyte)
convert1.go:86:12: error: invalid type conversion (cannot use type Trune as type Tint64)
convert1.go:88:6: error: invalid type conversion (cannot use type Tint64 as type string)
convert1.go:89:12: error: invalid type conversion
convert1.go:90:12: error: invalid type conversion
convert1.go:92:13: error: invalid type conversion (cannot use type Tint64 as type Tstring)
convert1.go:93:11: error: invalid type conversion (cannot use type Tint64 as type Tbyte)
convert1.go:94:11: error: invalid type conversion (cannot use type Tint64 as type Trune)

fixedbugs/bug195.go:9:21: error: interface contains embedded non-interface
fixedbugs/bug195.go:12:21: error: interface contains embedded non-interface
fixedbugs/bug195.go:15:15: error: interface contains embedded non-interface
fixedbugs/bug195.go:18:2: error: invalid recursive interface
fixedbugs/bug195.go:26:2: error: invalid recursive interface
fixedbugs/bug195.go:22:2: error: invalid recursive interface

fixedbugs/bug251.go:15:2: error: invalid recursive interface
fixedbugs/bug251.go:11:2: error: invalid recursive interface

fixedbugs/bug374.go:18:34: error: use of undefined type ‘xxxx’
fixedbugs/bug374.go:16:5: error: incompatible type in initialization (incompatible type for method ‘m’ (different number of parameters))

fixedbugs/bug383.go:11:2: error: expected boolean expression
fixedbugs/bug383.go:12:2: error: expected boolean expression

fixedbugs/bug386.go:10:25: error: incompatible type for return value 1 (type has no methods)
fixedbugs/bug386.go:12:25: error: incompatible type for return value 1 (type has no methods)

fixedbugs/bug388.go:12:10: error: invalid named/anonymous mix
fixedbugs/bug388.go:17:19: error: non-name on left side of ‘:=’
fixedbugs/bug388.go:22:9: error: non-name on left side of ‘:=’
fixedbugs/bug388.go:27:10: error: expected type
fixedbugs/bug388.go:32:9: error: expected type
fixedbugs/bug388.go:23:14: error: reference to field ‘i’ in object which has no fields or methods
fixedbugs/bug388.go:18:18: error: invalid use of type

fixedbugs/bug389.go:12:5: error: incompatible type in initialization (different parameter types)

fixedbugs/bug390.go:15:24: error: expected integer, floating, or complex type

fixedbugs/bug394.go:10:1: error: expected declaration

fixedbugs/bug397.go:12:2: error: incompatible type for element 2 key in map construction

switch3.go:18:2: error: incompatible types in binary expression
switch3.go:22:2: error: incompatible types in binary expression
switch3.go:28:2: error: map can only be compared to nil
switch3.go:35:2: error: slice can only be compared to nil
switch3.go:42:2: error: func can only be compared to nil

syntax/else.go:11:9: error: expected ‘if’ or ‘{’

typeswitch2.go:15:2: error: duplicate type in switch
typeswitch2.go:19:2: error: duplicate type in switch
typeswitch2.go:26:2: error: duplicate type in switch
typeswitch2.go:40:9: error: ‘t’ declared and not used

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5573073
2012-01-26 23:06:47 -08:00
Russ Cox
408f0b1f74 gc, runtime: handle floating point map keys
Fixes #2609.

R=ken2
CC=golang-dev
https://golang.org/cl/5572069
2012-01-26 16:25:07 -05:00
Russ Cox
ee9bfb023a gc: fix order of evaluation
Pulling function calls out to happen before the
expression being evaluated was causing illegal
reorderings even without inlining; with inlining
it got worse.  This CL adds a separate ordering pass
to move things with a fixed order out of expressions
and into the statement sequence, where they will
not be reordered by walk.

Replaces lvd's CL 5534079.

Fixes #2740.

R=lvd
CC=golang-dev
https://golang.org/cl/5569062
2012-01-25 17:53:50 -05:00
Olivier Duperray
0da89b3964 test: Add the usual Copyright notice.
Fixes #2759.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5570053
2012-01-24 14:48:15 -05:00
Luuk van Dijk
0e919ff2c9 gc: static implements check on typeswitches only applies to concrete case types.
Fixes #2700.

R=rsc
CC=golang-dev
https://golang.org/cl/5574046
2012-01-24 13:53:00 +01:00
Luuk van Dijk
93c4e29605 gc: missed typecheck in subscripting a const string.
Fixes #2674.

R=rsc
CC=golang-dev
https://golang.org/cl/5574045
2012-01-23 16:57:12 +01:00
Luuk van Dijk
5ad9e2db28 gc: handle function calls in arguments to builtin complex operations.
Fixes #2582

R=rsc
CC=golang-dev
https://golang.org/cl/5574044
2012-01-23 16:56:57 +01:00
Russ Cox
427b5bddcd gc: fix recursion loop in interface comparison
iant's idea.

Fixes #2745.

R=iant, dsymonds
CC=golang-dev
https://golang.org/cl/5536085
2012-01-23 09:19:02 -05:00
Ian Lance Taylor
387e7c2742 test: explicitly use variables to avoid gccgo "not used" error
I haven't looked at the source, but the gc compiler appears to
omit "not used" errors when there is an error in the
initializer.  This is harder to do in gccgo, and frankly I
think the "not used" error is still useful even if the
initializer has a problem.  This CL tweaks some tests to avoid
the error, which is not the point of these tests in any case.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5561059
2012-01-22 11:50:45 -08:00
David Symonds
c3eddc4503 gc: test case for recursive interface bug.
R=rsc
CC=golang-dev
https://golang.org/cl/5555066
2012-01-21 17:02:54 +11:00
Russ Cox
290e68b983 gc: undo most of 'fix infinite recursion for embedded interfaces'
Preserve test.

changeset:   11593:f1deaf35e1d1
user:        Luuk van Dijk <lvd@golang.org>
date:        Tue Jan 17 10:00:57 2012 +0100
summary:     gc: fix infinite recursion for embedded interfaces

This is causing 'interface type loop' errors during compilation
of a complex program.  I don't understand what's happening
well enough to boil it down to a simple test case, but undoing
this change fixes the problem.

The change being undone is fixing a corner case (uses of
pointer to interface in an interface definition) that basically
only comes up in erroneous Go programs.  Let's not try to
fix this again until after Go 1.

Unfixes issue 1909.

TBR=lvd
CC=golang-dev
https://golang.org/cl/5555063
2012-01-20 17:14:09 -05:00
Jeff R. Allen
46e7cb57c9 gc: do not try to add a key with incorrect type to a hash
Fixes #2623.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5533043
2012-01-20 13:34:38 -05:00
Ian Lance Taylor
5e77b009d0 test: split golden.out into expected output per test
This will permit gccgo to check test output.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5554056
2012-01-18 16:12:24 -08:00
Ian Lance Taylor
f203093852 test: change several tests to not print
This will make these tests more meaningful for gccgo, which
runs tests in parallel and has no equivalent to golden.out.

Remove ken/simpprint.go since it duplicates helloworld.go.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5536058
2012-01-18 14:31:31 -08:00
Ian Lance Taylor
6b3462820f test: gofmt a few tests
I'm planning to change these tests, but the gofmt changes are
fairly extensive, so I'm separating the gofmt changes from the
substantive changes.

R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/5557052
2012-01-18 13:20:55 -08:00
Luuk van Dijk
6ff01f01f4 gc: fieldnames in structliterals in exported inlines should not be qualified if they're embedded builtin types.
Trust me.
Fixes #2687.

R=rsc
CC=golang-dev
https://golang.org/cl/5545047
2012-01-18 17:51:28 +01:00
Ian Lance Taylor
6a5db20d14 test: match gccgo error messages for bug345
bug345.dir/main.go:25:18: error: argument 1 has incompatible type (need explicit conversion; missing method ‘Write’)
bug345.dir/main.go:27:8: error: argument 1 has incompatible type

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5556043
2012-01-17 18:00:34 -08:00
Ian Lance Taylor
24c76f68ed test: fix bug364 to actually run
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5536044
2012-01-17 18:00:11 -08:00
Rob Pike
7585aa6ae5 utf8.String: move to exp/utf8string.String
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5528115
2012-01-17 14:21:50 -08:00
Luuk van Dijk
9523b4d59c gc: fix infinite recursion for embedded interfaces
Fixes #1909

R=rsc, gri
CC=golang-dev
https://golang.org/cl/5523047
2012-01-17 10:00:57 +01:00
Scott Lawrence
b16f3a2d50 gc: don't fault on return outside function
Fixes #2598.

R=golang-dev, ality, minux.ma, mpimenov, rsc
CC=golang-dev
https://golang.org/cl/5510043
2012-01-16 18:12:25 -05:00
Rémy Oudompheng
6b72b07016 gc: do not compile switch on interface values into a binary search.
Fixes #2672.

R=golang-dev, lvd
CC=golang-dev, remy
https://golang.org/cl/5543058
2012-01-14 17:00:14 +01:00
Rémy Oudompheng
94ff311d1b gc: avoid false positives when using scalar struct fields.
The escape analysis code does not make a distinction between
scalar and pointers fields in structs. Non-pointer fields
that escape should not make the whole struct escape.

R=lvd, rsc
CC=golang-dev, remy
https://golang.org/cl/5489128
2012-01-12 12:08:40 +01:00
Russ Cox
524fb81c41 gc: inlining bug
R=lvd
CC=golang-dev
https://golang.org/cl/5533078
2012-01-11 20:32:02 -05:00
Russ Cox
81728cf06d gc: fix inlining bug
R=lvd
CC=golang-dev
https://golang.org/cl/5532077
2012-01-11 17:25:09 -05:00
Russ Cox
836a517f69 gc: fix inlining bug
Fixes #2682.

R=lvd
CC=golang-dev
https://golang.org/cl/5538043
2012-01-11 13:21:06 -08:00
Luuk van Dijk
feaa9ed10a gc: export nil literals without inferred type.
Fixes #2678

R=rsc
CC=golang-dev
https://golang.org/cl/5529066
2012-01-11 21:26:54 +01:00
Russ Cox
4a6b07f235 gc: enable inlining by default
R=lvd, r
CC=golang-dev
https://golang.org/cl/5531058
2012-01-10 20:08:53 -08:00
Russ Cox
a6d8b483b6 runtime: make garbage collector faster by deleting code
Suggested by Sanjay Ghemawat.  5-20% faster depending
on the benchmark.

Add tree2 garbage benchmark.
Update other garbage benchmarks to build again.

R=golang-dev, r, adg
CC=golang-dev
https://golang.org/cl/5530074
2012-01-10 19:49:11 -08:00
Luuk van Dijk
25cf9bdea6 gc: test that asserts closures are not wrapped when they don't have closure vars.
R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5529060
2012-01-10 21:47:22 +01:00
Luuk van Dijk
a6c49098bc gc: Nicer errors before miscompiling.
This fixes issue 2444.

A big cleanup of all 31/32bit size boundaries i'll leave for another cl though.  (see also issue 1700).

R=rsc
CC=golang-dev
https://golang.org/cl/5484058
2012-01-10 11:19:22 +01:00
Luuk van Dijk
4bcc9c6b5e gc: disallow declaration of variables outside package.
Fixes #2231.

Declaring main.i in package main in the same way already triggers syntax errors.

R=rsc
CC=golang-dev
https://golang.org/cl/5483078
2012-01-10 11:18:56 +01:00
Luuk van Dijk
41806ec26d gc: remove now redundant typecheck of ->ninit on switches.
Fixes #2576.

R=rsc
CC=golang-dev
https://golang.org/cl/5498105
2012-01-09 21:42:24 +01:00
Ryan Hitchman
a15448d65e gc: improve unsafe.Pointer type-check error messages
Fixes #2627.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/5498088
2012-01-06 14:34:16 -08:00
Rob Pike
c50e4f5e2f testing: allow benchmarks to print and fail
Refactors the benchmarks and test code.
Now benchmarks can call Errorf, Fail, etc.,
and the runner will act accordingly.

Because functionality has been folded into an
embedded type, a number of methods' docs
no longer appear in godoc output. A fix is
underway; if it doesn't happen fast enough,
I'll add wrapper methods to restore the
documentation.

R=bradfitz, adg, rsc
CC=golang-dev
https://golang.org/cl/5492060
2011-12-20 09:51:39 -08:00
Maxim Pimenov
bf6dd2db04 various: use $GCFLAGS and $GCIMPORTS like Make does
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5489065
2011-12-16 11:31:39 -05:00
Russ Cox
6e8875551a test/bench/go1: first draft of Go 1 benchmark suite
I have included a few important microbenchmarks,
but the overall intent is to have mostly end-to-end
benchmarks timing real world operations.

The jsondata.go file is a summary of agl's
activity in various open source repositories.
It gets used as test data for many of the benchmarks.

Everything links into one binary (even the test data)
so that it is easy to run the benchmarks on many
computers: there is just one file to copy around.

R=golang-dev, r, bradfitz, adg, r
CC=golang-dev
https://golang.org/cl/5484071
2011-12-15 12:32:59 -05:00
Luuk van Dijk
7e6890a670 gc: inlining, allow empty bodies, fix _ arguments.
R=rsc
CC=golang-dev
https://golang.org/cl/5487077
2011-12-15 17:50:59 +01:00
Luuk van Dijk
5b2f8d96ce gc: omit argument names from function types in error messages
Fixes #2563

R=rsc
CC=golang-dev
https://golang.org/cl/5495047
2011-12-15 17:38:47 +01:00
Luuk van Dijk
9bf3478658 gc: better loopdepth analysis for labels
This avoids degraded performance caused by extra labels
emitted by inlining (breaking strconv ftoa alloc count unittest) and is better in any case.

R=rsc
CC=golang-dev
https://golang.org/cl/5483071
2011-12-15 17:35:59 +01:00
Russ Cox
17264df112 gc: implement and test \r in raw strings
For issue 680.

R=ken2
CC=golang-dev
https://golang.org/cl/5492046
2011-12-15 10:47:09 -05:00
Luuk van Dijk
e14d1d7e41 gc: use inferred type rather than original one when reporting non-assignability.
Fixes #2451

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5372105
2011-12-14 17:34:35 +01:00
Luuk van Dijk
1f6d130b14 gc: add forgotten typecheck in a lonely corner of sinit
Fixes #2549

R=rsc
CC=golang-dev
https://golang.org/cl/5484060
2011-12-14 15:54:10 +01:00
Luuk van Dijk
3c638f2892 gc: Use %#F in error messages instead of %F.
Fixes #2520

R=rsc
CC=golang-dev
https://golang.org/cl/5482056
2011-12-14 08:22:36 +01:00
Luuk van Dijk
6a401339c1 gc: suppress non-root cause message for bad receivers.
Fixed issue 2500

R=rsc
CC=golang-dev
https://golang.org/cl/5485053
2011-12-14 08:21:37 +01:00
Russ Cox
5fe96c640a test/garbage: move to test/bench/garbage
(These are benchmarks for the garbage collector, not tests.)

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5484070
2011-12-13 18:02:49 -05:00
Russ Cox
1161e1172b fix build, sorry
TBR=r
CC=golang-dev
https://golang.org/cl/5488066
2011-12-13 17:53:00 -05:00
Russ Cox
bcbb2f93ee test/bench: move to test/bench/shootout
R=golang-dev, r, gri, bradfitz
CC=golang-dev
https://golang.org/cl/5487067
2011-12-13 17:46:54 -05:00
Luuk van Dijk
e1b1a5fea2 gc: fix use of stackallocated AST node in generation of static initialisation code.
Fixes #2529

R=rsc, rogpeppe
CC=golang-dev
https://golang.org/cl/5483048
2011-12-13 09:09:10 +01:00
Russ Cox
196b663075 gc: implement == on structs and arrays
To allow these types as map keys, we must fill in
equal and hash functions in their algorithm tables.
Structs or arrays that are "just memory", like [2]int,
can and do continue to use the AMEM algorithm.
Structs or arrays that contain special values like
strings or interface values use generated functions
for both equal and hash.

The runtime helper func runtime.equal(t, x, y) bool handles
the general equality case for x == y and calls out to
the equal implementation in the algorithm table.

For short values (<= 4 struct fields or array elements),
the sequence of elementwise comparisons is inlined
instead of calling runtime.equal.

R=ken, mpimenov
CC=golang-dev
https://golang.org/cl/5451105
2011-12-12 22:22:09 -05:00
Russ Cox
1cb7f85d74 gc: 0 expected bugs
Now that Luuk's qualified exporting code
is in, fixing this bug is trivial.

R=ken2
CC=golang-dev
https://golang.org/cl/5479048
2011-12-09 14:58:28 -05:00
Russ Cox
8c0b699ca4 gc: fix another blank bug
R=ken2
CC=golang-dev
https://golang.org/cl/5478051
2011-12-09 11:59:21 -05:00
Russ Cox
012798a325 gc: rune is now an alias for int32
R=ken2
CC=golang-dev
https://golang.org/cl/5467049
2011-12-09 00:12:07 -05:00
Russ Cox
be0ffbfd02 gc: implement character constant type rules
R=ken2
CC=golang-dev
https://golang.org/cl/5444054
2011-12-08 22:07:43 -05:00
Rémy Oudompheng
4349effb15 gc: keep pointer to original node in constant rewrites.
This allows printing meaningful expressions in error messages
instead of evaluated constants.
Fixes #2276.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/5432082
2011-12-07 16:18:50 -05:00
Russ Cox
5e98505ba7 gc: fix spurious typecheck loop in &composite literal
Fixes #2538.

R=ken2
CC=golang-dev
https://golang.org/cl/5449114
2011-12-07 15:48:55 -05:00
Russ Cox
3c56a7b17e test: make array smaller in nilptr test
Fixes #2314.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5437154
2011-12-07 15:00:44 -05:00
Russ Cox
46deaa297b gc: disallow map/func equality via interface comparison
Missed when I removed direct map/func equality.

R=ken2
CC=golang-dev
https://golang.org/cl/5452052
2011-12-06 10:48:17 -05:00
Russ Cox
2666b815a3 use new strconv API
All but 3 cases (in gcimporter.go and hixie.go)
are automatic conversions using gofix.

No attempt is made to use the new Append functions
even though there are definitely opportunities.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5447069
2011-12-05 15:48:46 -05:00
Russ Cox
5cb1c82d96 gc: remove type elision in struct literals
R=ken2
CC=golang-dev
https://golang.org/cl/5437136
2011-12-05 14:22:41 -05:00
Russ Cox
434a6c85cb gc: use gofmt spacing when printing map type
R=ken2
CC=golang-dev
https://golang.org/cl/5450071
2011-12-02 14:45:07 -05:00
Russ Cox
7dc9d8c72b gc: composite literals as per Go 1
R=ken2
CC=golang-dev
https://golang.org/cl/5450067
2011-12-02 14:13:12 -05:00
Russ Cox
7d15eda95d gc: do not allow slice of array literal
R=ken2
CC=golang-dev
https://golang.org/cl/5440083
2011-12-02 12:30:56 -05:00
Adam Langley
bac7bc55a6 Add a []byte argument to hash.Hash to allow an allocation to be saved.
This is the result of running `gofix -r hashsum` over the tree, changing
the hash function implementations by hand and then fixing a couple of
instances where gofix didn't catch something.

The changed implementations are as simple as possible while still
working: I'm not trying to optimise in this CL.

R=rsc, cw, rogpeppe
CC=golang-dev
https://golang.org/cl/5448065
2011-12-01 12:35:37 -05:00
Russ Cox
03823b881c use new time API
R=bradfitz, gri, r, dsymonds
CC=golang-dev
https://golang.org/cl/5390042
2011-11-30 12:01:46 -05:00
Russ Cox
8e515485e2 gc: remove funarg special case in structfield
This should make CL 5431046 a little simpler.

R=ken2
CC=golang-dev
https://golang.org/cl/5444048
2011-11-28 16:40:39 -05:00
Rémy Oudompheng
60e4a61d30 gc: don't inherit orig from subnodes in constant expression nodes.
The wrong value made Nconv() show "1" for node "-1", and "2" from
node "2+3".
Fixes #2452.

R=gri, lvd, rsc
CC=golang-dev, remy
https://golang.org/cl/5435064
2011-11-28 12:22:15 -05:00
Maxim Pimenov
ffa6b383f5 gc: fix copying of types
reset xmethod during copytype

Fixes #2497

R=rsc, dvyukov
CC=golang-dev
https://golang.org/cl/5441045
2011-11-28 11:52:16 -05:00
Russ Cox
6e3e380923 allow direct conversion between string and named []byte, []rune
The allowed conversions before and after are:
        type Tstring string
        type Tbyte []byte
        type Trune []rune

        string <-> string  // ok
        string <-> []byte  // ok
        string <-> []rune // ok
        string <-> Tstring // ok
        string <-> Tbyte // was illegal, now ok
        string <-> Trune // was illegal, now ok

        Tstring <-> string  // ok
        Tstring <-> []byte  // ok
        Tstring <-> []rune // ok
        Tstring <-> Tstring // ok
        Tstring <-> Tbyte // was illegal, now ok
        Tstring <-> Trune // was illegal, now ok

Update spec, compiler, tests.  Use in a few packages.

We agreed on this a few months ago but never implemented it.

Fixes #1707.

R=golang-dev, gri, r
CC=golang-dev
https://golang.org/cl/5421057
2011-11-22 12:30:02 -05:00
Russ Cox
4d27f64863 gofmt: do not stop test.sh after 1 error
Fix bug377.go to be gofmt-compliant.

R=gri, r, r
CC=golang-dev
https://golang.org/cl/5400045
2011-11-16 18:44:21 -05:00
Russ Cox
d03611f628 allow copy of struct containing unexported fields
An experiment: allow structs to be copied even if they
contain unexported fields.  This gives packages the
ability to return opaque values in their APIs, like reflect
does for reflect.Value but without the kludgy hacks reflect
resorts to.

In general, we trust programmers not to do silly things
like *x = *y on a package's struct pointers, just as we trust
programmers not to do unicode.Letter = unicode.Digit,
but packages that want a harder guarantee can introduce
an extra level of indirection, like in the changes to os.File
in this CL or by using an interface type.

All in one CL so that it can be rolled back more easily if
we decide this is a bad idea.

Originally discussed in March 2011.
https://groups.google.com/group/golang-dev/t/3f5d30938c7c45ef

R=golang-dev, adg, dvyukov, r, bradfitz, jan.mercl, gri
CC=golang-dev
https://golang.org/cl/5372095
2011-11-15 12:20:59 -05:00
Russ Cox
5bb54b8e9c gc: remove func, map compare
R=ken, ken
CC=golang-dev
https://golang.org/cl/5373079
2011-11-13 22:58:08 -05:00
Russ Cox
5fc3771b3a gc: remove m[k] = x, false
R=ken2
CC=golang-dev
https://golang.org/cl/5376076
2011-11-11 16:48:25 -05:00
Luuk van Dijk
924ea515cf gc: better error for non-calling use of unsafe builtins.
Fixes #1951

R=rsc
CC=golang-dev
https://golang.org/cl/5372041
2011-11-09 18:30:54 +01:00
Luuk van Dijk
d5a5855ba1 gc: Preserve original blank name for .anon substitution on out params.
Fixes #1802.

R=rsc
CC=golang-dev
https://golang.org/cl/5364043
2011-11-09 11:27:27 +01:00
Luuk van Dijk
151b2f1509 gc: Fail on implicit assigment to non-exported fields in copy and append.
Fixes #1387.

R=rsc
CC=golang-dev
https://golang.org/cl/5348046
2011-11-09 11:17:06 +01:00
Luuk van Dijk
13e92e4d75 gc: Better typechecks and errors in switches.
Allow any type in switch on interface value.
Statically check typeswitch early.

Fixes #2423.
Fixes #2424.

R=rsc, dsymonds
CC=golang-dev
https://golang.org/cl/5339045
2011-11-09 10:58:53 +01:00
Rob Pike
f9489bed72 renaming_4: gofix -r everything/but/src/pkg
R=rsc
CC=golang-dev
https://golang.org/cl/5338043
2011-11-08 15:43:02 -08:00
Rob Pike
6ab6c49fce renaming_1: hand-edited files for go 1 renaming
This contains the files that required handiwork, mostly
Makefiles with updated TARGs, plus the two packages
with modified package names.
html/template/doc.go needs a separate edit pass.
test/fixedbugs/bug358.go is not legal go so gofix fails on it.

R=rsc
CC=golang-dev
https://golang.org/cl/5340050
2011-11-08 15:38:47 -08:00
Luuk van Dijk
087bec3dcd gc: Clean up dostruct/stotype, detect broken fields and propagate up to structs and functions to supress spurious errors.
Fixes #1556.

R=rsc
CC=golang-dev
https://golang.org/cl/5351042
2011-11-07 21:35:13 +01:00
Luuk van Dijk
ea9e93862d gc: Better error message for range over non-receive channel.
Fixes #2354

R=rsc
CC=golang-dev
https://golang.org/cl/5346044
2011-11-06 22:14:15 +01:00
Luuk van Dijk
0d6f857c3f gc: Switch related errors should use plain format.
Fixes #2422.

R=rsc
CC=golang-dev
https://golang.org/cl/5353046
2011-11-06 22:13:54 +01:00
Ian Lance Taylor
7f0622e66d test: make closedchan.go exit with failure if something fails
R=golang-dev, rsc, iant
CC=golang-dev
https://golang.org/cl/5356042
2011-11-04 14:12:35 -07:00
Luuk van Dijk
aac144b120 gc: detect type switch variable not used cases.
Fixes #873
Fixes #2162

R=rsc
CC=golang-dev
https://golang.org/cl/5341043
2011-11-04 17:03:50 +01:00
Luuk van Dijk
11075ed893 gc: Don't pollute the xmethod list with non-methods.
Fixes #2355.

I have a test, but not sure if it's worth adding.  Instead i've made
the patching-over in reflect.c methods more fatal and more descriptive.

R=rsc
CC=golang-dev
https://golang.org/cl/5302082
2011-11-03 17:51:15 +01:00
Mikio Hara
bc440f1bfe test: clear execute bit from source file
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5330068
2011-11-03 10:26:33 +09:00
Luuk van Dijk
7df9ff5594 gc: helpful message instead of internal error on method call on pointer to pointer.
Fixes #2343.

R=rsc
CC=golang-dev
https://golang.org/cl/5332048
2011-11-02 17:18:53 +01:00
Luuk van Dijk
29a5ae657f gc: small fixes for printing.
mark OADDR inserted by typecheck as implicit
OCOPY takes ->left and ->right, not ->list
OMAKE*'s can all have arguments
precedence for OIND was initalized twice

fixes #2414

R=rsc, dave
CC=golang-dev
https://golang.org/cl/5319065
2011-11-02 15:36:33 +01:00
Russ Cox
44526cdbe0 non-pkg: gofix -r error -force=error
R=golang-dev, iant, r, r
CC=golang-dev
https://golang.org/cl/5307066
2011-11-01 22:06:05 -04:00
Russ Cox
b4df33a6ea gc: test + fix escape analysis bug
R=lvd
CC=golang-dev
https://golang.org/cl/5333049
2011-11-01 11:02:43 -04:00
Russ Cox
a07841e21e test: make bug107 os.Error-proof
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5306087
2011-10-31 17:50:38 -04:00
Luuk van Dijk
50110c9f83 gc: clean up printing.
Got rid of all the magic mystery globals. Now
for %N, %T, and %S, the flags +,- and # set a sticky
debug, sym and export mode, only visible in the new fmt.c.
Default is error mode. Handle h and l flags consistently with
the least side effects, so we can now change
things without worrying about unrelated things
breaking.

fixes #2361

R=rsc
CC=golang-dev
https://golang.org/cl/5316043
2011-10-31 18:09:40 +01:00
Russ Cox
64f78c918a test: error-related fixes
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5328051
2011-10-27 19:41:39 -07:00
Russ Cox
8658b36ba2 test/alias.go: additional tests
R=ken2
CC=golang-dev
https://golang.org/cl/5327045
2011-10-26 15:27:47 -07:00
Russ Cox
db33959797 cgo, goyacc, go/build, html, http, path, path/filepath, testing/quick, test: use rune
Nothing terribly interesting here.

R=golang-dev, bradfitz, gri, r
CC=golang-dev
https://golang.org/cl/5300043
2011-10-25 22:20:02 -07:00
Russ Cox
862179b0f5 gc: preserve uint8 and byte distinction in errors, import data
There is no semantic change here, just better errors.
If a function says it takes a byte, and you pass it an int,
the compiler error now says that you need a byte, not
that you need a uint8.

Groundwork for rune.

R=ken2
CC=golang-dev
https://golang.org/cl/5300042
2011-10-18 14:55:50 -04:00
Russ Cox
389d55fadf build: pass $GCFLAGS to compiler
For example, if you are debugging an optimization
problem you can now run

        GCFLAGS=-N gotest

This is a convention for make, not for the general build,
so it may go away or be done differently in the eventual
'go' command.

The plan is that people will be able to test their code for
rune safety by doing GCFLAGS=-r.

R=golang-dev, bradfitz, lvd
CC=golang-dev
https://golang.org/cl/5294042
2011-10-18 14:55:10 -04:00
Russ Cox
313c8224d5 gofix -r mapdelete
R=golang-dev, r, adg, r, cw
CC=golang-dev
https://golang.org/cl/5266045
2011-10-18 09:56:34 -04:00
Russ Cox
304cf4dc9b reflect: disallow Interface method on Value obtained via unexported name
Had been allowing it for use by fmt, but it is too hard to lock down.
Fix other packages not to depend on it.

R=r, r
CC=golang-dev
https://golang.org/cl/5266054
2011-10-17 18:48:45 -04:00
Russ Cox
f58ed4e641 gc: disallow close on receive-only channels
Fixes #2353.
Fixes #2246.

R=golang-dev, r, gri
CC=golang-dev
https://golang.org/cl/5282042
2011-10-13 16:58:04 -04:00
Russ Cox
d1bafffa4b runtime: run goroutines during init
Fixes #583.
Fixes #1776.
Fixes #2001.
Fixes #2112.

R=golang-dev, bradfitz, r, gri
CC=golang-dev
https://golang.org/cl/5265044
2011-10-13 15:54:23 -04:00
Russ Cox
eb3aba24b5 gc: stricter multiple assignment + test
Fixes #693.

R=ken2
CC=golang-dev
https://golang.org/cl/5265045
2011-10-13 15:46:39 -04:00
Luuk van Dijk
77fac21e82 runtime: append([]byte, string...)
Fixes #2274

R=rsc, gri, dsymonds, bradfitz, lvd
CC=golang-dev
https://golang.org/cl/5149045
2011-10-12 15:59:23 +02:00
Rob Pike
f4cb96b438 container/vector: delete
Slices are better:
http://code.google.com/p/go-wiki/wiki/SliceTricks

R=golang-dev, bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/5248060
2011-10-11 16:41:48 -07:00
Luuk van Dijk
b536adbfba gc: changes to export format in preparation for inlining.
string literals used as package qualifiers are now prefixed with '@'
which obviates the need for the extra ':' before tags.

R=rsc, gri, lvd
CC=golang-dev
https://golang.org/cl/5129057
2011-10-08 19:37:06 +02:00
Dmitriy Vyukov
c14b2689f0 runtime: faster finalizers
Linux/amd64, 2 x Intel Xeon E5620, 8 HT cores, 2.40GHz
benchmark                    old ns/op    new ns/op    delta
BenchmarkFinalizer              420.00       261.00  -37.86%
BenchmarkFinalizer-2            985.00       201.00  -79.59%
BenchmarkFinalizer-4           1077.00       244.00  -77.34%
BenchmarkFinalizer-8           1155.00       180.00  -84.42%
BenchmarkFinalizer-16          1182.00       184.00  -84.43%

BenchmarkFinalizerRun          2128.00      1378.00  -35.24%
BenchmarkFinalizerRun-2        1655.00      1418.00  -14.32%
BenchmarkFinalizerRun-4        1634.00      1522.00   -6.85%
BenchmarkFinalizerRun-8        2213.00      1581.00  -28.56%
BenchmarkFinalizerRun-16       2424.00      1599.00  -34.03%

Darwin/amd64, Intel L9600, 2 cores, 2.13GHz
benchmark                    old ns/op    new ns/op    delta
BenchmarkChanCreation          1451.00       926.00  -36.18%
BenchmarkChanCreation-2        3124.00      1412.00  -54.80%
BenchmarkChanCreation-4        6121.00      2628.00  -57.07%

BenchmarkFinalizer              684.00       420.00  -38.60%
BenchmarkFinalizer-2          11195.00       398.00  -96.44%
BenchmarkFinalizer-4          15862.00       654.00  -95.88%

BenchmarkFinalizerRun          2025.00      1397.00  -31.01%
BenchmarkFinalizerRun-2        3920.00      1447.00  -63.09%
BenchmarkFinalizerRun-4        9471.00      1545.00  -83.69%

R=golang-dev, cw, rsc
CC=golang-dev
https://golang.org/cl/4963057
2011-10-06 18:42:51 +03:00
Dmitriy Vyukov
5695915833 runtime: fix spurious deadlock reporting
Fixes #2337.
Unfortunate sequence of events is:
1. maxcpu=2, mcpu=1, grunning=1
2. starttheworld creates an extra M:
   maxcpu=2, mcpu=2, grunning=1
4. the goroutine calls runtime.GOMAXPROCS(1)
   maxcpu=1, mcpu=2, grunning=1
5. since it sees mcpu>maxcpu, it calls gosched()
6. schedule() deschedules the goroutine:
   maxcpu=1, mcpu=1, grunning=0
7. schedule() call getnextandunlock() which
   fails to pick up the goroutine again,
   because canaddcpu() fails, because mcpu==maxcpu
8. then it sees that grunning==0,
   reports deadlock and terminates

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5191044
2011-10-06 18:10:14 +03:00
Brad Fitzpatrick
2cef85f8a1 Fix build, disabling flaky registerization test.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5179045
2011-10-03 17:25:55 -07:00
Russ Cox
e419535f2a 5g, 6g, 8g: registerize variables again
My previous CL:

changeset:   9645:ce2e5f44b310
user:        Russ Cox <rsc@golang.org>
date:        Tue Sep 06 10:24:21 2011 -0400
summary:     gc: unify stack frame layout

introduced a bug wherein no variables were
being registerized, making Go programs 2-3x
slower than they had been before.

This CL fixes that bug (along with some others
it was hiding) and adds a test that optimization
makes at least one test case faster.

R=ken2
CC=golang-dev
https://golang.org/cl/5174045
2011-10-03 17:46:36 -04:00
Russ Cox
d324f2143b runtime: parallelize garbage collector mark + sweep
Running test/garbage/parser.out.

On a 4-core Lenovo X201s (Linux):
31.12u 0.60s 31.74r 	 1 cpu, no atomics
32.27u 0.58s 32.86r 	 1 cpu, atomic instructions
33.04u 0.83s 27.47r 	 2 cpu

On a 16-core Xeon (Linux):
33.08u 0.65s 33.80r 	 1 cpu, no atomics
34.87u 1.12s 29.60r 	 2 cpu
36.00u 1.87s 28.43r 	 3 cpu
36.46u 2.34s 27.10r 	 4 cpu
38.28u 3.85s 26.92r 	 5 cpu
37.72u 5.25s 26.73r	 6 cpu
39.63u 7.11s 26.95r	 7 cpu
39.67u 8.10s 26.68r	 8 cpu

On a 2-core MacBook Pro Core 2 Duo 2.26 (circa 2009, MacBookPro5,5):
39.43u 1.45s 41.27r 	 1 cpu, no atomics
43.98u 2.95s 38.69r 	 2 cpu

On a 2-core Mac Mini Core 2 Duo 1.83 (circa 2008; Macmini2,1):
48.81u 2.12s 51.76r 	 1 cpu, no atomics
57.15u 4.72s 51.54r 	 2 cpu

The handoff algorithm is really only good for two cores.
Beyond that we will need to so something more sophisticated,
like have each core hand off to the next one, around a circle.
Even so, the code is a good checkpoint; for now we'll limit the
number of gc procs to at most 2.

R=dvyukov
CC=golang-dev
https://golang.org/cl/4641082
2011-09-30 09:40:01 -04:00
Russ Cox
092a211fb9 5g: fix -f()
R=ken2
CC=golang-dev
https://golang.org/cl/5161041
2011-09-29 12:09:46 -04:00
Russ Cox
a1a3acbd95 test: fix windows build
TBR=bradfitz
CC=golang-dev
https://golang.org/cl/5124049
2011-09-27 09:13:00 -04:00
Ian Lance Taylor
45301ba8c0 runtime: check for nil value pointer in select syncsend case
Fixes #2309.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5128053
2011-09-26 20:46:37 -07:00
Russ Cox
4bdf1fc02b test: silence/coalesce some tests
Add copyright notice to nilptr.go.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5139048
2011-09-26 19:35:21 -04:00
Russ Cox
67d48daae9 test: merge nilptr/* into one test
The 512 MB array causes load delays on some systems.
Now that we have recover, we can do all the tests in
one binary, so that the delay is incurred just once.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5142044
2011-09-26 13:59:01 -04:00
Russ Cox
0b09a56a64 test: disable sigchld test on Windows
Alex Brainman reports that this is the only test
that keeps us from running test/run.

R=alex.brainman, lucio.dere, bradfitz, hectorchu
CC=golang-dev
https://golang.org/cl/4777043
2011-09-26 13:11:22 -04:00
Ian Lance Taylor
8a06936ea1 test: match gccgo error messages
bug340.go:14:7: error: expected type
bug340.go:15:4: error: reference to undefined field or method ‘x’

bug350.go:12:1: error: redefinition of ‘m’
bug350.go:11:1: note: previous definition of ‘m’ was here
bug350.go:15:1: error: redefinition of ‘p’
bug350.go:14:1: note: previous definition of ‘p’ was here

bug351.go:12:6: error: non-name on left side of ‘:=’

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5127041
2011-09-23 21:23:40 -07:00
Ian Lance Taylor
9169c27eaa test: match gccgo error messages
bug363.go:13:12: error: invalid context-determined non-integer type for shift operand
bug363.go:16:12: error: invalid context-determined non-integer type for shift operand

pointer.go:34:6: error: incompatible type in initialization (pointer to interface type has no methods)
pointer.go:36:6: error: incompatible type in initialization

method2.go:15:1: error: invalid pointer or interface receiver type
method2.go:16:1: error: invalid pointer or interface receiver type
method2.go:21:1: error: invalid pointer or interface receiver type
method2.go:22:1: error: invalid pointer or interface receiver type
method2.go:28:15: error: type ‘*Val’ has no method ‘val’
method2.go:33:11: error: reference to undefined field or method ‘val’

shift1.go:19:16: error: invalid context-determined non-integer type for shift operand
shift1.go:24:19: error: invalid context-determined non-integer type for shift operand
shift1.go:25:17: error: invalid context-determined non-integer type for shift operand
shift1.go:18:18: error: shift of non-integer operand
shift1.go:26:13: error: floating point constant truncated to integer
shift1.go:33:15: error: integer constant overflow
shift1.go:34:15: error: integer constant overflow
shift1.go:35:17: error: integer constant overflow

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5081051
2011-09-21 17:25:48 -07:00
Ian Lance Taylor
1f27519988 test: match gccgo error messages
Added a return to bug357.go to avoid an error which gccgo
reports but 6g does not.

bug353.go:16:14: error: reference to undefined identifer ‘io.ReadWriterCloser’

bug357.go:18:2: error: value computed is not used

bug358.go:14:11: error: imported and not used: ioutil
bug358.go:19:9: error: invalid use of type

bug359.go:25:14: error: redefinition of ‘a’
bug359.go:25:6: note: previous definition of ‘a’ was here
bug359.go:19:6: error: incompatible type in initialization (implicit assignment of ‘list.List’ hidden field ‘front’)

bug362.go:13:6: error: iota is only defined in const declarations
bug362.go:14:6: error: iota is only defined in const declarations
bug362.go:15:6: error: iota is only defined in const declarations

bug363.go:13:12: error: shift of non-integer operand
bug363.go:16:12: error: shift of non-integer operand

bug365.go:15:8: error: expected package

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5078046
2011-09-20 16:47:17 -07:00
Ian Lance Taylor
86d97aa981 test: match gccgo error messages for bug349.go
bug349.go:12:14: error: expected ‘;’ or ‘}’ or newline
bug349.go:12:2: error: not enough arguments to return

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5081047
2011-09-20 14:47:48 -07:00
Ian Lance Taylor
f1aefc0d36 test: match gccgo error messages for goto.go and bug344.go
goto.go:39:2: error: goto jumps over declaration of ‘x’
goto.go:40:2: note: ‘x’ defined here
goto.go:57:2: error: goto jumps over declaration of ‘x’
goto.go:62:2: note: ‘x’ defined here
goto.go:77:2: error: goto jumps over declaration of ‘x’
goto.go:78:2: note: ‘x’ defined here
goto.go:87:2: error: goto jumps over declaration of ‘x’
goto.go:88:2: note: ‘x’ defined here
goto.go:114:2: error: goto jumps into block
goto.go:115:2: note: goto target block starts here
goto.go:125:2: error: goto jumps into block
goto.go:122:2: note: goto target block starts here
goto.go:130:2: error: goto jumps into block
goto.go:133:4: note: goto target block starts here
goto.go:142:2: error: goto jumps into block
goto.go:145:2: note: goto target block starts here
goto.go:179:2: error: goto jumps into block
goto.go:180:10: note: goto target block starts here
goto.go:186:2: error: goto jumps into block
goto.go:187:10: note: goto target block starts here
goto.go:194:2: error: goto jumps into block
goto.go:196:4: note: goto target block starts here
goto.go:205:3: error: goto jumps into block
goto.go:202:11: note: goto target block starts here
goto.go:211:3: error: goto jumps into block
goto.go:212:4: note: goto target block starts here
goto.go:219:3: error: goto jumps into block
goto.go:220:18: note: goto target block starts here
goto.go:227:3: error: goto jumps into block
goto.go:228:18: note: goto target block starts here
goto.go:241:3: error: goto jumps into block
goto.go:243:4: note: goto target block starts here
goto.go:290:2: error: goto jumps into block
goto.go:287:6: note: goto target block starts here
goto.go:299:2: error: goto jumps into block
goto.go:294:6: note: goto target block starts here
goto.go:306:2: error: goto jumps into block
goto.go:303:12: note: goto target block starts here
goto.go:313:2: error: goto jumps into block
goto.go:310:24: note: goto target block starts here
goto.go:320:2: error: goto jumps into block
goto.go:317:18: note: goto target block starts here
goto.go:327:2: error: goto jumps into block
goto.go:324:18: note: goto target block starts here
goto.go:334:2: error: goto jumps into block
goto.go:331:18: note: goto target block starts here
goto.go:341:2: error: goto jumps into block
goto.go:338:18: note: goto target block starts here
goto.go:395:2: error: goto jumps into block
goto.go:398:2: note: goto target block starts here
goto.go:403:2: error: goto jumps into block
goto.go:406:2: note: goto target block starts here
goto.go:413:2: error: goto jumps into block
goto.go:417:2: note: goto target block starts here
goto.go:424:3: error: goto jumps into block
goto.go:426:2: note: goto target block starts here
goto.go:436:3: error: goto jumps into block
goto.go:433:2: note: goto target block starts here
goto.go:492:2: error: goto jumps into block
goto.go:495:2: note: goto target block starts here
goto.go:500:2: error: goto jumps into block
goto.go:503:2: note: goto target block starts here
goto.go:510:2: error: goto jumps into block
goto.go:514:2: note: goto target block starts here
goto.go:521:3: error: goto jumps into block
goto.go:523:2: note: goto target block starts here
goto.go:533:3: error: goto jumps into block
goto.go:530:2: note: goto target block starts here

bug344.go:17:2: error: goto jumps into block
bug344.go:20:21: note: goto target block starts here

R=rsc
CC=golang-dev
https://golang.org/cl/5077044
2011-09-20 14:45:54 -07:00
Ian Lance Taylor
c55d0c4dd7 test: match gccgo error message for bug337.go
bug337.go:17:2: error: value computed is not used

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5094042
2011-09-20 09:31:07 -07:00
Russ Cox
7ca406396f gc: disallow invalid map keys
The algtype-based test broke when algtype
got a bit more fine-grained, so replace with
an explicit check for the invalid key types.

R=ken2
CC=golang-dev
https://golang.org/cl/5071041
2011-09-19 13:11:24 -04:00
Russ Cox
ad7dea1e96 gc: handle complex CONVNOP
Fixes #2256.

R=ken2
CC=golang-dev
https://golang.org/cl/5044047
2011-09-19 11:50:53 -04:00
Ian Lance Taylor
bfe9f228a4 test: match gccgo error messages for bug330.go.
bug330.go:11:6: error: expected numeric type
bug330.go:12:6: error: expected numeric type

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5031050
2011-09-16 18:28:57 -07:00
Ian Lance Taylor
5f172fadbe test: Add test for inheriting private method from anonymous field.
The spec says that all methods are inherited from an anonymous
field.  There is no exception for non-exported methods.

This is related to issue 1536.

R=rsc
CC=golang-dev
https://golang.org/cl/5012043
2011-09-14 10:31:51 -07:00
Russ Cox
9fc687392c gc: clean up if grammar
Fixes #2248.

R=ken2
CC=golang-dev
https://golang.org/cl/4978064
2011-09-12 15:52:29 -04:00
Luuk van Dijk
ac1b9545e3 ld: grow dwarf includestack on demand.
Fixes #2241
while not breaking issue 1878 again.

R=rsc
CC=golang-dev
https://golang.org/cl/4988048
2011-09-09 15:08:57 +02:00
Luuk van Dijk
f2460a8c57 gc: treat DOTMETH like DOT in escape analysis.
Fixes #2225

R=rsc, nigeltao, dave
CC=bradfitz, golang-dev, mikioh.mikioh
https://golang.org/cl/4972056
2011-09-07 19:03:11 +02:00
Russ Cox
919cb2ec7c gc: fix zero-length struct eval
Fixes #2232.

R=ken2
CC=golang-dev
https://golang.org/cl/4960054
2011-09-05 15:31:22 -04:00
Mike Rosset
8ddd66145e build: clear execute bit from Go files
R=golang-dev, rsc
CC=golang-dev, mike.rosset
https://golang.org/cl/4950062
2011-09-05 07:48:42 -04:00
Russ Cox
c45c0c0c1d gc: zero stack-allocated slice backing arrays
Fixes Han-Wen's termite bug.

R=lvd
CC=golang-dev
https://golang.org/cl/4977052
2011-09-02 15:11:28 -04:00
Russ Cox
60d47101aa gc: fix label recursion bugs
Was keeping a pointer to the labeled statement in n->right,
which meant that generic traversals of the tree visited it twice.
That combined with aggressive flattening of the block
structure when possible during parsing meant that
the kinds of label: code label: code label: code sequences
generated by yacc were giving the recursion 2ⁿ paths
through the program.

Fixes #2212.

R=lvd
CC=golang-dev
https://golang.org/cl/4960050
2011-09-01 13:44:46 -04:00
Russ Cox
335da67e00 gc: make static initialization more static
Does as much as possible in data layout instead
of during the init function.

Handles var x = y; var y = z as a special case too,
because it is so prevalent in package unicode
(var Greek = _Greek; var _Greek = []...).

Introduces InitPlan description of initialized data
so that it can be traversed multiple times (for example,
in the copy handler).

Cuts package unicode's init function size by 8x.
All that remains there is map initialization, which
is on the chopping block too.

Fixes sinit.go test case.

Aggregate DATA instructions at end of object file.

Checkpoint.  More to come.

R=ken2
CC=golang-dev
https://golang.org/cl/4969051
2011-08-31 07:37:14 -04:00
Russ Cox
4fb3c4f765 gc: fix div bug
R=ken2
CC=golang-dev
https://golang.org/cl/4950052
2011-08-30 08:47:28 -04:00
Russ Cox
77f0bdce07 gc: fix arm build
Escape analysis was incorrectly assuming that
functions without bodies don't leak their
parameters.  This meant that sync/atomic's
TestAddInt64 was allocating x on its stack,
and then x was not properly aligned for use
with the atomic 64-bit instructions.  Obviously
we should figure out the alignment story on 5g
too, but this fix is correct and should restore the
build to 'ok'.

TBR=lvd
CC=golang-dev
https://golang.org/cl/4964047
2011-08-28 23:29:34 -04:00
Russ Cox
db5f9da425 gc: tweak and enable escape analysis
-s now means *disable* escape analysis.

Fix escape leaks for struct/slice/map literals.
Add ... tracking.
Rewrite new(T) and slice literal into stack allocation when safe.

Add annotations to reflect.
Reflect is too chummy with the compiler,
so changes like these affect it more than they should.

R=lvd, dave, gustavo
CC=golang-dev
https://golang.org/cl/4954043
2011-08-28 12:05:00 -04:00
Russ Cox
0227c45ede gc: fix some spurious leaks
Probably will spark some discussion.  ☺

R=lvd
CC=golang-dev
https://golang.org/cl/4948041
2011-08-25 09:26:13 -04:00
Luuk van Dijk
847b61b554 gc: Escape analysis.
For now it's switch-on-and-offable with -s, and the effects can be inspected
with -m.  Defaults are the old codepaths.

R=rsc
CC=golang-dev
https://golang.org/cl/4634073
2011-08-24 19:07:08 +02:00
Luuk van Dijk
940281bd3c test: put GOROOT/bin before all others in run
If you installed a 6g in /usr/bin it interferes
with test/run otherwise.

R=rsc
CC=golang-dev
https://golang.org/cl/4944046
2011-08-24 16:12:20 +02:00
Russ Cox
03e9ea5b74 runtime: simplify stack traces
Make the stack traces more readable for new
Go programmers while preserving their utility for old hands.

- Change status number [4] to string.
- Elide frames in runtime package (internal details).
- Swap file:line and arguments.
- Drop 'created by' for main goroutine.
- Show goroutines in order of allocation:
  implies main goroutine first if nothing else.

There is no option to get the extra frames back.
Uncomment 'return 1' at the bottom of symtab.c.

$ 6.out
throw: all goroutines are asleep - deadlock!

goroutine 1 [chan send]:
main.main()
       /Users/rsc/g/go/src/pkg/runtime/x.go:22 +0x8a

goroutine 2 [select (no cases)]:
main.sel()
       /Users/rsc/g/go/src/pkg/runtime/x.go:11 +0x18
created by main.main
       /Users/rsc/g/go/src/pkg/runtime/x.go:19 +0x23

goroutine 3 [chan receive]:
main.recv(0xf8400010a0, 0x0)
       /Users/rsc/g/go/src/pkg/runtime/x.go:15 +0x2e
created by main.main
       /Users/rsc/g/go/src/pkg/runtime/x.go:20 +0x50

goroutine 4 [chan receive (nil chan)]:
main.recv(0x0, 0x0)
       /Users/rsc/g/go/src/pkg/runtime/x.go:15 +0x2e
created by main.main
       /Users/rsc/g/go/src/pkg/runtime/x.go:21 +0x66
$

$ 6.out index
panic: runtime error: index out of range

goroutine 1 [running]:
main.main()
        /Users/rsc/g/go/src/pkg/runtime/x.go:25 +0xb9
$

$ 6.out nil
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x22ca]

goroutine 1 [running]:
main.main()
        /Users/rsc/g/go/src/pkg/runtime/x.go:28 +0x211
$

$ 6.out panic
panic: panic

goroutine 1 [running]:
main.main()
        /Users/rsc/g/go/src/pkg/runtime/x.go:30 +0x101
$

R=golang-dev, qyzhai, n13m3y3r, r
CC=golang-dev
https://golang.org/cl/4907048
2011-08-22 23:26:39 -04:00
Rob Pike
97eb06233f test/chan/sieve2.go: remove container/vector.
R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/4918043
2011-08-22 13:29:17 +10:00
Robert Griesemer
fd897ffc68 type switches: test for pathological case
R=rsc, r
CC=golang-dev
https://golang.org/cl/4894057
2011-08-19 09:31:50 -07:00
Rob Pike
3f5edd2461 test/chan/select5.go: change "with" to "if" in templatea
I converted this program yesterday and the output is the
same as it used to be, ignoring space, but the result is
not the best expression of the algorithm.  The old {.section
Maybe} pieces are now {{with .Maybe}}, as a direct translation,
but I they should be {{if .Maybe}} as the output is just a
bool and there is no cascading.

I have verified that the output of the program is unaffected.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4889053
2011-08-18 13:27:18 +10:00
Russ Cox
75cb084283 test: new nil semantics
R=gri
CC=golang-dev
https://golang.org/cl/4644052
2011-08-17 15:55:06 -04:00
Russ Cox
3770b0e60c gc: implement nil chan support
The spec has defined nil chans this way for months.
I'm behind.

R=ken2
CC=golang-dev
https://golang.org/cl/4897050
2011-08-17 15:54:17 -04:00
Rob Pike
6b5962c274 test/chan/select5.go: update to new templates
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4911041
2011-08-17 16:51:04 +10:00