From 4f7dc282c4bdfba4e63b39bbe9846c1469dc7ee5 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Fri, 19 Apr 2024 13:52:31 -0400 Subject: all: split old and swiss map abi and compiler integration The two map implementations are still identical, but now the compiler targets the appropriate ABI depending on GOEXPERIMENT. For #54766. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-amd64-longtest-swissmap Change-Id: I8438f64f044ba9de30ddbf2b8ceb9b4edd2d5614 Reviewed-on: https://go-review.googlesource.com/c/go/+/580779 Reviewed-by: Michael Knyszek Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI Auto-Submit: Michael Pratt --- src/runtime/type.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/runtime/type.go') diff --git a/src/runtime/type.go b/src/runtime/type.go index 201340752b..5e5c99276c 100644 --- a/src/runtime/type.go +++ b/src/runtime/type.go @@ -8,6 +8,7 @@ package runtime import ( "internal/abi" + "internal/goexperiment" "unsafe" ) @@ -235,8 +236,6 @@ type uncommontype = abi.UncommonType type interfacetype = abi.InterfaceType -type maptype = abi.MapType - type arraytype = abi.ArrayType type chantype = abi.ChanType @@ -439,8 +438,13 @@ func typesEqual(t, v *_type, seen map[_typePair]struct{}) bool { } return true case abi.Map: - mt := (*maptype)(unsafe.Pointer(t)) - mv := (*maptype)(unsafe.Pointer(v)) + if goexperiment.SwissMap { + mt := (*abi.SwissMapType)(unsafe.Pointer(t)) + mv := (*abi.SwissMapType)(unsafe.Pointer(v)) + return typesEqual(mt.Key, mv.Key, seen) && typesEqual(mt.Elem, mv.Elem, seen) + } + mt := (*abi.OldMapType)(unsafe.Pointer(t)) + mv := (*abi.OldMapType)(unsafe.Pointer(v)) return typesEqual(mt.Key, mv.Key, seen) && typesEqual(mt.Elem, mv.Elem, seen) case abi.Pointer: pt := (*ptrtype)(unsafe.Pointer(t)) -- cgit v1.3