]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: eliminate b == 0 special case from scanblock
authorAustin Clements <austin@google.com>
Thu, 12 Feb 2015 20:20:13 +0000 (15:20 -0500)
committerAustin Clements <austin@google.com>
Fri, 13 Feb 2015 15:34:34 +0000 (15:34 +0000)
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>
src/runtime/mgc.go

index 3f361c1b4d9cf8340fb9ec16228982ae0390e0a8..27b3b1158f75333dbbd51889940b3c057f5a6c33 100644 (file)
@@ -422,8 +422,6 @@ func scanobject(b, n uintptr, ptrmask *uint8, wbuf *workbuf) *workbuf {
 // scanblock starts by scanning b as scanobject would.
 // If the gcphase is GCscan, that's all scanblock does.
 // 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
 func scanblock(b0, n0 uintptr, ptrmask *uint8, wbuf *workbuf) *workbuf {
        // Use local copies of original parameters, so that a stack trace
@@ -439,19 +437,16 @@ func scanblock(b0, n0 uintptr, ptrmask *uint8, wbuf *workbuf) *workbuf {
        if wbuf == nil {
                wbuf = getpartialorempty(460) // no wbuf passed in.
        }
-       if b != 0 {
-               wbuf = scanobject(b, n, ptrmask, wbuf)
-               if gcphase == _GCscan {
-                       if inheap(b) && ptrmask == nil {
-                               // b is in heap, we are in GCscan so there should be a ptrmask.
-                               throw("scanblock: In GCscan phase and inheap is true.")
-                       }
-                       return wbuf
+       wbuf = scanobject(b, n, ptrmask, wbuf)
+       if gcphase == _GCscan {
+               if inheap(b) && ptrmask == nil {
+                       // b is in heap, we are in GCscan so there should be a ptrmask.
+                       throw("scanblock: In GCscan phase and inheap is true.")
                }
+               return wbuf
        }
 
-       drainallwbufs := b == 0
-       drainworkbuf(wbuf, drainallwbufs)
+       drainworkbuf(wbuf, false)
        return nil
 }