1
0
mirror of https://github.com/golang/go synced 2024-10-03 05:21:22 -06:00
Commit Graph

12373 Commits

Author SHA1 Message Date
Rémy Oudompheng
ce99bb2caf cmd/gc: fix nil pointer dereferences.
Fixes #5119.

R=golang-dev, dvyukov, dave, rsc
CC=golang-dev
https://golang.org/cl/7838050
2013-03-26 08:20:10 +01:00
Dave Cheney
adb9d60cd1 image/gif: make test repeatable
Fixes issue with go test -cpu=1,1

R=minux.ma, bradfitz, nigeltao
CC=golang-dev
https://golang.org/cl/7808045
2013-03-26 16:20:17 +11:00
Julien Schmidt
5e74f5029b database/sql: optimized []byte copy + []byte(nil) -> *interface fix
Make the copy directly in the convert switch instead of an extra loop.
Also stops converting nil-[]byte to zero-[]byte when assigning to *interface

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7962044
2013-03-25 17:43:30 -07:00
Brad Fitzpatrick
eee3e63607 database/sql: link to driver wiki page
Fixes #5127

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/8011044
2013-03-25 17:38:51 -07:00
Brad Fitzpatrick
209f6b1d2c database/sql: don't close a driver.Conn until its Stmts are closed
Fixes #5046

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8016044
2013-03-25 16:50:27 -07:00
Adam Langley
f20f8b8b0a crypto/rsa: don't correct private exponent unless needed.
At some point in the past, I believe the GCD algorithm was setting d to
be negative. The RSA code has been correcting that ever since but, now,
it appears to have changed and the correction isn't needed.

Having d be too large is harmless, it's just a little odd and I
happened to notice.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7948044
2013-03-25 19:08:29 -04:00
Ian Lance Taylor
5a529b61aa cmd/ld: permit sym to be both cgo_export_static and cgo_export_dynamic
Fixes SWIG callbacks.  Previously crosscall2 was only
cgo_export_static, despite the use of two #pragma declarations
in runtime/cgo/callbacks.c.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/7817048
2013-03-25 15:37:54 -07:00
Russ Cox
6a70f9d073 runtime: pass setmg function to cgo_init
This keeps the logic about how to set the thread-local variables
m and g in code compiled and linked by the gc toolchain,
an important property for upcoming cgo changes.

It's also just a nice cleanup: one less place to update when
these details change.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7560048
2013-03-25 18:14:02 -04:00
Russ Cox
cb807e7b4a runtime: delete mkasmh.sh
This functionality moved into cmd/dist for Go 1.0.
Changes to this script have no effect.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8020043
2013-03-25 17:46:11 -04:00
Rémy Oudompheng
c0b3c17184 cmd/gc: instrument logical && and ||.
The right operand of a && and || is only executed conditionnally,
so the instrumentation must be more careful. In particular
it should not turn nodes assumed to be cheap after walk into
expensive ones.

Update #4228

R=dvyukov, golang-dev
CC=golang-dev
https://golang.org/cl/7986043
2013-03-25 22:12:47 +01:00
Carl Shapiro
4cb921bbf1 runtime: store asmcgocall return PC where the ARM unwind expects it
The ARM implementation of runtime.cgocallback_gofunc diverged
from the calling convention by leaving a word of garbage at
the top of the stack and storing the return PC above the
locals.  This change stores the return PC at the top of the
stack and removes the save area above the locals.

Update #5124
This CL fixes first part of the ARM issues and added the unwind test.

R=golang-dev, bradfitz, minux.ma, cshapiro, rsc
CC=golang-dev
https://golang.org/cl/7728045
2013-03-25 14:10:28 -07:00
Rémy Oudompheng
d815a14718 cmd/5l, cmd/6l, cmd/8l: fix segfault on reading LOCALS for a duplicate definition.
Fixes #5105.

R=golang-dev, dave, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/7965043
2013-03-25 22:09:55 +01:00
Russ Cox
60a1f54d6b math: make Hypot special cases look like others
The edit makes Hypot's description match the form
used in the other routines in this package.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/8003046
2013-03-25 17:01:40 -04:00
Jan Ziak
bf1f46180e runtime: optionally check all allocations in hashmap.c
Adds the new debugging constant 'checkgc'. If its value is non-zero
all calls to mallocgc() from hashmap.c will start a garbage collection.

Fixes #5074.

R=golang-dev, khr
CC=golang-dev, rsc
https://golang.org/cl/7663051
2013-03-25 21:35:46 +01:00
Dmitriy Vyukov
ea15104110 net: band-aid for windows network poller
Fixes performance of the current windows network poller
with the new scheduler.
Gives runtime a hint when GetQueuedCompletionStatus() will block.
Fixes #5068.

benchmark                    old ns/op    new ns/op    delta
BenchmarkTCP4Persistent        4004000        33906  -99.15%
BenchmarkTCP4Persistent-2        21790        17513  -19.63%
BenchmarkTCP4Persistent-4        44760        34270  -23.44%
BenchmarkTCP4Persistent-6        45280        43000   -5.04%

R=golang-dev, alex.brainman, coocood, rsc
CC=golang-dev
https://golang.org/cl/7612045
2013-03-25 20:57:36 +04:00
Oling Cat
1693e14bc4 math: modify a comment to the convention format.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/8012043
2013-03-25 08:43:51 -07:00
Rémy Oudompheng
77e7e4c329 cmd/cc, cmd/ld: do not overflow strings in symbol lookup.
R=golang-dev, dave, minux.ma
CC=golang-dev
https://golang.org/cl/7876044
2013-03-25 08:20:22 +01:00
Rémy Oudompheng
3add0fef1e net/http: deflake BenchmarkServerFakeConnNoKeepAlive.
Fixes #5121.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7814046
2013-03-25 08:17:10 +01:00
Mikio Hara
2f2f9fef90 net: disable tests with controlling network facilities in short mode
Perhaps it would make FreeBSD 10-CURRENT/ARM on Raspberry Pi builders happy.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/8008043
2013-03-25 13:25:28 +09:00
Alex Brainman
77fb0c17df all.bat,make.bat,run.bat: make these work even when directory has space in it
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7510048
2013-03-25 12:13:34 +11:00
Shenghou Ma
976d99b9a8 build, cmd/5l: actually report failures for -linkmode tests
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7938046
2013-03-25 03:18:05 +08:00
Rémy Oudompheng
a909e4ba1e cmd/cc: fix typo leading to index out of range.
Detected by GCC static analysis.

Fixes #5117.

R=golang-dev, ality, minux.ma
CC=golang-dev
https://golang.org/cl/7665047
2013-03-24 11:38:57 +01:00
Shenghou Ma
0a517e458c build: increase timeout for ARM
in an effort to make builder freebsd-arm-pi and netbsd-arm-qemu pass again.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7621050
2013-03-24 16:31:28 +08:00
Rémy Oudompheng
a3c2d62a9a cmd/5l, cmd/6l, cmd/8l: remove declaration on non-existent variables.
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7985043
2013-03-24 08:55:08 +01:00
Mikio Hara
bfb32dc6d1 net: use original raddr if getpeername fails
This CL updates CL 7511043;
- adds new test cases for both UDPConn and UnixConn,
- makes sure unnamed UnixAddr handling,
- replaces t.Errorf with t.Fatalf in sockname related test cases.

Fixes #3721 (again).
Fixes #3838 (again).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7627048
2013-03-23 22:32:19 +09:00
Mikio Hara
aa0dda767a net: support IPv6 scoped addressing zone
This CL provides IPv6 scoped addressing zone support as defined
in RFC 4007 for internet protocol family connection setups.

Follwoing types and functions allow a literal IPv6 address with
zone identifer as theirs parameter.

pkg net, func Dial(string, string) (Conn, error)
pkg net, func DialOpt(string, ...DialOption) (Conn, error)
pkg net, func DialTimeout(string, string, time.Duration) (Conn, error)
pkg net, func Listen(string, string) (Listener, error)
pkg net, func ListenPacket(string, string) (PacketConn, error)
pkg net, func ResolveIPAddr(string, string) (*IPAddr, error)
pkg net, func ResolveTCPAddr(string, string) (*TCPAddr, error)
pkg net, func ResolveUDPAddr(string, string) (*UDPAddr, error)
pkg net, type IPAddr struct, Zone string
pkg net, type TCPAddr struct, Zone string
pkg net, type UDPAddr struct, Zone string

Also follwoing methods return a literal IPv6 address with zone
identifier string if possible.

pkg net, method (*IPAddr) String() string
pkg net, method (*TCPAddr) String() string
pkg net, method (*UDPAddr) String() string

Fixes #4234.
Fixes #4501.
Update #5081.

R=rsc, iant
CC=golang-dev
https://golang.org/cl/6816116
2013-03-23 09:57:40 +09:00
Ian Lance Taylor
c90850277b runtime: remove declaration of non-existent function
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/7577049
2013-03-22 17:52:55 -07:00
Ian Lance Taylor
fb7f217fe7 runtime: correct misplaced right brace in Linux SIGBUS handling
I'm not sure how to write a test for this.  The change in
behaviour is that if you somehow get a SIGBUS signal for an
address >= 0x1000, the program will now crash rather than
calling panic.  As far as I know, on x86 GNU/Linux, the only
way to get a SIGBUS (rather than a SIGSEGV) is to set the
stack pointer to an invalid value.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7906045
2013-03-22 17:32:04 -07:00
Mikio Hara
8b6d501704 net: fix documentation for UnixAddr
Also simplifies ResolveUnixAddr.

R=golang-dev, dave, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/7510047
2013-03-23 07:39:43 +09:00
Russ Cox
ba0dd1f139 cmd/gc: fix line number for 'missing return' in closure
R=ken2
CC=golang-dev
https://golang.org/cl/7838048
2013-03-22 17:50:29 -04:00
Russ Cox
228fe9d057 cmd/vet: diagnose unreachable code
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7493048
2013-03-22 17:46:45 -04:00
Russ Cox
f6d0adedb6 build: remove dead code
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7877045
2013-03-22 17:28:22 -04:00
Rob Pike
f29b091110 encoding/gob: delete dead code.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7834047
2013-03-22 14:22:55 -07:00
Shenghou Ma
092b7cfb08 runtime/cgo, go/build: re-enable cgo for FreeBSD/ARM.
R=dave, rsc
CC=golang-dev
https://golang.org/cl/7970043
2013-03-23 03:21:30 +08:00
Julien Schmidt
81d26e3817 database/sql: add missing []byte and RawBytes conversions
E.g conversions from numeric types to RawBytes are missing, what makes RawBytes unusable in some cases.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7783046
2013-03-22 12:19:21 -07:00
Russ Cox
b5cfbda212 cmd/vet: add assembly checker
Fixes #5036.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7531045
2013-03-22 15:14:40 -04:00
Russ Cox
07720b67b3 build: update assembly variable names for vet
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7834046
2013-03-22 12:57:55 -04:00
Russ Cox
dabe51065c crypto/cipher: fix vet warning
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7973043
2013-03-22 12:57:34 -04:00
Jeff R. Allen
87700cf75d image/gif: reject a GIF image if frame bounds larger than image bounds
The GIF89a spec says: "Each image must fit within the
boundaries of the Logical Screen, as defined in the
Logical Screen Descriptor." Also, do not accept
GIFs which have too much data for the image size.

R=nigeltao, jra, r
CC=bradfitz, golang-dev
https://golang.org/cl/7602045
2013-03-22 09:30:31 -07:00
Joel Sing
3b9702c9c8 runtime: correct return value checks for mmap on darwin/freebsd
On Darwin and FreeBSD, the mmap syscall return value is returned
unmodified. This means that the return value will either be a
valid address or a positive error number.

Also check return value from mmap in SysReserve - the callers of
SysReserve expect nil to be returned if the allocation failed.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7871043
2013-03-23 02:17:01 +11:00
Joel Sing
28f65bf4a2 runtime: improve mmap return value checking for netbsd/openbsd
Rather than just checking for ENOMEM, check for a return value of less
than 4096, so that we catch other errors such as EACCES and EINVAL.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7942043
2013-03-23 02:15:52 +11:00
Oling Cat
79ae1ad489 math: remove repeated comment.
R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/7835046
2013-03-22 14:54:20 +11:00
Nigel Tao
f308efd869 image/gif: tighten the checks for when the amount of an image's pixel
data does not agree with its bounds.

R=r, jeff.allen
CC=golang-dev
https://golang.org/cl/7938043
2013-03-22 14:42:02 +11:00
Miki Tebeka
0ffdfe42d1 cmd/cgo: fix the cgo example on multiple assignment context.
Change from atoi to strtol since atoi does not set errno.

R=golang-dev, minux.ma, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/7888047
2013-03-21 20:06:25 -07:00
Brad Fitzpatrick
985b0992cd net/http: reuse bufio.Reader and bufio.Writer between conns
Saves over 8KB of allocations per new connection.

benchmark                             old ns/op    new ns/op    delta
BenchmarkServerFakeConnNoKeepAlive        28777        24927  -13.38%

benchmark                            old allocs   new allocs    delta
BenchmarkServerFakeConnNoKeepAlive           52           46  -11.54%

