From a81868f073c8acb8f1d2207f823db4341878d63c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 4 Jan 2016 20:47:27 -0800 Subject: 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. --- struct.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'struct.c') 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); } } -- cgit v1.2.3