recursive evals now share the same stack.

since in a minimal chibi heap the stack accounts for a large
amount of the space, this makes a big difference - you can
now load (chibi match) in a 2MB heap on a 64-bit system and
it won't grow the heap.
This commit is contained in:
Alex Shinn 2009-12-26 08:25:57 +09:00
parent 7392e082cc
commit 8596e1812a
2 changed files with 8 additions and 6 deletions

7
TODO
View file

@ -9,11 +9,8 @@
- State "DONE" [2009-04-09 Thu 14:45] - State "DONE" [2009-04-09 Thu 14:45]
** TODO native x86 backend ** TODO native x86 backend
** TODO fasl/image files ** TODO fasl/image files
** TODO shared stack on EVAL ** DONE shared stack on EVAL
Arguably a bug, at the moment we create a new stack on every EVAL - State "DONE" [2009-12-26 Sat 08:22]
(which includes every macro definition, and in particular every
call to let-syntax that a macro may expand into - I'm looking at
you, (chibi loop)).
* compiler optimizations * compiler optimizations
** DONE constant folding ** DONE constant folding

7
eval.c
View file

@ -2653,13 +2653,18 @@ sexp sexp_compile (sexp ctx, sexp x) {
} }
sexp sexp_eval (sexp ctx, sexp obj, sexp env) { sexp sexp_eval (sexp ctx, sexp obj, sexp env) {
sexp_sint_t top;
sexp ctx2; sexp ctx2;
sexp_gc_var1(res); sexp_gc_var1(res);
sexp_gc_preserve1(ctx, res); sexp_gc_preserve1(ctx, res);
ctx2 = sexp_make_eval_context(ctx, NULL, (env ? env : sexp_context_env(ctx))); top = sexp_context_top(ctx);
ctx2 = sexp_make_eval_context(ctx,
sexp_context_stack(ctx),
(env ? env : sexp_context_env(ctx)));
res = sexp_compile(ctx2, obj); res = sexp_compile(ctx2, obj);
if (! sexp_exceptionp(res)) if (! sexp_exceptionp(res))
res = sexp_apply(ctx2, res, SEXP_NULL); res = sexp_apply(ctx2, res, SEXP_NULL);
sexp_context_top(ctx) = top;
sexp_gc_release1(ctx); sexp_gc_release1(ctx);
return res; return res;
} }