summaryrefslogtreecommitdiff
path: root/src/lisp/ao_lisp_eval.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-11-15 20:18:59 -0800
committerKeith Packard <keithp@keithp.com>2017-02-20 11:16:51 -0800
commit881161fe1c5fb0e2b1220c30572eb2c45bedbafe (patch)
tree36070649f2e3d46de239f769cc67cc765f3b9c9a /src/lisp/ao_lisp_eval.c
parent994adc7a47cbf3cbf6041eca7430273f8018de08 (diff)
altos/lisp: re-use small frames
This saves a pile more use of the allocator by noting when frames have not been referenced from another frame and freeing them when they go out of scope. Frames with references are left to the allocator to deal with. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp/ao_lisp_eval.c')
-rw-r--r--src/lisp/ao_lisp_eval.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lisp/ao_lisp_eval.c b/src/lisp/ao_lisp_eval.c
index 3af56796..6f56a120 100644
--- a/src/lisp/ao_lisp_eval.c
+++ b/src/lisp/ao_lisp_eval.c
@@ -122,7 +122,8 @@ ao_lisp_stack_push(void)
static void
ao_lisp_stack_pop(void)
{
- ao_poly prev;
+ ao_poly prev;
+ struct ao_lisp_frame *prev_frame;
if (!ao_lisp_stack)
return;
@@ -131,10 +132,13 @@ ao_lisp_stack_pop(void)
ao_lisp_stack_free_list = ao_lisp_stack;
ao_lisp_stack = ao_lisp_poly_stack(prev);
+ prev_frame = ao_lisp_frame_current;
if (ao_lisp_stack)
ao_lisp_frame_current = ao_lisp_poly_frame(ao_lisp_stack->frame);
else
ao_lisp_frame_current = NULL;
+ if (ao_lisp_frame_current != prev_frame)
+ ao_lisp_frame_free(prev_frame);
DBG_OUT();
DBGI("stack pop\n");
DBG_FRAMES();