From c98f779588624b9f5479c9740920e7760a1f7d98 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 3 Sep 2019 20:25:47 -0700 Subject: struct: recycle conses used for slot lookups. When a slot is not found in a cache, and in other situations the object system conses up a key in order to search a the global slot_hash. We should be recycling these keys for reuse via rcyc_cons. This change makes recompilation of TXR's library (make clean-tlo; make) about 1.6% faster. * struct.c (lookup_slot, lookup_static_slot_desc, static_slot_p): Recycle the hash key cons cell via rcyc_cons, so it can be reused immediately. --- struct.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'struct.c') diff --git a/struct.c b/struct.c index 693c20dc..27853839 100644 --- a/struct.c +++ b/struct.c @@ -882,6 +882,9 @@ static loc lookup_slot(val inst, struct struct_inst *si, val sym) val key = cons(sym, num_fast(id)); val sl = gethash(slot_hash, key); cnum slnum = coerce(cnum, sl) >> TAG_SHIFT; + + rcyc_cons(key); + if (sl) { cache_set_insert(*set, id, slnum); if (slnum >= STATIC_SLOT_BASE) { @@ -904,6 +907,8 @@ static loc lookup_slot(val inst, struct struct_inst *si, val sym) sym->s.slot_cache = slot_cache; + rcyc_cons(key); + if (sl) { cache_set_insert(*set, id, slnum); if (slnum >= STATIC_SLOT_BASE) { @@ -934,6 +939,9 @@ static struct stslot *lookup_static_slot_desc(struct struct_type *st, val sym) val key = cons(sym, num_fast(id)); val sl = gethash(slot_hash, key); cnum slnum = coerce(cnum, sl) >> TAG_SHIFT; + + rcyc_cons(key); + if (sl) { cache_set_insert(*set, id, slnum); if (slnum >= STATIC_SLOT_BASE) @@ -951,6 +959,8 @@ static struct stslot *lookup_static_slot_desc(struct struct_type *st, val sym) sym->s.slot_cache = slot_cache; + rcyc_cons(key); + if (sl) { cache_set_insert(*set, id, slnum); if (slnum >= STATIC_SLOT_BASE) @@ -1318,6 +1328,8 @@ val static_slot_p(val type, val sym) val sl = gethash(slot_hash, key); cnum slnum = coerce(cnum, sl) >> TAG_SHIFT; + rcyc_cons(key); + if (sl && slnum >= STATIC_SLOT_BASE) return t; } -- cgit v1.2.3