Skip to content

Commit

Permalink
Internals renamings regarding state -> resume init
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Sep 24, 2020
1 parent bab515a commit f771916
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
32 changes: 16 additions & 16 deletions src/disp/program.c
Expand Up @@ -30,10 +30,10 @@ static void dump_recording_capture(MVMThreadContext *tc,
if (capture->capture == rec->outcome_capture)
fprintf(stderr, "%s Used as args for invoke result\n", indent_str);
MVMuint32 i;
for (i = 0; i < MVM_VECTOR_ELEMS(rec->states); i++) {
if (rec->states[i].capture == capture->capture) {
char *disp_id = MVM_string_utf8_encode_C_string(tc, rec->states[i].disp->id);
fprintf(stderr, "%s Used as dispatch state for %s\n", indent_str, disp_id);
for (i = 0; i < MVM_VECTOR_ELEMS(rec->resume_inits); i++) {
if (rec->resume_inits[i].capture == capture->capture) {
char *disp_id = MVM_string_utf8_encode_C_string(tc, rec->resume_inits[i].disp->id);
fprintf(stderr, "%s Used as resume init args for %s\n", indent_str, disp_id);
MVM_free(disp_id);
}
}
Expand Down Expand Up @@ -362,7 +362,7 @@ void MVM_disp_program_run_dispatch(MVMThreadContext *tc, MVMDispDefinition *disp
record->rec.initial_capture.transformation = MVMDispProgramRecordingInitial;
MVM_VECTOR_INIT(record->rec.initial_capture.captures, 8);
MVM_VECTOR_INIT(record->rec.values, 16);
MVM_VECTOR_INIT(record->rec.states, 4);
MVM_VECTOR_INIT(record->rec.resume_inits, 4);
record->rec.outcome_capture = NULL;
record->ic_entry_ptr = ic_entry_ptr;
record->ic_entry = ic_entry;
Expand Down Expand Up @@ -761,16 +761,16 @@ void MVM_disp_program_record_set_resume_init_args(MVMThreadContext *tc, MVMObjec
"Can only use dispatcher-set-resume-init-args in a resumable dispatcher");
ensure_known_capture(tc, record, capture);

/* Record the saving of the dispatch state for this dispatcher, making
* sure we didn't already save state for it. */
/* Record the saving of the resume init state for this dispatcher, making
* sure we didn't already do so. */
MVMuint32 i;
for (i = 0; i < MVM_VECTOR_ELEMS(record->rec.states); i++)
if (record->rec.states[i].disp == record->current_disp)
for (i = 0; i < MVM_VECTOR_ELEMS(record->rec.resume_inits); i++)
if (record->rec.resume_inits[i].disp == record->current_disp)
MVM_exception_throw_adhoc(tc, "Already set resume init args for this dispatcher");
MVMDispProgramRecordingState new_state;
new_state.disp = record->current_disp;
new_state.capture = capture;
MVM_VECTOR_PUSH(record->rec.states, new_state);
MVMDispProgramRecordingResumeInit new_resume_init;
new_resume_init.disp = record->current_disp;
new_resume_init.capture = capture;
MVM_VECTOR_PUSH(record->rec.resume_inits, new_resume_init);
}

/* Record the getting of the dispatch rsume init args. */
Expand Down Expand Up @@ -1779,8 +1779,8 @@ void MVM_disp_program_mark_recording(MVMThreadContext *tc, MVMDispProgramRecordi
MVM_gc_worklist_add(tc, worklist, &(value->not_literal_guards[i]));
}
mark_recording_capture(tc, &(rec->initial_capture), worklist);
for (i = 0; i < MVM_VECTOR_ELEMS(rec->states); i++) {
MVM_gc_worklist_add(tc, worklist, &(rec->states[i].capture));
for (i = 0; i < MVM_VECTOR_ELEMS(rec->resume_inits); i++) {
MVM_gc_worklist_add(tc, worklist, &(rec->resume_inits[i].capture));
}
MVM_gc_worklist_add(tc, worklist, &(rec->outcome_capture));
}
Expand Down Expand Up @@ -1838,6 +1838,6 @@ void MVM_disp_program_recording_destroy(MVMThreadContext *tc, MVMDispProgramReco
for (i = 0; i < MVM_VECTOR_ELEMS(rec->values); i++)
MVM_VECTOR_DESTROY(rec->values[i].not_literal_guards);
MVM_VECTOR_DESTROY(rec->values);
MVM_VECTOR_DESTROY(rec->states);
MVM_VECTOR_DESTROY(rec->resume_inits);
destroy_recording_capture(tc, &(rec->initial_capture));
}
12 changes: 6 additions & 6 deletions src/disp/program.h
Expand Up @@ -150,10 +150,10 @@ struct MVMDispProgramRecordingCapture {
MVM_VECTOR_DECL(MVMDispProgramRecordingCapture, captures);
};

/* Dispatch state saved during this recording, keyed on the dispatch
* definition. */
struct MVMDispProgramRecordingState {
/* The dispatcher that saved state. */
/* Resume initialization arguments. */
struct MVMDispProgramRecordingResumeInit {
/* The resumable dispatcher that, upon resumption, wants these args to
* figure out how to resume. */
MVMDispDefinition *disp;

/* The capture (which must appear in the capture tree). */
Expand All @@ -170,8 +170,8 @@ struct MVMDispProgramRecording {
* guards against. */
MVM_VECTOR_DECL(MVMDispProgramRecordingValue, values);

/* Any dispatcher state that we have saved. */
MVM_VECTOR_DECL(MVMDispProgramRecordingState, states);
/* Any resume init args that we have saved. */
MVM_VECTOR_DECL(MVMDispProgramRecordingResumeInit, resume_inits);

/* The index of the value that is the outcome of the dispatch. For a value
* outcome, it's the value we'll produce. For the invocations, it's the
Expand Down
2 changes: 1 addition & 1 deletion src/types.h
Expand Up @@ -320,7 +320,7 @@ typedef struct MVMDispProgramOutcome MVMDispProgramOutcome;
typedef struct MVMDispProgramRecording MVMDispProgramRecording;
typedef struct MVMDispProgramRecordingValue MVMDispProgramRecordingValue;
typedef struct MVMDispProgramRecordingCapture MVMDispProgramRecordingCapture;
typedef struct MVMDispProgramRecordingState MVMDispProgramRecordingState;
typedef struct MVMDispProgramRecordingResumeInit MVMDispProgramRecordingResumeInit;
typedef struct MVMDispProgram MVMDispProgram;
typedef union MVMDispProgramConstant MVMDispProgramConstant;
typedef struct MVMDispProgramOp MVMDispProgramOp;
Expand Down

0 comments on commit f771916

Please sign in to comment.