From c2de2f87f08c6ebdae095a84dd8c2c8c5ecfc671 Mon Sep 17 00:00:00 2001
From: Austin Clements <austin@google.com>
Date: Thu, 12 Feb 2015 15:00:54 -0500
Subject: [PATCH] runtime: move checknocurrentwbuf() from scanblock to
 drainworkbuf

Previously, scanblock called checknocurrentwbuf() after
drainworkbuf().  Move this call into drainworkbuf so that every return
path from drainworkbuf calls checknocurrentwbuf().  This is equivalent
to the previous code because scanblock was the only caller of
drainworkbuf.

Change-Id: I96ef2168c8aa169bfc4d368f296342fa0fbeafb4
Reviewed-on: https://go-review.googlesource.com/4780
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
---
 src/runtime/mgc.go | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go
index 4c7a6790a0..afca568e0b 100644
--- a/src/runtime/mgc.go
+++ b/src/runtime/mgc.go
@@ -452,7 +452,6 @@ func scanblock(b0, n0 uintptr, ptrmask *uint8, wbuf *workbuf) *workbuf {
 
 	drainallwbufs := b == 0
 	drainworkbuf(wbuf, drainallwbufs)
-	checknocurrentwbuf()
 	return nil
 }
 
@@ -471,13 +470,12 @@ func drainworkbuf(wbuf *workbuf, drainallwbufs bool) {
 		if wbuf.nobj == 0 {
 			putempty(wbuf, 496)
 			if !drainallwbufs {
-				checknocurrentwbuf()
-				return
+				break
 			}
 			// Refill workbuf from global queue.
 			wbuf = getfull(504)
 			if wbuf == nil { // nil means out of work barrier reached
-				return
+				break
 			}
 			wbuf.checknonempty()
 		}
@@ -501,6 +499,7 @@ func drainworkbuf(wbuf *workbuf, drainallwbufs bool) {
 		// a performance hit as we keep fetching fresh wbufs.
 		wbuf = scanobject(b, 0, nil, wbuf)
 	}
+	checknocurrentwbuf()
 }
 
 // Scan count objects starting with those in wbuf.
-- 
2.30.9