summaryrefslogtreecommitdiff
path: root/libgo/go/runtime/hashmap.go
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-23 22:36:54 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-23 22:36:54 +0000
commit88a3ea34080ad3087a8191fbf479543153175d59 (patch)
tree34eaec34d3588e09f9a77abba776266f124dc823 /libgo/go/runtime/hashmap.go
parent25e15aaed275cdfef34b3ee6eb3cb4b43a48d44f (diff)
parente65055a558093bd4fc0b1b0024b7814cc187b8e8 (diff)
downloadgccgo.tar.gz
Merge from trunk revision 257954.gccgo
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gccgo@257955 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/runtime/hashmap.go')
-rw-r--r--libgo/go/runtime/hashmap.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/libgo/go/runtime/hashmap.go b/libgo/go/runtime/hashmap.go
index a1fe49e9305..aba9abd7aab 100644
--- a/libgo/go/runtime/hashmap.go
+++ b/libgo/go/runtime/hashmap.go
@@ -356,6 +356,11 @@ func makemap(t *maptype, hint int, h *hmap) *hmap {
// NOTE: The returned pointer may keep the whole map live, so don't
// hold onto it for very long.
func mapaccess1(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer {
+ // Check preemption, since unlike gc we don't check on every call.
+ if getg().preempt {
+ checkPreempt()
+ }
+
if raceenabled && h != nil {
callerpc := getcallerpc()
pc := funcPC(mapaccess1)
@@ -409,6 +414,11 @@ func mapaccess1(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer {
}
func mapaccess2(t *maptype, h *hmap, key unsafe.Pointer) (unsafe.Pointer, bool) {
+ // Check preemption, since unlike gc we don't check on every call.
+ if getg().preempt {
+ checkPreempt()
+ }
+
if raceenabled && h != nil {
callerpc := getcallerpc()
pc := funcPC(mapaccess2)
@@ -463,6 +473,11 @@ func mapaccess2(t *maptype, h *hmap, key unsafe.Pointer) (unsafe.Pointer, bool)
// returns both key and value. Used by map iterator
func mapaccessK(t *maptype, h *hmap, key unsafe.Pointer) (unsafe.Pointer, unsafe.Pointer) {
+ // Check preemption, since unlike gc we don't check on every call.
+ if getg().preempt {
+ checkPreempt()
+ }
+
if h == nil || h.count == 0 {
return nil, nil
}
@@ -521,6 +536,11 @@ func mapaccess2_fat(t *maptype, h *hmap, key, zero unsafe.Pointer) (unsafe.Point
// Like mapaccess, but allocates a slot for the key if it is not present in the map.
func mapassign(t *maptype, h *hmap, key unsafe.Pointer) unsafe.Pointer {
+ // Check preemption, since unlike gc we don't check on every call.
+ if getg().preempt {
+ checkPreempt()
+ }
+
if h == nil {
panic(plainError("assignment to entry in nil map"))
}
@@ -772,6 +792,11 @@ func mapiterinit(t *maptype, h *hmap, it *hiter) {
}
func mapiternext(it *hiter) {
+ // Check preemption, since unlike gc we don't check on every call.
+ if getg().preempt {
+ checkPreempt()
+ }
+
h := it.h
if raceenabled {
callerpc := getcallerpc()