GH-112354: END_FOR instruction to only pop one value. (GH-114247)

* Compiler emits END_FOR; POP_TOP instead of END_FOR. To support tier 2 side exits in loops.
This commit is contained in:
Mark Shannon 2024-01-24 15:10:17 +00:00 committed by GitHub
parent 6fadd68da5
commit 981d172f7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 238 additions and 184 deletions

View file

@ -572,9 +572,10 @@ top: // Jump here after _PUSH_FRAME or likely branches
uop = _PyUOp_Replacements[uop];
assert(uop != 0);
if (uop == _FOR_ITER_TIER_TWO) {
target += 1 + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 1 + extended;
assert(_PyCode_CODE(code)[target-1].op.code == END_FOR ||
_PyCode_CODE(code)[target-1].op.code == INSTRUMENTED_END_FOR);
target += 1 + INLINE_CACHE_ENTRIES_FOR_ITER + oparg + 2 + extended;
assert(_PyCode_CODE(code)[target-2].op.code == END_FOR ||
_PyCode_CODE(code)[target-2].op.code == INSTRUMENTED_END_FOR);
assert(_PyCode_CODE(code)[target-1].op.code == POP_TOP);
}
break;
default: