Skip to content

Commit 3ed8850

Browse files
committed
Include final _EXIT_TRACE, but not trailing instructions
1 parent 61a0404 commit 3ed8850

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Python/optimizer.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,9 +1750,8 @@ dump_executor(_PyExecutorObject *executor, FILE *out)
17501750
else {
17511751
fprintf(out, " <tr><td border=\"1\" >");
17521752
write_str(code->co_qualname, out);
1753-
fprintf(out, "</td></tr>\n");
17541753
int line = find_line_number(code, executor);
1755-
fprintf(out, " <tr><td border=\"1\" >line: %d</td></tr>\n", line);
1754+
fprintf(out, ": %d</td></tr>\n", line);
17561755
}
17571756
for (uint32_t i = 0; i < executor->code_size; i++) {
17581757
_PyUOpInstruction const *inst = &executor->trace[i];
@@ -1762,20 +1761,30 @@ dump_executor(_PyExecutorObject *executor, FILE *out)
17621761
#else
17631762
fprintf(out, " <tr><td port=\"i%d\" border=\"1\" >%s</td></tr>\n", i, opname);
17641763
#endif
1764+
if (inst->opcode == _EXIT_TRACE || inst->opcode == _JUMP_TO_TOP) {
1765+
break;
1766+
}
17651767
}
17661768
fprintf(out, " label = </table>>\n");
17671769
fprintf(out, "]\n\n");
17681770
for (uint32_t i = 0; i < executor->code_size; i++) {
17691771
_PyUOpInstruction const *inst = &executor->trace[i];
17701772
uint16_t flags = _PyUop_Flags[inst->opcode];
1771-
if (flags & HAS_EXIT_FLAG) {
1773+
_PyExitData *exit = NULL;
1774+
if (inst->opcode == _EXIT_TRACE) {
1775+
exit = (_PyExitData *)inst->operand0;
1776+
}
1777+
else if (flags & HAS_EXIT_FLAG) {
17721778
assert(inst->format == UOP_FORMAT_JUMP);
17731779
_PyUOpInstruction const *exit_inst = &executor->trace[inst->jump_target];
17741780
assert(exit_inst->opcode == _EXIT_TRACE);
1775-
_PyExitData *exit = (_PyExitData *)exit_inst->operand0;
1776-
if (exit->executor != NULL) {
1777-
fprintf(out, "executor_%p:i%d -> executor_%p:start\n", executor, i, exit->executor);
1778-
}
1781+
exit = (_PyExitData *)exit_inst->operand0;
1782+
}
1783+
if (exit != NULL && exit->executor != NULL) {
1784+
fprintf(out, "executor_%p:i%d -> executor_%p:start\n", executor, i, exit->executor);
1785+
}
1786+
if (inst->opcode == _EXIT_TRACE || inst->opcode == _JUMP_TO_TOP) {
1787+
break;
17791788
}
17801789
}
17811790
}

0 commit comments

Comments
 (0)