]> Cypherpunks repositories - gostls13.git/log
gostls13.git
11 years agoruntime: add a missing newline in a debug printf.
David Symonds [Mon, 22 Jul 2013 02:42:42 +0000 (12:42 +1000)]
runtime: add a missing newline in a debug printf.

Trivial, but annoying while debugging this code.

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

11 years agodoc: fix wiki content error
Andrew Gerrand [Mon, 22 Jul 2013 02:22:14 +0000 (12:22 +1000)]
doc: fix wiki content error

Fixes #5898.

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

11 years agoregexp: use a very fast random generator for benchmarks.
Rémy Oudompheng [Sat, 20 Jul 2013 21:31:51 +0000 (23:31 +0200)]
regexp: use a very fast random generator for benchmarks.

Calls into math/rand are very slow, especially under race
detector because of heap accesses.

go test -bench . -run none -benchtime .1s
Before: 23.0s
After:  17.4s

Fixes #5837.

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

11 years agolibmach: support more 386/amd64 instructions
Anthony Martin [Sat, 20 Jul 2013 07:38:26 +0000 (00:38 -0700)]
libmach: support more 386/amd64 instructions

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

11 years agolibmach,lib9: override unused parameter warnings (fixes netbsd and openbsd builds)
Alex Brainman [Sat, 20 Jul 2013 06:09:30 +0000 (16:09 +1000)]
libmach,lib9: override unused parameter warnings (fixes netbsd and openbsd builds)

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

11 years agolibmach,lib9: override unused parameter warnings (fixes windows build)
Alex Brainman [Sat, 20 Jul 2013 02:43:50 +0000 (12:43 +1000)]
libmach,lib9: override unused parameter warnings (fixes windows build)

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

11 years agocmd/dist, cmd/go: enable more warnings, make clang errors legible
Russ Cox [Fri, 19 Jul 2013 23:36:15 +0000 (19:36 -0400)]
cmd/dist, cmd/go: enable more warnings, make clang errors legible

This does not change the default compiler on OS X to clang.
It appears that for now we can keep using gcc as long as we
enable a few more warning settings that are on-by-default
elsewhere.

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

11 years agocmd/ld, runtime: remove unused fields from Func
Russ Cox [Fri, 19 Jul 2013 22:52:35 +0000 (18:52 -0400)]
cmd/ld, runtime: remove unused fields from Func

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

11 years agocmd/gc, cmd/ld: fix build: remove unused var, use correct var in printf
Ian Lance Taylor [Fri, 19 Jul 2013 22:04:53 +0000 (15:04 -0700)]
cmd/gc, cmd/ld: fix build: remove unused var, use correct var in printf

Fixes #5924.

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

11 years agoruntime: use funcdata to supply garbage collection information
Russ Cox [Fri, 19 Jul 2013 20:04:09 +0000 (16:04 -0400)]
runtime: use funcdata to supply garbage collection information

This CL introduces a FUNCDATA number for runtime-specific
garbage collection metadata, changes the C and Go compilers
to emit that metadata, and changes the runtime to expect it.

The old pseudo-instructions that carried this information
are gone, as is the linker code to process them.

R=golang-dev, dvyukov, cshapiro
CC=golang-dev
https://golang.org/cl/11406044

11 years agocmd/dist: generate offsets for P structure
Russ Cox [Fri, 19 Jul 2013 19:40:32 +0000 (15:40 -0400)]
cmd/dist: generate offsets for P structure

So far no checked-in assembly needs these,
but it matches having them for M and G.
I needed these for some manual testing.

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

11 years agodebug/gosym: put pclinetest file in temporary directory
Keith Randall [Fri, 19 Jul 2013 19:31:42 +0000 (12:31 -0700)]
debug/gosym: put pclinetest file in temporary directory
where it belongs.

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

11 years agoruntime: cleanup: use ArgsSizeUnknown to mark all functions
Keith Randall [Fri, 19 Jul 2013 18:19:18 +0000 (11:19 -0700)]
runtime: cleanup: use ArgsSizeUnknown to mark all functions
whose argument size is unknown (C vararg functions, and
assembly code without an explicit specification).

We used to use 0 to mean "unknown" and 1 to mean "zero".
Now we use ArgsSizeUnknown (0x80000000) to mean "unknown".

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

11 years agoruntime: prevent GC from seeing the contents of a frame in runfinq
Dmitriy Vyukov [Fri, 19 Jul 2013 14:01:33 +0000 (18:01 +0400)]
runtime: prevent GC from seeing the contents of a frame in runfinq
This holds the last finalized object and arguments to its finalizer.
Fixes #5348.

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

11 years agotest: fix error output in the test
Dmitriy Vyukov [Fri, 19 Jul 2013 13:48:19 +0000 (17:48 +0400)]
test: fix error output in the test

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

11 years agoruntime: hide mheap from GC
Dmitriy Vyukov [Fri, 19 Jul 2013 13:47:40 +0000 (17:47 +0400)]
runtime: hide mheap from GC
It contains pointers to first blocks of lots of spans.

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

11 years agoruntime: prevent sysmon from polling network excessivly
Dmitriy Vyukov [Fri, 19 Jul 2013 13:45:34 +0000 (17:45 +0400)]
runtime: prevent sysmon from polling network excessivly
If the network is not polled for 10ms, sysmon starts polling network
on every iteration (every 20us) until another thread blocks in netpoll.
Fixes #5922.

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

11 years agoregexp: exclude exhaustive RE2 test from running under race detector.
David Symonds [Fri, 19 Jul 2013 13:44:22 +0000 (23:44 +1000)]
regexp: exclude exhaustive RE2 test from running under race detector.

It is an expensive test to run, and even more so with -race,
and causes timeouts on builders. It is doubtful that it would
find a race that other tests in this package wouldn't, so there
is little loss in excluding it.

Update #5837.

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

11 years agoruntime: disable preemption during runtime.settype
Russ Cox [Fri, 19 Jul 2013 02:58:49 +0000 (22:58 -0400)]
runtime: disable preemption during runtime.settype

It assumes that the m will not change, and the m may
change if the goroutine is preempted.

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

11 years agonet/http: document and test Client.Post treating Reader body as ReadCloser
Brad Fitzpatrick [Fri, 19 Jul 2013 02:02:54 +0000 (12:02 +1000)]
net/http: document and test Client.Post treating Reader body as ReadCloser

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

11 years agoruntime: preempt long-running goroutines
Dmitriy Vyukov [Thu, 18 Jul 2013 21:22:26 +0000 (01:22 +0400)]
runtime: preempt long-running goroutines
If a goroutine runs for more than 10ms, preempt it.
Update #543.

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

11 years agoruntime: handle morestack/lessstack in stack trace
Russ Cox [Thu, 18 Jul 2013 20:53:45 +0000 (16:53 -0400)]
runtime: handle morestack/lessstack in stack trace

If we start a garbage collection on g0 during a
stack split or unsplit, we'll see morestack or lessstack
at the top of the stack. Record an argument frame size
for those, and record that they terminate the stack.

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

11 years agocmd/6a, cmd/6l: make FUNCDATA work
Russ Cox [Thu, 18 Jul 2013 19:38:19 +0000 (15:38 -0400)]
cmd/6a, cmd/6l: make FUNCDATA work

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

11 years agoregexp/syntax: update documentation for Parse.
Daniel Morsing [Thu, 18 Jul 2013 19:28:00 +0000 (21:28 +0200)]
regexp/syntax: update documentation for Parse.

Syntax description was moved to the top level comment of this package.

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

11 years agoruntime: disable preemption during deferreturn
Russ Cox [Thu, 18 Jul 2013 16:26:47 +0000 (12:26 -0400)]
runtime: disable preemption during deferreturn

Deferreturn is synthesizing a new call frame.
It must not be interrupted between copying the args there
and fixing up the program counter, or else the stack will
be in an inconsistent state, one that will confuse the
garbage collector.

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

11 years agoruntime: record full frame size for arm _sfloat2
Russ Cox [Thu, 18 Jul 2013 16:23:38 +0000 (12:23 -0400)]
runtime: record full frame size for arm _sfloat2

With preemption, _sfloat2 can show up in stack traces.
Write the function prototype in a way that accurately
shows the frame size and the fact that it might contain
pointers.

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

11 years agoruntime: mark concatstring as variadic (fixes 386 build)
Russ Cox [Thu, 18 Jul 2013 16:19:38 +0000 (12:19 -0400)]
runtime: mark concatstring as variadic (fixes 386 build)

Windows was the only one seeing this bug reliably in the builder,
but it was easy to reproduce using 'GOGC=1 go test strconv'.
concatstring looked like it took only one string, but in fact it
takes a long list of strings. Add an explicit ... so that the traceback
will not use the "fixed" frame size and instead look at the
frame size metadata recorded by the caller.

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

11 years agocmd/ld: refine test for history stack pop (fix Windows build)
Russ Cox [Thu, 18 Jul 2013 15:40:59 +0000 (11:40 -0400)]
cmd/ld: refine test for history stack pop (fix Windows build)

This should fix the Windows build, or at least
what's breaking it at the moment.

Fixes #5904.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/11519044

11 years agodebug/gosym: avoid test failure on Windows
Russ Cox [Thu, 18 Jul 2013 15:01:58 +0000 (11:01 -0400)]
debug/gosym: avoid test failure on Windows

Would fix build if build hadn't already been broken with something else.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/11525043

