From d48a2e0f78cfd0a0a3ad1deaf46dac5b5c138cf7 Mon Sep 17 00:00:00 2001 From: Benjamin Vedder Date: Tue, 1 Feb 2022 21:35:41 +0100 Subject: [PATCH] Squashed 'lispBM/lispBM/' changes from 9559204f..046eb52e 046eb52e Change the eval_state state machine to not go into pause mode (visible outside) until after gc if instructed to run GC git-subtree-dir: lispBM/lispBM git-subtree-split: 046eb52e068c6f8ec15c8f8e7bd7b0c348edde1c --- repl-cps/repl.c | 2 +- src/eval_cps.c | 14 +++++++------- src/lbm_c_interop.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/repl-cps/repl.c b/repl-cps/repl.c index c6eeb406..78adc998 100644 --- a/repl-cps/repl.c +++ b/repl-cps/repl.c @@ -169,7 +169,7 @@ lbm_value ext_print(lbm_value *args, lbm_uint argn) { lbm_array_header_t *array = (lbm_array_header_t *)lbm_car(t); switch (array->elt_type){ case LBM_VAL_TYPE_CHAR: { - char *data = (char*)array + 8; + char *data = (char*)array->data; printf("%s", data); break; } diff --git a/src/eval_cps.c b/src/eval_cps.c index f8a086d5..c8d08376 100644 --- a/src/eval_cps.c +++ b/src/eval_cps.c @@ -1919,24 +1919,24 @@ void lbm_run_eval(void){ while (eval_running) { - uint32_t prev_state = eval_cps_run_state; - eval_cps_run_state = eval_cps_next_state; + //uint32_t prev_state = eval_cps_run_state; + //eval_cps_run_state = eval_cps_next_state; - switch (eval_cps_run_state) { + switch (eval_cps_next_state) { case EVAL_CPS_STATE_INIT: - eval_cps_next_state = EVAL_CPS_STATE_RUNNING; + eval_cps_run_state = EVAL_CPS_STATE_RUNNING; break; case EVAL_CPS_STATE_STEP: - eval_cps_next_state = EVAL_CPS_STATE_PAUSED; + eval_cps_run_state = EVAL_CPS_STATE_PAUSED; break; case EVAL_CPS_STATE_PAUSED: - if (prev_state != EVAL_CPS_STATE_PAUSED) { + if (eval_cps_run_state != EVAL_CPS_STATE_PAUSED) { if (lbm_heap_num_free() < eval_cps_next_state_arg) { gc(NIL, NIL); } eval_cps_next_state_arg = 0; } - eval_cps_next_state = EVAL_CPS_STATE_PAUSED; + eval_cps_run_state = EVAL_CPS_STATE_PAUSED; usleep_callback(EVAL_CPS_MIN_SLEEP); continue; /* jump back to start of eval_running loop */ case EVAL_CPS_STATE_KILL: diff --git a/src/lbm_c_interop.c b/src/lbm_c_interop.c index 70af0946..18af0ddd 100644 --- a/src/lbm_c_interop.c +++ b/src/lbm_c_interop.c @@ -168,7 +168,7 @@ int lbm_define(char *symbol, lbm_value value) { if (lbm_get_eval_state() == EVAL_CPS_STATE_PAUSED) { if (!lbm_get_symbol_by_name(symbol, &sym_id)) { - if (!lbm_add_symbol(symbol, &sym_id)) { + if (!lbm_add_symbol_const(symbol, &sym_id)) { return 0; } }