benchmark                             old bytes    new bytes    delta
BenchmarkServerFakeConnNoKeepAlive        13716         5286  -61.46%

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7799047
2013-03-21 20:02:01 -07:00
Brad Fitzpatrick
dc71ace282 bufio: add some tests
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7927044
2013-03-21 19:59:49 -07:00
Rémy Oudompheng
5060dded0f debug/elf: repair GNU version symbols.
After the revert of revision 9ea9e7e6e0c8
the related revision 76ff7da868c6 must be reverted too.

Fixes #5102.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7961044
2013-03-22 01:27:55 +01:00
Rémy Oudompheng
88b98ff791 cmd/gc: accept ideal float as indices.
Fixes #4813.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/7625050
2013-03-22 00:38:23 +01:00
Robert Griesemer
5e6a1a3f48 go/doc: use regexp for -notes instead of comma-sep. list
-notes="BUG|TODO" instead of -notes="BUG,TODO".
Permits -notes=".*" to see all notes.

R=cnicolaou
CC=golang-dev
https://golang.org/cl/7951043
2013-03-21 15:56:15 -07:00
Rob Pike
5bbdf40544 bufio.Scanner: delete obsolete TODO
Also fix the examples to use stderr for errors.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7716052
2013-03-21 14:56:42 -07:00
Brad Fitzpatrick
d7c1f67cb9 net/http/fcgi: fix a shutdown race
If a handler didn't consume all its Request.Body, child.go was
closing the socket while the host was still writing to it,
causing the child to send a RST and the host (at least nginx)
to send an empty response body.

Now, we tell the host we're done with the request/response
first, and then close our input pipe after consuming a bit of
it. Consuming the body fixes the problem, and flushing to the
host first to tell it that we're done increases the chance
that the host cuts off further data to us, meaning we won't
have much to consume.

No new tests, because this package is lacking in tests.
Tested by hand with nginx.  See issue for testing details.

Fixes #4183

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7939045
2013-03-21 14:07:24 -07:00
Russ Cox
aafc444b74 debug/elf: restore Go 1.0 semantics for (*File).Symbols
Also adjust the implementation of applyRelocationsAMD64
so that the test added in CL 6848044 still passes.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7686049
2013-03-21 17:01:39 -04:00
Russ Cox
3be703665e reflect: implement method values
Fixes #1517.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7906043
2013-03-21 16:59:16 -04:00
Russ Cox
b505ff6279 crypto/rc4: faster amd64 implementation
XOR key into data 128 bits at a time instead of 64 bits
and pipeline half of state loads. Rotate loop to allow
single-register indexing for state[i].

On a MacBookPro10,2 (Core i5):

benchmark           old ns/op    new ns/op    delta
BenchmarkRC4_128          412          224  -45.63%
BenchmarkRC4_1K          3179         1613  -49.26%
BenchmarkRC4_8K         25223        12545  -50.26%

benchmark            old MB/s     new MB/s  speedup
BenchmarkRC4_128       310.51       570.42    1.84x
BenchmarkRC4_1K        322.09       634.48    1.97x
BenchmarkRC4_8K        320.97       645.32    2.01x

For comparison, on the same machine, openssl 0.9.8r reports
its rc4 speed as somewhat under 350 MB/s for both 1K and 8K
(it is operating 64 bits at a time).

On an Intel Xeon E5520:

benchmark           old ns/op    new ns/op    delta
BenchmarkRC4_128          418          259  -38.04%
BenchmarkRC4_1K          3200         1884  -41.12%
BenchmarkRC4_8K         25173        14529  -42.28%

benchmark            old MB/s     new MB/s  speedup
BenchmarkRC4_128       306.04       492.48    1.61x
BenchmarkRC4_1K        319.93       543.26    1.70x
BenchmarkRC4_8K        321.61       557.20    1.73x

For comparison, on the same machine, openssl 1.0.1
reports its rc4 speed as 587 MB/s for 1K and 601 MB/s for 8K.

R=agl
CC=golang-dev
https://golang.org/cl/7865046
2013-03-21 16:38:57 -04:00
Shenghou Ma
d04ac4b0b7 cmd/ld: portability fixes
fix code that implicitly assumes little-endian machines.

R=golang-dev, bradfitz, rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/6792043
2013-03-22 04:00:54 +08:00
Shenghou Ma
a891b916bd cmd/ld: don't generate DW_AT_type attr for unsafe.Pointer to match gcc behavior
gcc generates only attr DW_AT_byte_size for DW_TAG_pointer_type of "void *",
but we used to also generate DW_AT_type pointing to imaginary unspecified
type "void", which confuses some gdb.
This change makes old Apple gdb 6.x (specifically, Apple version gdb-1515)
accepts our binary without issue like this:
(gdb) b 'main.main'
Die: DW_TAG_unspecified_type (abbrev = 10, offset = 47079)
    has children: FALSE
    attributes:
        DW_AT_name (DW_FORM_string) string: "void"
Dwarf Error: Cannot find type of die [in module /Users/minux/go/go2.hg/bin/go]

Special thanks to Russ Cox for pointing out the problem in comment #6 of
CL 7891044.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7744051
2013-03-22 03:58:35 +08:00
Shenghou Ma
f74b4d3de3 cmd/ld: fix bad merge
CL 7504044 accidentally reverted part of CL 7891044 and 7552045, this CL
bring those part back.

R=golang-dev
TBR=rsc
CC=golang-dev
https://golang.org/cl/7950045
2013-03-22 03:54:14 +08:00
Jan Ziak
ec8caf696a runtime: mark strings without going through an intermediate buffer
R=rsc
CC=golang-dev
https://golang.org/cl/7949043
2013-03-21 19:00:02 +01:00
Robert Griesemer
e95c41f30b go/format: fix documentation
R=r
CC=golang-dev
https://golang.org/cl/7920048
2013-03-21 08:47:34 -07:00
Russ Cox
2f32138aba crypto/sha1: faster amd64, 386 implementations
-- amd64 --

On a MacBookPro10,2 (Core i5):

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes          785          592  -24.59%
BenchmarkHash1K             8727         3014  -65.46%
BenchmarkHash8K            64926        20723  -68.08%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes        10.19        13.50    1.32x
BenchmarkHash1K           117.34       339.71    2.90x
BenchmarkHash8K           126.17       395.31    3.13x

For comparison, on the same machine, openssl 0.9.8r reports
its sha1 speed as 341 MB/s for 1K and 404 MB/s for 8K.

On an Intel Xeon E5520:

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes          984          707  -28.15%
BenchmarkHash1K            11141         3466  -68.89%
BenchmarkHash8K            82435        23411  -71.60%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes         8.13        11.31    1.39x
BenchmarkHash1K            91.91       295.36    3.21x
BenchmarkHash8K            99.37       349.91    3.52x

For comparison, on the same machine, openssl 1.0.1 reports
its sha1 speed as 286 MB/s for 1K and 394 MB/s for 8K.

-- 386 --

On a MacBookPro10,2 (Core i5):

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes         1041          713  -31.51%
BenchmarkHash1K            15612         3382  -78.34%
BenchmarkHash8K           110152        22733  -79.36%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes         7.68        11.21    1.46x
BenchmarkHash1K            65.59       302.76    4.62x
BenchmarkHash8K            74.37       360.36    4.85x

On an Intel Xeon E5520:

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes         1221          842  -31.04%
BenchmarkHash1K            14643         4137  -71.75%
BenchmarkHash8K           108722        27394  -74.80%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes         6.55         9.49    1.45x
BenchmarkHash1K            69.93       247.51    3.54x
BenchmarkHash8K            75.35       299.04    3.97x

R=agl, dave
CC=golang-dev
https://golang.org/cl/7763049
2013-03-21 11:32:02 -04:00
Russ Cox
25cbd534df crypto/md5: faster amd64, 386 implementations
-- amd64 --

On a MacBookPro10,2 (Core i5):

benchmark                       old ns/op    new ns/op    delta
BenchmarkHash8Bytes                   471          524  +11.25%
BenchmarkHash1K                      3018         2220  -26.44%
BenchmarkHash8K                     20634        14604  -29.22%
BenchmarkHash8BytesUnaligned          468          523  +11.75%
BenchmarkHash1KUnaligned             3006         2212  -26.41%
BenchmarkHash8KUnaligned            20820        14652  -29.63%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkHash8Bytes                 16.98        15.26    0.90x
BenchmarkHash1K                    339.26       461.19    1.36x
BenchmarkHash8K                    397.00       560.92    1.41x
BenchmarkHash8BytesUnaligned        17.08        15.27    0.89x
BenchmarkHash1KUnaligned           340.65       462.75    1.36x
BenchmarkHash8KUnaligned           393.45       559.08    1.42x

For comparison, on the same machine, openssl 0.9.8r reports
its md5 speed as 350 MB/s for 1K and 410 MB/s for 8K.

On an Intel Xeon E5520:

benchmark                       old ns/op    new ns/op    delta
BenchmarkHash8Bytes                   565          607   +7.43%
BenchmarkHash1K                      3753         2475  -34.05%
BenchmarkHash8K                     25945        16250  -37.37%
BenchmarkHash8BytesUnaligned          559          594   +6.26%
BenchmarkHash1KUnaligned             3754         2474  -34.10%
BenchmarkHash8KUnaligned            26011        16359  -37.11%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkHash8Bytes                 14.15        13.17    0.93x
BenchmarkHash1K                    272.83       413.58    1.52x
BenchmarkHash8K                    315.74       504.11    1.60x
BenchmarkHash8BytesUnaligned        14.31        13.46    0.94x
BenchmarkHash1KUnaligned           272.73       413.78    1.52x
BenchmarkHash8KUnaligned           314.93       500.73    1.59x

For comparison, on the same machine, openssl 1.0.1 reports
its md5 speed as 443 MB/s for 1K and 513 MB/s for 8K.

-- 386 --

On a MacBookPro10,2 (Core i5):

benchmark                       old ns/op    new ns/op    delta
BenchmarkHash8Bytes                   602          670  +11.30%
BenchmarkHash1K                      4038         2549  -36.87%
BenchmarkHash8K                     27879        16690  -40.13%
BenchmarkHash8BytesUnaligned          602          670  +11.30%
BenchmarkHash1KUnaligned             4025         2546  -36.75%
BenchmarkHash8KUnaligned            27844        16692  -40.05%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkHash8Bytes                 13.28        11.93    0.90x
BenchmarkHash1K                    253.58       401.69    1.58x
BenchmarkHash8K                    293.83       490.81    1.67x
BenchmarkHash8BytesUnaligned        13.27        11.94    0.90x
BenchmarkHash1KUnaligned           254.40       402.05    1.58x
BenchmarkHash8KUnaligned           294.21       490.77    1.67x

On an Intel Xeon E5520:

benchmark                       old ns/op    new ns/op    delta
BenchmarkHash8Bytes                   752          716   -4.79%
BenchmarkHash1K                      5307         2799  -47.26%
BenchmarkHash8K                     36993        18042  -51.23%
BenchmarkHash8BytesUnaligned          748          730   -2.41%
BenchmarkHash1KUnaligned             5301         2795  -47.27%
BenchmarkHash8KUnaligned            36983        18085  -51.10%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkHash8Bytes                 10.64        11.16    1.05x
BenchmarkHash1K                    192.93       365.80    1.90x
BenchmarkHash8K                    221.44       454.03    2.05x
BenchmarkHash8BytesUnaligned        10.69        10.95    1.02x
BenchmarkHash1KUnaligned           193.15       366.36    1.90x
BenchmarkHash8KUnaligned           221.51       452.96    2.04x

R=agl
CC=golang-dev
https://golang.org/cl/7621049
2013-03-21 11:26:00 -04:00
Russ Cox
1af960802a crypto/rc4: faster amd64, 386 implementations
-- amd64 --

On a MacBookPro10,2 (Core i5):

benchmark           old ns/op    new ns/op    delta
BenchmarkRC4_128          470          421  -10.43%
BenchmarkRC4_1K          3123         3275   +4.87%
BenchmarkRC4_8K         26351        25866   -1.84%

benchmark            old MB/s     new MB/s  speedup
BenchmarkRC4_128       272.22       303.40    1.11x
BenchmarkRC4_1K        327.80       312.58    0.95x
BenchmarkRC4_8K        307.24       313.00    1.02x

For comparison, on the same machine, openssl 0.9.8r reports
its rc4 speed as somewhat under 350 MB/s for both 1K and 8K.
The Core i5 performance can be boosted another 20%, but only
by making the Xeon performance significantly slower.

On an Intel Xeon E5520:

benchmark           old ns/op    new ns/op    delta
BenchmarkRC4_128          774          417  -46.12%
BenchmarkRC4_1K          6121         3200  -47.72%
BenchmarkRC4_8K         48394        25151  -48.03%

benchmark            old MB/s     new MB/s  speedup
BenchmarkRC4_128       165.18       306.84    1.86x
BenchmarkRC4_1K        167.28       319.92    1.91x
BenchmarkRC4_8K        167.29       321.89    1.92x

For comparison, on the same machine, openssl 1.0.1
(which uses a different implementation than 0.9.8r)
reports its rc4 speed as 587 MB/s for 1K and 601 MB/s for 8K.
It is using SIMD instructions to do more in parallel.

