mirror of
https://github.com/golang/go
synced 2024-09-24 19:20:13 -06:00
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/22630 Reviewed-by: Rick Hudson <rlh@golang.org> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
7a60a962b9
commit
a5d3f7ece9
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user