aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/map_fast64.go
diff options
context:
space:
mode:
authorqiulaidongfeng <2645477756@qq.com>2024-01-31 03:51:34 +0000
committerKeith Randall <khr@golang.org>2024-02-27 20:56:00 +0000
commitfdb200834feb8bd8e5d0073d83c51f68e364d0fd (patch)
treea67da0475d5beaa44cfcd2235b40fb92e81720a9 /src/runtime/map_fast64.go
parent24070cf747d8b3f4487f1ca7247dcdf0ac266e8c (diff)
downloadgo-fdb200834feb8bd8e5d0073d83c51f68e364d0fd.tar.xz
runtime: use MapMaxKeyBytes,MapMaxElemBytes,MapBucketCount of internal/abi
For #59670 Change-Id: I9265e033bf3a84c3dc7b4a5d52c0df9672435f0d GitHub-Last-Rev: 8e4099095cec9e774abe9b72212a1eab6f6f9fdb GitHub-Pull-Request: golang/go#64774 Reviewed-on: https://go-review.googlesource.com/c/go/+/550117 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime/map_fast64.go')
-rw-r--r--src/runtime/map_fast64.go42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/runtime/map_fast64.go b/src/runtime/map_fast64.go
index 7ca35ec6cb..48dea02e39 100644
--- a/src/runtime/map_fast64.go
+++ b/src/runtime/map_fast64.go
@@ -41,9 +41,9 @@ func mapaccess1_fast64(t *maptype, h *hmap, key uint64) unsafe.Pointer {
}
}
for ; b != nil; b = b.overflow(t) {
- for i, k := uintptr(0), b.keys(); i < bucketCnt; i, k = i+1, add(k, 8) {
+ for i, k := uintptr(0), b.keys(); i < abi.MapBucketCount; i, k = i+1, add(k, 8) {
if *(*uint64)(k) == key && !isEmpty(b.tophash[i]) {
- return add(unsafe.Pointer(b), dataOffset+bucketCnt*8+i*uintptr(t.ValueSize))
+ return add(unsafe.Pointer(b), dataOffset+abi.MapBucketCount*8+i*uintptr(t.ValueSize))
}
}
}
@@ -81,9 +81,9 @@ func mapaccess2_fast64(t *maptype, h *hmap, key uint64) (unsafe.Pointer, bool) {
}
}
for ; b != nil; b = b.overflow(t) {
- for i, k := uintptr(0), b.keys(); i < bucketCnt; i, k = i+1, add(k, 8) {
+ for i, k := uintptr(0), b.keys(); i < abi.MapBucketCount; i, k = i+1, add(k, 8) {
if *(*uint64)(k) == key && !isEmpty(b.tophash[i]) {
- return add(unsafe.Pointer(b), dataOffset+bucketCnt*8+i*uintptr(t.ValueSize)), true
+ return add(unsafe.Pointer(b), dataOffset+abi.MapBucketCount*8+i*uintptr(t.ValueSize)), true
}
}
}
@@ -123,7 +123,7 @@ again:
bucketloop:
for {
- for i := uintptr(0); i < bucketCnt; i++ {
+ for i := uintptr(0); i < abi.MapBucketCount; i++ {
if isEmpty(b.tophash[i]) {
if insertb == nil {
insertb = b
@@ -163,7 +163,7 @@ bucketloop:
insertb = h.newoverflow(t, b)
inserti = 0 // not necessary, but avoids needlessly spilling inserti
}
- insertb.tophash[inserti&(bucketCnt-1)] = tophash(hash) // mask inserti to avoid bounds checks
+ insertb.tophash[inserti&(abi.MapBucketCount-1)] = tophash(hash) // mask inserti to avoid bounds checks
insertk = add(unsafe.Pointer(insertb), dataOffset+inserti*8)
// store new key at insert position
@@ -172,7 +172,7 @@ bucketloop:
h.count++
done:
- elem := add(unsafe.Pointer(insertb), dataOffset+bucketCnt*8+inserti*uintptr(t.ValueSize))
+ elem := add(unsafe.Pointer(insertb), dataOffset+abi.MapBucketCount*8+inserti*uintptr(t.ValueSize))
if h.flags&hashWriting == 0 {
fatal("concurrent map writes")
}
@@ -213,7 +213,7 @@ again:
bucketloop:
for {
- for i := uintptr(0); i < bucketCnt; i++ {
+ for i := uintptr(0); i < abi.MapBucketCount; i++ {
if isEmpty(b.tophash[i]) {
if insertb == nil {
insertb = b
@@ -253,7 +253,7 @@ bucketloop:
insertb = h.newoverflow(t, b)
inserti = 0 // not necessary, but avoids needlessly spilling inserti
}
- insertb.tophash[inserti&(bucketCnt-1)] = tophash(hash) // mask inserti to avoid bounds checks
+ insertb.tophash[inserti&(abi.MapBucketCount-1)] = tophash(hash) // mask inserti to avoid bounds checks
insertk = add(unsafe.Pointer(insertb), dataOffset+inserti*8)
// store new key at insert position
@@ -262,7 +262,7 @@ bucketloop:
h.count++
done:
- elem := add(unsafe.Pointer(insertb), dataOffset+bucketCnt*8+inserti*uintptr(t.ValueSize))
+ elem := add(unsafe.Pointer(insertb), dataOffset+abi.MapBucketCount*8+inserti*uintptr(t.ValueSize))
if h.flags&hashWriting == 0 {
fatal("concurrent map writes")
}
@@ -295,7 +295,7 @@ func mapdelete_fast64(t *maptype, h *hmap, key uint64) {
bOrig := b
search:
for ; b != nil; b = b.overflow(t) {
- for i, k := uintptr(0), b.keys(); i < bucketCnt; i, k = i+1, add(k, 8) {
+ for i, k := uintptr(0), b.keys(); i < abi.MapBucketCount; i, k = i+1, add(k, 8) {
if key != *(*uint64)(k) || isEmpty(b.tophash[i]) {
continue
}
@@ -309,7 +309,7 @@ search:
memclrHasPointers(k, 8)
}
}
- e := add(unsafe.Pointer(b), dataOffset+bucketCnt*8+i*uintptr(t.ValueSize))
+ e := add(unsafe.Pointer(b), dataOffset+abi.MapBucketCount*8+i*uintptr(t.ValueSize))
if t.Elem.PtrBytes != 0 {
memclrHasPointers(e, t.Elem.Size_)
} else {
@@ -318,7 +318,7 @@ search:
b.tophash[i] = emptyOne
// If the bucket now ends in a bunch of emptyOne states,
// change those to emptyRest states.
- if i == bucketCnt-1 {
+ if i == abi.MapBucketCount-1 {
if b.overflow(t) != nil && b.overflow(t).tophash[0] != emptyRest {
goto notLast
}
@@ -337,7 +337,7 @@ search:
c := b
for b = bOrig; b.overflow(t) != c; b = b.overflow(t) {
}
- i = bucketCnt - 1
+ i = abi.MapBucketCount - 1
} else {
i--
}
@@ -385,7 +385,7 @@ func evacuate_fast64(t *maptype, h *hmap, oldbucket uintptr) {
x := &xy[0]
x.b = (*bmap)(add(h.buckets, oldbucket*uintptr(t.BucketSize)))
x.k = add(unsafe.Pointer(x.b), dataOffset)
- x.e = add(x.k, bucketCnt*8)
+ x.e = add(x.k, abi.MapBucketCount*8)
if !h.sameSizeGrow() {
// Only calculate y pointers if we're growing bigger.
@@ -393,13 +393,13 @@ func evacuate_fast64(t *maptype, h *hmap, oldbucket uintptr) {
y := &xy[1]
y.b = (*bmap)(add(h.buckets, (oldbucket+newbit)*uintptr(t.BucketSize)))
y.k = add(unsafe.Pointer(y.b), dataOffset)
- y.e = add(y.k, bucketCnt*8)
+ y.e = add(y.k, abi.MapBucketCount*8)
}
for ; b != nil; b = b.overflow(t) {
k := add(unsafe.Pointer(b), dataOffset)
- e := add(k, bucketCnt*8)
- for i := 0; i < bucketCnt; i, k, e = i+1, add(k, 8), add(e, uintptr(t.ValueSize)) {
+ e := add(k, abi.MapBucketCount*8)
+ for i := 0; i < abi.MapBucketCount; i, k, e = i+1, add(k, 8), add(e, uintptr(t.ValueSize)) {
top := b.tophash[i]
if isEmpty(top) {
b.tophash[i] = evacuatedEmpty
@@ -421,13 +421,13 @@ func evacuate_fast64(t *maptype, h *hmap, oldbucket uintptr) {
b.tophash[i] = evacuatedX + useY // evacuatedX + 1 == evacuatedY, enforced in makemap
dst := &xy[useY] // evacuation destination
- if dst.i == bucketCnt {
+ if dst.i == abi.MapBucketCount {
dst.b = h.newoverflow(t, dst.b)
dst.i = 0
dst.k = add(unsafe.Pointer(dst.b), dataOffset)
- dst.e = add(dst.k, bucketCnt*8)
+ dst.e = add(dst.k, abi.MapBucketCount*8)
}
- dst.b.tophash[dst.i&(bucketCnt-1)] = top // mask dst.i as an optimization, to avoid a bounds check
+ dst.b.tophash[dst.i&(abi.MapBucketCount-1)] = top // mask dst.i as an optimization, to avoid a bounds check
// Copy key.
if t.Key.PtrBytes != 0 && writeBarrier.enabled {