[maybe] bytevm: open-code lexical environment allocation

To avoid dependency on vector.o we opencode allocating the vector.

Note that we can't use ecl_make_stack, because mallocated memory must be
reegistered as a root.

[todo] move finalizers to memory and fix t_bclosure
[note] ecl_stack_pshu never resizes the stack (realloc vs manual resize)
This commit is contained in:
Daniel Kochmański 2025-06-06 15:15:48 +02:00
parent 0f616e9e2c
commit a54570352a
2 changed files with 18 additions and 4 deletions

View file

@ -175,16 +175,22 @@ ecl_lex_env_get_record(cl_object env, int s)
/* -- Lexical and local env operators ------------------------------------------ */
static cl_object
make_lex(cl_index n)
make_lex(cl_index size)
{
return si_make_vector(ECL_T, ecl_make_fixnum(n), ECL_NIL,
ecl_make_fixnum(0), ECL_NIL, ECL_NIL);
cl_object x = ecl_alloc_object(t_vector);
x->vector.elttype = ecl_aet_object;
x->vector.displaced = ECL_NIL;
x->vector.dim = size;
x->vector.fillp = 0;
x->vector.flags = ECL_FLAG_ADJUSTABLE | ECL_FLAG_HAS_FILL_POINTER;
x->vector.self.t = (cl_object *)ecl_alloc(size * sizeof(cl_object));
return x;
}
static void
push_lex(cl_object stack, cl_object new)
{
cl_vector_push(new, stack);
ecl_stack_pshu(stack, new);
}
/* -------------------- AIDS TO THE INTERPRETER -------------------- */

View file

@ -340,6 +340,13 @@ standard_finalizer(cl_object o)
case t_weak_pointer:
GC_unregister_disappearing_link((void**)&(o->weak.value));
break;
#if 0
case t_bclosure: {
ecl_free_stack(o->bclosure.lex);
o->bclosure.lex = ECL_NIL;
break;
}
#endif
#ifdef ECL_THREADS
case t_lock: {
const cl_env_ptr the_env = ecl_process_env();
@ -400,6 +407,7 @@ standard_finalizer(cl_object o)
ecl_atomic_push(&ecl_core.reused_indices, ecl_make_fixnum(o->symbol.binding));
o->symbol.binding = ECL_MISSING_SPECIAL_BINDING;
}
break;
}
#endif /* ECL_THREADS */
default:;