]> Cypherpunks repositories - gostls13.git/log
gostls13.git
12 years agocmd/8g: eliminate obviously useless temps before regopt.
Rémy Oudompheng [Tue, 13 Nov 2012 06:39:18 +0000 (07:39 +0100)]
cmd/8g: eliminate obviously useless temps before regopt.

This patch introduces a sort of pre-regopt peephole optimization.
When a temporary is introduced that just holds a value for the
duration of the next instruction and is otherwise unused, we
elide it to make the job of regopt easier.

Since x86 has very few registers, this situation happens very
often. The result is large savings in stack variables for
arithmetic-heavy functions.

crypto/aes

benchmark                 old ns/op    new ns/op    delta
BenchmarkEncrypt               1301          392  -69.87%
BenchmarkDecrypt               1309          368  -71.89%
BenchmarkExpand                2913         1036  -64.44%
benchmark                  old MB/s     new MB/s  speedup
BenchmarkEncrypt              12.29        40.74    3.31x
BenchmarkDecrypt              12.21        43.37    3.55x

crypto/md5

benchmark                 old ns/op    new ns/op    delta
BenchmarkHash8Bytes            1761          914  -48.10%
BenchmarkHash1K               16912         5570  -67.06%
BenchmarkHash8K              123895        38286  -69.10%
benchmark                  old MB/s     new MB/s  speedup
BenchmarkHash8Bytes            4.54         8.75    1.93x
BenchmarkHash1K               60.55       183.83    3.04x
BenchmarkHash8K               66.12       213.97    3.24x

bench/go1

benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    8364835000   8303154000   -0.74%
BenchmarkFannkuch11      7511723000   6381729000  -15.04%
BenchmarkGobDecode         27764090     27103270   -2.38%
BenchmarkGobEncode         11240880     11184370   -0.50%
BenchmarkGzip            1470224000    856668400  -41.73%
BenchmarkGunzip           240660800    201697300  -16.19%
BenchmarkJSONEncode       155225800    185571900  +19.55%
BenchmarkJSONDecode       243347900    282123000  +15.93%
BenchmarkMandelbrot200     12240970     12201880   -0.32%
BenchmarkParse              8837445      8765210   -0.82%
BenchmarkRevcomp         2556310000   1868566000  -26.90%
BenchmarkTemplate         389298000    379792000   -2.44%
benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            27.64        28.32    1.02x
BenchmarkGobEncode            68.28        68.63    1.01x
BenchmarkGzip                 13.20        22.65    1.72x
BenchmarkGunzip               80.63        96.21    1.19x
BenchmarkJSONEncode           12.50        10.46    0.84x
BenchmarkJSONDecode            7.97         6.88    0.86x
BenchmarkParse                 6.55         6.61    1.01x
BenchmarkRevcomp              99.43       136.02    1.37x
BenchmarkTemplate              4.98         5.11    1.03x

Fixes #4035.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6828056

12 years agocmd/gc: fix typos in clearslim.
Rémy Oudompheng [Tue, 13 Nov 2012 06:08:29 +0000 (07:08 +0100)]
cmd/gc: fix typos in clearslim.

Fixes build failure.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6847043

12 years agonet: protocol specific listen functions return a proper local socket address
Mikio Hara [Tue, 13 Nov 2012 03:56:28 +0000 (12:56 +0900)]
net: protocol specific listen functions return a proper local socket address

When a nil listener address is passed to some protocol specific
listen function, it will create an unnamed, unbound socket because
of the nil listener address. Other listener functions may return
invalid address error.

This CL allows to pass a nil listener address to all protocol
specific listen functions to fix above inconsistency. Also make it
possible to return a proper local socket address in case of a nil
listner address.

Fixes #4190.
Fixes #3847.

R=rsc, iant
CC=golang-dev
https://golang.org/cl/6525048

12 years agonet: make LocalAddr on multicast UDPConn return a listening address
Mikio Hara [Tue, 13 Nov 2012 03:26:20 +0000 (12:26 +0900)]
net: make LocalAddr on multicast UDPConn return a listening address

The package go.net/ipv4 allows to exist a single UDP listener
that join multiple different group addresses. That means that
LocalAddr on multicast UDPConn returns a first joined group
address is not desirable.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6822108

12 years agonet/textproto: faster header canonicalization with fewer allocations
Jeff R. Allen [Mon, 12 Nov 2012 23:31:42 +0000 (15:31 -0800)]
net/textproto: faster header canonicalization with fewer allocations

By keeping a single copy of the strings that commonly show up
in headers, we can avoid one string allocation per header.

benchmark                  old ns/op    new ns/op    delta
BenchmarkReadMIMEHeader        19590        10824  -44.75%
BenchmarkUncommon               3168         1861  -41.26%

benchmark                 old allocs   new allocs    delta
BenchmarkReadMIMEHeader           32           25  -21.88%
BenchmarkUncommon                  5            5    0.00%

