Stop pointer parameters leaking value-pool slots
Create structure parameters before allocating their representation, then keep pointer references in the call variable's inline slot. Add an 8,000-call regression and document the remaining by-value structure escape limitation. Co-authored-by: andrew <andrew@aklabs.net> Co-authored-by: OpenAI Codex (GPT-5) <noreply@openai.com>
This commit is contained in:
@@ -306,7 +306,8 @@ akerr_ErrorContext *akbasic_environment_get(akbasic_Environment *obj, const char
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
akerr_ErrorContext *akbasic_environment_create(akbasic_Environment *obj, const char *varname, akbasic_Variable **dest)
|
||||
static akerr_ErrorContext *environment_create_named(akbasic_Environment *obj, const char *varname,
|
||||
akbasic_Variable **dest, bool initialize)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
akbasic_Variable *variable = NULL;
|
||||
@@ -340,12 +341,31 @@ akerr_ErrorContext *akbasic_environment_create(akbasic_Environment *obj, const c
|
||||
PASS(errctx, aksl_strcpy(variable->name, sizeof(variable->name), varname));
|
||||
variable->valuetype = AKBASIC_TYPE_UNDEFINED;
|
||||
variable->mutable_ = true;
|
||||
PASS(errctx, akbasic_variable_init(variable, &obj->runtime->valuepool, sizes, 1));
|
||||
if ( initialize ) {
|
||||
PASS(errctx, akbasic_variable_init(variable, &obj->runtime->valuepool, sizes, 1));
|
||||
}
|
||||
PASS(errctx, akbasic_symtab_set(&obj->variables, varname, variable, 0));
|
||||
*dest = variable;
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
akerr_ErrorContext *akbasic_environment_create(akbasic_Environment *obj, const char *varname, akbasic_Variable **dest)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
|
||||
PASS(errctx, environment_create_named(obj, varname, dest, true));
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
akerr_ErrorContext *akbasic_environment_create_empty(akbasic_Environment *obj, const char *varname,
|
||||
akbasic_Variable **dest)
|
||||
{
|
||||
PREPARE_ERROR(errctx);
|
||||
|
||||
PASS(errctx, environment_create_named(obj, varname, dest, false));
|
||||
SUCCEED_RETURN(errctx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Evaluate an lvalue's subscript list, if it has one, into `subscripts`. A bare
|
||||
* identifier yields the single subscript {0}, which is how a scalar is addressed
|
||||
|
||||
Reference in New Issue
Block a user