// sentinel bucket ID for iterator checks
noCheck = 1<<(8*ptrSize) - 1
-
- // trigger a garbage collection at every alloc called from this code
- checkgc = false
)
// A header for a Go map.
// If hint is large zeroing this memory could take a while.
buckets := bucket
if B != 0 {
- if checkgc {
- memstats.next_gc = memstats.heap_alloc
- }
buckets = newarray(t.bucket, uintptr(1)<<B)
}
// initialize Hmap
- if checkgc {
- memstats.next_gc = memstats.heap_alloc
- }
if h == nil {
h = (*hmap)(newobject(t.hmap))
}
hash := alg.hash(key, uintptr(h.hash0))
if h.buckets == nil {
- if checkgc {
- memstats.next_gc = memstats.heap_alloc
- }
h.buckets = newarray(t.bucket, 1)
}
if inserti == nil {
// all current buckets are full, allocate a new one.
- if checkgc {
- memstats.next_gc = memstats.heap_alloc
- }
newb := (*bmap)(newobject(t.bucket))
h.setoverflow(t, b, newb)
inserti = &newb.tophash[0]
// store new key/value at insert position
if t.indirectkey {
- if checkgc {
- memstats.next_gc = memstats.heap_alloc
- }
kmem := newobject(t.key)
*(*unsafe.Pointer)(insertk) = kmem
insertk = kmem
}
if t.indirectvalue {
- if checkgc {
- memstats.next_gc = memstats.heap_alloc
- }
vmem := newobject(t.elem)
*(*unsafe.Pointer)(insertv) = vmem
insertv = vmem
throw("evacuation not done in time")
}
oldbuckets := h.buckets
- if checkgc {
- memstats.next_gc = memstats.heap_alloc
- }
newbuckets := newarray(t.bucket, uintptr(1)<<(h.B+1))
flags := h.flags &^ (iterator | oldIterator)
if h.flags&iterator != 0 {
if (hash & newbit) == 0 {
b.tophash[i] = evacuatedX
if xi == bucketCnt {
- if checkgc {
- memstats.next_gc = memstats.heap_alloc
- }
newx := (*bmap)(newobject(t.bucket))
h.setoverflow(t, x, newx)
x = newx
} else {
b.tophash[i] = evacuatedY
if yi == bucketCnt {
- if checkgc {
- memstats.next_gc = memstats.heap_alloc
- }
newy := (*bmap)(newobject(t.bucket))
h.setoverflow(t, y, newy)
y = newy