R=bradfitz, golang-dev, dave, rsc, jra
CC=golang-dev
https://golang.org/cl/6721055

12 years agonet/http: handle 413 responses more robustly
Brad Fitzpatrick [Mon, 12 Nov 2012 23:20:18 +0000 (15:20 -0800)]
net/http: handle 413 responses more robustly

When HTTP bodies were too large and we didn't want to finish
reading them for DoS reasons, we previously found it necessary
to send a FIN and then pause before closing the connection
(which might send a RST) if we wanted the client to have a
better chance at receiving our error response. That was Issue 3595.

This issue adds the same fix to request headers which
are too large, which might fix the Windows flakiness
we observed on TestRequestLimit at:
http://build.golang.org/log/146a2a7d9b24441dc14602a1293918191d4e75f1

R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/6826084

12 years agocmd/6g: extend componentgen to small arrays and structs.
Rémy Oudompheng [Mon, 12 Nov 2012 23:08:04 +0000 (00:08 +0100)]
cmd/6g: extend componentgen to small arrays and structs.

Fixes #4092.

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

12 years agocmd/5g, cmd/6g: pass the full torture test.
Rémy Oudompheng [Mon, 12 Nov 2012 22:56:11 +0000 (23:56 +0100)]
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

12 years agoexp/types: avoid init race in check_test.go.
David Symonds [Mon, 12 Nov 2012 22:08:33 +0000 (09:08 +1100)]
exp/types: avoid init race in check_test.go.

There was an init race between
check_test.go:init
        universe.go:def
        use of Universe
and
universe.go:init
        creation of Universe

The order in which init funcs are executed in a package is unspecified.
The test is not currently broken in the golang.org environment
because the go tool compiles the test with non-test sources before test sources,
but other environments may, say, sort the source files before compiling,
and thus trigger this race, causing a nil pointer panic.

R=gri
CC=golang-dev
https://golang.org/cl/6827076

12 years agoencoding/json: skip unexpected null values
Rick Arnold [Mon, 12 Nov 2012 20:35:11 +0000 (15:35 -0500)]
encoding/json: skip unexpected null values

As discussed in issue 2540, nulls are allowed for any type in JSON so they should not result in an error during Unmarshal.
Fixes #2540.

R=rsc
CC=golang-dev
https://golang.org/cl/6759043

12 years agoA+C: Rick Arnold (individual CLA)
Russ Cox [Mon, 12 Nov 2012 20:34:09 +0000 (15:34 -0500)]
A+C: Rick Arnold (individual CLA)

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6821110

12 years agocrypto/x509: implement EncryptPEMBlock
Roger Peppe [Mon, 12 Nov 2012 15:31:23 +0000 (15:31 +0000)]
crypto/x509: implement EncryptPEMBlock

Arbitrary decisions: order of the arguments and the
fact it takes a block-type argument (rather than
leaving to user to fill it in later); I'm happy whatever
colour we want to paint it.

We also change DecryptPEMBlock so that it won't
panic when the IV has the wrong size.

R=agl, agl
CC=golang-dev
https://golang.org/cl/6820114

12 years agoencoding/pem: write Proc-Type header first.
Roger Peppe [Mon, 12 Nov 2012 15:29:17 +0000 (15:29 +0000)]
encoding/pem: write Proc-Type header first.
See RFC 1421, section 4.6.1.1

R=agl, agl
CC=golang-dev
https://golang.org/cl/6814104

12 years agofaq: mention go vet in "What happens with closures running as goroutines?"
Christian Himpel [Mon, 12 Nov 2012 15:25:54 +0000 (07:25 -0800)]
faq: mention go vet in "What happens with closures running as goroutines?"

R=r
CC=golang-dev
https://golang.org/cl/6822111

12 years agoarchive/zip: Fix bounds check panic for ZIP files with a truncated extra header.
David McLeish [Mon, 12 Nov 2012 11:21:00 +0000 (12:21 +0100)]
archive/zip: Fix bounds check panic for ZIP files with a truncated extra header.

R=adg, dave
CC=gobot, golang-dev
https://golang.org/cl/6811080

12 years agoC: add David McLeish (Google CLA)
Andrew Gerrand [Mon, 12 Nov 2012 11:20:54 +0000 (12:20 +0100)]
C: add David McLeish (Google CLA)

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6814120

12 years agodoc/install: document system requirements for the FreeBSD/ARM port
Shenghou Ma [Mon, 12 Nov 2012 11:20:42 +0000 (12:20 +0100)]
doc/install: document system requirements for the FreeBSD/ARM port

R=golang-dev, r, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6816080

12 years agocmd/5g: enable xtramodes optimisation
Dave Cheney [Sat, 10 Nov 2012 20:51:20 +0000 (07:51 +1100)]
cmd/5g: enable xtramodes optimisation

xtramodes' C_PBIT optimisation transforms:

MOVW          0(R3),R1
ADD           $4,R3,R3

into:

MOVW.P        4(R3),R1

