GeezerVison is showing github.com — LoadClosure as pseudo op by youknowone · Pull Request #6789 · RustPython/RustPython
Conversation
youknowone
commented
Jan 18, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary by CodeRabbit
- Refactor
- Optimized internal bytecode instruction handling for closure variable loading, improving the compiler's variable scope management and frame initialization during runtime.
✏️ Tip: You can customize this high-level summary in your review settings.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jan 18, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
📝 Walkthrough
Walkthrough
The PR migrates the LoadClosure opcode from the concrete Instruction enum to the PseudoInstruction enum, updating bytecode emission, IR lowering, decoding logic, instruction metadata, and VM frame execution paths to accommodate this structural change.
Changes
| Cohort / File(s) |
Summary |
Bytecode Definition and Conversion crates/compiler-core/src/bytecode/instruction.rs |
Moves LoadClosure(Arg<NameIdx>) from Instruction to PseudoInstruction (discriminant 268); updates TryFrom bounds and removes LoadClosure handling from Instruction paths; removes stack effects and formatting for LoadClosure from Instruction, adds stack effect of 1 to PseudoInstruction. |
Code Generation and IR Lowering crates/codegen/src/compile.rs, crates/codegen/src/ir.rs |
Updates closure variable emission to use PseudoInstruction::LoadClosure instead of Instruction::LoadClosure; adds IR lowering to convert PseudoInstruction::LoadClosure to LOAD_FAST with index adjusted by varnames count. |
Opcode Metadata crates/stdlib/src/opcode.rs |
Removes LoadClosure(_) from the has_free instruction pattern match, no longer treating it as a free-variable instruction. |
Frame Execution and Locals crates/vm/src/frame.rs |
Restructures frame locals initialization to combine varnames, cellvars, and freevars into a single fastlocals array with pre-filled cell objects; removes the Instruction::LoadClosure execution path from frame dispatch. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~22 minutes
Possibly related PRs
Suggested reviewers
Poem
🐰 A closure hops from Instruction's gate,
To Pseudo's burrow, a lighter fate!
Fastlocals swell with cells in place,
No more dispatch—just stack-bound grace.
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
⚠️ Warning |
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (2 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title accurately describes the main change: moving LoadClosure from a regular Instruction to a PseudoInstruction, which is the primary focus across all modified files. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment @coderabbitai help to get the list of available commands and usage tips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Code has been automatically formatted
The code in this PR has been formatted using:
python scripts/generate_opcode_metadata.py
Please pull the latest changes before pushing again:
git pull origin LoadClosure
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Jan 29, 2026
This was referenced Mar 2, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|