Skip to content

Commit 396818b

Browse files
Fix unsupported opcode bug, turn off optimizer again
1 parent 96b7bb2 commit 396818b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Python/optimizer.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,8 @@ _PyJIT_translate_single_bytecode_to_trace(
617617
const struct opcode_macro_expansion *expansion = &_PyOpcode_macro_expansion[opcode];
618618

619619
// Strange control-flow, unsupported opcode, etc.
620-
if (jump_taken || expansion->nuops == 0 || opcode == WITH_EXCEPT_START || opcode == RERAISE || opcode == CLEANUP_THROW || opcode == PUSH_EXC_INFO) {
620+
if (jump_taken || opcode == WITH_EXCEPT_START || opcode == RERAISE || opcode == CLEANUP_THROW || opcode == PUSH_EXC_INFO) {
621+
unsupported:
621622
// Rewind to previous instruction and replace with _EXIT_TRACE.
622623
_PyUOpInstruction *curr = &trace[trace_length-1];
623624
while (curr->opcode != _SET_IP && trace_length > 1) {
@@ -698,6 +699,10 @@ _PyJIT_translate_single_bytecode_to_trace(
698699
const struct opcode_macro_expansion *expansion = &_PyOpcode_macro_expansion[opcode];
699700
// Reserve space for nuops (+ _SET_IP + _EXIT_TRACE)
700701
int nuops = expansion->nuops;
702+
if (nuops == 0) {
703+
DPRINTF(2, "Unsupported opcode %s\n", _PyOpcode_OpName[opcode]);
704+
goto unsupported;
705+
}
701706
assert(nuops > 0);
702707
RESERVE(nuops + 1); /* One extra for exit */
703708
uint32_t orig_oparg = oparg; // For OPARG_TOP/BOTTOM
@@ -1169,7 +1174,7 @@ uop_optimize(
11691174
int curr_stackentries = tstate->interp->jit_tracer_initial_stack_depth;
11701175
int length = interp->jit_tracer_code_curr_size;
11711176
// Trace too short, don't bother.
1172-
if (length <= 8) {
1177+
if (length <= 4) {
11731178
return 0;
11741179
}
11751180
assert(length > 0);

0 commit comments

Comments
 (0)