1
0
mirror of https://github.com/golang/go synced 2024-10-04 12:31:21 -06:00
Commit Graph

1094 Commits

Author SHA1 Message Date
Joel Sing
2cb7498455 runtime: fix tv_sec handling for netbsd/386
On netbsd/386, tv_sec is a 64-bit integer for both timeval and timespec.
Fix the time handling code so that it works correctly.

R=golang-dev, rsc, m4dh4tt3r
CC=golang-dev
https://golang.org/cl/6256056
2012-06-06 20:39:27 +10:00
Russ Cox
3a66bc415e runtime: use OS X vsyscall for gettimeofday (amd64)
Thanks to Dave Cheney for the magic words "comm page".

benchmark       old ns/op    new ns/op    delta
BenchmarkNow          197           33  -83.05%

This should make profiling a little better on OS X.
The raw time saved is unlikely to matter: what likely matters
more is that it seems like OS X sends profiling signals on the
way out of system calls more often than it should; avoiding
the system call should increase the accuracy of cpu profiles.

The 386 version would be similar but needs to do different
math for CPU speeds less than 1 GHz. (Apparently Apple has
never shipped a 64-bit CPU with such a slow clock.)

R=golang-dev, bradfitz, dave, minux.ma, r
CC=golang-dev
https://golang.org/cl/6275056
2012-06-05 16:24:37 -04:00
Russ Cox
c7be4defe3 runtime: use OS X vsyscall for gettimeofday (386)
amd64 was done in CL 6275056.

We don't attempt to handle machines with clock speeds
less than 1 GHz. Those will fall back to the system call.

benchmark       old ns/op    new ns/op    delta
BenchmarkNow          364           38  -89.53%

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6307045
2012-06-05 16:23:30 -04:00
Dave Cheney
09f48db3e1 runtime: use uintptr for block length in scanblock
Using an int64 for a block size doesn't make
sense on 32bit platforms but extracts a performance
penalty dealing with double word quantities on Arm.

linux/arm

benchmark                 old ns/op    new ns/op    delta
BenchmarkGobDecode        155401600    144589300   -6.96%
BenchmarkGobEncode         72772220     62460940  -14.17%
BenchmarkGzip               5822632      2604797  -55.26%
BenchmarkGunzip              326321       151721  -53.51%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkGobDecode             4.94         5.31    1.07x
BenchmarkGobEncode            10.55        12.29    1.16x

R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/6272047
2012-06-05 18:55:14 +10:00
Joel Sing
5131deeeb2 cgo: enable cgo on netbsd/386 and netbsd/amd64
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6261056
2012-06-05 01:43:04 +10:00
Luuk van Dijk
40af78c19e cmd/gc: inline slice[arr,str] in the frontend (mostly).
R=rsc, ality, rogpeppe, minux.ma, dave
CC=golang-dev
https://golang.org/cl/5966075
2012-06-02 22:50:57 -04:00
Shenghou Ma
e8265f18e6 runtime: remove unnecessary macros in vlop_arm.s
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6270045
2012-06-03 04:03:09 +08:00
Jan Ziak
65e61d5770 runtime: add (unused for now) gc field to type information
R=rsc
CC=golang-dev
https://golang.org/cl/6255074
2012-06-02 14:02:44 -04:00
Rémy Oudompheng
baf91c313f runtime: lower memory overhead of heap profiling.
The previous code was preparing arrays of entries that would be
filled if there was one entry every 128 bytes. Moving to a 4096
byte interval reduces the overhead per megabyte of address space
to 2kB from 64kB (on 64-bit systems).
The performance impact will be negative for very small MemProfileRate.

test/bench/garbage/tree2 -heapsize 800000000 (default memprofilerate)
Before: mprof 65993056 bytes (1664 bucketmem + 65991392 addrmem)
After:  mprof  1989984 bytes (1680 bucketmem +  1988304 addrmem)

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6257069
2012-05-31 23:30:55 +02:00
Rémy Oudompheng
c4a814f2da runtime/pprof, misc/pprof: correct profile of total allocations.
The previous heap profile format did not include buckets with
zero used bytes. Also add several missing MemStats fields in
debug mode.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6249068
2012-05-31 07:57:49 +02:00
Joel Sing
deb93b0f7b runtime: always initialise procid on netbsd
The correct procid is needed for unparking LWPs on NetBSD - always
initialise procid in minit() so that cgo works correctly. The non-cgo
case already works correctly since procid is initialised via
lwp_create().

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6257071
2012-05-31 03:27:04 +10:00
Jan Ziak
334bf95f9e runtime: update field types in preparation for GC changes
R=rsc, remyoudompheng, minux.ma, ality
CC=golang-dev
https://golang.org/cl/6242061
2012-05-30 13:07:52 -04:00
Jan Ziak
46d7d5fcf5 runtime: hide symbol table from garbage collector
R=rsc
CC=golang-dev
https://golang.org/cl/6243059
2012-05-30 13:04:48 -04:00
Alex Brainman
994cdcea18 runtime: disable new TestCrashHandle on freebsd to fix build
R=golang-dev
CC=golang-dev
https://golang.org/cl/6256069
2012-05-30 16:41:15 +10:00
Rémy Oudompheng
348087877c runtime: do not unset the special bit after finalization.
A block with finalizer might also be profiled. The special bit
is needed to unregister the block from the profile. It will be
unset only when the block is freed.

Fixes #3668.

R=golang-dev, rsc
CC=golang-dev, remy
https://golang.org/cl/6249066
2012-05-30 08:04:11 +02:00
Alex Brainman
afe0e97aa6 runtime: handle windows exceptions, even in cgo programs
Fixes #3543.

R=golang-dev, kardianos, rsc
CC=golang-dev, hectorchu, vcc.163
https://golang.org/cl/6245063
2012-05-30 15:10:54 +10:00
Russ Cox
c1b53d43e8 merge unexpected branch 2012-05-29 14:37:41 -04:00
Dmitriy Vyukov
a0efca84e6 time: fix deadlock in Sleep(0)
See time/sleep_test.go for repro.

R=golang-dev, r, rsc
CC=golang-dev, patrick.allen.higgins
https://golang.org/cl/6250072
2012-05-29 22:30:56 +04:00
Russ Cox
6dbaa206fb runtime: replace runtime·rnd function with ROUND macro
It's sad to introduce a new macro, but rnd shows up consistently
in profiles, and the function call overwhelms the two arithmetic
instructions it performs.

R=r
CC=golang-dev
https://golang.org/cl/6260051
2012-05-29 14:02:29 -04:00
Joel Sing
fb32d60cd1 runtime: make go work on netbsd/386
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6254055
2012-05-30 02:52:50 +10:00
Russ Cox
bf18d57d4a runtime: handle and test large map values
This is from CL 5451105 but was dropped from that CL.
See also CL 6137051.

The only change compared to 5451105 is to check for
h != nil in reflect·mapiterinit; allowing use of nil maps
must have happened after that original CL.

Fixes #3573.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/6215078
2012-05-24 22:41:07 -04:00
Rob Pike
11c1b1f96b runtime: fix docs for Caller and Callers
The previous attempt to explain this got it backwards (all the more reason to be
sad we couldn't make the two functions behave the same).

Fixes #3669.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6249051
2012-05-24 14:15:43 -07:00
Dmitriy Vyukov
b0702bd0db runtime: faster GC mark phase
Also bump MaxGcproc to 8.

benchmark             old ns/op    new ns/op    delta
Parser               3796323000   3763880000   -0.85%
Parser-2             3591752500   3518560250   -2.04%
Parser-4             3423825250   3334955250   -2.60%
Parser-8             3304585500   3267014750   -1.14%
Parser-16            3313615750   3286160500   -0.83%

Tree                  984128500    942501166   -4.23%
Tree-2                932564444    883266222   -5.29%
Tree-4                835831000    799912777   -4.30%
Tree-8                819238500    789717333   -3.73%
Tree-16               880837833    837840055   -5.13%

Tree2                 604698100    579716900   -4.13%
Tree2-2               372414500    356765200   -4.20%
Tree2-4               187488100    177455900   -5.56%
Tree2-8               136315300    102086700  -25.11%
Tree2-16               93725900     76705800  -22.18%

ParserPause           157441210    166202783   +5.56%
ParserPause-2          93842650     85199900   -9.21%
ParserPause-4          56844404     53535684   -5.82%
ParserPause-8          35739446     30767613  -16.15%
ParserPause-16         32718255     27212441  -16.83%

TreePause              29610557     29787725   +0.60%
TreePause-2            24001659     20674421  -13.86%
TreePause-4            15114887     12842781  -15.03%
TreePause-8            13128725     10741747  -22.22%
TreePause-16           16131360     12506901  -22.47%

Tree2Pause           2673350920   2651045280   -0.83%
Tree2Pause-2         1796999200   1709350040   -4.88%
Tree2Pause-4         1163553320   1090706480   -6.67%
Tree2Pause-8          987032520    858916360  -25.11%
Tree2Pause-16         864758560    809567480   -6.81%

ParserLastPause       280537000    289047000   +3.03%
ParserLastPause-2     183030000    166748000   -8.90%
ParserLastPause-4     105817000     91552000  -13.48%
ParserLastPause-8      65127000     53288000  -18.18%
ParserLastPause-16     45258000     38334000  -15.30%

TreeLastPause          45072000     51449000  +12.39%
TreeLastPause-2        39269000     37866000   -3.57%
TreeLastPause-4        23564000     20649000  -12.37%
TreeLastPause-8        20881000     15807000  -24.30%
TreeLastPause-16       23297000     17309000  -25.70%

Tree2LastPause       6046912000   5797120000   -4.13%
Tree2LastPause-2     3724034000   3567592000   -4.20%
Tree2LastPause-4     1874831000   1774524000   -5.65%
Tree2LastPause-8     1363108000   1020809000  -12.79%
Tree2LastPause-16     937208000    767019000  -22.18%

R=rsc, 0xe2.0x9a.0x9b
CC=golang-dev
https://golang.org/cl/6223050
2012-05-24 10:55:50 +04:00
Joel Sing
5a043de746 runtime: make go work on netbsd/amd64
R=golang-dev, rsc, devon.odell
CC=golang-dev
https://golang.org/cl/6222044
2012-05-24 11:33:11 +10:00
Shenghou Ma
fb3a1b6821 runtime: support conditional execution in ARM softfloat
Fixes #3638.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6213057
2012-05-23 02:00:40 +08:00
Dmitriy Vyukov
845aa1fc2c runtime: faster GC sweep phase
benchmark                              old ns/op    new ns/op    delta

garbage.BenchmarkParser               3731065750   3715543750   -0.41%
garbage.BenchmarkParser-2             3631299750   3495248500   -3.75%
garbage.BenchmarkParser-4             3386486000   3339353000   -1.39%
garbage.BenchmarkParser-8             3267632000   3286422500   +0.58%
garbage.BenchmarkParser-16            3299203000   3316081750   +0.51%

garbage.BenchmarkTree                  977532888    919453833   -5.94%
garbage.BenchmarkTree-2                919948555    853478000   -7.23%
garbage.BenchmarkTree-4                841329000    790207000   -6.08%
garbage.BenchmarkTree-8                787792777    740380666   -6.01%
garbage.BenchmarkTree-16               899257166    846594555   -5.86%

garbage.BenchmarkTree2                 574876300    571885800   -0.52%
garbage.BenchmarkTree2-2               348162700    345888900   -0.65%
garbage.BenchmarkTree2-4               184912500    179137000   -3.22%
garbage.BenchmarkTree2-8               104243900    103485600   -0.73%
garbage.BenchmarkTree2-16               97269500     85137100  -14.25%

garbage.BenchmarkParserPause           141101976    157746974  +11.80%
garbage.BenchmarkParserPause-2         103096051     83043048  -19.45%
garbage.BenchmarkParserPause-4          52153133     45951111  -11.89%
garbage.BenchmarkParserPause-8          36730190     38901024   +5.91%
garbage.BenchmarkParserPause-16         32678875     29578585   -9.49%

garbage.BenchmarkTreePause              29487065     29648439   +0.55%
garbage.BenchmarkTreePause-2            22443494     21306159   -5.07%
garbage.BenchmarkTreePause-4            15799691     14985647   -5.15%
garbage.BenchmarkTreePause-8            10768112     9531420   -12.97%
garbage.BenchmarkTreePause-16           16329891     15205158   -6.89%

garbage.BenchmarkTree2Pause           2586957240   2577533200   -0.36%
garbage.BenchmarkTree2Pause-2         1683383760   1673923800   -0.56%
garbage.BenchmarkTree2Pause-4         1102860320   1074040280   -2.68%
garbage.BenchmarkTree2Pause-8          902627920    886122400   -1.86%
garbage.BenchmarkTree2Pause-16         856470920    804152320   -6.50%

garbage.BenchmarkParserLastPause       277316000    280839000   +1.25%
garbage.BenchmarkParserLastPause-2     179446000    163687000   -8.78%
garbage.BenchmarkParserLastPause-4     106752000     94144000  -11.81%
garbage.BenchmarkParserLastPause-8      57758000     61640000   +6.72%
garbage.BenchmarkParserLastPause-16     51235000     42552000  -16.95%

garbage.BenchmarkTreeLastPause          45244000     50786000  +12.25%
garbage.BenchmarkTreeLastPause-2        37163000     34654000   -6.75%
garbage.BenchmarkTreeLastPause-4        24178000     21967000   -9.14%
garbage.BenchmarkTreeLastPause-8        20390000     15648000  -30.30%
garbage.BenchmarkTreeLastPause-16       22398000     20180000   -9.90%

garbage.BenchmarkTree2LastPause       5748706000   5718809000   -0.52%
garbage.BenchmarkTree2LastPause-2     3481570000   3458844000   -0.65%
garbage.BenchmarkTree2LastPause-4     1849073000   1791330000   -3.22%
garbage.BenchmarkTree2LastPause-8     1042375000   1034811000   -0.73%
garbage.BenchmarkTree2LastPause-16     972637000    851323000  -14.25%

There is also visible improvement in consumed CPU time:
tree2 -heapsize=8000000000 -cpus=12
before: 248.74user 6.36system 0:52.74elapsed 483%CPU
after:  229.86user 6.33system 0:51.08elapsed 462%CPU
-1.66s of real time, but -18.91s of consumed CPU time

R=golang-dev
CC=golang-dev
https://golang.org/cl/6215065
2012-05-22 13:35:52 -04:00
Russ Cox
85266dfd4d runtime: relax TestGcSys
This fixes occasional 64-bit failures.
Maybe it will fix the 32-bit failures too,
so re-enable on 32-bit for now.

R=golang-dev, bradfitz, r, dvyukov
CC=golang-dev
https://golang.org/cl/6218050
2012-05-22 00:07:13 -04:00
Andrew Gerrand
283a3ddab8 runtime: disable gc test on non-amd64 systems
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6210062
2012-05-17 11:34:28 +10:00
Akshat Kumar
f5752848fd pkg/runtime: Fix semasleep on Plan 9
With the timed semacquire patch
(kernel-tsemacquire) for Plan 9,
we can now properly do a timed
wait for the semaphore, in
semasleep.

R=golang-dev, rsc, rminnich, ality, r
CC=0intro, golang-dev, john, mirtchovski
https://golang.org/cl/6197046
2012-05-16 15:09:28 -07:00
Joel Sing
efa67b2c55 runtime: implement getcontext and sigprocmask for netbsd
Implement getcontext and sigprocmask for NetBSD - these will soon be
used by the thread handling code.

Also fix netbsd/386 signal handling - there is no sigreturn, just
return so that we hit the trampoline.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6215049
2012-05-16 04:32:49 +10:00
Joel Sing
0b7bcb84e3 runtime: fix netbsd syscalls
Use correct system calls/syscall numbers for NetBSD.

R=golang-dev, for.go.yong, rsc
CC=golang-dev
https://golang.org/cl/6200070
2012-05-16 03:33:37 +10:00
Joel Sing
4a5a5b20a5 runtime: fix netbsd signal handling
Update/correct NetBSD signal handling - most of this is needed due to
the correctly generated runtime definitions.

R=golang-dev, m4dh4tt3r, rsc
CC=golang-dev
https://golang.org/cl/6195079
2012-05-16 01:53:26 +10:00
Joel Sing
8a9edcf790 runtime: fix netbsd runtime defs
Fix and regenerate runtime defs for NetBSD.

Whilst the mcontext struct can be handled across architectures,
the registers are provided as defines that index an array, rather
than as members of the struct. Since these are architecture
dependent, include them via a defs_netbsd_<arch>.go file.

R=golang-dev, m4dh4tt3r, rsc
CC=golang-dev
https://golang.org/cl/6190070
2012-05-16 01:52:20 +10:00
Jan Ziak
773685b4a3 runtime: fix counting of free objects
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6206056
2012-05-15 11:48:58 -04:00
Dmitriy Vyukov
01826280eb runtime: refactor helpgc functionality in preparation for parallel GC
Parallel GC needs to know in advance how many helper threads will be there.
Hopefully it's the last patch before I can tackle parallel sweep phase.
The benchmarks are unaffected.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6200064
2012-05-15 19:10:16 +04:00
Joel Sing
b42ebb6fbf runtime: fix TLS handling for netbsd
Set the TLS base using the _lwp_setprivate() syscall, instead of via
sysarch(). NetBSD tracks the pointer passed to _lwp_setprivate() and
restores this value when restoring mcontext. If sysarch() is used
directly, restoring an mcontext trashes the FS/GS value, resulting
in a segfault when we next try to access the TLS.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6206062
2012-05-15 11:26:05 +10:00
Dmitriy Vyukov
eb0bc8164a runtime: revert MaxGcproc from 16 to 4
The change accidentally come in with this revision:
https://code.google.com/p/go/source/detail?spec=svn345cbca96c5550f2e89bc727703301933802923c&r=14c38c23c819a17021b1808cf4a34ef3a1a17db5

R=golang-dev
CC=golang-dev
https://golang.org/cl/6195073
2012-05-11 13:30:34 +04:00
Dmitriy Vyukov
95643647ae runtime: add parallel for algorithm
This is factored out part of:
https://golang.org/cl/5279048/
(parallel GC)

R=bsiegert, mpimenov, rsc, minux.ma, r
CC=golang-dev
https://golang.org/cl/5986054
2012-05-11 10:50:03 +04:00
Shenghou Ma
aa45e52e74 runtime: fix complex division benchmarks
we can't add the division result to n during iteration, because it might
turn n into NaN or Inf.

R=golang-dev, rsc, iant, iant
CC=golang-dev
https://golang.org/cl/6197045
2012-05-11 03:09:14 +08:00
Joel Sing
5374ded1f3 runtime: fix syscalls for netbsd
Use correct syscall numbers and arguments for NetBSD.
Provide a trampoline for signal returns (using signal API 3).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6209048
2012-05-11 03:48:43 +10:00
Joel Sing
38445ca089 runtime: fix netbsd sigaction struct
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6198063
2012-05-11 03:48:16 +10:00
Shenghou Ma
a642ca4930 runtime: get per-process random number from auxv for hash table
Decode AT_RANDOM, AT_HWCAP, and AT_PLATFORM.
This CL only make use of AT_RANDOM, but future CLs will make use of the others.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/5978051
2012-05-05 01:59:14 +08:00
Shenghou Ma
a29304bfb8 runtime: fix c compiler warning
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6185047
2012-05-05 01:39:09 +08:00
Shenghou Ma
018bcc3535 runtime, misc/cgo/test: fix build for Linux/ARM
1. In CL 5989057, I made a mistake in the last minute change.
"MOVW.W R4, -4(SP)" should really be "MOVW.W R4, -4(R13)",
as 5l will rewrite offset for SP.
2. misc/cgo/test/issue1560.go tests for parallel sleep of 1s,
but on ARM, the deadline is frequently missed, so change sleep
time to 2s on ARM.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6202043
2012-05-05 01:35:13 +08:00
Akshat Kumar
ccdca2cd6b pkg/runtime: Plan 9 signal handling in Go
This adds proper note handling for Plan 9,
and fixes the issue of properly killing go procs.
Without this change, the first go proc that dies
(using runtime·exit()) would kill all the running
go procs. Proper signal handling is needed.

R=golang-dev, ality, rminnich, rsc
CC=golang-dev, john, mirtchovski
https://golang.org/cl/5617048
2012-05-04 03:48:34 -07:00
Shenghou Ma
5cffce611a runtime: cgo support for Linux/ARM
Part 2 of CL 5601044 (cgo: Linux/ARM support)

R=dave, rsc
CC=golang-dev
https://golang.org/cl/5989057
2012-05-04 18:20:09 +08:00
Russ Cox
d42495aa80 cmd/cc: add PREFETCH built-in (like SET, USED)
This makes it possible to inline the prefetch of upcoming
memory addresses during garbage collection, instead of
needing to flush registers, make a function call, and
reload registers.  On garbage collection-heavy workloads,
this results in a 5% speedup.

Fixes #3493.

R=dvyukov, ken, r, dave
CC=golang-dev
https://golang.org/cl/5990066
2012-05-02 16:22:56 -04:00
Dmitriy Vyukov
c1c851bbe8 runtime: avoid unnecessary zeroization of huge memory blocks
+move zeroization out of the heap mutex

R=golang-dev, iant, rsc
CC=golang-dev
https://golang.org/cl/6094050
2012-05-02 18:01:11 +04:00
Shenghou Ma
44fd1d1a6a runtime: give proper messages when user defined DYLD_INSERT_LIBRARIES on Darwin
also gives clear error when bsdthread_register fails on Darwin
       Fixes #2992.

R=rsc, krautz
CC=golang-dev
https://golang.org/cl/5966067
2012-04-30 15:55:07 -04:00
Joel Sing
689d5b9163 runtime: use __tfork() syscall on openbsd
Switch from using the rfork() syscall on OpenBSD, to the __tfork()
syscall.  The __tfork() syscall is the preferred way of creating
system threads and the rfork() syscall has recently been removed.

Note: this will break compatibility with OpenBSD releases prior to 5.1.

R=golang-dev, bradfitz, devon.odell, rsc
CC=golang-dev
https://golang.org/cl/6037048
2012-04-26 00:08:02 +10:00
Shenghou Ma
0f80050542 runtime: fix runtime.Breakpoint for ARM
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6100053
2012-04-24 23:19:44 +08:00
Michael Chaten
32c3a626da runtime: add benchmark for complex128 division
R=golang-dev, dave, rsc
CC=golang-dev, minux.ma
https://golang.org/cl/6070043
2012-04-21 13:24:41 +10:00
Ian Lance Taylor
244706bd0f runtime: disable memory profiler in gc_test
This lets the test pass on PPC64 GNU/Linux, which uses a much
larger page size and thus uses more memory to hold blocks
allocated for memory profiling.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6048054
2012-04-20 11:36:06 -07:00
Joel Sing
99fc281743 runtime: update defs for openbsd
Update runtime defs for openbsd. Add struct __tfork, which will be
needed by an upcoming change.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6007050
2012-04-17 02:35:41 +10:00
Dmitriy Vyukov
4945fc8e40 runtime: speedup GC sweep phase (batch free)
benchmark                             old ns/op    new ns/op    delta
garbage.BenchmarkParser              4370050250   3779668750  -13.51%
garbage.BenchmarkParser-2            3713087000   3628771500   -2.27%
garbage.BenchmarkParser-4            3519755250   3406349750   -3.22%
garbage.BenchmarkParser-8            3386627750   3319144000   -1.99%

garbage.BenchmarkTree                 493585529    408102411  -17.32%
garbage.BenchmarkTree-2               500487176    402285176  -19.62%
garbage.BenchmarkTree-4               473238882    361484058  -23.61%
garbage.BenchmarkTree-8               486977823    368334823  -24.36%

garbage.BenchmarkTree2                 31446600     31203200   -0.77%
garbage.BenchmarkTree2-2               21469000     21077900   -1.82%
garbage.BenchmarkTree2-4               11007600     10899100   -0.99%
garbage.BenchmarkTree2-8                7692400      7032600   -8.58%

garbage.BenchmarkParserPause          241863263    163249450  -32.50%
garbage.BenchmarkParserPause-2        120135418    112981575   -5.95%
garbage.BenchmarkParserPause-4         83411552     64580700  -22.58%
garbage.BenchmarkParserPause-8         51870697     42207244  -18.63%

garbage.BenchmarkTreePause             20940474     13147011  -37.22%
garbage.BenchmarkTreePause-2           20115124     11146715  -44.59%
garbage.BenchmarkTreePause-4           17217584      7486327  -56.52%
garbage.BenchmarkTreePause-8           18258845      7400871  -59.47%

garbage.BenchmarkTree2Pause           174067190    172674190   -0.80%
garbage.BenchmarkTree2Pause-2         131175809    130615761   -0.43%
garbage.BenchmarkTree2Pause-4          95406666     93972047   -1.50%
garbage.BenchmarkTree2Pause-8          86056095     85334952   -0.84%

garbage.BenchmarkParserLastPause      329932000    324790000   -1.56%
garbage.BenchmarkParserLastPause-2    209383000    210456000   +0.51%
garbage.BenchmarkParserLastPause-4    113981000    112921000   -0.93%
garbage.BenchmarkParserLastPause-8     77967000     76625000   -1.72%

garbage.BenchmarkTreeLastPause         29752000     18444000  -38.01%
garbage.BenchmarkTreeLastPause-2       24274000     14766000  -39.17%
garbage.BenchmarkTreeLastPause-4       19565000      8726000  -55.40%
garbage.BenchmarkTreeLastPause-8       21956000     10530000  -52.04%

garbage.BenchmarkTree2LastPause       314411000    311945000   -0.78%
garbage.BenchmarkTree2LastPause-2     214641000    210836000   -1.77%
garbage.BenchmarkTree2LastPause-4     110024000    108943000   -0.98%
garbage.BenchmarkTree2LastPause-8      76873000     70263000   -8.60%

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5991049
2012-04-12 12:01:24 +04:00
Dmitriy Vyukov
a5dc7793c0 runtime: add lock-free stack
This is factored out part of the:
https://golang.org/cl/5279048/
(parallel GC)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5993043
2012-04-12 11:49:25 +04:00
Dave Cheney
d8e9b04ca6 runtime: add interface microbenchmarks
2011 Mac Mini, Core i5 @ 2.3Ghz

BenchmarkConvT2E        50000000                40.4 ns/op
BenchmarkConvT2EBig     20000000               107 ns/op
BenchmarkConvT2I        100000000               28.9 ns/op
BenchmarkConvI2E        500000000                5.93 ns/op
BenchmarkConvI2I        100000000               19.0 ns/op
BenchmarkAssertE2T      100000000               14.1 ns/op
BenchmarkAssertE2TBig   100000000               17.8 ns/op
BenchmarkAssertE2I      100000000               21.3 ns/op
BenchmarkAssertI2T      100000000               14.3 ns/op
BenchmarkAssertI2I      100000000               20.8 ns/op
BenchmarkAssertI2E      500000000                5.58 ns/op

Pandaboard, 2 x Omap4 @ 1.2Ghz

BenchmarkConvT2E        10000000               215 ns/op
BenchmarkConvT2EBig      1000000              3697 ns/op
BenchmarkConvT2I         5000000               666 ns/op
BenchmarkConvI2E        50000000                42.4 ns/op
BenchmarkConvI2I         5000000               489 ns/op
BenchmarkAssertE2T      20000000                90.0 ns/op
BenchmarkAssertE2TBig   20000000                91.6 ns/op
BenchmarkAssertE2I       5000000               515 ns/op
BenchmarkAssertI2T      20000000               124 ns/op
BenchmarkAssertI2I       5000000               517 ns/op
BenchmarkAssertI2E      50000000                47.2 ns/op
BenchmarkAssertE2E      50000000                42.7 ns/op

R=minux.ma, rsc, fullung, bsiegert, dsymonds
CC=golang-dev
https://golang.org/cl/5777048
2012-04-11 22:45:44 +10:00
Joel Sing
8cea1bf102 runtime: update openbsd thread related syscalls to match kernel
Update the threxit and thrsleep syscalls to match the ABI of the
OpenBSD 5.1 kernel. These changes are backwards compatible with
older kernels.

Fixes #3311.

R=golang-dev, rsc, devon.odell
CC=golang-dev
https://golang.org/cl/5777079
2012-04-11 22:02:08 +10:00
Shenghou Ma
1a59e6239c 5l, runtime: remove softfloat emulation code when not used
This leads to ~30kB improvement on code size for ARM machines with VFP/NEON.
Example: go test -c math
       GOARM=5  GOARM=6
  Old: 1884200  1839144
  New: 1884165  1805245
  -:        35    33899

R=rsc, bradfitz, dave, kai.backman
CC=golang-dev
https://golang.org/cl/5975060
2012-04-11 04:11:27 +08:00
Akshat Kumar
7056ec6bfd runtime: fix floating point exception on Plan 9
Change 5660047 moved an FLDCW instruction
that disables invalid operand traps into
runtime·asminit, which is called from
runtime·mstart. Thus, runtime·check is being
called prior to setting the appropriate control bits,
which on any QNaN comparison will cause Plan 9
to take an invalid operand trap. This change loads
the control bits (for Plan 9) prior to runtime·check.
Ideally, this should be done before the QNaN checks
on any system, but possibly other kernels simply
don't ever trap on invalid operands.

R=golang-dev, rminnich
CC=golang-dev, john, rsc
https://golang.org/cl/5939045
2012-04-10 15:14:10 -04:00
Quan Yong Zhai
e133ee9538 runtime: unregister the SIGILL handler after ARM EABI test
Part of issue 3381

R=rsc, minux.ma, dave
CC=golang-dev
https://golang.org/cl/5969064
2012-04-10 15:05:22 -04:00
Russ Cox
3d462449f6 8a, 8l: add PREFETCH instructions
R=ken2
CC=golang-dev
https://golang.org/cl/5992082
2012-04-10 10:09:27 -04:00
Russ Cox
35d260fa4c 6a, 6l: add PREFETCH instructions
R=ken2
CC=golang-dev
https://golang.org/cl/5989073
2012-04-10 10:09:09 -04:00
Joel Sing
098b9dcf2f runtime: block signals during thread creation on openbsd
Block signals during thread creation, otherwise the new thread can
receive a signal prior to initialisation completing.

Fixes #3102.

R=golang-dev, rsc, devon.odell, minux.ma
CC=golang-dev
https://golang.org/cl/5757064
2012-04-10 21:57:05 +10:00
Rob Pike
6849c4db0c runtime.Callers: make documentation match code
It is a bug that Caller and Callers disagree about the offset of the skip
parameter. Document the bug.

R=rsc, dsymonds, r, iant
CC=golang-dev
https://golang.org/cl/5976064
2012-04-10 09:47:57 +10:00
Dmitriy Vyukov
342658bbb6 runtime: preparation for parallel GC
make MHeap.allspans an array instead on a linked-list,
it's required for parallel for

benchmark                              old ns/op    new ns/op    delta

garbage.BenchmarkTree                  494435529    487962705   -1.31%
garbage.BenchmarkTree-2                499652705    485358000   -2.86%
garbage.BenchmarkTree-4                468482117    454093117   -3.07%
garbage.BenchmarkTree-8                488533235    471872470   -3.41%
garbage.BenchmarkTree-16               507835176    492558470   -3.01%

garbage.BenchmarkTree2                  31453900     31404300   -0.16%
garbage.BenchmarkTree2-2                21440600     21477000   +0.17%
garbage.BenchmarkTree2-4                10982000     11117400   +1.23%
garbage.BenchmarkTree2-8                 7544700      7456700   -1.17%
garbage.BenchmarkTree2-16                7049500      6805700   -3.46%

garbage.BenchmarkParser               4448988000   4453264000   +0.10%
garbage.BenchmarkParser-2             4086045000   4057948000   -0.69%
garbage.BenchmarkParser-4             3677365000   3661246000   -0.44%
garbage.BenchmarkParser-8             3517253000   3540190000   +0.65%
garbage.BenchmarkParser-16            3506562000   3463478000   -1.23%

garbage.BenchmarkTreePause              20969784     21100238   +0.62%
garbage.BenchmarkTreePause-2            20215875     20139572   -0.38%
garbage.BenchmarkTreePause-4            17240709     16683624   -3.23%
garbage.BenchmarkTreePause-8            18196386     17639306   -3.06%
garbage.BenchmarkTreePause-16           20621158     20215056   -1.97%

garbage.BenchmarkTree2Pause            173992142    173872380   -0.07%
garbage.BenchmarkTree2Pause-2          131281904    131366666   +0.06%
garbage.BenchmarkTree2Pause-4           93484952     95109619   +1.74%
garbage.BenchmarkTree2Pause-8           88950523     86533333   -2.72%
garbage.BenchmarkTree2Pause-16          86071238     84089190   -2.30%

garbage.BenchmarkParserPause           135815000    135255952   -0.41%
garbage.BenchmarkParserPause-2          92691523     91451428   -1.34%
garbage.BenchmarkParserPause-4          53392190     51611904   -3.33%
garbage.BenchmarkParserPause-8          36059523     35116666   -2.61%
garbage.BenchmarkParserPause-16         30174300     27340600   -9.39%

garbage.BenchmarkTreeLastPause          28420000     29142000   +2.54%
garbage.BenchmarkTreeLastPause-2        23514000     26779000  +13.89%
garbage.BenchmarkTreeLastPause-4        21773000     18660000  -14.30%
garbage.BenchmarkTreeLastPause-8        24072000     21276000  -11.62%
garbage.BenchmarkTreeLastPause-16       25149000     28541000  +13.49%

garbage.BenchmarkTree2LastPause        314491000    313982000   -0.16%
garbage.BenchmarkTree2LastPause-2      214363000    214715000   +0.16%
garbage.BenchmarkTree2LastPause-4      109778000    111115000   +1.22%
garbage.BenchmarkTree2LastPause-8       75390000     74522000   -1.15%
garbage.BenchmarkTree2LastPause-16      70333000     67880000   -3.49%

garbage.BenchmarkParserLastPause       327247000    326815000   -0.13%
garbage.BenchmarkParserLastPause-2     217039000    212529000   -2.08%
garbage.BenchmarkParserLastPause-4     119722000    111535000   -6.84%
garbage.BenchmarkParserLastPause-8      70806000     69613000   -1.68%
garbage.BenchmarkParserLastPause-16     62813000     48009000  -23.57%

R=rsc, r
CC=golang-dev
https://golang.org/cl/5992055
2012-04-09 13:05:43 +04:00
Dmitriy Vyukov
f09e63a2a0 runtime: add memory prefetching to GC
benchmark                              old ns/op    new ns/op    delta

garbage.BenchmarkParser               4448988000   4370531000   -1.76%
garbage.BenchmarkParser-2             4086045000   4023083000   -1.54%
garbage.BenchmarkParser-4             3677365000   3667020000   -0.28%
garbage.BenchmarkParser-8             3517253000   3543946000   +0.76%
garbage.BenchmarkParser-16            3506562000   3512518000   +0.17%

garbage.BenchmarkTree                  494435529    505784058   +2.30%
garbage.BenchmarkTree-2                499652705    502774823   +0.62%
garbage.BenchmarkTree-4                468482117    465713352   -0.59%
garbage.BenchmarkTree-8                488533235    482287000   -1.28%
garbage.BenchmarkTree-16               507835176    500654882   -1.41%

garbage.BenchmarkTree2                  31453900     28804600   -8.42%
garbage.BenchmarkTree2-2                21440600     19065800  -11.08%
garbage.BenchmarkTree2-4                10982000     10009100   -8.86%
garbage.BenchmarkTree2-8                 7544700      6479800  -14.11%
garbage.BenchmarkTree2-16                7049500      6163200  -12.57%

garbage.BenchmarkParserPause           135815000    125360666   -7.70%
garbage.BenchmarkParserPause-2          92691523     84365476   -8.98%
garbage.BenchmarkParserPause-4          53392190     46995809  -11.98%
garbage.BenchmarkParserPause-8          36059523     30998900  -14.03%
garbage.BenchmarkParserPause-16         30174300     27613350   -8.49%

garbage.BenchmarkTreePause              20969784     22568102   +7.62%
garbage.BenchmarkTreePause-2            20215875     20975130   +3.76%
garbage.BenchmarkTreePause-4            17240709     17180666   -0.35%
garbage.BenchmarkTreePause-8            18196386     18205870   +0.05%
garbage.BenchmarkTreePause-16           20621158     20486867   -0.65%

garbage.BenchmarkTree2Pause            173992142    159995285   -8.04%
garbage.BenchmarkTree2Pause-2          131281904    118013714  -10.11%
garbage.BenchmarkTree2Pause-4           93484952     85092666   -8.98%
garbage.BenchmarkTree2Pause-8           88950523     77340809  -13.05%
garbage.BenchmarkTree2Pause-16          86071238     76557952  -11.05%

garbage.BenchmarkParserLastPause       327247000    288205000  -11.93%
garbage.BenchmarkParserLastPause-2     217039000    187336000  -13.69%
garbage.BenchmarkParserLastPause-4     119722000    105069000  -12.24%
garbage.BenchmarkParserLastPause-8      70806000     64755000   -8.55%
garbage.BenchmarkParserLastPause-16     62813000     53486000  -14.85%

garbage.BenchmarkTreeLastPause          28420000     29735000   +4.63%
garbage.BenchmarkTreeLastPause-2        23514000     25427000   +8.14%
garbage.BenchmarkTreeLastPause-4        21773000     19548000  -10.22%
garbage.BenchmarkTreeLastPause-8        24072000     24046000   -0.11%
garbage.BenchmarkTreeLastPause-16       25149000     25291000   +0.56%

garbage.BenchmarkTree2LastPause        314491000    287988000   -8.43%
garbage.BenchmarkTree2LastPause-2      214363000    190616000  -11.08%
garbage.BenchmarkTree2LastPause-4      109778000    100052000   -8.86%
garbage.BenchmarkTree2LastPause-8       75390000     64753000  -14.11%
garbage.BenchmarkTree2LastPause-16      70333000     61484000  -12.58%

FTR, below are result with the empty prefetch function,
that is, single RET but no real prefetching.
It suggests that inlinable PREFETCH is worth pursuing.

benchmark                              old ns/op    new ns/op    delta

garbage.BenchmarkParser               4448988000   4560488000   +2.51%
garbage.BenchmarkParser-2             4086045000   4129728000   +1.07%
garbage.BenchmarkParser-4             3677365000   3728672000   +1.40%
garbage.BenchmarkParser-8             3517253000   3583968000   +1.90%
garbage.BenchmarkParser-16            3506562000   3591414000   +2.42%

garbage.BenchmarkTree                  494435529    499580882   +1.04%
garbage.BenchmarkTree-4                468482117    467387294   -0.23%
garbage.BenchmarkTree-8                488533235    478311117   -2.09%
garbage.BenchmarkTree-2                499652705    499324235   -0.07%
garbage.BenchmarkTree-16               507835176    502005705   -1.15%

garbage.BenchmarkTree2                  31453900     33296800   +5.86%
garbage.BenchmarkTree2-2                21440600     22466400   +4.78%
garbage.BenchmarkTree2-4                10982000     11402700   +3.83%
garbage.BenchmarkTree2-8                 7544700      7476500   -0.90%
garbage.BenchmarkTree2-16                7049500      7338200   +4.10%

garbage.BenchmarkParserPause           135815000    139529142   +2.73%
garbage.BenchmarkParserPause-2          92691523     95229190   +2.74%
garbage.BenchmarkParserPause-4          53392190     53083476   -0.58%
garbage.BenchmarkParserPause-8          36059523     34594800   -4.06%
garbage.BenchmarkParserPause-16         30174300     30063300   -0.37%

garbage.BenchmarkTreePause              20969784     21866920   +4.28%
garbage.BenchmarkTreePause-2            20215875     20731125   +2.55%
garbage.BenchmarkTreePause-4            17240709     17275837   +0.20%
garbage.BenchmarkTreePause-8            18196386     17898777   -1.64%
garbage.BenchmarkTreePause-16           20621158     20662772   +0.20%

garbage.BenchmarkTree2Pause            173992142    184336857   +5.95%
garbage.BenchmarkTree2Pause-2          131281904    138005714   +5.12%
garbage.BenchmarkTree2Pause-4           93484952     98449238   +5.31%
garbage.BenchmarkTree2Pause-8           88950523     89286095   +0.38%
garbage.BenchmarkTree2Pause-16          86071238     89568666   +4.06%

garbage.BenchmarkParserLastPause       327247000    342189000   +4.57%
garbage.BenchmarkParserLastPause-2     217039000    217224000   +0.09%
garbage.BenchmarkParserLastPause-4     119722000    121327000   +1.34%
garbage.BenchmarkParserLastPause-8      70806000     71941000   +1.60%
garbage.BenchmarkParserLastPause-16     62813000     60166000   -4.21%

garbage.BenchmarkTreeLastPause          28420000     27840000   -2.04%
garbage.BenchmarkTreeLastPause-2        23514000     27390000  +16.48%
garbage.BenchmarkTreeLastPause-4        21773000     21414000   -1.65%
garbage.BenchmarkTreeLastPause-8        24072000     21705000   -9.83%
garbage.BenchmarkTreeLastPause-16       25149000     23932000   -4.84%

garbage.BenchmarkTree2LastPause        314491000    332894000   +5.85%
garbage.BenchmarkTree2LastPause-2      214363000    224611000   +4.78%
garbage.BenchmarkTree2LastPause-4      109778000    113976000   +3.82%
garbage.BenchmarkTree2LastPause-8       75390000     67223000  -10.83%
garbage.BenchmarkTree2LastPause-16      70333000     73216000   +4.10%

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5991057
2012-04-07 17:02:44 +04:00
Dmitriy Vyukov
9903d6870f runtime: minor refactoring in preparation for parallel GC
factor sweepspan() out of sweep(), no logical changes

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5991047
2012-04-05 21:02:20 +04:00
Dmitriy Vyukov
d839a809b2 runtime: make GC stats per-M
This is factored out part of:
https://golang.org/cl/5279048/
(Parallel GC)

benchmark                             old ns/op    new ns/op    delta
garbage.BenchmarkParser              3999106750   3975026500   -0.60%
garbage.BenchmarkParser-2            3720553750   3719196500   -0.04%
garbage.BenchmarkParser-4            3502857000   3474980500   -0.80%
garbage.BenchmarkParser-8            3375448000   3341310500   -1.01%
garbage.BenchmarkParserLastPause      329401000    324097000   -1.61%
garbage.BenchmarkParserLastPause-2    208953000    214222000   +2.52%
garbage.BenchmarkParserLastPause-4    110933000    111656000   +0.65%
garbage.BenchmarkParserLastPause-8     71969000     78230000   +8.70%
garbage.BenchmarkParserPause          230808842    197237400  -14.55%
garbage.BenchmarkParserPause-2        123674365    125197595   +1.23%
garbage.BenchmarkParserPause-4         80518525     85710333   +6.45%
garbage.BenchmarkParserPause-8         58310243     56940512   -2.35%
garbage.BenchmarkTree2                 31471700     31289400   -0.58%
garbage.BenchmarkTree2-2               21536800     21086300   -2.09%
garbage.BenchmarkTree2-4               11074700     10880000   -1.76%
garbage.BenchmarkTree2-8                7568600      7351400   -2.87%
garbage.BenchmarkTree2LastPause       314664000    312840000   -0.58%
garbage.BenchmarkTree2LastPause-2     215319000    210815000   -2.09%
garbage.BenchmarkTree2LastPause-4     110698000    108751000   -1.76%
garbage.BenchmarkTree2LastPause-8      75635000     73463000   -2.87%
garbage.BenchmarkTree2Pause           174280857    173147571   -0.65%
garbage.BenchmarkTree2Pause-2         131332714    129665761   -1.27%
garbage.BenchmarkTree2Pause-4          93803095     93422904   -0.41%
garbage.BenchmarkTree2Pause-8          86242333     85146761   -1.27%

R=rsc
CC=golang-dev
https://golang.org/cl/5987045
2012-04-05 20:48:28 +04:00
Dmitriy Vyukov
fd04f05f2f runtime: replace XOR AX, AX with MOV $0, AX
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5985048
2012-04-05 18:59:50 +04:00
Dmitriy Vyukov
4667571619 runtime: add 64-bit atomics
This is factored out part of:
https://golang.org/cl/5279048/
(Parallel GC)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5985047
2012-04-05 18:47:43 +04:00
Dmitriy Vyukov
a28a10e1a2 runtime: remove redundant code
R=rsc
CC=golang-dev
https://golang.org/cl/5987046
2012-04-05 18:37:46 +04:00
Maxim Pimenov
6727a2ad78 runtime: fix a comment
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5975043
2012-04-02 11:27:50 -04:00
Russ Cox
5eb007dede runtime: work around false negative in deadlock detection
Not a complete fix for issue 3342, but fixes the trivial case.
There may still be a race in the instants before and after
a scavenger-induced garbage collection.

Intended to be "obviously safe": a call to runtime·gosched
before main.main is no different than a call to runtime.Gosched
at the beginning of main.main, and it is (or had better be)
safe to call runtime.Gosched at any point during main.

Update #3342.

R=iant
CC=golang-dev
https://golang.org/cl/5919052
2012-03-27 12:22:19 -04:00
Mikio Hara
4c2614c57c undo CL 5844051 / 5d0322034aa8
Breaks closure test when GOMAXPROCS=2 or more.

««« original CL description
runtime: restore deadlock detection in the simplest case.

Fixes #3342.

R=iant, r, dave, rsc
CC=golang-dev, remy
https://golang.org/cl/5844051

»»»

R=rsc
CC=golang-dev
https://golang.org/cl/5924045
2012-03-27 13:05:17 +09:00
Rémy Oudompheng
84bb2547fb runtime: restore deadlock detection in the simplest case.
Fixes #3342.

R=iant, r, dave, rsc
CC=golang-dev, remy
https://golang.org/cl/5844051
2012-03-26 23:06:20 -04:00
Shenghou Ma
4b1933dfb2 runtime: remove unused goc2c.c
Its functionality has been moved into cmd/dist.

R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/5843062
2012-03-21 00:49:45 +08:00
Russ Cox
2e4a035995 runtime: do not handle signals before configuring handler
There was a small window during program initialization
where a signal could come in before the handling mechanisms
were set up to handle it.  Delay the signal-handler installation
until we're ready for the signals.

Fixes #3314.

R=golang-dev, dsymonds, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/5833049
2012-03-15 22:17:54 -04:00
Russ Cox
bd6404a4cc runtime: fix arm build
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/5832047
2012-03-15 17:40:17 -04:00
Russ Cox
9e5db8c90a 5l, 6l, 8l: fix stack split logic for stacks near default segment size
Fixes #3310.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5823051
2012-03-15 15:22:30 -04:00
Shenghou Ma
b2a9079e54 runtime: manage stack by ourselves for badcallback on windows/amd64
This function uses 48-byte of precious non-split stack for every callback
function, and without this CL, it can easily overflow the non-split stack.
I encountered this when trying to enable misc/cgo/test on windows/amd64.

R=rsc
CC=golang-dev
https://golang.org/cl/5784075
2012-03-15 02:24:49 +08:00
Mikio Hara
9eeb90945e runtime/cgo: linux signal masking
Fixes #3314.
Fixes #3101 (again).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5820047
2012-03-14 13:07:25 +09:00
Mikio Hara
1fc9a17c7e runtime/cgo: darwin signal masking
Fixes #3101 (again).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5825043
2012-03-14 12:49:59 +09:00
Alex Brainman
16ade99d9d runtime: fix windows/amd64 exception handler
R=golang-dev, rsc
CC=golang-dev, hectorchu
https://golang.org/cl/5797077
2012-03-12 22:42:55 -04:00
Russ Cox
2d3cc97c9c runtime: fix windows/amd64
Maybe.

TBR=bradfitz
CC=golang-dev
https://golang.org/cl/5754091
2012-03-12 16:48:16 -04:00
Russ Cox
b23691148f runtime: print error on receipt of signal on non-Go thread
It's the best we can do before Go 1.

For issue 3250; not a fix but at least less mysterious.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5797068
2012-03-12 15:55:18 -04:00
Russ Cox
c9e5600f7d runtime: move runtime.write back to C
It may have to switch stacks, since we are calling
a DLL instead of a system call.

badcallback says where it is, because it is being called
on a Windows stack already.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/5782060
2012-03-09 00:10:34 -05:00
Russ Cox
8a1b3d5a57 runtime: fix windows build
Implement runtime·write, like on the other systems,
and also runtime·badcallback, in assembly to reduce
stack footprint.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/5785055
2012-03-08 15:53:11 -05:00
Russ Cox
36aa7d4d14 runtime: inline calls to notok
When a very low-level system call that should never fail
does fail, we call notok, which crashes the program.
Often, we are then left with only the program counter as
information about the crash, and it is in notok.
Instead, inline calls to notok (it is just one instruction
on most systems) so that the program counter will
tell us which system call is unhappy.

R=golang-dev, gri, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/5792048
2012-03-08 14:03:56 -05:00
Russ Cox
9b73238daa cgo, runtime: diagnose callback on non-Go thread
Before:
$ go run x.go
signal 11 (core dumped)
$

After:
$ go run x.go
runtime: cgo callback on thread not created by Go.
signal 11 (core dumped)
$

For issue 3068.
Not a fix, but as much of a fix as we can do before Go 1.

R=golang-dev, rogpeppe, gri
CC=golang-dev
https://golang.org/cl/5781047
2012-03-08 12:12:40 -05:00
Russ Cox
b0beeb1501 runtime: fix freebsd crash
FreeBSD, alone among our supported operating systems,
required that usleep not be interrupted.  Don't require that.

Fixes #3217.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5781045
2012-03-07 15:30:54 -05:00
Rémy Oudompheng
3dcedb620c runtime: try extending arena size in 32-bit allocator.
If it didn't reach the limit, we can try extending the arena
before resorting to random memory mappings and praying for the
kernel to be kind.

Fixes #3173.

R=rsc, rsc
CC=golang-dev
https://golang.org/cl/5725045
2012-03-07 14:21:45 -05:00
Russ Cox
b37841cc06 runtime/pprof: disable test on Leopard 64-bit
Fixes #3234.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5756078
2012-03-07 11:44:54 -05:00
Ian Lance Taylor
aabbcda816 runtime: remove unused runtime·signame and runtime·newError
R=golang-dev
CC=golang-dev
https://golang.org/cl/5756044
2012-03-06 09:07:00 -08:00
Russ Cox
4e110af169 runtime: add Compiler
R=iant, r, gri
CC=golang-dev
https://golang.org/cl/5720073
2012-03-05 22:28:02 -05:00
Rémy Oudompheng
aa1aaee7fd runtime: wait for main goroutine before setting GOMAXPROCS.
Fixes #3182.

R=golang-dev, dvyukov, rsc
CC=golang-dev, remy
https://golang.org/cl/5732057
2012-03-05 16:40:27 -05:00
Russ Cox
c0a842e57f runtime/debug: fix test when source cannot be found
This happens with GOROOT_FINAL=/somewhere/else

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5727069
2012-03-05 16:13:15 -05:00
Russ Cox
dc159fabff runtime: run init on main thread
Fixes #3125.

R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/5714049
2012-03-01 11:48:17 -05:00
Shenghou Ma
357b257cd1 runtime/pprof: skip test on 64-bit Mac OS X 10.6
R=rsc, bsiegert
CC=golang-dev
https://golang.org/cl/5709060
2012-03-01 03:11:37 +08:00
Luuk van Dijk
fb2706113f pkg/runtime: 2 sanity checks in the runtime-gdb.py prettyprinters.
Don't try to print obviously corrupt slices or interfaces.
Doesn't actually solve 3047 or 2818, but seems a good idea anyway.

R=rsc, bsiegert
CC=golang-dev
https://golang.org/cl/5708061
2012-02-29 16:42:25 +01:00
Russ Cox
6e2ae0a12c runtime/pprof: support OS X CPU profiling
Work around profiling kernel bug with signal masks.
Still broken on 64-bit Snow Leopard kernel,
but I think we can ignore that one and let people
upgrade to Lion.

Add new trivial tools addr2line and objdump to take
the place of the GNU tools of the same name, since
those are not installed on OS X.

Adapt pprof to invoke 'go tool addr2line' and
'go tool objdump' if the system tools do not exist.

Clean up disassembly of base register on amd64.

Fixes #2008.

R=golang-dev, bradfitz, mikioh.mikioh, r, iant
CC=golang-dev
https://golang.org/cl/5697066
2012-02-28 16:18:24 -05:00
Russ Cox
102274a30e runtime: size arena to fit in virtual address space limit
For Brad.
Now FreeBSD/386 binaries run on nearlyfreespeech.net.

Fixes #2302.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5700060
2012-02-24 15:28:51 -05:00
Russ Cox
51a84bbfaa runtime: fix arm
signal.test binary passes on my phone; should fix builder

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5694064
2012-02-23 23:10:38 -05:00
Shenghou Ma
1bddfb5203 runtime: check for ARM syscall failures
While we are at it, also update some comments.
    Tested on Linux/ARM builder.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/5696047
2012-02-23 15:43:14 -05:00
Russ Cox
224f05ba88 runtime: darwin signal masking
Fixes #3101 (darwin).

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5693044
2012-02-23 14:44:06 -05:00
Russ Cox
240b1d5b44 runtime: linux signal masking
Fixes #3101 (Linux).

R=golang-dev, bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/5696043
2012-02-23 14:43:58 -05:00
Russ Cox
ebae73bb24 pprof: add Profile type
Makes it possible for client code to maintain its own profiles,
and also reduces the API surface by giving us a type that
models built-in profiles.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5684056
2012-02-22 21:46:12 -05:00
Russ Cox
e4b02bfdc0 runtime: goroutine profile, stack dumps
R=golang-dev, r, r
CC=golang-dev
https://golang.org/cl/5687076
2012-02-22 21:45:01 -05:00
Devon H. O'Dell
b0891060ae runtime: fix FreeBSD signal handling around thread creation
Ignore signals while we are spawning a new thread. Previously, a
signal arriving just before runtime.minit setting up the signal
handler triggers a "double fault" in signal trampolining.
Fixes #3017.

R=rsc, mikioh.mikioh, minux.ma, adg
CC=golang-dev
https://golang.org/cl/5684060
2012-02-22 15:44:09 +11:00
Russ Cox
5bcad92f07 ld: add NOPTRBSS for large, pointer-free uninitialized data
cc: add #pragma textflag to set it
runtime: mark mheap to go into noptr-bss.
        remove special case in garbage collector

Remove the ARM from.flag field created by CL 5687044.
The DUPOK flag was already in p->reg, so keep using that.

Otherwise test/nilptr.go creates a very large binary.
Should fix the arm build.
Diagnosed by minux.ma; replacement for CL 5690044.

R=golang-dev, minux.ma, r
CC=golang-dev
https://golang.org/cl/5686060
2012-02-21 22:08:42 -05:00
Devon H. O'Dell
8542dc0764 runtime: use SYSCALL instead of INT 0x80 in FreeBSD's runtime.osyield on amd64
R=mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/5690062
2012-02-22 11:04:25 +09:00
Russ Cox
fc7ed45b35 runtime: avoid malloc during malloc
A fault during malloc might lead to the program's
first call to findfunc, which would in turn call malloc.
Don't do that.

Fixes #1777.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5689047
2012-02-21 16:36:15 -05:00
Mikio Hara
22c41ff019 runtime: remove an obsolete file
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/5686049
2012-02-21 12:07:38 +09:00
Devon H. O'Dell
dff5535aaa runtime: implement runtime.osyield on FreeBSD 386, amd64
R=rsc, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/5689046
2012-02-21 07:32:20 +09:00
Russ Cox
8a4c2b3cc4 runtime: fix another memory leak
morebuf holds a pc/sp from the last stack split or
reflect.call or panic/recover.  If the pc is a closure,
the reference will keep it from being collected.

moreargp holds a pointer to the arguments from the
last stack split or reflect.call or panic/recover.
Normally it is a stack pointer and thus not of interest,
but in the case of reflect.call it is an allocated argument
list and holds up the arguments to the call.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5674109
2012-02-19 11:05:19 -05:00
Russ Cox
89b075cc90 runtime: fix tiny memory leak
The m->cret word holds the C return value when returning
across a stack split boundary.  It was not being cleared after
use, which means that the return value (if a C function)
or else the value of AX/R0 at the time of the last stack unsplit
was being kept alive longer than necessary.  Clear it.

I think the effect here should be very small, but worth fixing
anyway.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5677092
2012-02-19 00:26:33 -05:00
Russ Cox
03f2289f7e runtime: API
Delete Alloc, Free, Lookup, Semacquire, Semrelease

Fixes #2955.

R=golang-dev, r, bradfitz
CC=golang-dev
https://golang.org/cl/5675093
2012-02-19 00:11:44 -05:00
Gustavo Niemeyer
ce020ffacd runtime: remove use of ?:
Fixes #3061.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5656089
2012-02-17 17:13:16 -02:00
Alex Brainman
b8f465644c runtime: silence warnings
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5656084
2012-02-17 17:05:41 +11:00
David Symonds
3d8ebefbbe runtime: Permit default behaviour of SIGTSTP, SIGTTIN, SIGTTOU.
Fixes #3037.

R=rsc, minux.ma, r, rsc
CC=golang-dev
https://golang.org/cl/5674072
2012-02-17 14:36:40 +11:00
David Symonds
4b171e5040 runtime: rename Cgocalls and Goroutines to NumCgoCall and NumGoroutine, respectively.
Update some other docs too.

Update #2955.

R=rsc
CC=golang-dev
https://golang.org/cl/5676060
2012-02-17 08:49:41 +11:00
Sébastien Paolacci
5c598d3c9f runtime: release unused memory to the OS.
Periodically browse MHeap's freelists for long unused spans and release them if any.

Current hardcoded settings:
        - GC is forced if none occured over the last 2 minutes.
        - spans are handed back after 5 minutes of uselessness.

SysUnused (for Unix) is a wrapper on madvise MADV_DONTNEED on Linux and MADV_FREE on BSDs.

R=rsc, dvyukov, remyoudompheng
CC=golang-dev
https://golang.org/cl/5451057
2012-02-16 13:30:04 -05:00
David du Colombier
1064f3a97b runtime: define NSIG to fix plan 9 build
R=rsc
CC=golang-dev
https://golang.org/cl/5677053
2012-02-15 14:36:20 -05:00
Gustavo Niemeyer
8eee153bc8 runtime: fix grsec support
Changeset 36c9c7810f14 broke support for grsec-patched kernels.
Those do not give back the address requested without MAP_FIXED,
so when verifying an mmap without this flag for success, the
resulting address must not be compared against the requested
address since it may have succeeded at a different location.

R=golang-dev, rsc, gustavo, iant
CC=golang-dev
https://golang.org/cl/5650072
2012-02-14 22:09:02 -02:00
Rémy Oudompheng
2a6e6999a4 runtime, time: accelerate tests in short mode.
before   after
go test -short time                4.144s  1.215s
go test -short runtime             1.315s  0.351s
go test -short -cpu=1,2,4 runtime  4.376s  1.266s

Partially solves issue 3015.

R=golang-dev, r
CC=golang-dev, remy
https://golang.org/cl/5673045
2012-02-14 22:13:19 +01:00
Russ Cox
1707a9977f runtime: on 386, fix FP control word on all threads, not just initial thread
It is possible that Linux and Windows copy the FP control word
from the parent thread when creating a new thread.  Empirically,
Darwin does not.  Reset the FP control world in all cases.

Enable the floating-point strconv test.

Fixes #2917 (again).

R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/5660047
2012-02-14 01:23:15 -05:00
Russ Cox
55a54691f9 runtime: use startpanic so that only one thread handles an incoming SIGQUIT
Typing ^\ delivers the SIGQUIT to all threads, it appears.

R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/5657044
2012-02-13 23:06:21 -05:00
Russ Cox
0995aba983 runtime/debug: fix build
TBR=r
CC=golang-dev
https://golang.org/cl/5661053
2012-02-13 23:05:19 -05:00
Rob Pike
bf2838334c testing: let runtime catch the panic.
It's not as pretty, but it deletes some irrelevant information from the
printout and avoids a dependency.
It also means the test binary will stop if a test panics. That's a feature,
not a bug.
Any output printed by the test appears before the panic traceback.

before:

--- FAIL: TestPanic (0.00 seconds)
        fmt_test.go:19: HI
        testing.go:257: runtime error: index out of range
                /Users/r/go/src/pkg/testing/testing.go:257 (0x23998)
                        _func_003: t.Logf("%s\n%s", err, debug.Stack())
                /Users/r/go/src/pkg/runtime/proc.c:1388 (0x10d2d)
                        panic: reflect·call(d->fn, d->args, d->siz);
                /Users/r/go/src/pkg/runtime/runtime.c:128 (0x119b0)
                        panicstring: runtime·panic(err);
                /Users/r/go/src/pkg/runtime/runtime.c:85 (0x11857)
                        panicindex: runtime·panicstring("index out of range");
                /Users/r/go/src/pkg/fmt/fmt_test.go:21 (0x23d72)
                        TestPanic: a[10]=1
                /Users/r/go/src/pkg/testing/testing.go:264 (0x21b75)
                        tRunner: test.F(t)
                /Users/r/go/src/pkg/runtime/proc.c:258 (0xee9e)
                        goexit: runtime·goexit(void)
FAIL

after:

--- FAIL: TestPanic (0.00 seconds)
        fmt_test.go:19: HI
panic: runtime error: index out of range [recovered]
        panic: (*testing.T) (0xec3b0,0xf8400001c0)

goroutine 2 [running]:
testing._func_003(0x21f5fa8, 0x21f5100, 0x21f5fb8, 0x21f5e88)
        /Users/r/go/src/pkg/testing/testing.go:259 +0x108
----- stack segment boundary -----
fmt_test.TestPanic(0xf8400001c0, 0x27603728)
        /Users/r/go/src/pkg/fmt/fmt_test.go:21 +0x6b
testing.tRunner(0xf8400001c0, 0x18edb8, 0x0, 0x0)
        /Users/r/go/src/pkg/testing/testing.go:264 +0x6f
created by testing.RunTests
        /Users/r/go/src/pkg/testing/testing.go:343 +0x76e

goroutine 1 [chan receive]:
testing.RunTests(0x2000, 0x18edb8, 0x2400000024, 0x100000001, 0x200000001, ...)
        /Users/r/go/src/pkg/testing/testing.go:344 +0x791
testing.Main(0x2000, 0x18edb8, 0x2400000024, 0x188a58, 0x800000008, ...)
        /Users/r/go/src/pkg/testing/testing.go:275 +0x62
main.main()
        /var/folders/++/+++Fn+++6+0++4RjPqRgNE++2Qk/-Tmp-/go-build743922747/fmt/_test/_testmain.go:129 +0x91
exit status 2

R=rsc, dsymonds
CC=golang-dev
https://golang.org/cl/5658048
2012-02-14 14:53:30 +11:00
Alex Brainman
07a2989d17 runtime, syscall, os/signal: fix windows build
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5656048
2012-02-14 13:51:38 +11:00
Shenghou Ma
31ab16f98e fix build for Linux/ARM.
1, IMO, the fatal error "regfree: not a register" from 5g when
         compiling runtime/debug.go is due to gcc miscompile, it doesn't
         show up when compiled with -O0. But I still haven't thought of
         a way to fix this, should all ARM builds be built with -O0?
        2, fixed mksysnum_linux.pl, so zsysnum_linux_arm.go no longer
        needs to be hand-generated.
        3, regen all in pkg syscall for Linux/ARM on Debian 6.0
This CL is somewhat big, I'd like to split it if necessary.

R=rsc, dave
CC=golang-dev
https://golang.org/cl/5659044
2012-02-13 20:16:57 -05:00
Andrew Gerrand
2d53d227f6 runtime, syscall: fix freebsd-386 build
R=rsc
CC=golang-dev
https://golang.org/cl/5659045
2012-02-14 10:04:59 +11:00
Andrew Gerrand
7c2607a91d runtime, syscall: fix freebsd build
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5661047
2012-02-14 09:29:51 +11:00
Shenghou Ma
9a4487458a all: update 'gotest' to 'go test'
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5645099
2012-02-13 13:58:17 -05:00
Russ Cox
35586f718c os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only.  Also, signals
go to everyone who asks, not just one client.

This could plausibly move into package os now
that there are no magic side effects as a result
of the import.

Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)