So there's still some improvement to be had, but even so,
this is almost 2x faster than what it replaced.

-- 386 --

On a MacBookPro10,2 (Core i5):

benchmark           old ns/op    new ns/op    delta
BenchmarkRC4_128         3491          421  -87.94%
BenchmarkRC4_1K         28063         3205  -88.58%
BenchmarkRC4_8K        220392        25228  -88.55%

benchmark            old MB/s     new MB/s  speedup
BenchmarkRC4_128        36.66       303.81    8.29x
BenchmarkRC4_1K         36.49       319.42    8.75x
BenchmarkRC4_8K         36.73       320.90    8.74x

On an Intel Xeon E5520:

benchmark           old ns/op    new ns/op    delta
BenchmarkRC4_128         2268          524  -76.90%
BenchmarkRC4_1K         18161         4137  -77.22%
BenchmarkRC4_8K        142396        32350  -77.28%

benchmark            old MB/s     new MB/s  speedup
BenchmarkRC4_128        56.42       244.13    4.33x
BenchmarkRC4_1K         56.38       247.46    4.39x
BenchmarkRC4_8K         56.86       250.26    4.40x

R=agl
CC=golang-dev
https://golang.org/cl/7547050
2013-03-21 11:25:09 -04:00
Dmitriy Vyukov
44840786ae runtime: explicitly remove fd's from epoll waitset before close()
Fixes #5061.

Current code relies on the fact that fd's are automatically removed from epoll set when closed. However, it is not true. Underlying file description is removed from epoll set only when *all* fd's referring to it are closed.

There are 2 bad consequences:
1. Kernel delivers notifications on already closed fd's.
2. The following sequence of events leads to error:
   - add fd1 to epoll
   - dup fd1 = fd2
   - close fd1 (not removed from epoll since we've dup'ed the fd)
   - dup fd2 = fd1 (get the same fd as fd1)
   - add fd1 to epoll = EEXIST

So, if fd can be potentially dup'ed of fork'ed, it's necessary to explicitly remove the fd from epoll set.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/7870043
2013-03-21 12:54:19 +04:00
Dmitriy Vyukov
d4c80d19a8 runtime: faster parallel GC
Use per-thread work buffers instead of global mutex-protected pool. This eliminates contention from parallel scan phase.

benchmark                             old ns/op    new ns/op    delta
garbage.BenchmarkTree2-8               97100768     71417553  -26.45%
garbage.BenchmarkTree2LastPause-8     970931485    714103692  -26.45%
garbage.BenchmarkTree2Pause-8         469127802    345029253  -26.45%
garbage.BenchmarkParser-8            2880950854   2715456901   -5.74%
garbage.BenchmarkParserLastPause-8    137047399    103336476  -24.60%
garbage.BenchmarkParserPause-8         80686028     58922680  -26.97%

R=golang-dev, 0xe2.0x9a.0x9b, dave, adg, rsc, iant
CC=golang-dev
https://golang.org/cl/7816044
2013-03-21 12:48:02 +04:00
Rémy Oudompheng
656bc3eb96 cmd/gc: implement more cases in racewalk.
Add missing CLOSUREVAR in switch.
Mark MAKE, string conversion nodes as impossible.
Control statements do not need instrumentation.
Instrument COM and LROT nodes.
Instrument map length.

Update #4228

R=dvyukov, golang-dev
CC=golang-dev
https://golang.org/cl/7504047
2013-03-21 08:53:52 +01:00
Brad Fitzpatrick
76d5e2ce7d crypto/tls: use method values
Currently fails with a compiler error, though.

R=golang-dev, agl, rsc
CC=golang-dev
https://golang.org/cl/7933043
2013-03-20 23:53:38 -04:00
Russ Cox
38e9b0773d cmd/gc: fix escape analysis of method values
R=ken2
CC=golang-dev
https://golang.org/cl/7518050
2013-03-20 23:53:27 -04:00
Robert Griesemer
0ad265d48f src/pkg: fixed various typos
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7936043
2013-03-20 16:32:37 -07:00
Keith Randall
bcb39a778c runtime: free map structures more aggressively
R=rsc, bradfitz, khr
CC=golang-dev
https://golang.org/cl/7849047
2013-03-20 15:38:51 -07:00
Robert Griesemer
5ae4012b64 go/parser: use method values
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7858045
2013-03-20 15:03:30 -07:00
Keith Randall
db53d97ac4 runtime: Use aligned loads for AES key schedule.
R=rsc, minux.ma, khr
CC=golang-dev
https://golang.org/cl/7763050
2013-03-20 14:34:26 -07:00
Russ Cox
a63d5dd118 cmd/gc: add OCHECKNOTNIL to race walker (fix build)
TBR=dvyukov
CC=golang-dev
https://golang.org/cl/7635046
2013-03-20 17:20:32 -04:00
Daniel Morsing
7c3694c4de cmd/gc: reject methods on non-locals, even if symbol exists
Fixes #5089.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7767044
2013-03-20 22:18:20 +01:00
Russ Cox
d3c758d7d2 cmd/gc: implement method values
R=ken2, ken
CC=golang-dev
https://golang.org/cl/7546052
2013-03-20 17:11:09 -04:00
Keith Randall
00224a356a runtime: faster hashmap implementation.
Hashtable is arranged as an array of
8-entry buckets with chained overflow.
Each bucket has 8 extra hash bits
per key to provide quick lookup within
a bucket.  Table is grown incrementally.

Update #3885
Go time drops from 0.51s to 0.34s.

R=r, rsc, m3b, dave, bradfitz, khr, ugorji, remyoudompheng
CC=golang-dev
https://golang.org/cl/7504044
2013-03-20 13:51:29 -07:00
Jan Ziak
2001f0c28e runtime: prevent garbage collection during hashmap insertion (fix 2)
Fixes #5074 in multi-threaded scenarios.

R=golang-dev, daniel.morsing, dave, dvyukov, bradfitz, rsc
CC=golang-dev, remyoudompheng
https://golang.org/cl/7916043
2013-03-20 20:36:33 +01:00
Brad Fitzpatrick
bd21f7f1b5 net/http/fcgi: Request.Body should always be non-nil
Found this inconsistency from net/http's Server while
debugging Issue 4183

Unfortunately this package lacks testing around this,
or most of child.go. :/

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7735046
2013-03-20 09:06:33 -07:00
Dave Cheney
f701e1c320 cmd/6c, cmd/8c: fix stack allocated Biobuf leaking at exit
Fixes #5085.

{6,8}c/swt.c allocates a third Biobuf in automatic memory which is not terminated at the end of the function. This causes the buffer to be 'in use' when the batexit handler fires, confusing valgrind.

Huge thanks to DMorsing for the diagnosis.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/7844044
2013-03-20 23:42:00 +11:00
Rémy Oudompheng
b35019fe9a cmd/ld: remove remaining occurrence of isobj.
Fixes cgo builds.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7784044
2013-03-20 08:32:11 +01:00
Brad Fitzpatrick
1ce0d72fdf net/http: new benchmark to measure server without network
No net package involved. And with ReportAllocs we can see
how much garbage is created per request.

R=adg, dave
CC=golang-dev
https://golang.org/cl/7913044
2013-03-19 23:32:28 -07:00
Dave Cheney
85773e6bc2 cmd/5l: fix arm build
Fixes build. One part of ../misc/cgo/test appears to be unhappy but this does not cause the build to fail.

R=rsc, r
CC=golang-dev
https://golang.org/cl/7769047
2013-03-20 12:05:52 +11:00
Rémy Oudompheng
465ff4cfc0 cmd/gc: implement revised rule for shifts in equality.
R=rsc, daniel.morsing
CC=golang-dev
https://golang.org/cl/7613046
2013-03-20 00:19:11 +01:00
Rob Pike
1b6b1bc66e bytes,strings: remove user name from BUG in comment
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7856048
2013-03-19 15:04:18 -07:00
Jan Ziak
54dffda2b6 runtime: prevent garbage collection during hashmap insertion
Inserting a key-value pair into a hashmap storing keys or values
indirectly can cause the garbage collector to find the hashmap in
an inconsistent	state.

Fixes #5074.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7913043
2013-03-19 22:17:39 +01:00
Ian Lance Taylor
b79afe1b71 debug/dwarf: support for DWARF 3
R=rsc
CC=golang-dev
https://golang.org/cl/7662045
2013-03-19 13:59:37 -07:00
Russ Cox
47ce4bd353 cmd/ld: fix typo
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7552045
2013-03-19 16:53:07 -04:00
Russ Cox
40d356e9ab cmd/ld: generate relocated DWARF in hostobj mode
While we're here, downgrade DWARF to version 2.
We're not using any version 3 features, and OS X gdb
only supports version 2.

Fixes #3436.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7891044
2013-03-19 16:31:52 -04:00
Russ Cox
b4f3533c92 cmd/ld: replace -hostobj with -linkmode
Still disabled. Need to fix TLS.

R=golang-dev, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/7783044
2013-03-19 15:45:42 -04:00
Jan Ziak
ab08eac5b7 runtime: optimize calls to addroot()
R=golang-dev, rsc
CC=dvyukov, golang-dev
https://golang.org/cl/7879043
2013-03-19 19:57:15 +01:00
Jan Ziak
6e69df6102 cmd/gc: support channel types in the garbage collector
R=golang-dev, dvyukov, rsc
CC=golang-dev
https://golang.org/cl/7473044
2013-03-19 19:51:03 +01:00
Oling Cat
d8714ca49f unicode: modify a comment to the convention format.
R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/7869043
2013-03-19 14:47:41 -04:00
Robert Griesemer
5268119f26 go/doc, godoc: improved note reading
- A note doesn't have to be in the first
comment of a comment group anymore, and
several notes may appear in the same comment
group (e.g., it is fairly common to have a
TODO(uid) note immediately following another
comment).

- Define a doc.Note type which also contains
note uid and position info.

- Better formatting in godoc output. The position
information is not yet used, but could be used to
locate the note in the source text if desired.

Fixes #4843.

R=r, cnicolaou
CC=gobot, golang-dev
https://golang.org/cl/7496048
2013-03-19 11:14:35 -07:00
Oling Cat
a88d82813d unicode: remove an extra space
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7856044
2013-03-19 13:48:07 -04:00
Mikio Hara
4aeb0fc0a4 runtime: add missing copyright
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7884045
2013-03-20 02:40:29 +09:00
Mikio Hara
3560f3b9b8 net: make use of reflect.DeepEqual in IP manipulation tests
Also applies camel style to test case holders.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7884043
2013-03-20 01:07:18 +09:00
Mikio Hara
5ccb769112 cmd/fix: revert IPv6 scoped address zone support of IPNet
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7554051
2013-03-20 01:05:16 +09:00
Rémy Oudompheng
51f14a9fe2 runtime: fix erroneous overflow protection on netbsd/openbsd semasleep.
On NetBSD tv_sec is already an int64 so no need for a test.

On OpenBSD, semasleep expects a Unix time as argument,
and 1<<30 is in 2004.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7810044
2013-03-19 07:08:26 +01:00
Brad Fitzpatrick
646e54106d database/sql: doc cleanup on the DB type
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7865044
2013-03-18 15:54:22 -07:00
Brad Fitzpatrick
3a2fe62f44 database/sql: add DB.SetMaxIdleConns
Update #4805

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7634045
2013-03-18 15:33:04 -07:00
Daniel Morsing
2667dcd113 cmd/gc: steal escape analysis info when inlining
Usually, there is no esc info when inlining, but there will be when generating inlined wrapper functions.

If we don't use this information, we get invalid addresses on the stack.

Fixes #5056.

R=golang-dev, rsc
CC=golang-dev, remyoudompheng
https://golang.org/cl/7850045
2013-03-18 22:22:35 +01:00
Brad Fitzpatrick
725519902f net/http: add StripPrefix example; simplify code
The example is the same as the FileServer one, but
it's relevant for both.

Also use strings.TrimPrefix while I'm here.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7598046
2013-03-18 13:44:20 -07:00
Brad Fitzpatrick
c668715334 net/http: shorten and clean up TestTransportConcurrency
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7817044
2013-03-18 13:32:42 -07:00
Rémy Oudompheng
ba50e4f120 runtime: fix tv_sec 32-bit overflows in sleep routines.
Fixes #5063.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7876043
2013-03-18 20:11:11 +01:00
Shenghou Ma
e7537157a5 runtime: fix build for NetBSD/ARM
R=golang-dev, jsing
CC=golang-dev
https://golang.org/cl/7597046
2013-03-19 02:47:04 +08:00
Brad Fitzpatrick
a7a803c7b7 database/sql: allow simultaneous queries, etc in a Tx
Now that revision 0c029965805f is in, it's easy
to guarantee that we never access a driver.Conn
concurrently, per the database/sql/driver contract,
so we can remove this overlarge mutex.

Fixes #3857

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7707047
2013-03-18 11:39:00 -07:00
Brad Fitzpatrick
9db0583007 os/exec: fix fd leak with Std*Pipe + LookPath
If LookPath in Command fails, sets a sticky error, and then
StdinPipe, StdoutPipe, or StderrPipe were called, those pipe
fds were never cleaned up.

Fixes #5071

R=golang-dev, rogpeppe
CC=golang-dev
https://golang.org/cl/7799046
2013-03-18 09:52:39 -07:00
Joel Sing
7f50c23e2d runtime: correct mmap return value checking on netbsd/openbsd
The current SysAlloc implementation suffers from a signed vs unsigned
comparision bug. Since the error code from mmap is negated, the
unsigned comparision of v < 4096 is always false on error. Fix this
by switching to the darwin/freebsd/linux mmap model and leave the mmap
return value unmodified.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7870044
2013-03-18 12:18:49 +11:00
Mikio Hara
ecc174324c net: revert Zone in IPNet temporally
Update #4501.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7853047
2013-03-17 19:50:01 +09:00
Rob Pike
36ed57931b make.bash: delete vestigial TODO, now resolved
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7789050
2013-03-16 14:53:12 -07:00
Rob Pike
464257eeff bytes,string: move the BUG to the comment of the function it's about
Avoids printing it every time we ask a question about the package from
the command line.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7789048
2013-03-15 17:08:07 -07:00
Brad Fitzpatrick
f98b8a00db net/http: don't test for goroutine leaks in short mode
Too annoying and flaky to debug for now. Later. This
tangent has taken enough time.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7863043
2013-03-15 16:50:54 -07:00
Rémy Oudompheng
861aa4698a cmd/gc: missing type inference for untyped complex() calls.
Fixes #5014.

R=golang-dev, r, rsc, daniel.morsing
CC=golang-dev
https://golang.org/cl/7664043
2013-03-16 00:37:28 +01:00
Brad Fitzpatrick
552207611b net/http: fix test breakage on Windows
Treat the Windows net server as uninteresting for leak
purposes too.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7818048
2013-03-15 15:58:43 -07:00
Robert Griesemer
3fdeb8614d go/doc: fix TODO
R=r
CC=golang-dev
https://golang.org/cl/7716049
2013-03-15 15:55:31 -07:00
Brad Fitzpatrick
caf513a66c net/http: less flaky leaking goroutine test
Fixes #5005

R=golang-dev, adg, fullung
CC=golang-dev
https://golang.org/cl/7777043
2013-03-15 15:09:17 -07:00
Jan Ziak
92c153d5f4 runtime: scan the type of an interface value
R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/7744047
2013-03-15 16:07:52 -04:00
Shenghou Ma
1d64d04da5 net, runtime: enable runtime-integrated pollster on Linux/ARM.
Results from linux/arm on a Samsung Chromebook (from dfc):
localhost(~/go/src/pkg/net) % ~/go/misc/benchcmp {old,new}.txt
benchmark                           old ns/op    new ns/op    delta
BenchmarkTCP4OneShot                   568840       350526  -38.38%
BenchmarkTCP4OneShot-2                 359054       206708  -42.43%
BenchmarkTCP4OneShotTimeout            637464       363550  -42.97%
BenchmarkTCP4OneShotTimeout-2          374255       216695  -42.10%
BenchmarkTCP4Persistent                184974        64984  -64.87%
BenchmarkTCP4Persistent-2              109902        47195  -57.06%
BenchmarkTCP4PersistentTimeout         210039        64789  -69.15%
BenchmarkTCP4PersistentTimeout-2       124284        43374  -65.10%
BenchmarkTCP6OneShot                   672278       362116  -46.14%
BenchmarkTCP6OneShot-2                 383631       216400  -43.59%
BenchmarkTCP6OneShotTimeout            680740       378306  -44.43%
BenchmarkTCP6OneShotTimeout-2          397524       230152  -42.10%
BenchmarkTCP6Persistent                172346        65292  -62.12%
BenchmarkTCP6Persistent-2              106229        42096  -60.37%
BenchmarkTCP6PersistentTimeout         161149        65138  -59.58%
BenchmarkTCP6PersistentTimeout-2       152276        44548  -70.75%

R=golang-dev, dave, bradfitz, dvyukov, rsc
CC=golang-dev
https://golang.org/cl/7820045
2013-03-16 04:01:56 +08:00
Russ Cox
615f289209 cmd/gc: ensure unique parameter and result names in function types
In addition to fixing the bug, the check is now linear instead of quadratic.

Fixes #4469.

R=ken2
CC=golang-dev
https://golang.org/cl/7773047
2013-03-15 15:24:13 -04:00
Dmitriy Vyukov
ca15ac36ed net: fix build with CGO_ENABLED=0
R=golang-dev, rsc, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7857044
2013-03-15 22:23:35 +04:00
Keith Randall
6b57329268 runtime: use AES hash for compound objects.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7716047
2013-03-15 10:46:34 -07:00
Russ Cox
a5b2623dab build: skip benchmarks on OpenBSD
They are making the build die. I want to be able to see that everything else is okay.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7546049
2013-03-15 12:39:14 -04:00
Jan Ziak
ee3c88482b runtime: remove struct BitTarget
R=golang-dev
CC=dvyukov, golang-dev, rsc
https://golang.org/cl/7845043
2013-03-15 12:37:40 -04:00
Joel Sing
e67f198516 runtime: unbreak netbsd builds
Fix signal handling so that Go builds on NetBSD.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7759048
2013-03-15 11:43:43 -04:00
Rémy Oudompheng
20c7e41555 cmd/gc: fix escape analysis bug.
It used to not mark parameters as escaping if only one of the
fields it points to leaks out of the function. This causes
problems when importing from another package.

Fixes #4964.

R=rsc, lvd, dvyukov, daniel.morsing
CC=golang-dev
https://golang.org/cl/7648045
2013-03-15 09:03:45 +01:00
Jan Ziak
2924638d26 runtime: replace lock() with casp() in the GC
Note: BitTarget will be removed by a forthcoming changeset.

R=golang-dev, dvyukov
CC=golang-dev, rsc
https://golang.org/cl/7837044
2013-03-15 09:02:36 +01:00
Jan Ziak
175c401523 cmd/gc: unroll small array types
R=golang-dev, rsc
CC=golang-dev, nigeltao
https://golang.org/cl/7812044
2013-03-15 06:57:50 +01:00
Russ Cox
5146a93e72 runtime: accept GOTRACEBACK=crash to mean 'crash after panic'
This provides a way to generate core dumps when people need them.
The settings are:

        GOTRACEBACK=0  no traceback on panic, just exit
        GOTRACEBACK=1  default - traceback on panic, then exit
        GOTRACEBACK=2  traceback including runtime frames on panic, then exit
        GOTRACEBACK=crash traceback including runtime frames on panic, then crash

Fixes #3257.

R=golang-dev, devon.odell, r, daniel.morsing, ality
CC=golang-dev
https://golang.org/cl/7666044
2013-03-15 01:11:03 -04:00
Tyler Bunnell
f6a952599e cmd/gc: disallow fallthrough in final case of switch
Small change to cmd/gc to catch a "fallthrough" in the final case of a switch.

R=golang-dev, rsc, mtj
CC=golang-dev
https://golang.org/cl/7841043
2013-03-15 00:35:09 -04:00
Anthony Martin
d94da6fab5 cmd/dist: instruct the user to bind $GOBIN on Plan 9
R=seed, rminnich, bradfitz, r
CC=golang-dev
https://golang.org/cl/7395059
2013-03-15 05:04:19 +01:00
Russ Cox
cb4428e555 os/signal: add Stop, be careful about SIGHUP
Fixes #4268.
Fixes #4491.

R=golang-dev, nightlyone, fullung, r
CC=golang-dev
https://golang.org/cl/7546048
2013-03-15 00:00:02 -04:00
Jonathan Nieder
392d5feb8b go/build: allow ~ in middle of path, just not at beginning
CL 7799045 relaxed the restriction in cmd/go on ~ in GOPATH
to allow paths with ~ in the middle while continuing to
protect against the common mistake of using GOPATH='~/home'
instead of GOPATH=~/home.  Unfortunately go/build still
filters these paths out:

        $ GOPATH=/tmp/test~ing go build
        test.go:22:2: cannot find package "test" in any of:
                /usr/lib/go/test (from $GOROOT)
                ($GOPATH not set)

So relax the requirement in go/build, too.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7826043
2013-03-14 23:59:49 -04:00
Russ Cox
e3c7a9db83 runtime: use 64-bit negative error code on 64-bit machines
NEGL does a negation of the bottom 32 bits and then zero-extends to 64 bits,
resulting in a negative 32-bit number but a positive 64-bit number.

NEGQ does a full 64-bit negation, so that the result is negative both as
a 32-bit and as a 64-bit number.

This doesn't matter for the functions that are declared to return int32.
It only matters for the ones that return int64 or void* [sic].

This will fix the current incorrect error in the OpenBSD/amd64 build.
The build will still be broken, but it won't report a bogus error.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7536046
2013-03-14 23:42:11 -04:00
Brad Fitzpatrick
f28c8fba67 database/sql: associate a mutex with each driver interface
The database/sql/driver docs make this promise:

   "Conn is a connection to a database. It is not used
   concurrently by multiple goroutines."

That promises exists as part of database/sql's overall
goal of making drivers relatively easy to write.

So far this promise has been kept without the use of locks by
being careful in the database/sql package, but sometimes too
careful. (cf. golang.org/issue/3857)

The CL associates a Mutex with each driver.Conn, and with the
interface value progeny thereof. (e.g. each driver.Tx,
driver.Stmt, driver.Rows, driver.Result, etc) Then whenever
those interface values are used, the Locker is locked.

This CL should be a no-op (aside from some new Lock/Unlock
pairs) and doesn't attempt to fix Issue 3857 or Issue 4459,
but should make it much easier in a subsequent CL.

Update #3857

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7803043
2013-03-14 15:01:45 -07:00
Russ Cox
eb80431b61 runtime: fix netbsd after reorg (again)
R=golang-dev
CC=golang-dev
https://golang.org/cl/7719046
2013-03-14 17:59:45 -04:00
Russ Cox
214c178493 runtime: fix netbsd again after reorg
This time for sure.
That C file sure looked like a header file to me. :-)

R=golang-dev
CC=golang-dev
https://golang.org/cl/7830043
2013-03-14 17:53:01 -04:00
Russ Cox
c89fc124c4 runtime: fix build for freebsd/arm after reorg
R=golang-dev
CC=golang-dev
https://golang.org/cl/7701046
2013-03-14 17:50:07 -04:00
Russ Cox
a98bec4554 runtime: fix freebsd arm for hash change
Was missing definitions of open, read, close.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7828043
2013-03-14 17:45:44 -04:00
Russ Cox
45ebc06484 runtime: freebsd, netbsd build fixes after reorg
R=golang-dev
CC=golang-dev
https://golang.org/cl/7826044
2013-03-14 17:39:39 -04:00
Brad Fitzpatrick
a4a8651419 database/sql: document non-open of Open; add Ping
Fixes #4804

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7819043
2013-03-14 14:06:46 -07:00
Russ Cox
cf46e561b2 runtime, net: fix arm build
Bring net/fd_linux.go back (it was deleted this morning)
because it is still needed for ARM.

Fix a few typos in the runtime reorg.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7759046
2013-03-14 19:42:25 +00:00
Russ Cox
8bbb6d3ed0 cmd/ld: another use-after-free
This only shows up in the duplicate symbol error message.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7486053
2013-03-14 14:35:47 -04:00
Russ Cox
e9d62a6d81 runtime: refactor os-specific code
thread_GOOS.c becomes os_GOOS.c.

signal_GOOS_GOARCH.c becomes os_GOOS_GOARCH.c,
but with non-GOARCH-specific code moved into os_GOOS.c.

The actual arch-specific signal handler moves into signal_GOARCH.c
to avoid per-GOOS duplication.

New files signal_GOOS_GOARCH.h provide macros for
accessing fields of the very system-specific signal info structs.

Lots moving, but nothing changing.
This is a preliminarly cleanup so I can work on the signal
handling code to fix some open issues without having to
make each change 13 times.

Tested on Linux and OS X, 386 and amd64.
Will fix Plan 9, Windows, and ARM after the fact if necessary.
(Plan 9 and Windows should be fine; ARM will probably have some typos.)

Net effect: -1081 lines of code.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7565048
2013-03-14 11:35:13 -07:00
Albert Strasheim
cdc642453b net: deflake TestDialTimeout
Fixes #3867.
Fixes #3307.

R=bradfitz, dvyukov
CC=golang-dev
https://golang.org/cl/7735044
2013-03-14 09:42:29 -07:00
Dmitriy Vyukov
76959e2cc6 runtime: do not memprofile settype_flush
Fixes #4850.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/7745044
2013-03-14 19:11:29 +04:00
Dmitriy Vyukov
49e0300854 runtime: integrated network poller for linux
vs tip:
BenchmarkTCP4OneShot                    172994        40485  -76.60%
BenchmarkTCP4OneShot-2                   96581        30028  -68.91%
BenchmarkTCP4OneShot-4                   52615        18454  -64.93%
BenchmarkTCP4OneShot-8                   26351        12289  -53.36%
BenchmarkTCP4OneShot-16                  12258        16093  +31.29%
BenchmarkTCP4OneShot-32                  13200        17045  +29.13%

