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

6979 Commits

Author SHA1 Message Date
Mikio Hara
f02cf1997d runtime: regenerate defs-files for freebsd
R=minux.ma, jsing
CC=golang-dev
https://golang.org/cl/6855080
2012-11-26 21:29:13 +09:00
Shenghou Ma
62f54e1294 net/http: clarify docs of ParseForm and mention ParseForm in docs for FormValue
while we're at it, also fix a return value stutter in ParseForm.

R=bradfitz
CC=golang-dev
https://golang.org/cl/6847074
2012-11-26 20:03:24 +08:00
Joel Sing
4047f300c9 runtime: implement SysUnused for netbsd
R=golang-dev, bradfitz, minux.ma, dave
CC=golang-dev
https://golang.org/cl/6842081
2012-11-26 22:34:01 +11:00
Joel Sing
c6afb781e2 runtime: implement SysUnused for openbsd
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6854079
2012-11-26 22:32:59 +11:00
Dave Cheney
73b3e2301e net: never return -1 bytes read from netFD.Read
If the a network read would block, and a packet arrived just before the timeout expired, then the number of bytes from the previous (blocking) read, -1, would be returned.

This change restores the previous logic, where n would be unconditionally set to 0 if err != nil, but was skipped due to a change in CL 6851096.

The test for this change is CL 6851061.

R=bradfitz, mikioh.mikioh, dvyukov, rsc
CC=golang-dev
https://golang.org/cl/6852085
2012-11-26 10:59:43 +11:00
Brad Fitzpatrick
f97bb12bb0 net/http/httptest: protect against port reuse
Should make BSDs more reliable. (they seem to reuse ports
quicker than Linux)

Tested by hand with local modifications to force reuse on
Linux. (net/http tests failed before, pass now) Details in the
issue.

Fixes #4436

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6847101
2012-11-25 15:23:20 -08:00
Brad Fitzpatrick
c8fa7dcc25 bytes, strings: fix Reader WriteTo return value on 0 bytes copied
Fixes #4421

R=golang-dev, dave, minux.ma, mchaten, rsc
CC=golang-dev
https://golang.org/cl/6855083
2012-11-25 09:04:13 -08:00
Mikio Hara
1fbe3090d8 runtime: fix madvise for freebsd/amd64
Make use of carry clear condition instead of low or same.

R=minux.ma, jsing, dave
CC=golang-dev
https://golang.org/cl/6844080
2012-11-25 18:46:41 +09:00
Dmitriy Vyukov
74fcf82dd9 net: add unit tests for read/write deadlines
The tests verify that deadlines are "persistent",
read/write deadlines do not interfere, can be reset,
read deadline can be set with both SetDeadline()
and SetReadDeadline(), etc.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6850070
2012-11-25 13:27:32 +04:00
Dave Cheney
1e9ab9e792 time: add Now()/UnixNano() malloc tests
The fix for issue 4403 may include more calls to time.Now().UnixNano(). I was concerned that if this function allocated it would cause additional garbage on the heap. It turns out that it doesn't, which is a nice surprise.

Also add benchmark for Now().UnixNano()

R=bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/6849097
2012-11-25 11:29:06 +11:00
Alex Brainman
747dda9767 net: do not start io if deadline has passed
R=golang-dev, mikioh.mikioh, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/6851098
2012-11-25 10:02:57 +11:00
Caine Tighe
7afcae6bab http/transport.go: trivial comment error.
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6856078
2012-11-25 05:08:17 +08:00
Brad Fitzpatrick
5fa3aeb14d net: check read and write deadlines before doing syscalls
Otherwise a fast sender or receiver can make sockets always
readable or writable, preventing deadline checks from ever
occuring.

Update #4191 (fixes it with other CL, coming separately)
Fixes #4403

R=golang-dev, alex.brainman, dave, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6851096
2012-11-23 22:15:26 -08:00
John Graham-Cumming
314fd62434 runtime: implement runtime.SysUnused on FreeBSD
madvise was missing so implement it in assembler. This change
needs to be extended to the other BSD variantes (Net and Open)

Without this change the scavenger will attempt to pass memory back
to the operating system when it has become idle, but the memory is
not returned and for long running Go processes the total memory used
can grow until OOM occurs.

I have only been able to test the code on FreeBSD AMD64. The ARM
platforms needs testing.

R=golang-dev, mikioh.mikioh, dave, jgc, minux.ma
CC=golang-dev
https://golang.org/cl/6850081
2012-11-24 15:55:19 +11:00
Dave Cheney
d4775a7814 net/http/httptest: fix possible race on historyListener.history
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6845077
2012-11-24 15:50:43 +11:00
Dave Cheney
dd43bf807d net/http: use runtime.Stack instead of runtime/debug.Stack
Fixes #4060.

2012/11/21 19:51:34 http: panic serving 127.0.0.1:47139: Kaaarn!
goroutine 7 [running]:
net/http.func·004(0x7f330807ffb0, 0x7f330807f100)
	/home/dfc/go/src/pkg/net/http/server.go:615 +0xa7
----- stack segment boundary -----
main.(*httpHandler).ServeHTTP()
	/home/dfc/src/httppanic.go:16 +0x53
net/http.(*conn).serve(0xc200090240, 0x0)
	/home/dfc/go/src/pkg/net/http/server.go:695 +0x55d
created by net/http.(*Server).Serve
	/home/dfc/go/src/pkg/net/http/server.go:1119 +0x36d

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6846085
2012-11-22 08:18:45 +11:00
Shenghou Ma
42c8904fe1 all: fix the the typos
Fixes #4420.

R=golang-dev, rsc, remyoudompheng
CC=golang-dev
https://golang.org/cl/6854080
2012-11-22 02:58:24 +08:00
Joel Sing
cd37fecffb runtime: update openbsd runtime to use new tfork syscall
Update OpenBSD runtime to use the new version of the sys___tfork
syscall and switch TLS initialisation from sys_arch to sys___set_tcb
(note that both of these syscalls are available in OpenBSD 5.2).

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6843058
2012-11-22 01:25:53 +11:00
Dave Cheney
d28133dc9f net: remove another unguarded sysfile == nil check
Putting aside the unguarded access to fd.sysfile, the condition will never be true as fd.incref above handles the closed condition.

R=mikioh.mikioh, dvyukov
CC=golang-dev
https://golang.org/cl/6845062
2012-11-21 15:04:22 +11:00
Shenghou Ma
7bce6f9386 net/http, net/http/httputil: fix TestChunkReaderAllocs failure when GOMAXPROCS > 1
R=fullung, bradfitz, dave
CC=golang-dev
https://golang.org/cl/6846081
2012-11-21 02:18:34 +08:00
Ian Lance Taylor
4bf261f9e3 exp/types: don't test importing types if using gccgo
The exp/types packages does not support the gccgo export data
format.  At some point it should, but not yet.

R=gri, bradfitz, r, iant, dsymonds
CC=golang-dev
https://golang.org/cl/6854068
2012-11-19 21:56:24 -08:00
Alex Brainman
54b9c20151 net/http/cgi: another attempt to fix windows tests
Also enables TestDirWindows test on windows.

Fixes #4401.

R=golang-dev, bradfitz
CC=golang-dev, krautz
https://golang.org/cl/6847072
2012-11-20 16:24:12 +11:00
Brad Fitzpatrick
9466c27fec net/http: remove more garbage from chunk reading
Noticed this while closing tabs. Yesterday I thought I could
ignore this garbage and hope that a fix for issue 2205 handled
it, but I just realized that's the opposite case,
string->[]byte, whereas this is []byte->string.  I'm having a
hard time convincing myself that an Issue 2205-style fix with
static analysis and faking a string header would be safe in
all cases without violating the memory model (callee assumes
frozen memory; are there non-racy ways it could keep being
modified?)

R=dsymonds
CC=dave, gobot, golang-dev
https://golang.org/cl/6850067
2012-11-19 19:50:42 -08:00
Brad Fitzpatrick
d32d1e098a mime/multipart: transparently decode quoted-printable transfer encoding
Fixes #4411

R=dsymonds
CC=gobot, golang-dev
https://golang.org/cl/6854067
2012-11-19 19:50:19 -08:00
Robert Griesemer
c00bda1352 go/printer: simply ignore filename changes in position information
There's no good reason to make any printer state adjustments
simply because the file name in node position information has
changed. Eliminate the relevant code.

R=r
CC=golang-dev
https://golang.org/cl/6856054
2012-11-19 13:23:32 -08:00
Brad Fitzpatrick
e070aeae77 net/http/cgi: more windows perl test work
Don't rely on finding cmd.exe in a particular spot.

Fixes #4401

R=golang-dev, krautz
CC=golang-dev
https://golang.org/cl/6842066
2012-11-19 10:40:13 -08:00
Christian Himpel
ca8aac698f runtime: gdb support: use parse_and_eval to get the goroutine id
This enables to loop over some goroutines, e.g. to print the
backtrace of goroutines 1 to 9:

        set $i = 1
        while $i < 10
        printf "backtrace of goroutine %d:\n", $i
        goroutine $i++ bt
        end

R=lvd, lvd
CC=golang-dev
https://golang.org/cl/6843071
2012-11-19 10:22:47 -08:00
Brad Fitzpatrick
c8e7469fcd net/http/cgi: make test more robust for Windows perl
Update #4401

R=golang-dev, mattn.jp
CC=golang-dev
https://golang.org/cl/6853067
2012-11-19 08:25:51 -08:00
Dave Cheney
c9856e7d22 net: fix data race on fd.sysfd
Fixes #4369.

Remove the check for fd.sysfd < 0, the first line of fd.accept() tests if the fd is open correctly and will handle the fd being closed during accept.

R=dvyukov, bradfitz
CC=golang-dev
https://golang.org/cl/6843076
2012-11-19 06:53:58 +11:00
Dave Cheney
0bfece06d7 net: remove unused nil check
This is part 1 of a series of proposals to fix issue 4369.

In resolving issue 3507 it was decided not to nil out the inner conn.fd field to avoid a race. This implies the checks for fd == nil inside incref/decref are never true.

Removing this logic removes one source of errClosing error values, which affects issue 4373 and moves towards bradfitz's request that fd.accept() return io.EOF when closed concurrently.

Update #4369.
Update #4373.

R=mikioh.mikioh, bradfitz, dvyukov, rsc
CC=golang-dev
https://golang.org/cl/6852057
2012-11-18 15:31:26 +11:00
Dave Cheney
4758f89ddb runtime/cgo: enable warnings and treat as errors
Enable warnings as errors during the cgo portion of runtime/cgo. iant requested that the list of flags match cmd/dist/build.c, but I would like to avoid the set of disabled warnings if possible.

ref: https://groups.google.com/d/topic/golang-nuts/TrCoVzIIG4M/discussion

requires: 6843061

R=minux.ma, iant
CC=golang-dev
https://golang.org/cl/6852055
2012-11-18 08:58:54 +11:00
Shenghou Ma
d1e06dab7c runtime: don't assume AT_RANDOM provide 4-byte aligned ptr
R=dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6854056
2012-11-18 02:47:17 +08:00
Robert Griesemer
80dcc434a8 go/doc: fix identifier blank import handling for examples
Replacement CL for 6813061; thanks to minux for prototyping.

Fixes #4300.

R=minux.ma
CC=golang-dev
https://golang.org/cl/6782082
2012-11-17 10:40:11 -08:00
Shenghou Ma
38458ce3fe crypto/md5: speed up aligned writes and test/bench unaligned writes
Write() can safely use uint32 loads when input is aligned.
Also add test and benchmarks for unaligned writes.

Benchmark result obtained by Dave Cheney on ARMv5TE @ 1.2GHz:
benchmark                       old ns/op    new ns/op    delta
BenchmarkHash8Bytes                  4104         3417  -16.74%
BenchmarkHash1K                     22061        11208  -49.20%
BenchmarkHash8K                    146630        65148  -55.57%
BenchmarkHash8BytesUnaligned         4128         3436  -16.76%
BenchmarkHash1KUnaligned            22054        21473   -2.63%
BenchmarkHash8KUnaligned           146658       146909   +0.17%

benchmark                        old MB/s     new MB/s  speedup
BenchmarkHash8Bytes                  1.95         2.34    1.20x
BenchmarkHash1K                     46.42        91.36    1.97x
BenchmarkHash8K                     55.87       125.74    2.25x
BenchmarkHash8BytesUnaligned         1.94         2.33    1.20x
BenchmarkHash1KUnaligned            46.43        47.69    1.03x
BenchmarkHash8KUnaligned            55.86        55.76    1.00x

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/6782072
2012-11-18 02:23:34 +08:00
Shenghou Ma
3513d84068 runtime/cgo: fix compilation on Windows with CFLAGS -Wall -Werror
also fix one out-of-date comment in cmd/ld/pe.c as well.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/6843061
2012-11-18 02:06:08 +08:00
Dave Cheney
7ec76e25b6 archive/zip: handle extra data headers with no body
Fixes #4393.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6854058
2012-11-18 00:45:47 +11:00
Robin Eklind
4f250132f7 archive/zip, crypto/tls, net/http: Fix print format errors.
All of the errors were located using "go vet ./..." in "src/pkg".

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6856056
2012-11-16 17:24:43 -08:00
Brad Fitzpatrick
f3e6b20606 net/http: reduce allocations in chunk reading & writing
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6847063
2012-11-16 13:25:01 -08:00
Robert Griesemer
de58eb9091 go/printer: leave indentation alone when printing nodes from different files
ASTs may be created by various tools and built from nodes of
different files. An incorrectly constructed AST will likely
not print at all, but a (structurally) correct AST with bad
position information should still print structurally correct.

One heuristic used was to reset indentation when the filename
in the position information of nodes changed. However, this
can lead to wrong indentation for structurally correct ASTs.

Fix: Don't change the indentation in this case.

Related to issue 4300.

R=r
CC=golang-dev
https://golang.org/cl/6849066
2012-11-16 13:17:12 -08:00
Robert Griesemer
a42e8a8086 go/ast: FuncType.Params may be nil (per AST documentation)
ast.Walk needs to check for it or it will crash.

R=r
CC=golang-dev
https://golang.org/cl/6852062
2012-11-16 11:53:26 -08:00
Dmitriy Vyukov
8f82bff545 runtime: hide mheap from race detector
This significantly decreases amount of shadow memory
mapped by race detector.
I haven't tested on Windows, but on Linux it reduces
virtual memory size from 1351m to 330m for fmt.test.
Fixes #4379.

R=golang-dev, alex.brainman, iant
CC=golang-dev
https://golang.org/cl/6849057
2012-11-16 20:06:11 +04:00
Oling Cat
aa3d05acc9 runtime: remove extra parentheses.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6843069
2012-11-16 23:09:37 +11:00
Joel Sing
aaf3b71288 crypto/tls: add support for loading EC X.509 key pairs
Add support for loading X.509 key pairs that consist of a certificate
with an EC public key and its corresponding EC private key.

R=agl
CC=golang-dev
https://golang.org/cl/6776043
2012-11-16 19:33:59 +11:00
Dmitriy Vyukov
9b4aaa418f syscall: fix data races in LazyDLL/LazyProc
Reincarnation of https://golang.org/cl/6817086 (sent from another account).
It is ugly because sync.Once will cause allocation of a closure.
Fixes #4343.

R=golang-dev, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/6856046
2012-11-16 12:06:48 +04:00
Marcel van Lohuizen
8b7ea6489c exp/locale/collate: changed implementation of Compare and CompareString to
compare incrementally. Also modified collation API to be more high-level
by removing the need for an explicit buffer to be passed as an argument.
This considerably speeds up Compare and CompareString.  This change also eliminates
the need to reinitialize the normalization buffer for each use of an iter. This
also significantly improves performance for Key and KeyString.

R=r, rsc
CC=golang-dev
https://golang.org/cl/6842050
2012-11-15 22:23:56 +01:00
Brad Fitzpatrick
0d0eff7165 os: add FileMode.IsRegular
API change.

R=golang-dev, r, iant, rsc
CC=golang-dev
https://golang.org/cl/6844048
2012-11-15 11:46:00 -08:00
Dmitriy Vyukov
27087022ce sync/atomic: fix race instrumentation
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6782075
2012-11-15 21:30:24 +04:00
Ian Lance Taylor
cc8bd8969f runtime/cgo: include <string.h> as needed so that strerror is declared
R=golang-dev, dave, jsing
CC=golang-dev
https://golang.org/cl/6847051
2012-11-14 22:04:03 -08:00
Robin Eklind
45b4867d0e strconv: Removed unnecessary use of goto. Made code easier to read.
R=gri
CC=gobot, golang-dev
https://golang.org/cl/6855048
2012-11-14 09:42:48 -08:00
Joel Sing
63315c0af1 crypto/x509: add support for SEC1/EC private keys.
Add support for parsing SEC1 EC private keys and PKCS8 encapsulated
EC private key structures.

R=agl
CC=golang-dev
https://golang.org/cl/6767045
2012-11-15 03:39:00 +11:00
Joel Sing
8c96e6d740 debug/elf: fix offset for GNU version symbols
Since we no longer skip the first entry when reading a symbol table,
we no longer need to allow for the offset difference when processing
the GNU version symbols.

Unbreaks builds on Linux.

R=golang-dev, agl, iant
CC=golang-dev
https://golang.org/cl/6843057
2012-11-15 03:36:19 +11:00
Joel Sing
76689845e3 debug/elf: do not skip first symbol in the symbol table
Do not skip the first symbol in the symbol table. Any other indexes
into the symbol table (for example, indexes in relocation entries)
will now refer to the symbol following the one that was intended.

Add an object that contains debug relocations, which debug/dwarf
failed to decode correctly. Extend the relocation tests to cover
this case.

Note that the existing tests passed since the symbol following the
symbol that required relocation is also of type STT_SECTION.

Fixes #4107.

R=golang-dev, mikioh.mikioh, iant, iant
CC=golang-dev
https://golang.org/cl/6848044
2012-11-15 02:24:14 +11:00
Dmitriy Vyukov
063c13a34c runtime/race: more precise handling of finalizers
Currently race detector runtime just disables race detection in the finalizer goroutine.
It has false positives when a finalizer writes to shared memory -- the race with finalizer is reported in a normal goroutine that accesses the same memory.
After this change I am going to synchronize the finalizer goroutine with the rest of the world in racefingo(). This is closer to what happens in reality and so
does not have false positives.
And also add README file with instructions how to build the runtime.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6810095
2012-11-14 16:58:10 +04:00
Dmitriy Vyukov
51e89f59b2 runtime: add RaceRead/RaceWrite functions
It allows to catch e.g. a data race between atomic write and non-atomic write,
or Mutex.Lock() and mutex overwrite (e.g. mu = Mutex{}).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6817103
2012-11-14 16:51:23 +04:00
Andrew Gerrand
e33b9f7815 regexp: add simple package-level example
Update #4125

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6846045
2012-11-14 10:43:21 +01:00
Joel Sing
7f70bb5913 syscall: regenerate z-files for openbsd/386
Regenerate z-files for OpenBSD/386 on OpenBSD 5.2.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6844044
2012-11-14 19:06:12 +11:00
Brad Fitzpatrick
56bcef02fc net/http: add missing error checking reading trailers
This is a simplified version of earlier versions of this CL
and now only fixes obviously incorrect things, without
changing the locking on bodyEOFReader.

I'd like to see if this is sufficient before changing the
locking.

Update #4191

R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/6739055
2012-11-13 22:38:25 -08:00
Robert Griesemer
aa38801788 reflect: fix FieldByNameFunc
The existing algorithm did not properly propagate the type
count from one level to the next, and as a consequence it
missed collisions.

Properly propagate multiplicity (count) information to the
next level.

benchmark                old ns/op    new ns/op    delta
BenchmarkFieldByName1          182          180   -1.10%
BenchmarkFieldByName2         6273         6183   -1.43%
BenchmarkFieldByName3        49267        46784   -5.04%

Fixes #4355.

R=rsc
CC=golang-dev
https://golang.org/cl/6821094
2012-11-13 10:45:30 -08:00
Russ Cox
1120982590 reflect: add ArrayOf, ChanOf, MapOf, SliceOf
In order to add these, we need to be able to find references
to such types that already exist in the binary. To do that, introduce
a new linker section holding a list of the types corresponding to
arrays, chans, maps, and slices.

To offset the storage cost of this list, and to simplify the code,
remove the interface{} header from the representation of a
runtime type. It was used in early versions of the code but was
made obsolete by the kind field: a switch on kind is more efficient
than a type switch.

In the godoc binary, removing the interface{} header cuts two
words from each of about 10,000 types. Adding back the list of pointers
to array, chan, map, and slice types reintroduces one word for
each of about 500 types. On a 64-bit machine, then, this CL *removes*
a net 156 kB of read-only data from the binary.

This CL does not include the needed support for precise garbage
collection. I have created issue 4375 to track that.

This CL also does not set the 'algorithm' - specifically the equality
and copy functions - for a new array correctly, so I have unexported
ArrayOf for now. That is also part of issue 4375.

Fixes #2339.

R=r, remyoudompheng, mirtchovski, iant
CC=golang-dev
https://golang.org/cl/6572043
2012-11-13 13:06:29 -05:00
Russ Cox
9799a5a4fd runtime: allow up to 128 GB of allocated memory
Incorporates code from CL 6828055.

Fixes #2142.

R=golang-dev, iant, devon.odell
CC=golang-dev
https://golang.org/cl/6826088
2012-11-13 12:45:08 -05:00
Joel Sing
fc5e64cb8f syscall: regenerate z-files for openbsd/amd64
Regenerate z-files for OpenBSD/amd64 on OpenBSD 5.2.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6843045
2012-11-14 03:19:34 +11:00
Mikio Hara
306afc7725 net: consolidate common socket functions for Plan 9
This CL extends changeset 13126:fc4a62e14aba to Plan 9.

R=ality, golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6820124
2012-11-13 16:18:37 +09:00
Mikio Hara
677c6e6ee7 net: protocol specific listen functions return a proper local socket address
When a nil listener address is passed to some protocol specific
listen function, it will create an unnamed, unbound socket because
of the nil listener address. Other listener functions may return
invalid address error.

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

Fixes #4190.
Fixes #3847.

R=rsc, iant
CC=golang-dev
https://golang.org/cl/6525048
2012-11-13 12:56:28 +09:00
Mikio Hara
0ae80785e6 net: make LocalAddr on multicast UDPConn return a listening address
The package go.net/ipv4 allows to exist a single UDP listener
that join multiple different group addresses. That means that
LocalAddr on multicast UDPConn returns a first joined group
address is not desirable.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6822108
2012-11-13 12:26:20 +09:00
Jeff R. Allen
7e7b89f7d0 net/textproto: faster header canonicalization with fewer allocations
By keeping a single copy of the strings that commonly show up
in headers, we can avoid one string allocation per header.

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

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

R=bradfitz, golang-dev, dave, rsc, jra
CC=golang-dev
https://golang.org/cl/6721055
2012-11-12 15:31:42 -08:00
Brad Fitzpatrick
73c67606e9 net/http: handle 413 responses more robustly
When HTTP bodies were too large and we didn't want to finish
reading them for DoS reasons, we previously found it necessary
to send a FIN and then pause before closing the connection
(which might send a RST) if we wanted the client to have a
better chance at receiving our error response. That was Issue 3595.

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

R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/6826084
2012-11-12 15:20:18 -08:00
David Symonds
80f4ff226f exp/types: avoid init race in check_test.go.
There was an init race between
	check_test.go:init
        universe.go:def
        use of Universe
and
	universe.go:init
        creation of Universe

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

R=gri
CC=golang-dev
https://golang.org/cl/6827076
2012-11-13 09:08:33 +11:00
Rick Arnold
c90739e41e encoding/json: skip unexpected null values
As discussed in issue 2540, nulls are allowed for any type in JSON so they should not result in an error during Unmarshal.
Fixes #2540.

R=rsc
CC=golang-dev
https://golang.org/cl/6759043
2012-11-12 15:35:11 -05:00
Roger Peppe
791fb978dd crypto/x509: implement EncryptPEMBlock
Arbitrary decisions: order of the arguments and the
fact it takes a block-type argument (rather than
leaving to user to fill it in later); I'm happy whatever
colour we want to paint it.

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

R=agl, agl
CC=golang-dev
https://golang.org/cl/6820114
2012-11-12 15:31:23 +00:00
Roger Peppe
1e1733a9ac encoding/pem: write Proc-Type header first.
See RFC 1421, section 4.6.1.1

R=agl, agl
CC=golang-dev
https://golang.org/cl/6814104
2012-11-12 15:29:17 +00:00
David McLeish
20a1815833 archive/zip: Fix bounds check panic for ZIP files with a truncated extra header.
R=adg, dave
CC=gobot, golang-dev
https://golang.org/cl/6811080
2012-11-12 12:21:00 +01:00
Ian Lance Taylor
e9a3087e29 runtime, runtime/cgo: track memory allocated by non-Go code
Otherwise a poorly timed GC can collect the memory before it
is returned to the Go program.

R=golang-dev, dave, dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/6819119
2012-11-10 11:19:06 -08:00
Mikio Hara
5612edb13e net: add more tests for protocol specific methods
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6821100
2012-11-10 14:34:34 +09:00
Ian Lance Taylor
5e57954f8c runtime/pprof: fix typo in comment
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6810102
2012-11-08 23:48:13 -08:00
Shenghou Ma
4022fc4e21 runtime: use vDSO clock_gettime for time.now & runtime.nanotime on Linux/amd64
Performance improvement aside, time.Now() now gets real nanosecond resolution
on supported systems.

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

