aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/runtime.c
AgeCommit message (Collapse)Author
2011-08-22runtime: simplify stack tracesRuss Cox
Make the stack traces more readable for new Go programmers while preserving their utility for old hands. - Change status number [4] to string. - Elide frames in runtime package (internal details). - Swap file:line and arguments. - Drop 'created by' for main goroutine. - Show goroutines in order of allocation: implies main goroutine first if nothing else. There is no option to get the extra frames back. Uncomment 'return 1' at the bottom of symtab.c. $ 6.out throw: all goroutines are asleep - deadlock! goroutine 1 [chan send]: main.main() /Users/rsc/g/go/src/pkg/runtime/x.go:22 +0x8a goroutine 2 [select (no cases)]: main.sel() /Users/rsc/g/go/src/pkg/runtime/x.go:11 +0x18 created by main.main /Users/rsc/g/go/src/pkg/runtime/x.go:19 +0x23 goroutine 3 [chan receive]: main.recv(0xf8400010a0, 0x0) /Users/rsc/g/go/src/pkg/runtime/x.go:15 +0x2e created by main.main /Users/rsc/g/go/src/pkg/runtime/x.go:20 +0x50 goroutine 4 [chan receive (nil chan)]: main.recv(0x0, 0x0) /Users/rsc/g/go/src/pkg/runtime/x.go:15 +0x2e created by main.main /Users/rsc/g/go/src/pkg/runtime/x.go:21 +0x66 $ $ 6.out index panic: runtime error: index out of range goroutine 1 [running]: main.main() /Users/rsc/g/go/src/pkg/runtime/x.go:25 +0xb9 $ $ 6.out nil panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x0 pc=0x22ca] goroutine 1 [running]: main.main() /Users/rsc/g/go/src/pkg/runtime/x.go:28 +0x211 $ $ 6.out panic panic: panic goroutine 1 [running]: main.main() /Users/rsc/g/go/src/pkg/runtime/x.go:30 +0x101 $ R=golang-dev, qyzhai, n13m3y3r, r CC=golang-dev https://golang.org/cl/4907048
2011-08-08runtime: add more specialized type algorithmsDmitriy Vyukov
The change adds specialized type algorithms for slices and types of size 8/16/32/64/128. It significantly accelerates chan and map operations for most builtin types as well as user structs. benchmark old,ns/op new,ns/op BenchmarkChanUncontended 226 94 (on Intel Xeon E5620, 2.4GHz, Linux 64 bit) R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4815087
2011-08-04runtime: faster chan creation on Linux/FreeBSD/Plan9Dmitriy Vyukov
The change removes chan finalizer (Lock destructor) if it is not required on the platform. benchmark old ns/op new ns/op delta BenchmarkChanCreation 1132.00 381.00 -66.34% BenchmarkChanCreation-2 1215.00 243.00 -80.00% BenchmarkChanCreation-4 1084.00 186.00 -82.84% BenchmarkChanCreation-8 1415.00 154.00 -89.12% BenchmarkChanCreation-16 1386.00 144.00 -89.61% (on 2 x Intel Xeon E5620, 8 HT cores, 2.4 GHz, Linux) R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4841041
2011-07-26gc, runtime: fix range+panic line number bugsRuss Cox
Fixes #1856. R=ken2 CC=golang-dev https://golang.org/cl/4810054
2011-07-23runtime: replace byte-at-a-time zeroing loop with memclrQuan Yong Zhai
R=golang-dev, r, r, dsymonds, rsc CC=golang-dev https://golang.org/cl/4813043
2011-07-15runtime: native xadd for 386/amd64Dmitriy Vyukov
benchmark old ns/op new ns/op delta BenchmarkSemaUncontended 37.40 34.10 -8.82% BenchmarkSemaUncontended-2 18.90 17.70 -6.35% BenchmarkSemaUncontended-4 11.90 10.90 -8.40% BenchmarkSemaUncontended-8 6.26 5.19 -17.09% BenchmarkSemaUncontended-16 4.39 3.91 -10.93% BenchmarkSemaSyntNonblock 38.00 35.30 -7.11% BenchmarkSemaSyntNonblock-2 83.00 46.70 -43.73% BenchmarkSemaSyntNonblock-4 124.00 101.00 -18.55% BenchmarkSemaSyntNonblock-8 124.00 116.00 -6.45% BenchmarkSemaSyntNonblock-16 148.00 114.00 -22.97% (on HP Z600 2 x Xeon E5620, 8 HT cores, 2.40GHz) R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4755041
2011-07-12runtime: replace runtime.mcpy with runtime.memmoveQuan Yong Zhai
faster string operations, and more tested on linux/386 runtime_test.BenchmarkSliceToString 642 532 -17.13% runtime_test.BenchmarkStringToSlice 636 528 -16.98% runtime_test.BenchmarkConcatString 1109 897 -19.12% R=r, iant, rsc CC=golang-dev https://golang.org/cl/4674042
2011-07-12runtime: eliminate false sharing on random number generatorsDmitriy Vyukov
Use machine-local random number generator instead of racy global ones. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4674049
2011-02-25runtime: omit breakpoint during terminal panicRuss Cox
again. CL 4222043 missed this case. R=brainman, r, r2 CC=golang-dev https://golang.org/cl/4235043
2011-02-22ld: detect stack overflow due to NOSPLITRuss Cox
Fix problems found. On amd64, various library routines had bigger stack frames than expected, because large function calls had been added. runtime.assertI2T: nosplit stack overflow 120 assumed on entry to runtime.assertI2T 8 after runtime.assertI2T uses 112 0 on entry to runtime.newTypeAssertionError -8 on entry to runtime.morestack01 runtime.assertE2E: nosplit stack overflow 120 assumed on entry to runtime.assertE2E 16 after runtime.assertE2E uses 104 8 on entry to runtime.panic 0 on entry to runtime.morestack16 -8 after runtime.morestack16 uses 8 runtime.assertE2T: nosplit stack overflow 120 assumed on entry to runtime.assertE2T 16 after runtime.assertE2T uses 104 8 on entry to runtime.panic 0 on entry to runtime.morestack16 -8 after runtime.morestack16 uses 8 runtime.newselect: nosplit stack overflow 120 assumed on entry to runtime.newselect 56 after runtime.newselect uses 64 48 on entry to runtime.printf 8 after runtime.printf uses 40 0 on entry to vprintf -8 on entry to runtime.morestack16 runtime.selectdefault: nosplit stack overflow 120 assumed on entry to runtime.selectdefault 56 after runtime.selectdefault uses 64 48 on entry to runtime.printf 8 after runtime.printf uses 40 0 on entry to vprintf -8 on entry to runtime.morestack16 runtime.selectgo: nosplit stack overflow 120 assumed on entry to runtime.selectgo 0 after runtime.selectgo uses 120 -8 on entry to runtime.gosched On arm, 5c was tagging functions NOSPLIT that should not have been, like the recursive function printpanics: printpanics: nosplit stack overflow 124 assumed on entry to printpanics 112 after printpanics uses 12 108 on entry to printpanics 96 after printpanics uses 12 92 on entry to printpanics 80 after printpanics uses 12 76 on entry to printpanics 64 after printpanics uses 12 60 on entry to printpanics 48 after printpanics uses 12 44 on entry to printpanics 32 after printpanics uses 12 28 on entry to printpanics 16 after printpanics uses 12 12 on entry to printpanics 0 after printpanics uses 12 -4 on entry to printpanics R=r, r2 CC=golang-dev https://golang.org/cl/4188061
2011-02-16runtime: minor cleanupRuss Cox
implement runtime.casp on amd64. keep simultaneous panic messages separate. R=r CC=golang-dev https://golang.org/cl/4188053
2011-02-02runtime: more detailed panic traces, line number workRuss Cox
Follow morestack, so that crashes during a stack split give complete traces. Also mark stack segment boundaries as an aid to debugging. Correct various line number bugs with yet another attempt at interpreting the pc/ln table. This one has a chance at being correct, because I based it on reading src/cmd/ld/lib.c instead of on reading the documentation. Fixes #1138. Fixes #1430. Fixes #1461. throw: runtime: split stack overflow runtime.throw+0x3e /home/rsc/g/go2/src/pkg/runtime/runtime.c:78 runtime.throw(0x81880af, 0xf75c8b18) runtime.newstack+0xad /home/rsc/g/go2/src/pkg/runtime/proc.c:728 runtime.newstack() runtime.morestack+0x4f /home/rsc/g/go2/src/pkg/runtime/386/asm.s:184 runtime.morestack() ----- morestack called from stack: ----- runtime.new+0x1a /home/rsc/g/go2/src/pkg/runtime/malloc.c:288 runtime.new(0x1, 0x0, 0x0) gongo.makeBoard+0x33 /tmp/Gongo/gongo_robot_test.go:344 gongo.makeBoard(0x809d238, 0x1, 0xf76092c8, 0x1) ----- stack segment boundary ----- gongo.checkEasyScore+0xcc /tmp/Gongo/gongo_robot_test.go:287 gongo.checkEasyScore(0xf764b710, 0x0, 0x809d238, 0x1) gongo.TestEasyScore+0x8c /tmp/Gongo/gongo_robot_test.go:255 gongo.TestEasyScore(0xf764b710, 0x818a990) testing.tRunner+0x2f /home/rsc/g/go2/src/pkg/testing/testing.go:132 testing.tRunner(0xf764b710, 0xf763b5dc, 0x0) runtime.goexit /home/rsc/g/go2/src/pkg/runtime/proc.c:149 runtime.goexit() R=ken2, r CC=golang-dev https://golang.org/cl/4000053
2011-02-01windows: multiple improvements and cleanupsHector Chu
The callback mechanism has been made more flexible. Eliminated one round of argument copying in Syscall. Faster Get/SetLastError implemented. Added gettime for gc perf profiling. R=rsc, brainman, mattn, rog CC=golang-dev https://golang.org/cl/4058046
2011-01-25runtime: prefer fixed stack allocator over general memory allocatorRuss Cox
* move stack constants from proc.c to runtime.h * make memclr take uintptr length R=r CC=golang-dev https://golang.org/cl/3985046
2011-01-20cgo: windows/386 portWei Guangjing
R=rsc, peterGo, brainman CC=golang-dev https://golang.org/cl/3733046
2011-01-18runtime: print signal information during panicRuss Cox
$ 6.out panic: runtime error: invalid memory address or nil pointer dereference [signal 11 code=0x1 addr=0x0 pc=0x1c16] runtime.panic+0xa7 /Users/rsc/g/go/src/pkg/runtime/proc.c:1089 runtime.panic(0xf6c8, 0x25c010) runtime.panicstring+0x69 /Users/rsc/g/go/src/pkg/runtime/runtime.c:88 runtime.panicstring(0x24814, 0x0) runtime.sigpanic+0x144 /Users/rsc/g/go/src/pkg/runtime/darwin/thread.c:465 runtime.sigpanic() main.f+0x16 /Users/rsc/x.go:5 main.f() main.main+0x1c /Users/rsc/x.go:9 main.main() runtime.mainstart+0xf /Users/rsc/g/go/src/pkg/runtime/amd64/asm.s:77 runtime.mainstart() runtime.goexit /Users/rsc/g/go/src/pkg/runtime/proc.c:149 runtime.goexit() R=r CC=golang-dev https://golang.org/cl/4036042
2011-01-12runtime: revert 6974:1f3c3696babbAlex Brainman
I missed that environment is used during runtime setup, well before go init() functions run. Implemented os-dependent runtime.goenvs functions to allow for different unix, plan9 and windows versions of environment discovery. R=rsc, paulzhol CC=golang-dev https://golang.org/cl/3787046
2010-12-16runtime: move windows goargs implementation from runtime and into os packageAlex Brainman
R=rsc CC=golang-dev https://golang.org/cl/3702041
2010-12-14runtime: write only to standard errorRuss Cox
Will mail a warning to golang-nuts once this is submitted. R=r, niemeyer CC=golang-dev https://golang.org/cl/3573043
2010-12-13gc: align structs according to max alignment of fieldsRuss Cox
cc: same runtime: test cc alignment (required moving #define of offsetof to runtime.h) fix bug260 Fixes #482. Fixes #609. R=ken2, r CC=golang-dev https://golang.org/cl/3563042
2010-11-04Small addition to previous optimization of memequal as discussed here: ↵Graham Miller
http://groups.google.com/group/golang-nuts/browse_thread/thread/f591ba36d83723c0/9aba02d344045f38 R=golang-dev, r, r2 CC=golang-dev https://golang.org/cl/2880041
2010-11-04runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almostRuss Cox
Prefix all external symbols in runtime by runtime·, to avoid conflicts with possible symbols of the same name in linked-in C libraries. The obvious conflicts are printf, malloc, and free, but hide everything to avoid future pain. The symbols left alone are: ** known to cgo ** _cgo_free _cgo_malloc libcgo_thread_start initcgo ncgocall ** known to linker ** _rt0_$GOARCH _rt0_$GOARCH_$GOOS text etext data end pclntab epclntab symtab esymtab ** known to C compiler ** _divv _modv _div64by32 etc (arch specific) Tested on darwin/386, darwin/amd64, linux/386, linux/amd64. Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386. R=r, PeterGo CC=golang-dev https://golang.org/cl/2899041
2010-10-18runtime: fix amd64 build (broke by 386 support for Plan 9)Russ Cox
TBR=r CC=golang-dev https://golang.org/cl/2556041
2010-10-188l, runtime: initial support for Plan 9Yuval Pavel Zholkover
No multiple processes/locks, managed to compile and run a hello.go (with print not fmt). Also test/sieve.go seems to run until 439 and stops with a 'throw: all goroutines are asleep - deadlock!' - just like runtime/tiny. based on Russ's suggestions at: http://groups.google.com/group/comp.os.plan9/browse_thread/thread/cfda8b82535d2d68/243777a597ec1612 Build instructions: cd src/pkg/runtime make clean && GOOS=plan9 make install this will build and install the runtime. When linking with 8l, you should pass -s to suppress symbol generation in the a.out, otherwise the generated executable will not run. This is runtime only, the porting of the toolchain has already been done: http://code.google.com/p/go-plan9/source/browse in the plan9-quanstro branch. R=rsc CC=golang-dev https://golang.org/cl/2273041
2010-10-07runtime: faster strequal, memequalGraham Miller
Fixes #1161. R=rsc, cwvh CC=golang-dev https://golang.org/cl/2317044
2010-08-26runtime: special case copy, equal for one-word interface valuesKyle Consalus
Based on the observation that a great number of the types that are copied or compared in interfaces, maps, and channels are word-sized, this uses specialized copy and equality functions for them that use a word instead of 4 or 8 bytes. Seems to yield 0-6% improvements in performance in the benchmarks I've run. For example, with the regexp benchmarks: Before: regexp.BenchmarkLiteral 500000 3.26 µs/op regexp.BenchmarkNotLiteral 100000 13.67 µs/op regexp.BenchmarkMatchClass 100000 18.72 µs/op regexp.BenchmarkMatchClass_InRange 100000 20.04 µs/op regexp.BenchmarkReplaceAll 100000 27.85 µs/op After: regexp.BenchmarkLiteral 500000 3.11 µs/op regexp.BenchmarkNotLiteral 200000 13.29 µs/op regexp.BenchmarkMatchClass 100000 17.65 µs/op regexp.BenchmarkMatchClass_InRange 100000 18.49 µs/op regexp.BenchmarkReplaceAll 100000 26.34 µs/op R=rsc CC=golang-dev https://golang.org/cl/1967047
2010-06-28Only catch all signals if os/signal package imported.Ian Lance Taylor
Fixes #776. R=rsc CC=golang-dev https://golang.org/cl/1745041
2010-05-19runtime: avoid allocation for fixed stringsRuss Cox
R=r CC=golang-dev https://golang.org/cl/1083041
2010-04-08runtime: fix build (panic) for FreeBSDRuss Cox
R=adg CC=golang-dev https://golang.org/cl/867046
2010-04-05runtime: fix CallerRuss Cox
log: add test of Caller New regexp in log test is picky and will require some maintenance, but it catches off-by-one mistakes too. Fixes #710. R=gri CC=esko.luontola, golang-dev https://golang.org/cl/887043
2010-04-05runtime: various arm fixesRuss Cox
* correct symbol table size * do not reorder functions in output * traceback * signal handling * use same code for go + defer * handle leaf functions in symbol table R=kaib, dpx CC=golang-dev https://golang.org/cl/884041
2010-04-01runtime: turn run time errors checks into panicsRuss Cox
R=ken2, r CC=golang-dev https://golang.org/cl/871042
2010-03-31gc: implement panic and recoverRuss Cox
R=ken2, r, ken3 CC=golang-dev https://golang.org/cl/831042
2010-03-30gc: add panic and recover (still unimplemented in runtime)Russ Cox
main semantic change is to enforce single argument to panic. runtime: change to 1-argument panic. use String method on argument if it has one. R=ken2, r CC=golang-dev https://golang.org/cl/812043
2010-03-24runtime: malloc sampling, pprof interfaceRuss Cox
R=r CC=golang-dev https://golang.org/cl/719041
2010-03-23runtime: add CallersRuss Cox
cut copies of traceback from 6 to 1. R=r CC=golang-dev https://golang.org/cl/703041
2010-03-16runtime: add GOROOT and VersionRuss Cox
R=r CC=golang-dev https://golang.org/cl/608041
2010-02-08runtime: instrument malloc + garbage collector.Russ Cox
add simple garbage collection benchmark. R=iant CC=golang-dev https://golang.org/cl/204053
2010-01-25in C and asm, replace pkg·name with ·nameRuss Cox
(eliminate assumption of package global name space, make code easier to move between packages). R=r CC=golang-dev https://golang.org/cl/194072
2010-01-06Ported runtime to Windows.Hector Chu
R=rsc CC=golang-dev https://golang.org/cl/176066
2009-11-20x[lo:] - gc and runtime.Russ Cox
* add runtime sliceslice1 for x[lo:] * remove runtime arraytoslice, rewriting &arr into arr[0:len(arr)]. * port cgen_inline into 8g, 5g. * use native memmove in maps R=ken2 https://golang.org/cl/157106
2009-10-15rename sys functions to runtime,Russ Cox
because they are in package runtime. another step to enforcing package boundaries. R=r DELTA=732 (114 added, 93 deleted, 525 changed) OCL=35811 CL=35824
2009-10-13write stack traces and panics to stderrRob Pike
R=rsc DELTA=31 (5 added, 3 deleted, 23 changed) OCL=35700 CL=35700
2009-08-28sliceslice inlineKen Thompson
R=rsc OCL=34041 CL=34041
2009-08-25rename runtime internals to have modern names (array->slice etc)Rob Pike
R=rsc DELTA=444 (179 added, 177 deleted, 88 changed) OCL=33847 CL=33849
2009-06-09mv src/lib to src/pkgRob Pike
tests: all.bash passes, gobuild still works, godoc still works. R=rsc OCL=30096 CL=30102