Skip to content

Commit

Permalink
Don't duplicately set up fake temps
Browse files Browse the repository at this point in the history
We allow resume init values from one resumption to be used in the next
one. This works out because while we only keep info around about the
resumption we are currently handling, the resume init arg will have been
loaded into a temporary at the right time, and then the dispatch program
can later reference that temporary. When we are producing a dispatch
program recording, we didn't really run the resulting dispatch program,
so fake up the temporaries. We erroneously did this for every mention of
the resume init arg, however, meaning we could overwrite the correct
value already stored with a bogus one later. Fix it by making sure we
only ever accept the first value for a given fake temporary.
  • Loading branch information
jnthn committed Oct 15, 2021
1 parent 24fd304 commit 61600a3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/disp/program.c
Expand Up @@ -2346,6 +2346,16 @@ static void emit_args_ops(MVMThreadContext *tc, MVMCallStackDispatchRecord *reco
static void add_resume_init_temp_to_fake(MVMThreadContext *tc, compile_state *cs,
MVMDispProgramRecordingResumption *rec_res, MVMuint32 temp_idx,
MVMuint32 init_arg_idx) {
/* Make sure we didn't already add the argument to fake; it's possible we
* will end up overwriting it with the wrong value (because it could have
* previously been set from a resumption other than the one we are now
* in). */
MVMuint32 i;
for (i = 0; i < MVM_VECTOR_ELEMS(cs->fake_temps); i++)
if (cs->fake_temps[i].temp_idx == temp_idx)
return;

/* Not found, so add it. */
MVMRegister value;
MVMCallsiteFlags unused;
MVM_capture_arg_by_flag_index(tc, rec_res->initial_resume_capture.capture, init_arg_idx,
Expand Down

0 comments on commit 61600a3

Please sign in to comment.