]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: use morePointers and isPointer in more places
authorAustin Clements <austin@google.com>
Fri, 29 Apr 2016 19:19:11 +0000 (15:19 -0400)
committerAustin Clements <austin@google.com>
Sat, 30 Apr 2016 16:49:50 +0000 (16:49 +0000)
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/22631
Reviewed-by: Rick Hudson <rlh@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/cgocall.go
src/runtime/mgcmark.go

index fa996d24058bf0db4c331865a8a3c6f11c0ffd2e..887343edd1d1d45ea6eaa867e93c38dd61351c06 100644 (file)
@@ -559,12 +559,11 @@ func cgoCheckUnknownPointer(p unsafe.Pointer, msg string) (base, i uintptr) {
                }
                n := span.elemsize
                for i = uintptr(0); i < n; i += sys.PtrSize {
-                       bits := hbits.bits()
-                       if i >= 2*sys.PtrSize && bits&bitMarked == 0 {
+                       if i >= 2*sys.PtrSize && !hbits.morePointers() {
                                // No more possible pointers.
                                break
                        }
-                       if bits&bitPointer != 0 {
+                       if hbits.isPointer() {
                                if cgoIsGoPointer(*(*unsafe.Pointer)(unsafe.Pointer(base + i))) {
                                        panic(errorString(msg))
                                }
index 14449c3d4b401a05ada77a2229783676d9972552..8c8ce67fbfb8bd16c73f51b4b20d942ac4165c5e 100644 (file)
@@ -1132,11 +1132,10 @@ func scanobject(b uintptr, gcw *gcWork) {
                // 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
                // data into larger allocations.
-               bits := hbits.bits()
-               if i >= 2*sys.PtrSize && bits&bitMarked == 0 {
+               if i >= 2*sys.PtrSize && !hbits.morePointers() {
                        break // no more pointers in this object
                }
-               if bits&bitPointer == 0 {
+               if !hbits.isPointer() {
                        continue // not a pointer
                }