From: Josh Bleecher Snyder Date: Sun, 20 Aug 2017 18:47:50 +0000 (-0700) Subject: runtime: mask shifts in map implementation on x86 X-Git-Tag: go1.10beta1~1394 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f7aa454c58ed0d06823f509fc39474b6f52f7c3a;p=gostls13.git runtime: mask shifts in map implementation on x86 This slightly improves the generated code on x86 architectures, including on many hot paths. It is a no-op on other architectures. Change-Id: I86336fd846bc5805a27bbec572e8c73dcbd0d567 Reviewed-on: https://go-review.googlesource.com/57411 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- diff --git a/src/runtime/hashmap.go b/src/runtime/hashmap.go index 60af870fac..df4df053d1 100644 --- a/src/runtime/hashmap.go +++ b/src/runtime/hashmap.go @@ -170,6 +170,19 @@ type hiter struct { checkBucket uintptr } +// bucketShift returns 1<> (sys.PtrSize*8 - 8)) @@ -374,7 +387,7 @@ func mapaccess1(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer { } alg := t.key.alg hash := alg.hash(key, uintptr(h.hash0)) - m := uintptr(1)< 31-bucketCntBits { r += uintptr(fastrand()) << 31 } - it.startBucket = r & (uintptr(1)<> h.B & (bucketCnt - 1)) // iterator state @@ -817,7 +830,7 @@ next: checkBucket = noCheck } bucket++ - if bucket == uintptr(1)<= bucketCnt && uint64(count) >= loadFactorNum*((uint64(1)<= bucketCnt && uintptr(count) >= loadFactorNum*(bucketShift(B)/loadFactorDen) } // tooManyOverflowBuckets reports whether noverflow buckets is too many for a map with 1<