FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-128563: Move labels in ceval.c to bytecodes.c by Fidget-Spinner · Pull Request #129112 · python/cpython · GitHub

/ cpython Public

gh-128563: Move labels in ceval.c to bytecodes.c - #129112

Merged
Fidget-Spinner merged 15 commits into
python:mainfrom
Fidget-Spinner:labels-in-dsl
Jan 27, 2025
Merged

gh-128563: Move labels in ceval.c to bytecodes.c#129112
Fidget-Spinner merged 15 commits into
python:mainfrom
Fidget-Spinner:labels-in-dsl

Conversation

Fidget-Spinner commented Jan 21, 2025
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

markshannon commented Jan 21, 2025
edited
Loading

Copy link
Copy Markdown
Member

I don't think adding another code generator is the way to go.
The code in labels is part of the interpreter, so they should be handled similarly to instructions.

For code in labels we will, in the future, want to:

  • Spill the stack around escaping calls
  • Use the same dispatching mechanism as for instructions
  • Potentially access stack variables without cumbersome explicit pops and pushes.

I'm not suggesting that we do any of the above in this PR. The simple code you generate is fine for now, but it needs to be a bit more closely integrated into the interpreter/JIT generators.

Since labels exist outside the dispatch loop, we'll need to generate the dispatch loop as well. We can simply copy the few lines of code surrounding #include "generated_cases.c.h" into the tier1 code generator.

The tier 1 code generator would then generate:

  • The dispatch preamble (from /* Start instructions */ onwards)
  • The cases
  • The dispatch loop end including EXTRA_CASES up to Py_UNREACHABLE();
  • All the labels

Fidget-Spinner commented Jan 21, 2025
edited
Loading

Copy link
Copy Markdown
Member Author

Alright. I've moved the labels generator back into the tier 1 generator. We need to port over tier 2 in a separate PR as well.

I've combined the switch-case generator into the cases generator as well.

markshannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Mostly looks good. One thing doesn't look right

markshannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Adding the markers to the generated code for testing looks good, but the parsing in the test is a bit cumbersome.

Comment thread Lib/test/test_generated_cases.py Outdated
lines.pop(0)
while lines and lines[-1].startswith(("#", "\n")):
lines.pop(-1)
while lines and tier1_generator.INSTRUCTION_START_MARKER not in lines[0]:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You can replace this line by line processing, including the start and end comment stripping, by splitting the whole file on INSTRUCTION_START_MARKER and INSTRUCTION_START_MARKER, discarding the first and last parts.

text = temp_output.read()
_, rest = text.split(INSTRUCTION_START_MARKER)
actual, _ = rest.split(LABEL_START_MARKER)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Good observation. Thanks!

bedevere-app Bot commented Jan 24, 2025

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Fidget-Spinner added a commit to Fidget-Spinner/cpython that referenced this pull request Jan 25, 2025
markshannon self-requested a review January 27, 2025 10:25

markshannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks for doing this.

Fidget-Spinner merged commit 87fb8b1 into python:main Jan 27, 2025
colesbury added a commit to colesbury/cpython that referenced this pull request Jan 29, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

2 participants


Back | FazBrowse Home | New Git URL