1
0
mirror of https://github.com/golang/go synced 2024-10-02 14:38:33 -06:00
Commit Graph

1166 Commits

Author SHA1 Message Date
Russ Cox
3d2dfc5a7b runtime: add cgocallback_gofunc that can call Go func value
For now, all the callbacks from C use top-level Go functions,
so they use the equivalent C function pointer, and will continue
to do so. But perhaps some day this will be useful for calling
a Go func value (at least if the type is already known).

More importantly, the Windows callback code needs to be able
to use cgocallback_gofunc to call a Go func value.
Should fix the Windows build.

R=ken2
CC=golang-dev
https://golang.org/cl/7388049
2013-02-22 16:08:56 -05:00
Russ Cox
a48ed66447 runtime: delete old closure code
Step 4 of http://golang.org/s/go11func.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7393049
2013-02-22 15:24:29 -05:00
Russ Cox
9f647288ef cmd/gc: avoid runtime code generation for closures
Change ARM context register to R7, to get out of the way
of the register allocator during the compilation of the
prologue statements (it wants to use R0 as a temporary).

Step 2 of http://golang.org/s/go11func.

R=ken2
CC=golang-dev
https://golang.org/cl/7369048
2013-02-22 14:25:50 -05:00
Russ Cox
ec892be1af runtime: preserve DX during racefuncenter
R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/7382049
2013-02-22 13:06:43 -05:00
Russ Cox
0ba5f75513 runtime: avoid closure in parfor test
R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/7395051
2013-02-22 12:11:12 -05:00
Russ Cox
6066fdcf38 cmd/6g, cmd/8g: switch to DX for indirect call block
runtime: add context argument to gogocall

Too many other things use AX, and at least one
(stack zeroing) cannot be moved onto a different
register. Use the less special DX instead.

Preparation for step 2 of http://golang.org/s/go11func.
Nothing interesting here, just split out so that we can
see it's correct before moving on.

R=ken2
CC=golang-dev
https://golang.org/cl/7395050
2013-02-22 10:47:54 -05:00
Alex Brainman
6ec551887a runtime: windows callback code to match new func value representation
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7393048
2013-02-22 12:21:42 +11:00
Russ Cox
1903ad7189 cmd/gc, reflect, runtime: switch to indirect func value representation
Step 1 of http://golang.org/s/go11func.

R=golang-dev, r, daniel.morsing, remyoudompheng
CC=golang-dev
https://golang.org/cl/7393045
2013-02-21 17:01:13 -05:00
Carl Shapiro
f466617a62 cmd/5g, cmd/5l, cmd/6l, cmd/8l, cmd/gc, cmd/ld, runtime: accurate args and locals information
Previously, the func structure contained an inaccurate value for
the args member and a 0 value for the locals member.

This change populates the func structure with args and locals
values computed by the compiler.  The number of args was
already available in the ATEXT instruction.  The number of
locals is now passed through in the new ALOCALS instruction.

This change also switches the unit of args and locals to be
bytes, just like the frame member, instead of 32-bit words.

R=golang-dev, bradfitz, cshapiro, dave, rsc
CC=golang-dev
https://golang.org/cl/7399045
2013-02-21 12:52:26 -08:00
Russ Cox
5833c96b0a runtime: better error from TestGcSys when gc is disabled
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7390047
2013-02-21 13:30:31 -05:00
Dmitriy Vyukov
94fab3cad3 runtime: fix heap corruption
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7397049
2013-02-21 21:59:46 +04:00
Dmitriy Vyukov
a0955a2aa2 runtime: split minit() to mpreinit() and minit()
mpreinit() is called on the parent thread and with mcache (can allocate memory),
minit() is called on the child thread and can not allocate memory.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7389043
2013-02-21 16:24:38 +04:00
Russ Cox
6c976393ae runtime: allow cgo callbacks on non-Go threads
Fixes #4435.

R=golang-dev, iant, alex.brainman, minux.ma, dvyukov
CC=golang-dev
https://golang.org/cl/7304104
2013-02-20 17:48:23 -05:00
Dmitriy Vyukov
1e063eea38 runtime: prepare for M's running w/o mcache
Can not happen ATM. In preparation for the new scheduler.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7388043
2013-02-20 21:17:56 +04:00
Dmitriy Vyukov
e25f19a638 runtime: introduce entersyscallblock()
In preparation for the new scheduler.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7386044
2013-02-20 20:21:45 +04:00
Dmitriy Vyukov
e5b0bcebdb runtime/debug: deflake TestFreeOSMemory
This is followup to https://golang.org/cl/7319050/

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7379043
2013-02-20 12:34:16 +04:00
Dmitriy Vyukov
06a488fa97 runtime: fix deadlock detector false negative
Fixes #4819.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7322086
2013-02-20 12:15:02 +04:00
Dmitriy Vyukov
a92e11a256 runtime: ensure forward progress of runtime.Gosched() for locked goroutines
The removed code leads to the situation when M executes the same locked G again
and again.
This is https://golang.org/cl/7310096 but with return instead of break
in the nested switch.
Fixes #4820.

R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/7304102
2013-02-20 12:13:04 +04:00
Carl Shapiro
7f9c02a10d runtime: add conversion specifier to printf for char values
R=r, golang-dev
CC=golang-dev
https://golang.org/cl/7327053
2013-02-19 18:05:44 -08:00
Russ Cox
cb32ea9c19 runtime: replace bubble sort with heap sort in select
R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/7304106
2013-02-19 10:15:13 -05:00
Robin Eklind
d137a2cb56 src: use internal tests if possible
If a test can be placed in the same package ("internal"), it is placed
there. This facilitates testing of package-private details. Because of
dependency cycles some packages cannot be tested by internal tests.

R=golang-dev, rsc, mikioh.mikioh
CC=golang-dev, r
https://golang.org/cl/7323044
2013-02-19 10:02:01 -05:00
Russ Cox
86d509b463 runtime: preparation for non-Go threads running Go code
* Handle p==nil in signalstack by setting SS_DISABLE flag.
* Make minit only allocate a signal g if there's not one already.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7323072
2013-02-18 13:43:12 -05:00
Dmitriy Vyukov
d62239b5f6 runtime/debug: make TestFreeOSMemory repeatable
Fixes #4835.

R=golang-dev, fullung
CC=golang-dev
https://golang.org/cl/7319050
2013-02-18 15:46:36 +04:00
Joel Sing
556dd0bfbd runtime: fix sigaction struct on freebsd
Fix the sa_mask member of the sigaction struct - on FreeBSD this is
declared as a sigset_t, which is an array of four unsigned ints.
Replace the current int64 with Sigset from defs_freebsd_GOARCH, which
has the correct definition.

Unbreaks the FreeBSD builds.

R=golang-dev, dave, minux.ma
CC=golang-dev
https://golang.org/cl/7333047
2013-02-18 03:23:29 +11:00
Georg Reinke
f1037f0e86 runtime: fix build on openbsd
R=golang-dev, jsing
CC=golang-dev
https://golang.org/cl/7312104
2013-02-17 02:06:59 +11:00
Dave Cheney
21327e1970 runtime: fix unused variable warning
R=rsc, dvyukov
CC=golang-dev
https://golang.org/cl/7312103
2013-02-16 14:32:04 +11:00
Russ Cox
60526ca6d1 undo CL 7310096 / 59da6744d66d
broke windows build

««« original CL description
runtime: ensure forward progress of runtime.Gosched() for locked goroutines
The removed code leads to the situation when M executes the same locked G again and again.
Fixes #4820.

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

TBR=dvyukov
CC=golang-dev
https://golang.org/cl/7343050
2013-02-15 17:54:46 -05:00
Russ Cox
0c3b17a55a runtime: allow mem profiles with GOGC=off
Fixes #3586.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7304098
2013-02-15 14:48:58 -05:00
Russ Cox
6c1539bb01 runtime: show frame pointer values during throw
Should help if stack overflows start happening again.

Fixes #3582.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7311098
2013-02-15 14:48:47 -05:00
Russ Cox
c8214c78bd runtime: make return from main wait for active panic
Arguably if this happens the program is buggy anyway,
but letting the panic continue looks better than interrupting it.
Otherwise things like this are possible, and confusing:

$ go run x.go
panic: $ echo $?
0
$

Fixes #3934.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7322083
2013-02-15 14:48:35 -05:00
Russ Cox
318309a51f runtime/pprof: adjust reported line numbers to show call sites
This is the same logic used in the standard tracebacks.
The caller pc is the pc after the call, so except in the
fake "call" caused by a panic, back up the pc enough
that the lookup will use the previous instruction.

Fixes #4150.
Fixes #4151.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7317047
2013-02-15 14:27:16 -05:00
Russ Cox
8a6ff3ab34 runtime: allocate heap metadata at run time
Before, the mheap structure was in the bss,
but it's quite large (today, 256 MB, much of
which is never actually paged in), and it makes
Go binaries run afoul of exec-time bss size
limits on some BSD systems.

Fixes #4447.