and the AADD optimisation tranforms:

ADD          R0,R1
MOVBU        0(R1),R0

into:

MOVBU        R0<<0(R1),R0

5g does not appear to generate sequences that
can be transformed by xtramodes' AMOVW.

R=remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6817085

12 years agoruntime, runtime/cgo: track memory allocated by non-Go code
Ian Lance Taylor [Sat, 10 Nov 2012 19:19:06 +0000 (11:19 -0800)]
runtime, runtime/cgo: track memory allocated by non-Go code

Otherwise a poorly timed GC can collect the memory before it
is returned to the Go program.

R=golang-dev, dave, dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/6819119

12 years agonet: add more tests for protocol specific methods
Mikio Hara [Sat, 10 Nov 2012 05:34:34 +0000 (14:34 +0900)]
net: add more tests for protocol specific methods

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6821100

12 years agocmd/6c, cmd/8c: use signed char explicitly in mul.c
Rémy Oudompheng [Fri, 9 Nov 2012 20:06:45 +0000 (21:06 +0100)]
cmd/6c, cmd/8c: use signed char explicitly in mul.c

On ARM, char is unsigned, and the code generation for
multiplication gets totally broken.

Fixes #4354.

R=golang-dev, dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6826079

12 years agocmd/go: fix selection of packages for testing
Dmitriy Vyukov [Fri, 9 Nov 2012 10:00:41 +0000 (14:00 +0400)]
cmd/go: fix selection of packages for testing
Currently it works incorrectly if user specifies own build tags
and with race detection (e.g. runtime/race is not selected,
because it contains only test files with +build race).

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6814107

12 years agoruntime/pprof: fix typo in comment
Ian Lance Taylor [Fri, 9 Nov 2012 07:48:13 +0000 (23:48 -0800)]
runtime/pprof: fix typo in comment

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6810102

12 years agoruntime: use vDSO clock_gettime for time.now & runtime.nanotime on Linux/amd64
Shenghou Ma [Fri, 9 Nov 2012 06:19:07 +0000 (14:19 +0800)]
runtime: use vDSO clock_gettime for time.now & runtime.nanotime on Linux/amd64
Performance improvement aside, time.Now() now gets real nanosecond resolution
on supported systems.

Benchmark done on Core i7-2600 @ 3.40GHz with kernel 3.5.2-gentoo.
original vDSO gettimeofday:
BenchmarkNow    100000000               27.4 ns/op
new vDSO gettimeofday fallback:
BenchmarkNow    100000000               27.6 ns/op
new vDSO clock_gettime:
BenchmarkNow    100000000               24.4 ns/op

R=golang-dev, bradfitz, iant, iant
CC=golang-dev
https://golang.org/cl/6814103

12 years agonet: consolidate multiple init functions
Mikio Hara [Fri, 9 Nov 2012 03:09:22 +0000 (12:09 +0900)]
net: consolidate multiple init functions

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6819117

12 years agoruntime: re-enable crash test on FreeBSD
Mikio Hara [Fri, 9 Nov 2012 01:05:46 +0000 (10:05 +0900)]
runtime: re-enable crash test on FreeBSD

It also passes on FreeBSD.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6812103

12 years agotest: change index.go to test size of int, not GOARCH == "amd64"
Ian Lance Taylor [Thu, 8 Nov 2012 23:43:28 +0000 (15:43 -0800)]
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

12 years agoarchive/tar: accept binary format when reading numeric header fields.
David Symonds [Thu, 8 Nov 2012 21:50:10 +0000 (08:50 +1100)]
archive/tar: accept binary format when reading numeric header fields.

Fixes #4358.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6840043

12 years agocmd/gc: fix export of inlined function body with type guard
Russ Cox [Thu, 8 Nov 2012 21:07:05 +0000 (16:07 -0500)]
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

12 years agonet: fix non-unixen build
Mikio Hara [Thu, 8 Nov 2012 17:09:09 +0000 (02:09 +0900)]
net: fix non-unixen build

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6813101

12 years agotest: run some more tests by default
Ian Lance Taylor [Thu, 8 Nov 2012 17:04:27 +0000 (09:04 -0800)]
test: run some more tests by default

R=golang-dev, remyoudompheng, iant, rsc
CC=golang-dev
https://golang.org/cl/6833043

12 years agoruntime: re-enable crash test on NetBSD
Joel Sing [Thu, 8 Nov 2012 16:41:43 +0000 (03:41 +1100)]
runtime: re-enable crash test on NetBSD

Re-enable the crash tests on NetBSD now that the issue has been
identified and fixed.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6813100

12 years agoruntime: fix instrumentation of slice append for race detection
Dmitriy Vyukov [Thu, 8 Nov 2012 16:37:05 +0000 (20:37 +0400)]
runtime: fix instrumentation of slice append for race detection

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6819107

