ref: 300cfb6caacb43cbe98e61d2d0e4e071fb507f75
parent: c19d6c213ddc2cffce3d5345bdf18dfb8be5bb55
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Mon Feb 17 21:15:35 EST 2025
WIP stack pointer as an actual pointer
--- a/src/builtins.c
+++ b/src/builtins.c
@@ -31,7 +31,7 @@
value_t lst, first = FL_nil;
value_t *pcdr = &first;
cons_t *c;
- uint32_t i = 0;
+ int i = 0;
while(1){
lst = args[i++];
@@ -317,15 +317,13 @@
BUILTIN("vector-alloc", vector_alloc)
{
- size_t i, k, a;
- value_t f, v;
if(nargs < 1)
argcount(nargs, 1);
- i = tosize(args[0]);
- v = alloc_vector(i, 0);
- a = 1;
- for(k = 0; k < i; k++){
- f = a < nargs ? args[a] : FL_void;
+ size_t i = tosize(args[0]);
+ value_t v = alloc_vector(i, 0);
+ int a = 1;
+ for(size_t k = 0; k < i; k++){
+ value_t f = a < nargs ? args[a] : FL_void;
vector_elt(v, k) = f;
if((a = (a + 1) % nargs) < 1)
a = 1;
--- a/src/cvalues.c
+++ b/src/cvalues.c
@@ -236,7 +236,7 @@
{ \
if(nargs == 0){ \
PUSH(fixnum(0)); \
- args = &FL(stack)[FL(sp)-1]; \
+ args = FL(sp)-1; \
} \
value_t cp = cprim(FL(typenam##type), sizeof(ctype)); \
cvalue_##ctype##_init(FL(typenam##type), args[0], cp_data(ptr(cp))); \
@@ -292,7 +292,7 @@
{
if(nargs == 0){
PUSH(fixnum(0));
- args = &FL(stack)[FL(sp)-1];
+ args = FL(sp)-1;
}
value_t cv = cvalue(FL(mpinttype), sizeof(mpint*));
cvalue_mpint_init(FL(mpinttype), args[0], cvalue_data(cv));
@@ -451,7 +451,7 @@
value_t cv = cvalue(type, sz);
char *dest = cvalue_data(cv);
- uint32_t i;
+ int i;
FOR_ARGS(i, 1, arg, args){
if(!fl_isnumber(arg))
type_error("number", arg);
@@ -1165,7 +1165,7 @@
if(nargs == 0)
return fixnum(-1);
v = args[0];
- uint32_t i;
+ int i;
FOR_ARGS(i, 1, e, args){
if(bothfixnums(v, e))
v = v & e;
@@ -1181,7 +1181,7 @@
if(nargs == 0)
return fixnum(0);
v = args[0];
- uint32_t i;
+ int i;
FOR_ARGS(i, 1, e, args){
if(bothfixnums(v, e))
v = v | e;
@@ -1197,7 +1197,7 @@
if(nargs == 0)
return fixnum(0);
v = args[0];
- uint32_t i;
+ int i;
FOR_ARGS(i, 1, e, args){
if(bothfixnums(v, e))
v = fixnum(numval(v) ^ numval(e));
--- a/src/flisp.c
+++ b/src/flisp.c
@@ -48,11 +48,11 @@
bool
isbuiltin(value_t x)
{
- uint32_t i;
+ int i;
return tag(x) == TAG_FUNCTION && (i = uintval(x)) < nelem(builtins) && builtins[i].name != nil;
}
-static value_t apply_cl(uint32_t nargs) fl_hotfn;
+static value_t apply_cl(int nargs) fl_hotfn;
// error utilities ------------------------------------------------------------
@@ -164,9 +164,9 @@
}
_Noreturn void
-arity_error(uint32_t nargs, uint32_t c)
+arity_error(int nargs, int c)
{
- lerrorf(FL_ArgError, "arity mismatch: wanted %"PRIu32", got %"PRIu32, c, nargs);
+ lerrorf(FL_ArgError, "arity mismatch: wanted %"PRId32", got %"PRId32, c, nargs);
}
// safe cast operators --------------------------------------------------------
@@ -259,7 +259,7 @@
}
char *
-uint2str(char *dest, size_t len, uint64_t num, uint32_t base)
+uint2str(char *dest, size_t len, uint64_t num, int base)
{
int i = len-1;
uint64_t b = (uint64_t)base;
@@ -307,7 +307,7 @@
}
void *
-alloc_words(uint32_t n)
+alloc_words(int n)
{
value_t *first;
@@ -352,7 +352,7 @@
}
void
-fl_free_gc_handles(uint32_t n)
+fl_free_gc_handles(int n)
{
assert(FL(ngchandles) >= n);
FL(ngchandles) -= n;
@@ -468,10 +468,6 @@
void
fl_gc(bool mustgrow)
{
- void *temp;
- uint32_t i, f, top;
- fl_readstate_t *rs;
-
FL(gccalls)++;
FL(curheap) = FL(tospace);
if(FL(grew))
@@ -479,34 +475,35 @@
else
FL(lim) = FL(curheap)+FL(heapsize)-sizeof(cons_t);
+ value_t *top, *f;
if(FL(throwing_frame) > FL(curr_frame)){
top = FL(throwing_frame) - 3;
- f = FL(stack)[FL(throwing_frame)-3];
+ f = (value_t*)*top;
}else{
top = FL(sp);
f = FL(curr_frame);
}
- while(1){
- for(i = f; i < top; i++)
- FL(stack)[i] = relocate(FL(stack)[i]);
- if(f == 0)
+ for(;;){
+ for(value_t *p = f; p < top; p++)
+ *p = relocate(*p);
+ if(f == FL(stack))
break;
top = f - 3;
- f = FL(stack)[f-3];
+ f = (value_t*)*top;
}
- for(i = 0; i < FL(ngchandles); i++)
+ for(int i = 0; i < FL(ngchandles); i++)
*FL(gchandles)[i] = relocate(*FL(gchandles)[i]);
trace_globals();
relocate_typetable();
- rs = FL(readstate);
+ fl_readstate_t *rs = FL(readstate);
while(rs){
value_t ent;
- for(i = 0; i < rs->backrefs.size; i++){
+ for(int i = 0; i < rs->backrefs.size; i++){
ent = (value_t)rs->backrefs.table[i];
if(ent != (value_t)HT_NOTFOUND)
rs->backrefs.table[i] = (void*)relocate(ent);
}
- for(i = 0; i < rs->gensyms.size; i++){
+ for(int i = 0; i < rs->gensyms.size; i++){
ent = (value_t)rs->gensyms.table[i];
if(ent != (value_t)HT_NOTFOUND)
rs->gensyms.table[i] = (void*)relocate(ent);
@@ -521,7 +518,7 @@
sweep_finalizers();
- temp = FL(tospace);
+ void *temp = FL(tospace);
FL(tospace) = FL(fromspace);
FL(fromspace) = temp;
@@ -550,29 +547,18 @@
}
}
-void
-fl_grow_stack(void)
-{
- size_t newsz = FL(nstack) * 2;
- value_t *ns = MEM_REALLOC(FL(stack), newsz*sizeof(value_t));
- if(fl_unlikely(ns == nil))
- lerrorf(FL_MemoryError, "stack overflow");
- FL(stack) = ns;
- FL(nstack) = newsz;
-}
-
// utils ----------------------------------------------------------------------
// apply function with n args on the stack
fl_hotfn
static value_t
-_applyn(uint32_t n)
+_applyn(int n)
{
- value_t f = FL(stack)[FL(sp)-n-1];
- uint32_t saveSP = FL(sp);
+ value_t f = FL(sp)[-n-1];
+ value_t *saveSP = FL(sp);
value_t v;
if(iscbuiltin(f))
- v = ((cvalue_t*)ptr(f))->cbuiltin(&FL(stack)[saveSP-n], n);
+ v = ((cvalue_t*)ptr(f))->cbuiltin(saveSP-n, n);
else if(isfunction(f))
v = apply_cl(n);
else if(fl_likely(isbuiltin(f))){
@@ -579,7 +565,7 @@
value_t tab = symbol_value(FL_builtins_table_sym);
if(fl_unlikely(ptr(tab) == nil))
unbound_error(tab);
- FL(stack)[saveSP-n-1] = vector_elt(tab, uintval(f));
+ saveSP[-n-1] = vector_elt(tab, uintval(f));
v = apply_cl(n);
}else{
type_error("function", f);
@@ -589,35 +575,31 @@
}
value_t
-fl_apply(value_t f, value_t l)
+fl_apply(value_t f, value_t v)
{
- value_t v = l;
- uint32_t n = FL(sp);
+ value_t *saveSP = FL(sp);
PUSH(f);
- while(iscons(v)){
- PUSHSAFE(car_(v));
+ int n;
+ for(n = 0; iscons(v); n++){
+ PUSH(car_(v));
v = cdr_(v);
}
if(v != FL_nil)
lerrorf(FL_ArgError, "apply: last argument: not a list");
- n = FL(sp) - n - 1;
v = _applyn(n);
- POPN(n+1);
+ FL(sp) = saveSP;
return v;
}
value_t
-fl_applyn(uint32_t n, value_t f, ...)
+fl_applyn(int n, value_t f, ...)
{
va_list ap;
va_start(ap, f);
- size_t i;
PUSH(f);
- while(FL(sp)+n >= FL(nstack))
- fl_grow_stack();
- for(i = 0; i < n; i++){
+ for(int i = 0; i < n; i++){
value_t a = va_arg(ap, value_t);
PUSH(a);
}
@@ -628,23 +610,20 @@
}
value_t
-fl_listn(size_t n, ...)
+fl_listn(int n, ...)
{
va_list ap;
va_start(ap, n);
- uint32_t si = FL(sp);
- size_t i;
+ value_t *si = FL(sp);
- while(FL(sp)+n >= FL(nstack))
- fl_grow_stack();
- for(i = 0; i < n; i++){
+ for(int i = 0; i < n; i++){
value_t a = va_arg(ap, value_t);
PUSH(a);
}
cons_t *c = alloc_words(n*2);
cons_t *l = c;
- for(i = 0; i < n; i++){
- c->car = FL(stack)[si++];
+ for(int i = 0; i < n; i++){
+ c->car = *si++;
c->cdr = tagptr(c+1, TAG_CONS);
c++;
}
@@ -697,14 +676,11 @@
fl_hotfn
static value_t
-list(value_t *args, uint32_t nargs, int star)
+list(value_t *args, int nargs, int star)
{
- cons_t *c;
- uint32_t i;
- value_t v;
- v = cons_reserve(nargs);
- c = ptr(v);
- for(i = 0; i < nargs; i++){
+ value_t v = cons_reserve(nargs);
+ cons_t *c = ptr(v);
+ for(int i = 0; i < nargs; i++){
c->car = args[i];
c->cdr = tagptr(c+1, TAG_CONS);
c++;
@@ -723,8 +699,8 @@
return FL_nil;
PUSH(FL_nil);
PUSH(L);
- value_t *plcons = &FL(stack)[FL(sp)-2];
- value_t *pL = &FL(stack)[FL(sp)-1];
+ value_t *plcons = FL(sp)-2;
+ value_t *pL = FL(sp)-1;
value_t c;
c = mk_cons(); PUSH(c); // save first cons
car_(c) = car_(*pL);
@@ -747,17 +723,17 @@
static value_t
do_trycatch(void)
{
- uint32_t saveSP = FL(sp);
+ value_t *saveSP = FL(sp);
value_t v = FL_nil;
- value_t thunk = FL(stack)[FL(sp)-2];
- FL(stack)[FL(sp)-2] = FL(stack)[FL(sp)-1];
- FL(stack)[FL(sp)-1] = thunk;
+ value_t thunk = FL(sp)[-2];
+ FL(sp)[-2] = FL(sp)[-1];
+ FL(sp)[-1] = thunk;
FL_TRY{
v = apply_cl(0);
}
FL_CATCH{
- v = FL(stack)[saveSP-2];
+ v = saveSP[-2];
PUSH(v);
PUSH(FL(lasterror));
v = apply_cl(1);
@@ -770,16 +746,16 @@
argument layout on stack is
|--required args--|--opt args--|--kw args--|--rest args...
*/
-static uint32_t
-process_keys(value_t kwtable, uint32_t nreq, uint32_t nkw, uint32_t nopt, uint32_t bp, uint32_t nargs, int va)
+static int
+process_keys(value_t kwtable, int nreq, int nkw, int nopt, value_t *bp, int nargs, int va)
{
- uint32_t extr = nopt+nkw;
- uint32_t ntot = nreq+extr;
+ int extr = nopt+nkw;
+ int ntot = nreq+extr;
value_t args[64], v = FL_nil;
- uint32_t i, a = 0, nrestargs;
- value_t s1 = FL(stack)[FL(sp)-1];
- value_t s3 = FL(stack)[FL(sp)-3];
- value_t s4 = FL(stack)[FL(sp)-4];
+ int i, a = 0, nrestargs;
+ value_t s1 = FL(sp)[-1];
+ value_t s3 = FL(sp)[-3];
+ value_t s4 = FL(sp)[-4];
if(fl_unlikely(nargs < nreq))
lerrorf(FL_ArgError, "too few arguments");
if(fl_unlikely(extr > nelem(args)))
@@ -787,7 +763,7 @@
for(i = 0; i < extr; i++)
args[i] = UNBOUND;
for(i = nreq; i < nargs; i++){
- v = FL(stack)[bp+i];
+ v = bp[i];
if(issymbol(v) && iskeyword((symbol_t*)ptr(v)))
break;
if(a >= nopt)
@@ -806,12 +782,12 @@
fixnum_t lx = numval(hv);
uintptr_t x = 2*((lx < 0 ? -lx : lx) % n);
if(fl_likely(vector_elt(kwtable, x) == v)){
- uintptr_t idx = numval(vector_elt(kwtable, x+1));
+ intptr_t idx = numval(vector_elt(kwtable, x+1));
assert(idx < nkw);
idx += nopt;
if(args[idx] == UNBOUND){
// if duplicate key, keep first value
- args[idx] = FL(stack)[bp+i];
+ args[idx] = bp[i];
}
}else{
lerrorf(FL_ArgError, "unsupported keyword %s", symbol_name(v));
@@ -819,7 +795,7 @@
i++;
if(i >= nargs)
break;
- v = FL(stack)[bp+i];
+ v = bp[i];
}while(issymbol(v) && iskeyword((symbol_t*)ptr(v)));
no_kw:
nrestargs = nargs - i;
@@ -827,10 +803,10 @@
lerrorf(FL_ArgError, "too many arguments");
nargs = ntot + nrestargs;
if(nrestargs)
- memmove(&FL(stack)[bp+ntot], &FL(stack)[bp+i], nrestargs*sizeof(value_t));
- memmove(&FL(stack)[bp+nreq], args, extr*sizeof(value_t));
+ memmove(bp+ntot, bp+i, nrestargs*sizeof(value_t));
+ memmove(bp+nreq, args, extr*sizeof(value_t));
FL(sp) = bp + nargs;
- assert(FL(sp) < FL(nstack)-4);
+ assert(FL(sp)-FL(stack) < FL(nstack)-4);
PUSH(s4);
PUSH(s3);
PUSH(nargs);
@@ -861,25 +837,22 @@
- push closed env, set up new environment
*/
static value_t
-apply_cl(uint32_t nargs)
+apply_cl(int nargs)
{
- uint32_t top_frame = FL(curr_frame);
- uint32_t n;
+ value_t *top_frame = FL(curr_frame);
bool tail;
+ int n;
apply_cl_top:;
- uint32_t bp = FL(sp)-nargs;
- function_t *fn = (function_t*)ptr(FL(stack)[bp-1]);
+ value_t *bp = FL(sp)-nargs;
+ function_t *fn = (function_t*)ptr(bp[-1]);
const uint8_t *ip = cvalue_data(fn->bcode);
assert(!ismanaged((uintptr_t)ip));
- if(FL(sp)+5+2 >= FL(nstack))
- fl_grow_stack();
-
PUSH(fn->env);
- PUSH(FL(curr_frame));
+ PUSH((value_t)FL(curr_frame));
PUSH(nargs);
- uint32_t ipd = FL(sp)++;
+ value_t *ipd = FL(sp)++;
FL(curr_frame) = FL(sp);
#if defined(COMPUTED_GOTO)
@@ -918,29 +891,30 @@
// top = top frame pointer to start at
static value_t
-_stacktrace(uint32_t top)
+_stacktrace(value_t *top)
{
value_t lst = FL_nil;
+ value_t *stack = FL(stack);
fl_gc_handle(&lst);
- while(top > 0){
- const uint8_t *ip1 = (void*)FL(stack)[top-1];
- uint32_t sz = FL(stack)[top-2]+1;
- uint32_t bp = top-4-sz;
- value_t func = FL(stack)[bp];
+ while(top > stack){
+ const uint8_t *ip1 = (void*)top[-1];
+ int sz = top[-2]+1;
+ value_t *bp = top-4-sz;
+ value_t func = bp[0];
const uint8_t *ip0 = cvalue_data(fn_bcode(func));
intptr_t ip = ip1 - ip0 - 1; /* -1: ip1 is *after* the one that was being executed */
value_t v = alloc_vector(sz+1, 0);
vector_elt(v, 0) = fixnum(ip);
vector_elt(v, 1) = func;
- for(uint32_t i = 1; i < sz; i++){
- value_t si = FL(stack)[bp+i];
+ for(int i = 1; i < sz; i++){
+ value_t si = bp[i];
// if there's an error evaluating argument defaults some slots
// might be left set to UNBOUND
vector_elt(v, i+1) = si == UNBOUND ? FL_void : si;
}
lst = fl_cons(v, lst);
- top = FL(stack)[top-3];
+ top = (value_t*)top[-3];
}
fl_free_gc_handles(1);
return lst;
@@ -1056,7 +1030,7 @@
BUILTIN("append", append)
{
value_t first = FL_nil, lst, lastcons = FL_nil;
- uint32_t i;
+ int i;
if(nargs == 0)
return FL_nil;
fl_gc_handle(&first);
@@ -1098,22 +1072,18 @@
{
if(fl_unlikely(nargs < 2))
lerrorf(FL_ArgError, "too few arguments");
- intptr_t argSP = args-FL(stack);
- assert(argSP >= 0 && argSP < (intptr_t)FL(nstack));
- while(FL(sp)+2+1+nargs >= FL(nstack))
- fl_grow_stack();
- uint32_t k = FL(sp);
+ value_t *k = FL(sp);
PUSH(FL_nil);
PUSH(FL_nil);
for(bool first = true;;){
- PUSH(FL(stack)[argSP]);
- for(uint32_t i = 1; i < nargs; i++){
- if(!iscons(FL(stack)[argSP+i])){
+ PUSH(args[0]);
+ for(int i = 1; i < nargs; i++){
+ if(!iscons(args[i])){
POPN(2+i);
- return FL(stack)[k+1];
+ return k[1];
}
- PUSH(car(FL(stack)[argSP+i]));
- FL(stack)[argSP+i] = cdr_(FL(stack)[argSP+i]);
+ PUSH(car(args[i]));
+ args[i] = cdr_(args[i]);
}
value_t v = _applyn(nargs-1);
POPN(nargs);
@@ -1121,10 +1091,10 @@
value_t c = mk_cons();
car_(c) = POP(); cdr_(c) = FL_nil;
if(first)
- FL(stack)[k+1] = c;
+ k[1] = c;
else
- cdr_(FL(stack)[k]) = c;
- FL(stack)[k] = c;
+ cdr_(k[0]) = c;
+ k[0] = c;
first = false;
}
}
@@ -1133,18 +1103,14 @@
{
if(fl_unlikely(nargs < 2))
lerrorf(FL_ArgError, "too few arguments");
- intptr_t argSP = args-FL(stack);
- assert(argSP >= 0 && argSP < (intptr_t)FL(nstack));
- if(FL(sp)+1+2*nargs >= FL(nstack))
- fl_grow_stack();
for(size_t n = 0;; n++){
- PUSH(FL(stack)[argSP]);
- uint32_t pargs = 0;
- for(uint32_t i = 1; i < nargs; i++, pargs++){
- value_t v = FL(stack)[argSP+i];
+ PUSH(args[0]);
+ int pargs = 0;
+ for(int i = 1; i < nargs; i++, pargs++){
+ value_t v = args[i];
if(iscons(v)){
PUSH(car_(v));
- FL(stack)[argSP+i] = cdr_(v);
+ args[i] = cdr_(v);
continue;
}
if(isvector(v)){
@@ -1252,9 +1218,10 @@
goto failed;
FL(curheap) = FL(fromspace);
FL(lim) = FL(curheap)+FL(heapsize)-sizeof(cons_t);
- FL(nstack) = 4096;
- if((FL(stack) = MEM_ALLOC(FL(nstack)*sizeof(value_t))) == nil)
+ FL(nstack) = 64*1024*1024/sizeof(value_t);
+ if((FL(stack) = FL(sp) = MEM_ALLOC(FL(nstack)*sizeof(value_t))) == nil)
goto failed;
+ FL(curr_frame) = FL(sp);
FL(maxfinalizers) = 512;
if((FL(finalizers) = MEM_ALLOC(FL(maxfinalizers) * sizeof(*FL(finalizers)))) == nil)
goto failed;
@@ -1353,12 +1320,12 @@
{
FL(loading) = true;
PUSH(sys_image_iostream);
- uint32_t saveSP = FL(sp);
+ value_t *saveSP = FL(sp);
FL_TRY{
while(1){
FL(sp) = saveSP;
- value_t e = fl_read_sexpr(FL(stack)[FL(sp)-1]);
- if(ios_eof(value2c(ios_t*, FL(stack)[FL(sp)-1])))
+ value_t e = fl_read_sexpr(FL(sp)[-1]);
+ if(ios_eof(value2c(ios_t*, FL(sp)[-1])))
break;
if(isfunction(e)){
// stage 0 format: series of thunks
@@ -1384,7 +1351,7 @@
ios_putc(ios_stderr, '\n');
return 1;
}
- ios_close(value2c(ios_t*, FL(stack)[FL(sp)-1]));
+ ios_close(value2c(ios_t*, FL(sp)[-1]));
FL(sp) = saveSP-1;
FL(loading) = false;
return 0;
--- a/src/flisp.h
+++ b/src/flisp.h
@@ -90,7 +90,7 @@
int nargs;
};
-typedef value_t (*builtin_t)(value_t*, uint32_t);
+typedef value_t (*builtin_t)(value_t*, int);
#define fits_bits(x, b) (((x)>>(b-1)) == 0 || (~((x)>>(b-1))) == 0)
#define fits_fixnum(x) fits_bits(x, FIXNUM_BITS)
@@ -166,19 +166,13 @@
#define PUSH(v) \
do{ \
- FL(stack)[FL(sp)++] = (v); \
+ *FL(sp)++ = (v); \
}while(0)
-#define PUSHSAFE(v) \
- do{ \
- if(FL(sp) >= FL(nstack)) \
- fl_grow_stack(); \
- PUSH(v); \
- }while(0)
#define POPN(n) \
do{ \
FL(sp) -= (n); \
}while(0)
-#define POP() (FL(stack)[--FL(sp)])
+#define POP() *(--FL(sp))
bool isbuiltin(value_t x) fl_constfn fl_hotfn;
int fl_init(size_t initial_heapsize);
@@ -189,9 +183,8 @@
/* collector */
value_t relocate(value_t v) fl_hotfn;
void fl_gc(bool mustgrow);
-void fl_grow_stack(void);
void fl_gc_handle(value_t *pv);
-void fl_free_gc_handles(uint32_t n);
+void fl_free_gc_handles(int n);
/* symbol table */
value_t gensym(void);
@@ -203,12 +196,12 @@
/* read, eval, print main entry points */
value_t fl_toplevel_eval(value_t expr);
value_t fl_apply(value_t f, value_t l);
-value_t fl_applyn(uint32_t n, value_t f, ...);
+value_t fl_applyn(int n, value_t f, ...);
/* object model manipulation */
value_t fl_cons(value_t a, value_t b);
value_t fl_list2(value_t a, value_t b);
-value_t fl_listn(size_t n, ...);
+value_t fl_listn(int n, ...);
bool fl_isnumber(value_t v) fl_purefn;
value_t alloc_vector(size_t n, bool init);
@@ -225,9 +218,9 @@
/* conses */
value_t mk_cons(void) fl_hotfn;
-void *alloc_words(uint32_t n) fl_hotfn;
+void *alloc_words(int n) fl_hotfn;
-char *uint2str(char *dest, size_t len, uint64_t num, uint32_t base);
+char *uint2str(char *dest, size_t len, uint64_t num, int base);
/* error handling */
typedef struct _fl_readstate_t {
@@ -241,9 +234,9 @@
fl_readstate_t *rdst;
struct _ectx_t *prev;
jmp_buf buf;
- uint32_t sp;
- uint32_t frame;
- uint32_t ngchnd;
+ value_t *sp;
+ value_t *frame;
+ int ngchnd;
}fl_exception_context_t;
void free_readstate(fl_readstate_t *rs);
@@ -269,7 +262,7 @@
_Noreturn void type_error(const char *expected, value_t got);
_Noreturn void bounds_error(value_t arr, value_t ind);
_Noreturn void unbound_error(value_t sym);
-_Noreturn void arity_error(uint32_t nargs, uint32_t c);
+_Noreturn void arity_error(int nargs, int c);
#define argcount(nargs, c) \
do{ \
@@ -340,7 +333,7 @@
#define tompint(v) (*(mpint**)cv_data(ptr(v)))
#define BUILTIN(lname, cname) \
- value_t fn_builtin_##cname(value_t *args, uint32_t nargs)
+ value_t fn_builtin_##cname(value_t *args, int nargs)
#define BUILTIN_FN(l, c, attr) attr BUILTIN(l, c);
#include "builtin_fns.h"
@@ -360,18 +353,19 @@
typedef struct Fl Fl;
struct Fl {
- value_t *stack;
- uint32_t sp;
- uint32_t nstack;
- uintptr_t heapsize;//bytes
- uint8_t *fromspace;
- uint32_t curr_frame;
+ value_t *sp;
+ uint8_t *curheap;
+ value_t *curr_frame;
+ uint8_t *fromspace;
uint8_t *tospace;
- uint8_t *curheap;
uint8_t *lim;
+ value_t *stack;
+
+ uintptr_t heapsize;//bytes
size_t malloc_pressure;
+ uint32_t nstack;
cvalue_t **finalizers;
size_t nfinalizers;
@@ -382,7 +376,7 @@
// saved execution state for an unwind target
fl_exception_context_t *exctx;
- uint32_t throwing_frame; // active frame when exception was thrown
+ value_t *throwing_frame; // active frame when exception was thrown
value_t lasterror;
fltype_t *tabletype;
@@ -428,7 +422,7 @@
htable_t reverse_dlsym_lookup_table;
htable_t TypeTable;
- uint32_t ngchandles;
+ int ngchandles;
value_t *gchandles[N_GC_HANDLES];
};
--- a/src/htable.c
+++ b/src/htable.c
@@ -24,7 +24,7 @@
}
htable_t *
-htable_new(htable_t *h, size_t size)
+htable_new(htable_t *h, int size)
{
if(size <= HT_N_INLINE/2){
size = HT_N_INLINE;
@@ -38,7 +38,7 @@
}
h->size = size;
h->i = 0;
- for(size_t i = 0; i < size; i++)
+ for(int i = 0; i < size; i++)
h->table[i] = HT_NOTFOUND;
return h;
}
@@ -52,7 +52,7 @@
// empty and reduce size
void
-htable_reset(htable_t *h, size_t sz)
+htable_reset(htable_t *h, int sz)
{
sz = nextipow2(sz);
if(h->size > sz*4 && h->table != &h->_space[0]){
--- a/src/htable.h
+++ b/src/htable.h
@@ -4,10 +4,10 @@
typedef struct {
void **table;
- uint32_t size;
+ int size;
// this is to skip over non-items in for-each
// FIXME(sigrid): in a multithreaded environment this isn't enough
- uint32_t i;
+ int i;
void *_space[HT_N_INLINE];
}fl_aligned(8) htable_t;
@@ -15,8 +15,8 @@
#define HT_NOTFOUND ((void*)1)
// initialize and free
-htable_t *htable_new(htable_t *h, size_t size);
+htable_t *htable_new(htable_t *h, int size);
void htable_free(htable_t *h);
// clear and (possibly) change size
-void htable_reset(htable_t *h, size_t sz);
+void htable_reset(htable_t *h, int sz);
--- a/src/iostream.c
+++ b/src/iostream.c
@@ -74,9 +74,8 @@
{
if(nargs < 1)
argcount(nargs, 1);
- size_t i;
bool r = false, w = false, c = false, t = false, a = false;
- for(i = 1; i < nargs; i++){
+ for(int i = 1; i < nargs; i++){
if(args[i] == FL_rdsym)
r = 1;
else if(args[i] == FL_wrsym)
--- a/src/read.c
+++ b/src/read.c
@@ -394,14 +394,14 @@
{
size_t i, s = vector_size(v);
size_t d = vector_grow_amt(s);
- PUSHSAFE(v);
+ PUSH(v);
assert(s+d > s);
value_t newv = alloc_vector(s+d, 1);
- v = FL(stack)[FL(sp)-1];
+ v = FL(sp)[-1];
for(i = 0; i < s; i++)
vector_elt(newv, i) = vector_elt(v, i);
// use gc to rewrite references from the old vector to the new
- FL(stack)[FL(sp)-1] = newv;
+ FL(sp)[-1] = newv;
if(s > 0 && rewrite_refs){
((size_t*)ptr(v))[0] |= 0x1;
vector_elt(v, 0) = newv;
@@ -415,20 +415,20 @@
{
value_t v = FL(the_empty_vector), elt;
uint32_t i = 0;
- PUSHSAFE(v);
+ PUSH(v);
if(label != UNBOUND)
ptrhash_put(&FL(readstate)->backrefs, (void*)label, (void*)v);
while(peek(ctx) != closer){
if(ios_eof(RS))
parse_error(&ctx->loc, "unexpected end of input");
- v = FL(stack)[FL(sp)-1]; // reload after possible alloc in peek()
+ v = FL(sp)[-1]; // reload after possible alloc in peek()
if(i >= vector_size(v)){
- v = FL(stack)[FL(sp)-1] = vector_grow(v, label != UNBOUND);
+ v = FL(sp)[-1] = vector_grow(v, label != UNBOUND);
if(label != UNBOUND)
ptrhash_put(&FL(readstate)->backrefs, (void*)label, (void*)v);
}
elt = do_read_sexpr(ctx, UNBOUND);
- v = FL(stack)[FL(sp)-1];
+ v = FL(sp)[-1];
assert(i < vector_size(v));
vector_elt(v, i) = elt;
i++;
@@ -549,14 +549,14 @@
static void
read_list(Rctx *ctx, value_t label, uint32_t closer)
{
- value_t c, *pc, *pval;
- uint32_t t, ipval, ipc;
+ value_t c, *pc, *pval, *ipval, *ipc;
+ uint32_t t;
ios_loc_t loc0;
loc0 = RS->loc;
loc0.colno--;
ipval = FL(sp)-1;
- PUSHSAFE(FL_nil);
+ PUSH(FL_nil);
ipc = FL(sp)-1; // to keep track of current cons cell
t = peek(ctx);
while(t != closer){
@@ -563,11 +563,11 @@
if(ios_eof(RS))
parse_error(&loc0, "not closed: unexpected EOI "PAtLoc, ctx->loc.lineno, ctx->loc.colno);
c = mk_cons(); car_(c) = cdr_(c) = FL_nil;
- pc = &FL(stack)[ipc];
+ pc = ipc;
if(iscons(*pc))
cdr_(*pc) = c;
else{
- pval = &FL(stack)[ipval];
+ pval = ipval;
*pval = c;
if(label != UNBOUND)
ptrhash_put(&FL(readstate)->backrefs, (void*)label, (void*)c);
@@ -574,7 +574,7 @@
}
*pc = c;
c = do_read_sexpr(ctx, UNBOUND);
- pc = &FL(stack)[ipc];
+ pc = ipc;
car_(*pc) = c;
t = peek(ctx);
@@ -581,7 +581,7 @@
if(t == TOK_DOT){
take(ctx);
c = do_read_sexpr(ctx, UNBOUND);
- pc = &FL(stack)[ipc];
+ pc = ipc;
cdr_(*pc) = c;
t = peek(ctx);
if(ios_eof(RS))
@@ -614,7 +614,7 @@
take(ctx);
switch(t){
case TOK_OPEN:
- PUSHSAFE(FL_nil);
+ PUSH(FL_nil);
read_list(ctx, label, TOK_CLOSE);
return POP();
case TOK_SYM:
@@ -621,11 +621,11 @@
case TOK_NUM:
return ctx->tokval;
case TOK_OPENB:
- PUSHSAFE(FL_nil);
+ PUSH(FL_nil);
read_list(ctx, label, TOK_CLOSEB);
return POP();
case TOK_OPENC:
- PUSHSAFE(FL_nil);
+ PUSH(FL_nil);
read_list(ctx, label, TOK_CLOSEC);
return POP();
case TOK_COMMA:
@@ -643,11 +643,11 @@
car_(v) = *head;
cdr_(v) = tagptr((cons_t*)ptr(v)+1, TAG_CONS);
car_(cdr_(v)) = cdr_(cdr_(v)) = FL_nil;
- PUSHSAFE(v);
+ PUSH(v);
if(label != UNBOUND)
ptrhash_put(&FL(readstate)->backrefs, (void*)label, (void*)v);
v = do_read_sexpr(ctx, UNBOUND);
- car_(cdr_(FL(stack)[FL(sp)-1])) = v;
+ car_(cdr_(FL(sp)[-1])) = v;
return POP();
case TOK_SHARPQUOTE:
// femtoLisp doesn't need symbol-function, so #' does nothing
@@ -661,11 +661,11 @@
take(ctx);
parse_error(&ctx->loc, "expected argument list for %s", symbol_name(ctx->tokval));
}
- PUSHSAFE(FL_nil);
+ PUSH(FL_nil);
read_list(ctx, UNBOUND, TOK_CLOSE);
if(sym == FL_vu8sym){
sym = FL_arraysym;
- FL(stack)[FL(sp)-1] = fl_cons(FL_uint8sym, FL(stack)[FL(sp)-1]);
+ FL(sp)[-1] = fl_cons(FL_uint8sym, FL(sp)[-1]);
}else if(sym == FL_fnsym){
sym = FL_function;
}
--- a/src/string.c
+++ b/src/string.c
@@ -127,7 +127,7 @@
value_t oldpp = symbol_value(FL_printprettysym);
set(FL_printreadablysym, FL_nil);
set(FL_printprettysym, FL_nil);
- uint32_t i;
+ int i;
FOR_ARGS(i, 0, arg, args){
USED(arg);
fl_print(s, args[i]);
--- a/src/table.c
+++ b/src/table.c
@@ -11,10 +11,9 @@
print_htable(value_t v, ios_t *f)
{
htable_t *h = cvalue_data(v);
- size_t i;
int first = 1;
fl_print_str(f, "#table(");
- for(i = 0; i < h->size; i += 2){
+ for(int i = 0; i < h->size; i += 2){
if(h->table[i+1] != HT_NOTFOUND){
if(!first)
fl_print_str(f, " ");
@@ -31,8 +30,7 @@
print_traverse_htable(value_t self)
{
htable_t *h = cvalue_data(self);
- size_t i;
- for(i = 0; i < h->size; i += 2){
+ for(int i = 0; i < h->size; i += 2){
if(h->table[i+1] != HT_NOTFOUND){
print_traverse((value_t)h->table[i]);
print_traverse((value_t)h->table[i+1]);
@@ -55,7 +53,7 @@
if(oldh->table == &oldh->_space[0])
h->table = &h->_space[0];
h->i = oldh->i;
- for(size_t i = 0; i < h->size; i++){
+ for(int i = 0; i < h->size; i++){
if(h->table[i] != HT_NOTFOUND)
h->table[i] = (void*)relocate((value_t)h->table[i]);
}
@@ -91,7 +89,7 @@
BUILTIN("table", table)
{
- size_t cnt = (size_t)nargs;
+ int cnt = nargs;
if(cnt & 1)
lerrorf(FL_ArgError, "arguments must come in pairs");
value_t nt;
@@ -102,8 +100,8 @@
nt = cvalue(FL(tabletype), sizeof(htable_t)-inline_space);
htable_t *h = cvalue_data(nt);
htable_new(h, cnt/2);
- size_t i;
value_t k = FL_nil, arg;
+ int i;
FOR_ARGS(i, 0, arg, args){
if(i & 1)
equalhash_put(h, (void*)k, (void*)arg);
@@ -177,12 +175,12 @@
argcount(nargs, 3);
value_t f = args[0], zero = args[1], t = args[2];
htable_t *h = totable(t);
- size_t n = h->size;
+ int n = h->size;
void **table = h->table;
fl_gc_handle(&f);
fl_gc_handle(&zero);
fl_gc_handle(&t);
- for(size_t i = 0; i < n; i += 2){
+ for(int i = 0; i < n; i += 2){
if(table[i+1] == HT_NOTFOUND)
continue;
zero = fl_applyn(3, f, (value_t)table[i], (value_t)table[i+1], zero);
--- a/src/types.c
+++ b/src/types.c
@@ -75,7 +75,7 @@
relocate_typetable(void)
{
htable_t *h = &FL(TypeTable);
- for(size_t i = 0; i < h->size; i += 2){
+ for(int i = 0; i < h->size; i += 2){
if(h->table[i] != HT_NOTFOUND){
void *nv = (void*)relocate((value_t)h->table[i]);
h->table[i] = nv;
--- a/src/vm.inc
+++ b/src/vm.inc
@@ -7,7 +7,7 @@
)
OP(OP_LOADA0)
- PUSH(FL(stack)[bp]);
+ PUSH(*bp);
NEXT_OP;
OP(OP_CALL) {
@@ -28,29 +28,29 @@
ip += 4;
}
LABEL(do_call):
- FL(stack)[ipd] = (uintptr_t)ip;
- value_t v = FL(stack)[FL(sp)-n-1];
+ *ipd = (uintptr_t)ip;
+ value_t v = FL(sp)[-n-1];
if(tag(v) == TAG_FUNCTION){
if(v > (N_BUILTINS<<3)){
if(tail){
- FL(curr_frame) = FL(stack)[FL(curr_frame)-3];
+ FL(curr_frame) = (value_t*)FL(curr_frame)[-3];
for(fixnum_t s = -1; s < (fixnum_t)n; s++)
- FL(stack)[bp+s] = FL(stack)[FL(sp)+s-n];
+ bp[s] = FL(sp)[s-n];
FL(sp) = bp+n;
}
nargs = n;
goto apply_cl_top;
}
- uint32_t i = uintval(v);
+ int i = uintval(v);
assert(isbuiltin(v));
fixnum_t s = builtins[i].nargs;
if(s >= 0)
- argcount(n, (unsigned)s);
- else if(s != ANYARGS && (signed)n < -s)
- argcount(n, (unsigned)-s);
+ argcount(n, s);
+ else if(s != ANYARGS && n < -s)
+ argcount(n, -s);
// remove function arg
- for(s = FL(sp)-n-1; s < (int)FL(sp)-1; s++)
- FL(stack)[s] = FL(stack)[s+1];
+ for(value_t *p = FL(sp)-n-1; p < FL(sp)-1; p++)
+ p[0] = p[1];
FL(sp)--;
switch(i){
case OP_VECTOR: goto LABEL(apply_vector);
@@ -73,10 +73,10 @@
#endif
}
}else if(fl_likely(iscbuiltin(v))){
- fixnum_t s = FL(sp) - n;
- v = ((cvalue_t*)ptr(v))->cbuiltin(&FL(stack)[s], n);
- FL(sp) = s;
- FL(stack)[s-1] = v;
+ value_t *p = FL(sp) - n;
+ v = ((cvalue_t*)ptr(v))->cbuiltin(p, n);
+ FL(sp) = p;
+ p[-1] = v;
NEXT_OP;
}
type_error("function", v);
@@ -83,7 +83,7 @@
}
OP(OP_ARGC) {
- uint32_t na = *ip++;
+ int na = *ip++;
if(0){
OP(OP_ARGCL)
na = GET_INT32(ip);
@@ -90,7 +90,7 @@
ip += 4;
}
if(fl_unlikely(nargs != na)){
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
arity_error(nargs, na);
}
NEXT_OP;
@@ -97,21 +97,21 @@
}
OP(OP_LOADA1)
- PUSH(FL(stack)[bp+1]);
+ PUSH(bp[1]);
NEXT_OP;
OP(OP_RET) {
value_t v = POP();
FL(sp) = FL(curr_frame);
- FL(curr_frame) = FL(stack)[FL(sp)-3];
+ FL(curr_frame) = (value_t*)FL(sp)[-3];
if(FL(curr_frame) == top_frame)
return v;
FL(sp) -= 4+nargs;
ipd = FL(curr_frame)-1;
- ip = (uint8_t*)FL(stack)[ipd];
- nargs = FL(stack)[FL(curr_frame)-2];
+ ip = (uint8_t*)*ipd;
+ nargs = FL(curr_frame)[-2];
bp = FL(curr_frame) - 4 - nargs;
- FL(stack)[FL(sp)-1] = v;
+ FL(sp)[-1] = v;
NEXT_OP;
}
@@ -120,7 +120,7 @@
NEXT_OP;
OP(OP_LOADA)
- PUSH(FL(stack)[bp + *ip++]);
+ PUSH(bp[*ip++]);
NEXT_OP;
OP(OP_BRN)
@@ -128,13 +128,13 @@
NEXT_OP;
OP(OP_LOADG) {
- value_t v = fn_vals(FL(stack)[bp-1]);
+ value_t v = fn_vals(bp[-1]);
assert(*ip < vector_size(v));
v = vector_elt(v, *ip);
ip++;
if(0){
OP(OP_LOADGL)
- v = fn_vals(FL(stack)[bp-1]);
+ v = fn_vals(bp[-1]);
v = vector_elt(v, GET_INT32(ip));
ip += 4;
}
@@ -141,7 +141,7 @@
assert(issymbol(v));
symbol_t *sym = ptr(v);
if(fl_unlikely(sym->binding == UNBOUND)){
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
unbound_error(v);
}
PUSH(sym->binding);
@@ -152,11 +152,11 @@
n = *ip++;
LABEL(apply_lt):
{
- uint32_t i = n;
- value_t a = FL(stack)[FL(sp)-i], b, v;
+ int i = n;
+ value_t a = FL(sp)[-i], b, v;
for(v = FL_t; i > 1; a = b){
i--;
- b = FL(stack)[FL(sp)-i];
+ b = FL(sp)[-i];
if(bothfixnums(a, b)){
if((fixnum_t)a >= (fixnum_t)b){
v = FL_nil;
@@ -178,7 +178,7 @@
NEXT_OP;
OP(OP_LOADV) {
- value_t v = fn_vals(FL(stack)[bp-1]);
+ value_t v = fn_vals(bp[-1]);
assert(*ip < vector_size(v));
PUSH(vector_elt(v, *ip++));
NEXT_OP;
@@ -187,24 +187,24 @@
OP(OP_ADD2) {
value_t v;
LABEL(do_add2):
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
if(0){
OP(OP_SUB2)
LABEL(do_sub2):
- FL(stack)[ipd] = (uintptr_t)ip;
- v = FL(stack)[FL(sp)-1];
+ *ipd = (uintptr_t)ip;
+ v = FL(sp)[-1];
int64_t i64;
- FL(stack)[FL(sp)-1] = isfixnum(v) ? fixnum_neg(v) : fl_neg(v);
+ FL(sp)[-1] = isfixnum(v) ? fixnum_neg(v) : fl_neg(v);
}
value_t a, b, q;
- a = FL(stack)[FL(sp)-2];
- b = FL(stack)[FL(sp)-1];
+ a = FL(sp)[-2];
+ b = FL(sp)[-1];
if(bothfixnums(a, b) && !sadd_overflow(numval(a), numval(b), &q) && fits_fixnum(q))
v = fixnum(q);
else
- v = fl_add_any(&FL(stack)[FL(sp)-2], 2);
+ v = fl_add_any(FL(sp)-2, 2);
POPN(1);
- FL(stack)[FL(sp)-1] = v;
+ FL(sp)[-1] = v;
NEXT_OP;
}
@@ -221,28 +221,28 @@
NEXT_OP;
OP(OP_DUP)
- FL(stack)[FL(sp)] = FL(stack)[FL(sp)-1];
+ FL(sp)[0] = FL(sp)[-1];
FL(sp)++;
NEXT_OP;
OP(OP_LOADC0)
- PUSH(vector_elt(FL(stack)[bp+nargs], 0));
+ PUSH(vector_elt(bp[nargs], 0));
NEXT_OP;
OP(OP_CAR) {
- value_t v = FL(stack)[FL(sp)-1];
+ value_t v = FL(sp)[-1];
if(fl_likely(iscons(v)))
v = car_(v);
else if(fl_unlikely(v != FL_nil)){
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
type_error("cons", v);
}
- FL(stack)[FL(sp)-1] = v;
+ FL(sp)[-1] = v;
NEXT_OP;
}
OP(OP_CLOSURE) {
- uint32_t x = *ip++;
+ int x = *ip++;
assert(x > 0);
value_t *pv = alloc_words(
1+x+
@@ -252,8 +252,8 @@
sizeof(function_t)/sizeof(value_t));
value_t v = tagptr(pv, TAG_VECTOR);
*pv++ = fixnum(x);
- for(uint32_t i = 0; i < x; i++)
- *pv++ = FL(stack)[FL(sp)-x+i];
+ for(int i = 0; i < x; i++)
+ *pv++ = FL(sp)[-x+i];
POPN(x);
PUSH(v);
#if !defined(BITS64)
@@ -261,14 +261,14 @@
pv++;
#endif
function_t *f = (function_t*)pv;
- value_t e = FL(stack)[FL(sp)-2]; // closure to copy
+ value_t e = FL(sp)[-2]; // closure to copy
assert(isfunction(e));
f->bcode = fn_bcode(e);
f->vals = fn_vals(e);
- f->env = FL(stack)[FL(sp)-1];
+ f->env = FL(sp)[-1];
f->name = fn_name(e);
POPN(1);
- FL(stack)[FL(sp)-1] = tagptr(f, TAG_FUNCTION);
+ FL(sp)[-1] = tagptr(f, TAG_FUNCTION);
NEXT_OP;
}
@@ -277,27 +277,27 @@
fl_gc(0);
cons_t *c = (cons_t*)FL(curheap);
FL(curheap) += sizeof(cons_t);
- c->car = FL(stack)[FL(sp)-2];
- c->cdr = FL(stack)[FL(sp)-1];
- FL(stack)[FL(sp)-2] = tagptr(c, TAG_CONS);
+ c->car = FL(sp)[-2];
+ c->cdr = FL(sp)[-1];
+ FL(sp)[-2] = tagptr(c, TAG_CONS);
POPN(1);
NEXT_OP;
}
OP(OP_BRNE)
- ip += FL(stack)[FL(sp)-2] != FL(stack)[FL(sp)-1] ? GET_INT16(ip) : 2;
+ ip += FL(sp)[-2] != FL(sp)[-1] ? GET_INT16(ip) : 2;
POPN(2);
NEXT_OP;
OP(OP_CDR) {
- value_t v = FL(stack)[FL(sp)-1];
+ value_t v = FL(sp)[-1];
if(fl_likely(iscons(v)))
v = cdr_(v);
else if(fl_unlikely(v != FL_nil)){
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
type_error("cons", v);
}
- FL(stack)[FL(sp)-1] = v;
+ FL(sp)[-1] = v;
NEXT_OP;
}
@@ -306,15 +306,15 @@
NEXT_OP;
OP(OP_NOT)
- FL(stack)[FL(sp)-1] = FL(stack)[FL(sp)-1] == FL_nil ? FL_t : FL_nil;
+ FL(sp)[-1] = FL(sp)[-1] == FL_nil ? FL_t : FL_nil;
NEXT_OP;
OP(OP_SETA)
- FL(stack)[bp + *ip++] = FL(stack)[FL(sp)-1];
+ bp[*ip++] = FL(sp)[-1];
NEXT_OP;
OP(OP_VARGC) {
- uint32_t i = *ip++;
+ int i = *ip++;
if(0){
OP(OP_VARGCL)
i = GET_INT32(ip);
@@ -322,25 +322,25 @@
}
fixnum_t s = (fixnum_t)nargs - (fixnum_t)i;
if(s > 0){
- value_t v = list(&FL(stack)[bp+i], s, 0);
- FL(stack)[bp+i] = v;
+ value_t v = list(bp+i, s, 0);
+ bp[i] = v;
if(s > 1){
- FL(stack)[bp+i+1] = FL(stack)[bp+nargs+0];
- FL(stack)[bp+i+2] = FL(stack)[bp+nargs+1];
- FL(stack)[bp+i+3] = i+1;
- FL(stack)[bp+i+4] = 0;
- FL(sp) = bp+i+5;
+ bp[i+1] = bp[nargs+0];
+ bp[i+2] = bp[nargs+1];
+ bp[i+3] = i+1;
+ bp[i+4] = 0;
+ FL(sp) = bp+i+5;
FL(curr_frame) = FL(sp);
}
}else if(fl_unlikely(s < 0)){
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
lerrorf(FL_ArgError, "too few arguments");
}else{
FL(sp)++;
- FL(stack)[FL(sp)-2] = i+1;
- FL(stack)[FL(sp)-3] = FL(stack)[FL(sp)-4];
- FL(stack)[FL(sp)-4] = FL(stack)[FL(sp)-5];
- FL(stack)[FL(sp)-5] = FL_nil;
+ FL(sp)[-2] = i+1;
+ FL(sp)[-3] = FL(sp)[-4];
+ FL(sp)[-4] = FL(sp)[-5];
+ FL(sp)[-5] = FL_nil;
FL(curr_frame) = FL(sp);
}
ipd = FL(sp)-1;
@@ -349,19 +349,19 @@
}
OP(OP_SHIFT) {
- uint32_t i = *ip++;
- FL(stack)[FL(sp)-1-i] = FL(stack)[FL(sp)-1];
+ int i = *ip++;
+ FL(sp)[-1-i] = FL(sp)[-1];
FL(sp) -= i;
NEXT_OP;
}
OP(OP_SETCAR) {
- value_t v = FL(stack)[FL(sp)-2];
+ value_t v = FL(sp)[-2];
if(fl_unlikely(!iscons(v))){
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
type_error("cons", v);
}
- car_(v) = FL(stack)[FL(sp)-1];
+ car_(v) = FL(sp)[-1];
POPN(1);
NEXT_OP;
}
@@ -371,11 +371,11 @@
NEXT_OP;
OP(OP_BOX) {
- uint32_t i = *ip++;
+ int i = *ip++;
value_t v = mk_cons();
- car_(v) = FL(stack)[bp+i];
+ car_(v) = bp[i];
cdr_(v) = FL_nil;
- FL(stack)[bp+i] = v;
+ bp[i] = v;
NEXT_OP;
}
@@ -384,7 +384,7 @@
NEXT_OP;
OP(OP_ATOMP)
- FL(stack)[FL(sp)-1] = iscons(FL(stack)[FL(sp)-1]) ? FL_nil : FL_t;
+ FL(sp)[-1] = iscons(FL(sp)[-1]) ? FL_nil : FL_t;
NEXT_OP;
OP(OP_AREF2) {
@@ -391,18 +391,18 @@
n = 2;
if(0){
OP(OP_AREF)
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
n = 3 + *ip++;
}
LABEL(apply_aref):;
- value_t v = FL(stack)[FL(sp)-n];
- for(uint32_t i = n-1; i > 0; i--){
+ value_t v = FL(sp)[-n];
+ for(int i = n-1; i > 0; i--){
if(isarray(v)){
- FL(stack)[FL(sp)-i-1] = v;
- v = cvalue_array_aref(&FL(stack)[FL(sp)-i-1]);
+ FL(sp)[-i-1] = v;
+ v = cvalue_array_aref(FL(sp)-i-1);
continue;
}
- value_t e = FL(stack)[FL(sp)-i];
+ value_t e = FL(sp)[-i];
size_t isz = tosize(e);
if(isvector(v)){
if(fl_unlikely(isz >= vector_size(v)))
@@ -428,7 +428,7 @@
}
OP(OP_NANP) {
- value_t v = FL(stack)[FL(sp)-1];
+ value_t v = FL(sp)[-1];
if(!iscprim(v))
v = FL_nil;
else{
@@ -445,7 +445,7 @@
break;
}
}
- FL(stack)[FL(sp)-1] = v;
+ FL(sp)[-1] = v;
NEXT_OP;
}
@@ -454,34 +454,34 @@
NEXT_OP;
OP(OP_SETCDR) {
- value_t v = FL(stack)[FL(sp)-2];
+ value_t v = FL(sp)[-2];
if(fl_unlikely(!iscons(v))){
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
type_error("cons", v);
}
- cdr_(v) = FL(stack)[FL(sp)-1];
+ cdr_(v) = FL(sp)[-1];
POPN(1);
NEXT_OP;
}
OP(OP_LOADC1)
- PUSH(vector_elt(FL(stack)[bp+nargs], 1));
+ PUSH(vector_elt(bp[nargs], 1));
NEXT_OP;
OP(OP_ASET) {
- FL(stack)[ipd] = (uintptr_t)ip;
- value_t v = FL(stack)[FL(sp)-3];
+ *ipd = (uintptr_t)ip;
+ value_t v = FL(sp)[-3];
n = 3;
if(0){
LABEL(apply_aset):
- v = FL(stack)[FL(sp)-n];
- for(uint32_t i = n-1; i >= 3; i--){
+ v = FL(sp)[-n];
+ for(int i = n-1; i >= 3; i--){
if(isarray(v)){
- FL(stack)[FL(sp)-i-1] = v;
- v = cvalue_array_aref(&FL(stack)[FL(sp)-i-1]);
+ FL(sp)[-i-1] = v;
+ v = cvalue_array_aref(FL(sp)-i-1);
continue;
}
- value_t e = FL(stack)[FL(sp)-i];
+ value_t e = FL(sp)[-i];
size_t isz = tosize(e);
if(isvector(v)){
if(fl_unlikely(isz >= vector_size(v)))
@@ -501,18 +501,18 @@
bounds_error(v0, e);
}
}
- FL(stack)[FL(sp)-3] = v;
+ FL(sp)[-3] = v;
}
- value_t e = FL(stack)[FL(sp)-2];
+ value_t e = FL(sp)[-2];
size_t isz = tosize(e);
if(isvector(v)){
if(fl_unlikely(isz >= vector_size(v)))
bounds_error(v, e);
- vector_elt(v, isz) = (e = FL(stack)[FL(sp)-1]);
+ vector_elt(v, isz) = (e = FL(sp)[-1]);
}else if(iscons(v) || v == FL_nil){
for(value_t v0 = v;; isz--){
if(isz == 0){
- car_(v) = (e = FL(stack)[FL(sp)-1]);
+ car_(v) = (e = FL(sp)[-1]);
break;
}
v = cdr_(v);
@@ -520,7 +520,7 @@
bounds_error(v0, e);
}
}else if(isarray(v)){
- e = cvalue_array_aset(&FL(stack)[FL(sp)-3]);
+ e = cvalue_array_aset(FL(sp)-3);
}else{
type_error("sequence", v);
}
@@ -531,53 +531,53 @@
OP(OP_EQUAL) {
value_t v;
- if(FL(stack)[FL(sp)-2] == FL(stack)[FL(sp)-1])
+ if(FL(sp)[-2] == FL(sp)[-1])
v = FL_t;
else
- v = fl_compare(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], true) == 0 ? FL_t : FL_nil;
- FL(stack)[FL(sp)-2] = v;
+ v = fl_compare(FL(sp)[-2], FL(sp)[-1], true) == 0 ? FL_t : FL_nil;
+ FL(sp)[-2] = v;
POPN(1);
NEXT_OP;
}
OP(OP_CONSP)
- FL(stack)[FL(sp)-1] = iscons(FL(stack)[FL(sp)-1]) ? FL_t : FL_nil;
+ FL(sp)[-1] = iscons(FL(sp)[-1]) ? FL_t : FL_nil;
NEXT_OP;
OP(OP_LOADC) {
- value_t v = FL(stack)[bp+nargs];
- uint32_t i = *ip++;
+ value_t v = bp[nargs];
+ int i = *ip++;
assert(isvector(v));
- assert(i < vector_size(v));
+ assert(i < (int)vector_size(v));
PUSH(vector_elt(v, i));
NEXT_OP;
}
OP(OP_SYMBOLP)
- FL(stack)[FL(sp)-1] = issymbol(FL(stack)[FL(sp)-1]) ? FL_t : FL_nil;
+ FL(sp)[-1] = issymbol(FL(sp)[-1]) ? FL_t : FL_nil;
NEXT_OP;
OP(OP_NUMBERP)
- FL(stack)[FL(sp)-1] = fl_isnumber(FL(stack)[FL(sp)-1]) ? FL_t : FL_nil;
+ FL(sp)[-1] = fl_isnumber(FL(sp)[-1]) ? FL_t : FL_nil;
NEXT_OP;
OP(OP_BRBOUND)
- PUSH(FL(stack)[bp+GET_INT32(ip)] != UNBOUND ? FL_t : FL_nil);
+ PUSH(bp[GET_INT32(ip)] != UNBOUND ? FL_t : FL_nil);
ip += 4;
NEXT_OP;
OP(OP_OPTARGS) {
- uint32_t i = GET_INT32(ip);
+ int i = GET_INT32(ip);
ip += 4;
- uint32_t x = GET_INT32(ip);
+ int x = GET_INT32(ip);
ip += 4;
if(fl_unlikely(nargs < i)){
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
lerrorf(FL_ArgError, "too few arguments");
}
- if((int32_t)x > 0){
+ if(x > 0){
if(fl_unlikely(nargs > x)){
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
lerrorf(FL_ArgError, "too many arguments");
}
}else
@@ -585,14 +585,14 @@
if(fl_likely(x > nargs)){
x -= nargs;
FL(sp) += x;
- FL(stack)[FL(sp)-1] = FL(stack)[FL(sp)-x-1];
- FL(stack)[FL(sp)-2] = nargs+x;
- FL(stack)[FL(sp)-3] = FL(stack)[FL(sp)-x-3];
- FL(stack)[FL(sp)-4] = FL(stack)[FL(sp)-x-4];
+ FL(sp)[-1] = FL(sp)[-x-1];
+ FL(sp)[-2] = nargs+x;
+ FL(sp)[-3] = FL(sp)[-x-3];
+ FL(sp)[-4] = FL(sp)[-x-4];
FL(curr_frame) = FL(sp);
ipd = FL(sp)-1;
for(i = 0; i < x; i++)
- FL(stack)[bp+nargs+i] = UNBOUND;
+ bp[nargs+i] = UNBOUND;
nargs += x;
}
NEXT_OP;
@@ -599,7 +599,7 @@
}
OP(OP_EQ)
- FL(stack)[FL(sp)-2] = FL(stack)[FL(sp)-2] == FL(stack)[FL(sp)-1] ? FL_t : FL_nil;
+ FL(sp)[-2] = FL(sp)[-2] == FL(sp)[-1] ? FL_t : FL_nil;
POPN(1);
NEXT_OP;
@@ -607,7 +607,7 @@
n = *ip++;
LABEL(apply_list):
if(n > 0){
- value_t v = list(&FL(stack)[FL(sp)-n], n, 0);
+ value_t v = list(FL(sp)-n, n, 0);
POPN(n);
PUSH(v);
}else{
@@ -616,9 +616,9 @@
NEXT_OP;
OP(OP_BOUNDP) {
- FL(stack)[ipd] = (uintptr_t)ip;
- symbol_t *sym = tosymbol(FL(stack)[FL(sp)-1]);
- FL(stack)[FL(sp)-1] = sym->binding == UNBOUND ? FL_nil : FL_t;
+ *ipd = (uintptr_t)ip;
+ symbol_t *sym = tosymbol(FL(sp)[-1]);
+ FL(sp)[-1] = sym->binding == UNBOUND ? FL_nil : FL_t;
NEXT_OP;
}
@@ -626,11 +626,11 @@
n = *ip++;
LABEL(apply_numeq):
{
- uint32_t i = n;
- value_t a = FL(stack)[FL(sp)-i], b, v;
+ int i = n;
+ value_t a = FL(sp)[-i], b, v;
for(v = FL_t; i > 1; a = b){
i--;
- b = FL(stack)[FL(sp)-i];
+ b = FL(sp)[-i];
if(bothfixnums(a, b)){
if(a != b){
v = FL_nil;
@@ -647,7 +647,7 @@
NEXT_OP;
OP(OP_CADR) {
- value_t v = FL(stack)[FL(sp)-1];
+ value_t v = FL(sp)[-1];
if(fl_likely(iscons(v))){
v = cdr_(v);
if(fl_likely(iscons(v)))
@@ -657,11 +657,11 @@
}else{
LABEL(cadr_nil):
if(fl_unlikely(v != FL_nil)){
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
type_error("cons", v);
}
}
- FL(stack)[FL(sp)-1] = v;
+ FL(sp)[-1] = v;
NEXT_OP;
}
@@ -674,16 +674,16 @@
n = *ip++;
LABEL(apply_apply):;
value_t v = POP(); // arglist
- n = FL(sp)-(n-2); // n-2 == # leading arguments not in the list
+ value_t *p = FL(sp)-(n-2); // n-2 == # leading arguments not in the list
while(iscons(v)){
- PUSHSAFE(car_(v));
+ PUSH(car_(v));
v = cdr_(v);
}
if(v != FL_nil){
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
lerrorf(FL_ArgError, "apply: last argument: not a list");
}
- n = FL(sp)-n;
+ n = FL(sp)-p;
goto LABEL(do_call);
}
@@ -692,29 +692,29 @@
NEXT_OP;
OP(OP_BUILTINP) {
- value_t v = FL(stack)[FL(sp)-1];
- FL(stack)[FL(sp)-1] = (isbuiltin(v) || iscbuiltin(v)) ? FL_t : FL_nil;
+ value_t v = FL(sp)[-1];
+ FL(sp)[-1] = (isbuiltin(v) || iscbuiltin(v)) ? FL_t : FL_nil;
NEXT_OP;
}
OP(OP_NEG) {
LABEL(do_neg):
- FL(stack)[ipd] = (uintptr_t)ip;
- value_t v = FL(stack)[FL(sp)-1];
+ *ipd = (uintptr_t)ip;
+ value_t v = FL(sp)[-1];
int64_t i64;
- FL(stack)[FL(sp)-1] = isfixnum(v) ? fixnum_neg(v) : fl_neg(v);
+ FL(sp)[-1] = isfixnum(v) ? fixnum_neg(v) : fl_neg(v);
NEXT_OP;
}
OP(OP_FIXNUMP)
- FL(stack)[FL(sp)-1] = isfixnum(FL(stack)[FL(sp)-1]) ? FL_t : FL_nil;
+ FL(sp)[-1] = isfixnum(FL(sp)[-1]) ? FL_t : FL_nil;
NEXT_OP;
OP(OP_MUL) {
n = *ip++;
LABEL(apply_mul):
- FL(stack)[ipd] = (uintptr_t)ip;
- value_t v = fl_mul_any(&FL(stack)[FL(sp)-n], n);
+ *ipd = (uintptr_t)ip;
+ value_t v = fl_mul_any(FL(sp)-n, n);
POPN(n);
PUSH(v);
NEXT_OP;
@@ -721,21 +721,21 @@
}
OP(OP_IDIV) {
- value_t a = FL(stack)[FL(sp)-2];
- value_t b = FL(stack)[FL(sp)-1];
+ value_t a = FL(sp)[-2];
+ value_t b = FL(sp)[-1];
value_t v;
if(bothfixnums(a, b)){
if(b == 0){
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
divide_by_0_error();
}
v = fixnum(numval(a) / numval(b));
}else{
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
v = fl_idiv2(a, b);
}
POPN(1);
- FL(stack)[FL(sp)-1] = v;
+ FL(sp)[-1] = v;
NEXT_OP;
}
@@ -742,18 +742,18 @@
OP(OP_DIV) {
n = *ip++;
LABEL(apply_div):
- FL(stack)[ipd] = (uintptr_t)ip;
- uint32_t i = FL(sp)-n;
+ *ipd = (uintptr_t)ip;
+ value_t *p = FL(sp)-n;
if(n == 1){
- FL(stack)[FL(sp)-1] = fl_div2(fixnum(1), FL(stack)[i]);
+ FL(sp)[-1] = fl_div2(fixnum(1), *p);
}else{
if(fl_unlikely(n > 2)){
- PUSH(FL(stack)[i]);
- FL(stack)[i] = fixnum(1);
- FL(stack)[i+1] = fl_mul_any(&FL(stack)[i], n);
- FL(stack)[i] = POP();
+ PUSH(*p);
+ *p = fixnum(1);
+ p[1] = fl_mul_any(p, n);
+ *p = POP();
}
- value_t v = fl_div2(FL(stack)[i], FL(stack)[i+1]);
+ value_t v = fl_div2(p[0], p[1]);
POPN(n);
PUSH(v);
}
@@ -765,7 +765,7 @@
LABEL(apply_vector):;
value_t v = alloc_vector(n, 0);
if(n){
- memcpy(&vector_elt(v, 0), &FL(stack)[FL(sp)-n], n*sizeof(value_t));
+ memcpy(&vector_elt(v, 0), FL(sp)-n, n*sizeof(value_t));
POPN(n);
}
PUSH(v);
@@ -773,24 +773,24 @@
}
OP(OP_COMPARE)
- FL(stack)[FL(sp)-2] = fl_compare(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], false);
+ FL(sp)[-2] = fl_compare(FL(sp)[-2], FL(sp)[-1], false);
POPN(1);
NEXT_OP;
OP(OP_FOR) {
- FL(stack)[ipd] = (uintptr_t)ip;
- uint32_t i = FL(sp);
+ *ipd = (uintptr_t)ip;
+ value_t *p = FL(sp);
value_t v;
- fixnum_t s = tofixnum(FL(stack)[i-3]);
- fixnum_t hi = tofixnum(FL(stack)[i-2]);
+ fixnum_t s = tofixnum(p[-3]);
+ fixnum_t hi = tofixnum(p[-2]);
FL(sp) += 2;
for(v = FL_void; s <= hi; s++){
- FL(stack)[i+0] = FL(stack)[i-1];
- FL(stack)[i+1] = fixnum(s);
+ p[0] = p[-1];
+ p[1] = fixnum(s);
v = _applyn(1);
}
POPN(4);
- FL(stack)[i+1] = v;
+ p[1] = v;
NEXT_OP;
}
@@ -801,12 +801,12 @@
i = GET_INT32(ip);
ip += 4;
}
- value_t v = fn_vals(FL(stack)[bp-1]);
- assert(i < vector_size(v));
+ value_t v = fn_vals(bp[-1]);
+ assert(i < (int)vector_size(v));
v = vector_elt(v, i);
assert(issymbol(v));
symbol_t *sym = ptr(v);
- v = FL(stack)[FL(sp)-1];
+ v = FL(sp)[-1];
if(!isconstant(sym))
sym->binding = v;
NEXT_OP;
@@ -813,14 +813,14 @@
}
OP(OP_VECTORP)
- FL(stack)[FL(sp)-1] = isvector(FL(stack)[FL(sp)-1]) ? FL_t : FL_nil;
+ FL(sp)[-1] = isvector(FL(sp)[-1]) ? FL_t : FL_nil;
NEXT_OP;
OP(OP_TRYCATCH) {
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
value_t v = do_trycatch();
POPN(1);
- FL(stack)[FL(sp)-1] = v;
+ FL(sp)[-1] = v;
NEXT_OP;
}
@@ -829,8 +829,8 @@
if(n == 2)
goto LABEL(do_add2);
LABEL(apply_add):
- FL(stack)[ipd] = (uintptr_t)ip;
- value_t v = fl_add_any(&FL(stack)[FL(sp)-n], n);
+ *ipd = (uintptr_t)ip;
+ value_t v = fl_add_any(FL(sp)-n, n);
POPN(n);
PUSH(v);
NEXT_OP;
@@ -838,33 +838,33 @@
OP(OP_LOADAL)
assert(nargs > 0);
- PUSH(FL(stack)[bp+GET_INT32(ip)]);
+ PUSH(bp[GET_INT32(ip)]);
ip += 4;
NEXT_OP;
OP(OP_EQV) {
value_t v;
- if(FL(stack)[FL(sp)-2] == FL(stack)[FL(sp)-1])
+ if(FL(sp)[-2] == FL(sp)[-1])
v = FL_t;
- else if(!leafp(FL(stack)[FL(sp)-2]) || !leafp(FL(stack)[FL(sp)-1]))
+ else if(!leafp(FL(sp)[-2]) || !leafp(FL(sp)[-1]))
v = FL_nil;
else
- v = fl_compare(FL(stack)[FL(sp)-2], FL(stack)[FL(sp)-1], true) == 0 ? FL_t : FL_nil;
- FL(stack)[FL(sp)-2] = v;
+ v = fl_compare(FL(sp)[-2], FL(sp)[-1], true) == 0 ? FL_t : FL_nil;
+ FL(sp)[-2] = v;
POPN(1);
NEXT_OP;
}
OP(OP_KEYARGS) {
- value_t v = fn_vals(FL(stack)[bp-1]);
+ value_t v = fn_vals(bp[-1]);
v = vector_elt(v, 0);
- uint32_t i = GET_INT32(ip);
+ int i = GET_INT32(ip);
ip += 4;
- uint32_t x = GET_INT32(ip);
+ int x = GET_INT32(ip);
ip += 4;
fixnum_t s = GET_INT32(ip);
ip += 4;
- FL(stack)[ipd] = (uintptr_t)ip;
+ *ipd = (uintptr_t)ip;
nargs = process_keys(v, i, x, labs(s)-(i+x), bp, nargs, s<0);
ipd = FL(sp)-1;
NEXT_OP;
@@ -877,17 +877,17 @@
goto LABEL(do_sub2);
if(n == 1)
goto LABEL(do_neg);
- FL(stack)[ipd] = (uintptr_t)ip;
- uint32_t i = FL(sp)-n;
+ *ipd = (uintptr_t)ip;
+ value_t *p = FL(sp)-n;
// we need to pass the full arglist on to fl_add_any
// so it can handle rest args properly
- PUSH(FL(stack)[i]);
- FL(stack)[i] = fixnum(0);
- value_t v = fl_add_any(&FL(stack)[i], n);
+ PUSH(*p);
+ *p = fixnum(0);
+ value_t v = fl_add_any(p, n);
int64_t i64;
- FL(stack)[i+1] = isfixnum(v) ? fixnum_neg(v) : fl_neg(v);
- FL(stack)[i] = POP();
- v = fl_add_any(&FL(stack)[i], 2);
+ p[1] = isfixnum(v) ? fixnum_neg(v) : fl_neg(v);
+ p[0] = POP();
+ v = fl_add_any(p, 2);
POPN(n);
PUSH(v);
NEXT_OP;
@@ -898,23 +898,23 @@
NEXT_OP;
OP(OP_SETAL)
- FL(stack)[bp+GET_INT32(ip)] = FL(stack)[FL(sp)-1];
+ bp[GET_INT32(ip)] = FL(sp)[-1];
ip += 4;
NEXT_OP;
OP(OP_BOXL) {
- uint32_t i = GET_INT32(ip);
+ int i = GET_INT32(ip);
ip += 4;
value_t v = mk_cons();
- car_(v) = FL(stack)[bp+i];
+ car_(v) = bp[i];
cdr_(v) = FL_nil;
- FL(stack)[bp+i] = v;
+ bp[i] = v;
NEXT_OP;
}
OP(OP_FUNCTIONP) {
- value_t v = FL(stack)[FL(sp)-1];
- FL(stack)[FL(sp)-1] =
+ value_t v = FL(sp)[-1];
+ FL(sp)[-1] =
((tag(v) == TAG_FUNCTION &&
(isbuiltin(v) || v>(N_BUILTINS<<3))) ||
iscbuiltin(v)) ? FL_t : FL_nil;
@@ -926,7 +926,7 @@
NEXT_OP;
OP(OP_BRNEL)
- ip += FL(stack)[FL(sp)-2] != FL(stack)[FL(sp)-1] ? GET_INT32(ip) : 4;
+ ip += FL(sp)[-2] != FL(sp)[-1] ? GET_INT32(ip) : 4;
POPN(2);
NEXT_OP;
@@ -936,12 +936,12 @@
OP(OP_LOADCL)
ip += 4;
- PUSH(vector_elt(FL(stack)[bp+nargs], GET_INT32(ip)));
+ PUSH(vector_elt(bp[nargs], GET_INT32(ip)));
ip += 4;
NEXT_OP;
OP(OP_LOADVL) {
- value_t v = fn_vals(FL(stack)[bp-1]);
+ value_t v = fn_vals(bp[-1]);
v = vector_elt(v, GET_INT32(ip));
ip += 4;
PUSH(v);