diff options
author | Mark Shannon <mark@hotpy.org> | 2024-01-24 15:10:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-24 15:10:17 (GMT) |
commit | 981d172f7f0613d30bef4a8934b361db7fcf0672 (patch) | |
tree | bda610af879108b30ba43e39579900e35689543c /Python/optimizer.c | |
parent | 6fadd68da5dd928847264b17f62a5b8b369c1c1e (diff) | |
download | cpython-981d172f7f0613d30bef4a8934b361db7fcf0672.zip cpython-981d172f7f0613d30bef4a8934b361db7fcf0672.tar.gz cpython-981d172f7f0613d30bef4a8934b361db7fcf0672.tar.bz2 |
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.
Diffstat (limited to 'Python/optimizer.c')
-rw-r--r-- | Python/optimizer.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c index 4b6ed17..db61506 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -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: |