From 8596e1812abc6d70721cf7157adce5e95d14113d Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sat, 26 Dec 2009 08:25:57 +0900 Subject: [PATCH] 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. --- TODO | 7 ++----- eval.c | 7 ++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index 8c59ef19..854cceb3 100644 --- a/TODO +++ b/TODO @@ -9,11 +9,8 @@ - State "DONE" [2009-04-09 Thu 14:45] ** TODO native x86 backend ** TODO fasl/image files -** TODO shared stack on EVAL - Arguably a bug, at the moment we create a new stack on every EVAL - (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)). +** DONE shared stack on EVAL + - State "DONE" [2009-12-26 Sat 08:22] * compiler optimizations ** DONE constant folding diff --git a/eval.c b/eval.c index 4ec24ffc..7b7305fc 100644 --- a/eval.c +++ b/eval.c @@ -2653,13 +2653,18 @@ sexp sexp_compile (sexp ctx, sexp x) { } sexp sexp_eval (sexp ctx, sexp obj, sexp env) { + sexp_sint_t top; sexp ctx2; sexp_gc_var1(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); if (! sexp_exceptionp(res)) res = sexp_apply(ctx2, res, SEXP_NULL); + sexp_context_top(ctx) = top; sexp_gc_release1(ctx); return res; }