R=golang-dev, dave, minux.ma, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/7307122
2013-02-15 14:27:03 -05:00
Dmitriy Vyukov
f87b7f67b2 runtime: ensure forward progress of runtime.Gosched() for locked goroutines
The removed code leads to the situation when M executes the same locked G again and again.
Fixes #4820.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7310096
2013-02-15 22:22:13 +04:00
Russ Cox
d3d89ae7d2 runtime: check rt_sigaction return values on linux
(If the mask size is wrong the system call fails.)

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7305097
2013-02-15 13:13:19 -05:00
Russ Cox
c7f7bbbf03 runtime: fix build on linux
In addition to the compile failure fixed in signal*.c,
preserving the signal mask led to very strange crashes.
Testing shows that looking for SIG_IGN is all that
matters to get along with nohup, so reintroduce
sigset_zero instead of trying to preserve the signal mask.

TBR=iant
CC=golang-dev
https://golang.org/cl/7323067
2013-02-15 12:18:33 -05:00
Russ Cox
f3407f445d runtime: fix running under nohup
There are two ways nohup(1) might be implemented:
it might mask away the signal, or it might set the handler
to SIG_IGN, both of which are inherited across fork+exec.
So two fixes:

* Make sure to preserve the inherited signal mask at
minit instead of clearing it.

* If the SIGHUP handler is SIG_IGN, leave it that way.

Fixes #4491.

R=golang-dev, mikioh.mikioh, iant
CC=golang-dev
https://golang.org/cl/7308102
2013-02-15 11:18:55 -05:00
Dmitriy Vyukov
a9824f178d runtime: fix debug output
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7312101
2013-02-15 17:04:02 +04:00
Alan Donovan
e49f945603 runtime: expand error for signal received on non-Go thread.
We call runtime.findnull dynamically to avoid exceeding the
static nosplit stack limit check.  (Thanks minux!)

Fixes #4048.

R=rsc, minux.ma, ality
CC=golang-dev
https://golang.org/cl/7232066
2013-02-14 23:37:14 -05:00
Dmitriy Vyukov
6a828482fa runtime: add more tests for LockOSThread()
Just test some additional paths through the scheduler.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7331044
2013-02-15 00:02:12 +04:00
Dmitriy Vyukov
691455f780 runtime: move stack management related code to stack.c
No code changes.
This is mainly in preparation to scheduler changes,
oldstack/newstack are not related to scheduling.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7311085
2013-02-14 12:37:55 +04:00
Russ Cox
e5dae3baaa runtime: tweak addfinroots to preserve original pointer
Use local variable so that stack trace will show value of v.

Fixes #4790.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7300106
2013-02-13 22:31:45 -05:00
Dmitriy Vyukov
4a524311f4 runtime: instrument slicebytetostring for race detection
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7322068
2013-02-13 18:29:59 +04:00
Shenghou Ma
2fdd60b9b6 go/build, runtime/cgo: cgo support for NetBSD/ARM
R=golang-dev, rsc, dave
CC=golang-dev
https://golang.org/cl/7229082
2013-02-13 01:06:52 +08:00
Shenghou Ma
37aba1aa77 runtime: NetBSD/ARM support
R=rsc, dave
CC=golang-dev
https://golang.org/cl/7289044
2013-02-13 01:00:04 +08:00
Jan Ziak
1e01fba2fc runtime: precise garbage collection of hashmaps
R=golang-dev, rsc
CC=dave, dvyukov, golang-dev, minux.ma, remyoudompheng
https://golang.org/cl/7252047
2013-02-08 16:00:33 -05:00
Dmitriy Vyukov
0a9f1ab8bb runtime/race: deflake tests
With the new scheduler races in the tests are reported during execution of other tests.
The change joins goroutines started during the tests.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7310066
2013-02-08 19:24:50 +04:00
Dmitriy Vyukov
45636db01b runtime: fix integer overflow
The problem happens when end=0, then end-1 is very big number.
Observed with the new scheduler.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7307073
2013-02-08 19:05:19 +04:00
Shenghou Ma
6c54bf9916 runtime: fix build for Linux/ARM
R=dave, rsc
CC=golang-dev
https://golang.org/cl/7299055
2013-02-08 13:24:38 +08:00
Dmitriy Vyukov
0a40cd2661 runtime/race: switch to explicit race context instead of goroutine id's
Removes limit on maximum number of goroutines ever existed.
code.google.com/p/goexecutor tests now pass successfully.
Also slightly improves performance.
Before: $ time ./flate.test -test.short
real	0m9.314s
After:  $ time ./flate.test -test.short
real	0m8.958s
Fixes #4286.
The runtime is built from llvm rev 174312.

R=rsc
CC=golang-dev
https://golang.org/cl/7218044
2013-02-06 11:40:54 +04:00
Shenghou Ma
7de3d71797 runtime: save LR to stack when panicking to handle leaf function traceback
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7289047
2013-02-06 01:18:37 +08:00
Dmitriy Vyukov
6b1b613d6a runtime/race: do not include pthread.h
Fixes #4721.

