summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-01-04 20:47:27 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-01-04 20:47:27 -0800
commita81868f073c8acb8f1d2207f823db4341878d63c (patch)
tree39cc709e266f0ad1a35b15e1a12e0dcb6bf4d5a3
parent66dae5a4d72765c80d5cd97f5f16a4d095d79f2f (diff)
downloadtxr-a81868f073c8acb8f1d2207f823db4341878d63c.tar.gz
txr-a81868f073c8acb8f1d2207f823db4341878d63c.tar.bz2
txr-a81868f073c8acb8f1d2207f823db4341878d63c.zip
Static slots mustn't trigger instantiation.
It is already documented that accessing the instance slots (not static slots) of a lazy struct forces it to instantiate, thus this is a doc conformance bug. * struct.c (lookup_slot): Only call check_init_lazy_structs in the code paths where we calculate the location of an instance slot.
-rw-r--r--struct.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/struct.c b/struct.c
index 79df2de9..ad7a6260 100644
--- a/struct.c
+++ b/struct.c
@@ -623,8 +623,6 @@ static loc lookup_slot(val inst, struct struct_inst *si, val sym)
slot_cache_t slot_cache = sym->s.slot_cache;
cnum id = si->id;
- check_init_lazy_struct(inst, si);
-
if (slot_cache != 0) {
slot_cache_set_t *set = &slot_cache[id % SLOT_CACHE_SIZE];
cnum slot = cache_set_lookup(*set, id);
@@ -633,6 +631,7 @@ static loc lookup_slot(val inst, struct struct_inst *si, val sym)
struct struct_type *st = si->type;
return mkloc(st->stslot[slot - STATIC_SLOT_BASE], st->self);
} else if (slot >= 0) {
+ check_init_lazy_struct(inst, si);
return mkloc(si->slot[slot], inst);
} else {
val key = cons(sym, num_fast(id));
@@ -644,6 +643,7 @@ static loc lookup_slot(val inst, struct struct_inst *si, val sym)
struct struct_type *st = si->type;
return mkloc(st->stslot[slnum - STATIC_SLOT_BASE], st->self);
}
+ check_init_lazy_struct(inst, si);
return mkloc(si->slot[slnum], inst);
}
}
@@ -664,6 +664,7 @@ static loc lookup_slot(val inst, struct struct_inst *si, val sym)
struct struct_type *st = si->type;
return mkloc(st->stslot[slnum - STATIC_SLOT_BASE], st->self);
}
+ check_init_lazy_struct(inst, si);
return mkloc(si->slot[slnum], inst);
}
}