Skip to content

Commit 4f45776

Browse files
Apply suggestions
1 parent d9eb7a9 commit 4f45776

File tree

5 files changed

+7
-12
lines changed

5 files changed

+7
-12
lines changed

Include/internal/pycore_opcode_metadata.h

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

Python/bytecodes.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5384,10 +5384,6 @@ dummy_func(
53845384

53855385
tier2 op(_ERROR_POP_N, (target/2 --)) {
53865386
assert(oparg == 0);
5387-
_Py_CODEUNIT *current_instr = _PyFrame_GetBytecode(frame) + target;
5388-
_Py_CODEUNIT *next_instr = current_instr + 1 + _PyOpcode_Caches[_PyOpcode_Deopt[current_instr->op.code]];
5389-
// gh-140104: The exception handler expects frame->instr_ptr to be pointing to next_instr, not this_instr!
5390-
frame->instr_ptr = next_instr;
53915387
SYNC_SP();
53925388
GOTO_TIER_ONE(NULL);
53935389
}

Python/ceval_macros.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ do { \
358358
frame = tstate->current_frame; \
359359
stack_pointer = _PyFrame_GetStackPointer(frame); \
360360
if (next_instr == NULL) { \
361-
next_instr = frame->instr_ptr; \
361+
/* gh-140104: The exception handler expects frame->instr_ptr
362+
to be pointing to next_instr, not this_instr! */ \
363+
next_instr = frame->instr_ptr + 1 + _PyOpcode_Caches[_PyOpcode_Deopt[frame->instr_ptr->op.code]]; \
362364
JUMP_TO_LABEL(error); \
363365
} \
364366
DISPATCH(); \

Python/executor_cases.c.h

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

Tools/cases_generator/opcode_metadata_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def generate_instruction_formats(analysis: Analysis, out: CWriter) -> None:
147147

148148

149149
def generate_deopt_table(analysis: Analysis, out: CWriter) -> None:
150-
out.emit("PyAPI_DATA(const uint8_t) _PyOpcode_Deopt[256];\n")
150+
out.emit("extern const uint8_t _PyOpcode_Deopt[256];\n")
151151
out.emit("#ifdef NEED_OPCODE_METADATA\n")
152152
out.emit("const uint8_t _PyOpcode_Deopt[256] = {\n")
153153
deopts: list[tuple[str, str]] = []
@@ -170,7 +170,7 @@ def generate_deopt_table(analysis: Analysis, out: CWriter) -> None:
170170

171171

172172
def generate_cache_table(analysis: Analysis, out: CWriter) -> None:
173-
out.emit("PyAPI_DATA(const uint8_t) _PyOpcode_Caches[256];\n")
173+
out.emit("extern const uint8_t _PyOpcode_Caches[256];\n")
174174
out.emit("#ifdef NEED_OPCODE_METADATA\n")
175175
out.emit("const uint8_t _PyOpcode_Caches[256] = {\n")
176176
for inst in analysis.instructions.values():

0 commit comments

Comments
 (0)