]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: trivial clean ups to greyobject
authorAustin Clements <austin@google.com>
Fri, 27 Feb 2015 17:41:20 +0000 (12:41 -0500)
committerAustin Clements <austin@google.com>
Fri, 27 Feb 2015 19:39:57 +0000 (19:39 +0000)
Previously, the typeDead check in greyobject was under a separate
!useCheckmark conditional.  Put it with the rest of the !useCheckmark
code.  Also move a comment about atomic update of the marked bit to
where we actually do that update now.

Change-Id: Ief5f16401a25739ad57d959607b8d81ffe0bc211
Reviewed-on: https://go-review.googlesource.com/6271
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mbitmap.go
src/runtime/mgcmark.go

index 702fccae985e908033ef31ad076d1fc3093dc226..45920443639c9b776e448654905a2fbbd649fc82 100644 (file)
@@ -234,6 +234,10 @@ func (h heapBits) isMarked() bool {
 
 // setMarked sets the marked bit in the heap bits, atomically.
 func (h heapBits) setMarked() {
+       // Each byte of GC bitmap holds info for two words.
+       // Might be racing with other updates, so use atomic update always.
+       // We used to be clever here and use a non-atomic update in certain
+       // cases, but it's not worth the risk.
        atomicor8(h.bitp, bitMarked<<h.shift)
 }
 
index 50e125dc2703b131d497bfb60a0eb42be144f072..494c3c162142578f5c88bd6d8c567d161b5ea818 100644 (file)
@@ -577,15 +577,13 @@ func greyobject(obj, base, off uintptr, hbits heapBits, gcw *gcWorkProducer) {
                        return
                }
 
-               // Each byte of GC bitmap holds info for two words.
-               // Might be racing with other updates, so use atomic update always.
-               // We used to be clever here and use a non-atomic update in certain
-               // cases, but it's not worth the risk.
                hbits.setMarked()
-       }
 
-       if !useCheckmark && hbits.typeBits() == typeDead {
-               return // noscan object
+               // If this is a noscan object, fast-track it to black
+               // instead of greying it.
+               if hbits.typeBits() == typeDead {
+                       return
+               }
        }
 
        // Queue the obj for scanning. The PREFETCH(obj) logic has been removed but