]> Cypherpunks repositories - gostls13.git/log
gostls13.git
10 years agoruntime: fix handling of GOTRACEBACK
David du Colombier [Thu, 18 Sep 2014 21:25:11 +0000 (23:25 +0200)]
runtime: fix handling of GOTRACEBACK

Since CL 130990043, the GOTRACEBACK variable is
only used when the GODEBUG variable is set.
This change restores the original behavior.

LGTM=rsc
R=golang-codereviews, aram, gobot, r, rsc
CC=golang-codereviews
https://golang.org/cl/132520043

10 years agoruntime: delete panicstring; move its checks into gopanic
Russ Cox [Thu, 18 Sep 2014 18:49:24 +0000 (14:49 -0400)]
runtime: delete panicstring; move its checks into gopanic

In Go 1.3 the runtime called panicstring to report errors like
divide by zero or memory faults. Now we call panic (gopanic)
with pre-allocated error values. That new path is missing the
checking that panicstring did, so add it there.

The only call to panicstring left is in cnew, which is problematic
because if it fails, probably the heap is corrupt. In that case,
calling panicstring creates a new errorCString (no allocation there),
but then panic tries to print it, invoking errorCString.Error, which
does a string concatenation (allocating), which then dies.
Replace that one panicstring with a throw: cnew is for allocating
runtime data structures and should never ask for an inappropriate
amount of memory.

With panicstring gone, delete newErrorCString, errorCString.
While we're here, delete newErrorString, not called by anyone.
(It can't be: that would be C code calling Go code that might
block or grow the stack.)

Found while debugging a malloc corruption.
This resulted in 'panic during panic' instead of a more useful message.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/138290045

10 years agoos: avoid error result when dir is removed out from under RemoveAll
Russ Cox [Thu, 18 Sep 2014 18:48:47 +0000 (14:48 -0400)]
os: avoid error result when dir is removed out from under RemoveAll

Fixes #7776.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews, r
https://golang.org/cl/145860043

10 years agonet: disable TestDialMultiFDLeak
Russ Cox [Thu, 18 Sep 2014 18:48:26 +0000 (14:48 -0400)]
net: disable TestDialMultiFDLeak

It fails about 25% of the time on OS X.
I don't know what it's trying to do.
Created issue 8764 to correct this, but for now disable.

LGTM=bradfitz, mikioh.mikioh
R=bradfitz, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/144070044

10 years agoencoding/gob: speedup encoding
Dmitriy Vyukov [Thu, 18 Sep 2014 17:13:15 +0000 (10:13 -0700)]
encoding/gob: speedup encoding

Replace typeLock with copy-on-write map using atomic.Value.

benchmark                               old ns/op     new ns/op     delta
BenchmarkEndToEndPipe                   7722          7709          -0.17%
BenchmarkEndToEndPipe-2                 5114          4344          -15.06%
BenchmarkEndToEndPipe-4                 3192          2429          -23.90%
BenchmarkEndToEndPipe-8                 1833          1438          -21.55%
BenchmarkEndToEndPipe-16                1332          983           -26.20%
BenchmarkEndToEndPipe-32                1444          675           -53.25%
BenchmarkEndToEndByteBuffer             6474          6019          -7.03%
BenchmarkEndToEndByteBuffer-2           4280          2810          -34.35%
BenchmarkEndToEndByteBuffer-4           2264          1774          -21.64%
BenchmarkEndToEndByteBuffer-8           1275          979           -23.22%
BenchmarkEndToEndByteBuffer-16          1257          753           -40.10%
BenchmarkEndToEndByteBuffer-32          1342          644           -52.01%
BenchmarkEndToEndArrayByteBuffer        727725        671349        -7.75%
BenchmarkEndToEndArrayByteBuffer-2      394079        320473        -18.68%
BenchmarkEndToEndArrayByteBuffer-4      211785        178175        -15.87%
BenchmarkEndToEndArrayByteBuffer-8      141003        118857        -15.71%
BenchmarkEndToEndArrayByteBuffer-16     139249        86367         -37.98%
BenchmarkEndToEndArrayByteBuffer-32     144128        73454         -49.04%

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/147720043

10 years agofmt: fix allocation tests
Josh Bleecher Snyder [Thu, 18 Sep 2014 16:45:58 +0000 (09:45 -0700)]
fmt: fix allocation tests

Converting an integer to an interface{} allocates as of CL 130240043.

Fixes #8617.

LGTM=r
R=r
CC=golang-codereviews, khr
https://golang.org/cl/141700043

10 years agonet: separate NaCl dependent placeholders from BSD's
Mikio Hara [Thu, 18 Sep 2014 10:17:55 +0000 (19:17 +0900)]
net: separate NaCl dependent placeholders from BSD's

To clarify the dependency of NaCl platform.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/143830044

10 years agosync/atomic: remove unnecessary race instrumentation in Value
Dmitriy Vyukov [Thu, 18 Sep 2014 04:22:11 +0000 (21:22 -0700)]
sync/atomic: remove unnecessary race instrumentation in Value
It is left from the time when Value was implemented in assembly.
Now it is implemented in Go and race detector understands Go.
In particular the atomic operations must provide
all necessary synchronization.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews, khr, rsc
https://golang.org/cl/145880043

10 years agoruntime: output number of goroutines in GC trace
Dmitriy Vyukov [Thu, 18 Sep 2014 03:38:50 +0000 (20:38 -0700)]
runtime: output number of goroutines in GC trace
Example output:
gc26(1): 1+0+1038+0 us, 0 -> 1 MB, 19074 (88777-69703) objects, 5 gs, 184/0/0 sweeps, 0(0) handoff, 0(0) steal, 0/0/0 yields
It's useful to understand long scan times,
because goroutine traceback is slow.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://golang.org/cl/136310044

10 years agoimage/gif: fix GIF encoding of sub-images.
Nigel Tao [Thu, 18 Sep 2014 02:43:01 +0000 (12:43 +1000)]
image/gif: fix GIF encoding of sub-images.

benchmark                    old ns/op     new ns/op     delta
BenchmarkEncode              8641055       8646829       +0.07%

Fixes #7792.

LGTM=r
R=r
CC=dbathgate, golang-codereviews
https://golang.org/cl/147730043

10 years agoA+C: John Tuley (individual CLA)
Brad Fitzpatrick [Wed, 17 Sep 2014 20:52:01 +0000 (16:52 -0400)]
A+C: John Tuley (individual CLA)

Generated by a+c.

R=gobot
CC=golang-codereviews
https://golang.org/cl/142200043