R=golang-dev, bradfitz, iant, iant
CC=golang-dev
https://golang.org/cl/6814103
2012-11-09 14:19:07 +08:00
Mikio Hara
f668e0a5b3 net: consolidate multiple init functions
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6819117
2012-11-09 12:09:22 +09:00
Mikio Hara
e245ae7501 runtime: re-enable crash test on FreeBSD
It also passes on FreeBSD.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6812103
2012-11-09 10:05:46 +09:00
David Symonds
86b9e3e2b4 archive/tar: accept binary format when reading numeric header fields.
Fixes #4358.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6840043
2012-11-09 08:50:10 +11:00
Mikio Hara
5451708d5b net: fix non-unixen build
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6813101
2012-11-09 02:09:09 +09:00
Joel Sing
4e75d2c7d5 runtime: re-enable crash test on NetBSD
Re-enable the crash tests on NetBSD now that the issue has been
identified and fixed.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6813100
2012-11-09 03:41:43 +11:00
Dmitriy Vyukov
3f7f030c59 runtime: fix instrumentation of slice append for race detection
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6819107
2012-11-08 20:37:05 +04:00
Brad Fitzpatrick
ef6806fb13 net: close fds eagerly in DialTimeout
Integrates with the pollserver now.

Uses the old implementation on windows and plan9.

Fixes #2631

R=paul, iant, adg, bendaglish, rsc
CC=golang-dev
https://golang.org/cl/6815049
2012-11-08 10:35:16 -06:00
Shenghou Ma
48b739caac time: clarify why timer.Stop and ticker.Stop don't close the channel
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6818106
2012-11-08 23:25:48 +08:00
Anthony Martin
024a92c1da runtime: use vDSO for gettimeofday on linux/amd64
Intel Core 2 Duo (2.16 GHz) running 3.6.5-1-ARCH

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

R=rsc
CC=golang-dev
https://golang.org/cl/6826072
2012-11-07 18:29:31 -08:00
Nigel Tao
64b3e590c0 image/jpeg: handle fill bytes.
Fixes #4337.

R=r, minux.ma
CC=golang-dev
https://golang.org/cl/6814098
2012-11-08 10:36:29 +11:00
David Symonds
0ac317817b archive/tar: avoid writing ModTime that is out of range.
Update #4358
Still to do: support binary numeric format in Reader.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6818101
2012-11-08 08:22:40 +11:00
Rémy Oudompheng
f59a605645 runtime: use runtime·callers when racefuncenter's pc is on the heap.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6821069
2012-11-07 21:35:21 +01:00
Dmitriy Vyukov
1ebf2d85ba runtime/race: add Windows support
This is copy of https://golang.org/cl/6810080
but sent from another account (dvyukov@gmail.com is not in CONTRIBUTORS).

R=rsc
CC=golang-dev
https://golang.org/cl/6827060
2012-11-07 23:59:09 +04:00
Ian Lance Taylor
f8614a6645 reflect: fix test of whether structs are identical
The old code worked with gc, I assume because the linker
unified identical strings, but it failed with gccgo.

R=rsc
CC=gobot, golang-dev
https://golang.org/cl/6826063
2012-11-07 11:55:35 -08:00
Roger Peppe
768ba46cc1 crypto/x509: fix DecryptPEMBlock
The current implement can fail when the
block size is not a multiple of 8 bytes.
This CL makes it work, and also checks that the
data is in fact a multiple of the block size.

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

        int := "hello"
        j := 2

would normally turn into

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

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

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

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

Fixes #4326.

R=ken2
CC=golang-dev
https://golang.org/cl/6816100
2012-11-07 09:59:19 -05:00
Mikio Hara
63f29d17d1 net: fix protocol number for IPv6 test
The protocol number of ICMP for IPv6 is 58, not 1.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6810093
2012-11-07 21:55:29 +09:00
Dmitriy Vyukov
1a19f01a68 runtime/race: lazily allocate shadow memory
Currently race detector runtime maps shadow memory eagerly at process startup.
It works poorly on Windows, because Windows requires reservation in swap file
(especially problematic if several Go program runs at the same, each consuming GBs
of memory).
With this change race detector maps shadow memory lazily, so Go runtime must notify
about all new heap memory.
It will help with Windows port, but also eliminates scary 16TB virtual mememory
consumption in top output (which sometimes confuses some monitoring scripts).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6811085
2012-11-07 12:48:58 +04:00
Alex Brainman
eb2e6e59ee net: implement IPv6 support for windows
Thank you zhoumichaely for original CL 5175042.

Fixes #1740.
Fixes #2315.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev, zhoumichaely
https://golang.org/cl/6822045
2012-11-07 16:58:20 +11:00
Carl Mastrangelo
f8892fb395 crypto/sha1: Make sha-1 do block mixup in place
Benchmarks:

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

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

R=dave, rsc, iant
CC=golang-dev
https://golang.org/cl/6820096
2012-11-07 13:41:02 +11:00
Shenghou Ma
882eb608b1 sort: fix comment for various Search routines
Fixes #4205 (again).

R=r, 0xjnml
CC=golang-dev
https://golang.org/cl/6819082
2012-11-07 05:07:46 +08:00
Shenghou Ma
0e3f4fdb52 net/rpc: give hint to pass a pointer to Register
Fixes #4325.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6819081
2012-11-07 05:03:16 +08:00
Daniel Morsing
d098bffd84 cmd/gc, runtime: avoid unnecessary copy on type assertion.
When the first result of a type assertion is blank, the compiler would still copy out a potentially large non-interface type.

Fixes #1021.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6812079
2012-11-06 20:40:40 +01:00
Dmitriy Vyukov
0ead18c59e runtime: mark race instrumentation callbacks as nosplitstack
It speedups the race detector somewhat, but also prevents
getcallerpc() from obtaining lessstack().

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6812091
2012-11-06 20:54:22 +04:00
Dmitriy Vyukov
6ae448e8df runtime: fix deadlock in parallel for test
The deadlock occurs when another goroutine requests GC
during the test. When wait=true the test expects physical parallelism,
that is, that P goroutines are all active at the same time.
If GC is requested, then part of the goroutines are not scheduled,
so other goroutines deadlock.
With wait=false, goroutines finish parallel for w/o waiting for all
other goroutines.
Fixes #3954.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6820098
2012-11-06 20:11:16 +04:00
Dmitriy Vyukov
d6b9a03b7f runtime: disable parallel for tests under race detector.
The race detector does not understand ParFor synchronization, because it's implemented in C.
If run with -cpu=2 currently race detector says:
 WARNING: DATA RACE
 Read by goroutine 5:
  runtime_test.TestParForParallel()
      src/pkg/runtime/parfor_test.go:118 +0x2e0
  testing.tRunner()
      src/pkg/testing/testing.go:301 +0x8f
 Previous write by goroutine 6:
  runtime_test.func·024()
      src/pkg/runtime/parfor_test.go:111 +0x52

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6811082
2012-11-06 12:09:40 +04:00
Shenghou Ma
834028d527 net: fix timeout slack calculation
R=alex.brainman
CC=golang-dev
https://golang.org/cl/6816085
2012-11-04 18:07:59 +08:00
Alex Brainman
a906f9aa86 net: do not test TestReadWriteDeadline timeout upper bound during short test
It also increases timeout deltas to allow for longer wait.
Also disables this test on plan9.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6821062
2012-11-04 12:41:49 +11:00
Rob Pike
20548b153f sort: make return value for 'not found' clearer in docs
It was well-defined but easy to miss that the return value for
"not found" is len(input) not -1 as many expect.

Fixes #4205.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6820080
2012-11-02 16:17:34 -07:00
Dmitriy Vyukov
600de1fb3d net/http: fix data race in test
The issue is that server still sends body,
when client closes the fd.
Fixes #4329.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6822072
2012-11-03 00:26:36 +04:00
Shenghou Ma
31f8b07e55 runtime/cgo, go/build: cgo support for FreeBSD/ARM
This is the last CL for FreeBSD/ARM support.
Also update cmd/ld/doc.go for 5l support of -Hfreebsd.

R=rsc
CC=golang-dev
https://golang.org/cl/6650051
2012-11-03 02:22:37 +08:00
Alex Brainman
90d959be78 net: add missing locking in windows Shutdown
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6811069
2012-11-02 20:46:47 +11:00
Nigel Tao
d659633aff image/png: update palette out-of-bounds comment.
R=r
CC=golang-dev
https://golang.org/cl/6817070
2012-11-02 17:20:19 +11:00
Alex Brainman
84e20465fc net: use better error messages on windows
Fixes #4320.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6810064
2012-11-02 11:07:22 +11:00
Robert Griesemer
048323aa12 go/ast: document use of Data field for method objects
R=iant
CC=golang-dev
https://golang.org/cl/6775093
2012-11-01 16:27:43 -07:00
Robert Griesemer
159302f36f exp/types: move exp/types/staging -> exp/types
- removes exp/types/staging
- the only code change is in exp/gotype/gotype.go

R=iant
CC=golang-dev
https://golang.org/cl/6822068
2012-11-01 15:38:17 -07:00
Robert Griesemer
98133ac03a exp/types, exp/gotype: remove exp/types
The only code change is in exp/gotype/gotype.go.
The latest reviewed version of exp/types is now
exp/types/staging.

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

R=iant
CC=golang-dev
https://golang.org/cl/6819071
2012-11-01 15:25:51 -07:00
Eric Roshan-Eisner
03c52a5d65 crypto: use better hash benchmarks
Labels the existing benchmark as stream, and add benchmarks that
compute the checksum.

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/6814060
2012-11-01 16:21:18 -04:00
Rémy Oudompheng
824b332652 net: fix race in TestReadWriteDeadline.
Discovered by adding OBLOCK support to race
instrumentation.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6819067
2012-11-01 20:52:30 +01:00
Robert Griesemer
27c990e794 encoding/binary: skip blank fields when (en/de)coding structs
- minor unrelated cleanups
- performance impact in the noise

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

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

Fixes #4185.

R=r, rsc
CC=golang-dev
https://golang.org/cl/6750053
2012-11-01 12:39:20 -07:00
Han-Wen Nienhuys
4094c1bae7 syscall: add {Get,Set,List,Remove}xattr on Linux.
R=golang-dev, minux.ma, fullung, dave, rsc, hanwenn
CC=golang-dev
https://golang.org/cl/6350074
2012-11-01 14:49:38 -04:00
Rémy Oudompheng
ce287933d6 cmd/gc, runtime: pass PC directly to racefuncenter.
go test -race -run none -bench . encoding/json
benchmark                      old ns/op    new ns/op    delta
BenchmarkCodeEncoder          3207689000   1716149000  -46.50%
BenchmarkCodeMarshal          3206761000   1715677000  -46.50%
BenchmarkCodeDecoder          8647304000   4482709000  -48.16%
BenchmarkCodeUnmarshal        8032217000   3451248000  -57.03%
BenchmarkCodeUnmarshalReuse   8016722000   3480502000  -56.58%
BenchmarkSkipValue           10340453000   4560313000  -55.90%

benchmark                       old MB/s     new MB/s  speedup
BenchmarkCodeEncoder                0.60         1.13    1.88x
BenchmarkCodeMarshal                0.61         1.13    1.85x
BenchmarkCodeDecoder                0.22         0.43    1.95x
BenchmarkCodeUnmarshal              0.24         0.56    2.33x
BenchmarkCodeUnmarshalReuse         0.24         0.56    2.33x
BenchmarkSkipValue                  0.19         0.44    2.32x

Fixes #4248.

R=dvyukov, golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6815066
2012-11-01 19:43:29 +01:00
Robert Griesemer
5d15963a1f exp/types/staging: filling in more blanks
- simplified assignment checking by removing duplicate code
- implemented field lookup (methods, structs, embedded fields)
- importing methods (not just parsing them)
- type-checking functions and methods
- typechecking more statements (inc/dec, select, return)
- tracing support for easier debugging
- handling nil more correctly (comparisons)
- initial support for [...]T{} arrays
- initial support for method expressions
- lots of bug fixes

All packages under pkg/go as well as pkg/exp/types typecheck
now with pkg/exp/gotype applied to them; i.e., a significant
amount of typechecking works now (several statements are not
implemented yet, but handling statements is almost trivial in
comparison with typechecking expressions).

R=rsc
CC=golang-dev
https://golang.org/cl/6768063
2012-11-01 11:23:27 -07:00
Ian Lance Taylor
f07f9de8ec go/build: support compiler as build constraint
This supports writing different .c/.s code when using gccgo.

R=golang-dev, dsymonds, iant, rsc
CC=golang-dev
https://golang.org/cl/6823055
2012-11-01 11:12:15 -07:00
Ryan Hitchman
c7873ff2a6 compress/flate: shrink decompressor struct for better performance
Helps with issue 2703.

R=dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/5536078
2012-11-01 13:57:24 -04:00
Jan Ziak
5c1422afab runtime: move Itab to runtime.h
The 'type' field of Itab will be used by the garbage collector.

