From 98923ae1189f062b8b94120d47a56892db25493f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 1 Dec 2017 18:28:16 +0100 Subject: altos/lisp: Split out frame vals from frame struct This lets the frame be resized without moving the base structure. The plan is to allow all frames to be resized, not just the global frame. Signed-off-by: Keith Packard --- src/lisp/ao_lisp_mem.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/lisp/ao_lisp_mem.c') diff --git a/src/lisp/ao_lisp_mem.c b/src/lisp/ao_lisp_mem.c index dc0008c4..890eba1b 100644 --- a/src/lisp/ao_lisp_mem.c +++ b/src/lisp/ao_lisp_mem.c @@ -148,6 +148,7 @@ struct ao_lisp_root { static struct ao_lisp_cons *save_cons[2]; static char *save_string[2]; +static struct ao_lisp_frame *save_frame[1]; static ao_poly save_poly[3]; static const struct ao_lisp_root ao_lisp_root[] = { @@ -167,6 +168,10 @@ static const struct ao_lisp_root ao_lisp_root[] = { .type = &ao_lisp_string_type, .addr = (void **) &save_string[1], }, + { + .type = &ao_lisp_frame_type, + .addr = (void **) &save_frame[0], + }, { .type = NULL, .addr = (void **) (void *) &save_poly[0] @@ -455,6 +460,7 @@ static const struct ao_lisp_type *ao_lisp_types[AO_LISP_NUM_TYPE] = { [AO_LISP_ATOM] = &ao_lisp_atom_type, [AO_LISP_BUILTIN] = &ao_lisp_builtin_type, [AO_LISP_FRAME] = &ao_lisp_frame_type, + [AO_LISP_FRAME_VALS] = &ao_lisp_frame_vals_type, [AO_LISP_LAMBDA] = &ao_lisp_lambda_type, [AO_LISP_STACK] = &ao_lisp_stack_type, [AO_LISP_BOOL] = &ao_lisp_bool_type, @@ -620,6 +626,29 @@ ao_lisp_collect(uint8_t style) * Mark interfaces for objects */ + +/* + * Mark a block of memory with an explicit size + */ + +int +ao_lisp_mark_block(void *addr, int size) +{ + int offset; + if (!AO_LISP_IS_POOL(addr)) + return 1; + + offset = pool_offset(addr); + MDBG_MOVE("mark memory %d\n", MDBG_OFFSET(addr)); + if (busy(ao_lisp_busy, offset)) { + MDBG_MOVE("already marked\n"); + return 1; + } + mark(ao_lisp_busy, offset); + note_chunk(offset, size); + return 0; +} + /* * Note a reference to memory and collect information about a few * object sizes at a time @@ -891,3 +920,16 @@ ao_lisp_string_fetch(int id) return string; } +void +ao_lisp_frame_stash(int id, struct ao_lisp_frame *frame) +{ + save_frame[id] = frame; +} + +struct ao_lisp_frame * +ao_lisp_frame_fetch(int id) +{ + struct ao_lisp_frame *frame = save_frame[id]; + save_frame[id] = NULL; + return frame; +} -- cgit v1.2.3