12 years agonet: close fds eagerly in DialTimeout
Brad Fitzpatrick [Thu, 8 Nov 2012 16:35:16 +0000 (10:35 -0600)]
net: close fds eagerly in DialTimeout

Integrates with the pollserver now.

Uses the old implementation on windows and plan9.

Fixes #2631

R=paul, iant, adg, bendaglish, rsc
CC=golang-dev
https://golang.org/cl/6815049

12 years agocmd/api: bug fix for goapi's lame type checker
Brad Fitzpatrick [Thu, 8 Nov 2012 16:34:54 +0000 (10:34 -0600)]
cmd/api: bug fix for goapi's lame type checker

This is blocking me submitting the net fd timeout
CL, since goapi chokes on my constant.

The much more extensive fix to goapi's type checker
in pending review in https://golang.org/cl/6742050

But I'd rather get this quick fix in first.

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6818104

12 years agotime: clarify why timer.Stop and ticker.Stop don't close the channel
Shenghou Ma [Thu, 8 Nov 2012 15:25:48 +0000 (23:25 +0800)]
time: clarify why timer.Stop and ticker.Stop don't close the channel

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6818106

12 years agolib9: remove unreferenced externs and getuser()
Carl Mastrangelo [Thu, 8 Nov 2012 14:39:24 +0000 (09:39 -0500)]
lib9: remove unreferenced externs and getuser()

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

12 years agoruntime: use vDSO for gettimeofday on linux/amd64
Anthony Martin [Thu, 8 Nov 2012 02:29:31 +0000 (18:29 -0800)]
runtime: use vDSO for gettimeofday on linux/amd64

Intel Core 2 Duo (2.16 GHz) running 3.6.5-1-ARCH

benchmark       old ns/op    new ns/op    delta
BenchmarkNow         1856         1034  -44.29%

R=rsc
CC=golang-dev
https://golang.org/cl/6826072

12 years agocmd/go: say that -race flag can be used on windows/amd64
Alex Brainman [Thu, 8 Nov 2012 02:00:54 +0000 (13:00 +1100)]
cmd/go: say that -race flag can be used on windows/amd64

R=golang-dev, r
CC=dvyukov, golang-dev
https://golang.org/cl/6810099

12 years agocmd/gc: warn about slice indexes larger than int in typecheck pass
Ian Lance Taylor [Thu, 8 Nov 2012 01:34:06 +0000 (17:34 -0800)]
cmd/gc: warn about slice indexes larger than int in typecheck pass

Fixes GOARCH=386 build.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6810098

12 years agodoc/effective_go: don't use ALL_CAPS for variable names.
Nigel Tao [Thu, 8 Nov 2012 00:55:46 +0000 (11:55 +1100)]
doc/effective_go: don't use ALL_CAPS for variable names.

R=r, dsymonds
CC=golang-dev
https://golang.org/cl/6826070

12 years agoimage/jpeg: handle fill bytes.
Nigel Tao [Wed, 7 Nov 2012 23:36:29 +0000 (10:36 +1100)]
image/jpeg: handle fill bytes.

Fixes #4337.

R=r, minux.ma
CC=golang-dev
https://golang.org/cl/6814098

12 years agocmd/gc: fix internal compiler error with broken structs.
Rémy Oudompheng [Wed, 7 Nov 2012 22:09:01 +0000 (23:09 +0100)]
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

12 years agoarchive/tar: avoid writing ModTime that is out of range.
David Symonds [Wed, 7 Nov 2012 21:22:40 +0000 (08:22 +1100)]
archive/tar: avoid writing ModTime that is out of range.

Update #4358
Still to do: support binary numeric format in Reader.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6818101

12 years agocmd/6g, cmd/8g: mark used registers in indirect addressing.
Rémy Oudompheng [Wed, 7 Nov 2012 20:36:15 +0000 (21:36 +0100)]
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

12 years agoruntime: use runtime·callers when racefuncenter's pc is on the heap.
Rémy Oudompheng [Wed, 7 Nov 2012 20:35:21 +0000 (21:35 +0100)]
runtime: use runtime·callers when racefuncenter's pc is on the heap.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6821069

12 years agotest: run index test by default
Ian Lance Taylor [Wed, 7 Nov 2012 20:33:54 +0000 (12:33 -0800)]
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

12 years agoapi: refresh next.txt
Russ Cox [Wed, 7 Nov 2012 20:26:41 +0000 (15:26 -0500)]
api: refresh next.txt

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6811092

12 years agocmd/gc: fix escape analysis bug
Russ Cox [Wed, 7 Nov 2012 20:15:21 +0000 (15:15 -0500)]
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

12 years agoruntime/race: add Windows support
Dmitriy Vyukov [Wed, 7 Nov 2012 19:59:09 +0000 (23:59 +0400)]
runtime/race: add Windows support
This is copy of https://golang.org/cl/6810080
but sent from another account (dvyukov@gmail.com is not in CONTRIBUTORS).

R=rsc
CC=golang-dev
https://golang.org/cl/6827060