R=rsc
CC=golang-dev
https://golang.org/cl/6815059
2012-11-01 13:13:20 -04:00
Alexey Borzenkov
1eae1252e9 net: fix a bad cast in dnsmsg.go
Incorrect cast was causing panics when
calling String() on dnsMsg with dnsRR_A
answers.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6818043
2012-11-01 12:57:44 -04:00
Jan Ziak
e0c9d04aec runtime: add memorydump() debugging function
R=golang-dev
CC=golang-dev, remyoudompheng, rsc
https://golang.org/cl/6780059
2012-11-01 12:56:25 -04:00
Mikio Hara
b602c3dbbd all: clear execute bit
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6826044
2012-11-01 10:04:42 +09:00
Nigel Tao
de6bf20496 image/png: degrade gracefully for palette index values that aren't
defined by the PLTE chunk. Such pixels decode to opaque black,
which matches what libpng does.

Fixes #4319.

On my reading, the PNG spec isn't clear whether palette index values
outside of those defined by the PLTE chunk is an error, and if not,
what to do.

Libpng 1.5.3 falls back to opaque black. png_set_PLTE says:

/* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
 * of num_palette entries, in case of an invalid PNG file that has
 * too-large sample values.
 */
png_ptr->palette = (png_colorp)png_calloc(png_ptr,
        PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color));

ImageMagick 6.5.7 returns an error:

$ convert -version
Version: ImageMagick 6.5.7-8 2012-08-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
Features: OpenMP
$ convert packetloss.png x.bmp
convert: Invalid colormap index `packetloss.png' @ image.c/SyncImage/3849.

R=r
CC=golang-dev
https://golang.org/cl/6822065
2012-11-01 11:46:06 +11:00
Adam Langley
5176481f16 crypto/cipher: add examples
Fixes #1390.

R=golang-dev, minux.ma, adg, agl
CC=golang-dev
https://golang.org/cl/6631044
2012-10-31 16:37:26 -04:00
Rob Pike
a90b3a5528 strconv: update to unicode 6.2.0
Fixes build, too.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6775088
2012-10-31 10:11:04 -07:00
Marcel van Lohuizen
e14cf90a8b unicode: move unicode and related packages to Unicode 6.2.0.
R=r, mpvl
CC=golang-dev
https://golang.org/cl/6818067
2012-10-31 17:32:16 +01:00
Marcel van Lohuizen
b8b329451c exp/locale/collate: implementation of tailorings and table generation.
Tailorings are represented by removing and reinserting entries from a linked list.
After all tailorings are done, missing weights are computed and verified.
This implementation assumes that entries that are used in expansions are not
reinserted at a later point.  This considerably simplifies the implementation.

R=r
CC=golang-dev
https://golang.org/cl/6739052
2012-10-31 14:28:44 +01:00
Marcel van Lohuizen
4c1a6f84f8 exp/locale/collate: removed weights struct to allow for faster and easier
incremental comparisons. Instead, processing is now done directly on colElems.
As a result, the size of the weights array is now reduced by 75%.
Details:
- Primary value of type 1 colElem is shifted by 1 bit so that primaries
  of all types can be compared without shifting.
- Quaternary values are now stored in the colElem itself. This is possible
  as quaternary values other than 0 or maxQuaternary are only needed when other
  values are ignored.
- Simplified processWeights by removing cases that are needed for ICU but not
  for us (our CJK primary values fit in a single value).

R=r
CC=golang-dev
https://golang.org/cl/6817054
2012-10-31 14:28:18 +01:00
Marcel van Lohuizen
bc0783dbe5 exp/locale/collate: add context to entry.
R=r
CC=golang-dev
https://golang.org/cl/6727049
2012-10-31 14:02:43 +01:00
Peter Waller
3494010f7d syscall/exec_linux: enable changing controlling tty
As discussed in the following thread:
https://groups.google.com/forum/?fromgroups=#!topic/golang-dev/emeJffxWhVo

This is required to enable applications such as `less` to use something
other than stdin as the controlling terminal.

R=dave, iant
CC=bradfitz, golang-dev
https://golang.org/cl/6785057
2012-10-30 17:36:18 -07:00
Alex Brainman
fa3e4fc429 net: fix connection resets when closed on windows
It is common to close network connection while another goroutine is
blocked reading on another goroutine. This sequence corresponds to
windows calls to WSARecv to start io, followed by GetQueuedCompletionStatus
that blocks until io completes, and, finally, closesocket called from
another thread. We were expecting that closesocket would unblock
GetQueuedCompletionStatus, and it does, but not always
(http://code.google.com/p/go/issues/detail?id=4170#c5). Also that sequence
results in connection is being reset.

This CL inserts CancelIo between GetQueuedCompletionStatus and closesocket,
and waits for both WSARecv and GetQueuedCompletionStatus to complete before
proceeding to closesocket.  This seems to fix both connection resets and
issue 4170. It also makes windows code behave similar to unix version.

Unfortunately, CancelIo needs to be called on the same thread as WSARecv.
So we have to employ strategy we use for connections with deadlines to
every connection now. It means, there are 2 unavoidable thread switches
for every io. Some newer versions of windows have new CancelIoEx api that
doesn't have these drawbacks, and this CL uses this capability when available.
As time goes by, we should have less of CancelIo and more of CancelIoEx
systems. Computers with CancelIoEx are also not affected by issue 4195 anymore.

Fixes #3710
Fixes #3746
Fixes #4170
Partial fix for issue 4195

R=golang-dev, mikioh.mikioh, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6604072
2012-10-31 10:24:37 +11:00
Nigel Tao
ad487dad75 image/jpeg: don't call ensureNBits unless we have to.
benchmark                     old ns/op    new ns/op    delta
BenchmarkDecodeBaseline         3155638      2783998  -11.78%
BenchmarkDecodeProgressive      4008088      3660310   -8.68%

R=r, bradfitz
CC=golang-dev
https://golang.org/cl/6775072
2012-10-31 10:02:11 +11:00
Alexey Borzenkov
d12a7d39d1 net: use read deadline in Accept on windows
Fixes #4296.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/6815044
2012-10-31 09:58:05 +11:00
Rob Pike
8884fabfd7 reflect: improve documentation for DeepEqual regarding maps
Keys use ==; values use deep equality. Also remove the word 'member'.
Fixes #4258.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6812055
2012-10-30 14:42:47 -07:00
Robert Griesemer
465b9c35e5 gofmt: apply gofmt -w src misc
Remove trailing whitespace in comments.
No other changes.

R=r
CC=golang-dev
https://golang.org/cl/6815053
2012-10-30 13:38:01 -07:00
Robert Griesemer
db2b6ed854 go/printer, gofmt: trim trailing whitespace in comments
Also: updated go fix testcases to pass tests.

Fixes #4310.

R=r
CC=golang-dev
https://golang.org/cl/6810055
2012-10-30 13:09:47 -07:00
Dave Cheney
640d818f2a archive/zip: handle corrupt extra data records
Fixes #4302.

R=golang-dev, bradfitz, adg
CC=golang-dev
https://golang.org/cl/6811048
2012-10-31 03:51:59 +11:00
Robert Griesemer
d77eb12998 exp/gotype: add more test packages
R=r
CC=golang-dev
https://golang.org/cl/6822051
2012-10-30 09:42:43 -07:00
Brad Fitzpatrick
1d61c9bb3e io: add ByteWriter interface
API change.

R=golang-dev, dsymonds, nigeltao, rsc, r
CC=golang-dev
https://golang.org/cl/6760045
2012-10-30 10:51:29 +01:00
Nigel Tao
daf43ba476 image/jpeg: change block from [64]int to [64]int32.
On 6g/linux:
benchmark                     old ns/op    new ns/op    delta
BenchmarkFDCT                      4606         4241   -7.92%
BenchmarkIDCT                      4187         3923   -6.31%
BenchmarkDecodeBaseline         3154864      3170224   +0.49%
BenchmarkDecodeProgressive      4072812      4017132   -1.37%
BenchmarkEncode                39406920     34596760  -12.21%

Stack requirements before (from 'go tool 6g -S'):
(scan.go:37) TEXT    (*decoder).processSOS+0(SB),$1352-32
(writer.go:448) TEXT    (*encoder).writeSOS+0(SB),$5344-24

after:
(scan.go:37) TEXT    (*decoder).processSOS+0(SB),$1064-32
(writer.go:448) TEXT    (*encoder).writeSOS+0(SB),$2520-24

Also, in encoder.writeSOS, re-use the yBlock scratch buffer for Cb and
Cr. This reduces the stack requirement slightly, but also avoids an
unlucky coincidence where a BenchmarkEncode stack split lands between
encoder.writeByte and bufio.Writer.WriteByte, which occurs very often
during Huffman encoding and is otherwise disasterous for the final
benchmark number. FWIW, the yBlock re-use *without* the s/int/int32/
change does not have a noticable effect on the benchmarks.

R=r
CC=golang-dev, rsc
https://golang.org/cl/6823043
2012-10-30 11:10:08 +11:00
Roger Peppe
9c775353b9 encoding/json: tweak docs
"JSON object" means something specific, which
isn't the case here.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6789044
2012-10-29 20:58:24 +01:00
Dmitriy Vyukov
c242aa34cc syscalls: annotate Sendfile() for race detector
Fixes #4306.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6816054
2012-10-29 23:15:06 +04:00
Pawel Szczur
4918e3a960 net/http/client.go: fix cookie handling on (*Client) Do()
Fix the problem with no cookie handling when sending
other than GET or HEAD request through
(*Client) Do(*Request) (*Resposne, error).
https://code.google.com/p/go/issues/detail?id=3985

Adds a function (*Client) send(*Request) (*Reponse, error):
- sets cookies from CookieJar to request,
- sends request
- parses a reply cookies and updates CookieJar

Fixes #3985

R=bradfitz
CC=gobot, golang-dev
https://golang.org/cl/6653049
2012-10-29 17:56:31 +01:00
Adam Langley
184e7a2bf2 crypto/x509: always write validity times in UTC.
RFC 5280 section 4.1.2.5.1 says so.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6775068
2012-10-29 11:16:58 -04:00
Adam Langley
4d17fe3cd6 encoding/asn1: don't convert UTCTime to UTC.
Previously we converted a time to UTC *and* serialized the timezone of
the original time. With this change, we serialize a UTCTime in the
original timezone.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6817048
2012-10-29 11:16:05 -04:00
Taj Khattra
1158c6b9c6 container/list: fix typo
R=golang-dev, fullung, dave, minux.ma
CC=golang-dev
https://golang.org/cl/6682046
2012-10-28 21:16:50 +11:00
Patrick Smith
3c808164ad sort: Fixed a typo in the documentation for SearchStrings.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6777066
2012-10-28 10:07:59 +11:00
Ian Lance Taylor
5611e8b59f syscall: fix creds_test to reliably close os.File
Before this patch the test would close the file descriptor but
not the os.File.  When the os.File was GC'ed, the finalizer
would close the file descriptor again.  That would cause
problems if the same file descriptor were returned by a later
call to open in another test.

On my system:

> GOGC=30 go test
--- FAIL: TestPassFD (0.04 seconds)
passfd_test.go:62: 	FileConn: dup: bad file descriptor
FAIL

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6776053
2012-10-26 10:31:03 -07:00
Shenghou Ma
f9902c7197 encoding/binary: ReadVarint reads a signed number, not unsigned number
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6762051
2012-10-26 21:14:34 +08:00
Dave Cheney
067315c647 net: avoid allocation in setAddr
setAddr was showing up in profiles due to string concatenation construction the os.File name field. netFD.sysfile's Name() is never used, except in dup() so I believe it is safe to avoid this allocation.

R=mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/6742058
2012-10-26 19:41:21 +11:00
Rémy Oudompheng
38070a72c5 reflect: stop thinking that MaxFloat32 overflows float32.
Fixes #4282.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6759052
2012-10-26 08:39:36 +02:00
Dmitriy Vyukov
320df44f04 runtime: switch to 64-bit goroutine ids
Fixes #4275.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6759053
2012-10-26 10:13:06 +04:00
Marcel van Lohuizen
b575e3ca99 exp/locale/collate: slightly changed collation elements:
- Allow secondary values below the default value in second form. This is
  to support before tags for secondary values, as used by Chinese.
- Eliminate collation elements that are guaranteed to be immaterial
  after a weight increment.

R=r
CC=golang-dev
https://golang.org/cl/6739051
2012-10-25 13:02:31 +02:00
Shenghou Ma
7c412e962c syscall: implement (*PtraceRegs).PC() and SetPC()
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6763043
2012-10-25 13:41:04 +08:00
Marcel van Lohuizen
6653d76ef6 exp/locale/collate/build: fixed problem where blocks for first byte need
different indexes for values and index blocks. Fixes many regressions.

R=r
CC=golang-dev
https://golang.org/cl/6737057
2012-10-24 11:41:05 +02:00
Marcel van Lohuizen
34f2050626 exp/locale/collate: clarification in comments on use of returned value.
R=r
CC=golang-dev
https://golang.org/cl/6752043
2012-10-24 11:40:32 +02:00
Marcel van Lohuizen
a35f23f34e exp/locale/collate/tools/colcmp: add locale to output of regression failure.
R=r
CC=golang-dev
https://golang.org/cl/6749058
2012-10-24 11:28:18 +02:00
Shenghou Ma
7c44edf425 runtime, runtime/race: add missing if(raceenabled), update package docs of pkg race
R=dvyukov
CC=golang-dev
https://golang.org/cl/6733058
2012-10-23 02:33:51 +08:00
Robert Griesemer
7c03cd32b6 exp/type/staging: implemented recent spec changes
Also:
- type-checking receivers
- get rid of some multiple errors at the same position

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6709061
2012-10-22 11:28:21 -07:00
Nigel Tao
eb7d56965b os: fix documentation typos: s/an array/a slice/.
R=dsymonds
CC=golang-dev
https://golang.org/cl/6736057
2012-10-22 16:26:47 +11:00
Patrick Smith
2e67dd861d encoding/xml: expand allowed entity names
Previously, multi-byte characters were not allowed. Also certain single-byte
characters, such as '-', were disallowed.
Fixes #3813.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6641052
2012-10-21 20:33:24 -04:00
Jingcheng Zhang
5d05c7800e runtime: sizeclass in MSpan should be int32.
R=golang-dev, minux.ma, dave, rsc
CC=golang-dev
https://golang.org/cl/6643046
2012-10-21 20:32:43 -04:00
Nigel Tao
80c4eac637 go/build: document the behavior of multiple build constraints.
R=rsc, pkleiweg
CC=golang-dev
https://golang.org/cl/6725052
2012-10-22 11:15:17 +11:00
Jan Ziak
4a191c2c1b runtime: store types of allocated objects
R=rsc
CC=golang-dev
https://golang.org/cl/6569057
2012-10-21 17:41:32 -04:00
Mikio Hara
4545dc6a69 net: add test for Conn, PacketConn and Listener
I just realized that there is no good place for adding
exposed function or method tests because server, unicast
and multicast_test.go do test complicated multiple test
objects, platform behaviros, protocol behaviors and API,
at the same time. Perhaps splitting them into per test
object might be better, so this CL provides tests focused
on API.

R=rsc
CC=gobot, golang-dev
https://golang.org/cl/6501057
2012-10-21 17:17:51 -04:00
Evan Shaw
772decbc80 reflect: make Index and Slice accept strings
Fixes #3284.

R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/6643043
2012-10-21 17:02:10 -04:00
Shenghou Ma
c1b7ddc6aa runtime: update docs for MemStats.PauseNs
PauseNs is a circular buffer of recent pause times, and the
most recent one is at [((NumGC-1)+256)%256].

   Also fix comments cross-linking the Go and C definition of
various structs.

R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/6657047
2012-10-22 01:08:13 +08:00
Shenghou Ma
3e3fa7b5f1 runtime: ~3.7x speed up of div/mod on ARM
benchmark                      old ns/op    new ns/op    delta
BenchmarkUint32Div7                  281           75  -73.06%
BenchmarkUint32Div37                 281           75  -73.02%
BenchmarkUint32Div123                281           75  -73.02%
BenchmarkUint32Div763                280           75  -72.89%
BenchmarkUint32Div1247               280           75  -72.93%
BenchmarkUint32Div9305               281           75  -73.02%
BenchmarkUint32Div13307              281           75  -73.06%
BenchmarkUint32Div52513              281           75  -72.99%
BenchmarkUint32Div60978747           281           63  -77.33%
BenchmarkUint32Div106956295          280           63  -77.21%
BenchmarkUint32Mod7                  280           77  -72.21%
BenchmarkUint32Mod37                 280           77  -72.18%
BenchmarkUint32Mod123                280           77  -72.25%
BenchmarkUint32Mod763                280           77  -72.18%
BenchmarkUint32Mod1247               280           77  -72.21%
BenchmarkUint32Mod9305               280           77  -72.21%
BenchmarkUint32Mod13307              280           77  -72.25%
BenchmarkUint32Mod52513              280           77  -72.18%
BenchmarkUint32Mod60978747           280           63  -77.25%
BenchmarkUint32Mod106956295          280           63  -77.21%

R=dave, rsc
CC=dave, golang-dev, rsc
https://golang.org/cl/6717043
2012-10-20 16:40:19 +08:00
Nigel Tao
0ba5ec53b0 bufio: remove a little unnecessary indirection in tests.
R=mchaten, r
CC=golang-dev
https://golang.org/cl/6739045
2012-10-20 13:02:29 +11:00
Oling Cat
c117da37a2 unsafe: fix a typo
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6736048
2012-10-19 16:35:15 +11:00
Nigel Tao
e55fdff210 bufio: make Writer.ReadFrom not flush prematurely. For example,
many small writes to a network may be less efficient that a few
large writes.

This fixes net/http's TestClientWrites, broken by 6565056 that
introduced Writer.ReadFrom. That test implicitly assumed that
calling io.Copy on a *bufio.Writer wouldn't write to the
underlying network until the buffer was full.

R=dsymonds
CC=bradfitz, golang-dev, mchaten, mikioh.mikioh
https://golang.org/cl/6743044
2012-10-19 16:32:00 +11:00
Michael Chaten
2a4818dd11 bufio: Implement io.ReaderFrom for (*Writer).
This is part 2 of 2 for issue 4028.

benchmark                        old ns/op    new ns/op    delta
BenchmarkWriterCopyOptimal           53293        28326  -46.85%
BenchmarkWriterCopyUnoptimal         53757        30537  -43.19%
BenchmarkWriterCopyNoReadFrom        53192        36642  -31.11%

Fixes #4028.

R=nigeltao
CC=golang-dev
https://golang.org/cl/6565056
2012-10-19 11:22:51 +11:00
Nigel Tao
90ad6a2d11 runtime: update comment for the "extern register" variables g and m.
R=rsc, minux.ma, ality
CC=dave, golang-dev
https://golang.org/cl/6620050
2012-10-19 11:02:32 +11:00
Nigel Tao
5abf4bdc27 image/draw: fast-path for 4:4:0 chroma subsampled sources.
R=r
CC=golang-dev
https://golang.org/cl/6699049
2012-10-19 10:55:41 +11:00
Ian Lance Taylor
1e6d9f49da encoding/xml: correctly escape newline, carriage return, and tab
The generated encodings are those from
http://www.w3.org/TR/2000/WD-xml-c14n-20000119.html#charescaping

The change to the decoder ensures that we turn &#xD; in the
input into \r, not \n.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6747043
2012-10-18 13:40:45 -07:00
Rémy Oudompheng
2abaaefa72 image/jpeg: make TestDCT faster.
The value of cosines are cached in a global array
instead of being recomputed each time.
The test was terribly slow on arm.

R=golang-dev, dave, nigeltao
CC=golang-dev
https://golang.org/cl/6733046
2012-10-18 21:28:04 +02:00
Stephen McQuay
a5b0c67d5f net: add LookupNS(domain string)
Fixes #4224.

R=golang-dev, dave, minux.ma, mikioh.mikioh, alex.brainman, rsc, herbert.fischer
CC=golang-dev
https://golang.org/cl/6675043
2012-10-18 15:39:04 +09:00
Nigel Tao
9dc3152668 exp/html: update package docs and add an example; a node's children is
a linked list, not a slice.

R=r, minux.ma
CC=golang-dev
https://golang.org/cl/6618055
2012-10-18 10:25:50 +11:00
Rémy Oudompheng
a4682348c2 cmd/gc: don't squash complex literals when inlining.
Since this patch changes the way complex literals are written
in export data, there are a few other glitches.

Fixes #4159.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6674047
2012-10-17 20:33:44 +02:00
Shane Hansen
fcd5fd2ad4 crypto/cipher: panic on invalid IV length
Give better user feedback when invalid IV is used
to construct a cipher.

Fixes #3411

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/6652053
2012-10-17 14:29:00 -04:00
Adam Langley
73f11171b4 math/big: add 4-bit, fixed window exponentiation.
A 4-bit window is convenient because 4 divides both 32 and 64,
therefore we never have a window spanning words of the exponent.
Additionaly, the benefit of a 5-bit window is only 2.6% at 1024-bits
and 3.3% at 2048-bits.

This code is still not constant time, however.

benchmark                        old ns/op    new ns/op    delta
BenchmarkRSA2048Decrypt           17108590     11180370  -34.65%
Benchmark3PrimeRSA2048Decrypt     13003720      7680390  -40.94%

R=gri
CC=golang-dev
https://golang.org/cl/6716048
2012-10-17 11:19:26 -04:00
Shenghou Ma
ace9ff4578 sync/atomic: FreeBSD/ARM support
only supports ARMv6K and newer ARM cores.

R=rsc, dave
CC=golang-dev
https://golang.org/cl/6601064
2012-10-17 14:27:58 +08:00
Rob Pike
ec1ef16cea path/filepath: better documentation for WalkFunc
Define the properties of the arguments better. In particular,
explain that the path is (sort of) relative to the argument to
Walk.

Fixes #4119.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6721048
2012-10-17 16:00:09 +11:00
Dave Cheney
8c2b131cd1 net: return error from pollster rather than panicing
Fixes #3590.

R=bradfitz, mikioh.mikioh, iant, bsiegert
CC=golang-dev
https://golang.org/cl/6684054
2012-10-17 09:41:00 +11:00
Robert Griesemer
7565726875 math/big: fix big.Exp and document better
- always return 1 for y <= 0
- document that the sign of m is ignored
- protect against div-0 panics by treating
  m == 0 the same way as m == nil
- added extra tests

Fixes #4239.

R=agl, remyoudompheng, agl
CC=golang-dev
https://golang.org/cl/6724046
2012-10-16 13:46:27 -07:00
Adam Langley
cfa1ba34cc crypto/tls: make closeNotify a warning alert.
The RFC doesn't actually have an opinion on whether this is a fatal or
warning level alert, but common practice suggests that it should be a
warning.

This involves rebasing most of the tests.

Fixes #3413.

R=golang-dev, shanemhansen, rsc
CC=golang-dev
https://golang.org/cl/6654050
2012-10-16 15:40:37 -04:00
Robert Griesemer
71588bc2bc exp/types/staging: index and slice type checks
Also: handle assignments to the blank identifier.

R=rsc
CC=golang-dev
https://golang.org/cl/6658050
2012-10-16 10:20:03 -07:00
Dmitriy Vyukov
f24323c93e runtime: fix spurious deadlock crashes
Fixes #4243.

R=golang-dev, iant
CC=golang-dev, sebastien.paolacci
https://golang.org/cl/6682050
2012-10-16 14:41:32 +04:00
Dmitriy Vyukov
6273c7324f runtime: add missing if(raceenabled)
R=0xe2.0x9a.0x9b, minux.ma, iant, dave
CC=golang-dev
https://golang.org/cl/6654052
2012-10-15 13:54:31 +04:00
Nigel Tao
1f31598e86 image/jpeg: re-organize the processSOS code.
This is a straight copy/paste, and the deletion of a TODO. There are
no other changes.

R=r
CC=golang-dev
https://golang.org/cl/6687049
2012-10-15 13:28:30 +11:00
Nigel Tao
8b624f607f image/jpeg: decode progressive JPEGs.
To be clear, this supports decoding the bytes on the wire into an
in-memory image. There is no API change: jpeg.Decode will still not
return until the entire image is decoded.

The code is obviously more complicated, and costs around 10% in
performance on baseline JPEGs. The processSOS code could be cleaned up a
bit, and maybe some of that loss can be reclaimed, but I'll leave that
for follow-up CLs, to keep the diff for this one as small as possible.

Before:
BenchmarkDecode	    1000	   2855637 ns/op	  21.64 MB/s
After:
BenchmarkDecodeBaseline	     500	   3178960 ns/op	  19.44 MB/s
BenchmarkDecodeProgressive	     500	   4082640 ns/op	  15.14 MB/s

Fixes #3976.

The test data was generated by:
# Create intermediate files; cjpeg on Ubuntu 10.04 can't read PNG.
convert video-001.png video-001.bmp
convert video-005.gray.png video-005.gray.pgm
# Create new test files.
cjpeg -quality 100 -sample 1x1,1x1,1x1 -progressive video-001.bmp > video-001.progressive.jpeg
cjpeg -quality 50 -sample 2x2,1x1,1x1 video-001.bmp > video-001.q50.420.jpeg
cjpeg -quality 50 -sample 2x1,1x1,1x1 video-001.bmp > video-001.q50.422.jpeg
cjpeg -quality 50 -sample 1x1,1x1,1x1 video-001.bmp > video-001.q50.444.jpeg
cjpeg -quality 50 -sample 2x2,1x1,1x1 -progressive video-001.bmp > video-001.q50.420.progressive.jpeg
cjpeg -quality 50 -sample 2x1,1x1,1x1 -progressive video-001.bmp > video-001.q50.422.progressive.jpeg
cjpeg -quality 50 -sample 1x1,1x1,1x1 -progressive video-001.bmp > video-001.q50.444.progressive.jpeg
cjpeg -quality 50 video-005.gray.pgm > video-005.gray.q50.jpeg
cjpeg -quality 50 -progressive video-005.gray.pgm > video-005.gray.q50.progressive.jpeg
# Delete intermediate files.
rm video-001.bmp video-005.gray.pgm

R=r
CC=golang-dev
https://golang.org/cl/6684046
2012-10-15 11:21:20 +11:00
David Symonds
f2045aadd9 time: accept numbers larger than 2^32 in ParseDuration.
Fixes #3374.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6683047
2012-10-15 07:50:13 +11:00
Shenghou Ma
240834374a io/ioutil: use pathname instead of name in docs to avoid confusion
caller of ioutil.TempFile() can use f.Name() to get "pathname"
of the temporary file, instead of just the "name" of the file.

Also remove an out-of-date comment about random number state.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6649054
2012-10-13 19:05:22 +08:00
Anthony Martin
422da762b7 compress/bzip2: use io.ByteReader instead of internal interface
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6663044
2012-10-12 14:09:24 -07:00
Shenghou Ma
366268aa79 runtime: FreeBSD/ARM support
R=rsc
CC=golang-dev
https://golang.org/cl/6625071
2012-10-12 23:19:39 +08:00
Shenghou Ma
378d7ef59f syscall: FreeBSD/ARM support
R=rsc, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6657048
2012-10-12 16:26:42 +08:00
Rob Pike
e171b97ee6 fmt: document some undocumented details
Better explanation of width for floating-point values.
Explain that scanning does not handle %#q etc.

Fixes #4202.
Fixes #4206.

R=golang-dev, adg, rsc, iant
CC=golang-dev
https://golang.org/cl/6620074
2012-10-12 16:16:55 +11:00
Evan Shaw
eae25d430d bytes, strings: add (*Reader).WriteTo
Fixes #4031.

R=golang-dev, bradfitz, remyoudompheng, r, dave
CC=golang-dev
https://golang.org/cl/6632046
2012-10-12 14:43:50 +11:00
Rob Pike
06d42690b6 time: delete erroneous word from documentation.
Fixes #4236.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6658051
2012-10-12 11:00:00 +11:00
Andrew Gerrand
bd6601f4a0 os/signal: add Notify example
R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/6615078
2012-10-12 10:22:13 +11:00
Robert Griesemer
4bee88d45f math/big: more conservative use of lock for divisor table
Minor performance impact running sequentially:

benchmark                      old ns/op    new ns/op    delta
BenchmarkString10Base2               389          391   +0.51%
BenchmarkString100Base2             1530         1534   +0.26%
BenchmarkString1000Base2           11789        11787   -0.02%
BenchmarkString10000Base2         111443       112030   +0.53%
BenchmarkString100000Base2       1017483      1015347   -0.21%
BenchmarkString10Base8               339          344   +1.47%
BenchmarkString100Base8              753          756   +0.40%
BenchmarkString1000Base8            4618         4641   +0.50%
BenchmarkString10000Base8          43217        43534   +0.73%
BenchmarkString100000Base8        397518       400602   +0.78%
BenchmarkString10Base10              630          630   +0.00%
BenchmarkString100Base10            1975         1960   -0.76%
BenchmarkString1000Base10          10179        10174   -0.05%
BenchmarkString10000Base10         44527        44416   -0.25%
BenchmarkString100000Base10     14404694     14425308   +0.14%
BenchmarkString10Base16              283          288   +1.77%
BenchmarkString100Base16             597          598   +0.17%
BenchmarkString1000Base16           3189         3186   -0.09%
BenchmarkString10000Base16         29403        29364   -0.13%
BenchmarkString100000Base16       265657       265587   -0.03%

Note that due to other improvements (faster assembly routines,
better code generation by compiler), these benchmarks now run
up to 37% faster than they used to at the last time measured (1/9/2012).

Minor performance impact for StringPiParallel running in parallel:

Current CL but with Lock/Unlock commented out (removed):

BenchmarkStringPiParallel	    5000	    343581 ns/op
BenchmarkStringPiParallel-2	   10000	    184511 ns/op
BenchmarkStringPiParallel-3	   10000	    129768 ns/op
BenchmarkStringPiParallel-4	   10000	    102326 ns/op

Current CL:

BenchmarkStringPiParallel	    5000	    345169 ns/op
BenchmarkStringPiParallel-2	   10000	    185827 ns/op
BenchmarkStringPiParallel-3	   10000	    131168 ns/op
BenchmarkStringPiParallel-4	   10000	    102353 ns/op

Fixes #4218.

R=dvyukov, michael.jones, dave
CC=golang-dev
https://golang.org/cl/6643053
2012-10-11 16:04:03 -07:00
Adam Langley
3acce59b93 crypto/rsa: fix decryption benchmark.
I was an idiot and was thinking that a small base didn't matter
because the exponentiation would quickly make the number the same size
as the modulus. But, of course, the small base continues to make
multiplications unrealistically cheap throughout the computation.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6649048
2012-10-11 18:25:23 -04:00
Dave Cheney
a14f87ca81 net/http: fix data race on countReader.n
Fixes #4220.

R=dvyukov, bradfitz
CC=golang-dev
https://golang.org/cl/6638053
2012-10-12 09:17:56 +11:00
Dave Cheney
f1b1753627 net/http: fix race on bodyEOFSignal.isClosed
Update #4191.

Fixes unreported race failure at
http://build.golang.org/log/61e43a328fb220801d3d5c88cd91916cfc5dc43c

R=dvyukov, bradfitz
CC=golang-dev
https://golang.org/cl/6640057
2012-10-12 08:32:56 +11:00
Adam Langley
6720997f9e crypto/hmac: add Equal function.
It was suggested that it's too easy to use crypto/hmac insecurely and
I think that has some merit. This change adds a Equal function to
make it obvious that MAC values should be compared in constant time.

R=rsc, max
CC=golang-dev
https://golang.org/cl/6632044
2012-10-11 15:28:02 -04:00
Taj Khattra
c12dab2aa6 container/heap: optimization in case heap has many duplicates
benchmark       old ns/op    new ns/op    delta
BenchmarkDup      3075682       609448  -80.18%

R=gri
CC=golang-dev
https://golang.org/cl/6613064
2012-10-10 11:35:57 -07:00
Dmitriy Vyukov
be2b95fe3a runtime/debug: fix the test
If source are not available, then the stack looks like:
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/debug/bla-bla-bla/src/pkg/runtime/debug/stack_test.go:15 (0x43fb11)
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/debug/bla-bla-bla/src/pkg/runtime/debug/stack_test.go:18 (0x43fb7a)
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/debug/bla-bla-bla/src/pkg/runtime/debug/stack_test.go:37 (0x43fbf4)
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/testing/bla-bla-bla/src/pkg/testing/testing.go:301 (0x43b5ba)
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/bla-bla-bla/src/pkg/runtime/proc.c:276 (0x410670)
stack_test.go:40:
which is 6 lines.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6637060
2012-10-10 20:49:18 +04:00
Dmitriy Vyukov
27e93fbd00 runtime: fix race detector handling of stackalloc()
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6632051
2012-10-10 18:06:29 +04:00
Andrew Gerrand
749a445ba0 bytes: fix tests and fix build
R=golang-dev, edsrzf
CC=golang-dev
https://golang.org/cl/6633051
2012-10-10 11:59:39 +11:00
Andrew Gerrand
e7c222cada bytes: make examples work in playground
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6633050
2012-10-10 11:15:41 +11:00
Robert Griesemer
241b23606c go/printer: idempotent comment formatting
Also:

- Refactored testing framework to permit easier
idempotency testing.

- Applied gofmt -w src misc

This CL depends on CL 6639044 being applied first.

Formatting is not idempotent for all files: In those
files the comment position has changed (due to missing
precise location information) and/or the comment formatting
cannot/is not aware of independent code re-formatting.
In general it is very hard to make format idempotent when
running it in one pass only. Leaving that aside for now.

Fixes #1835.

R=r, rsc
CC=golang-dev
https://golang.org/cl/6624051
2012-10-09 17:08:09 -07:00
Robert Griesemer
af79568fde gofmt: apply gofmt -w -s src misc
Preparation for forthcoming CL 6624051: Will make it
easier to see if/what changes are incurred by it.

The alignment changes in this CL are due to CL 6610051
(fix to alignment heuristic) where it appears that an
old version of gofmt was run (and thus the correct
alignment updates were not done).

R=r
CC=golang-dev
https://golang.org/cl/6639044
2012-10-09 17:01:28 -07:00
Brad Fitzpatrick
dfc7304d32 net/http: fix name of result parameter in a comment
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6632053
2012-10-09 11:16:35 -07:00
Adam Langley
7e90f7b4ab crypto/tls: fix NPN extension parsing.
I typoed the code and tried to parse all the way to the end of the
message. Therefore it fails when NPN is not the last extension in the
ServerHello.

Fixes #4088.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6637052
2012-10-09 13:25:47 -04:00
Dmitriy Vyukov
49a5c28a18 io/ioutil: fix data race on rand
Fixes #4212.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6641050
2012-10-09 21:08:53 +04:00
Dmitriy Vyukov
cffbfaeb18 race: syscall changes
This is a part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044
The purpose of this patch is to provide coarse-grained synchronization
between all Read() and Write() calls.

R=rsc, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/6610064
2012-10-09 20:51:58 +04:00
Russ Cox
f76f120324 cmd/ld: use 64-bit alignment for large data and bss objects
Check for specific, important misalignment in garbage collector.
Not a complete fix for issue 599 but an important workaround.

Update #599.

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/6641049
2012-10-09 12:50:06 -04:00
Dmitriy Vyukov
aa97c88ecb encoding/gob: add test case for issue 4214.
See http://code.google.com/p/go/issues/detail?id=4214

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6619068
2012-10-09 09:55:57 +04:00
Rob Pike
e855fcc307 encoding/gob: fix data race in Register
Fixes #4214.

R=golang-dev, dsymonds, bradfitz
CC=golang-dev
https://golang.org/cl/6637047
2012-10-09 11:56:38 +11:00
Robin Eklind
e9f0fc8823 debug/pe: support PE files which contain no symbol table (if NumberOfSymbols is equal to 0 in the IMAGE_FILE_HEADER structure).
No longer assume that e_lfanew (in the IMAGE_DOS_HEADER strcuture) is always one byte. It is now regarded as a 4 byte uint32.

Fixes #4177.

R=golang-dev, alex.brainman, dave, minux.ma
CC=golang-dev
https://golang.org/cl/6587048
2012-10-09 11:15:53 +11:00
David Symonds
f8b5838123 testing: change -test.benchtime to a flag.Duration.
Fixes #3902.

R=golang-dev, minux.ma, rsc, r
CC=golang-dev
https://golang.org/cl/6611059
2012-10-09 08:57:29 +11:00
David Symonds
05e4e805e0 encoding/base{32,64}: add examples.
Fixes #4136.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6615061
2012-10-09 08:56:34 +11:00
David Symonds
c7cc894ef5 net/url: report first error from ParseQuery.
Fixes #4175.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6610068
2012-10-09 08:10:32 +11:00
Robert Griesemer
d5b570cdb1 fix build: use temporary variable to avoid compiler error
R=r
CC=golang-dev
https://golang.org/cl/6612066
2012-10-07 18:16:04 -07:00
Robert Griesemer
0d9474206f exp/types/staging: more flexible API, cleanups
- Changed Check signature to take function parameters for
  more flexibility: Now a client can interrupt type checking
  early (via panic in one the upcalls) once the desired
  type information or number of errors is reached. Default
  use is still simple.

- Cleaned up main typechecking loops. Now does not neglect
  _ declarations anymore.

- Various other cleanups.

R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/6612049
2012-10-07 18:02:19 -07:00
Robert Griesemer
5224875055 /exp/types/staging: expression and statement type checking
Still lots of pieces missing, but basic framework working.
Lots of tests.

R=rsc
CC=golang-dev
https://golang.org/cl/6594054
2012-10-07 18:01:43 -07:00
Robert Griesemer
328f0e7f2e exp/types/staging: test drivers
This code has been reviewed before. The most significant
change is to check_test which now can handle more than
one error at the same error position (due to spurious
errors - should not happen in praxis once error handling
has been fine-tuned). This change makes check_test easier
to use during development.

R=rsc
CC=golang-dev
https://golang.org/cl/6584057
2012-10-07 18:00:56 -07:00
Robert Griesemer
7f710c2de9 exp/locale/collate: use gofmt -w -s (rather than just gofmt -w)
Also: apply gofmt -w -s to existing tables.

R=mpvl, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6611051
2012-10-07 17:59:33 -07:00
Robert Griesemer
05fc42ab02 go/parser: fix object kind
Bug introduced with CL 6624047.

R=r
CC=golang-dev
https://golang.org/cl/6620073
2012-10-07 17:58:13 -07:00
Dmitriy Vyukov
373dbcb37a io/ioutil: fix data race under the race detector
See issue 3970 (it's already marked as Fixed).

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6624059
2012-10-07 22:08:06 +04:00
Dmitriy Vyukov
59b8745328 race: sync/atomic changes
This is a part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044

R=rsc, remyoudompheng
CC=gobot, golang-dev
https://golang.org/cl/6536059
2012-10-07 22:07:32 +04:00
Dmitriy Vyukov
53390c8fc7 race: sync changes
This is a part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044

R=rsc, minux.ma
CC=gobot, golang-dev
https://golang.org/cl/6529053
2012-10-07 22:07:03 +04:00
Dmitriy Vyukov
2f6cbc74f1 race: runtime changes
This is a part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044

R=rsc
CC=gobot, golang-dev
https://golang.org/cl/6535050
2012-10-07 22:05:32 +04:00
Shenghou Ma
f82c59b6cf runtime: disable TestParForParallel for now on 32-bit hosts
Also add call to GC() to make it easier to re-enable the test.

Update #4155.
When we have precise GC merged, re-enable this test.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6622058
2012-10-08 01:56:27 +08:00
Brad Fitzpatrick
54c109b122 os: make TestMkdirAllWithSymlink more robust
Don't assume the test has a clean environment within /tmp.
Use an actual new tempdir for its tests.

Fixes FreeBSD build failure as seen at:
http://build.golang.org/log/396738676356d7fb6bab6eaf1b97cac820f8a90f

--- FAIL: TestMkdirAllWithSymlink (0.00 seconds)
path_test.go:178:                 Mkdir /tmp/dir: mkdir /tmp/dir: file exists
FAIL
FAIL    os      1.091s

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6615057
2012-10-07 10:31:56 -07:00
Brad Fitzpatrick
13576e3b65 net/http/httptest: mimic the normal HTTP server's ResponseWriter more closely
Also adds tests, which didn't exist before.

Fixes #4188

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6613062
2012-10-07 09:48:14 -07:00
Shenghou Ma
51310d8320 testing: fix extra tabs when t.Log("string")
t.Log("line 1\nline 2\nline 3")

Old output:
=== RUN TestLine3
--- PASS: TestLine3 (0.00 seconds)
testing_test.go:25: 	line 1
		line 2
		line 3
		PASS

New output:
=== RUN TestLine3
--- PASS: TestLine3 (0.00 seconds)
testing_test.go:24: 	line 1
		line 2
		line 3
PASS

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6613069
2012-10-08 00:21:53 +08:00
Shenghou Ma
f8485954bf syscall: fix Statfs and Fstatfs on Linux/ARM
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6615055
2012-10-08 00:13:28 +08:00
Nigel Tao
d7b7957db1 image/jpeg: move the huffman bit decoder state higher up in the
decoder struct, inside the unmappedzero limit, to eliminate some
TESTB instructions in the inner decoding loop.

benchmark          old ns/op    new ns/op    delta
BenchmarkDecode      2943204      2746360   -6.69%

R=r, dave
CC=golang-dev
https://golang.org/cl/6625058
2012-10-07 19:32:28 +11:00
Nigel Tao
0b9fe6d24e image/jpeg: move the level-shift and clip out of the idct function,
to be consistent with the fdct function, and to ease any future
idct rewrites in assembly.

The BenchmarkIDCT delta is obviously just an accounting change and not
a real saving, but it does give an indication of what proportion of
time was spent in the actual IDCT and what proportion was in shift and
clip. The idct time taken is now comparable to fdct.

The BenchmarkFDCT delta is an estimate of benchmark noise.

benchmark                   old ns/op    new ns/op    delta
BenchmarkFDCT                    3842         3837   -0.13%
BenchmarkIDCT                    5611         3478  -38.01%
BenchmarkDecodeRGBOpaque      2932785      2929751   -0.10%

R=r
CC=golang-dev
https://golang.org/cl/6625057
2012-10-07 11:32:02 +11:00
Nigel Tao
f2444f0bc1 image/jpeg: clean up BenchmarkDecode and BenchmarkEncode to not
refer to opacity. Those references were copy/pasted from the
image/png encoding benchmarks, which cares whether or not the
source image is opaque, but the JPEG encoder does not care.

R=r
CC=golang-dev
https://golang.org/cl/6623052
2012-10-07 11:30:47 +11:00
Nigel Tao
12e343f372 image/jpeg: add DCT tests, do a small optimization (common sub-expression
elimination) in idct.go.

benchmark                   old ns/op    new ns/op    delta
BenchmarkIDCT                    5649         5610   -0.69%
BenchmarkDecodeRGBOpaque      2948607      2941051   -0.26%

The "type block" declaration moved so that idct.go is compilable
as a stand-alone file: "go tool 6g -S idct.go" works.

R=r
CC=golang-dev
https://golang.org/cl/6619056
2012-10-07 10:21:17 +11:00
Rob Pike
bcccad4020 text/template: fix nil crash on Templates
Fixes #3872.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6612060
2012-10-07 09:26:59 +11:00
Rob Pike
421b75c0db text/template: add an unexported method to Node
Protects the package a little against undesirable clients.

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

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6611056
2012-10-06 12:05:52 +02:00
Dmitriy Vyukov
4cc7bf326a pprof: add goroutine blocking profiling
The profiler collects goroutine blocking information similar to Google Perf Tools.
You may see an example of the profile (converted to svg) attached to
http://code.google.com/p/go/issues/detail?id=3946
The public API changes are:
+pkg runtime, func BlockProfile([]BlockProfileRecord) (int, bool)
+pkg runtime, func SetBlockProfileRate(int)
+pkg runtime, method (*BlockProfileRecord) Stack() []uintptr
+pkg runtime, type BlockProfileRecord struct
+pkg runtime, type BlockProfileRecord struct, Count int64
+pkg runtime, type BlockProfileRecord struct, Cycles int64
+pkg runtime, type BlockProfileRecord struct, embedded StackRecord

R=rsc, dave, minux.ma, r
CC=gobot, golang-dev, r, remyoudompheng
https://golang.org/cl/6443115
2012-10-06 12:56:04 +04:00
Dmitry Chestnykh
b459afe843 crypto/sha256, crypto/sha512: 1.3x speedup
SHA-256:

benchmark          old ns/op    new ns/op    delta
BenchmarkHash1K        21686        16912  -22.01%
BenchmarkHash8K       173216       135020  -22.05%

benchmark           old MB/s     new MB/s  speedup
BenchmarkHash1K        47.22        60.55    1.28x
BenchmarkHash8K        47.29        60.67    1.28x

SHA-512:

benchmark          old ns/op    new ns/op    delta
BenchmarkHash1K        14323        11163  -22.06%
BenchmarkHash8K       114120        88693  -22.28%

benchmark           old MB/s     new MB/s  speedup
BenchmarkHash1K        71.49        91.73    1.28x
BenchmarkHash8K        71.78        92.36    1.29x

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/6584071
2012-10-05 17:04:48 -04:00
Akshat Kumar
23599ca2f6 runtime: mask SSE exceptions on plan9/amd64
The Go run-time assumes that all SSE floating-point exceptions
are masked so that Go programs are not broken by such invalid
operations. By default, the 64-bit version of the Plan 9 kernel
masks only some SSE floating-point exceptions. Here, we mask
them all on a per-thread basis.

R=rsc, rminnich, minux.ma
CC=golang-dev
https://golang.org/cl/6592056
2012-10-05 16:23:30 -04:00
Robert Griesemer
1f6fba2d56 go/printer: don't forget the .0 in 1.0
(use floating-point rather then integer constant division)

gofmt -w src misc

Fixes #3965.

R=r, bsiegert, 0xjnml
CC=bradfitz, golang-dev
https://golang.org/cl/6610051
2012-10-05 08:48:23 -07:00
Robert Griesemer
1065c6f65a go/printer: parenthesize literal function types in conversions
Also: gofmt -w src misc

R=r
CC=golang-dev, iant
https://golang.org/cl/6591071
2012-10-04 21:03:50 -07:00
Robert Griesemer
6c740e769f go/parser: unify parsing of const and var declarations
The AST representation is already identical. Making the
code (nearly) identical in the parser reduces code size
and ensures that the ast.ValueSpec nodes have the same
values (specifically, iota). This in turn permits the
sharing of much of the respective code in the typechecker.

While at it: type functions work now, so use them.

R=r
CC=golang-dev
https://golang.org/cl/6624047
2012-10-04 20:53:43 -07:00
Graham Miller
9f807fcc4a net/mail: make address parsing (more) public
Code for parsing email addresses was already partially part of the public API with "func (Header) AddressList".  This CL adds a trivial implementation for two public methods to parse address and lists from a string. With tests.

R=dsymonds
CC=golang-dev
https://golang.org/cl/5676067
2012-10-05 10:08:54 +10:00
Jeff Wendling
70ab57ea2d crypto/x509: add DecryptBlock function for loading password protected keys
Adds a DecryptBlock function which takes a password and a *pem.Block and
returns the decrypted DER bytes suitable for passing into other crypto/x509
functions.

R=golang-dev, agl, leterip
CC=golang-dev
https://golang.org/cl/6555052
2012-10-04 15:42:57 -04:00
Andrew Gerrand
ce6acefc5d go/doc: add nil to list of predeclared constants
R=gri
CC=gobot, golang-dev
https://golang.org/cl/6601054
2012-10-04 08:37:48 +10:00
Andrew Gerrand
81ae666f16 go/doc: rewrite whole file examples for playground
R=gri
CC=gobot, golang-dev
https://golang.org/cl/6592061
2012-10-04 07:55:24 +10:00
Shenghou Ma
727e5ce95f testing: update package docs to use ResetTimer() instead of StopTimer/StartTimer()
R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/6591051
2012-10-03 11:41:18 +08:00
Rob Pike
7f4b4c0c00 text/template: better error messages during execution,
They now show the correct name, the byte offset on the line, and context for the failed evaluation.
Before:
        template: three:7: error calling index: index out of range: 5
After:
        template: top:7:20: executing "three" at <index "hi" $>: error calling index: index out of range: 5
Here top is the template that was parsed to create the set, and the error appears with the action
starting at byte 20 of line 7 of "top", inside the template called "three", evaluating the expression
<index "hi" $>.

Also fix a bug in index: it didn't work on strings. Ouch.

Also fix bug in error for index: was showing type of index not slice.
The real previous error was:
        template: three:7: error calling index: can't index item of type int
The html/template package's errors can be improved by building on this;
I'll do that in a separate pass.

Extends the API for text/template/parse but only by addition of a field and method. The
old API still works.

Fixes #3188.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6576058
2012-10-03 12:02:13 +10:00
Robert Griesemer
1659aef399 go/ast: track position of <- for channel types
This is a backward-compatible API change.

Without the correct <- position information,
certain channel types have incorrect position
information.

R=iant, iant
CC=golang-dev
https://golang.org/cl/6585063
2012-10-02 17:50:36 -07:00
Shivakumar GN
5f7f9062db os/user : use username as fullname if all else fails (on windows)
Fixes #4113.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/6545054
2012-10-03 10:33:09 +10:00
Robert Griesemer
05dc3bf572 go/parser: correctly parse <-chan T(x) as <-(chan T)(x)
Fixes #4110.

R=iant
CC=golang-dev
https://golang.org/cl/6597069
2012-10-02 16:48:30 -07:00
Andrew Gerrand
cf513387c3 go/doc: strip example output comment from synthesized main function
R=gri
CC=gobot, golang-dev
https://golang.org/cl/6524047
2012-10-02 08:35:20 +10:00
Jeremy Jackins
b9e423eff3 archive/tar: fix inconsistent namespace usage in example
This fixes some example code in the tar package documentation, which
first refers to tar.NewWriter and then to Header, which is inconsistent
because NewWriter and Header are both in the tar namespace.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6595050
2012-10-02 08:10:42 +10:00
Adam Langley
9070d5759f math/big: avoid some allocation in Exp
benchmark                        old ns/op    new ns/op    delta
BenchmarkRSA1024Decrypt             745686       644964  -13.51%
BenchmarkRSA2048Decrypt            5517318      5049200   -8.48%
Benchmark3PrimeRSA2048Decrypt      3767386      3288048  -12.72%

R=gri
CC=gobot, golang-dev
https://golang.org/cl/6566043
2012-10-01 17:31:35 -04:00
Akshat Kumar
af582674b0 pkg/syscall: Plan 9, 64-bit: Update error checks from sys calls.
This change updates CL 6576057 for exceptional cases where
return values from Syscall/RawSyscall functions are used.

The system calls return 32-bit integers. With the recent change
in size of `int' in Go for amd64, the type conversion was not
catching `-1' return values. This change makes the conversion
explicitly `int32'.