BenchmarkTCP4OneShotTimeout             124814        42932  -65.60%
BenchmarkTCP4OneShotTimeout-2            99090        29040  -70.69%
BenchmarkTCP4OneShotTimeout-4            51860        18455  -64.41%
BenchmarkTCP4OneShotTimeout-8            26100        12073  -53.74%
BenchmarkTCP4OneShotTimeout-16           12198        16654  +36.53%
BenchmarkTCP4OneShotTimeout-32           13438        17143  +27.57%

BenchmarkTCP4Persistent                 115647         7782  -93.27%
BenchmarkTCP4Persistent-2                58024         4808  -91.71%
BenchmarkTCP4Persistent-4                24715         3674  -85.13%
BenchmarkTCP4Persistent-8                16431         2407  -85.35%
BenchmarkTCP4Persistent-16                2336         1875  -19.73%
BenchmarkTCP4Persistent-32                1689         1637   -3.08%

BenchmarkTCP4PersistentTimeout           79754         7859  -90.15%
BenchmarkTCP4PersistentTimeout-2         57708         5952  -89.69%
BenchmarkTCP4PersistentTimeout-4         26907         3823  -85.79%
BenchmarkTCP4PersistentTimeout-8         15036         2567  -82.93%
BenchmarkTCP4PersistentTimeout-16         2507         1903  -24.09%
BenchmarkTCP4PersistentTimeout-32         1717         1627   -5.24%

vs old scheduler:
benchmark                           old ns/op    new ns/op    delta
BenchmarkTCPOneShot                    192244        40485  -78.94%
BenchmarkTCPOneShot-2                   63835        30028  -52.96%
BenchmarkTCPOneShot-4                   35443        18454  -47.93%
BenchmarkTCPOneShot-8                   22140        12289  -44.49%
BenchmarkTCPOneShot-16                  16930        16093   -4.94%
BenchmarkTCPOneShot-32                  16719        17045   +1.95%

BenchmarkTCPOneShotTimeout             190495        42932  -77.46%
BenchmarkTCPOneShotTimeout-2            64828        29040  -55.20%
BenchmarkTCPOneShotTimeout-4            34591        18455  -46.65%
BenchmarkTCPOneShotTimeout-8            21989        12073  -45.10%
BenchmarkTCPOneShotTimeout-16           16848        16654   -1.15%
BenchmarkTCPOneShotTimeout-32           16796        17143   +2.07%

BenchmarkTCPPersistent                  81670         7782  -90.47%
BenchmarkTCPPersistent-2                26598         4808  -81.92%
BenchmarkTCPPersistent-4                15633         3674  -76.50%
BenchmarkTCPPersistent-8                18093         2407  -86.70%
BenchmarkTCPPersistent-16               17472         1875  -89.27%
BenchmarkTCPPersistent-32                7679         1637  -78.68%

BenchmarkTCPPersistentTimeout           83186         7859  -90.55%
BenchmarkTCPPersistentTimeout-2         26883         5952  -77.86%
BenchmarkTCPPersistentTimeout-4         15776         3823  -75.77%
BenchmarkTCPPersistentTimeout-8         18180         2567  -85.88%
BenchmarkTCPPersistentTimeout-16        17454         1903  -89.10%
BenchmarkTCPPersistentTimeout-32         7798         1627  -79.14%

R=golang-dev, iant, bradfitz, dave, rsc
CC=golang-dev
https://golang.org/cl/7579044
2013-03-14 19:06:35 +04:00
Dmitriy Vyukov
4dd1b8999a cmd/dist: support goos,goarch build tags
This is necessary to submit netpoll for linux,386 linux,amd64

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/7470050
2013-03-14 19:04:47 +04:00
Russ Cox
f84d5dd475 runtime: make panic possible before malloc is ready
Otherwise startup problems can be difficult to debug.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7522046
2013-03-14 10:10:12 -04:00
Dmitriy Vyukov
5b79aa82ff runtime: revert UseSpanType back to 1
R=golang-dev
CC=golang-dev
https://golang.org/cl/7812043
2013-03-14 13:48:19 +04:00
Dmitriy Vyukov
f51ec00722 runtime: fix build
R=golang-dev
CC=golang-dev
https://golang.org/cl/7529049
2013-03-14 10:59:55 +04:00
Dmitriy Vyukov
0bee99ab3b runtime: integrated network poller for darwin
vs tip:
benchmark                           old ns/op    new ns/op    delta
BenchmarkTCP4Persistent                 67786        33175  -51.06%
BenchmarkTCP4Persistent-2               49085        31227  -36.38%
BenchmarkTCP4PersistentTimeout          69265        32565  -52.98%
BenchmarkTCP4PersistentTimeout-2        49217        32588  -33.79%

vs old scheduler:
benchmark                           old ns/op    new ns/op    delta
BenchmarkTCP4Persistent                 63517        33175  -47.77%
BenchmarkTCP4Persistent-2               54760        31227  -42.97%
BenchmarkTCP4PersistentTimeout          63234        32565  -48.50%
BenchmarkTCP4PersistentTimeout-2        56956        32588  -42.78%

R=golang-dev, bradfitz, devon.odell, mikioh.mikioh, iant, rsc
CC=golang-dev, pabuhr
https://golang.org/cl/7569043
2013-03-14 10:38:37 +04:00
Dmitriy Vyukov
a11d7d4e11 net: prepare connect() for new network poller
The problem is that new network poller can have spurious
rediness notifications. This implementation ensures that
the socket is actually connected.

R=golang-dev, rsc, akumar
CC=golang-dev
https://golang.org/cl/7785043
2013-03-14 10:32:42 +04:00
Russ Cox
ffbcd89f62 cmd/go: allow ~ in middle of path, just not at beginning
An earlier CL disallowed ~ anywhere in GOPATH, to avoid
problems with GOPATH='~/home' instead of GOPATH=~/home.
But ~ is only special in the shell at the beginning of each of
the paths in the list, and some paths do have ~ in the middle.
So relax the requirement slightly.

Fixes #4140.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7799045
2013-03-13 23:32:12 -04:00
Olivier Saingre
f74eb6dbf7 encoding/xml: rewrite invalid code points to U+FFFD in Marshal, Escape
Fixes #4235.

R=rsc, dave, r, dr.volker.dobler
CC=golang-dev
https://golang.org/cl/7438051
2013-03-13 23:26:03 -04:00
Russ Cox
e778f93022 cmd/go: add go1.1 build tag, add -installsuffix flag
The new build tag "go1.1" will be satisfied by any Go 1.z release >= 1.1.
In general, the build tag "go1.x" will be satisfied by any Go 1.z release >= 1.x.
What happens when we reach Go 2 is yet to be decided.

The tags "go1" or "go1.0" are missing, because +build tags did not exist
before then, and also because the Go 1.0 releases do not recognize them.

The new -installsuffix flag gives access to the build context's InstallSuffix
(formerly named InstallTag, but not part of Go 1.0), for use in isolating
builds to custom directories. For example -race implies -installsuffix race,
and an AppEngine-specific build might use -tags appengine -installsuffix appengine.

Fixes #4116.
Fixes #4443.

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/7794043
2013-03-13 17:37:49 -04:00
Russ Cox
3048a4c7b3 cmd/vet: make struct tag literal test work better with no go/types
Eliminate false positives when you can tell even without
type information that the literal does not need field tags.

Far too noisy otherwise.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7797043
2013-03-13 17:37:37 -04:00
Rob Pike
2211634113 cmd/go: better documentation about profiling
Point the user to "go tool pprof" and mention some
important flags.

Fixes #4990.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7657045
2013-03-13 13:56:51 -07:00
Dave Cheney
8883c484cf cmd/gc: silence valgrind error
valgrind complained that under some circumstances,

    *nr = *nc

was being called when nr and nc were the same *Node. The suggestion my Rémy was to introduce a tmp node to avoid the potential for aliasing in subnode.

R=remyoudompheng, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7780044
2013-03-13 16:12:38 -04:00
Rick Arnold
cb8aebf19d encoding/json: properly handle extra objects with fixed size arrays
If a fixed size array is passed in as the decode target and the JSON
to decode has extra array elements that are objects, then previously
the decoder would return a "data changing underfoot" error.

Fixes #3717.

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/7490046
2013-03-13 14:53:03 -04:00
Tyler Bunnell
06cbe78bd7 net: use original raddr if getpeername fails
Fixes #3838.

R=dave, mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/7511043
2013-03-13 14:49:24 -04:00
Russ Cox
bdf8bf6adc encoding/xml: predefine xml name space prefix
Also change prefix generation to use more human-friendly prefixes.

Fixes #5040.

R=golang-dev, r, bradfitz
CC=golang-dev
https://golang.org/cl/7777047
2013-03-13 14:36:42 -04:00
Jeff R. Allen
ea75ada36b unicode/utf8: fix insignificant typos in tests
Fixes #4972.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7649044
2013-03-13 07:45:31 -07:00
Brad Fitzpatrick
1fdb3e2ed6 net: fix windows and plan9 build
Don't call unix-only function in test init.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/7778043
2013-03-13 07:42:55 -07:00
Mikio Hara
8373f729fd net: require of both -external and -ipv6 flags to run IPv6 multicast tests
On BSD variants, the tests need surely constructed IPv6
routing table.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7776043
2013-03-13 08:00:01 +08:00
Nigel Tao
a3d1c1bdce image/jpeg: ignore extraneous data, the same as what libjpeg does.
Fixes #4705.

Note that libjpeg will print a warning to stderr if there are many
extraneous bytes, but can be silent if the extraneous bytes can fit
into its int32 bit-buffer for Huffman decoding. I'm guessing that
this is why whatever encoder that produced the image filed for issue
4705 did not realize that they are, strictly speaking, generating an
invalid JPEG. That issue's attached image has two extraneous bytes.

For example, piping the program below into libjpeg's djpeg program
will print an "18 extraneous bytes" warning, even though N == 20.

$ cat main.go
package main

import (
        "bytes"
        "image"
        "image/color"
        "image/jpeg"
        "os"
)

const N = 20

func main() {
        // Encode a 1x1 red image.
        m := image.NewRGBA(image.Rect(0, 0, 1, 1))
        m.Set(0, 0, color.RGBA{255, 0, 0, 255})
        buf := new(bytes.Buffer)
        jpeg.Encode(buf, m, nil)
        b := buf.Bytes()
        // Strip the final "\xff\xd9" EOI marker.
        b = b[:len(b)-2]
        // Append N dummy 0x80 bytes to the SOS data.
        for i := 0; i < N; i++ {
                b = append(b, 0x80)
        }
        // Put back the "\xff\xd9" EOI marker.
        b = append(b, 0xff, 0xd9)
        os.Stdout.Write(b)
}
$ go run main.go | djpeg /dev/stdin > /tmp/foo.pnm
Corrupt JPEG data: 18 extraneous bytes before marker 0xd9

The resultant /tmp/foo.pnm is a perfectly good 1x1 red image.

R=r
CC=golang-dev
https://golang.org/cl/7750043
2013-03-13 10:44:45 +11:00
Mikio Hara
9f399a0301 net: make sure to use /tmp in unix domain socket tests
R=golang-dev, bradfitz, dave, rsc
CC=golang-dev
https://golang.org/cl/7547044
2013-03-13 07:26:21 +08:00
Akshat Kumar
293c880f13 runtime: Plan 9, 32-bit: fix build by updating call to open()
With the global redefinition of runtime·open by CL 7543043,
we need to provide a third argument and remove the cast
to the string.

Fixes build on 386 version of Plan 9.

R=khr, rsc, rminnich, ality
CC=golang-dev
https://golang.org/cl/7644047
2013-03-12 23:10:18 +01:00
Akshat Kumar
a1b2d1404b net: Plan 9: add lookupProtocol
Needed by TestResolveIPAddr. This makes us pass tests
again.

R=rsc, rminnich, ality, bradfitz
CC=golang-dev
https://golang.org/cl/7737043
2013-03-12 23:05:39 +01:00
Russ Cox
f7ad816c5c cmd/ld: fix 'use after free' error in new obj code
Many thanks to Elias Naur for finding this with Valgrind on Linux.
Perhaps this is what is breaking the windows/amd64 builder.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7595044
2013-03-12 17:57:13 -04:00
Robert Figueiredo
e1a5aa8105 html/template: Ensure release of namespace mutex in Template.Execute()
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6727046
2013-03-12 14:35:14 -07:00
Rob Pike
4ce79096b6 go/types: delete from main repo; part of move to go.exp
See also https://golang.org/cl/7656044

R=golang-dev, gri, rsc
CC=golang-dev
https://golang.org/cl/7625048
2013-03-12 13:55:58 -07:00
Russ Cox
bfe80e21e4 encoding/xml: reject > chain with non-element
Fixes #5033.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7764044
2013-03-12 16:42:25 -04:00
Robert Griesemer
8323cef77c go/printer, gofmt: avoid extra final comma in multi-line signatures
The parameter list layout function was incorrectly computing the
end of the previous line in cases where a parameter type spanned
multiple lines. As a result, an extra (valid, but not needed)
comma was introduced before the paremeter list's closing parenthesis.

Fixes #4533.

R=rsc
CC=golang-dev
https://golang.org/cl/7674044
2013-03-12 13:07:15 -07:00
Robert Griesemer
d825320550 go/doc: set receiver type position for embedded methods
This was a bug that didn't manifest itself before CL 7674044;
but with that CL and without this fix, the go/doc tests fail.
(The bug fixed by 7674044 and the bug fixed here cancelled
each other out w/ respect to the go/doc tests).

R=rsc
CC=golang-dev
https://golang.org/cl/7628045
2013-03-12 13:06:55 -07:00
Dmitriy Vyukov
b09d881799 net: refactoring in preparation for integrated network poller
Introduce pollDesc struct, to split netFD struct into fd-related
and poller-related parts.

R=golang-dev, bradfitz, iant
CC=golang-dev
https://golang.org/cl/7762044
2013-03-13 00:03:00 +04:00
Shenghou Ma
07fb6fcd40 os/signal: windows is supported, update comment
Fixes #5035.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7519045
2013-03-13 02:40:56 +08:00
Keith Randall
66e346433e runtime: Fix plan9 aes hash initialization.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7593045
2013-03-12 11:03:16 -07:00
Keith Randall
a5d4024139 runtime: faster & safer hash function
Uses AES hardware instructions on 386/amd64 to implement
a fast hash function.  Incorporates a random key to
thwart hash collision DOS attacks.
Depends on CL#7548043 for new assembly instructions.

Update #3885
Helps some by making hashing faster.  Go time drops from
0.65s to 0.51s.

R=rsc, r, bradfitz, remyoudompheng, khr, dsymonds, minux.ma, elias.naur
CC=golang-dev
https://golang.org/cl/7543043
2013-03-12 10:47:44 -07:00
Dmitriy Vyukov
4e032ce301 runtime: fix build
R=golang-dev
CC=golang-dev
https://golang.org/cl/7760043
2013-03-12 21:39:49 +04:00
Dmitriy Vyukov
c211884731 runtime: add network polling support into scheduler
This is a part of the bigger change that moves network poller into runtime:
https://golang.org/cl/7326051/

R=golang-dev, bradfitz, mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/7448048
2013-03-12 21:14:26 +04:00
Russ Cox
4dd3e1e844 encoding/xml: name space bug fixes
If two fields have the same name but different explicit name spaces,
treat as non-conflicting. This allows parsing common XML formats
that have ns1:tag and ns2:tag in the same XML element.
Fixes #4691.

Allow setting the default name space for unadorned tags, by
writing to Decoder.DefaultSpace. This allows turned the job of
parsing common XML formats that have tag and ns2:tag in the
same XML element into the first case by setting DefaultSpace="ns1".
Fixes #3703.

Use name space attributes when decoding.
Attach name space to attributes when encoding.
Could be done with fewer annotations, but semantically correct as is.
Fixes #3526.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7227056
2013-03-12 11:46:12 -04:00
Adrian Nos
0d559f7b92 net/rpc/jsonrpc: nil pointer deference on invalid reply.
Fixes #5006.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7691045
2013-03-12 11:45:56 -04:00
Dmitriy Vyukov
6ee739d7e9 runtime: fix deadlock detector false negative
The issue was that scvg is assigned *after* the scavenger goroutine is started,
so when the scavenger calls entersyscall() the g==scvg check can fail.
Fixes #5025.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7629045
2013-03-12 17:21:44 +04:00
Dmitriy Vyukov
7f070af515 runtime: deflake TestStackMem
The problem is that there are lots of dead G's from previous tests,
each dead G consumes 1 stack segment.
Fixes #5034.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7749043
2013-03-12 15:19:06 +04:00
Dmitriy Vyukov
e0fd6d08b2 net/http: deflake test
Update #5005.

R=golang-dev, fullung, bradfitz
CC=golang-dev
https://golang.org/cl/7651045
2013-03-12 12:52:49 +04:00
Philip K. Warren
b4237b5997 encoding/base32, encoding/base64: fix issues with decoder whitespace handling
Adds a new reader to filter newlines, which fixes errors seen in the
decoder chunking code. Found additional issues with whitespace handling
after the first padding character.
Fixes #4779.

R=minux.ma, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/7311069
2013-03-12 01:50:10 -04:00
Russ Cox
e64f3f211a net: never use backlog > 65535
The system call takes an int, but the kernel stores it in a uint16.
At least one Linux system sets /proc/sys/net/core/somaxconn
to 262144, which ends up being 0 in the uint16. Avoid being tricked.

FreeBSD sources also store the backlog in a uint16.
Assume the problem is systemic and fix it everywhere.

Fixes #5030.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7480046
2013-03-12 01:48:48 -04:00
Russ Cox
019754ed40 encoding/xml: fix spurious "no semicolon" in error
Noticed while doing other XML investigations.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7550045
2013-03-12 00:29:36 -04:00
Russ Cox
aa81eb5901 encoding/xml: allow embedded non-structs
The old code just assumed that the only thing
you can embed is a struct. Not true.

Fixes #3803.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7743043
2013-03-11 23:58:20 -04:00
Brad Fitzpatrick
864278ad90 net/http: bit more docs on Client vs Transport
This isn't as bad as it used to be, but add a bit
more detail to close the issue.

Fixes #3359

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7606044
2013-03-11 18:51:01 -07:00
Nigel Tao
96e0c0c764 encoding/base32, encoding/base64: a small stack-space optimization.
R=dsymonds, dave
CC=golang-dev
https://golang.org/cl/7568045
2013-03-12 11:24:24 +11:00
Dave Cheney
2f2271db7a net/http: add tests for ParseHTTPVersion
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7739043
2013-03-12 11:18:18 +11:00
Nigel Tao
79d06d7286 encoding/base32: don't panic when decoding "AAAA==".
Edit encoding/base64's internals and tests to match encoding/base32.

Properly handling line breaks in padding is left for another CL.

R=dsymonds
CC=golang-dev
https://golang.org/cl/7693044
2013-03-12 11:07:36 +11:00
Rob Pike
1b3c969ac3 regexp: identify that submatch is also known as capturing group
Mention the syntax is defined by the regexp/syntax package.
Fixes #3953.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7702044
2013-03-11 16:23:06 -07:00
Robert Griesemer
916f4cfa64 go/parser: better error message if = is seen instead of ==
Fixes #4519.

R=rsc
CC=golang-dev
https://golang.org/cl/7733044
2013-03-11 15:23:18 -07:00
Russ Cox
d2be8f2948 cmd/addr2line: exit 0 for --help
This is what pprof expects, or else it won't use the program.
And if it doesn't use the program, it gets very bad results.

Fixes #4818.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7728043
2013-03-11 18:12:07 -04:00
Rémy Oudompheng
401e0fea3a cmd/gc: reject complex calls with mismatched argument types.
The specification says "the two arguments must be of the same
floating-point type."

R=rsc, gri
CC=golang-dev
https://golang.org/cl/7671045
2013-03-11 22:55:14 +01:00
Brad Fitzpatrick
e15c0ac693 all: remove now-unnecessary unreachable panics
Take advantage of the new terminating statement rule.

R=golang-dev, r, gri
CC=golang-dev
https://golang.org/cl/7712044
2013-03-11 14:16:55 -07:00
Rob Pike
5f91a62a3c cmd/go: fix description of -o flag to build
Fixes #5003.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7476047
2013-03-11 14:07:47 -07:00
Russ Cox
7b4ac31cab cmd/dist: make cc rule match what cmd/go uses
We added -I$GOROOT/pkg/$GOOS_$GOARCH in cmd/go
(I think for use by cgo and swig, primarily) but didn't
update cmd/dist. I was testing some other code and
found that my changes built with cmd/go but failed
during the initial bootstrap. Make them match again.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7707044
2013-03-11 16:50:44 -04:00
Robert Griesemer
5183bfda75 go/types: update operand types early
For expressions where the result type is independent
of the argument types (comparisons, conversions, rhs
of shifts), set the final expression types for those
subtrees early.

This fixes several bugs where incorrect lhs shift
operands where used (say in a comparison), but were
not reported.

Together with the changes listed below this CL fixes
many type-checker bugs.

Also:
- better documented updateExprType
- added larger comment to expr.go explaining
  the basic expression checking algorithm
- use latest definition for indices and make
  arguments; use the same code to check both
- use the same mechanism for cycle detection
  in constant expressions as for variables
  (new field Constant.visited)
- more tests for complex and make builtins
- many more and systematic tests for shifts;
  moved them into separate testfile
- in the testing code, don't compare the
  expected error pattern against itself
  (the actual message was always ignored...)
- fix affected error patterns in the test files
- various cleanups along the way

R=adonovan
CC=golang-dev
https://golang.org/cl/7432051
2013-03-11 13:38:45 -07:00
Akshat Kumar
76374412c3 lib9, cmd/dist, cmd/ld: Plan 9: fix build
lib9: fix runcmd, removeall, and tempdir functions

cmd/dist: Include run_plan9.c and tempdir_plan9.c
        from lib9 for build, and in general consider
        file names containing "plan9" for building.

cmd/ld: provide function args for the new functions
        from lib9.

R=rsc, rminnich, ality, bradfitz
CC=golang-dev
https://golang.org/cl/7666043
2013-03-11 13:34:57 -07:00
Rémy Oudompheng
386ad0ab90 cmd/gc: enable inlining in generated method wrappers.
Method calls on interfaces with large stored values
will call the pointer receiver method which may be
a wrapper over a method with value receiver.

This is particularly inefficient for very small bodies.
Inlining the wrapped method body saves a potentially expensive
function call.

benchmark                old ns/op    new ns/op    delta
BenchmarkSortString1K       802295       641387  -20.06%
BenchmarkSortInt1K          359914       238234  -33.81%
BenchmarkSortInt64K       35764226     22803078  -36.24%

