Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
markshannon merged 8 commits intopython:mainfromfaster-cpython:split-end-for
Jan 24, 2024

Conversation

@markshannon
Copy link
Member

@markshannonmarkshannon commentedJan 18, 2024
edited by bedevere-appbot
Loading

In order to support tier 2 side-exits fromFOR_ITER variants, we need a target that has the same stack as the exhaustion guard.
Currently we can either jump to theEND_FOR, as we do for generators or the instruction afterwards, which we do forFOR_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

@gvanrossum
Copy link
Member

gvanrossum commentedJan 18, 2024
edited
Loading

Maybe we can do without a separateEND_FOR opcode and instead just generate aPOP_TOP?

EDIT: Never mind, it's needed for instrumentation.

Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks good, never mind my premature commend about END_FOR/POP_TOP.

Comment on lines +672 to +674
string=&_Py_ID(alias);
assert(_PyUnicode_CheckConsistency(string,1));
_PyUnicode_InternInPlace(interp,&string);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

(The updates to this file (and a few other generated files) are spurious and will disappear after merging the latest main.)

@markshannon
Copy link
MemberAuthor

The benchmarks show no performance impact.

@markshannon
Copy link
MemberAuthor

EDIT: Never mind, it's needed for instrumentation.

That's evidently not clear. The order of thePOP_TOP andEND_FOR is important as well.
I'll add some comments.

Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks!

@brettcannonbrettcannon removed their request for reviewJanuary 19, 2024 18:31
@gvanrossum
Copy link
Member

Oh, fun stuff. Windows compilation error. :-(

@markshannonmarkshannon deleted the split-end-for branchFebruary 1, 2024 19:50
aisk pushed a commit to aisk/cpython that referenced this pull requestFeb 11, 2024
…GH-114247)* Compiler emits END_FOR; POP_TOP instead of END_FOR. To support tier 2 side exits in loops.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull requestSep 2, 2024
…GH-114247)* Compiler emits END_FOR; POP_TOP instead of END_FOR. To support tier 2 side exits in loops.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Eclips4Eclips4Eclips4 left review comments

@gvanrossumgvanrossumgvanrossum approved these changes

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

@ncoghlanncoghlanAwaiting requested review from ncoghlanncoghlan is a code owner

@warsawwarsawAwaiting requested review from warsawwarsaw is a code owner

@iritkatrieliritkatrielAwaiting requested review from iritkatrieliritkatriel is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@markshannon@gvanrossum@Eclips4

[8]ページ先頭

©2009-2025 Movatter.jp