Commit c14d25c6 authored by Austin Clements's avatar Austin Clements

runtime: generalize work.finalizersDone to work.markrootDone

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/20043Reviewed-by: default avatarRick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 276b1777
...@@ -755,11 +755,13 @@ var work struct { ...@@ -755,11 +755,13 @@ var work struct {
// Number of roots of various root types. Set by gcMarkRootPrepare. // Number of roots of various root types. Set by gcMarkRootPrepare.
nDataRoots, nBSSRoots, nSpanRoots, nStackRoots int nDataRoots, nBSSRoots, nSpanRoots, nStackRoots int
// finalizersDone indicates that finalizers and objects with // markrootDone indicates that roots have been marked at least
// finalizers have been scanned by markroot. During concurrent // once during the current GC cycle. This is checked by root
// GC, this happens during the concurrent scan phase. During // marking operations that have to happen only during the
// STW GC, this happens during mark termination. // first root marking pass, whether that's during the
finalizersDone bool // 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. // Each type of GC state transition is protected by a lock.
// Since multiple threads can simultaneously detect the state // Since multiple threads can simultaneously detect the state
...@@ -1112,9 +1114,8 @@ top: ...@@ -1112,9 +1114,8 @@ top:
// below. The important thing is that the wb remains active until // below. The important thing is that the wb remains active until
// all marking is complete. This includes writes made by the GC. // all marking is complete. This includes writes made by the GC.
// markroot is done now, so record that objects with // Record that one root marking pass has completed.
// finalizers have been scanned. work.markrootDone = true
work.finalizersDone = true
// Disable assists and background workers. We must do // Disable assists and background workers. We must do
// this before waking blocked assists. // this before waking blocked assists.
...@@ -1573,9 +1574,8 @@ func gcMark(start_time int64) { ...@@ -1573,9 +1574,8 @@ func gcMark(start_time int64) {
notesleep(&work.alldone) notesleep(&work.alldone)
} }
// markroot is done now, so record that objects with // Record that at least one root marking pass has completed.
// finalizers have been scanned. work.markrootDone = true
work.finalizersDone = true
for i := 0; i < int(gomaxprocs); i++ { for i := 0; i < int(gomaxprocs); i++ {
if !allp[i].gcw.empty() { if !allp[i].gcw.empty() {
...@@ -1745,7 +1745,7 @@ func gcResetMarkState() { ...@@ -1745,7 +1745,7 @@ func gcResetMarkState() {
work.bytesMarked = 0 work.bytesMarked = 0
work.initialHeapLive = memstats.heap_live work.initialHeapLive = memstats.heap_live
work.finalizersDone = false work.markrootDone = false
} }
// Hooks for other packages // Hooks for other packages
......
...@@ -235,11 +235,11 @@ func markrootSpans(gcw *gcWork, shard int) { ...@@ -235,11 +235,11 @@ func markrootSpans(gcw *gcWork, shard int) {
// We process objects with finalizers only during the first // We process objects with finalizers only during the first
// markroot pass. In concurrent GC, this happens during // 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 // 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. // termination.
if work.finalizersDone { if work.markrootDone {
return return
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment