Commit 822a24b6 authored by Austin Clements's avatar Austin Clements

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/8355Reviewed-by: 's avatarKeith Randall <khr@golang.org>
parent 6134caf1
...@@ -96,9 +96,6 @@ const ( ...@@ -96,9 +96,6 @@ const (
// sentinel bucket ID for iterator checks // sentinel bucket ID for iterator checks
noCheck = 1<<(8*ptrSize) - 1 noCheck = 1<<(8*ptrSize) - 1
// trigger a garbage collection at every alloc called from this code
checkgc = false
) )
// A header for a Go map. // A header for a Go map.
...@@ -246,16 +243,10 @@ func makemap(t *maptype, hint int64, h *hmap, bucket unsafe.Pointer) *hmap { ...@@ -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. // If hint is large zeroing this memory could take a while.
buckets := bucket buckets := bucket
if B != 0 { if B != 0 {
if checkgc {
memstats.next_gc = memstats.heap_alloc
}
buckets = newarray(t.bucket, uintptr(1)<<B) buckets = newarray(t.bucket, uintptr(1)<<B)
} }
// initialize Hmap // initialize Hmap
if checkgc {
memstats.next_gc = memstats.heap_alloc
}
if h == nil { if h == nil {
h = (*hmap)(newobject(t.hmap)) h = (*hmap)(newobject(t.hmap))
} }
...@@ -430,9 +421,6 @@ func mapassign1(t *maptype, h *hmap, key unsafe.Pointer, val unsafe.Pointer) { ...@@ -430,9 +421,6 @@ func mapassign1(t *maptype, h *hmap, key unsafe.Pointer, val unsafe.Pointer) {
hash := alg.hash(key, uintptr(h.hash0)) hash := alg.hash(key, uintptr(h.hash0))
if h.buckets == nil { if h.buckets == nil {
if checkgc {
memstats.next_gc = memstats.heap_alloc
}
h.buckets = newarray(t.bucket, 1) h.buckets = newarray(t.bucket, 1)
} }
...@@ -493,9 +481,6 @@ again: ...@@ -493,9 +481,6 @@ again:
if inserti == nil { if inserti == nil {
// all current buckets are full, allocate a new one. // all current buckets are full, allocate a new one.
if checkgc {
memstats.next_gc = memstats.heap_alloc
}
newb := (*bmap)(newobject(t.bucket)) newb := (*bmap)(newobject(t.bucket))
h.setoverflow(t, b, newb) h.setoverflow(t, b, newb)
inserti = &newb.tophash[0] inserti = &newb.tophash[0]
...@@ -505,17 +490,11 @@ again: ...@@ -505,17 +490,11 @@ again:
// store new key/value at insert position // store new key/value at insert position
if t.indirectkey { if t.indirectkey {
if checkgc {
memstats.next_gc = memstats.heap_alloc
}
kmem := newobject(t.key) kmem := newobject(t.key)
*(*unsafe.Pointer)(insertk) = kmem *(*unsafe.Pointer)(insertk) = kmem
insertk = kmem insertk = kmem
} }
if t.indirectvalue { if t.indirectvalue {
if checkgc {
memstats.next_gc = memstats.heap_alloc
}
vmem := newobject(t.elem) vmem := newobject(t.elem)
*(*unsafe.Pointer)(insertv) = vmem *(*unsafe.Pointer)(insertv) = vmem
insertv = vmem insertv = vmem
...@@ -776,9 +755,6 @@ func hashGrow(t *maptype, h *hmap) { ...@@ -776,9 +755,6 @@ func hashGrow(t *maptype, h *hmap) {
throw("evacuation not done in time") throw("evacuation not done in time")
} }
oldbuckets := h.buckets oldbuckets := h.buckets
if checkgc {
memstats.next_gc = memstats.heap_alloc
}
newbuckets := newarray(t.bucket, uintptr(1)<<(h.B+1)) newbuckets := newarray(t.bucket, uintptr(1)<<(h.B+1))
flags := h.flags &^ (iterator | oldIterator) flags := h.flags &^ (iterator | oldIterator)
if h.flags&iterator != 0 { if h.flags&iterator != 0 {
...@@ -879,9 +855,6 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) { ...@@ -879,9 +855,6 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) {
if (hash & newbit) == 0 { if (hash & newbit) == 0 {
b.tophash[i] = evacuatedX b.tophash[i] = evacuatedX
if xi == bucketCnt { if xi == bucketCnt {
if checkgc {
memstats.next_gc = memstats.heap_alloc
}
newx := (*bmap)(newobject(t.bucket)) newx := (*bmap)(newobject(t.bucket))
h.setoverflow(t, x, newx) h.setoverflow(t, x, newx)
x = newx x = newx
...@@ -906,9 +879,6 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) { ...@@ -906,9 +879,6 @@ func evacuate(t *maptype, h *hmap, oldbucket uintptr) {
} else { } else {
b.tophash[i] = evacuatedY b.tophash[i] = evacuatedY
if yi == bucketCnt { if yi == bucketCnt {
if checkgc {
memstats.next_gc = memstats.heap_alloc
}
newy := (*bmap)(newobject(t.bucket)) newy := (*bmap)(newobject(t.bucket))
h.setoverflow(t, y, newy) h.setoverflow(t, y, newy)
y = newy y = newy
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment