Commit d5e3d08b authored by Austin Clements's avatar Austin Clements

runtime: use morePointers and isPointer in more places

This makes this code better self-documenting and makes it easier to
find these places in the future.

Change-Id: I31dc5598ae67f937fb9ef26df92fd41d01e983c3
Reviewed-on: https://go-review.googlesource.com/22631Reviewed-by: default avatarRick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent a5d3f7ec
...@@ -559,12 +559,11 @@ func cgoCheckUnknownPointer(p unsafe.Pointer, msg string) (base, i uintptr) { ...@@ -559,12 +559,11 @@ func cgoCheckUnknownPointer(p unsafe.Pointer, msg string) (base, i uintptr) {
} }
n := span.elemsize n := span.elemsize
for i = uintptr(0); i < n; i += sys.PtrSize { for i = uintptr(0); i < n; i += sys.PtrSize {
bits := hbits.bits() if i >= 2*sys.PtrSize && !hbits.morePointers() {
if i >= 2*sys.PtrSize && bits&bitMarked == 0 {
// No more possible pointers. // No more possible pointers.
break break
} }
if bits&bitPointer != 0 { if hbits.isPointer() {
if cgoIsGoPointer(*(*unsafe.Pointer)(unsafe.Pointer(base + i))) { if cgoIsGoPointer(*(*unsafe.Pointer)(unsafe.Pointer(base + i))) {
panic(errorString(msg)) panic(errorString(msg))
} }
......
...@@ -1132,11 +1132,10 @@ func scanobject(b uintptr, gcw *gcWork) { ...@@ -1132,11 +1132,10 @@ func scanobject(b uintptr, gcw *gcWork) {
// in the type bit for the one word. The only one-word objects // in the type bit for the one word. The only one-word objects
// are pointers, or else they'd be merged with other non-pointer // are pointers, or else they'd be merged with other non-pointer
// data into larger allocations. // data into larger allocations.
bits := hbits.bits() if i >= 2*sys.PtrSize && !hbits.morePointers() {
if i >= 2*sys.PtrSize && bits&bitMarked == 0 {
break // no more pointers in this object break // no more pointers in this object
} }
if bits&bitPointer == 0 { if !hbits.isPointer() {
continue // not a pointer continue // not a pointer
} }
......
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