Skip to content

Commit

Permalink
Allow flow control, but not loops
Browse files Browse the repository at this point in the history
We currently have so many other restrictions that we don't yet need
to do any other special things at the moment to handle non-loop flow
control.

Unfortunately, merge_bbs breaks the preds, so will need to be given
some repairs. For now, it's disabled.
  • Loading branch information
jnthn committed Oct 5, 2018
1 parent ccded64 commit 029da56
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/spesh/optimize.c
Expand Up @@ -3238,7 +3238,7 @@ void MVM_spesh_optimize(MVMThreadContext *tc, MVMSpeshGraph *g, MVMSpeshPlanned
MVM_spesh_usages_remove_unused_deopt(tc, g);
MVM_spesh_eliminate_dead_ins(tc, g);

merge_bbs(tc, g);
// merge_bbs(tc, g);

/* Make a post-inline pass through the graph doing things that are better
* done after inlinings have taken place. Note that these things must not
Expand Down
21 changes: 15 additions & 6 deletions src/spesh/pea.c
Expand Up @@ -199,13 +199,26 @@ static void real_object_required(MVMThreadContext *tc, MVMSpeshGraph *g, MVMSpes

static MVMuint32 analyze(MVMThreadContext *tc, MVMSpeshGraph *g, GraphState *gs) {
MVMSpeshBB **rpo = MVM_spesh_graph_reverse_postorder(tc, g);
MVMuint8 *seen = MVM_calloc(g->num_bbs, 1);
MVMuint32 found_replaceable = 0;
MVMuint32 ins_count = 0;
MVMuint32 latest_deopt_ins = 0;
MVMuint32 i;
for (i = 0; i < g->num_bbs; i++) {
MVMSpeshBB *bb = rpo[i];
MVMSpeshIns *ins = bb->first_ins;

/* For now, we don't handle loops; bail entirely if we see one. */
MVMuint32 j;
for (j = 0; j < bb->num_pred; j++) {
if (!seen[bb->pred[j]->rpo_idx]) {
pea_log("partial escape analysis not implemented for loops");
MVM_free(seen);
MVM_free(rpo);
return 0;
}
}

while (ins) {
MVMuint16 opcode = ins->info->opcode;

Expand Down Expand Up @@ -339,14 +352,10 @@ static MVMuint32 analyze(MVMThreadContext *tc, MVMSpeshGraph *g, GraphState *gs)
ins_count++;
}

/* For now, we only handle linear code with no flow control. */
if (bb->num_succ > 1) {
pea_log("replacement blocked by NYI num_succ > 1");
MVM_free(rpo);
return 0;
}
seen[bb->rpo_idx] = 1;
}
MVM_free(rpo);
MVM_free(seen);
return found_replaceable;
}

Expand Down

0 comments on commit 029da56

Please sign in to comment.