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

1574 Commits

Author SHA1 Message Date
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