11 years agocmd/ld, runtime: use new contiguous pcln table
Russ Cox [Thu, 18 Jul 2013 14:43:22 +0000 (10:43 -0400)]
cmd/ld, runtime: use new contiguous pcln table

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

11 years agolibmach: update for Go 1.2 pcln table
Russ Cox [Thu, 18 Jul 2013 14:12:28 +0000 (10:12 -0400)]
libmach: update for Go 1.2 pcln table

The change to addr2line makes it easy to test by hand.

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

11 years agodebug/gosym: update for Go 1.2 pcln table
Russ Cox [Thu, 18 Jul 2013 14:12:14 +0000 (10:12 -0400)]
debug/gosym: update for Go 1.2 pcln table

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

11 years agoio: let SectionReader seek past the end; document Seeker semantics more
Brad Fitzpatrick [Thu, 18 Jul 2013 03:03:26 +0000 (13:03 +1000)]
io: let SectionReader seek past the end; document Seeker semantics more

Be consistent with os.File, strings.Reader, bytes.Reader, etc,
which all allow seeks past the end.

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

11 years agoimage/gif: don't write superfluous global color table
Andrew Bonventre [Thu, 18 Jul 2013 01:11:23 +0000 (11:11 +1000)]
image/gif: don't write superfluous global color table

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

11 years agocmd/cgo: don't emit #pragma declarations when using gccgo
Ian Lance Taylor [Thu, 18 Jul 2013 01:02:21 +0000 (18:02 -0700)]
cmd/cgo: don't emit #pragma declarations when using gccgo

Update #5905

Don't emit #pragma cgo_ldflag and cgo_import_static
declarations that gccgo doesn't understand and can't use.

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

11 years agocmd/ld: trivial: fix unused parameter pedantry
Dave Cheney [Thu, 18 Jul 2013 00:11:43 +0000 (10:11 +1000)]
cmd/ld: trivial: fix unused parameter pedantry

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

11 years agonet/http: document NewRequest treating Reader as ReadCloser
Brad Fitzpatrick [Thu, 18 Jul 2013 00:10:10 +0000 (10:10 +1000)]
net/http: document NewRequest treating Reader as ReadCloser

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

11 years agoruntime: disable preemption again to fix linux build
Ian Lance Taylor [Wed, 17 Jul 2013 23:15:46 +0000 (16:15 -0700)]
runtime: disable preemption again to fix linux build

Otherwise the tests in pkg/runtime fail:

runtime: unknown argument frame size for runtime.deferreturn called from 0x48657b [runtime_test.func·022]
fatal error: invalid stack
...

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

11 years agomisc/emacs: Add godef-jump-other-window
Dominik Honnef [Wed, 17 Jul 2013 22:16:44 +0000 (18:16 -0400)]
misc/emacs: Add godef-jump-other-window

This will behave like similar "*-other-window" functions in Emacs.

Default key bind is C-x 4 C-c C-j – while awkward, it follows both
the convention for other-window functions and the convention for
not using user- or emacs-reserved keys.

R=golang-dev, adonovan
CC=golang-dev
https://golang.org/cl/10707045

11 years agoruntime: re-enable preemption
Russ Cox [Wed, 17 Jul 2013 18:03:27 +0000 (14:03 -0400)]
runtime: re-enable preemption

Update #543

I believe the runtime is strong enough now to reenable
preemption during the function prologue.
Assuming this is or can be made stable, it will be in Go 1.2.
More aggressive preemption is not planned for Go 1.2.

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

11 years agoruntime: more reliable preemption
Dmitriy Vyukov [Wed, 17 Jul 2013 16:52:37 +0000 (12:52 -0400)]
runtime: more reliable preemption
Currently preemption signal g->stackguard0==StackPreempt
can be lost if it is received when preemption is disabled
(e.g. m->lock!=0). This change duplicates the preemption
signal in g->preempt and restores g->stackguard0
when preemption is enabled.
Update #543.

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

11 years agoruntime: use new frame argument size information
Russ Cox [Wed, 17 Jul 2013 16:47:18 +0000 (12:47 -0400)]
runtime: use new frame argument size information

With this CL, I believe the runtime always knows
the frame size during the gc walk. There is no fallback
to "assume entire stack frame of caller" anymore.

R=golang-dev, khr, cshapiro, dvyukov
CC=golang-dev
https://golang.org/cl/11374044

11 years agocrypto/tls: Add support for ECDHE-ECDSA
Joel Sing [Wed, 17 Jul 2013 16:33:16 +0000 (12:33 -0400)]
crypto/tls: Add support for ECDHE-ECDSA

Add support for ECDHE-ECDSA (RFC4492), which uses an ephemeral server
key pair to perform ECDH with ECDSA signatures. Like ECDHE-RSA,
ECDHE-ECDSA also provides PFS.

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

11 years agocmd/8g: Make clearfat non-interleaved with pointer calculations.
Daniel Morsing [Wed, 17 Jul 2013 09:04:34 +0000 (11:04 +0200)]
cmd/8g: Make clearfat non-interleaved with pointer calculations.

clearfat (used to zero initialize structures) will use AX for x86 block ops. If we write to AX while calculating the dest pointer, we will fill the structure with incorrect values.
Since 64-bit arithmetic uses AX to synthesize a 64-bit register, getting an adress by indexing with 64-bit ops can clobber the register.

Fixes #5820.

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

11 years agodoc/effective_go: stamp out stray GOROOT reference
Dave Cheney [Wed, 17 Jul 2013 08:48:55 +0000 (18:48 +1000)]
doc/effective_go: stamp out stray GOROOT reference

Replaced with something more appropriate.

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

11 years agoruntime: print g0 stack if we throw on it and GOTRACEBACK>=2.
Keith Randall [Tue, 16 Jul 2013 23:44:24 +0000 (16:44 -0700)]
runtime: print g0 stack if we throw on it and GOTRACEBACK>=2.

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

11 years agocrypto/rsa: remove obsolete TODO.
Adam Langley [Tue, 16 Jul 2013 23:34:21 +0000 (19:34 -0400)]
crypto/rsa: remove obsolete TODO.

(PSS support is complete.)

Thanks to Frithjof Schulze for noting this.

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

11 years agotest: add a compilation test that gccgo failed to compile
Ian Lance Taylor [Tue, 16 Jul 2013 22:31:42 +0000 (15:31 -0700)]
test: add a compilation test that gccgo failed to compile

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

11 years agoCONTRIBUTORS: add Drew Hintz (Google CLA)
Adam Langley [Tue, 16 Jul 2013 21:37:22 +0000 (17:37 -0400)]
CONTRIBUTORS: add Drew Hintz (Google CLA)

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

11 years agocmd/5g, cmd/6g, cmd/8g: insert arg size annotations on runtime calls
Russ Cox [Tue, 16 Jul 2013 20:25:10 +0000 (16:25 -0400)]
cmd/5g, cmd/6g, cmd/8g: insert arg size annotations on runtime calls

If calling a function in package runtime, emit argument size
information around the call in case the call is to a variadic C function.

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

11 years agocmd/5c, cmd/6c, cmd/8c: record arg size for every call
Russ Cox [Tue, 16 Jul 2013 20:24:43 +0000 (16:24 -0400)]
cmd/5c, cmd/6c, cmd/8c: record arg size for every call

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

11 years agoruntime: record argument size in assembly functions
Russ Cox [Tue, 16 Jul 2013 20:24:09 +0000 (16:24 -0400)]
runtime: record argument size in assembly functions

I have not done the system call stubs in sys_*.s.
I hope to avoid that, because those do not block, so those
frames will not appear in stack traces during garbage
collection.

R=golang-dev, dvyukov, khr
CC=golang-dev
https://golang.org/cl/11360043

11 years agosyscall: record argument size for all assembly functions
Russ Cox [Tue, 16 Jul 2013 20:23:53 +0000 (16:23 -0400)]
syscall: record argument size for all assembly functions

While we're here, fix Syscall9 on NetBSD and OpenBSD:
it was storing the results into the wrong memory locations.
I guess no one uses that function's results on those systems.

Part of cleaning up stack traces and argument frame information.

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

11 years agocmd/5a, cmd/6a, cmd/8a: parse PCDATA
Russ Cox [Tue, 16 Jul 2013 20:23:28 +0000 (16:23 -0400)]
cmd/5a, cmd/6a, cmd/8a: parse PCDATA

In cmd/5a, also add support for argument size in TEXT instruction.

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

11 years agocmd/5l, cmd/6l, cmd/8l: accept PCDATA instruction in input
Russ Cox [Tue, 16 Jul 2013 20:23:11 +0000 (16:23 -0400)]
cmd/5l, cmd/6l, cmd/8l: accept PCDATA instruction in input

The portable code in cmd/ld already knows how to process it,
we just have to ignore it during code generation.

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

11 years agotest: invert incorrect condition.
Alan Donovan [Tue, 16 Jul 2013 16:18:00 +0000 (12:18 -0400)]
test: invert incorrect condition.

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

11 years agoruntime: minor cleanup of hashmap code
Dmitriy Vyukov [Tue, 16 Jul 2013 15:51:18 +0000 (19:51 +0400)]
runtime: minor cleanup of hashmap code

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

11 years agonet: fix setsockopt for openbsd
Joel Sing [Tue, 16 Jul 2013 15:35:06 +0000 (08:35 -0700)]
net: fix setsockopt for openbsd

s/TCP_KEEPALIVE/SO_KEEPALIVE/ to unbreak build on OpenBSD.

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