R=alex.brainman, minux.ma
CC=golang-dev
https://golang.org/cl/7275048
2013-02-05 13:08:07 +04:00
Russ Cox
472354f81e runtime/debug: add controls for garbage collector
Fixes #4090.

R=golang-dev, iant, bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/7229070
2013-02-04 00:00:55 -05:00
Russ Cox
f02067a99a cmd/gc: implement latest rules for checking make sizes
Fixes #4085.

R=ken2
CC=golang-dev
https://golang.org/cl/7277047
2013-02-03 14:28:44 -05:00
Russ Cox
2eafbb8878 cmd/gc: elide self-assignment during return
More efficient, less racy code.

Fixes #4014.

R=ken2, ken
CC=golang-dev
https://golang.org/cl/7275047
2013-02-03 01:18:28 -05:00
Ian Lance Taylor
e5ea2d5335 runtime: fix windows build
Fixes #4743.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7284044
2013-02-02 11:41:04 -08:00
Elias Naur
44cf814d50 runtime, cmd/ld: make code more position-independent
Change the stack unwinding code to compensate for the dynamic
relocation of symbols.
Change the gc instruction GC_CALL to use a relative offset instead of
an absolute address.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7248048
2013-02-01 11:24:49 -08:00
Russ Cox
b0a29f393b runtime: cgo-related fixes
* Separate internal and external LockOSThread, for cgo safety.
* Show goroutine that made faulting cgo call.
* Never start a panic due to a signal caused by a cgo call.

Fixes #3774.
Fixes #3775.
Fixes #3797.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7228081
2013-02-01 08:34:41 -08:00
Jan Ziak
4da6b36fbf runtime: local allocation in mprof.goc
Binary data in mprof.goc may prevent the garbage collector from freeing
memory blocks. This patch replaces all calls to runtime·mallocgc() with
calls to an allocator private to mprof.goc, thus making the private
memory invisible to the garbage collector. The addrhash variable is
moved outside of the .bss section.

R=golang-dev, dvyukov, rsc, minux.ma
CC=dave, golang-dev, remyoudompheng
https://golang.org/cl/7135063
2013-01-30 09:01:31 -08:00
Akshat Kumar
c74f3c4576 runtime: add support for panic/recover in Plan 9 note handler
This change also resolves some issues with note handling: we now make
sure that there is enough room at the bottom of every goroutine to
execute the note handler, and the `exitstatus' is no longer a global
entity, which resolves some race conditions.

R=rminnich, npe, rsc, ality
CC=golang-dev
https://golang.org/cl/6569068
2013-01-30 02:53:56 -08:00
Rémy Oudompheng
ccc61eadd5 runtime: implement range access functions in race detector.
Range access functions are already available in TSan library
but were not yet used.

Time for go test -race -short:

Before:
compress/flate 24.244s
exp/norm       >200s
go/printer     78.268s

After:
compress/flate 17.760s
exp/norm        5.537s
go/printer      5.738s

Fixes #4250.

R=dvyukov, golang-dev, fullung
CC=golang-dev
https://golang.org/cl/7229044
2013-01-30 01:55:02 +01:00
Russ Cox
ec1948a44d runtime: clear up lr comments
R=cshapiro
CC=golang-dev
https://golang.org/cl/7230052
2013-01-29 13:12:50 -08:00
Dmitriy Vyukov
81221f512d runtime: dump the full stack of a throwing goroutine
Useful for debugging of runtime bugs.
+ Do not print "stack segment boundary" unless GOTRACEBACK>1.
+ Do not traceback system goroutines unless GOTRACEBACK>1.

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/7098050
2013-01-29 14:57:11 +04:00
Sébastien Paolacci
09ea3b518e runtime: earlier detection of unused spans.
Mark candidate spans one GC pass earlier.

Move scavenger's code out from mgc0 and constrain it into mheap (where it belongs).

R=rsc, dvyukov, minux.ma
CC=golang-dev
https://golang.org/cl/7002049
2013-01-28 12:53:35 -05:00
Ian Lance Taylor
e65c0a82ce runtime: use new CNT_MASK in lfstack
This is for SPARC64, a 64-bit processor that uses all 64-bits
of virtual addresses.  The idea is to use the low order 3 bits
to at least get a small ABA counter.  That should work since
pointers are aligned.  The idea is for SPARC64 to set CNT_MASK
== 7, PTR_BITS == 0, PTR_MASK == 0xffffffffffffff8.

Also add uintptr casts to avoid GCC warnings.  The gccgo
runtime code is compiled with GCC, and GCC warns when casting
between a pointer and a type of a different size.

R=dvyukov
CC=golang-dev
https://golang.org/cl/7225043
2013-01-26 18:16:43 -08:00
Shenghou Ma
4019d0e424 runtime: avoid defining the same variable in more than one translation unit
For gccgo runtime and Darwin where -fno-common is the default.

R=iant, dave
CC=golang-dev
https://golang.org/cl/7094061
2013-01-26 09:57:06 +08:00
Dmitriy Vyukov
3c25cd2784 runtime: increase stack limit in a test
Otherwise the test is flaky.
Fixes #4698.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7133071
2013-01-24 20:26:08 +04:00
Dave Cheney
6a9e956f19 all: use t.Skip{,f}
Replace various t.Log{,f} ; return checks with t.Skip{,f}.

R=golang-dev, n13m3y3r, bradfitz, adg, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7193044
2013-01-24 17:32:10 +11:00
Dmitriy Vyukov
fd32ac4bae runtime: account stop-the-world time in the "other" GOGCTRACE section
Currently it's summed to mark phase.
The change makes it easier to diagnose long stop-the-world phases.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/7182043
2013-01-22 13:44:49 +04:00
Jan Ziak
059fed3dfb runtime: try to determine the actual type during garbage collection
If the scanned block has no typeinfo the garbage collector will attempt
to get the actual type of the block.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/7093045
2013-01-18 16:56:17 -05:00
Sébastien Paolacci
d8626ef128 runtime: faster mcentral alloc.
Reduce individual object handling by anticipating how much of them are servable.

Not a chunked transfer cache, but decent enough to make sure the bottleneck is not here.

Mac OSX, median of 10 runs:

benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    5358937333   4892813012   -8.70%
BenchmarkFannkuch11      3257752475   3315436116   +1.77%
BenchmarkGobDecode         23277349     23001114   -1.19%
BenchmarkGobEncode         14367327     14262925   -0.73%
BenchmarkGzip             441045541    440451719   -0.13%
BenchmarkGunzip           139117663    139622494   +0.36%
BenchmarkJSONEncode        45715854     45687802   -0.06%
BenchmarkJSONDecode       103949570    106530032   +2.48%
BenchmarkMandelbrot200      4542462      4548290   +0.13%
BenchmarkParse              7790558      7557540   -2.99%
BenchmarkRevcomp          831436684    832510381   +0.13%
BenchmarkTemplate         133789824    133007337   -0.58%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            32.82        33.33    1.02x
BenchmarkGobEncode            53.42        53.86    1.01x
BenchmarkGzip                 43.70        44.01    1.01x
BenchmarkGunzip              139.09       139.14    1.00x
BenchmarkJSONEncode           42.69        42.56    1.00x
BenchmarkJSONDecode           18.78        17.91    0.95x
BenchmarkParse                 7.37         7.67    1.04x
BenchmarkRevcomp             306.83       305.70    1.00x
BenchmarkTemplate             14.57        14.56    1.00x

R=rsc, dvyukov
CC=golang-dev
https://golang.org/cl/7005055
2013-01-18 16:39:22 -05:00
Rémy Oudompheng
c13866db7f cmd/5c: fix handling of side effects when assigning a struct literal.
Also undo revision a5b96b602690 used to workaround the bug.

Fixes #4643.

R=rsc, golang-dev, dave, minux.ma, lucio.dere, bradfitz
CC=golang-dev
https://golang.org/cl/7090043
2013-01-12 09:16:50 +01:00
Rémy Oudompheng
6e981c181c runtime: work around 5c bug in GC code.
5c miscompiles *p++ = struct_literal.

R=dave, golang-dev
CC=golang-dev
https://golang.org/cl/7065069
2013-01-11 00:59:44 +01:00
Jan Ziak
9204eb4d3c runtime: interpret type information during garbage collection
R=rsc, dvyukov, remyoudompheng, dave, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/6945069
2013-01-10 15:45:46 -05:00
Dmitriy Vyukov
7847f328cd runtime: faster segmented stacks
benchmark                      old ns/op    new ns/op    delta
BenchmarkStackGrowth                 665          548  -17.59%
BenchmarkStackGrowth-2               333          274  -17.72%
BenchmarkStackGrowth-4               224          168  -25.00%
BenchmarkStackGrowth-8               124           91  -26.21%
BenchmarkStackGrowth-16               82           70  -14.55%
BenchmarkStackGrowth-32               73           59  -19.49%

R=nigeltao, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7026044
2013-01-10 11:36:40 +04:00
Dmitriy Vyukov
f82db7d9e4 runtime: less aggressive per-thread stack segment caching
Introduce global stack segment cache and limit per-thread cache size.
This greatly reduces StackSys memory on workloads that create lots of threads.

benchmark                      old ns/op    new ns/op    delta
BenchmarkStackGrowth                 665          656   -1.35%
BenchmarkStackGrowth-2               333          328   -1.50%
BenchmarkStackGrowth-4               224          172  -23.21%
BenchmarkStackGrowth-8               124           91  -26.13%
BenchmarkStackGrowth-16               82           47  -41.94%
BenchmarkStackGrowth-32               73           40  -44.79%

BenchmarkStackGrowthDeep           97231        94391   -2.92%
BenchmarkStackGrowthDeep-2         47230        58562  +23.99%
BenchmarkStackGrowthDeep-4         24993        49356  +97.48%
BenchmarkStackGrowthDeep-8         15105        30072  +99.09%
BenchmarkStackGrowthDeep-16        10005        15623  +56.15%
BenchmarkStackGrowthDeep-32        12517        13069   +4.41%

TestStackMem#1,MB                  310          12       -96.13%
TestStackMem#2,MB                  296          14       -95.27%
TestStackMem#3,MB                  479          14       -97.08%

TestStackMem#1,sec                 3.22         2.26     -29.81%
TestStackMem#2,sec                 2.43         2.15     -11.52%
TestStackMem#3,sec                 2.50         2.38      -4.80%

R=sougou, no.smile.face, rsc
CC=golang-dev, msolomon
https://golang.org/cl/7029044
2013-01-10 09:57:06 +04:00
Russ Cox
4e2aa9bff0 cmd/ld: use native-endian symbol values in symbol table
The Plan 9 symbol table format defines big-endian symbol values
for portability, but we want to be able to generate an ELF object file
and let the host linker link it, as part of the solution to issue 4069.
The symbol table itself, since it is loaded into memory at run time,
must be filled in by the final host linker, using relocation directives
to set the symbol values. On a little-endian machine, the linker will
only fill in little-endian values during relocation, so we are forced
to use little-endian symbol values.

To preserve most of the original portability of the symbol table
format, we make the table itself say whether it uses big- or
little-endian values. If the table begins with the magic sequence
        fe ff ff ff 00 00
then the actual table begins after those six bytes and contains
little-endian symbol values. Otherwise, the table is in the original
format and contains big-endian symbol values. The magic sequence
looks like an "end of table" entry (the fifth byte is zero), so legacy
readers will see a little-endian table as an empty table.

All the gc architectures are little-endian today, so the practical
effect of this CL is to make all the generated tables little-endian,
but if a big-endian system comes along, ld will not generate
the magic sequence, and the various readers will fall back to the
original big-endian interpretation.

R=ken2
CC=golang-dev
https://golang.org/cl/7066043
2013-01-04 17:03:57 -05:00
Ian Lance Taylor
63bee953a2 runtime: always incorporate hash seed at start of hash computation
Otherwise we can get predictable collisions.

R=golang-dev, dave, patrick, rsc
CC=golang-dev
https://golang.org/cl/7051043
2013-01-04 07:53:42 -08:00
Jan Ziak
89ec208ee8 runtime: introduce typedefs and delete struct keywords in mgc0.c
R=rsc
CC=golang-dev
https://golang.org/cl/7029055
2013-01-04 10:20:50 -05:00
Dave Cheney
c2d2bfcc49 runtime: fix freebsd/arm instruction cache flush
sysarch requires arguments to be passed on the stack, not in registers.

Credit to Shenghou Ma (minux) for the fix.

R=minux.ma, devon.odell
CC=golang-dev
https://golang.org/cl/7037043
2013-01-01 21:47:42 +11:00
Russ Cox
a22389ec38 runtime: say 'fatal error' instead of 'throw'
Fixes #4597.

R=ken2
CC=golang-dev
https://golang.org/cl/7032043
2012-12-29 21:48:25 -05:00
Sébastien Paolacci
e786829e83 runtime: handle locked mmap failure on Linux
Used to then die on a nil pointer situation. Most Linux standard setups are rather
restrictive regarding the default amount of lockable memory.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6997049
2012-12-29 14:34:06 -05:00
Dmitriy Vyukov
91484c6c48 runtime: fix potential crash in sigqueue
Fixes #4383.

R=golang-dev, minux.ma, rsc, iant
CC=golang-dev
https://golang.org/cl/6996060
2012-12-28 15:36:06 +04:00
Dmitriy Vyukov
4380fa6d99 runtime: diagnose double wakeup on Note
Double wakeup is prohibited by the Note interface
and checked in lock_sema.c.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6976054
2012-12-24 21:06:57 +04:00
Dmitriy Vyukov
43f2fc308b runtime/race: make test driver print compilation errors
Currently it silently "succeeds" saying that it run 0 tests
if there are compilations errors.
With this change it fails and outputs the compilation error.

R=golang-dev, remyoudompheng
CC=golang-dev
https://golang.org/cl/7002058
2012-12-24 15:33:32 +04:00
Rémy Oudompheng
ecbf99ad97 cmd/gc: fix race instrumentation of unaddressable arrays.
Fixes #4578.

R=dvyukov, golang-dev
CC=golang-dev
https://golang.org/cl/7005050
2012-12-24 12:14:41 +01:00
Russ Cox
403f012534 runtime: zero d.free field
Not programming in Go anymore:
have to clear fields in local variables.

R=ken2
CC=golang-dev
https://golang.org/cl/7002053
2012-12-22 18:23:26 -05:00
Russ Cox
e49a183b76 runtime/debug: document that Stack is deprecated
Fixes #4070.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7004050
2012-12-22 17:23:50 -05:00
Russ Cox
ec59b840f9 runtime: coalesce 0-size allocations
Fixes #3996.

R=ken2
CC=golang-dev
https://golang.org/cl/7001052
2012-12-22 16:42:22 -05:00
Russ Cox
295a4d8e64 runtime: ignore failure from madvise
When we release memory to the OS, if the OS doesn't want us
to release it (for example, because the program executed
mlockall(MCL_FUTURE)), madvise will fail. Ignore the failure
instead of crashing.

Fixes #3435.

R=ken2
CC=golang-dev
https://golang.org/cl/6998052
2012-12-22 15:06:28 -05:00
Russ Cox
0de71619ce runtime: aggregate defer allocations
benchmark             old ns/op    new ns/op    delta
BenchmarkDefer              165          113  -31.52%
BenchmarkDefer10            155          103  -33.55%
BenchmarkDeferMany          216          158  -26.85%

benchmark            old allocs   new allocs    delta
BenchmarkDefer                1            0  -100.00%
BenchmarkDefer10              1            0  -100.00%
BenchmarkDeferMany            1            0  -100.00%

benchmark             old bytes    new bytes    delta
BenchmarkDefer               64            0  -100.00%
BenchmarkDefer10             64            0  -100.00%
BenchmarkDeferMany           64           66    3.12%

Fixes #2364.

R=ken2
CC=golang-dev
https://golang.org/cl/7001051
2012-12-22 14:54:39 -05:00
Dmitriy Vyukov
080d31cc50 runtime/race: update linux runtime to r170876.
This disables checks for limited address space
and unlimited stack. They are not required for Go.
Fixes #4577.

R=golang-dev, iant
CC=golang-dev, kamil.kisiel, minux.ma
https://golang.org/cl/7003045
2012-12-21 19:12:00 +04:00
Joel Sing
708db79011 cgo: enable cgo on openbsd
Enable cgo on OpenBSD.

The OpenBSD ld.so(1) does not currently support PT_TLS sections. Work
around this by fixing up the TCB that has been provided by librthread
and reallocating a TCB with additional space for TLS. Also provide a
wrapper for pthread_create, allowing zeroed TLS to be allocated for
threads created externally to Go.

Joint work with Shenghou Ma (minux).

Requires change 6846064.

Fixes #3205.

R=golang-dev, minux.ma, iant, rsc, iant
CC=golang-dev
https://golang.org/cl/6853059
2012-12-21 01:43:19 +11:00
Jingcheng Zhang
70e967b7bc runtime: use "mp" and "gp" instead of "m" and "g" for local variable name to avoid confusion with the global "m" and "g".
R=golang-dev, minux.ma, rsc
CC=bradfitz, golang-dev
https://golang.org/cl/6939064
2012-12-19 00:30:29 +08:00
Shenghou Ma
7777bac6e4 runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.

Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          110          118   +7.27%

Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          625          542  -13.28%

Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          992          909   -8.37%

FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          699          695   -0.57%

FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow         1553         1658   +6.76%

OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow         1262         1236   -2.06%

OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow         5089         5043   -0.90%

NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          277          278   +0.36%

NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          103          105   +1.94%

Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.

R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 22:57:25 +08:00
Anthony Martin
432f18221f runtime: implement getenv for Plan 9
With this change the runtime can now read GOMAXPROCS, GOGC, etc.

I'm not quite sure how we missed this.

R=seed, lucio.dere, rsc
CC=golang-dev
https://golang.org/cl/6935062
2012-12-17 11:07:40 -05:00
Dmitriy Vyukov
ca4b868e9a cmd/gc: racewalk: fix compiler crash
The code:
func main() {
        v := make([]int64, 10)
        i := 1
        _ = v[(i*4)/3]
}
crashes compiler with:

Program received signal SIGSEGV, Segmentation fault.
0x000000000043c274 in walkexpr (np=0x7fffffffc9b8, init=0x0) at src/cmd/gc/walk.c:587
587			*init = concat(*init, n->ninit);
(gdb) bt
#0  0x000000000043c274 in walkexpr (np=0x7fffffffc9b8, init=0x0) at src/cmd/gc/walk.c:587
#1  0x0000000000432d15 in copyexpr (n=0x7ffff7f69a48, t=<optimized out>, init=0x0) at src/cmd/gc/subr.c:2020
#2  0x000000000043f281 in walkdiv (init=0x0, np=0x7fffffffca70) at src/cmd/gc/walk.c:2901
#3  walkexpr (np=0x7ffff7f69760, init=0x0) at src/cmd/gc/walk.c:956
#4  0x000000000043d801 in walkexpr (np=0x7ffff7f69bc0, init=0x0) at src/cmd/gc/walk.c:988
#5  0x000000000043cc9b in walkexpr (np=0x7ffff7f69d38, init=0x0) at src/cmd/gc/walk.c:1068
#6  0x000000000043c50b in walkexpr (np=0x7ffff7f69f50, init=0x0) at src/cmd/gc/walk.c:879
#7  0x000000000043c50b in walkexpr (np=0x7ffff7f6a0c8, init=0x0) at src/cmd/gc/walk.c:879
#8  0x0000000000440a53 in walkexprlist (l=0x7ffff7f6a0c8, init=0x0) at src/cmd/gc/walk.c:357
#9  0x000000000043d0bf in walkexpr (np=0x7fffffffd318, init=0x0) at src/cmd/gc/walk.c:566
#10 0x00000000004402bf in vmkcall (fn=<optimized out>, t=0x0, init=0x0, va=0x7fffffffd368) at src/cmd/gc/walk.c:2275
#11 0x000000000044059a in mkcall (name=<optimized out>, t=0x0, init=0x0) at src/cmd/gc/walk.c:2287
#12 0x000000000042862b in callinstr (np=0x7fffffffd4c8, init=0x7fffffffd568, wr=0, skip=<optimized out>) at src/cmd/gc/racewalk.c:478
#13 0x00000000004288b7 in racewalknode (np=0x7ffff7f68108, init=0x7fffffffd568, wr=0, skip=0) at src/cmd/gc/racewalk.c:287
#14 0x0000000000428781 in racewalknode (np=0x7ffff7f65840, init=0x7fffffffd568, wr=0, skip=0) at src/cmd/gc/racewalk.c:302
#15 0x0000000000428abd in racewalklist (l=0x7ffff7f65840, init=0x0) at src/cmd/gc/racewalk.c:97
#16 0x0000000000428d0b in racewalk (fn=0x7ffff7f5f010) at src/cmd/gc/racewalk.c:63
#17 0x0000000000402b9c in compile (fn=0x7ffff7f5f010) at src/cmd/6g/../gc/pgen.c:67
#18 0x0000000000419f86 in funccompile (n=0x7ffff7f5f010, isclosure=0) at src/cmd/gc/dcl.c:1414
#19 0x0000000000424161 in p9main (argc=<optimized out>, argv=<optimized out>) at src/cmd/gc/lex.c:431
#20 0x0000000000401739 in main (argc=<optimized out>, argv=<optimized out>) at src/lib9/main.c:35

The problem is nil init passed to mkcall().

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6940045
2012-12-17 12:55:41 +04:00
Jan Ziak
013fa63c90 runtime: struct Obj in mgc0.c and buffers in scanblock()
Details:

- This CL is the conceptual skeleton of code found in CL 6114046

- The garbage collector uses struct Obj to specify memory blocks

- scanblock() is putting found memory blocks into an intermediate buffer
  (xbuf) before adding/flushing them to the main work buffer (wbuf)

- The main loop in scanblock() is replaced with a skeleton code that
  in the future will be able to recognize the type of objects and
  thus will improve the garbage collector's precision.
  For now, all objects are simply sequences of pointers so
  the precision of the garbage collector remains unchanged.

- The code plugs .gcdata and .gcbss sections into the garbage collector.
  scanblock() in this CL is unable to make any use of this.

R=rsc, dvyukov, remyoudompheng
CC=dave, golang-dev, minux.ma
https://golang.org/cl/6856121
2012-12-16 19:32:12 -05:00
Mikio Hara
78cee46f3a src: gofmt -w -s
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6935059
2012-12-15 14:19:51 +09:00
Dmitriy Vyukov
10b3e310e2 runtime/race: update runtime to r170112.
This includes GORACE history_size and log_path flags.

This change is actually an addition to:
https://golang.org/cl/6947046

race_linux_amd64.syso somehow fall out of it.

R=minux.ma
CC=golang-dev
https://golang.org/cl/6946051
2012-12-14 13:40:59 +04:00
Dmitriy Vyukov
a719700e89 runtime/race: update runtime to r170112.
This includes GORACE history_size and log_path flags.

R=golang-dev, bradfitz, rsc, remyoudompheng, minux.ma
CC=golang-dev
https://golang.org/cl/6947046
2012-12-14 13:23:43 +04:00