R=rsc, r
CC=golang-dev
https://golang.org/cl/6590047
2012-10-01 10:09:08 +10:00
David Symonds
ff2f851af1 exp/types: permit importing packages without available source.
R=gri, iant
CC=golang-dev
https://golang.org/cl/6586051
2012-09-30 15:56:23 +10:00
David Symonds
0b448bdef7 exp/types: better diagnosis for compile failures.
R=gri, dave
CC=golang-dev
https://golang.org/cl/6587046
2012-09-30 15:46:37 +10:00
Mikio Hara
2fee6e3788 syscall: add ipv4 ancillary data for darwin
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/6586044
2012-09-29 12:43:05 +09:00
Robert Griesemer
de782dd146 container/list: slightly better code factoring
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6569077
2012-09-28 10:58:46 -07:00
Robert Griesemer
0e9daef2d1 container/list: Correctly maintain internal invariants
The previous implementation was a mess with invariants
maintained inconsistently. Essentially reimplemented
the package:

- used a circular list as internal representation for
  significantly simpler implementation with fewer
  special cases while maintaining the illusion of
  a nil-terminated doubly linked list externally

- more precise documentation

- cleaned up and simplified tests, added test case
  for issue 4103.

No changes to the API or documented semantics.

All this said, I would be in favor of removing
this package eventually. container/ring provides
a faster implementation and a simpler and more
powerful API.

