Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix existing bug in the PREDICT() macro for the codepath without comp…
…uted gotos
  • Loading branch information
pablogsal committed Sep 21, 2021
commit e1091e0e747a531364545c931b16bc6c3b28d0fc
11 changes: 5 additions & 6 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@ eval_frame_handle_pending(PyThreadState *tstate)
opcode = _Py_OPCODE(word); \
if (opcode == op) { \
oparg = _Py_OPARG(word); \
frame->f_lasti = INSTR_OFFSET(); \
next_instr++; \
goto PREDICT_ID(op); \
} \
Expand Down Expand Up @@ -1615,12 +1616,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
multiple values.

When the PREDICT() macros are enabled, some opcode pairs follow in
direct succession without updating frame->f_lasti. A successful
prediction effectively links the two codes together as if they
were a single new opcode; accordingly,frame->f_lasti will point to
the first code in the pair (for instance, GET_ITER followed by
FOR_ITER is effectively a single opcode and frame->f_lasti will point
to the beginning of the combined pair.)
direct succession. A successful prediction effectively links the two
codes together as if they were a single new opcode, but the value
of frame->f_lasti is correctly updated so potential inlined calls
or lookups of frame->f_lasti are aways correct when the macros are used.
*/
assert(frame->f_lasti >= -1);
_Py_CODEUNIT *next_instr = first_instr + frame->f_lasti + 1;
Expand Down