Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the generator frame-ownership changes.
No open issues 🎉
What changed in this PR
Addresses the generator portion of #2133 by making PythonGenerator manage its frame entry on the thread currently running the body. The .NET-async frame ownership issue remains outside this PR’s scope.
Changes:
- Transfer ownership of generator frame entries from compiled bodies to
PythonGenerator. - Remove entries on suspension or completion and restore them on the resuming thread.
- Add regression tests for cross-thread completion and tracing changes between resumptions.
| File | Description |
|---|---|
tests/suite/test_generator.py |
Tests cross-thread completion, frame preservation, and tracing transitions. |
src/core/IronPython/Runtime/Operations/PythonOps.cs |
Adds the generator frame handoff helper. |
src/core/IronPython/Runtime/Generator.cs |
Manages frame entries across suspension, resumption, and completion. |
src/core/IronPython/Compiler/Ast/Node.cs |
Adds generator-specific frame handling without a body-owned pop. |
src/core/IronPython/Compiler/Ast/FunctionDefinition.cs |
Selects generator-specific framing for bodies backed by PythonGenerator. |
src/core/IronPython/Compiler/Ast/AstMethods.cs |
Registers the new helper for generated calls. |
Review effort: Balanced
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the generator part of #2133:
The generator body pushes its entry once, through
PythonOps.PushGeneratorFrame, and hands it over to itsPythonGenerator.The generator removes the entry from the current thread at each suspension, adds it back at each resumption, and removes it when the body finishes.