summaryrefslogtreecommitdiff
path: root/src/lisp/ao_lisp_cons.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-11-05 14:51:58 -0700
committerKeith Packard <keithp@keithp.com>2016-11-17 22:18:39 -0800
commit8f57c0761eaf1f10493fd52118d309eb69491464 (patch)
treede9b0b076296dd93a6eb0eab9e65da55df4018fe /src/lisp/ao_lisp_cons.c
parent22076dcd5598ef30220bd9fde7a327765f447d43 (diff)
altos/lisp: Change GC move API
Pass reference to move API so it can change the values in-place, then let it return '1' when the underlying object has already been moved to shorten GC times. 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.c37
1 files changed, 6 insertions, 31 deletions
diff --git a/src/lisp/ao_lisp_cons.c b/src/lisp/ao_lisp_cons.c
index f8a34ed4..4929b91c 100644
--- a/src/lisp/ao_lisp_cons.c
+++ b/src/lisp/ao_lisp_cons.c
@@ -16,21 +16,6 @@
#define OFFSET(a) ((int) ((uint8_t *) (a) - ao_lisp_const))
-#if 0
-static int cons_depth;
-#define DBG(...) do { int d; for (d = 0; d < cons_depth; d++) printf (" "); printf(__VA_ARGS__); } while(0)
-#define DBG_IN() (cons_depth++)
-#define DBG_OUT() (cons_depth--)
-#define DBG_PR(c) ao_lisp_cons_print(ao_lisp_cons_poly(c))
-#define DBG_PRP(p) ao_lisp_poly_print(p)
-#else
-#define DBG(...)
-#define DBG_IN()
-#define DBG_OUT()
-#define DBG_PR(c)
-#define DBG_PRP(p)
-#endif
-
static void cons_mark(void *addr)
{
struct ao_lisp_cons *cons = addr;
@@ -55,25 +40,15 @@ static void cons_move(void *addr)
{
struct ao_lisp_cons *cons = addr;
- DBG_IN();
- DBG("move cons start %d\n", OFFSET(cons));
- for (;;) {
- struct ao_lisp_cons *cdr;
- ao_poly car;
+ if (!cons)
+ return;
- car = ao_lisp_poly_move(cons->car);
- DBG(" moved car %d -> %d\n", OFFSET(ao_lisp_ref(cons->car)), OFFSET(ao_lisp_ref(car)));
- cons->car = car;
- cdr = ao_lisp_poly_cons(cons->cdr);
- cdr = ao_lisp_move_memory(cdr, sizeof (struct ao_lisp_cons));
- if (!cdr)
+ for (;;) {
+ (void) ao_lisp_poly_move(&cons->car);
+ if (ao_lisp_poly_move(&cons->cdr))
break;
- DBG(" moved cdr %d -> %d\n", OFFSET(ao_lisp_poly_cons(cons->cdr)), OFFSET(cdr));
- cons->cdr = ao_lisp_cons_poly(cdr);
- cons = cdr;
+ cons = ao_lisp_poly_cons(cons->cdr);
}
- DBG("move cons end\n");
- DBG_OUT();
}
const struct ao_lisp_type ao_lisp_cons_type = {