Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-118095: Add tier 2 support for YIELD_VALUE #118380

Merged
merged 3 commits into from Apr 30, 2024

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Apr 29, 2024

This PR:

  • Makes a few changes to make YIELD_VALUE suitable for tier 2
  • Adds a few conditions to the tier 2 optimizer pipeline to support the new _YIELD_VALUE micro-op.
  • Adds a case for _FOR_ITER_GEN_FRAME to the tier 2 optimizer to get rid of a compiler warning. This isn't strictly necessary for this PR, but is just good housekeeping.

@markshannon
Copy link
Member Author

The stats show that this is working as intended. YIELD_VALUE disappears as an unsupported opcode for tier 2, and the number of trace "underflows" (unmatched return or yields) increases accordingly.

@markshannon markshannon marked this pull request as ready for review April 29, 2024 12:58
assert(frame != &entry_frame);
frame->instr_ptr = next_instr;
#endif
frame->instr_ptr++;
Copy link
Member

Choose a reason for hiding this comment

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

Would be good if the DSL had a symbol for "this instruction's size".

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

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

I don't understand the implications for tier2, but for tier1 this looks fine.

Copy link
Member

@Fidget-Spinner Fidget-Spinner left a comment

Choose a reason for hiding this comment

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

I don't understand the tier 1 changes that well, but the tier 2 changes LGTM.

@markshannon markshannon merged commit 5b05d45 into python:main Apr 30, 2024
54 checks passed
@markshannon markshannon deleted the tier-2-yield-value branch April 30, 2024 10:33
@@ -763,7 +763,7 @@ translate_bytecode_to_trace(
Py_FatalError("garbled expansion");
}

if (uop == _POP_FRAME || uop == _RETURN_GENERATOR) {
if (uop == _POP_FRAME || uop == _RETURN_GENERATOR || uop == _YIELD_VALUE) {
Copy link
Member

Choose a reason for hiding this comment

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

@markshannon Shouldn't this same change be made to optimizer_analysis.c (in get_code())?

@corona10
Copy link
Member

Adds a case for _FOR_ITER_GEN_FRAME to the tier 2 optimizer to get rid of a compiler warning. This isn't strictly necessary for this PR, but is just good housekeeping.

For your information, from gcc-14, since it enabled -Werror=incompatible-pointer-types by default, the code caused the build failure, but thanks to this PR, everything is okay now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants