diff options
| author | Keith Packard <keithp@keithp.com> | 2016-11-05 14:51:58 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2017-02-20 11:16:50 -0800 | 
| commit | 3366efb139653939f053c1fe4aba352ba3b66c94 (patch) | |
| tree | 57c01798cfaef078e4e8ca11680a9bb748ed3334 /src/lisp/ao_lisp_cons.c | |
| parent | 6fc1ee0f7adc6fcb3e850bcbaabc1db705314234 (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.c | 37 | 
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 = { | 
