diff options
| author | Michael Pratt <mpratt@google.com> | 2024-08-21 16:17:16 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-10-29 18:54:17 +0000 |
| commit | ed035af7b7d7c1cd2e6f852e22a9b04fc2a2cc65 (patch) | |
| tree | 43fd16f1c843197c59be555e6992324ca7c1f0da /src/runtime | |
| parent | cf967172097948a57d2e7cd037db87eaf261ec44 (diff) | |
| download | go-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/runtime')
| -rw-r--r-- | src/runtime/map_swiss.go | 12 | ||||
| -rw-r--r-- | src/runtime/map_swiss_test.go | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/runtime/map_swiss.go b/src/runtime/map_swiss.go index e62def9677..3ea82b547f 100644 --- a/src/runtime/map_swiss.go +++ b/src/runtime/map_swiss.go @@ -122,7 +122,7 @@ func mapaccess1(t *abi.SwissMapType, m *maps.Map, key unsafe.Pointer) unsafe.Poi return unsafe.Pointer(&zeroVal[0]) } - elem, ok := m.Get(key) + elem, ok := m.Get(t, key) if !ok { return unsafe.Pointer(&zeroVal[0]) } @@ -151,7 +151,7 @@ func mapaccess2(t *abi.SwissMapType, m *maps.Map, key unsafe.Pointer) (unsafe.Po return unsafe.Pointer(&zeroVal[0]), false } - elem, ok := m.Get(key) + elem, ok := m.Get(t, key) if !ok { return unsafe.Pointer(&zeroVal[0]), false } @@ -192,7 +192,7 @@ func mapassign(t *abi.SwissMapType, m *maps.Map, key unsafe.Pointer) unsafe.Poin asanread(key, t.Key.Size_) } - return m.PutSlot(key) + return m.PutSlot(t, key) } func mapdelete(t *abi.SwissMapType, m *maps.Map, key unsafe.Pointer) { @@ -217,7 +217,7 @@ func mapdelete(t *abi.SwissMapType, m *maps.Map, key unsafe.Pointer) { return } - m.Delete(key) + m.Delete(t, key) } // mapiterinit initializes the Iter struct used for ranging over maps. @@ -257,7 +257,7 @@ func mapclear(t *abi.SwissMapType, m *maps.Map) { return } - m.Clear() + m.Clear(t) } // Reflect stubs. Called from ../reflect/asm_*.s @@ -386,7 +386,7 @@ func mapclone2(t *abi.SwissMapType, src *maps.Map) *maps.Map { var iter maps.Iter iter.Init(t, src) for iter.Next(); iter.Key() != nil; iter.Next() { - dst.Put(iter.Key(), iter.Elem()) + dst.Put(t, iter.Key(), iter.Elem()) } return dst diff --git a/src/runtime/map_swiss_test.go b/src/runtime/map_swiss_test.go index 536e5eec32..d5c9fdbe46 100644 --- a/src/runtime/map_swiss_test.go +++ b/src/runtime/map_swiss_test.go @@ -18,8 +18,8 @@ import ( func TestHmapSize(t *testing.T) { // The structure of Map is defined in internal/runtime/maps/map.go // and in cmd/compile/internal/reflectdata/map_swiss.go and must be in sync. - // The size of Map should be 56 bytes on 64 bit and 36 bytes on 32 bit platforms. - wantSize := uintptr(2*8 + 5*goarch.PtrSize) + // The size of Map should be 48 bytes on 64 bit and 32 bytes on 32 bit platforms. + wantSize := uintptr(2*8 + 4*goarch.PtrSize) gotSize := unsafe.Sizeof(maps.Map{}) if gotSize != wantSize { t.Errorf("sizeof(maps.Map{})==%d, want %d", gotSize, wantSize) |
