aboutsummaryrefslogtreecommitdiff
path: root/src/internal/runtime/maps/table_debug.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2024-08-21 16:17:16 -0400
committerGopher Robot <gobot@golang.org>2024-10-29 18:54:17 +0000
commited035af7b7d7c1cd2e6f852e22a9b04fc2a2cc65 (patch)
tree43fd16f1c843197c59be555e6992324ca7c1f0da /src/internal/runtime/maps/table_debug.go
parentcf967172097948a57d2e7cd037db87eaf261ec44 (diff)
downloadgo-ed035af7b7d7c1cd2e6f852e22a9b04fc2a2cc65.tar.xz
internal/runtime/maps: remove type fields
Rather than storing the same type pointer in multiple places, just pass it around. For #54766. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-swissmap Change-Id: Ia6c74805c7a44125ae473177b317f16c6688e6de Reviewed-on: https://go-review.googlesource.com/c/go/+/622377 Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/internal/runtime/maps/table_debug.go')
-rw-r--r--src/internal/runtime/maps/table_debug.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/internal/runtime/maps/table_debug.go b/src/internal/runtime/maps/table_debug.go
index 2478b02bab..27ae611ec3 100644
--- a/src/internal/runtime/maps/table_debug.go
+++ b/src/internal/runtime/maps/table_debug.go
@@ -12,7 +12,7 @@ import (
const debugLog = false
-func (t *table) checkInvariants() {
+func (t *table) checkInvariants(typ *abi.SwissMapType) {
if !debugLog {
return
}
@@ -23,7 +23,7 @@ func (t *table) checkInvariants() {
var deleted uint16
var empty uint16
for i := uint64(0); i <= t.groups.lengthMask; i++ {
- g := t.groups.group(i)
+ g := t.groups.group(typ, i)
for j := uint32(0); j < abi.SwissMapGroupSlots; j++ {
c := g.ctrls().get(j)
switch {
@@ -34,20 +34,20 @@ func (t *table) checkInvariants() {
default:
used++
- key := g.key(j)
+ key := g.key(typ, j)
// Can't lookup keys that don't compare equal
// to themselves (e.g., NaN).
- if !t.typ.Key.Equal(key, key) {
+ if !typ.Key.Equal(key, key) {
continue
}
- if _, ok := t.Get(key); !ok {
- hash := t.typ.Hasher(key, t.seed)
+ if _, ok := t.Get(typ, key); !ok {
+ hash := typ.Hasher(key, t.seed)
print("invariant failed: slot(", i, "/", j, "): key ")
- dump(key, t.typ.Key.Size_)
+ dump(key, typ.Key.Size_)
print(" not found [hash=", hash, ", h2=", h2(hash), " h1=", h1(hash), "]\n")
- t.Print()
+ t.Print(typ)
panic("invariant failed: slot: key not found")
}
}
@@ -56,30 +56,30 @@ func (t *table) checkInvariants() {
if used != t.used {
print("invariant failed: found ", used, " used slots, but used count is ", t.used, "\n")
- t.Print()
+ t.Print(typ)
panic("invariant failed: found mismatched used slot count")
}
growthLeft := (t.capacity*maxAvgGroupLoad)/abi.SwissMapGroupSlots - t.used - deleted
if growthLeft != t.growthLeft {
print("invariant failed: found ", t.growthLeft, " growthLeft, but expected ", growthLeft, "\n")
- t.Print()
+ t.Print(typ)
panic("invariant failed: found mismatched growthLeft")
}
if deleted != t.tombstones() {
print("invariant failed: found ", deleted, " tombstones, but expected ", t.tombstones(), "\n")
- t.Print()
+ t.Print(typ)
panic("invariant failed: found mismatched tombstones")
}
if empty == 0 {
print("invariant failed: found no empty slots (violates probe invariant)\n")
- t.Print()
+ t.Print(typ)
panic("invariant failed: found no empty slots (violates probe invariant)")
}
}
-func (t *table) Print() {
+func (t *table) Print(typ *abi.SwissMapType) {
print(`table{
seed: `, t.seed, `
index: `, t.index, `
@@ -93,7 +93,7 @@ func (t *table) Print() {
for i := uint64(0); i <= t.groups.lengthMask; i++ {
print("\t\tgroup ", i, "\n")
- g := t.groups.group(i)
+ g := t.groups.group(typ, i)
ctrls := g.ctrls()
for j := uint32(0); j < abi.SwissMapGroupSlots; j++ {
print("\t\t\tslot ", j, "\n")
@@ -110,10 +110,10 @@ func (t *table) Print() {
}
print("\t\t\t\tkey ")
- dump(g.key(j), t.typ.Key.Size_)
+ dump(g.key(typ, j), typ.Key.Size_)
println("")
print("\t\t\t\telem ")
- dump(g.elem(j), t.typ.Elem.Size_)
+ dump(g.elem(typ, j), typ.Elem.Size_)
println("")
}
}