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

1085 Commits

Author SHA1 Message Date
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
Shenghou Ma
28a50c7f51 runtime: deletion on nil maps is a no-op now
Fixes #4535.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6942044
2012-12-13 23:48:48 +08:00
Albert Strasheim
b978995f5d runtime/race: fix test for GOMAXPROCS>1
Fixes #4530.

R=dvyukov, dave
CC=golang-dev
https://golang.org/cl/6933052
2012-12-13 10:14:32 +04:00
Shenghou Ma
9e30b708a1 all: set GOMAXPROCS to 1 when counting mallocs
also fix an annoying test that relies on $GOROOT be set.
Fixes #3690.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6844086
2012-12-01 00:38:01 +08:00
Dmitriy Vyukov
0ce96f9ef4 runtime: better stack traces in race reports
When a race happens inside of runtime (chan, slice, etc),
currently reports contain only user file:line.
If the line contains a complex expression,
it's difficult to figure out where the race exactly.
This change adds one more top frame with exact
runtime function (e.g. runtime.chansend, runtime.mapaccess).

R=golang-dev
CC=golang-dev
https://golang.org/cl/6851125
2012-11-30 10:29:41 +04:00
Jan Ziak
51b8edcb37 runtime: use reflect·call() to enter the function gc()
Garbage collection code (to be merged later) is calling functions
which have many local variables. This increases the probability that
the stack capacity won't be big enough to hold the local variables.
So, start gc() on a bigger stack to eliminate a potentially large number
of calls to runtime·morestack().

R=rsc, remyoudompheng, dsymonds, minux.ma, iant, iant
CC=golang-dev
https://golang.org/cl/6846044
2012-11-27 13:04:59 -05:00
Dmitriy Vyukov
58ce93b6bf runtime/race: add test case for issue 4453
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6854103
2012-11-27 21:59:08 +04:00
Dmitriy Vyukov
908e1b5ea1 runtime/race: add unit tests for race detector
R=golang-dev, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6525052
2012-11-27 15:04:48 +04:00
Shenghou Ma
2637777527 runtime: duplicate code for runtime.nanotime to avoid stack overflow in vDSO clock_gettime
Fixes #4402.

R=remyoudompheng, shivakumar.gn, random0x00, rsc
CC=golang-dev
https://golang.org/cl/6842063
2012-11-27 01:42:01 +08:00
Oling Cat
f80f23e748 runtime: re-format comments.
add necessary newlines.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6847067
2012-11-26 10:53:11 -05:00
Mikio Hara
f02cf1997d runtime: regenerate defs-files for freebsd
R=minux.ma, jsing
CC=golang-dev
https://golang.org/cl/6855080
2012-11-26 21:29:13 +09:00
Joel Sing
4047f300c9 runtime: implement SysUnused for netbsd
R=golang-dev, bradfitz, minux.ma, dave
CC=golang-dev
https://golang.org/cl/6842081
2012-11-26 22:34:01 +11:00
Joel Sing
c6afb781e2 runtime: implement SysUnused for openbsd
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6854079
2012-11-26 22:32:59 +11:00
Mikio Hara
1fbe3090d8 runtime: fix madvise for freebsd/amd64
Make use of carry clear condition instead of low or same.

R=minux.ma, jsing, dave
CC=golang-dev
https://golang.org/cl/6844080
2012-11-25 18:46:41 +09:00
John Graham-Cumming
314fd62434 runtime: implement runtime.SysUnused on FreeBSD
madvise was missing so implement it in assembler. This change
needs to be extended to the other BSD variantes (Net and Open)

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

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

R=golang-dev, mikioh.mikioh, dave, jgc, minux.ma
CC=golang-dev
https://golang.org/cl/6850081
2012-11-24 15:55:19 +11:00
Joel Sing
cd37fecffb runtime: update openbsd runtime to use new tfork syscall
Update OpenBSD runtime to use the new version of the sys___tfork
syscall and switch TLS initialisation from sys_arch to sys___set_tcb
(note that both of these syscalls are available in OpenBSD 5.2).

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6843058
2012-11-22 01:25:53 +11:00
Christian Himpel
ca8aac698f runtime: gdb support: use parse_and_eval to get the goroutine id
This enables to loop over some goroutines, e.g. to print the
backtrace of goroutines 1 to 9:

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

