aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/runtime.h
AgeCommit message (Collapse)Author
2013-06-03runtime: add stackguard0 to GDmitriy Vyukov
This is part of preemptive scheduler. stackguard0 is checked in split stack checks and can be set to StackPreempt. stackguard is not set to StackPreempt (holds the original value). R=golang-dev, daniel.morsing, iant CC=golang-dev https://golang.org/cl/9875043
2013-05-29runtime: make notetsleep() return false if timeout happensDmitriy Vyukov
This is needed for preemptive scheduler, because during stoptheworld we want to wait with timeout and re-preempt M's on timeout. R=golang-dev, remyoudompheng, iant CC=golang-dev https://golang.org/cl/9375043
2013-05-28cmd/5l, cmd/6l, cmd/8l, cmd/gc, runtime: generate and use bitmaps of ↵Carl Shapiro
argument pointer locations With this change the compiler emits a bitmap for each function covering its stack frame arguments area. If an argument word is known to contain a pointer, a bit is set. The garbage collector reads this information when scanning the stack by frames and uses it to ignores locations known to not contain a pointer. R=golang-dev, bradfitz, daniel.morsing, dvyukov, khr, khr, iant, cshapiro CC=golang-dev https://golang.org/cl/9223046
2013-05-28runtime: allocate internal symbol table eagerlyDmitriy Vyukov
we need it for GC anyway. R=golang-dev, khr, dave, khr CC=golang-dev https://golang.org/cl/9728044
2013-05-22runtime: detect deadlocks in programs using cgoDmitriy Vyukov
When cgo is used, runtime creates an additional M to handle callbacks on threads not created by Go. This effectively disabled deadlock detection, which is a right thing, because Go program can be blocked and only serve callbacks on external threads. This also disables deadlock detection under race detector, because it happens to use cgo. With this change the additional M is created lazily on first cgo call. So deadlock detector works for programs that import "C", "net" or "net/http/pprof" but do not use them in fact. Also fixes deadlock detector under race detector. It should be fine to create the M later, because C code can not call into Go before first cgo call, because C code does not know when Go initialization has completed. So a Go program need to call into C first either to create an external thread, or notify a thread created in global ctor that Go initialization has completed. Fixes #4973. Fixes #5475. R=golang-dev, minux.ma, iant CC=golang-dev https://golang.org/cl/9303046
2013-05-20runtime: change PollDesc.fd from int32 to uintptrAlex Brainman
This is in preparation for netpoll windows version. R=golang-dev, bradfitz CC=dvyukov, golang-dev, mikioh.mikioh https://golang.org/cl/9569043
2013-04-06runtime: make CgoMal alloc field void*Ian Lance Taylor
This makes it an unsafe.Pointer in Go so the garbage collector will treat it as a pointer to untyped data, not a pointer to bytes. R=golang-dev, dvyukov CC=golang-dev https://golang.org/cl/8286045
2013-04-06runtime: change Note from union to structDmitriy Vyukov
Unions can break precise GC. Update #5193. R=golang-dev, iant CC=golang-dev https://golang.org/cl/8362046
2013-04-06runtime: change Lock from union to structDmitriy Vyukov
Unions can break precise GC. Update #5193. R=golang-dev, iant CC=golang-dev https://golang.org/cl/8457043
2013-04-06runtime: reset dangling typed pointerDmitriy Vyukov
+untype it because it can point to different types Update #5193. R=golang-dev, iant CC=golang-dev https://golang.org/cl/8454043
2013-04-02runtime: Implement faster equals for strings and bytes.Keith Randall
(amd64) benchmark old ns/op new ns/op delta BenchmarkEqual0 16 6 -63.15% BenchmarkEqual9 22 7 -65.37% BenchmarkEqual32 36 9 -74.91% BenchmarkEqual4K 2187 120 -94.51% benchmark old MB/s new MB/s speedup BenchmarkEqual9 392.22 1134.38 2.89x BenchmarkEqual32 866.72 3457.39 3.99x BenchmarkEqual4K 1872.73 33998.87 18.15x (386) benchmark old ns/op new ns/op delta BenchmarkEqual0 16 5 -63.85% BenchmarkEqual9 22 7 -67.84% BenchmarkEqual32 34 12 -64.94% BenchmarkEqual4K 2196 113 -94.85% benchmark old MB/s new MB/s speedup BenchmarkEqual9 405.81 1260.18 3.11x BenchmarkEqual32 919.55 2631.21 2.86x BenchmarkEqual4K 1864.85 36072.54 19.34x Update #3751 R=bradfitz, r, khr, dave, remyoudompheng, fullung, minux.ma, ality CC=golang-dev https://golang.org/cl/8056043
2013-03-28cmd/ld, runtime: restrict stack root scan to locals and argumentsCarl Shapiro
Updates #5134 R=golang-dev, bradfitz, cshapiro, daniel.morsing, ality, iant CC=golang-dev https://golang.org/cl/8022044
2013-03-25net: band-aid for windows network pollerDmitriy Vyukov
Fixes performance of the current windows network poller with the new scheduler. Gives runtime a hint when GetQueuedCompletionStatus() will block. Fixes #5068. benchmark old ns/op new ns/op delta BenchmarkTCP4Persistent 4004000 33906 -99.15% BenchmarkTCP4Persistent-2 21790 17513 -19.63% BenchmarkTCP4Persistent-4 44760 34270 -23.44% BenchmarkTCP4Persistent-6 45280 43000 -5.04% R=golang-dev, alex.brainman, coocood, rsc CC=golang-dev https://golang.org/cl/7612045
2013-03-21runtime: explicitly remove fd's from epoll waitset before close()Dmitriy Vyukov
Fixes #5061. Current code relies on the fact that fd's are automatically removed from epoll set when closed. However, it is not true. Underlying file description is removed from epoll set only when *all* fd's referring to it are closed. There are 2 bad consequences: 1. Kernel delivers notifications on already closed fd's. 2. The following sequence of events leads to error: - add fd1 to epoll - dup fd1 = fd2 - close fd1 (not removed from epoll since we've dup'ed the fd) - dup fd2 = fd1 (get the same fd as fd1) - add fd1 to epoll = EEXIST So, if fd can be potentially dup'ed of fork'ed, it's necessary to explicitly remove the fd from epoll set. R=golang-dev, bradfitz, dave CC=golang-dev https://golang.org/cl/7870043
2013-03-20runtime: faster hashmap implementation.Keith Randall
Hashtable is arranged as an array of 8-entry buckets with chained overflow. Each bucket has 8 extra hash bits per key to provide quick lookup within a bucket. Table is grown incrementally. Update #3885 Go time drops from 0.51s to 0.34s. R=r, rsc, m3b, dave, bradfitz, khr, ugorji, remyoudompheng CC=golang-dev https://golang.org/cl/7504044
2013-03-15runtime: accept GOTRACEBACK=crash to mean 'crash after panic'Russ Cox
This provides a way to generate core dumps when people need them. The settings are: GOTRACEBACK=0 no traceback on panic, just exit GOTRACEBACK=1 default - traceback on panic, then exit GOTRACEBACK=2 traceback including runtime frames on panic, then exit GOTRACEBACK=crash traceback including runtime frames on panic, then crash Fixes #3257. R=golang-dev, devon.odell, r, daniel.morsing, ality CC=golang-dev https://golang.org/cl/7666044
2013-03-15os/signal: add Stop, be careful about SIGHUPRuss Cox
Fixes #4268. Fixes #4491. R=golang-dev, nightlyone, fullung, r CC=golang-dev https://golang.org/cl/7546048
2013-03-14runtime: revert UseSpanType back to 1Dmitriy Vyukov
R=golang-dev CC=golang-dev https://golang.org/cl/7812043
2013-03-14runtime: integrated network poller for darwinDmitriy Vyukov
vs tip: benchmark old ns/op new ns/op delta BenchmarkTCP4Persistent 67786 33175 -51.06% BenchmarkTCP4Persistent-2 49085 31227 -36.38% BenchmarkTCP4PersistentTimeout 69265 32565 -52.98% BenchmarkTCP4PersistentTimeout-2 49217 32588 -33.79% vs old scheduler: benchmark old ns/op new ns/op delta BenchmarkTCP4Persistent 63517 33175 -47.77% BenchmarkTCP4Persistent-2 54760 31227 -42.97% BenchmarkTCP4PersistentTimeout 63234 32565 -48.50% BenchmarkTCP4PersistentTimeout-2 56956 32588 -42.78% R=golang-dev, bradfitz, devon.odell, mikioh.mikioh, iant, rsc CC=golang-dev, pabuhr https://golang.org/cl/7569043
2013-03-12runtime: faster & safer hash functionKeith Randall
Uses AES hardware instructions on 386/amd64 to implement a fast hash function. Incorporates a random key to thwart hash collision DOS attacks. Depends on CL#7548043 for new assembly instructions. Update #3885 Helps some by making hashing faster. Go time drops from 0.65s to 0.51s. R=rsc, r, bradfitz, remyoudompheng, khr, dsymonds, minux.ma, elias.naur CC=golang-dev https://golang.org/cl/7543043
2013-03-12runtime: add network polling support into schedulerDmitriy Vyukov
This is a part of the bigger change that moves network poller into runtime: https://golang.org/cl/7326051/ R=golang-dev, bradfitz, mikioh.mikioh, rsc CC=golang-dev https://golang.org/cl/7448048
2013-03-12runtime: fix deadlock detector false negativeDmitriy Vyukov
The issue was that scvg is assigned *after* the scavenger goroutine is started, so when the scavenger calls entersyscall() the g==scvg check can fail. Fixes #5025. R=golang-dev, iant CC=golang-dev https://golang.org/cl/7629045
2013-03-10runtime: fix misaligned 64-bit atomicDmitriy Vyukov
Fixes #4869. Fixes #5007. Update #5005. R=golang-dev, 0xe2.0x9a.0x9b, bradfitz CC=golang-dev https://golang.org/cl/7534044
2013-03-09runtime: fix integer overflow in amd64 memmove.Rémy Oudompheng
Fixes #4981. R=bradfitz, fullung, rsc, minux.ma CC=golang-dev https://golang.org/cl/7474047
2013-03-08syscall: Plan 9: use lightweight errstr in entersyscall modeAkshat Kumar
Change 231af8ac63aa (CL 7314062) made runtime.enteryscall() set m->mcache = nil, which means that we can no longer use syscall.errstr in syscall.Syscall and syscall.Syscall6, since it requires a new buffer to be allocated for holding the error string. Instead, we use pre-allocated per-M storage to hold error strings from syscalls made while in entersyscall mode, and call runtime.findnull to calculate the lengths. Fixes #4994. R=rsc, rminnich, ality, dvyukov, rminnich, r CC=golang-dev https://golang.org/cl/7567043
2013-03-05undo CL 7301062 / 9742f722b558Russ Cox
broke arm garbage collector traceback_arm fails with a missing pc. It needs CL 7494043. But that only makes the build break later, this time with "invalid freelist". Roll back until it can be fixed correctly. ««« original CL description runtime: restrict stack root scan to locals and arguments R=rsc CC=golang-dev https://golang.org/cl/7301062 »»» R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/7493044
2013-03-05runtime: add atomic xchg64Dmitriy Vyukov
It will be handy for network poller. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7429048
2013-03-05runtime: declare addtimer/deltimer in runtime.hDmitriy Vyukov
In preparation for integrated network poller (https://golang.org/cl/7326051), this is required to handle deadlines. R=golang-dev, remyoudompheng, rsc CC=golang-dev https://golang.org/cl/7446047
2013-03-04runtime: restrict stack root scan to locals and argumentsCarl Shapiro
R=rsc CC=golang-dev https://golang.org/cl/7301062
2013-03-01runtime: add atomics to fix armRuss Cox
R=golang-dev, minux.ma CC=golang-dev https://golang.org/cl/7429046
2013-03-01runtime: start all threads with runtime.mstartRuss Cox
Putting the M initialization in multiple places will not scale. Various code assumes mstart is the start already. Make it so. R=golang-dev, devon.odell CC=golang-dev https://golang.org/cl/7420048
2013-03-01runtime: more build fixingRuss Cox
Move the mstartfn into its own field. Simpler, more likely to be correct. R=golang-dev, devon.odell CC=golang-dev https://golang.org/cl/7414046
2013-03-01runtime: fix new scheduler on freebsd, windowsRuss Cox
R=devon.odell CC=golang-dev https://golang.org/cl/7443046
2013-03-01runtime: improved schedulerDmitriy Vyukov
Distribute runnable queues, memory cache and cache of dead G's per processor. Faster non-blocking syscall enter/exit. More conservative worker thread blocking/unblocking. R=dave, bradfitz, remyoudompheng, rsc CC=golang-dev https://golang.org/cl/7314062
2013-02-27runtime: more changes in preparation to the new schedulerDmitriy Vyukov
add per-P cache of dead G's add global runnable queue (not used for now) add list of idle P's (not used for now) R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7397061
2013-02-25runtime: precise garbage collection of channelsJan Ziak
This changeset adds a mostly-precise garbage collection of channels. The garbage collection support code in the linker isn't recognizing channel types yet. Fixes issue http://stackoverflow.com/questions/14712586/memory-consumption-skyrocket R=dvyukov, rsc, bradfitz CC=dave, golang-dev, minux.ma, remyoudompheng https://golang.org/cl/7307086
2013-02-23runtime: implement local work queues (in preparation for new scheduler)Dmitriy Vyukov
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7402047
2013-02-22cmd/6g, cmd/8g: switch to DX for indirect call blockRuss Cox
runtime: add context argument to gogocall Too many other things use AX, and at least one (stack zeroing) cannot be moved onto a different register. Use the less special DX instead. Preparation for step 2 of http://golang.org/s/go11func. Nothing interesting here, just split out so that we can see it's correct before moving on. R=ken2 CC=golang-dev https://golang.org/cl/7395050
2013-02-21cmd/gc, reflect, runtime: switch to indirect func value representationRuss Cox
Step 1 of http://golang.org/s/go11func. R=golang-dev, r, daniel.morsing, remyoudompheng CC=golang-dev https://golang.org/cl/7393045
2013-02-21cmd/5g, cmd/5l, cmd/6l, cmd/8l, cmd/gc, cmd/ld, runtime: accurate args and ↵Carl Shapiro
locals information Previously, the func structure contained an inaccurate value for the args member and a 0 value for the locals member. This change populates the func structure with args and locals values computed by the compiler. The number of args was already available in the ATEXT instruction. The number of locals is now passed through in the new ALOCALS instruction. This change also switches the unit of args and locals to be bytes, just like the frame member, instead of 32-bit words. R=golang-dev, bradfitz, cshapiro, dave, rsc CC=golang-dev https://golang.org/cl/7399045
2013-02-21runtime: split minit() to mpreinit() and minit()Dmitriy Vyukov
mpreinit() is called on the parent thread and with mcache (can allocate memory), minit() is called on the child thread and can not allocate memory. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7389043
2013-02-20runtime: allow cgo callbacks on non-Go threadsRuss Cox
Fixes #4435. R=golang-dev, iant, alex.brainman, minux.ma, dvyukov CC=golang-dev https://golang.org/cl/7304104
2013-02-20runtime: introduce entersyscallblock()Dmitriy Vyukov
In preparation for the new scheduler. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/7386044
2013-02-19runtime: add conversion specifier to printf for char valuesCarl Shapiro
R=r, golang-dev CC=golang-dev https://golang.org/cl/7327053
2013-02-15runtime: fix build on linuxRuss Cox
In addition to the compile failure fixed in signal*.c, preserving the signal mask led to very strange crashes. Testing shows that looking for SIG_IGN is all that matters to get along with nohup, so reintroduce sigset_zero instead of trying to preserve the signal mask. TBR=iant CC=golang-dev https://golang.org/cl/7323067
2013-02-15runtime: fix running under nohupRuss Cox
There are two ways nohup(1) might be implemented: it might mask away the signal, or it might set the handler to SIG_IGN, both of which are inherited across fork+exec. So two fixes: * Make sure to preserve the inherited signal mask at minit instead of clearing it. * If the SIGHUP handler is SIG_IGN, leave it that way. Fixes #4491. R=golang-dev, mikioh.mikioh, iant CC=golang-dev https://golang.org/cl/7308102
2013-02-06runtime/race: switch to explicit race context instead of goroutine id'sDmitriy Vyukov
Removes limit on maximum number of goroutines ever existed. code.google.com/p/goexecutor tests now pass successfully. Also slightly improves performance. Before: $ time ./flate.test -test.short real 0m9.314s After: $ time ./flate.test -test.short real 0m8.958s Fixes #4286. The runtime is built from llvm rev 174312. R=rsc CC=golang-dev https://golang.org/cl/7218044
2013-02-01runtime: cgo-related fixesRuss Cox
* Separate internal and external LockOSThread, for cgo safety. * Show goroutine that made faulting cgo call. * Never start a panic due to a signal caused by a cgo call. Fixes #3774. Fixes #3775. Fixes #3797. R=golang-dev, iant CC=golang-dev https://golang.org/cl/7228081
2013-01-30runtime: local allocation in mprof.gocJan Ziak
Binary data in mprof.goc may prevent the garbage collector from freeing memory blocks. This patch replaces all calls to runtime·mallocgc() with calls to an allocator private to mprof.goc, thus making the private memory invisible to the garbage collector. The addrhash variable is moved outside of the .bss section. R=golang-dev, dvyukov, rsc, minux.ma CC=dave, golang-dev, remyoudompheng https://golang.org/cl/7135063
2013-01-30runtime: add support for panic/recover in Plan 9 note handlerAkshat Kumar
This change also resolves some issues with note handling: we now make sure that there is enough room at the bottom of every goroutine to execute the note handler, and the `exitstatus' is no longer a global entity, which resolves some race conditions. R=rminnich, npe, rsc, ality CC=golang-dev https://golang.org/cl/6569068