aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/malloc.go
AgeCommit message (Collapse)Author
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-16runtime: add support for linux/arm64Aram Hăvărneanu
Change-Id: Ibda6a5bedaff57fd161d63fc04ad260931d34413 Reviewed-on: https://go-review.googlesource.com/7142 Reviewed-by: Russ Cox <rsc@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-03-10runtime: Adjust when write barriers are activeRick Hudson
Even though the world is stopped the GC may do pointer writes that need to be protected by write barriers. This means that the write barrier must be on continuously from the time the mark phase starts and the mark termination phase ends. Checks were added to ensure that no allocation happens during a GC. Hoist the logic that clears pools the start of the GC so that the memory can be reclaimed during this GC cycle. Change-Id: I9d1551ac5db9bac7bac0cb5370d5b2b19a9e6a52 Reviewed-on: https://go-review.googlesource.com/6990 Reviewed-by: Austin Clements <austin@google.com>
2015-02-25runtime: fallback to 128M address space on 32bitDavid Crawshaw
Available darwin/arm devices sporadically have trouble mapping 256M. I would really appreciate it if anyone could check my working on this, and make sure sure there aren't obviously bad consequences I haven't considered. Change-Id: Id1a8edae104d974fcf5f9333274f958625467f79 Reviewed-on: https://go-review.googlesource.com/5752 Reviewed-by: Keith Randall <khr@golang.org>
2015-02-23runtime: Add prefetch to allocation codeRick Hudson
The routine mallocgc retrieves objects from freelists. Prefetch the object that will be returned in the next call to mallocgc. Experiments indicate that this produces a 1% improvement when using prefetchnta and less when using prefetcht0, prefetcht1, or prefetcht2. Benchmark numbers indicate a 1% improvement over no prefetch, much less over prefetcht0, prefetcht1, and prefetcht2. These numbers were for the garbage benchmark with MAXPROCS=4 no prefetch >> 5.96 / 5.77 / 5.89 prefetcht0(uintptr(v.ptr().next)) >> 5.88 / 6.17 / 5.84 prefetcht1(uintptr(v.ptr().next)) >> 5.88 / 5.89 / 5.91 prefetcht2(uintptr(v.ptr().next)) >> 5.87 / 6.47 / 5.92 prefetchnta(uintptr(v.ptr().next)) >> 5.72 / 5.84 / 5.85 Change-Id: I54e07172081cccb097d5b5ce8789d74daa055ed9 Reviewed-on: https://go-review.googlesource.com/5350 Reviewed-by: Dmitry Vyukov <dvyukov@google.com> Reviewed-by: Austin Clements <austin@google.com>
2015-02-20runtime: tidy GC driverRuss Cox
Change-Id: I0da26e89ae73272e49e82c6549c774e5bc97f64c Reviewed-on: https://go-review.googlesource.com/5331 Reviewed-by: Austin Clements <austin@google.com>
2015-02-19runtime: reorganize memory codeRuss Cox
Move code from malloc1.go, malloc2.go, mem.go, mgc0.go into appropriate locations. Factor mgc.go into mgc.go, mgcmark.go, mgcsweep.go, mstats.go. A lot of this code was in certain files because the right place was in a C file but it was written in Go, or vice versa. This is one step toward making things actually well-organized again. Change-Id: I6741deb88a7cfb1c17ffe0bcca3989e10207968f Reviewed-on: https://go-review.googlesource.com/5300 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Rick Hudson <rlh@golang.org>
2015-02-11runtime: cache workbufs on Ms and add consistency checksRick Hudson
Add local workbufs to the m struct in order to reduce contention. Add consistency checks for workbuf ownership. Chain workbufs through call change to avoid swapping them to and from the m struct. Adjust the size of the workbuf so that the mutators can more frequently pass modifications to the GC thus shifting some work from the STW mark termination phase to the concurrent mark phase. Change-Id: I557b53af34ad9972265e0ed9f5996e52d548563d Reviewed-on: https://go-review.googlesource.com/3972 Reviewed-by: Austin Clements <austin@google.com>
2015-02-02runtime: rename m.gcing to m.preemptoff and make it a stringAustin Clements
m.gcing has become overloaded to mean "don't preempt this g" in general. Once the garbage collector is preemptible, the one thing it *won't* mean is that we're in the garbage collector. So, rename gcing to "preemptoff" and make it a string giving a reason that preemption is disabled. gcing was never set to anything but 0 or 1, so we don't have to worry about there being a stack of reasons. Change-Id: I4337c29e8e942e7aa4f106fc29597e1b5de4ef46 Reviewed-on: https://go-review.googlesource.com/3660 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28runtime: avoid redundant scansRick Hudson
During a concurrent GC stacks are scanned in an initial scan phase informing the GC of all pointers on the stack. The GC only needs to rescan the stack if it potentially changes which can only happen if the goroutine runs. This CL tracks whether the Goroutine has run since it was last scanned and thus may have changed its stack. If necessary the stack is rescanned. Change-Id: I5fb1c4338d42e3f61ab56c9beb63b7b2da25f4f1 Reviewed-on: https://go-review.googlesource.com/3275 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28runtime: add tracing of runtime eventsDmitry Vyukov
Add actual tracing of interesting runtime events. Part of a larger tracing functionality: https://docs.google.com/document/u/1/d/1FP5apqzBgr7ahCCgFO-yoVhk4YZrNIDNf9RybngBc14/pub Full change: https://codereview.appspot.com/146920043 Change-Id: Icccf54aea54e09350bb698ba6bf11532f9fbe6d3 Reviewed-on: https://go-review.googlesource.com/1451 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-21runtime: fix trigger for concurrent GCRick Hudson
Adjust triggergc so that we trigger when we have used 7/8 of the available heap memory. Do first collection when we exceed 4Mbytes. Change-Id: I467b4335e16dc9cd1521d687fc1f99a51cc7e54b Reviewed-on: https://go-review.googlesource.com/3149 Reviewed-by: Austin Clements <austin@google.com>
2015-01-21Revert "runtime: fix trigger for concurrent GC"Austin Clements
This reverts commit 44529d939192c3034a04e2eff865d04ee51ae532. Change-Id: I7671e2cd6f6a476efffa16e8110500a98258c0c1 Reviewed-on: https://go-review.googlesource.com/3130 Reviewed-by: Austin Clements <austin@google.com>
2015-01-21runtime: fix trigger for concurrent GCRick Hudson
Adujst triggergc so that we trigger when we have used 7/8 of the available memory. Change-Id: I7ca02546d3084e6a04d60b09479e04a9a9837ae2 Reviewed-on: https://go-review.googlesource.com/3061 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-19runtime: factor out bitmap, finalizer code from malloc/mgcRuss Cox
The code in mfinal.go is moved from malloc*.go and mgc*.go and substantially unchanged. The code in mbitmap.go is also moved from those files, but cleaned up so that it can be called from those files (in most cases the code being moved was not already a standalone function). I also renamed the constants and wrote comments describing the format. The result is a significant cleanup and isolation of the bitmap code, but, roughly speaking, it should be treated and reviewed as new code. The other files changed only as much as necessary to support this code movement. This CL does NOT change the semantics of the heap or type bitmaps at all, although there are now some obvious opportunities to do so in followup CLs. Change-Id: I41b8d5de87ad1d3cd322709931ab25e659dbb21d Reviewed-on: https://go-review.googlesource.com/2991 Reviewed-by: Keith Randall <khr@golang.org>
2015-01-14runtime: fix bugs in previous commitRuss Cox
These were fixed in my local commit, but I forgot that the web Submit button can't see that. Change-Id: Iec3a70ce3ccd9db2a5394ae2da0b293e45ac2fb5 Reviewed-on: https://go-review.googlesource.com/2822 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-14runtime: change tinyalloc, persistentalloc not to point past allocated dataRuss Cox
During all.bash I got a crash in the GOMAXPROCS=2 runtime test reporting that the write barrier in the assignment 'c.tiny = add(x, size)' had been given a pointer pointing into an unexpected span. The problem is that the tiny allocation was at the end of a span and c.tiny was now pointing to the end of the allocation and therefore to the end of the span aka the beginning of the next span. Rewrite tinyalloc not to do that. More generally, it's not okay to call add(p, size) unless you know that p points at > (not just >=) size bytes. Similarly, pretty much any call to roundup doesn't know how much space p points at, so those are all broken. Rewrite persistentalloc not to use add(p, totalsize) and not to use roundup. There is only one use of roundup left, in vprintf, which is dead code. I will remove that code and roundup itself in a followup CL. Change-Id: I211e307d1a656d29087b8fd40b2b71010722fb4a Reviewed-on: https://go-review.googlesource.com/2814 Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-01-14runtime: fix a few GC-related bugsRuss Cox
1) Move non-preemption check even earlier in newstack. This avoids a few priority inversion problems. 2) Always use atomic operations to update bitmap for 1-word objects. This avoids lost mark bits during concurrent GC. 3) Stop using work.nproc == 1 as a signal for being single-threaded. The concurrent GC runs with work.nproc == 1 but other procs are running mutator code. The use of work.nproc == 1 in getfull *is* safe, but remove it anyway, since it is saving only a single atomic operation per GC round. Fixes #9225. Change-Id: I24134f100ad592ea8cb59efb6a54f5a1311093dc Reviewed-on: https://go-review.googlesource.com/2745 Reviewed-by: Rick Hudson <rlh@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-08runtime: increase GC concurrency.Rick Hudson
run GC in its own background goroutine making the caller runnable if resources are available. This is critical in single goroutine applications. Allow goroutines that allocate a lot to help out the GC and in doing so throttle their own allocation. Adjust test so that it only detects that a GC is run during init calls and not whether the GC is memory efficient. Memory efficiency work will happen later in 1.5. Change-Id: I4306f5e377bb47c69bda1aedba66164f12b20c2b Reviewed-on: https://go-review.googlesource.com/2349 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2015-01-08runtime: improve GC times printingAustin Clements
This improves the printing of GC times to be both more human-friendly and to provide enough information for the construction of MMU curves and other statistics. The new times look like: GC: #8 72413852ns @143036695895725 pause=622900 maxpause=427037 goroutines=11 gomaxprocs=4 GC: sweep term: 190584ns max=190584 total=275001 procs=4 GC: scan: 260397ns max=260397 total=902666 procs=1 GC: install wb: 5279ns max=5279 total=18642 procs=4 GC: mark: 71530555ns max=71530555 total=186694660 procs=1 GC: mark term: 427037ns max=427037 total=1691184 procs=4 This prints gomaxprocs and the number of procs used in each phase for the benefit of analyzing mutator utilization during concurrent phases. This also means the analysis doesn't have to hard-code which phases are STW. This prints the absolute start time only for the GC cycle. The other start times can be derived from the phase durations. This declutters the view for humans readers and doesn't pose any additional complexity for machine readers. This removes the confusing "cycle" terminology. Instead, this places the phase duration after the phase name and adds a "ns" unit, which both makes it implicitly clear that this is the duration of that phase and indicates the units of the times. This adds a "GC:" prefix to all lines for easier identification. Finally, this generally cleans up the code as well as the placement of spaces in the output and adds print locking so the statistics blocks are never interrupted by other prints. Change-Id: Ifd056db83ed1b888de7dfa9a8fc5732b01ccc631 Reviewed-on: https://go-review.googlesource.com/2542 Reviewed-by: Rick Hudson <rlh@golang.org>
2015-01-06runtime: fix two garbage collector bugsRuss Cox
First, call clearcheckmarks immediately after changing checkmark, so that there is less time when the checkmark flag and the bitmap are inconsistent. The tiny gap between the two lines is fine, because the world is stopped. Before, the gap was much larger and included such code as "go bgsweep()", which allocated. Second, modify gcphase only when the world is stopped. As written, gcscan_m was changing gcphase from 0 to GCscan and back to 0 while other goroutines were running. Another goroutine running at the same time might decide to sleep, see GCscan, call gcphasework, and start "helping" by scanning its stack. That's fine, except that if gcphase flips back to 0 as the goroutine calls scanblock, it will start draining the work buffers prematurely. Both of these were found wbshadow=2 (and a lot of hard work). Eventually that will run automatically, but right now it still doesn't quite work for all.bash, due to mmap conflicts with pthread-created threads. Change-Id: I99aa8210cff9c6e7d0a1b62c75be32a23321897b Reviewed-on: https://go-review.googlesource.com/2340 Reviewed-by: Rick Hudson <rlh@golang.org>
2015-01-06reflect: add write barriersRuss Cox
Use typedmemmove, typedslicecopy, and adjust reflect.call to execute the necessary write barriers. Found with GODEBUG=wbshadow=2 mode. Eventually that will run automatically, but right now it still detects other missing write barriers. Change-Id: Iec5b5b0c1be5589295e28e5228e37f1a92e07742 Reviewed-on: https://go-review.googlesource.com/2312 Reviewed-by: Keith Randall <khr@golang.org>
2015-01-06cmd/gc, runtime: make assertI2T and variants not variadicRuss Cox
A side effect of this change is that when assertI2T writes to the memory for the T being extracted, it can use typedmemmove for write barriers. There are other ways we could have done this, but this one finishes a TODO in package runtime. Found with GODEBUG=wbshadow=2 mode. Eventually that will run automatically, but right now it still detects other missing write barriers. Change-Id: Icbc8aabfd8a9b1f00be2e421af0e3b29fa54d01e Reviewed-on: https://go-review.googlesource.com/2279 Reviewed-by: Keith Randall <khr@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-12-16runtime: add profiling infrastructure for the Concurrent GCRick Hudson
Change-Id: Ia7a007444eeb1503cec27367a5c6699ce0bf4af6 Reviewed-on: https://go-review.googlesource.com/1441 Reviewed-by: Austin Clements <austin@google.com>
2014-11-24[dev.garbage] all: merge dev.cc (493ad916c3b1) into dev.garbageRuss Cox
TBR=austin CC=golang-codereviews https://golang.org/cl/179290043
2014-11-20[dev.garbage] runtime: Turn concurrent GC on by default. Avoid write ↵Rick Hudson
barriers for GC internal structures such as free lists. LGTM=rsc R=rsc CC=golang-codereviews, rsc https://golang.org/cl/179000043
2014-11-20[dev.cc] all: merge default (e4ab8f908aac) into dev.ccRuss Cox
TBR=austin CC=golang-codereviews https://golang.org/cl/179040044
2014-11-19runtime: remove assumption that noptrdata data bss noptrbss are ordered and ↵Russ Cox
contiguous The assumption can be violated by external linkers reordering them or inserting non-Go sections in between them. I looked briefly at trying to write out the _go_.o in external linking mode in a way that forced the ordering, but no matter what there's no way to force Go's data and Go's bss to be next to each other. If there is any data or bss from non-Go objects, it's very likely to get stuck in between them. Instead, rewrite the two places we know about that make the assumption. I grepped for noptrdata to look for more and didn't find any. The added race test (os/exec in external linking mode) fails without the changes in the runtime. It crashes with an invalid pointer dereference. Fixes #9133. LGTM=dneil R=dneil CC=dvyukov, golang-codereviews, iant https://golang.org/cl/179980043
2014-11-15[dev.garbage] all: merge dev.cc into dev.garbageRuss Cox
The garbage collector is now written in Go. There is plenty to clean up (just like on dev.cc). all.bash passes on darwin/amd64, darwin/386, linux/amd64, linux/386. TBR=rlh R=austin, rlh, bradfitz CC=golang-codereviews https://golang.org/cl/173250043
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-14[dev.garbage] all: merge default (f38460037b72) into dev.garbageRuss Cox
This is the revision that dev.cc is branched from. LGTM=austin R=austin CC=golang-codereviews https://golang.org/cl/169590043
2014-11-12[dev.cc] runtime: delete scalararg, ptrarg; rename onM to systemstackRuss Cox
Scalararg and ptrarg are not "signal safe". Go code filling them out can be interrupted by a signal, and then the signal handler runs, and if it also ends up in Go code that uses scalararg or ptrarg, now the old values have been smashed. For the pieces of code that do need to run in a signal handler, we introduced onM_signalok, which is really just onM except that the _signalok is meant to convey that the caller asserts that scalarg and ptrarg will be restored to their old values after the call (instead of the usual behavior, zeroing them). Scalararg and ptrarg are also untyped and therefore error-prone. Go code can always pass a closure instead of using scalararg and ptrarg; they were only really necessary for C code. And there's no more C code. For all these reasons, delete scalararg and ptrarg, converting the few remaining references to use closures. Once those are gone, there is no need for a distinction between onM and onM_signalok, so replace both with a single function equivalent to the current onM_signalok (that is, it can be called on any of the curg, g0, and gsignal stacks). The name onM and the phrase 'm stack' are misnomers, because on most system an M has two system stacks: the main thread stack and the signal handling stack. Correct the misnomer by naming the replacement function systemstack. Fix a few references to "M stack" in code. The main motivation for this change is to eliminate scalararg/ptrarg. Rick and I have already seen them cause problems because the calling sequence m.ptrarg[0] = p is a heap pointer assignment, so it gets a write barrier. The write barrier also uses onM, so it has all the same problems as if it were being invoked by a signal handler. We worked around this by saving and restoring the old values and by calling onM_signalok, but there's no point in keeping this nice home for bugs around any longer. This CL also changes funcline to return the file name as a result instead of filling in a passed-in *string. (The *string signature is left over from when the code was written in and called from C.) That's arguably an unrelated change, except that once I had done the ptrarg/scalararg/onM cleanup I started getting false positives about the *string argument escaping (not allowed in package runtime). The compiler is wrong, but the easiest fix is to write the code like Go code instead of like C code. I am a bit worried that the compiler is wrong because of some use of uninitialized memory in the escape analysis. If that's the reason, it will go away when we convert the compiler to Go. (And if not, we'll debug it the next time.) LGTM=khr R=r, khr CC=austin, golang-codereviews, iant, rlh https://golang.org/cl/174950043
2014-11-11[dev.cc] runtime: convert memory allocator and garbage collector to GoRuss Cox
The conversion was done with an automated tool and then modified only as necessary to make it compile and run. [This CL is part of the removal of C code from package runtime. See golang.org/s/dev.cc for an overview.] LGTM=r R=r CC=austin, dvyukov, golang-codereviews, iant, khr https://golang.org/cl/167540043
2014-11-10[dev.garbage] runtime: Code to implement write barriersRick Hudson
To turn concurrent gc on alter the if false in func gogc currently at line 489 in malloc.go LGTM=rsc R=rsc CC=golang-codereviews, rlh https://golang.org/cl/172190043
2014-11-04[dev.garbage] runtime: Add gc mark verification pass.Rick Hudson
This adds an independent mark phase to the GC that can be used to verify the the default concurrent mark phase has found all reachable objects. It uses the upper 2 bits of the boundary nibble to encode the mark leaving the lower bits to encode the boundary and the normal mark bit. LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/167130043
2014-11-03runtime: make Go and C mallocgc signatures matchAustin Clements
Previously, the flags argument to mallocgc was an int in Go, but a uint32 in C. Change the Go type to use uint32 so these agree. The largest flag value is 2 (and of course no flag values are negative), so this won't change anything on little endian architectures, but it matters on big endian. LGTM=rsc R=khr, rsc CC=golang-codereviews https://golang.org/cl/169920043
2014-10-30[dev.garbage] cmd/gc, runtime: implement write barriers in terms of ↵Russ Cox
writebarrierptr This CL implements the many multiword write barriers by calling writebarrierptr, so that only writebarrierptr needs the actual barrier. In lieu of an actual barrier, writebarrierptr checks that the value being copied is not a small non-zero integer. This is enough to shake out bugs where the barrier is being called when it should not (for non-pointer values). It also found a few tests in sync/atomic that were being too clever. This CL adds a write barrier for the memory moved during the builtin copy function, which I forgot when inserting barriers for Go 1.4. This CL re-enables some write barriers that were disabled for Go 1.4. Those were disabled because it is possible to change the generated code so that they are unnecessary most of the time, but we have not changed the generated code yet. For safety they must be enabled. None of this is terribly efficient. We are aiming for correct first. LGTM=rlh R=rlh CC=golang-codereviews https://golang.org/cl/168770043
2014-10-29[dev.garbage] all: merge dev.power64 (5ad5e85cfb99) into dev.garbageRuss Cox
The goal here is to get the big-endian fixes so that in some upcoming code movement for write barriers I don't make them unmergeable. LGTM=rlh R=rlh CC=golang-codereviews https://golang.org/cl/166890043
2014-10-24[dev.garbage] runtime: Concurrent scan codeRick Hudson
Routines and logic to preform a concurrent stack scan of go-routines. This CL excersizes most of the functionality needed. The major exception being that it does not scan running goroutines. After doing the scans it relies on a STW to finish the GC, including rescanning the stacks. It is intended to achieve correctness, performance will follow. LGTM=rsc R=golang-codereviews, rsc CC=dvyukov, golang-codereviews https://golang.org/cl/156580043
2014-10-22[dev.power64] all: merge default into dev.power64Austin Clements
This brings dev.power64 up-to-date with the current tip of default. go_bootstrap is still panicking with a bad defer when initializing the runtime (even on amd64). LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/152570049
2014-10-22build: merge the great pkg/ rename into dev.power64Austin Clements
This also removes pkg/runtime/traceback_lr.c, which was ported to Go in an earlier commit and then moved to runtime/traceback.go. Reviewer: rsc@golang.org rsc: LGTM
2014-10-17runtime: remove comment that leaked into CL 153710043Russ Cox
This doesn't actually do anything. Maybe it will some day, but maybe not. TBR=r CC=golang-codereviews https://golang.org/cl/155490043