Commit cf964e16 authored by Austin Clements's avatar Austin Clements

runtime: replace scanblock(0, 0, nil, nil) with drainworkbuf

scanblock(0, 0, nil, nil) was just a confusing way of saying

  wbuf = getpartialorempty()
  drainworkbuf(wbuf, true)

Make drainworkbuf accept a nil workbuf and perform the
getpartialorempty itself and replace all uses of scanblock(0, 0, nil,
nil) with direct calls to drainworkbuf(nil, true).

Change-Id: I7002a2f8f3eaf6aa85bbf17ccc81d7288acfef1c
Reviewed-on: https://go-review.googlesource.com/4781Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
parent c2de2f87
...@@ -461,6 +461,9 @@ func scanblock(b0, n0 uintptr, ptrmask *uint8, wbuf *workbuf) *workbuf { ...@@ -461,6 +461,9 @@ func scanblock(b0, n0 uintptr, ptrmask *uint8, wbuf *workbuf) *workbuf {
// If drainallwbufs is true find all other available workbufs and repeat the process. // If drainallwbufs is true find all other available workbufs and repeat the process.
//go:nowritebarrier //go:nowritebarrier
func drainworkbuf(wbuf *workbuf, drainallwbufs bool) { func drainworkbuf(wbuf *workbuf, drainallwbufs bool) {
if wbuf == nil {
wbuf = getpartialorempty(472)
}
checknocurrentwbuf() checknocurrentwbuf()
if gcphase != _GCmark && gcphase != _GCmarktermination { if gcphase != _GCmark && gcphase != _GCmarktermination {
throw("scanblock phase incorrect") throw("scanblock phase incorrect")
...@@ -1149,10 +1152,7 @@ func gchelper() { ...@@ -1149,10 +1152,7 @@ func gchelper() {
// parallel mark for over GC roots // parallel mark for over GC roots
parfordo(work.markfor) parfordo(work.markfor)
if gcphase != _GCscan { if gcphase != _GCscan {
wbuf := scanblock(0, 0, nil, nil) // blocks in getfull drainworkbuf(nil, true) // blocks in getfull
if wbuf != nil {
throw("gchelper did not extinguish wbuf")
}
} }
if trace.enabled { if trace.enabled {
...@@ -1414,13 +1414,9 @@ func gcscan_m() { ...@@ -1414,13 +1414,9 @@ func gcscan_m() {
// This is the concurrent mark phase. // This is the concurrent mark phase.
//go:nowritebarrier //go:nowritebarrier
func gcmark_m() { func gcmark_m() {
// If one is available grab this M's workbuffer. drainworkbuf(nil, true)
wbuf := scanblock(0, 0, nil, nil)
if wbuf != nil {
throw("gcmark_m did not extinguish wbuf")
}
// TODO add another harvestwbuf and reset work.nwait=0, work.ndone=0, and work.nproc=1 // TODO add another harvestwbuf and reset work.nwait=0, work.ndone=0, and work.nproc=1
// and repeat the above scanblock. // and repeat the above drainworkbuf.
} }
// For now this must be bracketed with a stoptheworld and a starttheworld to ensure // For now this must be bracketed with a stoptheworld and a starttheworld to ensure
...@@ -1505,10 +1501,7 @@ func gc(start_time int64, eagersweep bool) { ...@@ -1505,10 +1501,7 @@ func gc(start_time int64, eagersweep bool) {
harvestwbufs() // move local workbufs onto global queues where the GC can find them harvestwbufs() // move local workbufs onto global queues where the GC can find them
gchelperstart() gchelperstart()
parfordo(work.markfor) parfordo(work.markfor)
wbuf := scanblock(0, 0, nil, nil) drainworkbuf(nil, true)
if wbuf != nil {
throw("gc does not extinguish wbuf")
}
if work.full != 0 { if work.full != 0 {
throw("work.full != 0") throw("work.full != 0")
......
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