mirror of
https://github.com/python/cpython.git
synced 2025-08-24 18:55:00 +00:00
GH-117442: Check eval-breaker at start (rather than end) of tier 2 loops (GH-118482)
This commit is contained in:
parent
f8e088df2a
commit
67bba9dd0f
10 changed files with 137 additions and 174 deletions
16
Python/generated_cases.c.h
generated
16
Python/generated_cases.c.h
generated
|
@ -2493,19 +2493,21 @@
|
|||
next_instr += 1;
|
||||
INSTRUCTION_STATS(ENTER_EXECUTOR);
|
||||
#ifdef _Py_TIER2
|
||||
int prevoparg = oparg;
|
||||
CHECK_EVAL_BREAKER();
|
||||
if (this_instr->op.code != ENTER_EXECUTOR ||
|
||||
this_instr->op.arg != prevoparg) {
|
||||
next_instr = this_instr;
|
||||
DISPATCH();
|
||||
}
|
||||
PyCodeObject *code = _PyFrame_GetCode(frame);
|
||||
_PyExecutorObject *executor = code->co_executors->executors[oparg & 255];
|
||||
assert(executor->vm_data.index == INSTR_OFFSET() - 1);
|
||||
assert(executor->vm_data.code == code);
|
||||
assert(executor->vm_data.valid);
|
||||
assert(tstate->previous_executor == NULL);
|
||||
/* If the eval breaker is set then stay in tier 1.
|
||||
* This avoids any potentially infinite loops
|
||||
* involving _RESUME_CHECK */
|
||||
if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) {
|
||||
opcode = executor->vm_data.opcode;
|
||||
oparg = (oparg & ~255) | executor->vm_data.oparg;
|
||||
next_instr = this_instr;
|
||||
DISPATCH_GOTO();
|
||||
}
|
||||
tstate->previous_executor = Py_None;
|
||||
Py_INCREF(executor);
|
||||
GOTO_TIER_TWO(executor);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue