summaryrefslogtreecommitdiffstats
path: root/struct.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-09-03 20:25:47 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-09-03 20:25:47 -0700
commitc98f779588624b9f5479c9740920e7760a1f7d98 (patch)
tree9046ff13b827ae1577f1308c127f7d700c7ab7fc /struct.c
parentd6d182a4e1bbc4752a668848e19aae1ece50ba1e (diff)
downloadtxr-c98f779588624b9f5479c9740920e7760a1f7d98.tar.gz
txr-c98f779588624b9f5479c9740920e7760a1f7d98.tar.bz2
txr-c98f779588624b9f5479c9740920e7760a1f7d98.zip
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.
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c12
1 files changed, 12 insertions, 0 deletions
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;
}