Commit a5d3f7ec authored by Austin Clements's avatar Austin Clements

runtime: avoid conditional execution in morePointers and isPointer

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/22630Reviewed-by: 's avatarRick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 7a60a962
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment