Rob Pike [Wed, 10 Apr 2013 20:05:34 +0000 (13:05 -0700)]
encoding/json: different decision on tags and shadowing
If there are no tags, the rules are the same as before.
If there is a tagged field, choose it if there is exactly one
at the top level of all fields.
More tests. The old tests were clearly inadequate, since
they all pass as is. The new tests only work with the new code.
Rob Pike [Tue, 9 Apr 2013 22:00:21 +0000 (15:00 -0700)]
encoding/json: fix handling of anonymous fields
The old code was incorrect and also broken. It passed the tests by accident.
The new algorithm is:
1) Sort the fields in order of names.
2) For all fields with the same name, sort in increasing depth.
3) Choose the single field with shortest depth.
If any of the fields of a given name has a tag, do the above using
tagged fields of that name only.
Fixes #5245.
Dave Cheney [Tue, 9 Apr 2013 02:48:04 +0000 (12:48 +1000)]
misc/dashboard/builder: add -race builder support
If the build key contains -race, the builder will invoke to the race.{bat,bash} build command. This allows {darwin,linux,windows}-amd64 builders to do race and non race builds in sequence.
Andrew Wilkins [Mon, 8 Apr 2013 23:35:06 +0000 (07:35 +0800)]
cmd/cgo: record CGO_LDFLAGS env var in _cgo_flags
cgo stores cgo LDFLAGS in _cgo_flags and _cgo_defun.c.
The _cgo_defun.c records the flags via
"#pragma cgo_ldflag <flag>", which external linking
relies upon for passing libraries (and search paths)
to the host linker.
The go command will allow LDFLAGS for cgo to be passed
through the environment (CGO_LDFLAGS); cgo ignores
this environment variable, and so its value doesn't
make it into the above mentioned files. This CL changes
cgo to record CGO_LDFLAGS also.
runtime: poor man's heap type info checker
It's not trivial to make a comprehensive check
due to inferior pointers, reflect, gob, etc.
But this is essentially what I've used to debug
the GC issues.
Update #5193.
R=golang-dev, iant, 0xe2.0x9a.0x9b, r
CC=golang-dev
https://golang.org/cl/8455043
Rob Pike [Mon, 8 Apr 2013 06:27:26 +0000 (23:27 -0700)]
cmd/go: fix a misleading sentence
Apologies for not reviewing the previous CL; I was on the road.
The text was misleading; execution is no more separate than with
any other test. Rewritten. Dropped the odd adverb.
Andrew Gerrand [Mon, 8 Apr 2013 05:38:06 +0000 (15:38 +1000)]
archive/zip: handle trailing data after the end of directory header
The spec doesn't explicitly say that trailing data is okay, but a lot
of people do this and most unzippers will handle it just fine. In any
case, this makes the package more useful, and led me to make the
directory parsing code marginally more robust.
runtime: fix race on hashmap flags field
Use atomic operations on flags field to make sure we aren't
losing a flag update during parallel map operations.
R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/8377046
Don't measure wall time in map.go. Keep it portable
and only test NaN, but not time.
Move time tests to mapnan.go and only measure user CPU time,
not wall time. It builds on Darwin and Linux, the primary
platforms where people hack on the runtime & in particular
maps. The runtime is shared, though, so we don't need it to
run on all of the platforms.
runtime: fix deadlock in network poller
The invariant is that there must be at least one running P or a thread polling network.
It was broken.
Fixes #5216.
R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/8459043
runtime: reset typed dangling pointer
If for whatever reason seh points into Go heap region,
the dangling pointer will cause memory corruption during GC.
Update #5193.
The offset of an embedded field s.X must be relative to s
and not to the implicit s.Field of which X is a direct field.
Moreover, no indirections may happen on the path.
Fixes #4909.
R=nigeltao, ality, daniel.morsing, iant, gri, r
CC=golang-dev
https://golang.org/cl/8287043
Anthony Martin [Thu, 4 Apr 2013 01:23:43 +0000 (18:23 -0700)]
cmd/nm: don't add filename elements for m symbols
The compilers used to generate only one 'm' symbol
to record the stack frame size for each function.
In cmd/nm, the 'm' and 'f' symbols are handled in
the same switch case with a special exception for
the symbol described above called ".frame".
Now that the compilers emit additional 'm' symbols
for precise garbage collection of the stack, the
current logic is incorrect. cmd/nm will attempt to
interpret these new 'm' symbols as 'f' symbols and
add them to the file name index table.
This fails with an out-of-memory condition when
zenter encounters an 'm' symbol with a very large
value (usually the .args symbol indicating a
variadic NOSPLIT function).
runtime: fix data/bss shadow memory mapping for race detector
Fixes #5175.
Race detector runtime expects values passed to MapShadow() to be page-aligned,
because they are used in mmap() call. If they are not aligned mmap() trims
either beginning or end of the mapping.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8325043
Rob Pike [Wed, 3 Apr 2013 20:56:24 +0000 (13:56 -0700)]
doc: link the race detector document into the release notes
Also:
- put GORACE into the go env command
- do minor housekeeping on the race detector article
The smtp package originally allowed PLAIN whenever, but then
the TLS check was added for paranoia, but it's too paranoid:
it prevents using PLAIN auth even from localhost to localhost
when the server advertises PLAIN support.
This CL also permits the client to send PLAIN if the server
advertises it.
Fixes #5184
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8279043
Rob Pike [Wed, 3 Apr 2013 17:40:33 +0000 (10:40 -0700)]
doc/go1.1.html: state that the heap is bigger on 64-bit machines
Be deliberately vague, since the precise details should not be depended upon.
Fixes #5155.
net/http: don't allocate 0-byte io.LimitedReaders for GET requests
Save an allocation per GET request and don't call io.LimitedReader(r, 0)
just to read 0 bytes. There's already an eofReader global variable
for when we just want a non-nil io.Reader to immediately EOF.
(Sorry, I know Rob told me to stop, but I was bored on the plane and
wrote this before I received the recent "please, really stop" email.)
runtime: avoid hashing strings until needed in single-bucket maps
This changes the map lookup behavior for string maps with 2-8 keys.
There was already previously a fastpath for 0 items and 1 item.
Now, if a string-keyed map has <= 8 items, first check all the
keys for length first. If only one has the right length, then
just check it for equality and avoid hashing altogether. Once
the map has more than 8 items, always hash like normal.
I don't know why some of the other non-string map benchmarks
got faster. This was with benchtime=2s, multiple times. I haven't
anything else getting slower, though.
net/http: fewer allocations in chunkWriter.WriteHeader
It was unnecessarily cloning and then mutating a map that had
a very short lifetime (just that function).
No new tests, because they were added in revision 833bf2ef1527
(TestHeaderToWire). The benchmarks below are from the earlier
commit, revision 52e3407d.
I noticed this inefficiency when reviewing a change Peter Buhr
is looking into, which will also use these benchmarks.
David Symonds [Tue, 2 Apr 2013 21:26:08 +0000 (08:26 +1100)]
cmd/gc: preserve safe annotation of package def.
A package file may begin as either "package foo" or
"package foo safe". The latter is relevant when using -u.
https://golang.org/cl/6903059 resulted in the distinction
being dropped when a package was read for the second or later time.
This CL records whether that "safe" tag was present,
and includes it in the dummy statement generated for the lexer.