From c39bc22c141bc6990e4e2abf604dcf56669ff779 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Fri, 3 May 2024 13:03:04 -0400 Subject: all: wire up swisstable maps Use the new SwissTable-based map in internal/runtime/maps as the basis for the runtime map when GOEXPERIMENT=swissmap. Integration is complete enough to pass all.bash. Notable missing features: * Race integration / concurrent write detection * Stack-allocated maps * Specialized "fast" map variants * Indirect key / elem For #54766. Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64_power10,gotip-linux-amd64-longtest-swissmap Change-Id: Ie97b656b6d8e05c0403311ae08fef9f51756a639 Reviewed-on: https://go-review.googlesource.com/c/go/+/594596 Reviewed-by: Keith Randall Reviewed-by: Keith Randall Reviewed-by: Michael Knyszek LUCI-TryBot-Result: Go LUCI --- src/internal/runtime/maps/export_test.go | 42 ++++++-------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) (limited to 'src/internal/runtime/maps/export_test.go') diff --git a/src/internal/runtime/maps/export_test.go b/src/internal/runtime/maps/export_test.go index e2512d332a..2856a7314e 100644 --- a/src/internal/runtime/maps/export_test.go +++ b/src/internal/runtime/maps/export_test.go @@ -6,7 +6,6 @@ package maps import ( "internal/abi" - sabi "internal/runtime/maps/internal/abi" "unsafe" ) @@ -16,41 +15,16 @@ const DebugLog = debugLog var AlignUpPow2 = alignUpPow2 -type instantiatedGroup[K comparable, V any] struct { - ctrls ctrlGroup - slots [sabi.SwissMapGroupSlots]instantiatedSlot[K, V] -} - -type instantiatedSlot[K comparable, V any] struct { - key K - elem V +func (t *table) Type() *abi.SwissMapType { + return t.typ } -func NewTestTable[K comparable, V any](length uint64) *table { - var m map[K]V - mTyp := abi.TypeOf(m) - omt := (*abi.OldMapType)(unsafe.Pointer(mTyp)) - - var grp instantiatedGroup[K, V] - var slot instantiatedSlot[K, V] - - mt := &sabi.SwissMapType{ - Key: omt.Key, - Elem: omt.Elem, - Group: abi.TypeOf(grp), - Hasher: omt.Hasher, - SlotSize: unsafe.Sizeof(slot), - ElemOff: unsafe.Offsetof(slot.elem), - } - if omt.NeedKeyUpdate() { - mt.Flags |= sabi.SwissMapNeedKeyUpdate - } - if omt.HashMightPanic() { - mt.Flags |= sabi.SwissMapHashMightPanic - } - return newTable(mt, length) +// Returns the start address of the groups array. +func (t *table) GroupsStart() unsafe.Pointer { + return t.groups.data } -func (t *table) Type() *sabi.SwissMapType { - return t.typ +// Returns the length of the groups array. +func (t *table) GroupsLength() uintptr { + return uintptr(t.groups.lengthMask + 1) } -- cgit v1.3-5-g9baa