Fixes #4707.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/7214044
2013-03-11 21:24:51 +01:00
Brad Fitzpatrick
404e4a90cb net/http/httputil: fix string in test failure message
R=golang-dev, daniel.morsing
CC=golang-dev
https://golang.org/cl/7722043
2013-03-11 13:23:47 -07:00
Rob Pike
ea196278aa debug/macho: add doc comment for FormatError
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7624044
2013-03-11 12:32:47 -07:00
Rodrigo Moraes de Oliveira
82e3ca7b7a net/url: better path resolution
This includes a simplified resolvePath function and tests for all normal and abnormal path resolution examples described in RFC 3986, sections 5.4.1 and 5.4.2 [1]. Some of those examples failed before (see http://play.golang.org/p/F0ApSaXniv).

Also, parsing a reference "//foo" now works as expected. It was treated as an absolute path with very weird results (see http://play.golang.org/p/089b-_xoNe).

During path resolution, all dot segments are removed as described by the RFC.

A few existing tests had to be changed because they expected the wrong output.

Fixes #4700.

Fixes #4706.

[1] http://tools.ietf.org/html/rfc3986#section-5.4.1

R=rsc, adg, bradfitz
CC=golang-dev
https://golang.org/cl/7203059
2013-03-11 15:03:07 -04:00
Dmitriy Vyukov
fe017550ac os/signal: deflake test
Fixes #4987.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7713043
2013-03-11 22:31:34 +04:00
Brad Fitzpatrick
f0396caf12 net/http: add a test verifying header case preservation
Fixes #5022

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7712043
2013-03-11 11:10:43 -07:00
Brad Fitzpatrick
c6e8993e79 net/http/httputil: remove hop-by-hop headers in ReverseProxy
Fixes #2735

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7470048
2013-03-11 10:32:32 -07:00
Albert Strasheim
2f0a970bde net: allow concurrent UNIX socket tests if TMPDIR is unique.
Only clever enough to allow concurrent stress testing.

R=mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/7703044
2013-03-11 13:24:52 -04:00
Russ Cox
14a295c817 sync/atomic: make unaligned 64-bit atomics crash on 386
R=golang-dev, bradfitz, dvyukov
CC=golang-dev
https://golang.org/cl/7702043
2013-03-11 12:21:46 -04:00
Jonathan Rudenberg
fadeafac93 net/http: add additional status codes defined in RFC 6585
428 Precondition Required
429 Too Many Requests
431 Request Header Fields Too Large
511 Network Authentication Required

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7678043
2013-03-11 07:43:57 -07:00
Russ Cox
65ed3f1073 math/big: fix comment
The variable is named b not bit.

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/7699043
2013-03-11 10:20:33 -04:00
Shenghou Ma
960d7082ee cmd/ld, runtime/cgo: allow a symbol to be both cgo_export and cgo_import.
Fixes #4878.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7420052
2013-03-11 14:24:51 +08:00
Russ Cox
72dd01451f cmd/5l: fix build (define stub machoreloc1)
R=ken2
CC=golang-dev
https://golang.org/cl/7694043
2013-03-11 01:27:03 -04:00
Russ Cox
761c386770 build: enable host linking test for all BSDs
Let's just see what breaks.

R=golang-dev, bradfitz, adg
CC=golang-dev
https://golang.org/cl/7693043
2013-03-11 01:12:18 -04:00
Russ Cox
3b85b724c5 cmd/ld: darwin support for host linking
R=ken2
CC=golang-dev
https://golang.org/cl/7626045
2013-03-11 00:51:42 -04:00
Russ Cox
9e13803ae1 cmd/ld: avoid redundant external relocation calculations
R=ken2, ken
CC=golang-dev
https://golang.org/cl/7483045
2013-03-10 19:07:16 -07:00
Jeff R. Allen
53f034c7a8 cmd/go: send output of build and install to stderr
"go build" and "go install" were mixing stdout and stderr
from the toolchain, then putting it all on stdout. With this
change, it stays mixed, and is sent to stderr. Because
the toolchain does not create output in a clean compile/install,
sending all output to stderr makese more sense.

Also fix test.bash because of "mktemp: too few X's
in template `testgo'" on Linux.

Fixes #4917.

R=golang-dev, rsc, adg
CC=golang-dev
https://golang.org/cl/7393073
2013-03-11 11:31:14 +11:00
Russ Cox
96b243fa47 cmd/ld: replace dynimpname with extname
Dynimpname was getting too confusing.
Replace flag-like checks with tests of s->type.

R=ken2
CC=golang-dev
https://golang.org/cl/7594046
2013-03-10 18:19:53 -04:00
Russ Cox
4c40e5ae51 cmd/ld: wrap long data lines in -a output
Also move symbol names onto lines by themselves: some are very long.
Show relocations.

R=ken2
CC=golang-dev
https://golang.org/cl/7689043
2013-03-10 16:32:00 -04:00
Russ Cox
df6072b41c cmd/ld: include full symbol table in Mach-O output
This makes binaries work with OS X nm.

R=ken2
CC=golang-dev
https://golang.org/cl/7558044
2013-03-10 16:24:01 -04:00
Russ Cox
85d83c2e51 libmach: fix build
I guess it would be too much to ask for gcc on my machine to give
the same errors as gcc on the builder machines.

R=ken2
CC=golang-dev
https://golang.org/cl/7686044
2013-03-10 14:45:57 -04:00
Russ Cox
b83d4af330 cmd/ld: make mach-o sections match internal sections
This brings Mach-O generation more in line with ELF generation.

Having separate sections for the symtab and pclntab mean that we
can find them that way, instead of using the deprecated debug segments.
(And the host linker will keep separate sections for us, but probably
not the debug segments.)

R=ken2
CC=golang-dev
https://golang.org/cl/7688043
2013-03-10 14:17:04 -04:00
Russ Cox
e982ecacd1 cmd/ld: add tmpdir flag to preserve temp files
R=ken2
CC=golang-dev
https://golang.org/cl/7497044
2013-03-10 12:50:44 -04:00
Dmitriy Vyukov
433824d808 runtime: fix misaligned 64-bit atomic
Fixes #4869.
Fixes #5007.
Update #5005.

R=golang-dev, 0xe2.0x9a.0x9b, bradfitz
CC=golang-dev
https://golang.org/cl/7534044
2013-03-10 20:46:11 +04:00
Brad Fitzpatrick
8d51c33012 net: evaluate the timeout dial opt's deadline at dial time
Previously it was evaluated once, so re-using the timeout option
repeatedly would always generate the same deadine.

Also switch to doing just one pass over the options, making
the private interface actually useful.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7608045
2013-03-09 18:14:00 -08:00
Lucio De Re
a8e55f8858 cmd/8l/obj.c: NetBSD passes the test, Hnetbsd added.
myrtle$ go version
go version devel +d533352b414d Sat Mar 09 05:39:15 2013 +0100 netbsd/386
myrtle$ time go test -ldflags -hostobj ../misc/cgo/test
ok      _/var/project/GoLang/misc/cgo/test      10.962s
   68.63s real    49.60s user    19.06s system
myrtle$ uname -a
NetBSD myrtle.plan9.local 6.0_BETA2 NetBSD 6.0_BETA2 (GENERIC) i386

R=rsc
CC=golang-dev
https://golang.org/cl/7641047
2013-03-09 14:54:56 -08:00
Steve McCoy
18f926aab3 cgo: enable external linking mode on FreeBSD amd64.
Tested on FreeBSD 9.1 amd64, per rsc's instructions at
https://groups.google.com/d/topic/golang-dev/HjRTLvRsJXo/discussion .

R=golang-dev, lucio.dere, devon.odell, rsc
CC=golang-dev
https://golang.org/cl/7664044
2013-03-09 14:51:57 -08:00
Dave Cheney
9dd92d522f syscall: add PROT_* and MAP_* constants to freebsd
Update #4929

Regenerated from FreeBSD-9.1 for amd64 and 386, FreeBSD-CURRENT for arm.

R=devon.odell, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7438053
2013-03-09 16:25:30 +11:00
Ian Lance Taylor
30b89a84ac net: if accept4 returns EINVAL fall back to accept
R=golang-dev, andybalholm, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7485045
2013-03-08 21:18:06 -08:00
Akshat Kumar
ef7705f6dd runtime: Plan 9: fix errstr
The call to the C function runtime.findnull() requires
that we provide the argument at 0(SP).

R=rsc, rminnich, ality
CC=golang-dev
https://golang.org/cl/7559047
2013-03-09 05:39:15 +01:00
Russ Cox
cd94cabad6 cmd/ld: external linking fixes for linux/386
The sticking point on 386 has been the "PC relative" relocations
used to point the garbage collection metadata at the type info.
These aren't in the code segment, and I don't trust that the linker
isn't doing something special that would be okay in code but
not when interpreting the pointers as data (for example, a PLT
jump table would be terrible).

Solve the problem in two steps:

1. Handle "PC relative" relocations within a section internally,
so that the external linker never sees them.

2. Move the gcdata and gcbss tables into the rodata section,
where the type information lives, so that the relocations can
be handled internally.

(To answer the obvious question, we make the gc->type
references relative so that they need not be relocated
individually when generating a shared object file.)

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7629043
2013-03-08 20:22:38 -08:00
Rob Pike
0406c63ea3 text/template: revert minor change to Name method
For  better printing, I recently changed Name to return "<unnamed>" for templates
with empty names, but this causes trouble for the many packages that used "" as
the template name, so restore the old behavior.
It's usually printed as a quoted string anyway, so it should be fine.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7577044
2013-03-08 16:39:54 -08:00
Rémy Oudompheng
1b8f51c917 runtime: fix integer overflow in amd64 memmove.
Fixes #4981.

R=bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/7474047
2013-03-09 00:41:03 +01:00
Brad Fitzpatrick
3cdf8bae1a database/sql: fix Conn leak
Fixes #4902

R=golang-dev, alex.brainman, r, google
CC=golang-dev
https://golang.org/cl/7579045
2013-03-08 10:04:17 -08:00
Russ Cox
1a4599b41a runtime: clear locked bit when goroutine exits
Otherwise the next goroutine run on the m
can get inadvertently locked if it executes a cgo call
that turns on the internal lock.

While we're here, fix the cgo panic unwind to
decrement m->ncgo like the non-panic unwind does.

Fixes #4971.

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/7627043
2013-03-08 11:26:00 -05:00
Russ Cox
091d7210c7 runtime: make TestStackMem a little less flaky
Have seen failures with GOMAXPROCS=4 on Windows.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7626043
2013-03-08 11:25:21 -05:00
Russ Cox
e0c430d5b7 cmd/6l, cmd/8l: fix BSD builds
Before this CL, running

        cd misc/cgo/test
        go test -c
        readelf --dyn-syms test.test | grep cgoexp

turned up many UNDEF symbols corresponding to symbols actually
in the binary but marked only cgo_export_static. Only symbols
marked cgo_export_dynamic should be listed in this mode.
And if the symbol is going to be listed, it should be listed with its
actual address instead of UNDEF.

The Linux dynamic linker didn't care about the seemingly missing
symbols, but the BSD one did.

This CL eliminates the symbols from the dyn-syms table.

R=golang-dev
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7624043
2013-03-07 21:23:59 -08:00
Russ Cox
7663ffcae6 cmd/ld: steps toward 386 host linking
- Introduce MaxAlign constant and use in data layout
and ELF section header.

- Allow up to 16-byte alignment for large objects
(will help Keith's hash changes).

- Emit ELF symbol for .rathole (global /dev/null used by 8c).

- Invoke gcc with -m32/-m64 as appropriate.

- Don't invoke gcc if writing the .o file failed.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7563045
2013-03-07 19:57:25 -08:00
Russ Cox
dfc22e29ec runtime: change 386 startup convention
Now the default startup is that the program begins at _rt0_386_$GOOS,
which behaves as if calling main(argc, argv). Main jumps to _rt0_386.

This makes the _rt0_386 entry match the expected semantics for
the standard C "main" function, which we can now provide for use when
linking against a standard C library.

386 analogue of https://golang.org/cl/7525043

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7551045
2013-03-07 19:57:10 -08:00
Brad Fitzpatrick
b6e0d39a34 net/http: Transport socket late binding
Implement what Chrome calls socket "late binding". See:
https://insouciant.org/tech/connection-management-in-chromium/

In a nutshell, if our HTTP client needs a TCP connection to a
remote host and there's not an idle one available, rather than
kick off a dial and wait for that specific dial, we instead
kick off a dial and wait for either our own dial to finish, or
any other TCP connection to that same host to become
available.

The implementation looks like a classic "Learning Go
Concurrency" slide.

Chrome's commit and numbers:
http://src.chromium.org/viewvc/chrome?view=rev&revision=36230

R=golang-dev, daniel.morsing, adg
CC=golang-dev
https://golang.org/cl/7587043
2013-03-07 17:56:00 -08:00
Akshat Kumar
a566deace1 syscall: Plan 9: use lightweight errstr in entersyscall mode
Change 231af8ac63aa (CL 7314062) made runtime.enteryscall()
set m->mcache = nil, which means that we can no longer use
syscall.errstr in syscall.Syscall and syscall.Syscall6, since it
requires a new buffer to be allocated for holding the error string.
Instead, we use pre-allocated per-M storage to hold error strings
from syscalls made while in entersyscall mode, and call
runtime.findnull to calculate the lengths.

Fixes #4994.

R=rsc, rminnich, ality, dvyukov, rminnich, r
CC=golang-dev
https://golang.org/cl/7567043
2013-03-08 00:54:44 +01:00
Mikio Hara
2ac799cfbc net: fix multicast listener tests
This CL splits multicast listener tests into two; for IPv4 and
for IPv6. It also removes redundant test inputs and makes sure
that assignment of multicast interface to stablize the tests.

Fixes #4059.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7565043
2013-03-08 06:51:06 +09:00
Keith Randall
297bb12809 cmd/6a, cmd/8a, cmd/6l, cmd/8l: add AES instructions
Instructions for use in AES hashing.  See CL#7543043

R=rsc
CC=golang-dev
https://golang.org/cl/7548043
2013-03-07 12:54:00 -08:00
Rémy Oudompheng
4c203172a2 cmd/8g: fix code generation of int64(0) == int64(0).
The code would violate the contract of cmp64.

Fixes #5002.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/7593043
2013-03-07 21:47:45 +01:00
Russ Cox
5641a09171 lib9: fix windows build (don't use runesmprint)
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7575046
2013-03-07 14:38:49 -05:00
Robert Griesemer
6ee75663c9 go/types: more internal cleanups
R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/7492045
2013-03-07 11:17:30 -08:00
Dmitriy Vyukov
b000f2286c net: more refactoring in preparation for runtime integrated pollster
Move pollServer from fd_unix.go to fd_poll_unix.go.
Add pollServerInit(*NetFD) to allow custom initialization.
Add pollServer.Close(*NetFD) to allow custom finalization.
Move setDeadline() to fd_poll_unix.go to allow custom handling of deadlines.
Move newPollServer() to fd_poll_unix.go to allow custom initialization.
No logical code changes.
The next step will be to turn off fd_poll_unix.go for some platform
(I have changes for darwin/linux) and redirect it into runtime. See:
https://golang.org/cl/7569043/diff/2001/src/pkg/net/fd_poll_runtime.go

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7513045
2013-03-07 21:44:24 +04:00
Dmitriy Vyukov
cb945ba6ba runtime: fix deadlock
The deadlock episodically occurs on misc/cgo/test/TestCthread.
The problem is that starttheworld() leaves some P's with local work
without M's. Then all active M's enter into syscalls, but reject to
wake another M's due to the following check (both in entersyscallblock() and in retake()):
if(p->runqhead == p->runqtail &&
        runtime·atomicload(&runtime·sched.nmspinning) +
        runtime·atomicload(&runtime·sched.npidle) > 0)
        continue;

R=rsc
CC=golang-dev
https://golang.org/cl/7424054
2013-03-07 21:39:59 +04:00
Russ Cox
60f783d92b cmd/ld: host linking support for linux/amd64
Still to do: non-linux and non-amd64.
It may work on other ELF-based amd64 systems too, but untested.

"go test -ldflags -hostobj $GOROOT/misc/cgo/test" passes.

Much may yet change, but this seems a reasonable checkpoint.

R=iant
CC=golang-dev
https://golang.org/cl/7369057
2013-03-07 09:19:02 -05:00
Russ Cox
8aafb44b0b runtime: fix cgo callbacks on windows
Fixes #4955.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/7563043
2013-03-07 09:18:48 -05:00
Dmitriy Vyukov
0f136f2c05 net: fix accept/connect deadline handling
Ensure that accept/connect respect deadline,
even if the operation can be executed w/o blocking.
Note this changes external behavior, but it makes
it consistent with read/write.
Factor out deadline check into pollServer.PrepareRead/Write,
in preparation for edge triggered pollServer.
Ensure that pollServer.WaitRead/Write are not called concurrently
by adding rio/wio locks around connect/accept.

R=golang-dev, mikioh.mikioh, bradfitz, iant
CC=golang-dev
https://golang.org/cl/7436048
2013-03-07 17:03:40 +04:00
Mikio Hara
48fa4a10fb net: fix typo in skip message
R=golang-dev, akumar
CC=golang-dev
https://golang.org/cl/7523044
2013-03-07 19:17:18 +09:00
Mikio Hara
3fc244f370 net: fix plan9 build
R=golang-dev, akumar
CC=golang-dev
https://golang.org/cl/7564043
2013-03-07 19:15:00 +09:00
Tyler Bunnell
ae7aa345db cmd/fix: remove redundant 0 port
Fixes #4505.

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7468043
2013-03-07 19:06:19 +09:00
Rob Pike
bcb1da7065 all: delete a couple of mentions of the exp and old trees
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7551043
2013-03-06 16:52:03 -08:00
Robert Griesemer
0b2caf2717 go/types: implement constant string(x) conversions
Fixes #4982.

R=adonovan, r
CC=golang-dev
https://golang.org/cl/7537043
2013-03-06 16:15:04 -08:00
Robert Griesemer
b8db56ad2e go/types: cleanup of assignment checks
Also:
- cleaner handling of constants w/ unknown value
- removed several TODOs

R=adonovan
CC=golang-dev
https://golang.org/cl/7473043
2013-03-06 16:14:07 -08:00
Albert Strasheim
0a71a5b029 all: Skip AllocsPerRun tests if GOMAXPROCS>1.
Fixes #4974.

R=rsc, bradfitz, r
CC=golang-dev
https://golang.org/cl/7545043
2013-03-06 15:52:32 -08:00
Rob Pike
d07978a0f7 exp/norm: delete, part of moving to go.text
See also https://golang.org/cl/7520044

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7533044
2013-03-06 14:34:03 -08:00
Brad Fitzpatrick
a30bede5ef net/http: remove allocations in HeaderWriteSubset
Before:
BenchmarkHeaderWriteSubset  500000  2354 ns/op  197 B/op  2 allocs/op
After:
BenchmarkHeaderWriteSubset 1000000  2085 ns/op    0 B/op  0 allocs/op

Fixes #3761

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7508043
2013-03-06 14:10:47 -08:00
Russ Cox
fb59aed60b cmd/cgo: split cgo_export into cgo_export_static and cgo_export_dynamic
Also emit cgo_ldflag pragmas.

R=golang-dev, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/7530043
2013-03-06 16:57:14 -05:00
Russ Cox
56d1faa8b6 net/http/httputil: fix build
TBR=bradfitz
CC=golang-dev
https://golang.org/cl/7540043
2013-03-06 16:56:53 -05:00
Russ Cox
efd3d1ffe9 runtime: fix netbsd, windows build
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7539043
2013-03-06 16:55:08 -05:00
Russ Cox
48c1db4003 net/http: change user agent string
Some IDS somewhere thinks "Go http package" is a virus.
Make it something else for Go 1.1. Dumb but easy.

R=golang-dev, bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/7532043
2013-03-06 16:48:20 -05:00
Rob Pike
a25486e4b1 make.bash,bat: add -tags gotypes to the build
This installs type checking into go vet.
(To be removed before releasing Go 1.1)

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7528044
2013-03-06 13:16:43 -08:00
Rob Pike
0ed517e5e6 cmd/vet: isolate the type checking code into a separate file
We can enable/disable type checking with a build tag.
Should simplify cutting the go1.1 distribution free of go/types.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7482045
2013-03-06 12:49:56 -08:00
Russ Cox
7610a0552f lib9: add mktempdir, removeall, runprog
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7523043
2013-03-06 15:48:28 -05:00
Rob Pike
c76379954f text/template: improve error reporting for executing an empty template
Fixes #4522.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7502044
2013-03-06 12:34:19 -08:00
Ewan Chou
4f43201e51 strings: remove allocations in Split(s, "")
BenchmarkSplit1     77984460     24131380  -69.06%

R=golang-dev, rsc, minux.ma, dave, extemporalgenome
CC=golang-dev
https://golang.org/cl/7458043
2013-03-06 15:21:19 -05:00
Alex Brainman
2f23f90dab runtime,misc/cgo/test: disable broken tests so we can test the rest
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7486048
2013-03-06 15:19:01 -05:00
Alex Brainman
e44f42e056 libmach: fix amd64 pe handling
Fixes #4841.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7475046
2013-03-06 15:14:07 -05:00
Russ Cox
36b414f639 runtime: change amd64 startup convention
Now the default startup is that the program begins at _rt0_amd64_$GOOS,
which sets DI = argc, SI = argv and jumps to _rt0_amd64.

This makes the _rt0_amd64 entry match the expected semantics for
the standard C "main" function, which we can now provide for use when
linking against a standard C library.

R=golang-dev, devon.odell, minux.ma
CC=golang-dev
https://golang.org/cl/7525043
2013-03-06 15:03:04 -05:00
Brad Fitzpatrick
ce8341554c net/http: close TCP connection on Response.Body.Close
Previously the HTTP client's (*Response).Body.Close would try
to keep reading until EOF, hoping to reuse the keep-alive HTTP
connection, but the EOF might never come, or it might take a
long time. Now we immediately close the TCP connection if we
haven't seen EOF.

This shifts the burden onto clients to read their whole response
bodies if they want the advantage of reusing TCP connections.

In the future maybe we could decide on heuristics to read some
number of bytes for some max amount of time before forcefully
closing, but I'd rather not for now.

Statistically, touching this code makes things regress, so I
wouldn't be surprised if this introduces new bugs, but all the
tests pass, and I think the code is simpler now too. Maybe.

Please test your HTTP client code before Go 1.1.

Fixes #3672

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7419050
2013-03-05 18:47:27 -08:00
Nigel Tao
0d9bf2757e image/jpeg: for progressive JPEGs, the first SOS segment doesn't
necessarily contain all components.

Fixes #4975.

R=r, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/7469043
2013-03-06 10:08:46 +11:00
David Symonds
a22361d68d vet: check for useless assignments.
The only check so far is for self-assignments of the form "expr = expr",
but even that found one instance in the standard library.

R=r, adg, mtj, rsc
CC=golang-dev
https://golang.org/cl/7455048
2013-03-06 09:55:04 +11:00
Rob Pike
8cf6e75e2a cmd/vet: change some warnings to errors for consistency.
Fixes #4980.

R=golang-dev, rsc, dsymonds
CC=golang-dev
https://golang.org/cl/7479044
2013-03-05 14:31:17 -08:00
Russ Cox
e0deb2ef7f undo CL 7301062 / 9742f722b558
broke arm garbage collector

traceback_arm fails with a missing pc. It needs CL 7494043.
But that only makes the build break later, this time with
"invalid freelist". Roll back until it can be fixed correctly.

««« original CL description
runtime: restrict stack root scan to locals and arguments

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

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7493044
2013-03-05 15:36:40 -05:00
Robert Griesemer
d01516796c go/types: add test typechecking std lib
- run time is limited if -short is set
- also added missing TODO to unrelated file return.go

R=r
CC=golang-dev
https://golang.org/cl/7448052
2013-03-05 11:42:43 -08:00
Joel Sing
1b36bcc3b5 syscall: handle getsockname for unix sockets on openbsd 5.2
On OpenBSD 5.2, calling getsockname on an unbound Unix domain socket
results in a successful syscall, however the AF is unset and the length
is returned as zero. This has been changed to more portable behaviour,
which will be included in the OpenBSD 5.3 release.

For now, work around this by treating a successful getsockname() call
that returns a family of AF_UNSPEC and length of zero as a AF_UNIX
socket.

Makes TestPassFD work on OpenBSD 5.2.

Fixes #4956.

R=golang-dev, minux.ma, rsc, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7449046
2013-03-05 21:40:37 +11:00
Dmitriy Vyukov
add3349867 runtime: add atomic xchg64
It will be handy for network poller.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7429048
2013-03-05 09:46:52 +02:00
Dmitriy Vyukov
2fe840f4f6 runtime: fix false positive deadlock when using runtime.Goexit
Fixes #4893.
Actually it's fixed by cl/7314062 (improved scheduler),
just submitting the test.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7422054
2013-03-05 09:40:17 +02:00
Dmitriy Vyukov
d0c11d20b8 runtime: declare addtimer/deltimer in runtime.h
In preparation for integrated network poller
(https://golang.org/cl/7326051),
this is required to handle deadlines.

R=golang-dev, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/7446047
2013-03-05 09:38:15 +02:00
Carl Shapiro
db018bf77c runtime: restrict stack root scan to locals and arguments
R=rsc
CC=golang-dev
https://golang.org/cl/7301062
2013-03-04 19:48:50 -08:00
David Symonds
6a75252088 text/template/parse: remove self-assignment.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7431054
2013-03-05 11:16:58 +11:00
David Symonds
eeade74529 vet: clean up taglit error print when typechecking fails.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7416050
2013-03-05 09:56:46 +11:00
Robert Griesemer
6b34eba007 go/types: "missing return" check
Implementation closely based on Russ' CL 7440047.

Future work: The error messages could be better
(e.g., instead of "missing return" it might say
"missing return (no default in switch)", etc.).

R=adonovan, rsc
CC=golang-dev
https://golang.org/cl/7437049
2013-03-04 14:40:12 -08:00
Russ Cox
ecab408c42 cmd/gc: implement new return requirements
Fixes #65.

R=ken2
CC=golang-dev
https://golang.org/cl/7441049
2013-03-04 17:02:04 -05:00
Brad Fitzpatrick
9744c0e175 net: make some tests less flaky
Fixes #4969

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7456049
2013-03-04 11:55:27 -08:00
Russ Cox
6dc3c9cfdd cmd/cgo: use explicit flag to emit dynamic linker path
Using -import_runtime_cgo would have worked great except
that it doesn't get passed to the second invocation of cgo,
and that's the one that writes the relevant file.

Fixes ARM build on systems with a different dynamic linker
than the one 5l assumes (like Gentoo).

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7432048
2013-03-04 11:23:17 -05:00
Brad Fitzpatrick
7903e3600c net/http/cgi: maybe improve darwin test reliability
Use a 17 MB payload instead of a 1 MB payload, since
OS X can apparently buffer up to 16 MB in its pipes.

Fixes #4958 maybe

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7453049
2013-03-04 08:13:39 -08:00
Daniel Morsing
b65acaeab2 cmd/gc: disallow selectors to the blank identifier
Fixes #4941.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7415051
2013-03-04 17:01:42 +01:00
Jan Ziak
cea46387b9 runtime: add garbage collector statistics
If the constant CollectStats is non-zero and GOGCTRACE=1
the garbage collector will print basic statistics about executed
GC instructions.

R=golang-dev, dvyukov
CC=golang-dev, rsc
https://golang.org/cl/7413049
2013-03-04 16:54:37 +01:00
Rémy Oudompheng
a85fce282e cmd/gc: simplify and fix defaultlit.
Fixes #4882.
Fixes #4936.
Fixes #4937.

R=golang-dev, dave, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/7432044
2013-03-04 16:51:42 +01:00
Rémy Oudompheng
b0bb6f8cee cmd/gc: unbreak exporting of composite literals.
Fixes #4932.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/7437043
2013-03-04 16:42:03 +01:00
Russ Cox
69c90985b3 runtime: add link to design doc for new scheduler
R=golang-dev, remyoudompheng, bradfitz
CC=golang-dev
https://golang.org/cl/7419049
2013-03-04 10:36:45 -05:00
Stefan Nilsson
d4a020dec1 container/heap: fix int overflow bug
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7450052
2013-03-04 10:25:21 -05:00
Volker Dobler
9d6e02742c image/png: always set up palette during DecodeConfig
The old code would decode the palette only for 8-bit
images during a DecodeConfig.
This CL keeps the behavior for 8-bit images and sets
up the decoded palette also for 1, 2 and 4-bit images.

Fixes #4279.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/7421048
2013-03-04 14:54:36 +11:00
Andrew Gerrand
15825dc935 cmd/godoc: move note argument to godoc.go
Fixes the App Engine version of godoc. The other fix is to duplicate
this code inside appinit.go. I think initHandlers is the right place
to put the strings.Split call, as the notesToShow var is used by
docServer, which is what initHandlers sets up.

R=dsymonds
CC=golang-dev
https://golang.org/cl/7434044
2013-03-04 09:02:45 +11:00
Mikio Hara
51d52f820e net: disable unixgram test on Plan 9 and Windows
Fixes build on Plan 9 and Windows.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7454049
2013-03-03 20:06:51 +09:00