aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/runtime1.go
AgeCommit message (Collapse)Author
2015-11-16runtime: add optional expensive check for invalid cgo pointer passingIan Lance Taylor
If you set GODEBUG=cgocheck=2 the runtime package will use the write barrier to detect cases where a Go program writes a Go pointer into non-Go memory. In conjunction with the existing cgo checks, and the not-yet-implemented cgo check for exported functions, this should reliably detect all cases (that do not import the unsafe package) in which a Go pointer is incorrectly shared with C code. This check is optional because it turns on the write barrier at all times, which is known to be expensive. Update #12416. Change-Id: I549d8b2956daa76eac853928e9280e615d6365f4 Reviewed-on: https://go-review.googlesource.com/16899 Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-15runtime: remove go:nosplit comment from reflect.typelinksIan Lance Taylor
A nosplit comment was added to reflect.typelinks accidentally in https://golang.org/cl/98510044. There is only one caller of reflect.typelinks, reflect.typesByString, and that function is not nosplit. There is no reason for reflect.typelinks to be nosplit. Change-Id: I0fd3cc66fafcd92643e38e53fa586d6b2f868a0a Reviewed-on: https://go-review.googlesource.com/16932 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Minux Ma <minux@golang.org>
2015-11-12runtime: break out system-specific constants into package sysMichael Matloob
runtime/internal/sys will hold system-, architecture- and config- specific constants. Updates #11647 Change-Id: I6db29c312556087a42e8d2bdd9af40d157c56b54 Reviewed-on: https://go-review.googlesource.com/16817 Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-10cmd/cgo, runtime: add checks for passing pointers from Go to CIan Lance Taylor
This implements part of the proposal in issue 12416 by adding dynamic checks for passing pointers from Go to C. This code is intended to be on at all times. It does not try to catch every case. It does not implement checks on calling Go functions from C. The new cgo checks may be disabled using GODEBUG=cgocheck=0. Update #12416. Change-Id: I48de130e7e2e83fb99a1e176b2c856be38a4d3c8 Reviewed-on: https://go-review.googlesource.com/16003 Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-10runtime: break atomics out into package runtime/internal/atomicMichael Matloob
This change breaks out most of the atomics functions in the runtime into package runtime/internal/atomic. It adds some basic support in the toolchain for runtime packages, and also modifies linux/arm atomics to remove the dependency on the runtime's mutex. The mutexes have been replaced with spinlocks. all trybots are happy! In addition to the trybots, I've tested on the darwin/arm64 builder, on the darwin/arm builder, and on a ppc64le machine. Change-Id: I6698c8e3cf3834f55ce5824059f44d00dc8e3c2f Reviewed-on: https://go-review.googlesource.com/14204 Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2015-10-30runtime: introduce GOTRACEBACK=single, now the defaultRuss Cox
Abandon (but still support) the old numbering system. GOTRACEBACK=none is old 0 GOTRACEBACK=single is the new behavior GOTRACEBACK=all is old 1 GOTRACEBACK=system is old 2 GOTRACEBACK=crash is unchanged See doc comment change in runtime1.go for details. Filed #13107 to decide whether to change default back to GOTRACEBACK=all for Go 1.6 release. If you run into programs where printing only the current goroutine omits needed information, please add details in a comment on that issue. Fixes #12366. Change-Id: I82ca8b99b5d86dceb3f7102d38d2659d45dbe0db Reviewed-on: https://go-review.googlesource.com/16512 Reviewed-by: Austin Clements <austin@google.com>
2015-10-23runtime: replace is{plan9,solaris,windows} with GOOS testsMatthew Dempsky
Change-Id: I27589395f547c5837dc7536a0ab5bc7cc23a4ff6 Reviewed-on: https://go-review.googlesource.com/10872 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-30runtime: add GODEBUG for stack barriers at every frameAustin Clements
Currently enabling the debugging mode where stack barriers are installed at every frame requires recompiling the runtime. However, this is potentially useful for field debugging and for runtime tests, so make this mode a GODEBUG. Updates #12238. Change-Id: I6fb128f598b19568ae723a612e099c0ed96917f5 Reviewed-on: https://go-review.googlesource.com/13947 Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-29runtime: set invalidptr=1 by default, as documentedgo1.5beta3Russ Cox
Also make invalidptr control the recently added GC pointer check, as documented. Change-Id: Iccfdf49480219d12be8b33b8f03d8312d8ceabed Reviewed-on: https://go-review.googlesource.com/12857 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2015-07-11runtime: abort on fatal errors and panics in c-shared and c-archive modesElias Naur
The default behaviour for fatal errors and runtime panics is to dump the goroutine stack traces and exit with code 2. However, when the process is owned by foreign code, it is suprising and inappropriate to suddenly exit the whole process, even on fatal errors. Instead, re-use the crash behaviour from GOTRACEBACK=crash and abort. The motivating use case is issue #11382, where an Android crash reporter is confused by an exiting process, but I believe the aborting behaviour is appropriate for all cases where Go does not own the process. The change is simple and contained and will enable reliable crash reporting for Android apps in Go 1.5, but I'll leave it to others to judge whether it is too late for Go 1.5. Fixes #11382 Change-Id: I477328e1092f483591c99da1fbb8bc4411911785 Reviewed-on: https://go-review.googlesource.com/12032 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-06-15runtime: add GODEBUG gcshrinkstackoff, gcstackbarrieroff, and gcstoptheworld ↵Russ Cox
variables While we're here, update the documentation and delete variables with no effect. Change-Id: I4df0d266dff880df61b488ed547c2870205862f0 Reviewed-on: https://go-review.googlesource.com/10790 Reviewed-by: Austin Clements <austin@google.com>
2015-05-07runtime: turn off checkmark by defaultRuss Cox
Change-Id: Ic8cb8b1ed8715d6d5a53ec3cac385c0e93883514 Reviewed-on: https://go-review.googlesource.com/9825 Reviewed-by: Rick Hudson <rlh@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2015-05-07runtime: fix gccheckmark mode and enable by defaultRuss Cox
It was testing the mark bits on what roots pointed at, but not the remainder of the live heap, because in CL 2991 I accidentally inverted this check during refactoring. The next CL will turn it back off by default again, but I want one run on the builders with the full checkmark checks. Change-Id: Ic166458cea25c0a56e5387fc527cb166ff2e5ada Reviewed-on: https://go-review.googlesource.com/9824 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2015-05-07runtime: set heap minimum default based on GOGCRick Hudson
Currently the heap minimum is set to 4MB which prevents our ability to collect at every allocation by setting GOGC=0. This adjust the heap minimum to 4MB*GOGC/100 thus reenabling collecting at every allocation. Fixes #10681 Change-Id: I912d027dac4b14ae535597e8beefa9ac3fb8ad94 Reviewed-on: https://go-review.googlesource.com/9814 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-01runtime: detailed debug output of controller stateAustin Clements
This adds a detailed debug dump of the state of the GC controller and a GODEBUG flag to enable it. Change-Id: I562fed7981691a84ddf0f9e6fcd9f089f497ac13 Reviewed-on: https://go-review.googlesource.com/9640 Reviewed-by: Russ Cox <rsc@golang.org>
2015-04-17runtime: leave gccheckmark testing off by defaultRuss Cox
It's not helping anymore, and it's fooling people who try to understand performance (like me). Change-Id: I133a644acae0ddf1bfa17c654cdc01e2089da963 Reviewed-on: https://go-review.googlesource.com/9018 Reviewed-by: Austin Clements <austin@google.com>
2015-04-10runtime, cmd/internal/ld: rename themoduledata to firstmoduledataMichael Hudson-Doyle
'themoduledata' doesn't really make sense now we support multiple moduledata objects. Change-Id: I8263045d8f62a42cb523502b37289b0fba054f62 Reviewed-on: https://go-review.googlesource.com/8521 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-10runtime, reflect: support multiple moduledata objectsMichael Hudson-Doyle
This changes all the places that consult themoduledata to consult a linked list of moduledata objects, as will be necessary for -linkshared to work. Obviously, as there is as yet no way of adding moduledata objects to this list, all this change achieves right now is wasting a few instructions here and there. Change-Id: I397af7f60d0849b76aaccedf72238fe664867051 Reviewed-on: https://go-review.googlesource.com/8231 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-08runtime, cmd/internal/ld: initialize themoduledata slices directlyMichael Hudson-Doyle
This CL is quite conservative in some ways. It continues to define symbols that have no real purpose (e.g. epclntab). These could be deleted if there is no concern that external tools might look for them. It would also now be possible to make some changes to the pcln data but I get the impression that would definitely require some thought and discussion. Change-Id: Ib33cde07e4ec38ecc1d6c319a10138c9347933a3 Reviewed-on: https://go-review.googlesource.com/7616 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-31runtime, cmd/internal/ld: change runtime to use a single linker symbolMichael Hudson-Doyle
In preparation for being able to run a go program that has code in several objects, this changes from having several linker symbols used by the runtime into having one linker symbol that points at a structure containing the needed data. Multiple object support will construct a linked list of such structures. A follow up will initialize the slices in the themoduledata structure directly from the linker but I was aiming for a minimal diff for now. Change-Id: I613cce35309801cf265a1d5ae5aaca8d689c5cbf Reviewed-on: https://go-review.googlesource.com/7441 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-20runtime: add GODEBUG=sbrk=1 to bypass memory allocator (and GC)Russ Cox
To reduce lock contention in this mode, makes persistent allocation state per-P, which means at most 64 kB overhead x $GOMAXPROCS, which should be completely tolerable. Change-Id: I34ca95e77d7e67130e30822e5a4aff6772b1a1c5 Reviewed-on: https://go-review.googlesource.com/7740 Reviewed-by: Rick Hudson <rlh@golang.org>
2015-03-17runtime: copy env strings on startupDavid Crawshaw
Some versions of libc, in this case Android's bionic, point environ directly at the envp memory. https://android.googlesource.com/platform/bionic/+/master/libc/bionic/libc_init_common.cpp#104 The Go runtime does something surprisingly similar, building the runtime's envs []string using gostringnocopy. Both libc and the Go runtime reusing memory interacts badly. When syscall.Setenv uses cgo to call setenv(3), C modifies the underlying memory of a Go string. This manifests on android/arm. With GOROOT=/data/local/tmp, a runtime test calls syscall.Setenv("/os"), resulting in runtime.GOROOT()=="/os\x00a/local/tmp/goroot". Avoid this by copying environment string memory into Go. Covered by runtime.TestFixedGOROOT on android/arm. Change-Id: Id0cf9553969f587addd462f2239dafca1cf371fa Reviewed-on: https://go-review.googlesource.com/7663 Reviewed-by: Keith Randall <khr@golang.org>
2015-03-11runtime,reflect,cmd/internal/gc: Fix comments referring to .c/.h filesKeith Randall
Everything has moved to Go, but comments still refer to .c/.h files. Fix all of those up, at least for these three directories. Fixes #10138 Change-Id: Ie5efe89b247841e0b3f82aac5256b2c606ef67dc Reviewed-on: https://go-review.googlesource.com/7431 Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-20runtime: fix cputicks on x86Dmitry Vyukov
See the following issue for context: https://github.com/golang/go/issues/9729#issuecomment-74648287 In short, RDTSC can produce skewed results without preceding LFENCE/MFENCE. Information on this matter is very scrappy in the internet. But this is what linux kernel does (see rdtsc_barrier). It also fixes the test program on my machine. Update #9729 Change-Id: I3c1ffbf129fdfdd388bd5b7911b392b319248e68 Reviewed-on: https://go-review.googlesource.com/5033 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-03runtime: Change memprofrate to memprofilerateLynn Boger
Use memprofilerate in GODEBUG instead of memprofrate to be consistent with other uses. Change-Id: Iaf6bd3b378b1fc45d36ecde32f3ad4e63ca1e86b Reviewed-on: https://go-review.googlesource.com/3800 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-03runtime: Add memprofrate value to GODEBUGLynn Boger
Add memprofrate as a value recognized in GODEBUG. The value provided is used as the new setting for runtime.MemProfileRate, allowing the user to adjust memory profiling. Change-Id: If129a247683263b11e2dd42473cf9b31280543d5 Reviewed-on: https://go-review.googlesource.com/3450 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-29runtime: check alignment of 8-byte atomic loads and stores on 386Austin Clements
Currently, if we do an atomic{load,store}64 of an unaligned address on 386, we'll simply get a non-atomic load/store. This has been the source of myriad bugs, so add alignment checks to these two operations. These checks parallel the equivalent checks in sync/atomic. The alignment check is not necessary in cas64 because it uses a locked instruction. The CPU will either execute this atomically or raise an alignment fault (#AC)---depending on the alignment check flag---either of which is fine. This also fixes the two places in the runtime that trip the new checks. One is in the runtime self-test and shouldn't have caused real problems. The other is in tickspersecond and could, in principle, have caused a misread of the ticks per second during initialization. Change-Id: If1796667012a6154f64f5e71d043c7f5fb3dd050 Reviewed-on: https://go-review.googlesource.com/3521 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-12runtime: add GODEBUG=gccheckmark=0/1Austin Clements
Previously, gccheckmark could only be enabled or disabled by calling runtime.GCcheckmarkenable/GCcheckmarkdisable. This was a necessary hack because GODEBUG was broken. Now that GODEBUG works again, move control over gccheckmark to a GODEBUG variable and remove these runtime functions. Currently, gccheckmark is enabled by default (and will probably remain so for much of the 1.5 development cycle). Change-Id: I2bc6f30c21b795264edf7dbb6bd7354b050673ab Reviewed-on: https://go-review.googlesource.com/2603 Reviewed-by: Rick Hudson <rlh@golang.org>
2015-01-07cmd/cgo, runtime/cgo: support ppc64Austin Clements
This implements support for calls to and from C in the ppc64 C ABI, as well as supporting functionality such as an entry point from the dynamic linker. Change-Id: I68da6df50d5638cb1a3d3fef773fb412d7bf631a Reviewed-on: https://go-review.googlesource.com/2009 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-06runtime: add GODEBUG wbshadow for finding missing write barriersRuss Cox
This is the detection code. It works well enough that I know of a handful of missing write barriers. However, those are subtle enough that I'll address them in separate followup CLs. GODEBUG=wbshadow=1 checks for a write that bypassed the write barrier at the next write barrier of the same word. If a bug can be detected in this mode it is typically easy to understand, since the crash says quite clearly what kind of word has missed a write barrier. GODEBUG=wbshadow=2 adds a check of the write barrier shadow copy during garbage collection. Bugs detected at garbage collection can be difficult to understand, because there is no context for what the found word means. Typically you have to reproduce the problem with allocfreetrace=1 in order to understand the type of the badly updated word. Change-Id: If863837308e7c50d96b5bdc7d65af4969bf53a6e Reviewed-on: https://go-review.googlesource.com/2061 Reviewed-by: Austin Clements <austin@google.com>
2015-01-05Revert "liblink, cmd/ld, runtime: remove stackguard1"Russ Cox
This reverts commit ab0535ae3fb45ba734d47542cc4845f27f708d1b. I think it will remain useful to distinguish code that must run on a system stack from code that can run on either stack, even if that distinction is no longer based on the implementation language. That is, I expect to add a //go:systemstack comment that, in terms of the old implementation, tells the compiler, to pretend this function was written in C. Change-Id: I33d2ebb2f99ae12496484c6ec8ed07233d693275 Reviewed-on: https://go-review.googlesource.com/2275 Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-29runtime: remove go prefix from a few routinesKeith Randall
They are no longer needed now that C is gone. goatoi -> atoi gofuncname/funcname -> funcname/cfuncname goroundupsize -> already existing roundupsize Change-Id: I278bc33d279e1fdc5e8a2a04e961c4c1573b28c7 Reviewed-on: https://go-review.googlesource.com/2154 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Minux Ma <minux@golang.org>
2014-12-29liblink, cmd/ld, runtime: remove stackguard1Shenghou Ma
Now that we've removed all the C code in runtime and the C compilers, there is no need to have a separate stackguard field to check for C code on Go stack. Remove field g.stackguard1 and rename g.stackguard0 to g.stackguard. Adjust liblink and cmd/ld as necessary. Change-Id: I54e75db5a93d783e86af5ff1a6cd497d669d8d33 Reviewed-on: https://go-review.googlesource.com/2144 Reviewed-by: Keith Randall <khr@golang.org>
2014-12-28runtime: rename gothrow to throwKeith Randall
Rename "gothrow" to "throw" now that the C version of "throw" is no longer needed. This change is purely mechanical except in panic.go where the old version of "throw" has been deleted. sed -i "" 's/[[:<:]]gothrow[[:>:]]/throw/g' runtime/*.go Change-Id: Icf0752299c35958b92870a97111c67bcd9159dc3 Reviewed-on: https://go-review.googlesource.com/2150 Reviewed-by: Minux Ma <minux@golang.org> Reviewed-by: Dave Cheney <dave@cheney.net>
2014-12-23runtime: remove thunk.sRuss Cox
Replace with uses of //go:linkname in Go files, direct use of name in .s files. The only one that really truly needs a jump is reflect.call; the jump is now next to the runtime.reflectcall assembly implementations. Change-Id: Ie7ff3020a8f60a8e4c8645fe236e7883a3f23f46 Reviewed-on: https://go-review.googlesource.com/1962 Reviewed-by: Austin Clements <austin@google.com>
2014-11-21[dev.garbage] runtime: add prefetcht0, prefetcht1, prefetcht2, prefetcht3, ↵Russ Cox
prefetchnta for GC We don't know what we need yet, so add them all. Add them even on x86 architectures (as no-ops) so that the GC can refer to them unconditionally. Eventually we'll know what we want and probably have just one 'prefetch' with an appropriate meaning on each architecture. LGTM=rlh R=rlh CC=golang-codereviews https://golang.org/cl/179160043
2014-11-14[dev.cc] all: merge dev.power64 (7667e41f3ced) into dev.ccRuss Cox
This is to reduce the delta between dev.cc and dev.garbage to just garbage collector changes. These are the files that had merge conflicts and have been edited by hand: malloc.go mem_linux.go mgc.go os1_linux.go proc1.go panic1.go runtime1.go LGTM=austin R=austin CC=golang-codereviews https://golang.org/cl/174180043
2014-11-11[dev.cc] runtime: convert basic library routines from C to GoRuss Cox
float.c held bit patterns for special float64 values, hiding from the real uses. Rewrite Go code not to refer to those values directly. Convert library routines in runtime.c and string.c. LGTM=r R=r, dave CC=austin, dvyukov, golang-codereviews, iant, khr https://golang.org/cl/170330043