Skip to content

Commit

Permalink
Make sure output of spesh resolve gets optimized, too
Browse files Browse the repository at this point in the history
Until now we'd have resumed optimization after the last
instruction a speshresolve has put in. This misses the
opportunity to improve getattr faux-guards into direct
pointer access versions.

Fix this by remembering the previous instruction before
speshresolve is optimized and continuing with that
instruction. The next thing in the loop is to go to
ins->next, so we use prev->prev.
  • Loading branch information
timo committed Jul 23, 2018
1 parent ba906c4 commit 33d6c9c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/spesh/optimize.c
Expand Up @@ -2319,8 +2319,19 @@ static void optimize_bb_switch(MVMThreadContext *tc, MVMSpeshGraph *g, MVMSpeshB
optimize_call(tc, g, bb, ins, p, 1, &arg_info);
break;
case MVM_OP_speshresolve:
if (p)
if (p) {
/* Rewriting spesh plugins will insert a bunch of instructions
* in front of the generated code, which would be skipped by
* our loop, so we remember the previous instruction and see
* to it that we run across the new instructions, too. */
MVMSpeshIns *prev = ins->prev;
optimize_plugin(tc, g, bb, ins, p);
if (ins->info->opcode != MVM_OP_speshresolve
&& ins->info->opcode != MVM_OP_sp_speshresolve) {
if (prev->prev)
ins = prev->prev;
}
}
break;
case MVM_OP_islist:
case MVM_OP_ishash:
Expand Down

0 comments on commit 33d6c9c

Please sign in to comment.