ref: f9dcbeba057b482e136f0fbb27e078232410aeba
parent: 9a1bca556796f44f573e7c4b31168e6c54f0e04e
author: Jan-Willem Maessen <jmaessen@fb.com>
date: Tue Jan 30 17:15:12 EST 2024
Remove indirections Removes a bunch of unnecessary indirections, and makes indir clean them up too.
--- a/src/runtime/eval.c
+++ b/src/runtime/eval.c
@@ -1947,10 +1947,12 @@
/* Follow indirections */
static INLINE NODEPTR
-indir(NODEPTR n)
+indir(NODEPTR *np)
{+ NODEPTR n = *np;
while (GETTAG(n) == T_IND)
n = INDIR(n);
+ *np = n;
return n;
}
@@ -2017,7 +2019,7 @@
n = evali(n);
if (GETTAG(n) == T_K) /* Nil */
break;
- else if (GETTAG(n) == T_AP && GETTAG(x = indir(FUN(n))) == T_AP && GETTAG(indir(FUN(x))) == T_O) { /* Cons */+ else if (GETTAG(n) == T_AP && GETTAG(x = indir(&FUN(n))) == T_AP && GETTAG(indir(&FUN(x))) == T_O) { /* Cons */PUSH(n); /* protect from GC */
c = (uvalue_t)evalint(ARG(x));
n = POPTOP();
@@ -2337,7 +2339,8 @@
FREE(msg);
POP(1);
n = TOP(-1);
- GOIND(mkFlt(xd));
+ SETDBL(n, xd);
+ RET;
case T_FSHOW:
CHECK(1);
@@ -2348,7 +2351,7 @@
#endif /* WANT_FLOAT */
/* Retag a word sized value, keeping the value bits */
-#define CONV(t) do { CHECK(1); x = evali(ARG(TOP(0))); GCCHECK(1); y = alloc_node(t); SETVALUE(y, GETVALUE(x)); POP(1); n = TOP(-1); GOIND(y); } while(0)+#define CONV(t) do { CHECK(1); x = evali(ARG(TOP(0))); n = POPTOP(); SETTAG(n, t); SETVALUE(n, GETVALUE(x)); RET; } while(0)case T_TODBL: CONV(T_DBL);
case T_TOINT: CONV(T_INT);
case T_TOPTR: CONV(T_PTR);
@@ -2582,8 +2585,8 @@
//ppmsg("n before = ", ARG(FUN(top)));n = evali(ARG(FUN(top))); /* eval(n) */
//ppmsg("n after = ", n);- if (GETTAG(n) == T_AP && GETTAG(top1 = indir(FUN(n))) == T_AP) {- switch (GETTAG(indir(FUN(top1)))) {+ if (GETTAG(n) == T_AP && GETTAG(top1 = indir(&FUN(n))) == T_AP) {+ switch (GETTAG(indir(&FUN(top1)))) {case T_IO_BIND:
GCCHECKSAVE(n, 2);
s = ARG(n);
--
⑨