R=lvd, lvd
CC=golang-dev
https://golang.org/cl/6843071
2012-11-19 10:22:47 -08:00
Dave Cheney
4758f89ddb runtime/cgo: enable warnings and treat as errors
Enable warnings as errors during the cgo portion of runtime/cgo. iant requested that the list of flags match cmd/dist/build.c, but I would like to avoid the set of disabled warnings if possible.

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

requires: 6843061

R=minux.ma, iant
CC=golang-dev
https://golang.org/cl/6852055
2012-11-18 08:58:54 +11:00
Shenghou Ma
d1e06dab7c runtime: don't assume AT_RANDOM provide 4-byte aligned ptr
R=dave, remyoudompheng
CC=golang-dev
https://golang.org/cl/6854056
2012-11-18 02:47:17 +08:00
Shenghou Ma
3513d84068 runtime/cgo: fix compilation on Windows with CFLAGS -Wall -Werror
also fix one out-of-date comment in cmd/ld/pe.c as well.

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

R=golang-dev, alex.brainman, iant
CC=golang-dev
https://golang.org/cl/6849057
2012-11-16 20:06:11 +04:00
Oling Cat
aa3d05acc9 runtime: remove extra parentheses.
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6843069
2012-11-16 23:09:37 +11:00
Ian Lance Taylor
cc8bd8969f runtime/cgo: include <string.h> as needed so that strerror is declared
R=golang-dev, dave, jsing
CC=golang-dev
https://golang.org/cl/6847051
2012-11-14 22:04:03 -08:00
Dmitriy Vyukov
063c13a34c runtime/race: more precise handling of finalizers
Currently race detector runtime just disables race detection in the finalizer goroutine.
It has false positives when a finalizer writes to shared memory -- the race with finalizer is reported in a normal goroutine that accesses the same memory.
After this change I am going to synchronize the finalizer goroutine with the rest of the world in racefingo(). This is closer to what happens in reality and so
does not have false positives.
And also add README file with instructions how to build the runtime.

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

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

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

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

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

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

Fixes #2339.

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

Fixes #2142.

R=golang-dev, iant, devon.odell
CC=golang-dev
https://golang.org/cl/6826088
2012-11-13 12:45:08 -05:00
Ian Lance Taylor
e9a3087e29 runtime, runtime/cgo: track memory allocated by non-Go code
Otherwise a poorly timed GC can collect the memory before it
is returned to the Go program.

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

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

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

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6812103
2012-11-09 10:05:46 +09:00
Joel Sing
4e75d2c7d5 runtime: re-enable crash test on NetBSD
Re-enable the crash tests on NetBSD now that the issue has been
identified and fixed.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6813100
2012-11-09 03:41:43 +11:00
Dmitriy Vyukov
3f7f030c59 runtime: fix instrumentation of slice append for race detection
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6819107
2012-11-08 20:37:05 +04:00
Anthony Martin
024a92c1da runtime: use vDSO for gettimeofday on linux/amd64
Intel Core 2 Duo (2.16 GHz) running 3.6.5-1-ARCH

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

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

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

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6811085
2012-11-07 12:48:58 +04:00
Daniel Morsing
d098bffd84 cmd/gc, runtime: avoid unnecessary copy on type assertion.
When the first result of a type assertion is blank, the compiler would still copy out a potentially large non-interface type.

Fixes #1021.

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

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

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

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6811082
2012-11-06 12:09:40 +04:00
Shenghou Ma
31f8b07e55 runtime/cgo, go/build: cgo support for FreeBSD/ARM
This is the last CL for FreeBSD/ARM support.
Also update cmd/ld/doc.go for 5l support of -Hfreebsd.