11 years agocmd/ld, runtime: new in-memory symbol table format
Russ Cox [Tue, 16 Jul 2013 13:41:38 +0000 (09:41 -0400)]
cmd/ld, runtime: new in-memory symbol table format

Design at http://golang.org/s/go12symtab.

This enables some cleanup of the garbage collector metadata
that will be done in future CLs.

This CL does not move the old symtab and pclntab back into
an unmapped section of the file. That's a bit tricky and will be
done separately.

Fixes #4020.

R=golang-dev, dave, cshapiro, iant, r
CC=golang-dev, nigeltao
https://golang.org/cl/11085043

11 years agocmd/gc: do not race instrument syscall.forkAndExecInChild
Dmitriy Vyukov [Tue, 16 Jul 2013 11:35:03 +0000 (15:35 +0400)]
cmd/gc: do not race instrument syscall.forkAndExecInChild
Race instrumentation can allocate, switch stacks, preempt, etc.
All that is not allowed in between fork and exec.
Fixes #4840.

R=golang-dev, daniel.morsing, dave
CC=golang-dev
https://golang.org/cl/11324044

11 years agocmd/gc: fix incorrect error when using f(g()) form on ... args
Daniel Morsing [Tue, 16 Jul 2013 09:43:11 +0000 (11:43 +0200)]
cmd/gc: fix incorrect error when using f(g()) form on ... args

Fixes #5358.

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

11 years agocmd/gc: complex types don't contain pointers
Evan Shaw [Tue, 16 Jul 2013 07:41:31 +0000 (17:41 +1000)]
cmd/gc: complex types don't contain pointers

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

11 years agocmd/gc: fix race detector instrumentation of type switches.
Rémy Oudompheng [Tue, 16 Jul 2013 07:04:20 +0000 (09:04 +0200)]
cmd/gc: fix race detector instrumentation of type switches.

A type switch on a value with map index expressions,
could get a spurious instrumentation from a OTYPESW node.
These nodes do not need instrumentation because after
walk the type switch has been turned into a sequence
of ifs.

Fixes #5890.

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

11 years agoruntime: switch to os stack in windows osyield and usleep
Alex Brainman [Tue, 16 Jul 2013 02:36:05 +0000 (12:36 +1000)]
runtime: switch to os stack in windows osyield and usleep

Fixes #5831

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

11 years agocmd/gc: tweak interface satisfaction error message
Russ Cox [Tue, 16 Jul 2013 00:39:07 +0000 (20:39 -0400)]
cmd/gc: tweak interface satisfaction error message

"M requires pointer receiver" can be misinterpreted to
mean that method M should have a pointer receiver but
does not. In fact the message means "M has a pointer
receiver" (and you don't have a pointer).

Fixes #5891.

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

11 years agonet: add SetKeepAlivePeriod
David Presotto [Mon, 15 Jul 2013 22:40:55 +0000 (18:40 -0400)]
net: add SetKeepAlivePeriod

Sets both the duration from the last data packet to the first
keep alive packet and the duration between keep alive packets to be
the passed duration.

I've tested the function on both Darwin (10.8.4) and 4.2 Linux.
I've compiled (make.bash) for all the OS's and tested (all.bash)
on Darwin and Linux.

R=golang-dev, dave, rsc, dvyukov, presotto+facebook, nick
CC=golang-dev, veyron-team
https://golang.org/cl/11130044

11 years agoCONTRIBUTORS: add David Presotto (Google CLA)
Russ Cox [Mon, 15 Jul 2013 22:40:47 +0000 (18:40 -0400)]
CONTRIBUTORS: add David Presotto (Google CLA)

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

11 years agoruntime: minor test cleanup
Dmitriy Vyukov [Mon, 15 Jul 2013 21:02:42 +0000 (01:02 +0400)]
runtime: minor test cleanup

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

11 years agomisc/cgo/test: skip test for issue 3250, the runtime isn't ready yet.
Shenghou Ma [Mon, 15 Jul 2013 06:37:36 +0000 (14:37 +0800)]
misc/cgo/test: skip test for issue 3250, the runtime isn't ready yet.
see issue 5885.

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

11 years agoimage/gif: add writer implementation
Andrew Bonventre [Mon, 15 Jul 2013 00:57:01 +0000 (10:57 +1000)]
image/gif: add writer implementation

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

11 years agodist: fix postinstall script for Darwin
Alexandre Normand [Mon, 15 Jul 2013 00:52:38 +0000 (10:52 +1000)]
dist: fix postinstall script for Darwin

The postinstall script causes the installation to fail because the last
step that copies files for Xcode is broken. Two details can cause the
command to fail:
  1. The XCODE_MISC_DIR value has a space. Without quotes in the cp
     command, cp will just complain that this is an invalid syntax.
  2. The source of the cp is a directory with two subdirectories.
     We actually want the files for either Xcode 3 or Xcode 4 to be copied.
     Using xcodebuild -version, we check for the Xcode version and
     select which of xcode/3/* or xcode/4/* should be the source
     of the copy.

Fixes #5874.

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

11 years agoA+C: Alexandre Normand (individual CLA)
Andrew Gerrand [Mon, 15 Jul 2013 00:52:21 +0000 (10:52 +1000)]
A+C: Alexandre Normand (individual CLA)

Generated by addca.

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

11 years agoA+C: Andrew Bonventre (individual CLA).
Nigel Tao [Mon, 15 Jul 2013 00:45:53 +0000 (10:45 +1000)]
A+C: Andrew Bonventre (individual CLA).

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

11 years agolog/syslog: fix typo: change Wanring to Warning
Joseph Holsten [Sun, 14 Jul 2013 02:56:11 +0000 (12:56 +1000)]
log/syslog: fix typo: change Wanring to Warning

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

11 years agoA+C: Joseph Holsten (individual CLA)
Rob Pike [Sun, 14 Jul 2013 02:54:45 +0000 (12:54 +1000)]
A+C: Joseph Holsten (individual CLA)

Generated by addca.

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

11 years agocmd/6l, cmd/8l: use one-byte XCHG forms when possible
Russ Cox [Sat, 13 Jul 2013 00:58:38 +0000 (20:58 -0400)]
cmd/6l, cmd/8l: use one-byte XCHG forms when possible

Pointed out by khr.

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

11 years agoencoding/json: add more tests for UTF-8 coercion
Russ Cox [Sat, 13 Jul 2013 00:40:50 +0000 (20:40 -0400)]
encoding/json: add more tests for UTF-8 coercion

Suggested by Rob in CL 11211045, but the mail arrived
moments after hg submit completed.

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

11 years agocmd/go, testing: streamline direct use of test binaries
Russ Cox [Sat, 13 Jul 2013 00:40:30 +0000 (20:40 -0400)]
cmd/go, testing: streamline direct use of test binaries

Before:

        $ go test -c -cover fmt
        $ ./fmt.test -test.covermode=set
        PASS
        coverage: 65.1% of statements in strconv
        $

After:

        $ go test -c -cover fmt
        $ ./fmt.test
        PASS
        coverage: 65.1% of statements in strconv
        $

In addition to being cumbersome, the old flag didn't make sense:
the cover mode cannot be changed after the binary has been built.

Another useful effect of this CL is that if you happen to do

        $ go test -c -covermode=atomic fmt

and then forget you did that and run benchmarks,
the final line of the output (the coverage summary) reminds you
that you are benchmarking with coverage enabled, which might
not be what you want.

        $ ./fmt.test -test.bench .
        PASS
        BenchmarkSprintfEmpty 10000000        217 ns/op
        BenchmarkSprintfString  2000000        755 ns/op
        BenchmarkSprintfInt  2000000        774 ns/op
        BenchmarkSprintfIntInt  1000000       1363 ns/op
        BenchmarkSprintfPrefixedInt  1000000       1501 ns/op
        BenchmarkSprintfFloat  1000000       1257 ns/op
        BenchmarkManyArgs   500000       5346 ns/op
        BenchmarkScanInts     1000    2562402 ns/op
        BenchmarkScanRecursiveInt      500    3189457 ns/op
        coverage: 91.4% of statements
        $

As part of passing the new mode setting in via _testmain.go, merge
the two registration mechanisms into one extensible mechanism
(a struct).

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

11 years agoundo CL 11161044 / ba455262a9db
Russ Cox [Fri, 12 Jul 2013 21:42:01 +0000 (17:42 -0400)]
undo CL 11161044 / ba455262a9db

I want to think more carefully about this.

We put this in because Marshal encoded named []byte but Unmarshal rejected them.
And we noticed that Marshal's behavior was undocumented so we documented it.
But I am starting to think the docs and Unmarshal were correct and Marshal's
behavior was the problem.

Rolling back to give us more time to think.

««« original CL description
json: unmarshal types that are byte slices.

The json package cheerfully would marshal

        type S struct {
                IP net.IP
        }

but would give an error when unmarshalling.  This change allows any
type whose concrete type is a byte slice to be unmarshalled from a
string.

Fixes #5086.

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

»»»

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

11 years agoencoding/json: coerce invalid UTF-8 to valid UTF-8 during Marshal
Russ Cox [Fri, 12 Jul 2013 21:37:10 +0000 (17:37 -0400)]
encoding/json: coerce invalid UTF-8 to valid UTF-8 during Marshal

In practice, rejecting an entire structure due to a single invalid byte
in a string is just too picky, and too hard to track down.
Be consistent with the bulk of the standard library by converting
invalid UTF-8 into UTF-8 with replacement runes.

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/11211045

11 years agocmd/dist: allow assembly code to use enumerated constants.
Keith Randall [Fri, 12 Jul 2013 19:24:57 +0000 (12:24 -0700)]
cmd/dist: allow assembly code to use enumerated constants.

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

11 years agocmd/5a, cmd/6a, cmd/8a: fix flag parsing
Russ Cox [Fri, 12 Jul 2013 18:23:36 +0000 (14:23 -0400)]
cmd/5a, cmd/6a, cmd/8a: fix flag parsing

go tool 6a -$(unicode fffd) was crashing.

Fixes #5878.

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

11 years agorun.bash: enlarge timeout of runtime tests
Shenghou Ma [Fri, 12 Jul 2013 18:00:07 +0000 (02:00 +0800)]
run.bash: enlarge timeout of runtime tests
Recently addition to runtime test makes it take very close to 720s
of timeout limit on the netbsd-arm-qemu builder.

R=golang-dev, go.peter.90, rsc
CC=golang-dev
https://golang.org/cl/10935043

11 years agocmd/5g, cmd/6g, cmd/8g: fix line number of caller of deferred func
Russ Cox [Fri, 12 Jul 2013 17:47:55 +0000 (13:47 -0400)]
cmd/5g, cmd/6g, cmd/8g: fix line number of caller of deferred func

Deferred functions are not run by a call instruction. They are run by
the runtime editing registers to make the call start with a caller PC
returning to a
        CALL deferreturn
instruction.

That instruction has always had the line number of the function's
closing brace, but that instruction's line number is irrelevant.
Stack traces show the line number of the instruction before the
return PC, because normally that's what started the call. Not so here.
The instruction before the CALL deferreturn could be almost anywhere
in the function; it's unrelated and its line number is incorrect to show.

Fix the line number by inserting a true hardware no-op with the right
line number before the returned-to CALL instruction. That is, the deferred
calls now appear to start with a caller PC returning to the second instruction
in this sequence:
        NOP
        CALL deferreturn

The traceback will show the line number of the NOP, which we've set
to be the line number of the function's closing brace.

The NOP here is not the usual pseudo-instruction, which would be
elided by the linker. Instead it is the real hardware instruction:
XCHG AX, AX on 386 and amd64, and AND.EQ R0, R0, R0 on ARM.

Fixes #5856.

R=ken2, ken
CC=golang-dev
https://golang.org/cl/11223043

11 years agocmd/ld: fix large stack split for preempt check
Russ Cox [Fri, 12 Jul 2013 16:12:56 +0000 (12:12 -0400)]
cmd/ld: fix large stack split for preempt check

If the stack frame size is larger than the known-unmapped region at the
bottom of the address space, then the stack split prologue cannot use the usual
condition:

        SP - size >= stackguard

because SP - size may wrap around to a very large number.
Instead, if the stack frame is large, the prologue tests:

        SP - stackguard >= size

(This ends up being a few instructions more expensive, so we don't do it always.)

Preemption requests register by setting stackguard to a very large value, so
that the first test (SP - size >= stackguard) cannot possibly succeed.
Unfortunately, that same very large value causes a wraparound in the
second test (SP - stackguard >= size), making it succeed incorrectly.

To avoid *that* wraparound, we have to amend the test:

        stackguard != StackPreempt && SP - stackguard >= size

This test is only used for functions with large frames, which essentially
always split the stack, so the cost of the few instructions is noise.

This CL and CL 11085043 together fix the known issues with preemption,
at the beginning of a function, so we will be able to try turning it on again.

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

11 years agocmd/go, testing: remove redundant "for pkg" in coverage message
Russ Cox [Fri, 12 Jul 2013 11:34:16 +0000 (07:34 -0400)]
cmd/go, testing: remove redundant "for pkg" in coverage message

This is a transcript before this change. I've capitalized the text being removed.
Note that it is always near another line that already says fmt, marked with <<<

$ cd $GOROOT/src/pkg/fmt

$ go test -cover
PASS
coverage FOR FMT: 91.3% of statements
ok   fmt 0.040s <<<

$ go test -coverpkg strconv
PASS
coverage FOR FMT: 64.9% of statements in strconv
ok   fmt 0.039s <<<

$ go test -cover -c
$ ./fmt.test -test.covermode=set <<<
PASS
coverage FOR FMT: 91.3% of statements

$ go test -coverpkg strconv -c
$ ./fmt.test -test.covermode=set <<<
PASS
coverage FOR FMT: 64.9% of statements in strconv

That the summary printed by 'go test [options] fmt' is unchanged:

$ go test -cover fmt
ok   fmt 0.040s coverage: 91.3% of statements

$ go test -coverpkg strconv fmt
ok   fmt 0.038s coverage: 64.9% of statements in strconv

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

11 years agomisc/cgo/test: relax the threshold in test3250.
Shenghou Ma [Fri, 12 Jul 2013 06:13:59 +0000 (14:13 +0800)]
misc/cgo/test: relax the threshold in test3250.
Fixes build for some slow FreeBSD/NetBSD/Darwin builder.

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

11 years agoruntime: fix 386 build after cas64 change
Russ Cox [Fri, 12 Jul 2013 04:42:46 +0000 (00:42 -0400)]
runtime: fix 386 build after cas64 change

Missed this in CL 10909045.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/10803045

11 years agoencoding/json: escape U+2028 and U+2029.
David Symonds [Fri, 12 Jul 2013 04:35:55 +0000 (14:35 +1000)]
encoding/json: escape U+2028 and U+2029.

Fixes #5836.

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

11 years agoruntime: make cas64 like cas32 and casp
Russ Cox [Fri, 12 Jul 2013 04:03:32 +0000 (00:03 -0400)]
runtime: make cas64 like cas32 and casp

The current cas64 definition hard-codes the x86 behavior
of updating *old with the new value when the cas fails.
This is inconsistent with cas32 and casp.
Make it consistent.

This means that the cas64 uses will be epsilon less efficient
than they might be, because they have to do an unnecessary
memory load on x86. But so be it. Code clarity and consistency
is more important.

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

11 years agorun.bash: actually stop on cgo failures
Russ Cox [Fri, 12 Jul 2013 03:24:57 +0000 (23:24 -0400)]
run.bash: actually stop on cgo failures

I hate bash.

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

11 years agomisc/cgo/test: make test work with -linkmode=internal
Russ Cox [Fri, 12 Jul 2013 03:24:35 +0000 (23:24 -0400)]
misc/cgo/test: make test work with -linkmode=internal

The static func named thread in issue5337.go's C snippet
conflicts with the static func named thread in issue3350.go's C snippet.
I don't know why (they're both static) but I also don't care,
because -linkmode=internal only needs to be able to handle
the cgo in the standard library, and it does.

Change the test to avoid this problem.

Fixes build (after run.bash is fixed to detect the breakage).

R=minux.ma
TBR=minux.ma
CC=golang-dev
https://golang.org/cl/11201043

11 years agocmd/ld: place read-only data in non-executable segment
Russ Cox [Fri, 12 Jul 2013 02:52:48 +0000 (22:52 -0400)]
cmd/ld: place read-only data in non-executable segment

R=golang-dev, dave, r
CC=golang-dev, nigeltao
https://golang.org/cl/10713043

11 years agocmd/5l, cmd/6l, cmd/8l: increase error buffer size
Russ Cox [Fri, 12 Jul 2013 02:49:15 +0000 (22:49 -0400)]
cmd/5l, cmd/6l, cmd/8l: increase error buffer size

STRINGSZ (200) is fine for lines generated by things like
instruction dumps, but an error containing a couple file
names can easily exceed that, especially on Macs with
the ridiculous default $TMPDIR.

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

11 years agocmd/gc: fix error message for import as 'init'
Russ Cox [Fri, 12 Jul 2013 02:40:21 +0000 (22:40 -0400)]
cmd/gc: fix error message for import as 'init'

Fixes #5853.

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

11 years agojson: unmarshal types that are byte slices.
Paul Borman [Fri, 12 Jul 2013 02:34:09 +0000 (22:34 -0400)]
json: unmarshal types that are byte slices.

The json package cheerfully would marshal

        type S struct {
                IP net.IP
        }

but would give an error when unmarshalling.  This change allows any
type whose concrete type is a byte slice to be unmarshalled from a
string.

Fixes #5086.

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

11 years agomake.bat: incease runtime test timeout to 300s (fixes build)
Alex Brainman [Fri, 12 Jul 2013 02:30:18 +0000 (12:30 +1000)]
make.bat: incease runtime test timeout to 300s (fixes build)

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

11 years agomisc/goplay: use `go run x.go` instead of `go build x.go`
ChaiShushan [Thu, 11 Jul 2013 23:41:10 +0000 (09:41 +1000)]
misc/goplay: use `go run x.go` instead of `go build x.go`

when the program is not main package, `go run x.go` can't return the
link error message. so use `go run x.go` in instead `go build x.go`.

Fixes #5865.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/11165043

11 years agospec: move decl in example closer to use
Robert Griesemer [Thu, 11 Jul 2013 21:41:46 +0000 (14:41 -0700)]
spec: move decl in example closer to use

Fixes #5862.

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

11 years agoruntime: fix build for windows.
Shenghou Ma [Thu, 11 Jul 2013 21:06:43 +0000 (05:06 +0800)]
runtime: fix build for windows.

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