This avoids some zero-extension ops on 64-bit machines.
Based on khr@'s CL 619479.
For #54766.
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-swissmap
Change-Id: Ie9a56da26382dc9e515c613abc8cf6fec3767671
Reviewed-on: https://go-review.googlesource.com/c/go/+/620216
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
}
// All full or deleted slots.
- for j := uint32(0); j < abi.SwissMapGroupSlots; j++ {
+ for j := uintptr(0); j < abi.SwissMapGroupSlots; j++ {
if g.ctrls().get(j) == ctrlDeleted {
continue
}
// first control byte in the group that has the MSB set.
//
// Returns abi.SwissMapGroupSlots if the bitset is empty.
-func (b bitset) first() uint32 {
- return uint32(sys.TrailingZeros64(uint64(b))) >> 3
+func (b bitset) first() uintptr {
+ return uintptr(sys.TrailingZeros64(uint64(b))) >> 3
}
// removeFirst removes the first set bit (that is, resets the least significant set bit to 0).
type ctrlGroup uint64
// get returns the i-th control byte.
-func (g *ctrlGroup) get(i uint32) ctrl {
+func (g *ctrlGroup) get(i uintptr) ctrl {
if goarch.BigEndian {
return *(*ctrl)(unsafe.Add(unsafe.Pointer(g), 7-i))
}
}
// set sets the i-th control byte.
-func (g *ctrlGroup) set(i uint32, c ctrl) {
+func (g *ctrlGroup) set(i uintptr, c ctrl) {
if goarch.BigEndian {
*(*ctrl)(unsafe.Add(unsafe.Pointer(g), 7-i)) = c
return
}
// key returns a pointer to the key at index i.
-func (g *groupReference) key(typ *abi.SwissMapType, i uint32) unsafe.Pointer {
- offset := groupSlotsOffset + uintptr(i)*typ.SlotSize
+func (g *groupReference) key(typ *abi.SwissMapType, i uintptr) unsafe.Pointer {
+ offset := groupSlotsOffset + i*typ.SlotSize
return unsafe.Pointer(uintptr(g.data) + offset)
}
// elem returns a pointer to the element at index i.
-func (g *groupReference) elem(typ *abi.SwissMapType, i uint32) unsafe.Pointer {
- offset := groupSlotsOffset + uintptr(i)*typ.SlotSize + typ.ElemOff
+func (g *groupReference) elem(typ *abi.SwissMapType, i uintptr) unsafe.Pointer {
+ offset := groupSlotsOffset + i*typ.SlotSize + typ.ElemOff
return unsafe.Pointer(uintptr(g.data) + offset)
}
h2 := uint8(h2(hash))
ctrls := *g.ctrls()
- for i := uint32(0); i < abi.SwissMapGroupSlots; i++ {
+ for i := uintptr(0); i < abi.SwissMapGroupSlots; i++ {
c := uint8(ctrls)
ctrls >>= 8
if c != h2 {
data: m.dirPtr,
}
- for i := uint32(0); i < abi.SwissMapGroupSlots; i++ {
+ for i := uintptr(0); i < abi.SwissMapGroupSlots; i++ {
if (g.ctrls().get(i) & ctrlEmpty) == ctrlEmpty {
// Empty
continue
h2 := uint8(h2(hash))
ctrls := *g.ctrls()
- for i := uint32(0); i < 8; i++ {
+ for i := uintptr(0); i < 8; i++ {
c := uint8(ctrls)
ctrls >>= 8
if c != h2 {
// we find, which we'll use to insert the new entry if
// necessary.
var firstDeletedGroup groupReference
- var firstDeletedSlot uint32
+ var firstDeletedSlot uintptr
for ; ; seq = seq.next() {
g := t.groups.group(typ, seq.offset)
// Finding an empty slot means we've reached the end of
// the probe sequence.
- var i uint32
+ var i uintptr
// If we found a deleted slot along the way, we
// can replace it without consuming growthLeft.
// As we look for a match, keep track of the first deleted slot we
// find, which we'll use to insert the new entry if necessary.
var firstDeletedGroup groupReference
- var firstDeletedSlot uint32
+ var firstDeletedSlot uintptr
for ; ; seq = seq.next() {
g := t.groups.group(typ, seq.offset)
// Finding an empty slot means we've reached the end of
// the probe sequence.
- var i uint32
+ var i uintptr
// If we found a deleted slot along the way, we
// can replace it without consuming growthLeft.
h2 := uint8(h2(hash))
ctrls := *g.ctrls()
- for i := uint32(0); i < 8; i++ {
+ for i := uintptr(0); i < 8; i++ {
c := uint8(ctrls)
ctrls >>= 8
if c != h2 {
// we find, which we'll use to insert the new entry if
// necessary.
var firstDeletedGroup groupReference
- var firstDeletedSlot uint32
+ var firstDeletedSlot uintptr
for ; ; seq = seq.next() {
g := t.groups.group(typ, seq.offset)
// Finding an empty slot means we've reached the end of
// the probe sequence.
- var i uint32
+ var i uintptr
// If we found a deleted slot along the way, we
// can replace it without consuming growthLeft.
// we find, which we'll use to insert the new entry if
// necessary.
var firstDeletedGroup groupReference
- var firstDeletedSlot uint32
+ var firstDeletedSlot uintptr
for ; ; seq = seq.next() {
g := t.groups.group(typ, seq.offset)
// Finding an empty slot means we've reached the end of
// the probe sequence.
- var i uint32
+ var i uintptr
// If we found a deleted slot along the way, we
// can replace it without consuming growthLeft.
h2 := uint8(h2(hash))
ctrls := *g.ctrls()
- for i := uint32(0); i < abi.SwissMapGroupSlots; i++ {
+ for i := uintptr(0); i < abi.SwissMapGroupSlots; i++ {
c := uint8(ctrls)
ctrls >>= 8
if c != h2 {
// we find, which we'll use to insert the new entry if
// necessary.
var firstDeletedGroup groupReference
- var firstDeletedSlot uint32
+ var firstDeletedSlot uintptr
for ; ; seq = seq.next() {
g := t.groups.group(typ, seq.offset)
// Finding an empty slot means we've reached the end of
// the probe sequence.
- var i uint32
+ var i uintptr
// If we found a deleted slot along the way, we
// can replace it without consuming growthLeft.
// we find, which we'll use to insert the new entry if
// necessary.
var firstDeletedGroup groupReference
- var firstDeletedSlot uint32
+ var firstDeletedSlot uintptr
for ; ; seq = seq.next() {
g := t.groups.group(typ, seq.offset)
// Finding an empty slot means we've reached the end of
// the probe sequence.
- var i uint32
+ var i uintptr
// If we found a deleted slot along the way, we
// can replace it without consuming growthLeft.
// As we look for a match, keep track of the first deleted slot we
// find, which we'll use to insert the new entry if necessary.
var firstDeletedGroup groupReference
- var firstDeletedSlot uint32
+ var firstDeletedSlot uintptr
for ; ; seq = seq.next() {
g := t.groups.group(typ, seq.offset)
// Finding an empty slot means we've reached the end of
// the probe sequence.
- var i uint32
+ var i uintptr
// If we found a deleted slot along the way, we can
// replace it without consuming growthLeft.
// Map was small at Init.
g := it.groupSmall
for ; it.entryIdx < abi.SwissMapGroupSlots; it.entryIdx++ {
- k := uint32(it.entryIdx+it.entryOffset) % abi.SwissMapGroupSlots
+ k := uintptr(it.entryIdx+it.entryOffset) % abi.SwissMapGroupSlots
if (g.ctrls().get(k) & ctrlEmpty) == ctrlEmpty {
// Empty or deleted.
// on grown below.
for ; it.entryIdx <= it.tab.groups.entryMask; it.entryIdx++ {
entryIdx := (it.entryIdx + it.entryOffset) & it.tab.groups.entryMask
- slotIdx := uint32(entryIdx & (abi.SwissMapGroupSlots - 1))
+ slotIdx := uintptr(entryIdx & (abi.SwissMapGroupSlots - 1))
if slotIdx == 0 || g.data == nil {
// Only compute the group (a) when we switch
for i := uint64(0); i <= t.groups.lengthMask; i++ {
g := t.groups.group(typ, i)
- for j := uint32(0); j < abi.SwissMapGroupSlots; j++ {
+ for j := uintptr(0); j < abi.SwissMapGroupSlots; j++ {
if (g.ctrls().get(j) & ctrlEmpty) == ctrlEmpty {
// Empty or deleted
continue
if t.capacity > 0 {
for i := uint64(0); i <= t.groups.lengthMask; i++ {
g := t.groups.group(typ, i)
- for j := uint32(0); j < abi.SwissMapGroupSlots; j++ {
+ for j := uintptr(0); j < abi.SwissMapGroupSlots; j++ {
if (g.ctrls().get(j) & ctrlEmpty) == ctrlEmpty {
// Empty or deleted
continue
var empty uint16
for i := uint64(0); i <= t.groups.lengthMask; i++ {
g := t.groups.group(typ, i)
- for j := uint32(0); j < abi.SwissMapGroupSlots; j++ {
+ for j := uintptr(0); j < abi.SwissMapGroupSlots; j++ {
c := g.ctrls().get(j)
switch {
case c == ctrlDeleted:
g := t.groups.group(typ, i)
ctrls := g.ctrls()
- for j := uint32(0); j < abi.SwissMapGroupSlots; j++ {
+ for j := uintptr(0); j < abi.SwissMapGroupSlots; j++ {
print("\t\t\tslot ", j, "\n")
c := ctrls.get(j)