summaryrefslogtreecommitdiff
path: root/src/runtime/malloc.go
diff options
context:
space:
mode:
authorRick Hudson <rlh@golang.org>2014-11-04 13:31:34 -0500
committerRick Hudson <rlh@golang.org>2014-11-04 13:31:34 -0500
commit9155768e48e7de0fd0d6297eaa932d4c489e3f38 (patch)
treec3fa5804642a64da1e36b1f9a915a8f463a89559 /src/runtime/malloc.go
parentf65bb028c5ceb4fb213b103f24a85f17cf67ac39 (diff)
downloadgo-9155768e48e7de0fd0d6297eaa932d4c489e3f38.tar.gz
[dev.garbage] runtime: Add gc mark verification pass.
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://codereview.appspot.com/167130043
Diffstat (limited to 'src/runtime/malloc.go')
-rw-r--r--src/runtime/malloc.go28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index 56f4f7cd7..274bae9a3 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -306,6 +306,18 @@ func mallocgc(size uintptr, typ *_type, flags int) unsafe.Pointer {
}
}
marked:
+
+ // GCmarkterminate allocates black
+ // All slots hold nil so no scanning is needed.
+ // This may be racing with GC so do it atomically if there can be
+ // a race marking the bit.
+ if gcphase == _GCmarktermination {
+ mp := acquirem()
+ mp.ptrarg[0] = x
+ onM(gcmarknewobject_m)
+ releasem(mp)
+ }
+
if raceenabled {
racemalloc(x, size)
}
@@ -478,8 +490,12 @@ func gogc(force int32) {
// Do a concurrent heap scan before we stop the world.
onM(gcscan_m)
+ onM(gcinstallmarkwb_m)
onM(stoptheworld)
-
+ // onM(starttheworld)
+ // mark from roots scanned in gcscan_m. startthework when write barrier works
+ onM(gcmark_m)
+ // onM(stoptheworld)
if mp != acquirem() {
gothrow("gogc: rescheduled")
}
@@ -510,6 +526,8 @@ func gogc(force int32) {
onM(gc_m)
}
+ onM(gccheckmark_m)
+
// all done
mp.gcing = 0
semrelease(&worldsema)
@@ -524,6 +542,14 @@ func gogc(force int32) {
}
}
+func GCcheckmarkenable() {
+ onM(gccheckmarkenable_m)
+}
+
+func GCcheckmarkdisable() {
+ onM(gccheckmarkdisable_m)
+}
+
// GC runs a garbage collection.
func GC() {
gogc(2)