Fixes #4103.

R=r
CC=golang-dev
https://golang.org/cl/6569072
2012-09-28 10:35:32 -07:00
Eric Roshan-Eisner
631a0e71c1 strings: implement a faster single-string Replacer
The string searching is implemented separately so other functions
may make use of it in the future.

benchmark                        old ns/op    new ns/op    delta
BenchmarkSingleMaxSkipping          125889         2474  -98.03%
BenchmarkSingleLongSuffixFail        16252         1996  -87.72%
BenchmarkSingleMatch                260793       136266  -47.75%

benchmark                         old MB/s     new MB/s  speedup
BenchmarkSingleMaxSkipping           79.43      4041.57   50.88x
BenchmarkSingleLongSuffixFail        61.65       501.81    8.14x
BenchmarkSingleMatch                 57.52       110.08    1.91x

R=nigeltao
CC=golang-dev
https://golang.org/cl/6545049
2012-09-28 12:34:18 +10:00
Eric Roshan-Eisner
4bf6249ba5 testing: remove redundant whitespace in output
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6565061
2012-09-28 10:01:09 +10:00
Akshat Kumar
8fdc90acf4 pkg/syscall: Plan 9, 64-bit: Update error checks from sys calls.
The system calls return 32-bit integers. With the recent change
in size of `int' in Go for amd64, the type conversion was not
catching `-1' return values. This change makes the conversion
explicitly `int32'.

R=rsc, rminnich, npe, r
CC=golang-dev
https://golang.org/cl/6576057
2012-09-28 09:56:44 +10:00
Michael Chaten
e289a2b913 bufio: Implement io.WriterTo for (*Reader)
This is part 1 of 2 for issue 4028

benchmark                       old ns/op    new ns/op    delta
BenchmarkReaderCopyOptimal          33495         9849  -70.60%
BenchmarkReaderCopyUnoptimal        70631        27041  -61.72%
BenchmarkReaderCopyOldImpl          51407        52970   +3.04%

Update #4028

R=dave, nigeltao, rsc, bradfitz, rogpeppe
CC=golang-dev
https://golang.org/cl/6548047
2012-09-27 16:31:03 +10:00
Josh Holland
348e31f8f7 text/template: fix typo of errorf as error in comment.
R=r, minux.ma
CC=gobot, golang-dev
https://golang.org/cl/6506120
2012-09-27 15:47:54 +10:00
Nigel Tao
791ac65b82 lzw: fix Write returning the wrong number of bytes written.
Fixes #4160.

R=rsc, r
CC=golang-dev
https://golang.org/cl/6564060
2012-09-27 13:29:39 +10:00
Rob Pike
ffea835b8f fmt: allow # and x together for strings
Silly and small but easy to be consistent.
To make it worthwhile, I eliminated an allocation when using
%x on a byte slice.

Fixes #4149.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6574046
2012-09-27 06:21:38 +10:00
Sébastien Paolacci
7014bc64b1 net: spread fd over several pollservers.
Lighten contention without preventing further improvements on pollservers.
Connections are spread over Min(GOMAXPROCS, NumCPU, 8) pollserver instances.

Median of 10 runs, 4 cores @ 3.4GHz, amd/linux-3.2:

BenchmarkTCPOneShot                171917 ns/op   175194 ns/op      1.91%
BenchmarkTCPOneShot-2              101413 ns/op   109462 ns/op      7.94%
BenchmarkTCPOneShot-4               91796 ns/op    35712 ns/op    -61.10%
BenchmarkTCPOneShot-6               90938 ns/op    30607 ns/op    -66.34%
BenchmarkTCPOneShot-8               90374 ns/op    29150 ns/op    -67.75%
BenchmarkTCPOneShot-16             101089 ns/op   111526 ns/op     10.32%

BenchmarkTCPOneShotTimeout         174986 ns/op   178606 ns/op      2.07%
BenchmarkTCPOneShotTimeout-2       101585 ns/op   110678 ns/op      8.95%
BenchmarkTCPOneShotTimeout-4        91547 ns/op    35931 ns/op    -60.75%
BenchmarkTCPOneShotTimeout-6        91496 ns/op    31019 ns/op    -66.10%
BenchmarkTCPOneShotTimeout-8        90670 ns/op    29531 ns/op    -67.43%
BenchmarkTCPOneShotTimeout-16      101013 ns/op   106026 ns/op      4.96%

BenchmarkTCPPersistent              51731 ns/op    53324 ns/op      3.08%
BenchmarkTCPPersistent-2            32888 ns/op    30678 ns/op     -6.72%
BenchmarkTCPPersistent-4            25751 ns/op    15595 ns/op    -39.44%
BenchmarkTCPPersistent-6            26737 ns/op     9805 ns/op    -63.33%
BenchmarkTCPPersistent-8            26850 ns/op     9730 ns/op    -63.76%
BenchmarkTCPPersistent-16          104449 ns/op   102838 ns/op     -1.54%

BenchmarkTCPPersistentTimeout       51806 ns/op    53281 ns/op      2.85%
BenchmarkTCPPersistentTimeout-2     32956 ns/op    30895 ns/op     -6.25%
BenchmarkTCPPersistentTimeout-4     25994 ns/op    18111 ns/op    -30.33%
BenchmarkTCPPersistentTimeout-6     26679 ns/op     9846 ns/op    -63.09%
BenchmarkTCPPersistentTimeout-8     26810 ns/op     9727 ns/op    -63.72%
BenchmarkTCPPersistentTimeout-16   101652 ns/op   104410 ns/op      2.71%

R=rsc, dvyukov, dave, mikioh.mikioh, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/6496054
2012-09-26 15:32:59 -04:00
David du Colombier
cca48f1a57 crypto/x509: add Plan 9 root certificate location
R=golang-dev
CC=golang-dev, rsc
https://golang.org/cl/6571056
2012-09-26 14:47:47 -04:00
Shenghou Ma
948db4e091 crypto/aes: speed up using AES-NI on amd64
This CL requires CL 5970055.

benchmark           old ns/op    new ns/op    delta
BenchmarkEncrypt          161           23  -85.71%
BenchmarkDecrypt          158           24  -84.24%
BenchmarkExpand           526           62  -88.21%

benchmark            old MB/s     new MB/s  speedup
BenchmarkEncrypt        99.32       696.19    7.01x
BenchmarkDecrypt       100.93       641.56    6.36x

R=golang-dev, bradfitz, dave, rsc
CC=golang-dev
https://golang.org/cl/6549055
2012-09-27 01:54:10 +08:00
Rob Pike
ded94b7222 reflect.DeepEqual: rewrite clarification about nil and empty slice.
The previous version was created by an idiot. This time, Rog Peppe
wrote the text. Thanks, Rog.
(== doesn't work on slices in general, so it makes no sense to
talk about in the context of DeepEqual.)

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6566054
2012-09-26 20:46:49 +10:00
Mikio Hara
d6665bc338 net: fix plan 9 build
R=golang-dev, lucio.dere, fshahriar
CC=golang-dev
https://golang.org/cl/6562046
2012-09-26 16:11:49 +09:00
Rob Pike
74a7cc9bf2 reflect.DeepEqual: document that empty and nil are unequal for slices
Update #4133.
Added a sentence of documentation to call out the behavior.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6572051
2012-09-26 15:21:07 +10:00
Robert Griesemer
1785bfca6b exp/types/staging: updated gcimporter
Mostly minor changes to match the new
definitions in types.go and const.go.

R=rsc, r
CC=golang-dev
https://golang.org/cl/6506101
2012-09-25 17:39:02 -07:00
Robert Griesemer
ebf56e086d exp/types/staging: support for typechecking (most) builtins
This code relies on some functions that are not yet in staging,
but it get's harder to keep all this in sync in a piece-meal
fashion.

R=rsc
CC=golang-dev
https://golang.org/cl/6492124
2012-09-25 17:38:43 -07:00
Robert Griesemer
f5483fb801 exp/types/staging: operands, constants, and error handling
More pieces of the typechecker code:

- Operands are temporary objects representing an expressions's
type and value (for constants). An operand is the equivalent of
an "attribute" in attribute grammars except that it's not stored
but only passed around during type checking.

- Constant operations are implemented in const.go. Constants are
represented as bool (booleans), int64 and *big.Int (integers),
*big.Rat (floats), complex (complex numbers), and string (strings).

- Error reporting is consolidated in errors.go. Only the first
dozen of lines is new code, the rest of the file contains the
exprString and typeString functions formerly in two separate
files (which have been removed).

This is a replacement CL for 6492101 (which was created without
proper use of hg).

R=rsc, r
CC=golang-dev
https://golang.org/cl/6500114
2012-09-25 17:38:22 -07:00
Christian Himpel
1b6d4b5c0a net/http: use tls host instead of proxy, when checking against a certificate
Fixes #4152.

R=bradfitz
CC=golang-dev
https://golang.org/cl/6570045
2012-09-25 09:22:13 -07:00
Alex Brainman
0e6f927108 syscall: do not use int to test network syscall results (on windows)
Fixes #4147.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6569050
2012-09-25 17:06:39 +10:00
Russ Cox
10ea6519e4 build: make int 64 bits on amd64
The assembly offsets were converted mechanically using
code.google.com/p/rsc/cmd/asmlint. The instruction
changes were done by hand.

Fixes #2188.

R=iant, r, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/6550058
2012-09-24 20:57:01 -04:00
Jan Ziak
f8c58373e5 runtime: add types to MSpan
R=rsc
CC=golang-dev
https://golang.org/cl/6554060
2012-09-24 20:08:05 -04:00
Russ Cox
ba4625c66f reflect: add MakeFunc (API CHANGE)
Fixes #1765.

R=iant, r, daniel.morsing, minux.ma, bradfitz, rogpeppe, remyoudompheng
CC=golang-dev
https://golang.org/cl/6554067
2012-09-24 20:06:32 -04:00
Mikio Hara
4b9e8415de net: add read, write message methods to IPConn, UDPConn
Both methods allow to access the IP ancillary data through
socket control messages.

This CL is required for CL 6482044; go.net/ipv4: new package.

R=rsc, r, dave
CC=golang-dev
https://golang.org/cl/6426047
2012-09-25 06:57:32 +09:00
Adam Langley
65c7dc4ace crypto/tls: support session ticket resumption.
Session resumption saves a round trip and removes the need to perform
the public-key operations of a TLS handshake when both the client and
server support it (which is true of Firefox and Chrome, at least).

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6555051
2012-09-24 16:52:43 -04:00
Francesc Campoy
b7cbfe6ace testing: document -test.bench flag
Fixes #4080.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/6553068
2012-09-24 13:05:47 -07:00
Russ Cox
c7e0b8baa6 regexp/syntax: define accepted syntax
Update #3953.

R=bradfitz, campoy
CC=golang-dev
https://golang.org/cl/6543068
2012-09-24 15:33:53 -04:00
Eric Roshan-Eisner
74a1a8ae5f testing: add memory allocation stats to benchmark
R=rsc, nigeltao, dave, bradfitz, r, rogpeppe
CC=golang-dev
https://golang.org/cl/6497084
2012-09-24 15:03:16 -04:00
Russ Cox
0b08c9483f runtime: prepare for 64-bit ints
This CL makes the runtime understand that the type of
the len or cap of a map, slice, or string is 'int', not 'int32',
and it is also careful to distinguish between function arguments
and results of type 'int' vs type 'int32'.

In the runtime, the new typedefs 'intgo' and 'uintgo' refer
to Go int and uint. The C types int and uint continue to be
unavailable (cause intentional compile errors).

This CL does not change the meaning of int, but it should make
the eventual change of the meaning of int on amd64 a bit
smoother.

Update #2188.

R=iant, r, dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6551067
2012-09-24 14:58:34 -04:00
Akshat Kumar
e42788628a cmd/dist, pkg/runtime: Plan 9, 64-bit: Get PID from TLS; remove use of `_tos'.
Using offsets from Tos is cumbersome and we've had problems
in the past. Since it's only being used to grab the PID, we'll just
get that from the default TLS instead.

R=rsc, rminnich, npe
CC=golang-dev
https://golang.org/cl/6543049
2012-09-24 12:24:45 -04:00
Russ Cox
8696b08446 reflect: fix mistake in error message
Pointed out by James Chalfant after submit of CL 6500065.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/6543067
2012-09-24 11:47:27 -04:00