altos/lisp: make sure stack->formals_last gets moved during GC
authorKeith Packard <keithp@keithp.com>
Sat, 5 Nov 2016 22:12:05 +0000 (15:12 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 18 Nov 2016 06:18:39 +0000 (22:18 -0800)
Failing this leads to broken formals chains

Signed-off-by: Keith Packard <keithp@keithp.com>
src/lisp/ao_lisp_eval.c
src/lisp/ao_lisp_mem.c

index b7e7b9727639bb536c4a6f121f6261531eb9fc6f..0de3f1905bf1b81c05e1ca67c9d9a1c7844626b8 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "ao_lisp.h"
 
-#if 1
+#if 0
 static int stack_depth;
 #define DBG_INDENT()   do { int _s; for(_s = 0; _s < stack_depth; _s++) printf("  "); } while(0)
 #define DBG_IN()       (++stack_depth)
@@ -80,6 +80,7 @@ stack_mark(void *addr)
        for (;;) {
                ao_lisp_poly_mark(stack->actuals);
                ao_lisp_poly_mark(stack->formals);
+               /* no need to mark formals_tail */
                ao_lisp_poly_mark(stack->frame);
                stack = ao_lisp_poly_stack(stack->prev);
                if (ao_lisp_mark_memory(stack, sizeof (struct ao_lisp_stack)))
@@ -99,6 +100,7 @@ stack_move(void *addr)
                int     ret;
                (void) ao_lisp_poly_move(&stack->actuals);
                (void) ao_lisp_poly_move(&stack->formals);
+               (void) ao_lisp_poly_move(&stack->formals_tail);
                (void) ao_lisp_poly_move(&stack->frame);
                prev = ao_lisp_poly_stack(stack->prev);
                ret = ao_lisp_move(&ao_lisp_stack_type, &prev);
@@ -250,7 +252,7 @@ ao_lisp_lambda(struct ao_lisp_cons *cons)
        if (args_wanted != args_provided)
                return ao_lisp_error(AO_LISP_INVALID, "need %d args, not %d", args_wanted, args_provided);
        next_frame = ao_lisp_frame_new(args_wanted);
-       DBGI("new frame %d\n", OFFSET(next_frame));
+//     DBGI("new frame %d\n", OFFSET(next_frame));
        switch (type) {
        case _ao_lisp_atom_lambda: {
                int                     f;
index 29d8dbf44d2beb657b64ec9c7285e54194d478cd..9e716da9b2ebfbf82b6ccce6c55b1afc53b3432a 100644 (file)
@@ -35,8 +35,8 @@ uint8_t       ao_lisp_pool[AO_LISP_POOL] __attribute__((aligned(4)));
 #define DBG_POOL
 #endif
 
-#if 1
-#define DBG_DUMP
+#if 0
+#define DBG_DUMP       0
 #define DBG_OFFSET(a)  ((int) ((uint8_t *) (a) - ao_lisp_pool))
 #define DBG(...) printf(__VA_ARGS__)
 #define DBG_DO(a)      a
@@ -194,7 +194,7 @@ move_object(void)
        DBG_MOVE("move done\n");
 }
 
-#ifdef DBG_DUMP
+#if DBG_DUMP
 static void
 dump_busy(void)
 {