R=rsc
CC=golang-dev
https://golang.org/cl/6650051
2012-11-03 02:22:37 +08:00
Rémy Oudompheng
ce287933d6 cmd/gc, runtime: pass PC directly to racefuncenter.
go test -race -run none -bench . encoding/json
benchmark                      old ns/op    new ns/op    delta
BenchmarkCodeEncoder          3207689000   1716149000  -46.50%
BenchmarkCodeMarshal          3206761000   1715677000  -46.50%
BenchmarkCodeDecoder          8647304000   4482709000  -48.16%
BenchmarkCodeUnmarshal        8032217000   3451248000  -57.03%
BenchmarkCodeUnmarshalReuse   8016722000   3480502000  -56.58%
BenchmarkSkipValue           10340453000   4560313000  -55.90%

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

Fixes #4248.

R=dvyukov, golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6815066
2012-11-01 19:43:29 +01:00
Jan Ziak
5c1422afab runtime: move Itab to runtime.h
The 'type' field of Itab will be used by the garbage collector.

R=rsc
CC=golang-dev
https://golang.org/cl/6815059
2012-11-01 13:13:20 -04:00
Jan Ziak
e0c9d04aec runtime: add memorydump() debugging function
R=golang-dev
CC=golang-dev, remyoudompheng, rsc
https://golang.org/cl/6780059
2012-11-01 12:56:25 -04:00
Robert Griesemer
465b9c35e5 gofmt: apply gofmt -w src misc
Remove trailing whitespace in comments.
No other changes.

R=r
CC=golang-dev
https://golang.org/cl/6815053
2012-10-30 13:38:01 -07:00
Dmitriy Vyukov
320df44f04 runtime: switch to 64-bit goroutine ids
Fixes #4275.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6759053
2012-10-26 10:13:06 +04:00
Shenghou Ma
7c44edf425 runtime, runtime/race: add missing if(raceenabled), update package docs of pkg race
R=dvyukov
CC=golang-dev
https://golang.org/cl/6733058
2012-10-23 02:33:51 +08:00
Jingcheng Zhang
5d05c7800e runtime: sizeclass in MSpan should be int32.
R=golang-dev, minux.ma, dave, rsc
CC=golang-dev
https://golang.org/cl/6643046
2012-10-21 20:32:43 -04:00
Jan Ziak
4a191c2c1b runtime: store types of allocated objects
R=rsc
CC=golang-dev
https://golang.org/cl/6569057
2012-10-21 17:41:32 -04:00
Shenghou Ma
c1b7ddc6aa runtime: update docs for MemStats.PauseNs
PauseNs is a circular buffer of recent pause times, and the
most recent one is at [((NumGC-1)+256)%256].

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

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

R=dave, rsc
CC=dave, golang-dev, rsc
https://golang.org/cl/6717043
2012-10-20 16:40:19 +08:00
Nigel Tao
90ad6a2d11 runtime: update comment for the "extern register" variables g and m.
R=rsc, minux.ma, ality
CC=dave, golang-dev
https://golang.org/cl/6620050
2012-10-19 11:02:32 +11:00
Dmitriy Vyukov
f24323c93e runtime: fix spurious deadlock crashes
Fixes #4243.

R=golang-dev, iant
CC=golang-dev, sebastien.paolacci
https://golang.org/cl/6682050
2012-10-16 14:41:32 +04:00
Dmitriy Vyukov
6273c7324f runtime: add missing if(raceenabled)
R=0xe2.0x9a.0x9b, minux.ma, iant, dave
CC=golang-dev
https://golang.org/cl/6654052
2012-10-15 13:54:31 +04:00
Shenghou Ma
366268aa79 runtime: FreeBSD/ARM support
R=rsc
CC=golang-dev
https://golang.org/cl/6625071
2012-10-12 23:19:39 +08:00
Dmitriy Vyukov
be2b95fe3a runtime/debug: fix the test
If source are not available, then the stack looks like:
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/debug/bla-bla-bla/src/pkg/runtime/debug/stack_test.go:15 (0x43fb11)
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/debug/bla-bla-bla/src/pkg/runtime/debug/stack_test.go:18 (0x43fb7a)
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/debug/bla-bla-bla/src/pkg/runtime/debug/stack_test.go:37 (0x43fbf4)
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/testing/bla-bla-bla/src/pkg/testing/testing.go:301 (0x43b5ba)
stack_test.go:40: 	/tmp/gobuilder/linux-amd64-race-72b15c5d6f65/go/src/pkg/runtime/bla-bla-bla/src/pkg/runtime/proc.c:276 (0x410670)
stack_test.go:40:
which is 6 lines.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6637060
2012-10-10 20:49:18 +04:00
Dmitriy Vyukov
27e93fbd00 runtime: fix race detector handling of stackalloc()
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6632051
2012-10-10 18:06:29 +04:00
Russ Cox
f76f120324 cmd/ld: use 64-bit alignment for large data and bss objects
Check for specific, important misalignment in garbage collector.
Not a complete fix for issue 599 but an important workaround.