12 years agoreflect: fix test of whether structs are identical
Ian Lance Taylor [Wed, 7 Nov 2012 19:55:35 +0000 (11:55 -0800)]
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

12 years agocrypto/x509: fix DecryptPEMBlock
Roger Peppe [Wed, 7 Nov 2012 15:16:34 +0000 (15:16 +0000)]
crypto/x509: fix DecryptPEMBlock

The current implement can fail when the
block size is not a multiple of 8 bytes.
This CL makes it work, and also checks that the
data is in fact a multiple of the block size.

R=agl, agl
CC=golang-dev
https://golang.org/cl/6827058

12 years agocmd/gc: annotate local variables with unique ids for inlining
Russ Cox [Wed, 7 Nov 2012 14:59:19 +0000 (09:59 -0500)]
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

12 years agocmd/gc: fix go:nointerface export comment
Russ Cox [Wed, 7 Nov 2012 14:14:21 +0000 (09:14 -0500)]
cmd/gc: fix go:nointerface export comment

R=ken
CC=golang-dev
https://golang.org/cl/6815073

12 years agonet: fix protocol number for IPv6 test
Mikio Hara [Wed, 7 Nov 2012 12:55:29 +0000 (21:55 +0900)]
net: fix protocol number for IPv6 test

The protocol number of ICMP for IPv6 is 58, not 1.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6810093

12 years agoruntime/race: lazily allocate shadow memory
Dmitriy Vyukov [Wed, 7 Nov 2012 08:48:58 +0000 (12:48 +0400)]
runtime/race: lazily allocate shadow memory
Currently race detector runtime maps shadow memory eagerly at process startup.
It works poorly on Windows, because Windows requires reservation in swap file
(especially problematic if several Go program runs at the same, each consuming GBs
of memory).
With this change race detector maps shadow memory lazily, so Go runtime must notify
about all new heap memory.
It will help with Windows port, but also eliminates scary 16TB virtual mememory
consumption in top output (which sometimes confuses some monitoring scripts).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6811085

12 years agocmd/gc: racewalk: instrument returnsfromheap params
Dmitriy Vyukov [Wed, 7 Nov 2012 08:10:35 +0000 (12:10 +0400)]
cmd/gc: racewalk: instrument returnsfromheap params
Fixes #4307.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6822073

12 years agocmd/gc: racewalk: do not double function calls
Dmitriy Vyukov [Wed, 7 Nov 2012 08:06:27 +0000 (12:06 +0400)]
cmd/gc: racewalk: do not double function calls
Current racewalk transformation looks like:
x := <-makeChan().c
\/\/\/\/\/\/\/\/\/
runtime.raceread(&makeChan().c)
x := <-makeChan().c
and so makeChan() is called twice.
With this CL the transformation looks like:
x := <-makeChan().c
\/\/\/\/\/\/\/\/\/
chan *tmp = &(makeChan().c)
raceread(&*tmp)
x := <-(*tmp)
Fixes #4245.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6822075

12 years agocmd/gc: refactor racewalk
Dmitriy Vyukov [Wed, 7 Nov 2012 08:01:31 +0000 (12:01 +0400)]
cmd/gc: refactor racewalk
It is refactoring towards generic walk
+ it handles mode nodes.
Partially fixes 4228 issue.

R=golang-dev, lvd, rsc
CC=golang-dev
https://golang.org/cl/6775098

12 years agonet: implement IPv6 support for windows
Alex Brainman [Wed, 7 Nov 2012 05:58:20 +0000 (16:58 +1100)]
net: implement IPv6 support for windows

Thank you zhoumichaely for original CL 5175042.

Fixes #1740.
Fixes #2315.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev, zhoumichaely
https://golang.org/cl/6822045

12 years agocrypto/sha1: Make sha-1 do block mixup in place
Carl Mastrangelo [Wed, 7 Nov 2012 02:41:02 +0000 (13:41 +1100)]
crypto/sha1: Make sha-1 do block mixup in place

Benchmarks:

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes          762          674  -11.55%
BenchmarkHash1K             8791         7375  -16.11%
BenchmarkHash8K            65094        54881  -15.69%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes        10.50        11.86    1.13x
BenchmarkHash1K           116.48       138.84    1.19x
BenchmarkHash8K           125.85       149.27    1.19x

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

12 years agoCONTRIBUTORS: Add Carl Mastrangelo (Google CLA).
Ian Lance Taylor [Tue, 6 Nov 2012 23:58:18 +0000 (15:58 -0800)]
CONTRIBUTORS: Add Carl Mastrangelo (Google CLA).

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/6812095

12 years agocmd/6g: fix use of large integers as indexes or array sizes.
Rémy Oudompheng [Tue, 6 Nov 2012 21:53:57 +0000 (22:53 +0100)]
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

12 years agocmd/go: invoke gcc -print-libgcc-file-name only once
Shenghou Ma [Tue, 6 Nov 2012 21:09:54 +0000 (05:09 +0800)]
cmd/go: invoke gcc -print-libgcc-file-name only once

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6741051

