Skip to content

Commit 6936a38

Browse files
Just punt on large opargs for now
1 parent 95eee89 commit 6936a38

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

Python/bytecodes.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5407,9 +5407,11 @@ dummy_func(
54075407
}
54085408

54095409
tier2 op(_ERROR_POP_N, (target/2 --)) {
5410-
assert(target != 0);
54115410
assert(oparg == 0);
5412-
frame->instr_ptr = _PyFrame_GetBytecode(frame) + target;
5411+
_Py_CODEUNIT *current_instr = _PyFrame_GetBytecode(frame) + target;
5412+
_Py_CODEUNIT *next_instr = current_instr + 1 + _PyOpcode_Caches[_PyOpcode_Deopt[current_instr->op.code]];
5413+
// gh-140104: The exception handler expects frame->instr_ptr to be pointing to next_instr, not this_instr!
5414+
frame->instr_ptr = next_instr;
54135415
SYNC_SP();
54145416
GOTO_TIER_ONE(NULL, 0);
54155417
}

Python/executor_cases.c.h

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/optimizer.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,10 @@ _PyJIT_translate_single_bytecode_to_trace(
585585

586586
DPRINTF(2, "%d: %s(%d)\n", target, _PyOpcode_OpName[opcode], oparg);
587587

588-
if ((uint16_t)oparg != (uint64_t)oparg) {
588+
// TODO support EXTENDED_ARG
589+
if (oparg > 255) {
589590
goto unsupported;
590591
}
591-
// One for possible _DEOPT, one because _CHECK_VALIDITY itself might _DEOPT
592-
max_length -= 2;
593592

594593
if (opcode == EXTENDED_ARG) {
595594
return 1;
@@ -606,6 +605,9 @@ _PyJIT_translate_single_bytecode_to_trace(
606605
return 1;
607606
}
608607

608+
// One for possible _DEOPT, one because _CHECK_VALIDITY itself might _DEOPT
609+
max_length -= 2;
610+
609611
if (opcode == ENTER_EXECUTOR) {
610612
ADD_TO_TRACE(_CHECK_VALIDITY, 0, 0, target);
611613
ADD_TO_TRACE(_SET_IP, 0, (uintptr_t)target_instr, target);

0 commit comments

Comments
 (0)