Tested on darwin,linux 386,amd64.

Fixes #1266.

R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 13:52:37 -05:00
Russ Cox
f735d2d9d3 testing: use runtime/debug to format panics
Among other things, this avoids putting a testing.go:nnn:
prefix on every line of the stack trace.

R=golang-dev, r, dsymonds, r
CC=golang-dev
https://golang.org/cl/5651081
2012-02-12 23:39:40 -05:00
Russ Cox
6a75ece01c runtime: delete Type and implementations (use reflect instead)
unsafe: delete Typeof, Reflect, Unreflect, New, NewArray

Part of issue 2955 and issue 2968.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5650069
2012-02-12 23:26:20 -05:00
Ian Lance Taylor
53e139c7a0 runtime: put lockorder before pollorder in Select memory block.
Otherwise lockorder may be misaligned, since lockorder is a
list of pointers and pollorder is a list of uint16.
Discovered running gccgo (which uses a modified copy of this
code) on SPARC.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5655054
2012-02-10 21:24:14 -08:00
Russ Cox
f91cc3bdbb gc: optimize interface ==, !=
If the values being compared have different concrete types,
then they're clearly unequal without needing to invoke the
actual interface compare routine.  This speeds tests for
specific values, like if err == io.EOF, by about 3x.

benchmark                  old ns/op    new ns/op    delta
BenchmarkIfaceCmp100             843          287  -65.95%
BenchmarkIfaceCmpNil100          184          182   -1.09%

Fixes #2591.

R=ken2
CC=golang-dev
https://golang.org/cl/5651073
2012-02-11 00:19:24 -05:00
Shenghou Ma
bb40196ebf runtime: Linux/ARM: exit early on OABI systems, and give an error message
Fixes #2533.

R=rsc
CC=golang-dev
https://golang.org/cl/5654045
2012-02-09 16:18:21 -05:00
Russ Cox
1253c75cf5 runtime: fix compiler warnings
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5642068
2012-02-09 16:48:52 +11:00
Shenghou Ma
073aeff785 runtime: fix "SysReserve returned unaligned address" bug on 32-bit systems
R=rsc
CC=golang-dev
https://golang.org/cl/5642064
2012-02-09 09:25:10 +11:00
Paul Borman
d37a8b73c5 runtime: drop to 32 bit malloc if 64 bit will not work
On 64 bit UML it is not possible to reserve memory at 0xF8<<32.
Detect when linux cannot use these high virtual memory addresses
and drop back to the 32 bit memory allocator.

R=rsc, cw
CC=golang-dev
https://golang.org/cl/5634050
2012-02-08 14:39:16 -05:00
Russ Cox
5b93fc9da6 runtime, pprof: add profiling of thread creation
Same idea as heap profile: how did each thread get created?
Low memory (256 bytes per OS thread), high reward for
programs that suddenly have many threads running.

Fixes #1477.

R=golang-dev, r, dvyukov
CC=golang-dev
https://golang.org/cl/5639059
2012-02-08 10:33:54 -05:00
Rob Pike
0bd53d2ce0 runtime/cgo: silence warning on windows
It appears to want a * on an indirect function call (assembly language)

TBR=rsc

R=golang-dev
CC=golang-dev
https://golang.org/cl/5643054
2012-02-08 15:26:36 +11:00
Rémy Oudompheng
842c906e2e runtime: delete UpdateMemStats, replace with ReadMemStats(&stats).
Unexports runtime.MemStats and rename MemStatsType to MemStats.
The new accessor requires passing a pointer to a user-allocated
MemStats structure.

Fixes #2572.

R=bradfitz, rsc, bradfitz, gustavo
CC=golang-dev, remy
https://golang.org/cl/5616072
2012-02-06 19:16:26 +01:00
Shenghou Ma
6392b43a15 8a, 8l: implement support for RDTSC instruction.
Also modify runtime/asm_386.s to use it.

R=rsc
CC=golang-dev
https://golang.org/cl/5634043
2012-02-06 12:49:28 -05:00
Russ Cox
facee93a86 runtime: fix float64 hash on 32-bit machine
Multiplying by the low 32 bits was a bad idea
no matter what, but it was a particularly unfortunate
choice because those bits are 0 for small integer values.

