]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: generalize work.finalizersDone to work.markrootDone
authorAustin Clements <austin@google.com>
Mon, 15 Feb 2016 23:24:06 +0000 (18:24 -0500)
committerAustin Clements <austin@google.com>
Wed, 16 Mar 2016 20:13:22 +0000 (20:13 +0000)
We're about to add another root marking job that needs to happen only
during the first markroot pass (whether that's concurrent or STW),
just like finalizer scanning. Rather than introducing another flag
that has the same value as finalizersDone, just rename finalizersDone
to markrootDone.

Change-Id: I535356c6ea1f3734cb5b6add264cb7bf48de95e8
Reviewed-on: https://go-review.googlesource.com/20043
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/mgc.go
src/runtime/mgcmark.go

index 7e93740d04e46755b9793aef1864b61979ddc2e8..1c184db10b44f58486fe63c13d27d04571994ca8 100644 (file)
@@ -755,11 +755,13 @@ var work struct {
        // Number of roots of various root types. Set by gcMarkRootPrepare.
        nDataRoots, nBSSRoots, nSpanRoots, nStackRoots int
 
-       // finalizersDone indicates that finalizers and objects with
-       // finalizers have been scanned by markroot. During concurrent
-       // GC, this happens during the concurrent scan phase. During
-       // STW GC, this happens during mark termination.
-       finalizersDone bool
+       // markrootDone indicates that roots have been marked at least
+       // once during the current GC cycle. This is checked by root
+       // marking operations that have to happen only during the
+       // first root marking pass, whether that's during the
+       // concurrent mark phase in current GC or mark termination in
+       // STW GC.
+       markrootDone bool
 
        // Each type of GC state transition is protected by a lock.
        // Since multiple threads can simultaneously detect the state
@@ -1112,9 +1114,8 @@ top:
                // below. The important thing is that the wb remains active until
                // all marking is complete. This includes writes made by the GC.
 
-               // markroot is done now, so record that objects with
-               // finalizers have been scanned.
-               work.finalizersDone = true
+               // Record that one root marking pass has completed.
+               work.markrootDone = true
 
                // Disable assists and background workers. We must do
                // this before waking blocked assists.
@@ -1573,9 +1574,8 @@ func gcMark(start_time int64) {
                notesleep(&work.alldone)
        }
 
-       // markroot is done now, so record that objects with
-       // finalizers have been scanned.
-       work.finalizersDone = true
+       // Record that at least one root marking pass has completed.
+       work.markrootDone = true
 
        for i := 0; i < int(gomaxprocs); i++ {
                if !allp[i].gcw.empty() {
@@ -1745,7 +1745,7 @@ func gcResetMarkState() {
 
        work.bytesMarked = 0
        work.initialHeapLive = memstats.heap_live
-       work.finalizersDone = false
+       work.markrootDone = false
 }
 
 // Hooks for other packages
index 683dbf49ad538902b9ad34c4b64ca909bf0be800..a079358e706ba6174c9aff1c08454adb8b4da3a1 100644 (file)
@@ -235,11 +235,11 @@ func markrootSpans(gcw *gcWork, shard int) {
 
        // We process objects with finalizers only during the first
        // markroot pass. In concurrent GC, this happens during
-       // concurrent scan and we depend on addfinalizer to ensure the
+       // concurrent mark and we depend on addfinalizer to ensure the
        // above invariants for objects that get finalizers after
-       // concurrent scan. In STW GC, this will happen during mark
+       // concurrent mark. In STW GC, this will happen during mark
        // termination.
-       if work.finalizersDone {
+       if work.markrootDone {
                return
        }