From b096ddb9ea84efa28eafd7850b8f8a8b3e76e49f Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Sat, 9 Aug 2025 02:01:55 +0000 Subject: internal/runtime/maps: loop invariant code motion with h2(hash) by hand Change-Id: I0cd9763aeedfe326bc566da39b8be0d0ebd113ec GitHub-Last-Rev: 1ec88644148deb41eea2ae89f7f1fb1759b37c27 GitHub-Pull-Request: golang/go#74952 Reviewed-on: https://go-review.googlesource.com/c/go/+/694016 Auto-Submit: Michael Pratt Reviewed-by: Keith Randall Reviewed-by: Dmitri Shuralyov Reviewed-by: Michael Pratt LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall --- src/internal/runtime/maps/runtime_faststr.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/internal/runtime/maps/runtime_faststr.go') diff --git a/src/internal/runtime/maps/runtime_faststr.go b/src/internal/runtime/maps/runtime_faststr.go index ddac7eacc5..374468b664 100644 --- a/src/internal/runtime/maps/runtime_faststr.go +++ b/src/internal/runtime/maps/runtime_faststr.go @@ -131,10 +131,11 @@ func runtime_mapaccess1_faststr(typ *abi.MapType, m *Map, key string) unsafe.Poi // Probe table. seq := makeProbeSeq(h1(hash), t.groups.lengthMask) + h2Hash := h2(hash) for ; ; seq = seq.next() { g := t.groups.group(typ, seq.offset) - match := g.ctrls().matchH2(h2(hash)) + match := g.ctrls().matchH2(h2Hash) for match != 0 { i := match.first() @@ -190,10 +191,11 @@ func runtime_mapaccess2_faststr(typ *abi.MapType, m *Map, key string) (unsafe.Po // Probe table. seq := makeProbeSeq(h1(hash), t.groups.lengthMask) + h2Hash := h2(hash) for ; ; seq = seq.next() { g := t.groups.group(typ, seq.offset) - match := g.ctrls().matchH2(h2(hash)) + match := g.ctrls().matchH2(h2Hash) for match != 0 { i := match.first() @@ -313,9 +315,10 @@ outer: var firstDeletedGroup groupReference var firstDeletedSlot uintptr + h2Hash := h2(hash) for ; ; seq = seq.next() { g := t.groups.group(typ, seq.offset) - match := g.ctrls().matchH2(h2(hash)) + match := g.ctrls().matchH2(h2Hash) // Look for an existing slot containing this key. for match != 0 { @@ -373,7 +376,7 @@ outer: slotElem = g.elem(typ, i) - g.ctrls().set(i, ctrl(h2(hash))) + g.ctrls().set(i, ctrl(h2Hash)) t.growthLeft-- t.used++ m.used++ -- cgit v1.3