1
0
mirror of https://github.com/golang/go synced 2024-11-05 15:26:15 -07:00

runtime: eliminate b == 0 special case from scanblock

We no longer ever call scanblock with b == 0.

Change-Id: I9b01da39595e0cc251668c24d58748d88f5f0792
Reviewed-on: https://go-review.googlesource.com/4782
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
This commit is contained in:
Austin Clements 2015-02-12 15:20:13 -05:00
parent cf964e1653
commit 1ac65f82ad

View File

@ -422,8 +422,6 @@ func scanobject(b, n uintptr, ptrmask *uint8, wbuf *workbuf) *workbuf {
// scanblock starts by scanning b as scanobject would. // scanblock starts by scanning b as scanobject would.
// If the gcphase is GCscan, that's all scanblock does. // If the gcphase is GCscan, that's all scanblock does.
// Otherwise it traverses some fraction of the pointers it found in b, recursively. // Otherwise it traverses some fraction of the pointers it found in b, recursively.
// As a special case, scanblock(nil, 0, nil) means to scan previously queued work,
// stopping only when no work is left in the system.
//go:nowritebarrier //go:nowritebarrier
func scanblock(b0, n0 uintptr, ptrmask *uint8, wbuf *workbuf) *workbuf { func scanblock(b0, n0 uintptr, ptrmask *uint8, wbuf *workbuf) *workbuf {
// Use local copies of original parameters, so that a stack trace // Use local copies of original parameters, so that a stack trace
@ -439,7 +437,6 @@ func scanblock(b0, n0 uintptr, ptrmask *uint8, wbuf *workbuf) *workbuf {
if wbuf == nil { if wbuf == nil {
wbuf = getpartialorempty(460) // no wbuf passed in. wbuf = getpartialorempty(460) // no wbuf passed in.
} }
if b != 0 {
wbuf = scanobject(b, n, ptrmask, wbuf) wbuf = scanobject(b, n, ptrmask, wbuf)
if gcphase == _GCscan { if gcphase == _GCscan {
if inheap(b) && ptrmask == nil { if inheap(b) && ptrmask == nil {
@ -448,10 +445,8 @@ func scanblock(b0, n0 uintptr, ptrmask *uint8, wbuf *workbuf) *workbuf {
} }
return wbuf return wbuf
} }
}
drainallwbufs := b == 0 drainworkbuf(wbuf, false)
drainworkbuf(wbuf, drainallwbufs)
return nil return nil
} }