bytecodes: add a new slot nlcl denoting the maximal number of locals

Currently it is initialized to NIL, the next commit will assign to it a correct
value.
This commit is contained in:
Daniel Kochmański 2025-05-01 08:22:59 +02:00
parent 9addb2cc4a
commit 600901da05
5 changed files with 10 additions and 2 deletions

View file

@ -190,6 +190,7 @@ asm_end(cl_env_ptr env, cl_index beginning, cl_object definition) {
bytecodes->bytecodes.code = ecl_alloc_atomic(code_size * sizeof(cl_opcode));
bytecodes->bytecodes.data = c_env->constants;
bytecodes->bytecodes.flex = ECL_NIL;
bytecodes->bytecodes.nlcl = ECL_NIL;
for (i = 0, code = (cl_opcode *)bytecodes->bytecodes.code; i < code_size; i++) {
code[i] = (cl_opcode)(cl_fixnum)(env->stack[beginning+i]);
}
@ -642,7 +643,7 @@ c_restore_env(cl_env_ptr the_env, cl_compiler_env_ptr new_c_env, cl_compiler_env
static void
close_around_macros(cl_env_ptr env, cl_object mfun)
{
cl_object lex = mfun->bclosure.lex, record;
cl_object lex = mfun->bclosure.lex;
cl_object *lex_vec = lex->vector.self.t;
for (cl_index i = 0; i < lex->vector.dim; i++) {
cl_object reg = lex_vec[i]; /* INV see interpreter.d for lexenv structure */
@ -3603,6 +3604,7 @@ ecl_make_lambda(cl_env_ptr env, cl_object name, cl_object lambda) {
output = asm_end(env, handle, lambda);
output->bytecodes.name = name;
output->bytecodes.flex = ECL_NIL;
output->bytecodes.nlcl = ECL_NIL;
old_c_env->load_time_forms = new_c_env->load_time_forms;

View file

@ -30,6 +30,7 @@ _ecl_write_bytecodes_readably(cl_object x, cl_object stream, cl_object lex)
code_l,
x->bytecodes.data,
x->bytecodes.flex,
x->bytecodes.nlcl,
x->bytecodes.file,
x->bytecodes.file_position),
stream);

View file

@ -769,6 +769,10 @@ sharp_Y_reader(cl_object in, cl_object c, cl_object d)
x = ECL_CONS_CDR(x);
rv->bytecodes.flex = nth;
nth = ECL_CONS_CAR(x);
x = ECL_CONS_CDR(x);
rv->bytecodes.nlcl = nth;
if (ECL_ATOM(x)) {
nth = ECL_NIL;
} else {

View file

@ -770,6 +770,7 @@ struct ecl_bytecodes {
char *code; /* the intermediate language */
cl_object data; /* non-inmediate constants used in the code */
cl_object flex; /* indexes of captured objects (vector) */
cl_object nlcl; /* number of slots for local values */
cl_object file; /* file where it was defined... */
cl_object file_position;/* and where it was created */
};

View file

@ -314,7 +314,7 @@ extern ECL_API ecl_frame_ptr _ecl_frs_push(cl_env_ptr);
*******************
* Here we define how we handle the incoming arguments for a
* function. Our calling conventions specify that at most
* ECL_C_ARGUMENTS_LIMIT ar pushed onto the C stack. If the function
* ECL_C_ARGUMENTS_LIMIT are pushed onto the C stack. If the function
* receives more than this number of arguments it will keep a copy of
* _all_ those arguments _plus_ the remaining ones in the lisp
* stack. The caller is responsible for storing and removing such