Fixes #2883.

R=ken2
CC=golang-dev
https://golang.org/cl/5634047
2012-02-06 11:24:34 -05:00
Russ Cox
48bd13911d runtime: use GOTRACEBACK to decide whether to show runtime frames
Right now, GOTRACEBACK=0 means do not show any stack traces.
Unset means the default behavior (declutter by hiding runtime routines).

This CL makes GOTRACEBACK=2 mean include the runtime routines.
It avoids having to recompile the runtime when you want to see
the runtime in the tracebacks.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5633050
2012-02-06 11:24:14 -05:00
Russ Cox
961f96b5d2 build: delete buildscripts, runtime scripts
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5620059
2012-02-04 00:54:26 -05:00
Russ Cox
b3750ff52d build: rename $GOROOT/bin/go-tool to $GOROOT/bin/tool.
The go- is redundant now that the directory is required
to be inside $GOROOT.  Rob LGTMed the idea.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5618044
2012-02-02 23:32:41 -05:00
Damian Gryski
8e765da941 runtime: add runtime.cputicks() and seed fastrand with it
This patch adds a function to get the current cpu ticks.  This is
deemed to be 'sufficiently random' to use to seed fastrand to mitigate
the algorithmic complexity attacks on the hash table implementation.

On AMD64 we use the RDTSC instruction.  For 386, this instruction,
while valid, is not recognized by 8a so I've inserted the opcode by
hand.  For ARM, this routine is currently stubbed to return a constant
0 value.

Future work: update 8a to recognize RDTSC.

Fixes #2630.

R=rsc
CC=golang-dev
https://golang.org/cl/5606048
2012-02-02 14:09:27 -05:00
Russ Cox
9a15c2186c build: move goapi, quietgcc, cgo, gotype, ebnflint into go-tool
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5552054
2012-01-31 10:38:07 -05:00
Damian Gryski
85aeeadaec runtime: use per-map hash seeds
This patch adds a hash seed to the Hmap struct.  Each seed is
initialized by runtime.fastrand1().  This is the first step of a
solution to issue 2630.  Fastrand1 still needs to be updated to provide
us with actually random bits.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5599046
2012-01-31 00:37:03 -05:00
Russ Cox
2050a9e478 build: remove Make.pkg, Make.tool
Consequently, remove many package Makefiles,
and shorten the few that remain.

gomake becomes 'go tool make'.

Turn off test phases of run.bash that do not work,
flagged with $BROKEN.  Future CLs will restore these,
but this seemed like a big enough CL already.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5601057
2012-01-30 23:43:46 -05:00
Russ Cox
56e6a02490 runtime: fix mkasmh.sh for arm?
The builder is Debian, so maybe running dash,
the shell that time forgot.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5600053
2012-01-30 23:17:11 -05:00
Anthony Martin
bacb1b70f7 runtime: fix mkasmh.h
We weren't properly deleting the various header
files (that were temporarily renamed) if a $CC
for the current $GOARCH didn't exist.  And since
the compiler checks the current directory for
headers before any -I arguments, this had the
unfortunate side effect of including the last
generated headers instead of the correct ones.

R=r, rsc
CC=golang-dev
https://golang.org/cl/5581055
2012-01-30 19:25:40 -08:00
Rob Pike
91cb3489ab go: move compilers into the go-tool directory
Also delete gotest, since it's messy to fix and slated for deletion anyway.
A couple of things outside src can't be tested any more. "go test" will be
fixed and these tests will be re-enabled. They're noisy for now.

Fixes #284.

R=rsc
CC=golang-dev
https://golang.org/cl/5598049
2012-01-30 14:46:31 -08:00
Russ Cox
022aac7883 runtime: fix float64 hash
R=ken2
CC=golang-dev
https://golang.org/cl/5580046
2012-01-30 11:10:59 -05:00
Russ Cox
408f0b1f74 gc, runtime: handle floating point map keys
Fixes #2609.

R=ken2
CC=golang-dev
https://golang.org/cl/5572069
2012-01-26 16:25:07 -05:00
David Symonds
0ae9d812c8 runtime: move NumCPU declaration into debug.go.
R=rsc
CC=golang-dev
https://golang.org/cl/5574060
2012-01-25 14:13:11 +11:00
Shenghou Ma
0ae6084fef build: do not build all C compilers
In order to allow buildscript.sh to generate buildscripts for all
        $GOOS/$GOARCH combinations, we have to generate dummy files for cmd/go.
        Fixes #2586.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/5557050
2012-01-24 15:03:41 -05:00
Shenghou Ma
e021357673 runtime: update out-of-date comment
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5532118
2012-01-22 10:34:17 -08:00
Dmitriy Vyukov
1ff1405cc7 runtime: add type algorithms for zero-sized types
BenchmarkChanSem old=127ns new=78.6ns

R=golang-dev, bradfitz, sameer, rsc
CC=golang-dev
https://golang.org/cl/5558049
2012-01-20 10:32:55 +04:00
Alex Brainman
8d6958fc04 misc/cgo/test: make tests run on windows
- use proper Win64 gcc calling convention when
  calling initcgo on amd64
- increase g0 stack size to 64K on amd64 to make
  it the same as 386
- implement C.sleep
- do not use C.stat, since it is renamed to C._stat by mingw
- use fopen to implement TestErrno, since C.strtol
  always succeeds on windows
- skip TestSetEnv on windows, because os.Setenv
  sets windows process environment, while C.getenv
  inspects internal C runtime variable instead

R=golang-dev, vcc.163, rsc
CC=golang-dev
https://golang.org/cl/5500094
2012-01-20 12:59:44 +11:00
Shenghou Ma
fec7aa952f doc: update out-of-date comments about runtime/cgo
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5532100
2012-01-19 17:13:33 -05:00
Dave Cheney
c354f93b93 runtime: madvise and SysUnused for Darwin
SysUnused is a direct call to madvise MADV_FREE.

R=sebastien.paolacci, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/5531073
2012-01-19 15:51:29 -05:00
Olivier Duperray
e5c1f3870b pkg: Add & fix Copyright of "hand generated" files
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5554064
2012-01-19 10:14:56 -08:00
Shenghou Ma
c30ba7e65a runtime: implement runtime.usleep for FreeBSD/386 and amd64.
R=golang-dev, jsing
CC=golang-dev
https://golang.org/cl/5528106
2012-01-17 03:22:34 +11:00
Maxim Pimenov
0aaf2c2d10 runtime: fix typo in comment
R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/5540059
2012-01-16 18:42:18 +04:00
Dmitriy Vyukov
a03c519a8c effective_go: provide reference to runtime.NumCPU()
R=golang-dev, robert.hencke, r
CC=golang-dev
https://golang.org/cl/5538050
2012-01-12 22:06:50 +04:00
Russ Cox
610757b155 runtime: delete duplicate implementation of pcln walker
It's hard enough to get right once.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5533073
2012-01-11 18:45:32 -08:00
Shenghou Ma
1250f94f93 runtime: runtime.usleep() bugfix on darwin/amd64 and linux/arm
pkg/runtime/sys_darwin_amd64.s: fixes syscall select nr
pkg/runtime/sys_linux_arm.s: uses newselect instead of the now unimplemented
        (old) select, also fixes the wrong div/mod statements in runtime.usleep.
Fixes #2633

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/5504096
2012-01-10 20:48:02 -08:00
Russ Cox
a6d8b483b6 runtime: make garbage collector faster by deleting code
Suggested by Sanjay Ghemawat.  5-20% faster depending
on the benchmark.

Add tree2 garbage benchmark.
Update other garbage benchmarks to build again.

R=golang-dev, r, adg
CC=golang-dev
https://golang.org/cl/5530074
2012-01-10 19:49:11 -08:00
Maxim Pimenov
dcdc309c7c runtime: fix typo in comment
R=golang-dev
CC=golang-dev
https://golang.org/cl/5529059
2012-01-10 12:56:25 -08:00
Russ Cox
5032a7dc0c runtime: distinct panic message for call of nil func value
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5531062
2012-01-10 11:46:57 -08:00
Dave Cheney
bc1f4c1823 runtime: regenerate defs_darwin_{386,amd64}.h
Regenerated under Lion 10.7.2 amd64.
Also tested on Snow Leopart 10.6.8 386.

R=golang-dev, dsymonds, minux.ma
CC=golang-dev
https://golang.org/cl/5533058
2012-01-10 09:48:10 -08:00
Devon H. O'Dell
12bf00054e runtime: enable runtime.ncpu on FreeBSD
R=adg, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/5528062
2012-01-10 17:39:17 +11:00
Russ Cox
6dfdd4c1e3 runtime: add NumCPU
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5528061
2012-01-09 18:45:59 -08:00
Wei Guangjing
9569c67a6b windows: use ArbitraryUserPointer as TLS slot
R=hectorchu, alex.brainman
CC=golang-dev
https://golang.org/cl/5519054
2012-01-09 11:23:07 +11:00
Robert Griesemer
3f1eb94ef2 runtime: fix typo in comment
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5511047
2012-01-04 14:06:54 -08:00
Russ Cox
3800b14071 runtime: delete old asm_*.h if still around
Fixes bug Robert ran into.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5501070
2011-12-22 22:24:34 -05:00
Ian Lance Taylor
5690ddc7fa runtime: don't panic on SIGILL, just crash
R=rsc
CC=golang-dev
https://golang.org/cl/5504067
2011-12-21 15:45:36 -08:00
Russ Cox
3435438948 runtime: silence darwin/386 build warnings
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5502056
2011-12-21 07:23:03 -05:00
Alex Brainman
a462816753 build: multiple fixes to make "go install" work on windows
R=rsc
CC=golang-dev
https://golang.org/cl/5502054
2011-12-21 16:57:44 +11:00
Russ Cox
e83cd7f750 build: a round of fixes
TBR=r
CC=golang-dev
https://golang.org/cl/5503052
2011-12-20 17:54:40 -05:00
Russ Cox
41a6165c03 build: use go command during build
If something goes wrong, it should suffice to set
USE_GO_TOOL=false in env.bash to fall back to the
makefiles.  I will delete the makefiles in January.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5502047
2011-12-20 16:50:13 -05:00
Russ Cox
5d429ad013 runtime/cgo: fix build
Two forgotten renames from last CL.

TBR=r
CC=golang-dev
https://golang.org/cl/5502046
2011-12-20 14:42:58 -05:00
Russ Cox
54fb9940cf go: build runtime/cgo
Also rename -v to -x in the build and install commands,
to match the flag in go test (which we can't change
because -v is taken).  Matches sh -x anyway.

R=r, iant, ality
CC=golang-dev
https://golang.org/cl/5504045
2011-12-20 14:25:23 -05:00
Ian Lance Taylor
21af3d86cd runtime: correct '.' to '·' in comments
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5495097
2011-12-19 20:56:37 -08:00
Russ Cox
55889409f8 runtime: separate out auto-generated files, take 2
This is like the ill-fated CL 5493063 except that
I have written a shell script (autogen.sh) instead of
thinking I could possibly write a correct Makefile.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5496075
2011-12-19 15:51:13 -05:00
Rob Pike
13b26cb36a runtime: use correct traceback file on arm
reported by fred richter

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5494062
2011-12-16 22:52:02 -08:00
Russ Cox
86dcc431e9 runtime: hg revert -r 6ec0a5c12d75
That was the last build that was close to working.
I will try that change again next week.
Make is being very subtle today.

At the reverted-to CL, the ARM traceback appears
to be broken.  I'll look into that next week too.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5492063
2011-12-16 18:50:40 -05:00
Russ Cox
72bdd86835 runtime: fix build on gri's machine
Why it was not failing anywhere else I don't know,
but the Makefile was definitely wrong.  The rules
must not run in parallel.

TBR=r
CC=golang-dev
https://golang.org/cl/5489069
2011-12-16 18:31:09 -05:00
Russ Cox
cfd17a1b57 runtime: fix build
I am looking forward to not supporting two build
systems simultaneously.  Make complains about
a circular dependency still, but I don't understand it
and it's probably not worth the time to figure out.

TBR=r
CC=golang-dev
https://golang.org/cl/5496058
2011-12-16 17:58:53 -05:00
Russ Cox
bd9243da22 runtime: separate out auto-generated files
R=golang-dev, r, r
CC=golang-dev
https://golang.org/cl/5493063
2011-12-16 17:04:32 -05:00
Russ Cox
95907c4752 runtime: fix build
TBR=r
CC=golang-dev
https://golang.org/cl/5493061
2011-12-16 15:46:25 -05:00
Russ Cox
851f30136d runtime: make more build-friendly
Collapse the arch,os-specific directories into the main directory
by renaming xxx/foo.c to foo_xxx.c, and so on.

There are no substantial edits here, except to the Makefile.
The assumption is that the Go tool will #define GOOS_darwin
and GOARCH_amd64 and will make any file named something
like signals_darwin.h available as signals_GOOS.h during the
build.  This replaces what used to be done with -I$(GOOS).

There is still work to be done to make runtime build with
standard tools, but this is a big step.  After this we will have
to write a script to generate all the generated files so they
can be checked in (instead of generated during the build).

R=r, iant, r, lucio.dere
CC=golang-dev
https://golang.org/cl/5490053
2011-12-16 15:33:58 -05:00
Christopher Wedgwood
1e63a4e424 runtime: bump gc 'extra bytes' check
(needed for non-zero GOMAXPROCS)

R=iant, rsc
CC=go.peter.90, golang-dev
https://golang.org/cl/5486059
2011-12-13 21:28:43 -08:00
Ian Lance Taylor
26239417bb runtime: Make gc_test test extra allocated space, not total space.
Testing total space fails for gccgo when not using split
stacks, because then each goroutine has a large stack, and so
the total memory usage is large.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5487068
2011-12-13 15:12:55 -08:00
Russ Cox
dd8dc6f059 math: regularize build
This will be nicer to the automatic tools.
It requires a few more assembly stubs
but fewer Go files.

There are a few instances where it looks like
there are new blobs of code, but they are just
being copied out of deleted files.

There is no new code here.

Suppose you have a portable implementation for Sin
and a 386-specific assembly one.  The old way to
do this was to write three files

sin_decl.go
   func Sin(x float64) float64  // declaration only
sin_386.s
   assembly implementation

sin_port.go
   func Sin(x float64) float64 { ... }  // pure-Go impl

and then link in either sin_decl.go+sin_386.s or
just sin_port.go.  The Makefile actually did the magic
of linking in only the _port.go files for those without
assembly and only the _decl.go files for those with
assembly, or at least some of that magic.

The biggest problem with this, beyond being hard
to explain to the build system, is that once you do
explain it to the build system, godoc knows which
of sin_port.go or sin_decl.go are involved on a given
architecture, and it (correctly) ignores the other.
That means you have to put identical doc comments
in both files.

The new approach, which is more like what we did
in the later packages math/big and sync/atomic,
is to have

sin.go
   func Sin(x float64) float64  // decl only
   func sin(x float64) float64 {...}  // pure-Go impl

sin_386.s
   // assembly for Sin (ignores sin)
sin_amd64.s
   // assembly for Sin: jmp sin
sin_arm.s
   // assembly for Sin: jmp sin

Once we abandon Makefiles we can put all the assembly
stubs in one source file, so the number of files will
actually go down.

Chris asked whether the branches cost anything.
Given that they are branching to pure-Go implementations
that are not typically known for their speed, the single
direct branch is not going to be noticeable.  That is,
it's on the slow path.

An alternative would have been to preserve the old
"only write assembly files when there's an implementation"
and still have just one copy of the declaration of Sin
(and thus one doc comment) by doing:

sin.go
   func Sin(x float64) float64 { return sin(x) }

sin_decl.go
   func sin(x float64) float64 // declaration only
sin_386.s
   // assembly for sin

sin_port.go
   func sin(x float64) float64 { portable code }

In this version everyone would link in sin.go and
then either sin_decl.go+sin_386.s or sin_port.go.

This has an extra function call on all paths, including
the "fast path" to get to assembly, and it triples the
number of Go files involved compared to what I did
in this CL.  On the other hand you don't have to
write assembly stubs.  After starting down this path
I decided that the assembly stubs were the easier
approach.

As for generating the assembly stubs on the fly, much
of the goal here is to eliminate magic from the build
process, so that zero-configuration tools like goinstall
or the new go tool can handle this package.

R=golang-dev, r, cw, iant, r
CC=golang-dev
https://golang.org/cl/5488057
2011-12-13 15:20:12 -05:00
Russ Cox
196b663075 gc: implement == on structs and arrays
To allow these types as map keys, we must fill in
equal and hash functions in their algorithm tables.
Structs or arrays that are "just memory", like [2]int,
can and do continue to use the AMEM algorithm.
Structs or arrays that contain special values like
strings or interface values use generated functions
for both equal and hash.

The runtime helper func runtime.equal(t, x, y) bool handles
the general equality case for x == y and calls out to
the equal implementation in the algorithm table.

For short values (<= 4 struct fields or array elements),
the sequence of elementwise comparisons is inlined
instead of calling runtime.equal.