Update #599.

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/6641049
2012-10-09 12:50:06 -04:00
Dmitriy Vyukov
2f6cbc74f1 race: runtime changes
This is a part of a bigger change that adds data race detection feature:
https://golang.org/cl/6456044

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

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

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6622058
2012-10-08 01:56:27 +08:00
Rémy Oudompheng
782464aea5 runtime: fix a panic when growing zero-width-element slices.
Fixes #4197.

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

R=rsc, dave, minux.ma, r
CC=gobot, golang-dev, r, remyoudompheng
https://golang.org/cl/6443115
2012-10-06 12:56:04 +04:00
Akshat Kumar
23599ca2f6 runtime: mask SSE exceptions on plan9/amd64
The Go run-time assumes that all SSE floating-point exceptions
are masked so that Go programs are not broken by such invalid
operations. By default, the 64-bit version of the Plan 9 kernel
masks only some SSE floating-point exceptions. Here, we mask
them all on a per-thread basis.

R=rsc, rminnich, minux.ma
CC=golang-dev
https://golang.org/cl/6592056
2012-10-05 16:23:30 -04:00
Russ Cox
10ea6519e4 build: make int 64 bits on amd64
The assembly offsets were converted mechanically using
code.google.com/p/rsc/cmd/asmlint. The instruction
changes were done by hand.

Fixes #2188.

R=iant, r, bradfitz, remyoudompheng
CC=golang-dev
https://golang.org/cl/6550058
2012-09-24 20:57:01 -04:00
Jan Ziak
f8c58373e5 runtime: add types to MSpan
R=rsc
CC=golang-dev
https://golang.org/cl/6554060
2012-09-24 20:08:05 -04:00
Russ Cox
0b08c9483f runtime: prepare for 64-bit ints
This CL makes the runtime understand that the type of
the len or cap of a map, slice, or string is 'int', not 'int32',
and it is also careful to distinguish between function arguments
and results of type 'int' vs type 'int32'.

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

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

Update #2188.

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

R=rsc, rminnich, npe
CC=golang-dev
https://golang.org/cl/6543049
2012-09-24 12:24:45 -04:00
Jan Ziak
b16c41bed7 runtime: fix typos in comments
R=rsc
CC=golang-dev
https://golang.org/cl/6554043
2012-09-21 12:25:55 -04:00
Shenghou Ma
b151af1f36 runtime: fix mmap comments
We only pass lower 32 bits of file offset to asm routine.

R=r, dave, rsc
CC=golang-dev
https://golang.org/cl/6499118
2012-09-21 13:50:02 +08:00
Dmitriy Vyukov
d151fb9e20 runtime: reset parfor stats
Otherwise they sum up between GCs.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6535048
2012-09-20 22:46:24 +04:00
Jan Ziak
35724c1aa5 runtime: hide the semaphore table from garbage collector
R=rsc, dvyukov, dave
CC=golang-dev
https://golang.org/cl/6528043
2012-09-18 14:30:01 -04:00
Russ Cox
370ae05545 reflect: add Select
R=r, iant, rogpeppe, bradfitz
CC=golang-dev
https://golang.org/cl/6498078
2012-09-18 14:22:41 -04:00
Dmitriy Vyukov
f20fd87384 runtime: refactor goroutine blocking
The change is a preparation for the new scheduler.
It introduces runtime.park() function,
that will atomically unlock the mutex and park the goroutine.
It will allow to remove the racy readyonstop flag
that is difficult to implement w/o the global scheduler mutex.

R=rsc, remyoudompheng, dave
CC=golang-dev
https://golang.org/cl/6501077
2012-09-18 21:15:46 +04:00
Dave Cheney
55ca5ab0be runtime: arm: abort if VFPv3 support missing
Fixes #3456.

This proposal is a reformulation of CL 5987063. This CL resets
the default GOARM value to 6 and allows the use of the VFPv3
optimisation if GOARM=7. Binaries built with this CL in place
will abort if GOARM=7 was used and the target host does not
support VFPv3.

R=minux.ma, rsc, ajstarks
CC=golang-dev
https://golang.org/cl/6501099
2012-09-18 09:55:07 +10:00
Lucio De Re
b29ed23ab5 build: fix various 'set and not used' for Plan 9
R=dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6501134
2012-09-17 17:25:26 -04:00
Jan Ziak
54193689cc cmd/ld: fix compilation when GOARCH != GOHOSTARCH
R=rsc, dave, minux.ma
CC=golang-dev
https://golang.org/cl/6493123
2012-09-17 17:18:21 -04:00
Shenghou Ma
ecb2a0a9e5 runtime: fix SI_USER for FreeBSD
Ref: http://svnweb.freebsd.org/base/head/sys/sys/signal.h?revision=HEAD&view=markup

R=golang-dev, devon.odell, r
CC=golang-dev
https://golang.org/cl/6490118
2012-09-17 01:08:41 +08:00
Jan Ziak
d09afc2efb gc: generate garbage collection info for types
R=rsc, nigeltao, minux.ma
CC=golang-dev
https://golang.org/cl/6290043
2012-09-12 12:08:27 -04:00
Daniel Morsing
8fd65b0e1d cmd/gc: Inline pointer sized T2I interface conversions
This CL also adds support for marking the likelyness of IF nodes in the AST being true. This feature is being used here to mark the slow path as unlikely.

src/pkg/runtime:
benchmark                  old ns/op    new ns/op    delta
BenchmarkConvT2IUintptr           16            1  -91.63%

test/bench/go1:
benchmark                 old ns/op    new ns/op    delta
BenchmarkBinaryTree17    5416917000   5461355000   +0.82%
BenchmarkFannkuch11      3810355000   3842609000   +0.85%
BenchmarkGobDecode         19950950     19855420   -0.48%
BenchmarkGobEncode         11301220     11308530   +0.06%
BenchmarkGzip             548119600    546869200   -0.23%
BenchmarkGunzip           176145400    180208300   +2.31%
BenchmarkJSONEncode        93117400     70163100  -24.65%
BenchmarkJSONDecode       406626800    409999200   +0.83%
BenchmarkMandelbrot200      6300992      6317866   +0.27%
BenchmarkParse              7664396      7451625   -2.78%
BenchmarkRevcomp         1189424000   1412332000  +18.74%
BenchmarkTemplate         491308400    458654200   -6.65%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode            38.47        38.66    1.00x
BenchmarkGobEncode            67.92        67.87    1.00x
BenchmarkGzip                 35.40        35.48    1.00x
BenchmarkGunzip              110.16       107.68    0.98x
BenchmarkJSONEncode           20.84        27.66    1.33x
BenchmarkJSONDecode            4.77         4.73    0.99x
BenchmarkParse                 7.56         7.77    1.03x
BenchmarkRevcomp             213.69       179.96    0.84x
BenchmarkTemplate              3.95         4.23    1.07x

R=rsc, dave, nigeltao
CC=golang-dev
https://golang.org/cl/6351090
2012-09-11 21:42:30 +02:00
Dave Cheney
212ce41d00 runtime: arm: abort if hardware floating point missing
Fixes #3911.

Requires CL 6449127.

dfc@qnap:~$ ./runtime.test
runtime: this CPU has no floating point hardware, so it cannot run
this GOARM=7 binary. Recompile using GOARM=5.

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6442109
2012-09-07 14:26:42 +10:00
Alan Donovan
ee911c4265 runtime: fix typo in openbsd-only symbol name.
R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6490076
2012-09-04 16:35:05 -04:00