Commit 59877bfa authored by Gleb Stepanov's avatar Gleb Stepanov Committed by Austin Clements

runtime: rename variable

Rename variable to bitScan according to
TODO comment.

Change-Id: I81dd8cc1ca28c0dc9308a654ad65cdf5b2fd2ce3
Reviewed-on: https://go-review.googlesource.com/25175
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarAustin Clements <austin@google.com>
parent 3df926d5
...@@ -78,13 +78,13 @@ import ( ...@@ -78,13 +78,13 @@ import (
const ( const (
bitPointer = 1 << 0 bitPointer = 1 << 0
bitMarked = 1 << 4 // TODO: Rename bitScan. bitScan = 1 << 4
heapBitsShift = 1 // shift offset between successive bitPointer or bitMarked entries heapBitsShift = 1 // shift offset between successive bitPointer or bitMarked entries
heapBitmapScale = sys.PtrSize * (8 / 2) // number of data bytes described by one heap bitmap byte heapBitmapScale = sys.PtrSize * (8 / 2) // number of data bytes described by one heap bitmap byte
// all mark/pointer bits in a byte // all mark/pointer bits in a byte
bitMarkedAll = bitMarked | bitMarked<<heapBitsShift | bitMarked<<(2*heapBitsShift) | bitMarked<<(3*heapBitsShift) bitMarkedAll = bitScan | bitScan<<heapBitsShift | bitScan<<(2*heapBitsShift) | bitScan<<(3*heapBitsShift)
bitPointerAll = bitPointer | bitPointer<<heapBitsShift | bitPointer<<(2*heapBitsShift) | bitPointer<<(3*heapBitsShift) bitPointerAll = bitPointer | bitPointer<<heapBitsShift | bitPointer<<(2*heapBitsShift) | bitPointer<<(3*heapBitsShift)
) )
...@@ -494,7 +494,7 @@ func (h heapBits) bits() uint32 { ...@@ -494,7 +494,7 @@ func (h heapBits) bits() uint32 {
// are scalars. // are scalars.
// h must not describe the second word of the object. // h must not describe the second word of the object.
func (h heapBits) morePointers() bool { func (h heapBits) morePointers() bool {
return h.bits()&bitMarked != 0 return h.bits()&bitScan != 0
} }
// isPointer reports whether the heap bits describe a pointer word. // isPointer reports whether the heap bits describe a pointer word.
...@@ -512,7 +512,7 @@ func (h heapBits) hasPointers(size uintptr) bool { ...@@ -512,7 +512,7 @@ func (h heapBits) hasPointers(size uintptr) bool {
if size == sys.PtrSize { // 1-word objects are always pointers if size == sys.PtrSize { // 1-word objects are always pointers
return true return true
} }
return (*h.bitp>>h.shift)&bitMarked != 0 return (*h.bitp>>h.shift)&bitScan != 0
} }
// isCheckmarked reports whether the heap bits have the checkmarked bit set. // isCheckmarked reports whether the heap bits have the checkmarked bit set.
...@@ -527,7 +527,7 @@ func (h heapBits) isCheckmarked(size uintptr) bool { ...@@ -527,7 +527,7 @@ func (h heapBits) isCheckmarked(size uintptr) bool {
// so we know that the initial word's 2-bit pair // so we know that the initial word's 2-bit pair
// and the second word's 2-bit pair are in the // and the second word's 2-bit pair are in the
// same heap bitmap byte, *h.bitp. // same heap bitmap byte, *h.bitp.
return (*h.bitp>>(heapBitsShift+h.shift))&bitMarked != 0 return (*h.bitp>>(heapBitsShift+h.shift))&bitScan != 0
} }
// setCheckmarked sets the checkmarked bit. // setCheckmarked sets the checkmarked bit.
...@@ -539,7 +539,7 @@ func (h heapBits) setCheckmarked(size uintptr) { ...@@ -539,7 +539,7 @@ func (h heapBits) setCheckmarked(size uintptr) {
atomic.Or8(h.bitp, bitPointer<<h.shift) atomic.Or8(h.bitp, bitPointer<<h.shift)
return return
} }
atomic.Or8(h.bitp, bitMarked<<(heapBitsShift+h.shift)) atomic.Or8(h.bitp, bitScan<<(heapBitsShift+h.shift))
} }
// heapBitsBulkBarrier executes writebarrierptr_nostore // heapBitsBulkBarrier executes writebarrierptr_nostore
...@@ -758,7 +758,7 @@ func (h heapBits) initCheckmarkSpan(size, n, total uintptr) { ...@@ -758,7 +758,7 @@ func (h heapBits) initCheckmarkSpan(size, n, total uintptr) {
return return
} }
for i := uintptr(0); i < n; i++ { for i := uintptr(0); i < n; i++ {
*h.bitp &^= bitMarked << (heapBitsShift + h.shift) *h.bitp &^= bitScan << (heapBitsShift + h.shift)
h = h.forward(size / sys.PtrSize) h = h.forward(size / sys.PtrSize)
} }
} }
...@@ -918,18 +918,18 @@ func heapBitsSetType(x, size, dataSize uintptr, typ *_type) { ...@@ -918,18 +918,18 @@ func heapBitsSetType(x, size, dataSize uintptr, typ *_type) {
// 1 pointer object. On 32-bit machines clear the bit for the // 1 pointer object. On 32-bit machines clear the bit for the
// unused second word. // unused second word.
if gcphase == _GCoff { if gcphase == _GCoff {
*h.bitp &^= (bitPointer | bitMarked | ((bitPointer | bitMarked) << heapBitsShift)) << h.shift *h.bitp &^= (bitPointer | bitScan | ((bitPointer | bitScan) << heapBitsShift)) << h.shift
*h.bitp |= (bitPointer | bitMarked) << h.shift *h.bitp |= (bitPointer | bitScan) << h.shift
} else { } else {
atomic.And8(h.bitp, ^uint8((bitPointer|bitMarked|((bitPointer|bitMarked)<<heapBitsShift))<<h.shift)) atomic.And8(h.bitp, ^uint8((bitPointer|bitScan|((bitPointer|bitScan)<<heapBitsShift))<<h.shift))
atomic.Or8(h.bitp, (bitPointer|bitMarked)<<h.shift) atomic.Or8(h.bitp, (bitPointer|bitScan)<<h.shift)
} }
} else { } else {
// 2-element slice of pointer. // 2-element slice of pointer.
if gcphase == _GCoff { if gcphase == _GCoff {
*h.bitp |= (bitPointer | bitMarked | bitPointer<<heapBitsShift) << h.shift *h.bitp |= (bitPointer | bitScan | bitPointer<<heapBitsShift) << h.shift
} else { } else {
atomic.Or8(h.bitp, (bitPointer|bitMarked|bitPointer<<heapBitsShift)<<h.shift) atomic.Or8(h.bitp, (bitPointer|bitScan|bitPointer<<heapBitsShift)<<h.shift)
} }
} }
return return
...@@ -943,13 +943,13 @@ func heapBitsSetType(x, size, dataSize uintptr, typ *_type) { ...@@ -943,13 +943,13 @@ func heapBitsSetType(x, size, dataSize uintptr, typ *_type) {
} }
} }
b := uint32(*ptrmask) b := uint32(*ptrmask)
hb := (b & 3) | bitMarked hb := (b & 3) | bitScan
if gcphase == _GCoff { if gcphase == _GCoff {
// bitPointer == 1, bitMarked is 1 << 4, heapBitsShift is 1. // bitPointer == 1, bitMarked is 1 << 4, heapBitsShift is 1.
// 110011 is shifted h.shift and complemented. // 110011 is shifted h.shift and complemented.
// This clears out the bits that are about to be // This clears out the bits that are about to be
// ored into *h.hbitp in the next instructions. // ored into *h.hbitp in the next instructions.
*h.bitp &^= (bitPointer | bitMarked | ((bitPointer | bitMarked) << heapBitsShift)) << h.shift *h.bitp &^= (bitPointer | bitScan | ((bitPointer | bitScan) << heapBitsShift)) << h.shift
*h.bitp |= uint8(hb << h.shift) *h.bitp |= uint8(hb << h.shift)
} else { } else {
// TODO:(rlh) since the GC is not concurrently setting the // TODO:(rlh) since the GC is not concurrently setting the
...@@ -957,7 +957,7 @@ func heapBitsSetType(x, size, dataSize uintptr, typ *_type) { ...@@ -957,7 +957,7 @@ func heapBitsSetType(x, size, dataSize uintptr, typ *_type) {
// owns the span we are allocating in why does this have // owns the span we are allocating in why does this have
// to be atomic? // to be atomic?
atomic.And8(h.bitp, ^uint8((bitPointer|bitMarked|((bitPointer|bitMarked)<<heapBitsShift))<<h.shift)) atomic.And8(h.bitp, ^uint8((bitPointer|bitScan|((bitPointer|bitScan)<<heapBitsShift))<<h.shift))
atomic.Or8(h.bitp, uint8(hb<<h.shift)) atomic.Or8(h.bitp, uint8(hb<<h.shift))
} }
return return
...@@ -1151,7 +1151,7 @@ func heapBitsSetType(x, size, dataSize uintptr, typ *_type) { ...@@ -1151,7 +1151,7 @@ func heapBitsSetType(x, size, dataSize uintptr, typ *_type) {
// TODO: It doesn't matter if we set the checkmark, so // TODO: It doesn't matter if we set the checkmark, so
// maybe this case isn't needed any more. // maybe this case isn't needed any more.
hb = b & bitPointerAll hb = b & bitPointerAll
hb |= bitMarked | bitMarked<<(2*heapBitsShift) | bitMarked<<(3*heapBitsShift) hb |= bitScan | bitScan<<(2*heapBitsShift) | bitScan<<(3*heapBitsShift)
if w += 4; w >= nw { if w += 4; w >= nw {
goto Phase3 goto Phase3
} }
...@@ -1174,16 +1174,16 @@ func heapBitsSetType(x, size, dataSize uintptr, typ *_type) { ...@@ -1174,16 +1174,16 @@ func heapBitsSetType(x, size, dataSize uintptr, typ *_type) {
hb = (b & (bitPointer | bitPointer<<heapBitsShift)) << (2 * heapBitsShift) hb = (b & (bitPointer | bitPointer<<heapBitsShift)) << (2 * heapBitsShift)
// This is not noscan, so set the scan bit in the // This is not noscan, so set the scan bit in the
// first word. // first word.
hb |= bitMarked << (2 * heapBitsShift) hb |= bitScan << (2 * heapBitsShift)
b >>= 2 b >>= 2
nb -= 2 nb -= 2
// Note: no bitMarker for second word because that's // Note: no bitMarker for second word because that's
// the checkmark. // the checkmark.
if gcphase == _GCoff { if gcphase == _GCoff {
*hbitp &^= uint8((bitPointer | bitMarked | (bitPointer << heapBitsShift)) << (2 * heapBitsShift)) *hbitp &^= uint8((bitPointer | bitScan | (bitPointer << heapBitsShift)) << (2 * heapBitsShift))
*hbitp |= uint8(hb) *hbitp |= uint8(hb)
} else { } else {
atomic.And8(hbitp, ^(uint8(bitPointer|bitMarked|bitPointer<<heapBitsShift) << (2 * heapBitsShift))) atomic.And8(hbitp, ^(uint8(bitPointer|bitScan|bitPointer<<heapBitsShift) << (2 * heapBitsShift)))
atomic.Or8(hbitp, uint8(hb)) atomic.Or8(hbitp, uint8(hb))
} }
hbitp = subtract1(hbitp) hbitp = subtract1(hbitp)
...@@ -1302,9 +1302,9 @@ Phase3: ...@@ -1302,9 +1302,9 @@ Phase3:
// The byte is shared with the next object so we may need an atomic. // The byte is shared with the next object so we may need an atomic.
if w == nw+2 { if w == nw+2 {
if gcphase == _GCoff { if gcphase == _GCoff {
*hbitp = *hbitp&^(bitPointer|bitMarked|(bitPointer|bitMarked)<<heapBitsShift) | uint8(hb) *hbitp = *hbitp&^(bitPointer|bitScan|(bitPointer|bitScan)<<heapBitsShift) | uint8(hb)
} else { } else {
atomic.And8(hbitp, ^uint8(bitPointer|bitMarked|(bitPointer|bitMarked)<<heapBitsShift)) atomic.And8(hbitp, ^uint8(bitPointer|bitScan|(bitPointer|bitScan)<<heapBitsShift))
atomic.Or8(hbitp, uint8(hb)) atomic.Or8(hbitp, uint8(hb))
} }
} }
...@@ -1333,20 +1333,20 @@ Phase4: ...@@ -1333,20 +1333,20 @@ Phase4:
for i := uintptr(0); i < size/sys.PtrSize; i++ { for i := uintptr(0); i < size/sys.PtrSize; i++ {
j := i % ndata j := i % ndata
var have, want uint8 var have, want uint8
have = (*h.bitp >> h.shift) & (bitPointer | bitMarked) have = (*h.bitp >> h.shift) & (bitPointer | bitScan)
if i >= totalptr { if i >= totalptr {
want = 0 // deadmarker want = 0 // deadmarker
if typ.kind&kindGCProg != 0 && i < (totalptr+3)/4*4 { if typ.kind&kindGCProg != 0 && i < (totalptr+3)/4*4 {
want = bitMarked want = bitScan
} }
} else { } else {
if j < nptr && (*addb(ptrmask, j/8)>>(j%8))&1 != 0 { if j < nptr && (*addb(ptrmask, j/8)>>(j%8))&1 != 0 {
want |= bitPointer want |= bitPointer
} }
if i != 1 { if i != 1 {
want |= bitMarked want |= bitScan
} else { } else {
have &^= bitMarked have &^= bitScan
} }
} }
if have != want { if have != want {
...@@ -1377,7 +1377,7 @@ Phase4: ...@@ -1377,7 +1377,7 @@ Phase4:
// of x in the heap bitmap to scalar/dead. // of x in the heap bitmap to scalar/dead.
func heapBitsSetTypeNoScan(x uintptr) { func heapBitsSetTypeNoScan(x uintptr) {
h := heapBitsForAddr(uintptr(x)) h := heapBitsForAddr(uintptr(x))
*h.bitp &^= (bitPointer | bitMarked) << h.shift *h.bitp &^= (bitPointer | bitScan) << h.shift
} }
var debugPtrmask struct { var debugPtrmask struct {
......
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