12 years agosort: fix comment for various Search routines
Shenghou Ma [Tue, 6 Nov 2012 21:07:46 +0000 (05:07 +0800)]
sort: fix comment for various Search routines
Fixes #4205 (again).

R=r, 0xjnml
CC=golang-dev
https://golang.org/cl/6819082

12 years agonet/rpc: give hint to pass a pointer to Register
Shenghou Ma [Tue, 6 Nov 2012 21:03:16 +0000 (05:03 +0800)]
net/rpc: give hint to pass a pointer to Register
Fixes #4325.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6819081

12 years agocmd/godoc: initialize filesystem and metadata for -url
Péter Surányi [Tue, 6 Nov 2012 20:59:21 +0000 (04:59 +0800)]
cmd/godoc: initialize filesystem and metadata for -url

Unlike when using -http, godoc -url didn't initialize the "filesystem"
and metadata that are used when generating responses. This CL adds this
initialization, so that -url provides the same results as an HTTP
request when using -http.

Fixes #4335.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6817075

12 years agocmd/gc, runtime: avoid unnecessary copy on type assertion.
Daniel Morsing [Tue, 6 Nov 2012 19:40:40 +0000 (20:40 +0100)]
cmd/gc, runtime: avoid unnecessary copy on type assertion.

When the first result of a type assertion is blank, the compiler would still copy out a potentially large non-interface type.

Fixes #1021.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6812079

12 years agotest: fix index.go to pass with recent index checks
Ian Lance Taylor [Tue, 6 Nov 2012 19:38:16 +0000 (11:38 -0800)]
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

12 years agocmd/gc: don't require that slice index constants be small ints
Ian Lance Taylor [Tue, 6 Nov 2012 19:36:59 +0000 (11:36 -0800)]
cmd/gc: don't require that slice index constants be small ints

The test for this is test/index.go, which is not run by
default.

R=remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6812089

12 years agocmd/gc: check for array bounds overflow in slice expression
Ian Lance Taylor [Tue, 6 Nov 2012 19:35:58 +0000 (11:35 -0800)]
cmd/gc: check for array bounds overflow in slice expression

The test for this is test/index.go, which is not run by
default.  That test does not currently pass even after this is
applied, due to issue 4348.

Fixes #4344.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6815085

12 years agoruntime: mark race instrumentation callbacks as nosplitstack
Dmitriy Vyukov [Tue, 6 Nov 2012 16:54:22 +0000 (20:54 +0400)]
runtime: mark race instrumentation callbacks as nosplitstack
It speedups the race detector somewhat, but also prevents
getcallerpc() from obtaining lessstack().

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6812091

12 years agocmd/go: use correct paths with race detector
Dmitriy Vyukov [Tue, 6 Nov 2012 16:11:49 +0000 (20:11 +0400)]
cmd/go: use correct paths with race detector
Currently the build fails with -race if a package in GOPATH
imports another package in GOPATH.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6811083

12 years agoruntime: fix deadlock in parallel for test
Dmitriy Vyukov [Tue, 6 Nov 2012 16:11:16 +0000 (20:11 +0400)]
runtime: fix deadlock in parallel for test
The deadlock occurs when another goroutine requests GC
during the test. When wait=true the test expects physical parallelism,
that is, that P goroutines are all active at the same time.
If GC is requested, then part of the goroutines are not scheduled,
so other goroutines deadlock.
With wait=false, goroutines finish parallel for w/o waiting for all
other goroutines.
Fixes #3954.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6820098

12 years agoruntime: disable parallel for tests under race detector.
Dmitriy Vyukov [Tue, 6 Nov 2012 08:09:40 +0000 (12:09 +0400)]
runtime: disable parallel for tests under race detector.
The race detector does not understand ParFor synchronization, because it's implemented in C.
If run with -cpu=2 currently race detector says:
 WARNING: DATA RACE
 Read by goroutine 5:
  runtime_test.TestParForParallel()
      src/pkg/runtime/parfor_test.go:118 +0x2e0
  testing.tRunner()
      src/pkg/testing/testing.go:301 +0x8f
 Previous write by goroutine 6:
  runtime_test.func·024()
      src/pkg/runtime/parfor_test.go:111 +0x52

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6811082

12 years agoA+C: Péter Surányi (individual CLA)
Andrew Gerrand [Mon, 5 Nov 2012 21:48:27 +0000 (22:48 +0100)]
A+C: Péter Surányi (individual CLA)

R=golang-dev, bradfitz, lvd
CC=golang-dev
https://golang.org/cl/6819089

12 years agocmd/godoc: use normal gofmt printer settings for playground fmt
Andrew Gerrand [Mon, 5 Nov 2012 21:46:28 +0000 (22:46 +0100)]
cmd/godoc: use normal gofmt printer settings for playground fmt

R=gri
CC=golang-dev
https://golang.org/cl/6815081

12 years agonet: fix timeout slack calculation
Shenghou Ma [Sun, 4 Nov 2012 10:07:59 +0000 (18:07 +0800)]
net: fix timeout slack calculation

R=alex.brainman
CC=golang-dev
https://golang.org/cl/6816085

12 years agocmd/5g: improve shift code generation
Dave Cheney [Sun, 4 Nov 2012 09:06:37 +0000 (20:06 +1100)]
cmd/5g: improve shift code generation

This CL is a backport of 6012049 which improves code
generation for shift operations.

benchmark       old ns/op    new ns/op    delta
BenchmarkLSL            9            5  -49.67%
BenchmarkLSR            9            4  -50.00%

R=golang-dev, minux.ma, r, rsc
CC=golang-dev
https://golang.org/cl/6813045

12 years agonet: do not test TestReadWriteDeadline timeout upper bound during short test
Alex Brainman [Sun, 4 Nov 2012 01:41:49 +0000 (12:41 +1100)]
net: do not test TestReadWriteDeadline timeout upper bound during short test

It also increases timeout deltas to allow for longer wait.
Also disables this test on plan9.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6821062

12 years agosort: make return value for 'not found' clearer in docs
Rob Pike [Fri, 2 Nov 2012 23:17:34 +0000 (16:17 -0700)]
sort: make return value for 'not found' clearer in docs
It was well-defined but easy to miss that the return value for
"not found" is len(input) not -1 as many expect.

Fixes #4205.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6820080

12 years agocmd/gc: instrument blocks for race detection.
Rémy Oudompheng [Fri, 2 Nov 2012 23:11:06 +0000 (00:11 +0100)]
cmd/gc: instrument blocks for race detection.

It happens that blocks are used for function calls in a
quite low-level way so they cannot be instrumented as
usual.

Blocks are also used for inlined functions.

R=golang-dev, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/6821068

12 years agonet/http: fix data race in test
Dmitriy Vyukov [Fri, 2 Nov 2012 20:26:36 +0000 (00:26 +0400)]
net/http: fix data race in test
The issue is that server still sends body,
when client closes the fd.
Fixes #4329.

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

12 years agoruntime/cgo, go/build: cgo support for FreeBSD/ARM
Shenghou Ma [Fri, 2 Nov 2012 18:22:37 +0000 (02:22 +0800)]
runtime/cgo, go/build: cgo support for FreeBSD/ARM
This is the last CL for FreeBSD/ARM support.
Also update cmd/ld/doc.go for 5l support of -Hfreebsd.

R=rsc
CC=golang-dev
https://golang.org/cl/6650051

12 years agomisc/benchcmp: show memory statistics, when available
Jeff R. Allen [Fri, 2 Nov 2012 18:13:51 +0000 (02:13 +0800)]
misc/benchcmp: show memory statistics, when available

R=minux.ma, dave, extraterrestrial.neighbour, rsc
CC=golang-dev
https://golang.org/cl/6587069

12 years agonet: add missing locking in windows Shutdown
Alex Brainman [Fri, 2 Nov 2012 09:46:47 +0000 (20:46 +1100)]
net: add missing locking in windows Shutdown

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6811069

12 years agocmd/5g, cmd/6g: fix out of registers with array indexing.
Rémy Oudompheng [Fri, 2 Nov 2012 06:50:59 +0000 (07:50 +0100)]
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

12 years agoimage/png: update palette out-of-bounds comment.
Nigel Tao [Fri, 2 Nov 2012 06:20:19 +0000 (17:20 +1100)]
image/png: update palette out-of-bounds comment.

R=r
CC=golang-dev
https://golang.org/cl/6817070

12 years agospec: we're now at Unicode 6.2.0
Oling Cat [Fri, 2 Nov 2012 05:57:01 +0000 (22:57 -0700)]
spec: we're now at Unicode 6.2.0

R=golang-dev
CC=golang-dev
https://golang.org/cl/6818083

12 years agocmd/gc, cmd/ld: struct field tracking
Russ Cox [Fri, 2 Nov 2012 04:17:21 +0000 (00:17 -0400)]
cmd/gc, cmd/ld: struct field tracking

This is an experiment in static analysis of Go programs
to understand which struct fields a program might use.
It is not part of the Go language specification, it must
be enabled explicitly when building the toolchain,
and it may be removed at any time.

After building the toolchain with GOEXPERIMENT=fieldtrack,
a specific field can be marked for tracking by including
`go:"track"` in the field tag:

        package pkg

        type T struct {
                F int `go:"track"`
                G int // untracked
        }

To simplify usage, only named struct types can have
tracked fields, and only exported fields can be tracked.

The implementation works by making each function begin
with a sequence of no-op USEFIELD instructions declaring
which tracked fields are accessed by a specific function.
After the linker's dead code elimination removes unused
functions, the fields referred to by the remaining
USEFIELD instructions are the ones reported as used by
the binary.

