]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: eliminate heapBits.hasPointers
authorAustin Clements <austin@google.com>
Thu, 2 Jun 2016 15:07:41 +0000 (11:07 -0400)
committerAustin Clements <austin@google.com>
Fri, 28 Apr 2017 22:50:34 +0000 (22:50 +0000)
This is no longer necessary now that we can more efficiently consult
the span's noscan bit.

This is a cherry-pick of dev.garbage commit 312aa09996.

Change-Id: Id0b00b278533660973f45eb6efa5b00f373d58af
Reviewed-on: https://go-review.googlesource.com/41252
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/mbitmap.go
src/runtime/mgcmark.go

index 844e662a048b3bd48b00aa17366506a0c44a7b11..48754de56201006d7ebc13beb2825cda7a79e652 100644 (file)
@@ -495,17 +495,6 @@ func (h heapBits) isPointer() bool {
        return h.bits()&bitPointer != 0
 }
 
-// hasPointers reports whether the given object has any pointers.
-// It must be told how large the object at h is for efficiency.
-// h must describe the initial word of the object.
-func (h heapBits) hasPointers(size uintptr) bool {
-       // TODO: Use span.noScan instead of the heap bitmap.
-       if size == sys.PtrSize { // 1-word objects are always pointers
-               return true
-       }
-       return (*h.bitp>>h.shift)&bitScan != 0
-}
-
 // isCheckmarked reports whether the heap bits have the checkmarked bit set.
 // It must be told how large the object at h is, because the encoding of the
 // checkmark bit varies by size.
index 1046aa896e1b05550820ba00e6ed38d402682749..dbca5cd1c760099c734a54dfeceff759f52f6277 100644 (file)
@@ -1127,7 +1127,7 @@ func scanobject(b uintptr, gcw *gcWork) {
                        // paths), in which case we must *not* enqueue
                        // oblets since their bitmaps will be
                        // uninitialized.
-                       if !hbits.hasPointers(n) {
+                       if s.spanclass.noscan() {
                                // Bypass the whole scan.
                                gcw.bytesMarked += uint64(n)
                                return
@@ -1257,7 +1257,7 @@ func greyobject(obj, base, off uintptr, hbits heapBits, span *mspan, gcw *gcWork
                atomic.Or8(mbits.bytep, mbits.mask)
                // If this is a noscan object, fast-track it to black
                // instead of greying it.
-               if !hbits.hasPointers(span.elemsize) {
+               if span.spanclass.noscan() {
                        gcw.bytesMarked += uint64(span.elemsize)
                        return
                }