Skip to content

Commit fdc0081

Browse files
gh-91719: Reload opcode on unknown error so that C can optimize the dispatching in ceval.c (GH-94364) (#94453)
(cherry picked from commit ea39b77) Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
1 parent ecc8e77 commit fdc0081

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Reload ``opcode`` when raising ``unknown opcode error`` in the interpreter main loop,
2+
for C compilers to generate dispatching code independently.

Python/ceval.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5661,6 +5661,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
56615661
#else
56625662
EXTRA_CASES // From opcode.h, a 'case' for each unused opcode
56635663
#endif
5664+
/* Tell C compilers not to hold the opcode variable in the loop.
5665+
next_instr points the current instruction without TARGET(). */
5666+
opcode = _Py_OPCODE(*next_instr);
56645667
fprintf(stderr, "XXX lineno: %d, opcode: %d\n",
56655668
_PyInterpreterFrame_GetLine(frame), opcode);
56665669
_PyErr_SetString(tstate, PyExc_SystemError, "unknown opcode");

0 commit comments

Comments
 (0)