#include "malloc.h"
#include "type.h"
#include "race.h"
+#include "typekind.h"
#include "../../cmd/ld/textflag.h"
// This file contains the implementation of Go's map type.
{
if(raceenabled && h != nil) {
runtime·racereadpc(h, runtime·getcallerpc(&t), runtime·mapaccess1);
- runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapaccess1);
+ if(t->key->kind == KindArray || t->key->kind == KindStruct)
+ runtime·racereadrangepc(ak, t->key->size, runtime·getcallerpc(&t), runtime·mapaccess1);
+ else
+ runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapaccess1);
}
if(h == nil || h->count == 0) {
av = t->elem->zero;
{
if(raceenabled && h != nil) {
runtime·racereadpc(h, runtime·getcallerpc(&t), runtime·mapaccess2);
- runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapaccess2);
+ if(t->key->kind == KindArray || t->key->kind == KindStruct)
+ runtime·racereadrangepc(ak, t->key->size, runtime·getcallerpc(&t), runtime·mapaccess2);
+ else
+ runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapaccess2);
}
if(h == nil || h->count == 0) {
{
if(raceenabled && h != nil) {
runtime·racereadpc(h, runtime·getcallerpc(&t), reflect·mapaccess);
- runtime·racereadrangepc(key, t->key->size, runtime·getcallerpc(&t), reflect·mapaccess);
+ if(t->key->kind == KindArray || t->key->kind == KindStruct)
+ runtime·racereadrangepc(key, t->key->size, runtime·getcallerpc(&t), reflect·mapaccess);
+ else
+ runtime·racereadpc(key, runtime·getcallerpc(&t), reflect·mapaccess);
}
val = hash_lookup(t, h, &key);
FLUSH(&val);
if(raceenabled) {
runtime·racewritepc(h, runtime·getcallerpc(&t), runtime·mapassign1);
- runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapassign1);
- runtime·racereadpc(av, runtime·getcallerpc(&t), runtime·mapassign1);
+ if(t->key->kind == KindArray || t->key->kind == KindStruct)
+ runtime·racereadrangepc(ak, t->key->size, runtime·getcallerpc(&t), runtime·mapassign1);
+ else
+ runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapassign1);
+ if(t->elem->kind == KindArray || t->elem->kind == KindStruct)
+ runtime·racereadrangepc(av, t->elem->size, runtime·getcallerpc(&t), runtime·mapassign1);
+ else
+ runtime·racereadpc(av, runtime·getcallerpc(&t), runtime·mapassign1);
}
hash_insert(t, h, ak, av);
if(raceenabled) {
runtime·racewritepc(h, runtime·getcallerpc(&t), runtime·mapdelete);
- runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapdelete);
+ if(t->key->kind == KindArray || t->key->kind == KindStruct)
+ runtime·racereadrangepc(ak, t->key->size, runtime·getcallerpc(&t), runtime·mapdelete);
+ else
+ runtime·racereadpc(ak, runtime·getcallerpc(&t), runtime·mapdelete);
}
hash_remove(t, h, ak);
runtime·panicstring("assignment to entry in nil map");
if(raceenabled) {
runtime·racewritepc(h, runtime·getcallerpc(&t), reflect·mapassign);
- runtime·racereadrangepc(key, t->key->size, runtime·getcallerpc(&t), reflect·mapassign);
- runtime·racereadrangepc(val, t->elem->size, runtime·getcallerpc(&t), reflect·mapassign);
+ if(t->key->kind == KindArray || t->key->kind == KindStruct)
+ runtime·racereadrangepc(key, t->key->size, runtime·getcallerpc(&t), reflect·mapassign);
+ else
+ runtime·racereadpc(key, runtime·getcallerpc(&t), reflect·mapassign);
+ if(t->elem->kind == KindArray || t->elem->kind == KindStruct)
+ runtime·racereadrangepc(val, t->elem->size, runtime·getcallerpc(&t), reflect·mapassign);
+ else
+ runtime·racereadpc(val, runtime·getcallerpc(&t), reflect·mapassign);
}
hash_insert(t, h, key, val);
if(h == nil)
runtime·panicstring("delete from nil map");
if(raceenabled) {
- runtime·racewritepc(h, runtime·getcallerpc(&t), reflect·mapassign);
- runtime·racereadrangepc(key, t->key->size, runtime·getcallerpc(&t), reflect·mapassign);
+ runtime·racewritepc(h, runtime·getcallerpc(&t), reflect·mapdelete);
+ if(t->key->kind == KindArray || t->key->kind == KindStruct)
+ runtime·racereadrangepc(key, t->key->size, runtime·getcallerpc(&t), reflect·mapdelete);
+ else
+ runtime·racereadpc(key, runtime·getcallerpc(&t), reflect·mapdelete);
}
hash_remove(t, h, key);