R=ken, mpimenov
CC=golang-dev
https://golang.org/cl/5451105
2011-12-12 22:22:09 -05:00
Christopher Nielsen
26089cfe25 runtime: Changes to the runtime to support NetBSD.
R=rsc
CC=golang-dev
https://golang.org/cl/5477052
2011-12-12 18:10:11 -05:00
Sébastien Paolacci
e6f5a90b5f runtime: madvise and SysUnused for Linux
SysUnused being a direct call to madvise MADV_DONTNEED.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/5477057
2011-12-12 16:33:13 -05:00
Anthony Martin
1cb254a085 time: fix Plan 9 build for new API
I had to move readFile into sys_$GOOS.go
since syscall.Open takes only two arguments
on Plan 9.

R=lucio.dere, rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/5447061
2011-12-12 16:12:22 -05:00
Christopher Nielsen
728c16cf13 build: Changes to the build infrastructure for NetBSD.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5476048
2011-12-12 15:42:06 -05:00
Lucio De Re
e628144aeb pkg/runtime/Makefile: sorted object module names.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5479060
2011-12-11 09:21:53 -08:00
Dmitriy Vyukov
428062da4e ld: increase default stack size on Windows for cgo
Fixes #2437.

R=rsc, hectorchu, mattn.jp, alex.brainman, jdpoirier, snaury, n13m3y3r
CC=golang-dev
https://golang.org/cl/5371049
2011-12-07 16:53:17 +03:00
Russ Cox
b9ccd077dc runtime: prep for type-specific algorithms
Equality on structs will require arbitrary code for type equality,
so change algorithm in type data from uint8 to table pointer.
In the process, trim top-level map structure from
104/80 bytes (64-bit/32-bit) to 24/12.

Equality on structs will require being able to call code generated
by the Go compiler, and C code has no way to access Go return
values, so change the hash and equal algorithm functions to take
a pointer to a result instead of returning the result.

R=ken
CC=golang-dev
https://golang.org/cl/5453043
2011-12-05 09:40:22 -05:00
Russ Cox
efe3d35fc5 time: new Time, Duration, ZoneInfo types
R=r, bradfitz, gri, dsymonds, iant
CC=golang-dev
https://golang.org/cl/5392041
2011-11-30 11:59:44 -05:00
Alex Brainman
fbdec642a9 runtime: make sure windows/amd64 stack is 16-byte aligned on syscall entry (fixes build)
R=golang-dev, vcc.163
CC=golang-dev
https://golang.org/cl/5445051
2011-11-29 12:57:20 +11:00
Alex Brainman
6d4c18a4af syscall: implement Syscall15
Fixes #2251.

R=golang-dev, rsc
CC=golang-dev, jp
https://golang.org/cl/5440050
2011-11-29 10:24:19 +11:00
Dmitriy Vyukov
a899a467f2 time: fix timer stop
Due to data structure corruption,
some timers could not be removed.
Fixes #2495.

R=golang-dev, adg
CC=golang-dev, mdbrown
https://golang.org/cl/5437060
2011-11-25 14:13:10 +03:00
Anthony Martin
4a2d30e13b runtime: add nanotime for Plan 9
R=paulzhol, rsc, dave, rminnich
CC=golang-dev
https://golang.org/cl/5327063
2011-11-17 22:09:28 -05:00
Alex Brainman
0d37998a06 syscall: make windows build again after d3963c0fca78 change
R=rsc, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/5373097
2011-11-15 12:48:22 -05:00
Russ Cox
94c2536e3f runtime: avoid allocation for make([]T, 0)
R=gri, iant, iant
CC=golang-dev
https://golang.org/cl/5375093
2011-11-15 12:05:25 -05:00
Russ Cox
0acd879c26 syscall: take over env implementation
The environment is needed by package time, which
we want not to depend on os (so that os can use
time.Time), so push down into syscall.

Delete syscall.Sleep, now unnecessary.

The package os environment API is preserved;
it is only the implementation that is moving to syscall.

Delete os.Envs, which was undocumented,
uninitialized on Windows and Plan 9, and
not maintained by Setenv and Clearenv.
Code can call os.Environ instead.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5370091
2011-11-14 14:06:50 -05:00
Dmitriy Vyukov
dc6726b37f runtime: fix timers crash
Timer callbacks occasionally crash
with "sched while holding locks" message.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5381043
2011-11-14 21:59:48 +03:00
Alex Brainman
946647fb45 runtime: fix syscall test to satisfy new error
R=rsc
CC=golang-dev
https://golang.org/cl/5369103
2011-11-14 20:54:47 +11:00
Joel Sing
13dc53055f runtime: remove no longer used enums for openbsd
The code that used these has been moved to lock_sema.c.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5376062
2011-11-13 03:58:24 +11:00
Ian Lance Taylor
3f2d787c2b runtime: remove declarations of nonexistent functions
R=rsc, r
CC=golang-dev
https://golang.org/cl/5369089
2011-11-11 14:30:27 -08:00
Russ Cox
5fc3771b3a gc: remove m[k] = x, false
R=ken2
CC=golang-dev
https://golang.org/cl/5376076
2011-11-11 16:48:25 -05:00
Russ Cox
dd2abe5152 runtime, syscall: convert from godefs to cgo
R=golang-dev, mikioh.mikioh, r
CC=golang-dev
https://golang.org/cl/5348052
2011-11-10 19:08:28 -05:00
Joel Sing
85b7419211 runtime: fix semasleep() duration for openbsd
The timespec passed to thrsleep() needs to be an absolute/realtime
value, so add the current nanotime to ns.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5374048
2011-11-10 11:42:01 -08:00
Mikio Hara
be8025604e runtime: fix freebsd build
R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/5370050
2011-11-10 10:02:24 +09:00
Russ Cox
3b860269ee runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.

It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another.  (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)

Fixes #1644.
Fixes #1731.
Fixes #2190.

R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 15:17:05 -05:00
Dmitriy Vyukov
fbfed49134 cgo: fix g0 stack guard
Fixes crash when cgo consumes more than 8K
of stack and makes a callback.

Fixes #1328.

R=golang-dev, rogpeppe, rsc
CC=golang-dev, mpimenov
https://golang.org/cl/5371042
2011-11-09 23:11:48 +03:00
Ian Lance Taylor
4ac425fcdd runtime: add comments for various functions in proc.c
R=rsc
CC=golang-dev
https://golang.org/cl/5357047
2011-11-08 18:16:25 -08:00
Rob Pike
45e3bcb343 renaming_3: gofix -r go1pkgrename src/pkg/[m-z]*
R=rsc
CC=golang-dev
https://golang.org/cl/5345045
2011-11-08 15:41:54 -08:00
Joel Sing
0e5cd9d3f6 runtime: add timespec definition for freebsd
R=golang-dev, devon.odell
CC=golang-dev
https://golang.org/cl/5340058
2011-11-08 11:43:58 -05:00
Alex Brainman
b776b9e724 runtime: add windows callback tests
Just a copy of cgo callback tests from misc/cgo/test.

R=rsc
CC=golang-dev, hectorchu
https://golang.org/cl/5331062
2011-11-08 16:53:31 +11:00
Russ Cox
1c42db8835 runtime/cgo: fix data declaration to be extern
Otherwise some OS X toolchains complain about the redeclaration
of libcgo_thread_start by multiple object files.  The real definition
is in util.c.

Fixes #2167.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5364045
2011-11-07 13:15:06 -05:00
Joel Sing
a1c622dfea runtime: fix prototype for openbsd thrsleep
- Fix function prototype for thrsleep().
- Provide enums for clock identifiers.
- Provide timespec structure for use with thrsleep().

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/5360042
2011-11-07 11:57:34 -05:00
Alex Brainman
603d80c28d runtime: windows_386 sighandler to use correct g
Fixes #2403.

R=hectorchu
CC=golang-dev
https://golang.org/cl/5309071
2011-11-07 11:00:14 +11:00
Russ Cox
7f5ae484eb runtime: fix linux/arm nanotime?
TBR=r
CC=golang-dev
https://golang.org/cl/5354041
2011-11-04 08:38:10 -04:00
Russ Cox
cb2040b2ab runtime: fix openbsd nanotime?
TBR=r
CC=golang-dev
https://golang.org/cl/5353041
2011-11-04 07:24:39 -04:00
Russ Cox
f437331f80 time: faster Nanoseconds call
runtime knows how to get the time of day
without allocating memory.

R=golang-dev, dsymonds, dave, hectorchu, r, cw
CC=golang-dev
https://golang.org/cl/5297078
2011-11-03 17:35:28 -04:00
Russ Cox
31452a3618 runtime: fix set and not used
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5305087
2011-11-03 17:35:11 -04:00
Russ Cox
965845a86d all: sort imports
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5319072
2011-11-02 15:54:16 -04:00
Dmitriy Vyukov
ee24bfc058 runtime: unify mutex code across OSes
The change introduces 2 generic mutex implementations
(futex- and semaphore-based). Each OS chooses a suitable mutex
implementation and implements few callbacks (e.g. futex wait/wake).
The CL reduces code duplication, extends some optimizations available
only on Linux/Windows to other OSes and provides ground
for futher optimizations. Chan finalizers are finally eliminated.

(Linux/amd64, 8 HT cores)
benchmark                      old      new
BenchmarkChanContended         83.6     77.8 ns/op
BenchmarkChanContended-2       341      328 ns/op
BenchmarkChanContended-4       382      383 ns/op
BenchmarkChanContended-8       390      374 ns/op
BenchmarkChanContended-16      313      291 ns/op

(Darwin/amd64, 2 cores)
benchmark                      old      new
BenchmarkChanContended         159      172 ns/op
BenchmarkChanContended-2       6735     263 ns/op
BenchmarkChanContended-4       10384    255 ns/op
BenchmarkChanCreation          1174     407 ns/op
BenchmarkChanCreation-2        4007     254 ns/op
BenchmarkChanCreation-4        4029     246 ns/op

R=rsc, jsing, hectorchu
CC=golang-dev
https://golang.org/cl/5140043
2011-11-02 16:42:01 +03:00
Russ Cox
492098eb75 all: rename os.Error to error in various non-code contexts
R=adg
CC=golang-dev
https://golang.org/cl/5328062
2011-11-01 22:58:09 -04:00
Russ Cox
eb6929299b src/pkg/[n-z]*: gofix -r error -force=error
R=golang-dev, bsiegert, iant
CC=golang-dev
https://golang.org/cl/5294074
2011-11-01 22:05:34 -04:00
Russ Cox
c14f71c788 runtime: update for error
R=golang-dev, iant, r
CC=golang-dev
https://golang.org/cl/5306075
2011-11-01 21:48:27 -04:00
Russ Cox
d0eaa58b5a runtime/pprof: document OS X being broken
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5307078
2011-10-31 17:50:25 -04:00
Russ Cox
6808da0163 runtime: lock the main goroutine to the main OS thread during init
We only guarantee that the main goroutine runs on the
main OS thread for initialization.  Programs that wish to
preserve that property for main.main can call runtime.LockOSThread.
This is what programs used to do before we unleashed
goroutines during init, so it is both a simple fix and keeps
existing programs working.

R=iant, r, dave, dvyukov
CC=golang-dev
https://golang.org/cl/5309070
2011-10-27 18:04:12 -07:00
Russ Cox
6ed3fa6553 gc: introduce rune
R=ken, r
CC=golang-dev
https://golang.org/cl/5293046
2011-10-25 22:19:39 -07:00
Hector Chu
2572ca2ff2 runtime: include bootstrap m in mcpu accounting
R=rsc, dvyukov
CC=golang-dev
https://golang.org/cl/5307052
2011-10-25 08:35:20 +01:00
Russ Cox
4e7aac5413 reflect: make unsafe use of SliceHeader gc-friendly
Revert workaround in compiler and
revert test for compiler workaround.

Tested that the 386 build continues to fail if
the gc change is made without the reflect change.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5312041
2011-10-18 10:03:37 -04:00
Russ Cox
1d687c742d gc: add delete(m, x) but leave in m[x] = 0, false.
The old m[x] = 0, false syntax will be deleted
in a month or so, once people have had time to
change their code (there is a gofix in a separate CL).

R=ken2
CC=golang-dev
https://golang.org/cl/5265048
2011-10-18 09:41:32 -04:00
Russ Cox
e40d6e066a runtime: random offset for map iteration
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5285042
2011-10-17 18:49:02 -04:00