]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: avoid conditional execution in morePointers and isPointer
authorAustin Clements <austin@google.com>
Fri, 29 Apr 2016 19:17:34 +0000 (15:17 -0400)
committerAustin Clements <austin@google.com>
Sat, 30 Apr 2016 16:49:47 +0000 (16:49 +0000)
heapBits.bits is carefully written to produce good machine code. Use
it in heapBits.morePointers and heapBits.isPointer to get good machine
code there, too.

Change-Id: I208c7d0d38697e7a22cad67f692162589b75f1e2
Reviewed-on: https://go-review.googlesource.com/22630
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/mbitmap.go

index 9df64cb168eda57a8a1b66327b50157e99ed8c90..0bfb18494591adcb3b7126bc7edd9e483b3a779e 100644 (file)
@@ -492,7 +492,7 @@ func (h heapBits) bits() uint32 {
 // are scalars.
 // h must not describe the first or second word of the object.
 func (h heapBits) morePointers() bool {
-       return *h.bitp&(bitMarked<<h.shift) != 0
+       return h.bits()&bitMarked != 0
 }
 
 // isPointer reports whether the heap bits describe a pointer word.
@@ -501,7 +501,7 @@ func (h heapBits) morePointers() bool {
 // nosplit because it is used during write barriers and must not be preempted.
 //go:nosplit
 func (h heapBits) isPointer() bool {
-       return (*h.bitp>>h.shift)&bitPointer != 0
+       return h.bits()&bitPointer != 0
 }
 
 // hasPointers reports whether the given object has any pointers.