ref: d3c2b26e200148d7e5861f80e6c66ff7e9eca2b8
parent: bd9e211f7c14b4d8c5cc527321a2645e9f4bb1ad
author: Jan-Willem Maessen <jmaessen@fb.com>
date: Wed Jan 17 16:52:38 EST 2024
Don't create indirections for unreferenced labels during deserialization This opens the door to topologically sorting the list of bindings and squashing even more indirections. Or, dare I say it, tree-shaking the bindings and avoiding all those A combinators. (There are debugging reasons why that might not be a great plan, see eg https://github.com/augustss/MicroHs/pull/23)
--- a/src/runtime/eval.c
+++ b/src/runtime/eval.c
@@ -1300,16 +1300,15 @@
l = parse_int(f); /* The label */
if (!gobble(f, ' ')) ERR("parse ' '");nodep = find_label(l);
+ x = TOP(0);
if (*nodep == NIL) {- /* not referenced yet, so create a node */
- *nodep = alloc_node(T_IND);
- INDIR(*nodep) = NIL;
+ /* not referenced yet, so add a direct reference */
+ *nodep = x;
} else {/* Sanity check */
if (INDIR(*nodep) != NIL) ERR("shared != NIL");+ INDIR(*nodep) = x;
}
- x = TOP(0);
- INDIR(*nodep) = x;
break;
case '"' :
/* Everything up to the next " is a string.
--
⑨