mirror of https://github.com/golang/go.git
runtime: remove checkgc code from hashmap
Currently hashmap is riddled with code that attempts to force a GC on the next allocation if checkgc is set. This no longer works as originally intended with the concurrent collector, and is apparently no longer used anyway. Remove checkgc. Change-Id: Ia6c17c405fa8821dc2e6af28d506c1133ab1ca0c Reviewed-on: https://go-review.googlesource.com/8355 Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
6134caf1f9
commit
822a24b602
|
|
@ -96,9 +96,6 @@ const (
|
|||
|
||||
// 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.
|
||||
|
|
@ -246,16 +243,10 @@ func makemap(t *maptype, hint int64, h *hmap, bucket unsafe.Pointer) *hmap {
|
|||
// 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))
|
||||
}
|
||||
|
|
@ -430,9 +421,6 @@ func mapassign1(t *maptype, h *hmap, key unsafe.Pointer, val unsafe.Pointer) {
|
|||
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)
|
||||
}
|
||||
|
||||
|
|
@ -493,9 +481,6 @@ again:
|
|||
|
||||
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]
|
||||
|
|
@ -505,17 +490,11 @@ again:
|
|||
|
||||
// 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
|
||||
|
|
@ -776,9 +755,6 @@ func hashGrow(t *maptype, h *hmap) {
|
|||
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 {
|
||||
|
|
@ -879,9 +855,6 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) {
|
|||
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
|
||||
|
|
@ -906,9 +879,6 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) {
|
|||
} 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue