Skip to content

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

Merged
markshannon merged 8 commits into
python:mainfrom
faster-cpython:split-end-for
Jan 24, 2024
Merged

GH-112354: END_FOR instruction to only pop one value.#114247
markshannon merged 8 commits into
python:mainfrom
faster-cpython:split-end-for

Conversation

@markshannon

@markshannonmarkshannon commented Jan 18, 2024

Copy link
Copy Markdown
Member

In order to support tier 2 side-exits from FOR_ITER variants, we need a target that has the same stack as the exhaustion guard.
Currently we can either jump to the END_FOR, as we do for generators or the instruction afterwards, which we do for FOR_ITER.
In order to exit a guard we need a target in between those instructions, that pops the iterator, but not the value.
The compiler emits END_FOR; POP_TOP instead of END_FOR.
Previously:

 END_FOR (Pops two values) <- FOR_ITEN_GEN targets this
... <- FOR_ITER targets this

Now:

 END_FOR (Pops one value) <- FOR_ITEN_GEN targets this
POP_TOP (Pops one value) <- _GUARD_NOT_EXHAUSTED can target this
... <- FOR_ITER targets this

Loading
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@markshannon@gvanrossum@Eclips4