1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-18 06:34:48 +00:00

symbolslots should be gc'd, local_symbols always pushed in case *debug* is set in middle of function

This commit is contained in:
Jona Ekenberg 2023-02-01 11:45:13 +01:00
parent 624a6cf619
commit ce31db09e4
5 changed files with 7 additions and 11 deletions

View File

@ -218,7 +218,7 @@ JanetFuncDef *janet_funcdef_alloc(void) {
def->closure_bitset = NULL;
def->flags = 0;
def->slotcount = 0;
def->symbolslots = 0;
def->symbolslots = NULL;
def->arity = 0;
def->min_arity = 0;
def->max_arity = INT32_MAX;

View File

@ -1012,9 +1012,7 @@ JanetCompileResult janet_compile_lint(Janet source,
janetc_init(&c, env, where, lints);
/* Push a function scope */
if (janet_truthy(janet_dyn("debug"))) {
janet_v_push(c.local_symbols, NULL);
}
janet_v_push(c.local_symbols, NULL);
janetc_scope(&rootscope, &c, JANET_SCOPE_FUNCTION | JANET_SCOPE_TOP, "root");
/* Set initial form options */

View File

@ -314,6 +314,7 @@ static void janet_deinit_block(JanetGCObject *mem) {
janet_free(def->bytecode);
janet_free(def->sourcemap);
janet_free(def->closure_bitset);
janet_free(def->symbolslots);
}
break;
}

View File

@ -824,6 +824,8 @@ static const uint8_t *unmarshal_one_def(
def->constants = NULL;
def->bytecode = NULL;
def->sourcemap = NULL;
def->symbolslots = NULL;
def->symbolslots_length = 0;
janet_v_push(st->lookup_defs, def);
/* Set default lengths to zero */

View File

@ -753,10 +753,7 @@ static JanetSlot janetc_while(JanetFopts opts, int32_t argn, const Janet *argv)
if (c->buffer) janet_v__cnt(c->buffer) = labelwt;
if (c->mapbuffer) janet_v__cnt(c->mapbuffer) = labelwt;
if (janet_truthy(janet_dyn("debug"))) {
janet_v_push(c->local_symbols, NULL);
}
janet_v_push(c->local_symbols, NULL);
janetc_scope(&tempscope, c, JANET_SCOPE_FUNCTION, "while-iife");
/* Recompile in the function scope */
@ -833,9 +830,7 @@ static JanetSlot janetc_fn(JanetFopts opts, int32_t argn, const Janet *argv) {
/* Begin function */
c->scope->flags |= JANET_SCOPE_CLOSURE;
if (janet_truthy(janet_dyn("debug"))) {
janet_v_push(c->local_symbols, NULL);
}
janet_v_push(c->local_symbols, NULL);
janetc_scope(&fnscope, c, JANET_SCOPE_FUNCTION, "function");
if (argn == 0) {