diff options
author | Keith Packard <keithp@keithp.com> | 2016-11-06 10:53:46 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2016-11-17 22:18:39 -0800 |
commit | b97b9f8199d1f65d2304b035c4f99b5a1c76f61b (patch) | |
tree | df65524df6271dde7107a32c6a3db93dd603f879 /src/lisp/ao_lisp_cons.c | |
parent | 954bc72d5822e0f5666e80764e798c10b1eb541d (diff) |
altos/lisp: convert GC to non-recursive
Use a boolean array to note cons cells which would otherwise recurse,
then loop until that array is empty.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lisp/ao_lisp_cons.c')
-rw-r--r-- | src/lisp/ao_lisp_cons.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lisp/ao_lisp_cons.c b/src/lisp/ao_lisp_cons.c index 7d3ca68d..855079b8 100644 --- a/src/lisp/ao_lisp_cons.c +++ b/src/lisp/ao_lisp_cons.c @@ -21,7 +21,7 @@ static void cons_mark(void *addr) struct ao_lisp_cons *cons = addr; for (;;) { - ao_lisp_poly_mark(cons->car); + ao_lisp_poly_mark(cons->car, 1); cons = ao_lisp_poly_cons(cons->cdr); if (!cons) break; @@ -44,10 +44,17 @@ static void cons_move(void *addr) return; for (;;) { - (void) ao_lisp_poly_move(&cons->car); - if (ao_lisp_poly_move(&cons->cdr)) + struct ao_lisp_cons *cdr; + int ret; + + (void) ao_lisp_poly_move(&cons->car, 1); + cdr = ao_lisp_poly_cons(cons->cdr); + ret = ao_lisp_move_memory((void **) &cdr, sizeof (struct ao_lisp_cons)); + if (cdr != ao_lisp_poly_cons(cons->cdr)) + cons->cdr = ao_lisp_cons_poly(cdr); + if (ret) break; - cons = ao_lisp_poly_cons(cons->cdr); + cons = cdr; } } |