aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/runtime.h
AgeCommit message (Collapse)Author
2013-01-29runtime: dump the full stack of a throwing goroutineDmitriy Vyukov
Useful for debugging of runtime bugs. + Do not print "stack segment boundary" unless GOTRACEBACK>1. + Do not traceback system goroutines unless GOTRACEBACK>1. R=rsc, minux.ma CC=golang-dev https://golang.org/cl/7098050
2013-01-26runtime: avoid defining the same variable in more than one translation unitShenghou Ma
For gccgo runtime and Darwin where -fno-common is the default. R=iant, dave CC=golang-dev https://golang.org/cl/7094061
2013-01-10runtime: less aggressive per-thread stack segment cachingDmitriy Vyukov
Introduce global stack segment cache and limit per-thread cache size. This greatly reduces StackSys memory on workloads that create lots of threads. benchmark old ns/op new ns/op delta BenchmarkStackGrowth 665 656 -1.35% BenchmarkStackGrowth-2 333 328 -1.50% BenchmarkStackGrowth-4 224 172 -23.21% BenchmarkStackGrowth-8 124 91 -26.13% BenchmarkStackGrowth-16 82 47 -41.94% BenchmarkStackGrowth-32 73 40 -44.79% BenchmarkStackGrowthDeep 97231 94391 -2.92% BenchmarkStackGrowthDeep-2 47230 58562 +23.99% BenchmarkStackGrowthDeep-4 24993 49356 +97.48% BenchmarkStackGrowthDeep-8 15105 30072 +99.09% BenchmarkStackGrowthDeep-16 10005 15623 +56.15% BenchmarkStackGrowthDeep-32 12517 13069 +4.41% TestStackMem#1,MB 310 12 -96.13% TestStackMem#2,MB 296 14 -95.27% TestStackMem#3,MB 479 14 -97.08% TestStackMem#1,sec 3.22 2.26 -29.81% TestStackMem#2,sec 2.43 2.15 -11.52% TestStackMem#3,sec 2.50 2.38 -4.80% R=sougou, no.smile.face, rsc CC=golang-dev, msolomon https://golang.org/cl/7029044
2013-01-04runtime: always incorporate hash seed at start of hash computationIan Lance Taylor
Otherwise we can get predictable collisions. R=golang-dev, dave, patrick, rsc CC=golang-dev https://golang.org/cl/7051043
2012-12-22runtime: aggregate defer allocationsRuss Cox
benchmark old ns/op new ns/op delta BenchmarkDefer 165 113 -31.52% BenchmarkDefer10 155 103 -33.55% BenchmarkDeferMany 216 158 -26.85% benchmark old allocs new allocs delta BenchmarkDefer 1 0 -100.00% BenchmarkDefer10 1 0 -100.00% BenchmarkDeferMany 1 0 -100.00% benchmark old bytes new bytes delta BenchmarkDefer 64 0 -100.00% BenchmarkDefer10 64 0 -100.00% BenchmarkDeferMany 64 66 3.12% Fixes #2364. R=ken2 CC=golang-dev https://golang.org/cl/7001051
2012-12-19runtime: use "mp" and "gp" instead of "m" and "g" for local variable name to ↵Jingcheng Zhang
avoid confusion with the global "m" and "g". R=golang-dev, minux.ma, rsc CC=bradfitz, golang-dev https://golang.org/cl/6939064
2012-11-27runtime: use reflect·call() to enter the function gc()Jan Ziak
Garbage collection code (to be merged later) is calling functions which have many local variables. This increases the probability that the stack capacity won't be big enough to hold the local variables. So, start gc() on a bigger stack to eliminate a potentially large number of calls to runtime·morestack(). R=rsc, remyoudompheng, dsymonds, minux.ma, iant, iant CC=golang-dev https://golang.org/cl/6846044
2012-11-10runtime, runtime/cgo: track memory allocated by non-Go codeIan Lance Taylor
Otherwise a poorly timed GC can collect the memory before it is returned to the Go program. R=golang-dev, dave, dvyukov, minux.ma CC=golang-dev https://golang.org/cl/6819119
2012-11-01runtime: move Itab to runtime.hJan Ziak
The 'type' field of Itab will be used by the garbage collector. R=rsc CC=golang-dev https://golang.org/cl/6815059
2012-10-26runtime: switch to 64-bit goroutine idsDmitriy Vyukov
Fixes #4275. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6759053
2012-10-21runtime: store types of allocated objectsJan Ziak
R=rsc CC=golang-dev https://golang.org/cl/6569057
2012-10-19runtime: update comment for the "extern register" variables g and m.Nigel Tao
R=rsc, minux.ma, ality CC=dave, golang-dev https://golang.org/cl/6620050
2012-10-07race: runtime changesDmitriy Vyukov
This is a part of a bigger change that adds data race detection feature: https://golang.org/cl/6456044 R=rsc CC=gobot, golang-dev https://golang.org/cl/6535050
2012-10-06pprof: add goroutine blocking profilingDmitriy Vyukov
The profiler collects goroutine blocking information similar to Google Perf Tools. You may see an example of the profile (converted to svg) attached to http://code.google.com/p/go/issues/detail?id=3946 The public API changes are: +pkg runtime, func BlockProfile([]BlockProfileRecord) (int, bool) +pkg runtime, func SetBlockProfileRate(int) +pkg runtime, method (*BlockProfileRecord) Stack() []uintptr +pkg runtime, type BlockProfileRecord struct +pkg runtime, type BlockProfileRecord struct, Count int64 +pkg runtime, type BlockProfileRecord struct, Cycles int64 +pkg runtime, type BlockProfileRecord struct, embedded StackRecord R=rsc, dave, minux.ma, r CC=gobot, golang-dev, r, remyoudompheng https://golang.org/cl/6443115
2012-09-24build: make int 64 bits on amd64Russ Cox
The assembly offsets were converted mechanically using code.google.com/p/rsc/cmd/asmlint. The instruction changes were done by hand. Fixes #2188. R=iant, r, bradfitz, remyoudompheng CC=golang-dev https://golang.org/cl/6550058
2012-09-24runtime: add types to MSpanJan Ziak
R=rsc CC=golang-dev https://golang.org/cl/6554060
2012-09-24runtime: prepare for 64-bit intsRuss Cox
This CL makes the runtime understand that the type of the len or cap of a map, slice, or string is 'int', not 'int32', and it is also careful to distinguish between function arguments and results of type 'int' vs type 'int32'. In the runtime, the new typedefs 'intgo' and 'uintgo' refer to Go int and uint. The C types int and uint continue to be unavailable (cause intentional compile errors). This CL does not change the meaning of int, but it should make the eventual change of the meaning of int on amd64 a bit smoother. Update #2188. R=iant, r, dave, remyoudompheng CC=golang-dev https://golang.org/cl/6551067
2012-09-21runtime: fix mmap commentsShenghou Ma
We only pass lower 32 bits of file offset to asm routine. R=r, dave, rsc CC=golang-dev https://golang.org/cl/6499118
2012-09-18runtime: refactor goroutine blockingDmitriy Vyukov
The change is a preparation for the new scheduler. It introduces runtime.park() function, that will atomically unlock the mutex and park the goroutine. It will allow to remove the racy readyonstop flag that is difficult to implement w/o the global scheduler mutex. R=rsc, remyoudompheng, dave CC=golang-dev https://golang.org/cl/6501077
2012-09-17cmd/ld: fix compilation when GOARCH != GOHOSTARCHJan Ziak
R=rsc, dave, minux.ma CC=golang-dev https://golang.org/cl/6493123
2012-08-31runtime: add vdso support for linux/amd64. Fixes issue 1933.Ivan Krasin
R=iant, imkrasin, krasin, iant, minux.ma, rsc, nigeltao, r, fullung CC=golang-dev https://golang.org/cl/6454046
2012-08-07runtime: inline several float64 routines to speed up complex128 divisionShenghou Ma
Depends on CL 6197045. Result obtained on Core i7 620M, Darwin/amd64: benchmark old ns/op new ns/op delta BenchmarkComplex128DivNormal 57 28 -50.78% BenchmarkComplex128DivNisNaN 49 15 -68.90% BenchmarkComplex128DivDisNaN 49 15 -67.88% BenchmarkComplex128DivNisInf 40 12 -68.50% BenchmarkComplex128DivDisInf 33 13 -61.06% Result obtained on Core i7 620M, Darwin/386: benchmark old ns/op new ns/op delta BenchmarkComplex128DivNormal 89 50 -44.05% BenchmarkComplex128DivNisNaN 307 802 +161.24% BenchmarkComplex128DivDisNaN 309 788 +155.02% BenchmarkComplex128DivNisInf 278 237 -14.75% BenchmarkComplex128DivDisInf 46 22 -52.46% Result obtained on 700MHz OMAP4460, Linux/ARM: benchmark old ns/op new ns/op delta BenchmarkComplex128DivNormal 1557 465 -70.13% BenchmarkComplex128DivNisNaN 1443 220 -84.75% BenchmarkComplex128DivDisNaN 1481 218 -85.28% BenchmarkComplex128DivNisInf 952 216 -77.31% BenchmarkComplex128DivDisInf 861 231 -73.17% The 386 version has a performance regression, but as we have decided to use SSE2 instead of x87 FPU for 386 too (issue 3912), I won't address this issue. R=dsymonds, mchaten, iant, dave, mtj, rsc, r CC=golang-dev https://golang.org/cl/6024045
2012-07-04runtime: move panic/defer/recover-related stuff to a separate fileDmitriy Vyukov
Move panic/defer/recover-related stuff from proc.c/runtime.c to a new file panic.c. No semantic changes. proc.c is 1800+ LOC and is a bit difficult to work with. R=golang-dev, dave, r CC=golang-dev https://golang.org/cl/6343071
2012-07-01runtime: add freemcache() functionDmitriy Vyukov
It will be required for scheduler that maintains GOMAXPROCS MCache's. R=golang-dev, r CC=golang-dev https://golang.org/cl/6350062
2012-05-30runtime: update field types in preparation for GC changesJan Ziak
R=rsc, remyoudompheng, minux.ma, ality CC=golang-dev https://golang.org/cl/6242061
2012-05-30runtime: handle windows exceptions, even in cgo programsAlex Brainman
Fixes #3543. R=golang-dev, kardianos, rsc CC=golang-dev, hectorchu, vcc.163 https://golang.org/cl/6245063
2012-05-29runtime: replace runtime·rnd function with ROUND macroRuss Cox
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-15runtime: refactor helpgc functionality in preparation for parallel GCDmitriy Vyukov
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-11runtime: add parallel for algorithmDmitriy Vyukov
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-04-12runtime: add lock-free stackDmitriy Vyukov
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-05runtime: make GC stats per-MDmitriy Vyukov
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-05runtime: add 64-bit atomicsDmitriy Vyukov
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-03-06runtime: remove unused runtime·signame and runtime·newErrorIan Lance Taylor
R=golang-dev CC=golang-dev https://golang.org/cl/5756044
2012-02-28runtime/pprof: support OS X CPU profilingRuss Cox
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-24runtime: size arena to fit in virtual address space limitRuss Cox
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-22runtime: goroutine profile, stack dumpsRuss Cox
R=golang-dev, r, r CC=golang-dev https://golang.org/cl/5687076
2012-02-17runtime: Permit default behaviour of SIGTSTP, SIGTTIN, SIGTTOU.David Symonds
Fixes #3037. R=rsc, minux.ma, r, rsc CC=golang-dev https://golang.org/cl/5674072
2012-02-14runtime: on 386, fix FP control word on all threads, not just initial threadRuss Cox
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-14runtime, syscall, os/signal: fix windows buildAlex Brainman
R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5656048
2012-02-13os/signal: selective signal handlingRuss Cox
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-12runtime: delete Type and implementations (use reflect instead)Russ Cox
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-08runtime, pprof: add profiling of thread creationRuss Cox
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-02runtime: add runtime.cputicks() and seed fastrand with itDamian Gryski
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-01-26gc, runtime: handle floating point map keysRuss Cox
Fixes #2609. R=ken2 CC=golang-dev https://golang.org/cl/5572069
2012-01-20runtime: add type algorithms for zero-sized typesDmitriy Vyukov
BenchmarkChanSem old=127ns new=78.6ns R=golang-dev, bradfitz, sameer, rsc CC=golang-dev https://golang.org/cl/5558049
2012-01-19doc: update out-of-date comments about runtime/cgoShenghou Ma
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5532100
2011-12-20build: a round of fixesRuss Cox
TBR=r CC=golang-dev https://golang.org/cl/5503052
2011-12-16runtime: make more build-friendlyRuss Cox
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-12gc: implement == on structs and arraysRuss Cox
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-05runtime: prep for type-specific algorithmsRuss Cox
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