10 years agoruntime: free stacks of Gdead goroutines at GC time
Keith Randall [Wed, 17 Sep 2014 20:25:46 +0000 (13:25 -0700)]
runtime: free stacks of Gdead goroutines at GC time

We could probably free the G structures as well, but
for the allg list.  Leaving that for another day.

Fixes #8287

LGTM=rsc
R=golang-codereviews, dvyukov, khr, rsc
CC=golang-codereviews
https://golang.org/cl/145010043

10 years agoruntime: print more detail in adjustframe crash
Russ Cox [Wed, 17 Sep 2014 20:12:17 +0000 (16:12 -0400)]
runtime: print more detail in adjustframe crash

The logic here is copied from mgc0.c's scanframe.
Mostly it is messages although the minsize code is new
(and I believe necessary).

I am hoping to get more information about the current
arm build failures (or, if it's the minsize thing, fix them).

TBR=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/143180043

10 years agosync/atomic: add more missing Go prototype
Russ Cox [Wed, 17 Sep 2014 19:30:48 +0000 (15:30 -0400)]
sync/atomic: add more missing Go prototype

Should fix nacl/arm build.

TBR=minux
CC=golang-codereviews
https://golang.org/cl/145070043

10 years agodoc/go1.4.txt: add tinyallocs change
Russ Cox [Wed, 17 Sep 2014 18:50:49 +0000 (14:50 -0400)]
doc/go1.4.txt: add tinyallocs change

CC=golang-codereviews
https://golang.org/cl/145050043

10 years agoruntime: account for tiny allocs, for testing.AllocsPerRun
Russ Cox [Wed, 17 Sep 2014 18:49:32 +0000 (14:49 -0400)]
runtime: account for tiny allocs, for testing.AllocsPerRun

Fixes #8734.

LGTM=r, bradfitz, dvyukov
R=bradfitz, r, dvyukov
CC=golang-codereviews, iant, khr
https://golang.org/cl/143150043

10 years agodoc/go1.4.txt: reduced stack size
Rob Pike [Wed, 17 Sep 2014 15:39:18 +0000 (08:39 -0700)]
doc/go1.4.txt: reduced stack size

CC=golang-codereviews
https://golang.org/cl/144050043

10 years agoruntime: change minimum stack size to 2K.
Keith Randall [Wed, 17 Sep 2014 15:32:15 +0000 (08:32 -0700)]
runtime: change minimum stack size to 2K.

It will be 8K on windows because it needs 4K for the OS.
Similarly, plan9 will be 4K.

On linux/amd64, reduces size of 100,000 goroutines
from ~819MB to ~245MB.

Update #7514

LGTM=dvyukov
R=golang-codereviews, dvyukov, khr, aram
CC=golang-codereviews
https://golang.org/cl/145790043

10 years agosync: fix linux/arm build
Dave Cheney [Wed, 17 Sep 2014 05:44:42 +0000 (05:44 +0000)]
sync: fix linux/arm build

For real this time.

LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://golang.org/cl/141640043

10 years agodoc/go1.4.txt: add sync/atomic.Value
Rob Pike [Wed, 17 Sep 2014 04:49:10 +0000 (21:49 -0700)]
doc/go1.4.txt: add sync/atomic.Value

CC=golang-codereviews
https://golang.org/cl/145800043

10 years agosync/atomic: add Value
Dmitriy Vyukov [Wed, 17 Sep 2014 02:54:26 +0000 (19:54 -0700)]
sync/atomic: add Value
A Value provides an atomic load and store of a consistently typed value.
It's intended to be used with copy-on-write idiom (see the example).

Performance:
BenchmarkValueRead 50000000         21.7 ns/op
BenchmarkValueRead-2 200000000          8.63 ns/op
BenchmarkValueRead-4 300000000          4.33 ns/op

TBR=rsc
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/136710045

10 years agoliblink, sync/atomic: fix arm build
Russ Cox [Wed, 17 Sep 2014 00:53:38 +0000 (20:53 -0400)]
liblink, sync/atomic: fix arm build

The liblink code to insert the FUNCDATA for a stack map
from the Go prototype was not correct for ARM
(different data structure layout).

Also, sync/atomic was missing some Go prototypes
for ARM-specific functions.

TBR=r
CC=golang-codereviews
https://golang.org/cl/143160045

10 years agoruntime: always run semacquire on the G stack
Keith Randall [Wed, 17 Sep 2014 00:26:16 +0000 (17:26 -0700)]
runtime: always run semacquire on the G stack

semacquire might need to park the currently running G.  It can
only park if called from the G stack (because it has no way of
saving the M stack state).  So all calls to semacquire must come
from the G stack.

The three violators are GOMAXPROCS, ReadMemStats, and WriteHeapDump.
This change moves the semacquire call earlier, out of their C code
and into their Go code.

This seldom caused bugs because semacquire seldom actually had
to park the caller.  But it did happen intermittently.

Fixes #8749

LGTM=dvyukov
R=golang-codereviews, dvyukov, bradfitz
CC=golang-codereviews
https://golang.org/cl/144940043

10 years agodoc/go1.4.txt: reflect.Type.Comparable
Rob Pike [Tue, 16 Sep 2014 22:40:22 +0000 (15:40 -0700)]
doc/go1.4.txt: reflect.Type.Comparable

CC=golang-codereviews
https://golang.org/cl/138530044

10 years agocmd/go: use pkg-config include pathes in swig and don't double compile c++ files.
Ahmed Waheed Moanes [Tue, 16 Sep 2014 22:06:52 +0000 (15:06 -0700)]
cmd/go: use pkg-config include pathes in swig and don't double compile c++ files.

Fixes #8566.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/126210045

10 years agoA+C: Ahmed Waheed Moanes (individual CLA)
Ian Lance Taylor [Tue, 16 Sep 2014 22:06:23 +0000 (15:06 -0700)]
A+C: Ahmed Waheed Moanes (individual CLA)

Generated by a+c.

R=gobot
CC=golang-codereviews
https://golang.org/cl/138550043

10 years agoruntime: reenable TestStackGrowth on 32-bit systems
Russ Cox [Tue, 16 Sep 2014 21:46:25 +0000 (17:46 -0400)]
runtime: reenable TestStackGrowth on 32-bit systems

If this needs to be turned back off, it should be done
just before the '// in finalizer' comment, not at the top
of the function.

GC is more precise now than it was (the only imprecise
stuff left is some global variables), so maybe the finalizer
test will work now on 32-bit systems.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/144030043

10 years agonet/mail: allow us-ascii encoding
Russ Cox [Tue, 16 Sep 2014 21:40:33 +0000 (17:40 -0400)]
net/mail: allow us-ascii encoding

Fixes #6611.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/14990045

10 years agoreflect: add Type.Comparable
Russ Cox [Tue, 16 Sep 2014 21:40:10 +0000 (17:40 -0400)]
reflect: add Type.Comparable

Like most of the Type methods, the definition of Comparable
is what the Go spec says it is.

Fixes #7911.

LGTM=gri
R=gri, r
CC=golang-codereviews
https://golang.org/cl/144020043

10 years agoliblink: make GO_ARGS the default for functions beginning with ·
Russ Cox [Tue, 16 Sep 2014 21:39:55 +0000 (17:39 -0400)]
liblink: make GO_ARGS the default for functions beginning with ·

If there is a leading ·, assume there is a Go prototype and
attach the Go prototype information to the function.
If the function is not called from Go and does not need a
Go prototype, it can be made file-local instead (using name<>(SB)).

This fixes the current BSD build failures, by giving functions like
sync/atomic.StoreUint32 argument stack map information.

Fixes #8753.

LGTM=khr, iant
R=golang-codereviews, iant, khr, bradfitz
CC=golang-codereviews, r, rlh
https://golang.org/cl/142150043

10 years agosync: simplify TestOncePanic
Josh Bleecher Snyder [Tue, 16 Sep 2014 21:22:33 +0000 (14:22 -0700)]
sync: simplify TestOncePanic

Follow-up to CL 137350043.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/141620043

10 years agosync/once: panicking functions still marked as complete
Rob Pike [Tue, 16 Sep 2014 21:00:01 +0000 (14:00 -0700)]
sync/once: panicking functions still marked as complete

This is a corner case, and one that was even tested, but this
CL changes the behavior to say that f is "complete" even if it panics.
But don't think of it that way, think of it as sync.Once runs
the function only the first time it is called, rather than
repeatedly until a run of the function completes.

Fixes #8118.

LGTM=dvyukov
R=golang-codereviews, dvyukov
CC=golang-codereviews
https://golang.org/cl/137350043

10 years agoruntime: make it clear that Goexit cannot be recover'd.
Keith Randall [Tue, 16 Sep 2014 19:50:05 +0000 (12:50 -0700)]
runtime: make it clear that Goexit cannot be recover'd.

LGTM=r
R=r, bradfitz, khr
CC=golang-codereviews
https://golang.org/cl/136660044

10 years agoos/signal: increase timeout from 10ms to 100ms
Russ Cox [Tue, 16 Sep 2014 19:26:00 +0000 (15:26 -0400)]
os/signal: increase timeout from 10ms to 100ms

Might make test less flaky.
Fixes #8682.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/143160043

10 years agonet: make TestSelfConnect less fragile
Russ Cox [Tue, 16 Sep 2014 18:02:59 +0000 (14:02 -0400)]
net: make TestSelfConnect less fragile

We believe TestSelfConnect can accidentally connect to
something else listening on or dialing from that port.

Fixes #8680.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews, rlh
https://golang.org/cl/136700043

10 years agocmd/5g, cmd/8g: make 'out of registers' a fatal error
Russ Cox [Tue, 16 Sep 2014 17:16:43 +0000 (13:16 -0400)]
cmd/5g, cmd/8g: make 'out of registers' a fatal error

There's no point in continuing. We will only get confused.
6g already makes this fatal.

LGTM=dave, minux, iant
R=iant, dave, minux
CC=golang-codereviews
https://golang.org/cl/140660043

10 years agoruntime: fix 386 build
Russ Cox [Tue, 16 Sep 2014 15:43:35 +0000 (11:43 -0400)]
runtime: fix 386 build

mark finalizer1 as having no pointers

TBR=iant
CC=golang-codereviews
https://golang.org/cl/141570045

10 years agoruntime: remove uses of ScanConservatively
Russ Cox [Tue, 16 Sep 2014 15:09:58 +0000 (11:09 -0400)]
runtime: remove uses of ScanConservatively

Along with CLs 139610043 and 141490043,
this removes all conservative scanning during
garbage collection, except _cgo_allocate,
which is SWIG-only.

LGTM=rlh, khr
R=golang-codereviews, dvyukov, rlh, khr
CC=golang-codereviews, iant
https://golang.org/cl/144860043

10 years agoruntime: remove untyped allocation of ParFor
Russ Cox [Tue, 16 Sep 2014 15:03:11 +0000 (11:03 -0400)]
runtime: remove untyped allocation of ParFor

Now it's two allocations. I don't see much downside to that,
since the two pieces were in different cache lines anyway.

Rename 'conservative' to 'cgo_conservative_type' and make
clear that _cgo_allocate is the only allowed user.

This depends on CL 141490043, which removes the other
use of conservative (in defer).

LGTM=dvyukov, iant
R=khr, dvyukov, iant
CC=golang-codereviews, rlh
https://golang.org/cl/139610043

10 years agoruntime: use traceback to traverse defer structures
Russ Cox [Tue, 16 Sep 2014 14:36:38 +0000 (10:36 -0400)]
runtime: use traceback to traverse defer structures

This makes the GC and the stack copying agree about how
to interpret the defer structures. Previously, only the stack
copying treated them precisely.
This removes an untyped memory allocation and fixes
at least three copystack bugs.

To make sure the GC can find the deferred argument
frame until it has been copied, keep a Defer on the defer list
during its execution.

In addition to making it possible to remove the untyped
memory allocation, keeping the Defer on the list fixes
two races between copystack and execution of defers
(in both gopanic and Goexit). The problem is that once
the defer has been taken off the list, a stack copy that
happens before the deferred arguments have been copied
back to the stack will not update the arguments correctly.
The new tests TestDeferPtrsPanic and TestDeferPtrsGoexit
(variations on the existing TestDeferPtrs) pass now but
failed before this CL.

In addition to those fixes, keeping the Defer on the list
helps correct a dangling pointer error during copystack.
The traceback routines walk the Defer chain to provide
information about where a panic may resume execution.
When the executing Defer was not on the Defer chain
but instead linked from the Panic chain, the traceback
had to walk the Panic chain too. But Panic structs are
on the stack and being updated by copystack.
Traceback's use of the Panic chain while copystack is
updating those structs means that it can follow an
updated pointer and find itself reading from the new stack.
The new stack is usually all zeros, so it sees an incorrect
early end to the chain. The new TestPanicUseStack makes
this happen at tip and dies when adjustdefers finds an
unexpected argp. The new StackCopyPoison mode
causes an earlier bad dereference instead.
By keeping the Defer on the list, traceback can avoid
walking the Panic chain at all,  making it okay for copystack
to update the Panics.

We'd have the same problem for any Defers on the stack.
There was only one: gopanic's dabort. Since we are not
taking the executing Defer off the chain, we can use it
to do what dabort was doing, and then there are no
Defers on the stack ever, so it is okay for traceback to use
the Defer chain even while copystack is executing:
copystack cannot modify the Defer chain.

LGTM=khr
R=khr
CC=dvyukov, golang-codereviews, iant, rlh
https://golang.org/cl/141490043

10 years agoruntime: remove duplicated Go constants
Russ Cox [Tue, 16 Sep 2014 14:22:15 +0000 (10:22 -0400)]
runtime: remove duplicated Go constants

The C header files are the single point of truth:
every C enum constant Foo is available to Go as _Foo.
Remove or redirect duplicate Go declarations so they
cannot be out of sync.

Eventually we will need to put constants in Go, but for now having
them be out of sync with C is too risky. These predate the build
support for auto-generating Go constants from the C definitions.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/141510043

10 years agocmd/gc: say 'non-constant array bound' instead of 'invalid array bound'
Russ Cox [Tue, 16 Sep 2014 14:21:54 +0000 (10:21 -0400)]
cmd/gc: say 'non-constant array bound' instead of 'invalid array bound'

Fixes #8196.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/141510044

10 years agoio: clarify Reader returning 0, nil
Russ Cox [Tue, 16 Sep 2014 14:01:28 +0000 (10:01 -0400)]
io: clarify Reader returning 0, nil

Fixes #8317.

LGTM=bradfitz
R=bradfitz, iant, r
CC=golang-codereviews
https://golang.org/cl/143100043

10 years agocmd/gc: make runtime escape an error, not a fatal error
Russ Cox [Tue, 16 Sep 2014 13:58:17 +0000 (09:58 -0400)]
cmd/gc: make runtime escape an error, not a fatal error

It is more useful to report all the errors instead of just the first.

LGTM=dave, khr
R=khr, dave
CC=golang-codereviews
https://golang.org/cl/143940043

10 years agocmd/ld: document that -X overwrites initialized variables
Josh Bleecher Snyder [Tue, 16 Sep 2014 01:16:45 +0000 (18:16 -0700)]
cmd/ld: document that -X overwrites initialized variables

Fixes #7626.

LGTM=iant
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/144870045

10 years agocmd/api: internal debugging supprt
Robert Griesemer [Mon, 15 Sep 2014 23:40:43 +0000 (16:40 -0700)]
cmd/api: internal debugging supprt

Document that the package cache has
an issue (8425) to speed up future
debugging.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/143980043

10 years agoruntime: test Goexit/defer iteraction.
Keith Randall [Mon, 15 Sep 2014 22:09:17 +0000 (15:09 -0700)]
runtime: test Goexit/defer iteraction.

Make sure Goexit runs defers.
Make sure recover() during a Goexit defer returns nil.

LGTM=dvyukov, bradfitz
R=golang-codereviews, dvyukov, bradfitz, khr
CC=golang-codereviews
https://golang.org/cl/140650043

10 years agoruntime: try harder to get different iteration orders.
Keith Randall [Mon, 15 Sep 2014 19:30:57 +0000 (12:30 -0700)]
runtime: try harder to get different iteration orders.

Fixes #8736.

LGTM=iant, josharian
R=golang-codereviews, iant, josharian
CC=golang-codereviews
https://golang.org/cl/144910044

10 years agotest: make maplinear iterdelete test less flaky
Josh Bleecher Snyder [Mon, 15 Sep 2014 17:56:37 +0000 (10:56 -0700)]
test: make maplinear iterdelete test less flaky

iterdelete's run time varies; occasionally we get unlucky. To reduce spurious failures, average away some of the variation.

On my machine, 8 of 5000 runs (0.15%) failed before this CL. After this CL, there were no failures after 35,000 runs.

I confirmed that this adjusted test still fails before CL 141270043.

LGTM=khr
R=khr
CC=bradfitz, golang-codereviews
https://golang.org/cl/140610043

10 years agocmd/gc: don't walk static nodes generated by anylit.
Rémy Oudompheng [Mon, 15 Sep 2014 16:31:47 +0000 (18:31 +0200)]
cmd/gc: don't walk static nodes generated by anylit.

During anylit run, nodes such as SLICEARR(statictmp, [:])
may be generated and are expected to be found unchanged by
gen_as_init.

In some walks (in particular walkselect), the statement
may be walked again and lowered to its usual form, leading to a
crash.

Fixes #8017.
Fixes #8024.
Fixes #8058.

LGTM=rsc
R=golang-codereviews, dvyukov, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/112080043

10 years agocmd/gc: generate type alg after calling dowidth.
Rémy Oudompheng [Mon, 15 Sep 2014 16:24:16 +0000 (18:24 +0200)]
cmd/gc: generate type alg after calling dowidth.

Previously it might happen before calling dowidth and
result in a compiler crash.

Fixes #8060.

LGTM=dvyukov, rsc
R=golang-codereviews, dvyukov, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/110980044

10 years agonet/http: don't call FileSystem.Open with unclean index.html path
Brad Fitzpatrick [Mon, 15 Sep 2014 11:14:33 +0000 (07:14 -0400)]
net/http: don't call FileSystem.Open with unclean index.html path

Fixes #8722

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/142090043

10 years agoruntime: fix parameter checking in syscall.NewCallback
Alex Brainman [Mon, 15 Sep 2014 02:58:28 +0000 (12:58 +1000)]
runtime: fix parameter checking in syscall.NewCallback

I have made mistake while converting it to Go (CL 132820043).
Added test as penance for my sin.

LGTM=rsc
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/136560043

10 years agosyscall: add GO_ARGS to Go-called assembly
Russ Cox [Mon, 15 Sep 2014 02:27:03 +0000 (22:27 -0400)]
syscall: add GO_ARGS to Go-called assembly

Fixes sporadic linux/386 build failure (untyped args)
and probably some others we haven't observed yet.

Fixes #8727.

TBR=iant
R=golang-codereviews
CC=bradfitz, golang-codereviews, iant, khr, r
https://golang.org/cl/143930043

10 years agoruntime: fix solaris build, part 2
Russ Cox [Mon, 15 Sep 2014 02:24:29 +0000 (22:24 -0400)]
runtime: fix solaris build, part 2

This file was already assigned to another CL
so it didn't make it into the build fix CL. Sigh.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/144850043

10 years agoruntime: fix solaris build
Russ Cox [Mon, 15 Sep 2014 02:20:01 +0000 (22:20 -0400)]
runtime: fix solaris build

CL 144830043 changed LibCall for Windows.
I didn't realize Solaris used it too.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/142100043

10 years agoruntime: convert syscall_windows.c to Go
Russ Cox [Mon, 15 Sep 2014 01:25:44 +0000 (21:25 -0400)]
runtime: convert syscall_windows.c to Go

This is necessary because syscall.Syscall blocks, and the
garbage collector needs to be able to scan that frame while
it is blocked, and C frames have no garbage collection
information.

Windows builders are broken now due to this problem:
http://build.golang.org/log/152ca9a4be6783d3a8bf6e2f5b9fc265089728b6

LGTM=alex.brainman
R=alex.brainman
CC=golang-codereviews
https://golang.org/cl/144830043

10 years agoimage/jpeg: reject invalid Ta and Td values.
Nigel Tao [Sun, 14 Sep 2014 22:41:59 +0000 (08:41 +1000)]
image/jpeg: reject invalid Ta and Td values.

Fixes #8693.

LGTM=crawshaw
R=crawshaw
CC=golang-codereviews
https://golang.org/cl/141470043

10 years agoruntime: fix traceback of trap on ARM
Russ Cox [Sun, 14 Sep 2014 20:39:08 +0000 (20:39 +0000)]
runtime: fix traceback of trap on ARM

The merged traceback was wrong for LR machines,
because traceback didn't pass lr to gentraceback.
Now that we have a test looking at traceback output
for a trap (the test of runtime.Breakpoint),
we caught this.

While we're here, fix a 'set and not used' warning.

Fixes arm build.

TBR=r
R=r
CC=golang-codereviews
https://golang.org/cl/143040043

10 years agoruntime: mark asmcgocall<>(SB) as having no arguments
Russ Cox [Sun, 14 Sep 2014 17:57:28 +0000 (13:57 -0400)]
runtime: mark asmcgocall<>(SB) as having no arguments

It doesn't.
Fixes 386 build.

While we're here, mark runtime.asmcgocall as GO_ARGS,
so that it will work with stack copying. I don't think anything
that uses it can lead to a stack copy, but better safe than sorry.
Certainly the runtime.asmcgocall_errno variant needs
(and already has) GO_ARGS.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/138400043

10 years agocmd/8g: remove unused variable (fix build)
Robert Griesemer [Fri, 12 Sep 2014 23:35:40 +0000 (16:35 -0700)]
cmd/8g: remove unused variable (fix build)

http://build.golang.org/log/0434a945e3351eedaf56aa824d2bfe9c0d5e6735

LGTM=dave
R=bradfitz, dave
CC=golang-codereviews
https://golang.org/cl/144800043

10 years agoruntime: test iteration order of sparse maps
Josh Bleecher Snyder [Fri, 12 Sep 2014 23:16:09 +0000 (16:16 -0700)]
runtime: test iteration order of sparse maps

The behavior was fixed in CL 141270043. Add a test.

Fixes #8410.

LGTM=khr
R=khr, remyoudompheng
CC=golang-codereviews
https://golang.org/cl/137560044

10 years agocmd/gc: fix racewalk after writebarrier change
Dmitriy Vyukov [Fri, 12 Sep 2014 22:05:41 +0000 (15:05 -0700)]
cmd/gc: fix racewalk after writebarrier change
Instrument dst argument of writebarrier calls.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/139560045

10 years agoruntime: remove a few untyped allocations
Russ Cox [Fri, 12 Sep 2014 20:12:39 +0000 (16:12 -0400)]
runtime: remove a few untyped allocations

LGTM=iant, khr, rlh
R=khr, iant, bradfitz, rlh
CC=dvyukov, golang-codereviews
https://golang.org/cl/142030044

10 years agogo/printer: don't reduce nesting depth twice if parentheses are present around an...
Robert Griesemer [Fri, 12 Sep 2014 18:18:12 +0000 (11:18 -0700)]
go/printer: don't reduce nesting depth twice if parentheses are present around an expr

No impact on formatting on our repos.

Fixes #8021.

LGTM=adonovan
R=adonovan, dvyukov
CC=golang-codereviews
https://golang.org/cl/142020043

10 years agoruntime: fix typo in comment
Ian Lance Taylor [Fri, 12 Sep 2014 14:52:56 +0000 (07:52 -0700)]
runtime: fix typo in comment

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/140590043

10 years agocmd/cc, cmd/gc: stop generating 'argsize' PCDATA
Russ Cox [Fri, 12 Sep 2014 11:51:00 +0000 (07:51 -0400)]
cmd/cc, cmd/gc: stop generating 'argsize' PCDATA

The argsize PCDATA was specifying the number of
bytes passed to a function call, so that if the function
did not specify its argument count, the garbage collector
could use the call site information to scan those bytes
conservatively. We don't do that anymore, so stop
generating the information.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/139530043

10 years agoruntime: stop scanning stack frames/args conservatively
Russ Cox [Fri, 12 Sep 2014 11:46:11 +0000 (07:46 -0400)]
runtime: stop scanning stack frames/args conservatively

The goal here is to commit fully to having precise information
about stack frames. If we need information we don't have,
crash instead of assuming we should scan conservatively.

Since the stack copying assumes fully precise information,
any crashes during garbage collection that are introduced by
this CL are crashes that could have happened during stack
copying instead. Those are harder to find because stacks are
copied much less often than the garbage collector is invoked.

In service of that goal, remove ARGSIZE macros from
asm_*.s, change switchtoM to have no arguments
(it doesn't have any live arguments), and add
args and locals information to some frames that
can call back into Go.

LGTM=khr
R=khr, rlh
CC=golang-codereviews
https://golang.org/cl/137540043

10 years agoruntime: tell the truth about BitVector type
Russ Cox [Fri, 12 Sep 2014 11:36:23 +0000 (07:36 -0400)]
runtime: tell the truth about BitVector type

Dmitriy changed all the execution to interpret the BitVector
as an array of bytes. Update the declaration and generation
of the bitmaps to match, to avoid problems on big-endian
machines.

LGTM=khr
R=khr
CC=dvyukov, golang-codereviews
https://golang.org/cl/140570044

10 years agoruntime: look up arg stackmap for makeFuncStub/methodValueStub during traceback
Russ Cox [Fri, 12 Sep 2014 11:29:19 +0000 (07:29 -0400)]
runtime: look up arg stackmap for makeFuncStub/methodValueStub during traceback

makeFuncStub and methodValueStub are used by reflect as
generic function implementations. Each call might have
different arguments. Extract those arguments from the
closure data instead of assuming it is the same each time.

Because the argument map is now being extracted from the
function itself, we don't need the special cases in reflect.Call
anymore, so delete those.

Fixes an occasional crash seen when stack copying does
not update makeFuncStub's arguments correctly.

Will also help make it safe to require stack maps in the
garbage collector.

Derived from CL 142000044 by khr.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/143890044

10 years agoruntime: save correct pid for new m's on plan9/amd64
Anthony Martin [Fri, 12 Sep 2014 08:21:51 +0000 (01:21 -0700)]
runtime: save correct pid for new m's on plan9/amd64

The pid field in the Tos structure is a 32-bit value.
Loading a 64-bit word also brings in the next field
which is used for the profiling clock.

LGTM=0intro, aram
R=rsc, 0intro, aram
CC=golang-codereviews, mischief
https://golang.org/cl/139560044

10 years agosyscall: add #include "funcdata.h" to files modified in last CL
Russ Cox [Fri, 12 Sep 2014 04:55:24 +0000 (00:55 -0400)]
syscall: add #include "funcdata.h" to files modified in last CL

That's what defines GO_ARGS.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/141460043

10 years agosyscall: make func Syscall use pointer maps from Go prototypes
Russ Cox [Fri, 12 Sep 2014 04:23:03 +0000 (00:23 -0400)]
syscall: make func Syscall use pointer maps from Go prototypes

Before, Syscall and friends were having their arguments
treated conservatively. Now they will use the Go prototype,
which will mean the arguments are not considered pointers
at all.

This is safe because of CL 139360044.

The fact that all these non-Solaris systems were using
conservative scanning of the Syscall arguments is why
the failure that prompted CL 139360044 was only
observed on Solaris, which does something completely different.
If we'd done this earlier, we'd have seen the Solaris
failure in more places.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/144730043

10 years agocmd/gc: turn Go prototypes into ptr liveness maps for assembly functions
Russ Cox [Fri, 12 Sep 2014 04:18:20 +0000 (00:18 -0400)]
cmd/gc: turn Go prototypes into ptr liveness maps for assembly functions

The goal here is to allow assembly functions to appear in the middle
of a Go stack (having called other code) and still record enough information
about their pointers so that stack copying and garbage collection can handle
them precisely. Today, these frames are handled only conservatively.

If you write

        func myfunc(x *float64) (y *int)

(with no body, an 'extern' declaration), then the Go compiler now emits
a liveness bitmap for use from the assembly definition of myfunc.
The bitmap symbol is myfunc.args_stackmap and it contains two bitmaps.
The first bitmap, in effect at function entry, marks all inputs as live.
The second bitmap, not in effect at function entry, marks the outputs
live as well.

In funcdata.h, define new assembly macros:

GO_ARGS opts in to using the Go compiler-generated liveness bitmap
for the current function.

GO_RESULTS_INITIALIZED indicates that the results have been initialized
and need to be kept live for the remainder of the function; it causes a
switch to the second generated bitmap for the assembly code that follows.

NO_LOCAL_POINTERS indicates that there are no pointers in the
local variables being stored in the function's stack frame.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/137520043

10 years agoruntime: fix cgo to handle the case where the G stack is copied.
Keith Randall [Fri, 12 Sep 2014 03:36:23 +0000 (20:36 -0700)]
runtime: fix cgo to handle the case where the G stack is copied.

Tests will come in a separate CL after the funcdata stuff is resolved.

Update #8696

LGTM=iant, rsc
R=rsc, iant
CC=golang-codereviews
https://golang.org/cl/138330045

10 years agosyscall: SysProcAttr job control changes
Michael MacInnis [Fri, 12 Sep 2014 01:39:51 +0000 (18:39 -0700)]
syscall: SysProcAttr job control changes

Making the child's process group the foreground process group and
placing the child in a specific process group involves co-ordination
between the parent and child that must be done post-fork but pre-exec.

LGTM=iant
R=golang-codereviews, gobot, iant, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/131750044

10 years agoA+C: Michael MacInnis (individual CLA)
Ian Lance Taylor [Fri, 12 Sep 2014 01:35:25 +0000 (18:35 -0700)]
A+C: Michael MacInnis (individual CLA)

Generated by a+c.

R=gobot
CC=golang-codereviews
https://golang.org/cl/140570043

10 years agoruntime: make gostringnocopy update maxstring
Keith Randall [Thu, 11 Sep 2014 23:53:34 +0000 (16:53 -0700)]
runtime: make gostringnocopy update maxstring

Fixes #8706

LGTM=josharian
R=josharian
CC=golang-codereviews
https://golang.org/cl/143880043

10 years agodoc: link directly to https://golang.org/dl/
Matthew Dempsky [Thu, 11 Sep 2014 23:15:58 +0000 (09:15 +1000)]
doc: link directly to https://golang.org/dl/

Fixes #8705.

LGTM=adg
R=golang-codereviews, bradfitz, adg
CC=golang-codereviews
https://golang.org/cl/142890044

10 years agoruntime: get rid of copyable check - all G frames are copyable.
Keith Randall [Thu, 11 Sep 2014 20:46:58 +0000 (13:46 -0700)]
runtime: get rid of copyable check - all G frames are copyable.

Just go ahead and do it, if something is wrong we'll throw.

Also rip out cc-generated arg ptr maps, they are useless now.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/133690045

10 years agoruntime: make Gosched nosplit
Russ Cox [Thu, 11 Sep 2014 20:33:01 +0000 (16:33 -0400)]
runtime: make Gosched nosplit

Replacing gosched with Gosched broke some builds because
some of the call sites are at times when the stack cannot be grown.

TBR=khr
CC=golang-codereviews
https://golang.org/cl/142000043

10 years agoruntime: move gosched to Go, to add stack frame information
Russ Cox [Thu, 11 Sep 2014 20:22:21 +0000 (16:22 -0400)]
runtime: move gosched to Go, to add stack frame information

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/134520044

10 years agogo/printer, gofmt: don't align map entries for irregular inputs
Robert Griesemer [Thu, 11 Sep 2014 19:57:51 +0000 (12:57 -0700)]
go/printer, gofmt: don't align map entries for irregular inputs

Details: Until now, when we saw a key:value pair that fit onto
a single line, we assumed that it should be formatted with a
vtab after the ':' for alignment of its value. This leads to
odd behavior if there are more than one such pair on a line.
This CL changes the behavior such that alignment is only used
for the first pair on a line. This preserves existing behavior
(in the std lib we have composite literals where the last line
contains multiple entries and the first entry's value is aligned
with the values on previous lines), and resolves this issue.

No impact on formatting of std lib, go.tools, go.exp, go.net.

Fixes #8685.

LGTM=adonovan
R=adonovan
CC=golang-codereviews
https://golang.org/cl/139430043

10 years agotest: return errors earlier in run.go
Josh Bleecher Snyder [Thu, 11 Sep 2014 19:47:17 +0000 (12:47 -0700)]
test: return errors earlier in run.go

Fixes #8184.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/137510043

10 years agocmd/gc: emit write barriers
Russ Cox [Thu, 11 Sep 2014 16:17:45 +0000 (12:17 -0400)]
cmd/gc: emit write barriers

A write *p = x that needs a write barrier (not all do)
now turns into runtime.writebarrierptr(p, x)
or one of the other variants.

The write barrier implementations are trivial.
The goal here is to emit the calls in the correct places
and to incur the cost of those function calls in the Go 1.4 cycle.

Performance on the Go 1 benchmark suite below.
Remember, the goal is to slow things down (and be correct).

We will look into optimizations in separate CLs, as part of
the process of comparing Go 1.3 against tip in order to make
sure Go 1.4 runs at least as fast as Go 1.3.

benchmark                          old ns/op      new ns/op      delta
BenchmarkBinaryTree17              3118336716     3452876110     +10.73%
BenchmarkFannkuch11                3184497677     3211552284     +0.85%
BenchmarkFmtFprintfEmpty           89.9           107            +19.02%
BenchmarkFmtFprintfString          236            287            +21.61%
BenchmarkFmtFprintfInt             246            278            +13.01%
BenchmarkFmtFprintfIntInt          395            458            +15.95%
BenchmarkFmtFprintfPrefixedInt     343            378            +10.20%
BenchmarkFmtFprintfFloat           477            525            +10.06%
BenchmarkFmtManyArgs               1446           1707           +18.05%
BenchmarkGobDecode                 14398047       14685958       +2.00%
BenchmarkGobEncode                 12557718       12947104       +3.10%
BenchmarkGzip                      453462345      472413285      +4.18%
BenchmarkGunzip                    114226016      115127398      +0.79%
BenchmarkHTTPClientServer          114689         112122         -2.24%
BenchmarkJSONEncode                24914536       26135942       +4.90%
BenchmarkJSONDecode                86832877       103620289      +19.33%
BenchmarkMandelbrot200             4833452        4898780        +1.35%
BenchmarkGoParse                   4317976        4835474        +11.98%
BenchmarkRegexpMatchEasy0_32       150            166            +10.67%
BenchmarkRegexpMatchEasy0_1K       393            402            +2.29%
BenchmarkRegexpMatchEasy1_32       125            142            +13.60%
BenchmarkRegexpMatchEasy1_1K       1010           1236           +22.38%
BenchmarkRegexpMatchMedium_32      232            301            +29.74%
BenchmarkRegexpMatchMedium_1K      76963          102721         +33.47%
BenchmarkRegexpMatchHard_32        3833           5463           +42.53%
BenchmarkRegexpMatchHard_1K        119668         161614         +35.05%
BenchmarkRevcomp                   763449047      706768534      -7.42%
BenchmarkTemplate                  124954724      134834549      +7.91%
BenchmarkTimeParse                 517            511            -1.16%
BenchmarkTimeFormat                501            514            +2.59%

benchmark                         old MB/s     new MB/s     speedup
BenchmarkGobDecode                53.31        52.26        0.98x
BenchmarkGobEncode                61.12        59.28        0.97x
BenchmarkGzip                     42.79        41.08        0.96x
BenchmarkGunzip                   169.88       168.55       0.99x
BenchmarkJSONEncode               77.89        74.25        0.95x
BenchmarkJSONDecode               22.35        18.73        0.84x
BenchmarkGoParse                  13.41        11.98        0.89x
BenchmarkRegexpMatchEasy0_32      213.30       191.72       0.90x
BenchmarkRegexpMatchEasy0_1K      2603.92      2542.74      0.98x
BenchmarkRegexpMatchEasy1_32      254.00       224.93       0.89x
BenchmarkRegexpMatchEasy1_1K      1013.53      827.98       0.82x
BenchmarkRegexpMatchMedium_32     4.30         3.31         0.77x
BenchmarkRegexpMatchMedium_1K     13.30        9.97         0.75x
BenchmarkRegexpMatchHard_32       8.35         5.86         0.70x
BenchmarkRegexpMatchHard_1K       8.56         6.34         0.74x
BenchmarkRevcomp                  332.92       359.62       1.08x
BenchmarkTemplate                 15.53        14.39        0.93x

LGTM=rlh
R=rlh
CC=dvyukov, golang-codereviews, iant, khr, r
https://golang.org/cl/136380043

10 years agoruntime: allow crash from gsignal stack
Russ Cox [Thu, 11 Sep 2014 16:08:30 +0000 (12:08 -0400)]
runtime: allow crash from gsignal stack

The uses of onM in dopanic/startpanic are okay even from the signal stack.

Fixes #8666.

LGTM=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/134710043

10 years agonet: fix inconsistent behavior across platforms in SetKeepAlivePeriod
Mikio Hara [Thu, 11 Sep 2014 08:56:58 +0000 (17:56 +0900)]
net: fix inconsistent behavior across platforms in SetKeepAlivePeriod

The previous implementation used per-socket TCP keepalive options
wrong. For example, it used another level socket option to control
TCP and it didn't use TCP_KEEPINTVL option when possible.

Fixes #8683.
Fixes #8701.
Update #8679

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/136480043

10 years agoruntime: add timing test for iterate/delete map idiom.
Keith Randall [Thu, 11 Sep 2014 05:54:07 +0000 (22:54 -0700)]
runtime: add timing test for iterate/delete map idiom.

LGTM=bradfitz, iant
R=iant, bradfitz
CC=golang-codereviews
https://golang.org/cl/140510043

10 years agoreflect: use runtime's memmove instead of its own
Keith Randall [Wed, 10 Sep 2014 19:37:28 +0000 (12:37 -0700)]
reflect: use runtime's memmove instead of its own

They will both need write barriers at some point.
But until then, no reason why we shouldn't share.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/141330043

10 years agoruntime: stop plan9/amd64 build from crashing
Anthony Martin [Wed, 10 Sep 2014 13:25:05 +0000 (06:25 -0700)]
runtime: stop plan9/amd64 build from crashing

LGTM=iant
R=rsc, 0intro, alex.brainman, iant
CC=golang-codereviews
https://golang.org/cl/140460044

10 years agoruntime: cleanup openbsd semasleep implementation
Matthew Dempsky [Wed, 10 Sep 2014 00:41:48 +0000 (17:41 -0700)]
runtime: cleanup openbsd semasleep implementation

The previous implementation had several subtle issues.  It's not
clear if any of these could actually be causing the flakiness
problems on openbsd/386, but fixing them should only help.

1. thrsleep() is implemented internally as unlock, then test *abort
(if abort != nil), then tsleep().  Under the current code, that makes
it theoretically possible that semasleep()/thrsleep() could release
waitsemalock, then a racing semawakeup() could acquire the lock,
increment waitsemacount, and call thrwakeup()/wakeup() before
thrsleep() reaches tsleep().  (In practice, OpenBSD's big kernel lock
seems unlikely to let this actually happen.)

The proper way to avoid this is to pass &waitsemacount as the abort
pointer to thrsleep so thrsleep knows to re-check it before going to
sleep, and to wakeup if it's non-zero.  Then we avoid any races.
(I actually suspect openbsd's sema{sleep,wakeup}() could be further
simplified using cas/xadd instead of locks, but I don't want to be
more intrusive than necessary so late in the 1.4 release cycle.)

2. semasleep() takes a relative sleep duration, but thrsleep() needs
an absolute sleep deadline.  Instead of recomputing the deadline each
iteration, compute it once up front and use (*Timespec)(nil) to signify
no deadline.  Ensures we retry properly if there's a spurious wakeup.

3. Instead of assuming if thrsleep() woke up and waitsemacount wasn't
available that we must have hit the deadline, check that the system
call returned EWOULDBLOCK.

4. Instead of assuming that 64-bit systems are little-endian, compute
timediv() using a temporary int32 nsec and then assign it to tv_nsec.

LGTM=iant
R=jsing, iant
CC=golang-codereviews
https://golang.org/cl/137960043

10 years agoruntime: call rfork on scheduler stack on Plan 9
Anthony Martin [Wed, 10 Sep 2014 00:19:01 +0000 (17:19 -0700)]
runtime: call rfork on scheduler stack on Plan 9

A race exists between the parent and child processes after a fork.
The child needs to access the new M pointer passed as an argument
but the parent may have already returned and clobbered it.

Previously, we avoided this by saving the necessary data into
registers before the rfork system call but this isn't guaranteed
to work because Plan 9 makes no promises about the register state
after a system call. Only the 386 kernel seems to save them.
For amd64 and arm, this method won't work.

We eliminate the race by allocating stack space for the scheduler
goroutines (g0) in the per-process copy-on-write stack segment and
by only calling rfork on the scheduler stack.

LGTM=aram, 0intro, rsc
R=aram, 0intro, mischief, rsc
CC=golang-codereviews
https://golang.org/cl/110680044

10 years agoruntime: more cleanups
Keith Randall [Tue, 9 Sep 2014 21:32:53 +0000 (14:32 -0700)]
runtime: more cleanups

Move timenow thunk into time.s
Move declarations for generic c/asm services into stubs.go

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/137360043

10 years agoruntime: map iterators: always use intrabucket randomess
Keith Randall [Tue, 9 Sep 2014 21:22:58 +0000 (14:22 -0700)]
runtime: map iterators: always use intrabucket randomess

Fixes #8688

LGTM=rsc
R=golang-codereviews, bradfitz, rsc, khr
CC=golang-codereviews
https://golang.org/cl/135660043

10 years agoruntime: fix plan9/amd64 build?
Russ Cox [Tue, 9 Sep 2014 21:16:31 +0000 (17:16 -0400)]
runtime: fix plan9/amd64 build?

The only thing I can see that is really Plan 9-specific
is that the stack pointer used for signal handling used
to have more mapped memory above it.
Specifically it used to have at most 88 bytes (StackTop),
so change the allocation of a 40-byte frame to a 128-byte frame.

No idea if this will work, but worth a try.

Note that "fix" here means get it back to timing out
instead of crashing.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/142840043

10 years agoruntime: fix windows/386 build
Russ Cox [Tue, 9 Sep 2014 21:12:05 +0000 (17:12 -0400)]
runtime: fix windows/386 build

The difference between the old and the new (from earlier) code
is that we set stackguard = stack.lo + StackGuard, while the old
code set stackguard = stack.lo. That 512 bytes appears to be
the difference between the profileloop function running and not running.

We don't know how big the system stack is, but it is likely MUCH bigger than 4k.
Give Go/C 8k.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/140440044

10 years agoruntime: avoid read overrun in heapdump
Russ Cox [Tue, 9 Sep 2014 19:38:55 +0000 (15:38 -0400)]
runtime: avoid read overrun in heapdump

Start the stack a few words below the actual top, so that
if something tries to read goexit's caller PC from the stack,
it won't fault on a bad memory address.
Today, heapdump does that.
Maybe tomorrow, traceback or something else will do that.
Make it not a bug.

TBR=khr
R=khr
CC=golang-codereviews
https://golang.org/cl/136450043

10 years agotesting: read coverage counters atomically
Rob Pike [Tue, 9 Sep 2014 19:31:07 +0000 (12:31 -0700)]
testing: read coverage counters atomically
For -mode=atomic, we need to read the counters
using an atomic load to avoid a race. Not worth worrying
about when -mode=atomic is set during generation
of the profile, so we use atomic loads always.

Fixes #8630.

LGTM=rsc
R=dvyukov, rsc
CC=golang-codereviews
https://golang.org/cl/141800043

10 years agofmt: fix allocation test
Rob Pike [Tue, 9 Sep 2014 18:45:46 +0000 (11:45 -0700)]
fmt: fix allocation test
With new interface allocation rules, the old counts were wrong and
so was the commentary.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/142760044

10 years agostrconv: fix documentation for CanBackquote.
Rob Pike [Tue, 9 Sep 2014 18:45:36 +0000 (11:45 -0700)]
strconv: fix documentation for CanBackquote.
Space is not a control character.

Fixes #8571.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/137380043