Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rakudo RT#102994: Add flag indicating HLL init status on CodeRef (CodeRef edition) #806

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/6model/reprs/MVMCode.c
Expand Up @@ -69,6 +69,7 @@ static void gc_mark(MVMThreadContext *tc, MVMSTable *st, void *data, MVMGCWorkli
static void gc_free(MVMThreadContext *tc, MVMObject *obj) {
MVMCode *code_obj = (MVMCode *)obj;
MVM_free(code_obj->body.state_vars);
MVM_free(code_obj->body.state_vars_is_hll_init);
}

static const MVMStorageSpec storage_spec = {
Expand Down
1 change: 1 addition & 0 deletions src/6model/reprs/MVMCode.h
Expand Up @@ -6,6 +6,7 @@ struct MVMCodeBody {
MVMObject *code_object;
MVMString *name;
MVMRegister *state_vars;
MVMuint8 *state_vars_is_hll_init;
MVMuint16 is_static;
MVMuint16 is_compiler_stub;
};
Expand Down
8 changes: 5 additions & 3 deletions src/core/frame.c
Expand Up @@ -568,6 +568,7 @@ void MVM_frame_invoke(MVMThreadContext *tc, MVMStaticFrame *static_frame,
MVMRegister *env = static_frame->body.static_env;
MVMuint8 *flags = static_frame->body.static_env_flags;
MVMint64 numlex = static_frame->body.num_lexicals;
MVMCode *cref = (MVMCode *)frame->code_ref;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that frame is rooted below, and that looking this up from the frame every time makes sure that we always get the correct value. If it's lifted out, then it must be also MVMROOTed below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out. I had extracted that coderef because it seemed easier to read and write in it's shorter form, but didn't realize that side-effect at the time. I updated the branch to root that variable as well, but if you think it would be better put back as it was I can do so.

MVMRegister *state = NULL;
MVMint64 state_act = 0; /* 0 = none so far, 1 = first time, 2 = later */
MVMint64 i;
Expand All @@ -577,18 +578,19 @@ void MVM_frame_invoke(MVMThreadContext *tc, MVMStaticFrame *static_frame,
redo_state:
switch (state_act) {
case 0:
if (!frame->code_ref)
if (!cref)
MVM_exception_throw_adhoc(tc,
"Frame must have code-ref to have state variables");
state = ((MVMCode *)frame->code_ref)->body.state_vars;
state = cref->body.state_vars;
if (state) {
/* Already have state vars; pull them from this. */
state_act = 2;
}
else {
/* Allocate storage for state vars. */
state = (MVMRegister *)MVM_calloc(1, frame->static_info->body.env_size);
((MVMCode *)frame->code_ref)->body.state_vars = state;
cref->body.state_vars = state;
cref->body.state_vars_is_hll_init = (MVMuint8 *)MVM_calloc(1, numlex);
state_act = 1;

/* Note that this frame should run state init code. */
Expand Down