The -k option to the linker specifies the fully qualified
symbol name (such as my/pkg.list) of a string variable that
should be initialized with the field tracking information
for the program. The field tracking string is a sequence
of lines, each terminated by a \n and describing a single
tracked field referred to by the program. Each line is made
up of one or more tab-separated fields. The first field is
the name of the tracked field, fully qualified, as in
"my/pkg.T.F". Subsequent fields give a shortest path of
reverse references from that field to a global variable or
function, corresponding to one way in which the program
might reach that field.

A common source of false positives in field tracking is
types with large method sets, because a reference to the
type descriptor carries with it references to all methods.
To address this problem, the CL also introduces a comment
annotation

        //go:nointerface

that marks an upcoming method declaration as unavailable
for use in satisfying interfaces, both statically and
dynamically. Such a method is also invisible to package
reflect.

Again, all of this is disabled by default. It only turns on
if you have GOEXPERIMENT=fieldtrack set during make.bash.

R=iant, ken
CC=golang-dev
https://golang.org/cl/6749064

12 years agonet: use better error messages on windows
Alex Brainman [Fri, 2 Nov 2012 00:07:22 +0000 (11:07 +1100)]
net: use better error messages on windows

Fixes #4320.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6810064

12 years agogo/ast: document use of Data field for method objects
Robert Griesemer [Thu, 1 Nov 2012 23:27:43 +0000 (16:27 -0700)]
go/ast: document use of Data field for method objects

R=iant
CC=golang-dev
https://golang.org/cl/6775093

12 years agoexp/types: move exp/types/staging -> exp/types
Robert Griesemer [Thu, 1 Nov 2012 22:38:17 +0000 (15:38 -0700)]
exp/types: move exp/types/staging -> exp/types

- removes exp/types/staging
- the only code change is in exp/gotype/gotype.go

R=iant
CC=golang-dev
https://golang.org/cl/6822068

12 years agoexp/types, exp/gotype: remove exp/types
Robert Griesemer [Thu, 1 Nov 2012 22:25:51 +0000 (15:25 -0700)]
exp/types, exp/gotype: remove exp/types

The only code change is in exp/gotype/gotype.go.
The latest reviewed version of exp/types is now
exp/types/staging.

First step toward replacing exp/types with
exp/types/staging.

R=iant
CC=golang-dev
https://golang.org/cl/6819071

12 years agomisc/cgo/test: changes to pass when using gccgo
Ian Lance Taylor [Thu, 1 Nov 2012 20:54:09 +0000 (13:54 -0700)]
misc/cgo/test: changes to pass when using gccgo

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6821067

12 years agocrypto: use better hash benchmarks
Eric Roshan-Eisner [Thu, 1 Nov 2012 20:21:18 +0000 (16:21 -0400)]
crypto: use better hash benchmarks

Labels the existing benchmark as stream, and add benchmarks that
compute the checksum.

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/6814060

12 years agonet: fix race in TestReadWriteDeadline.
Rémy Oudompheng [Thu, 1 Nov 2012 19:52:30 +0000 (20:52 +0100)]
net: fix race in TestReadWriteDeadline.

Discovered by adding OBLOCK support to race
instrumentation.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6819067

12 years agoencoding/binary: skip blank fields when (en/de)coding structs
Robert Griesemer [Thu, 1 Nov 2012 19:39:20 +0000 (12:39 -0700)]
encoding/binary: skip blank fields when (en/de)coding structs

- minor unrelated cleanups
- performance impact in the noise

benchmark                       old ns/op    new ns/op    delta
BenchmarkReadSlice1000Int32s        83462        83346   -0.14%
BenchmarkReadStruct                  4141         4247   +2.56%
BenchmarkReadInts                    1588         1586   -0.13%
BenchmarkWriteInts                   1550         1489   -3.94%
BenchmarkPutUvarint32                  39           39   +1.02%
BenchmarkPutUvarint64                 142          144   +1.41%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkReadSlice1000Int32s        47.93        47.99    1.00x
BenchmarkReadStruct                 16.90        16.48    0.98x
BenchmarkReadInts                   18.89        18.91    1.00x
BenchmarkWriteInts                  19.35        20.15    1.04x
BenchmarkPutUvarint32              101.90       100.82    0.99x
BenchmarkPutUvarint64               56.11        55.45    0.99x

Fixes #4185.

R=r, rsc
CC=golang-dev
https://golang.org/cl/6750053

12 years agobuild: do not run race tests with cgo disabled
Russ Cox [Thu, 1 Nov 2012 19:13:00 +0000 (15:13 -0400)]
build: do not run race tests with cgo disabled

R=dvyukov
CC=golang-dev
https://golang.org/cl/6810067

12 years agocmd/gc: fix build
Dmitriy Vyukov [Thu, 1 Nov 2012 18:59:53 +0000 (22:59 +0400)]
cmd/gc: fix build

R=golang-dev
CC=golang-dev
https://golang.org/cl/6826047