Skip to content

Commit 6e5cc1f

Browse files
committed
runtime: rename drainworkbuf and drainobjects
drainworkbuf is now gcDrain, since it drains until there's nothing left to drain. drainobjects is now gcDrainN because it's the bounded equivalent to gcDrain. The new names use the Go camel case convention because we have to start somewhere. The "gc" prefix is because we don't have runtime packages yet and just "drain" is too ambiguous. Change-Id: I88dbdf32e8ce4ce6c3b7e1f234664be9b76cb8fd Reviewed-on: https://go-review.googlesource.com/4785 Reviewed-by: Russ Cox <[email protected]> Reviewed-by: Rick Hudson <[email protected]>
1 parent 60a16ea commit 6e5cc1f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/runtime/mgc.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,10 @@ func scanblock(b0, n0 uintptr, ptrmask *uint8, wbuf *workbuf) *workbuf {
446446
return wbuf
447447
}
448448

449-
// Scan objects in work buffers (starting with wbuf), blackening grey
449+
// gcDrain scans objects in work buffers (starting with wbuf), blackening grey
450450
// objects until all work buffers have been drained.
451451
//go:nowritebarrier
452-
func drainworkbuf(wbuf *workbuf) {
452+
func gcDrain(wbuf *workbuf) {
453453
if wbuf == nil {
454454
wbuf = getpartialorempty(472)
455455
}
@@ -491,11 +491,12 @@ func drainworkbuf(wbuf *workbuf) {
491491
checknocurrentwbuf()
492492
}
493493

494-
// Scan count objects starting with those in wbuf.
494+
// gcDrainN scans n objects starting with those in wbuf, blackening
495+
// grey objects.
495496
//go:nowritebarrier
496-
func drainobjects(wbuf *workbuf, count uintptr) *workbuf {
497+
func gcDrainN(wbuf *workbuf, n uintptr) *workbuf {
497498
checknocurrentwbuf()
498-
for i := uintptr(0); i < count; i++ {
499+
for i := uintptr(0); i < n; i++ {
499500
if wbuf.nobj == 0 {
500501
putempty(wbuf, 544)
501502
wbuf = trygetfull(545)
@@ -816,7 +817,7 @@ func gchelpwork() {
816817
wbuf = trygetfull(1228)
817818
}
818819
if wbuf != nil {
819-
wbuf = drainobjects(wbuf, uintptr(len(wbuf.obj))) // drain upto one buffer's worth of objects
820+
wbuf = gcDrainN(wbuf, uintptr(len(wbuf.obj))) // drain upto one buffer's worth of objects
820821
if wbuf != nil {
821822
if wbuf.nobj != 0 {
822823
putfull(wbuf, 1175)
@@ -1138,7 +1139,7 @@ func gchelper() {
11381139
// parallel mark for over GC roots
11391140
parfordo(work.markfor)
11401141
if gcphase != _GCscan {
1141-
drainworkbuf(nil) // blocks in getfull
1142+
gcDrain(nil) // blocks in getfull
11421143
}
11431144

11441145
if trace.enabled {
@@ -1400,9 +1401,9 @@ func gcscan_m() {
14001401
// This is the concurrent mark phase.
14011402
//go:nowritebarrier
14021403
func gcmark_m() {
1403-
drainworkbuf(nil)
1404+
gcDrain(nil)
14041405
// TODO add another harvestwbuf and reset work.nwait=0, work.ndone=0, and work.nproc=1
1405-
// and repeat the above drainworkbuf.
1406+
// and repeat the above gcDrain.
14061407
}
14071408

14081409
// For now this must be bracketed with a stoptheworld and a starttheworld to ensure
@@ -1487,7 +1488,7 @@ func gc(start_time int64, eagersweep bool) {
14871488
harvestwbufs() // move local workbufs onto global queues where the GC can find them
14881489
gchelperstart()
14891490
parfordo(work.markfor)
1490-
drainworkbuf(nil)
1491+
gcDrain(nil)
14911492

14921493
if work.full != 0 {
14931494
throw("work.full != 0")

0 commit comments

Comments
 (0)