| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
📝 Walkthrough
WalkthroughRenamed the Pop opcode to PopTop across compiler-core, codegen, VM, and JIT so emitted bytecode and dispatch use PopTop while preserving previous pop semantics (remove top-of-stack). Changes
Sequence Diagram(s)sequenceDiagram
participant Codegen
participant Bytecode as Compiler-core
participant Runtime as VM/JIT
rect rgb(240,255,240)
Note over Codegen,Bytecode: Build-time phase
Codegen->>Bytecode: emit PopTop
end
rect rgb(240,240,255)
Note over Runtime: Runtime execution
Runtime->>Runtime: fetch PopTop
Runtime-->>Runtime: STACK.pop() (discard)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
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. ❤️ ShareComment @coderabbitai help to get the list of available commands and usage tips. |
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)crates/codegen/src/compile.rs (1)📜 Review details1104-1115: Guard the compile_block_expr assumption about trailing PopTop
compile_block_expr still unconditionally pops the last instruction, assuming it’s the PopTop emitted for a trailing Stmt::Expr. That was true before the rename, but it’s an implicit contract between compile_statement and compile_block_expr. Consider asserting the last instruction is Instruction::PopTop (or otherwise checking) before popping to make future refactors safer.
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📥 CommitsReviewing files that changed from the base of the PR and between 61ddd98 and 2e220f9.
⛔ Files ignored due to path filters (4)📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style by running cargo fmt to format Rust code
Always run clippy to lint Rust code (cargo clippy) before completing tasks and fix any warnings or lints introduced by changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass, pymodule, pyfunction, etc.) when implementing Python functionality in Rust
Files:
Learnt from: youknowone Repo: RustPython/RustPython PR: 6123 File: stdlib/src/contextvars.rs:128-134 Timestamp: 2025-09-03T13:15:23.436Z Learning: Vec::pop_if was stabilized in Rust 1.86.0 (released April 3, 2025) and is available in standard library for conditionally removing the last element from a vector based on a predicate.
Applied to files:
crates/vm/src/frame.rs (4)⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)crates/codegen/src/compile.rs (2)
- arg (2458-2459)
- func (2121-2122)
- name (1231-1231)
- name (2450-2450)
crates/codegen/src/ir.rs (1)
- name (897-899)
- varname (900-907)
crates/stdlib/src/re.rs (1)
- idx (45-47)
- end (378-385)
crates/vm/src/frame.rs (1)crates/codegen/src/compile.rs (2)1359-1363: LGTM! Clean alignment with CPython naming.
The PopTop instruction handler correctly pops and discards the top-of-stack value. The implementation is straightforward, the comment is clear, and the semantics are unchanged from the previous Pop variant.
crates/compiler-core/src/bytecode.rs (1)1055-1093: PopTop replaces Pop cleanly for simple TOS discards
The new Instruction::PopTop usages here (REPL printing, import-from module pop, statement expr results, with without as, non-simple annotated assigns, and generator comprehensions) are all straightforward “drop unused result” sites and remain stack-correct with stack_effect(PopTop) == -1. No functional change beyond the opcode rename.
Also applies to: 1403-1412, 2050-2061, 2927-2957, 4190-4198, 4810-4833
3136-3710: Pattern-matching and control-flow cleanup PopTop sites remain stack-safe
All pattern/exception-related uses of PopTop (pattern failure cleanups, wildcard/star captures, mapping/sequence/class patterns, Match default/fallthrough handling, and chained-comparison early-exit cleanup) correctly discard subjects or intermediate values that are no longer needed. The PatternContext.on_top accounting plus stack_effect(PopTop) = -1 stays consistent, so control-flow and stack behavior are preserved across the rename.
Also applies to: 3793-3819, 3887-3894, 4125-4131
588-607: PopTop opcode semantics and disassembly alignment look correct
- Instruction::PopTop is documented as a pure STACK.pop() and has stack_effect == -1, matching the old Pop behavior.
- The disassembler now prints POP_TOP (and other opcodes in CPython-style ALL_CAPS), which aligns RustPython’s dis output with CPython without changing runtime behavior.
- Enum ordering and LAST_INSTRUCTION = Instruction::YieldValue stay intact, so the numeric opcode for this slot is preserved; only the variant name and displayed opname changed. This is a public API rename for Instruction, but internally everything remains consistent.
Also applies to: 795-799, 1672-1797, 1867-1973
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)crates/jit/src/instructions.rs (1)📜 Review details580-583: LGTM! The opcode rename correctly aligns with CPython.
The PopTop instruction is properly implemented - it pops the top value from the stack and returns successfully, matching the expected semantics.
Consider adding stack underflow validation for consistency with other stack operations in this file (e.g., lines 279, 447, 555). Most other instructions that pop from the stack use .ok_or(JitCompileError::BadBytecode)? to detect empty stack conditions.
🔎 Optional defensive programming improvementInstruction::PopTop => { - self.stack.pop(); + self.stack.pop().ok_or(JitCompileError::BadBytecode)?; Ok(()) }
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📥 CommitsReviewing files that changed from the base of the PR and between 2e220f9 and e5abd45.
📒 Files selected for processing (1)📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style by running cargo fmt to format Rust code
Always run clippy to lint Rust code (cargo clippy) before completing tasks and fix any warnings or lints introduced by changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass, pymodule, pyfunction, etc.) when implementing Python functionality in Rust
Files:
Sorry, something went wrong.
|
|
||
| match self { | ||
| BeforeAsyncWith => w!(BeforeAsyncWith), | ||
| BeforeAsyncWith => w!(BEFORE_ASYNC_WITH), |
There was a problem hiding this comment.
Is there reason to change the convention?
Sorry, something went wrong.
There was a problem hiding this comment.
Yes. Some tests are checking for the presents/absent of certain opcodes by name like:
RustPython/Lib/test/test_compile.py
Lines 1073 to 1081 in 61ddd98
And pretty much all tests under test_dis.py (which we have a VERY outdated version of ATM), aligning the names of the opcodes just increases our test coverage
Sorry, something went wrong.
There was a problem hiding this comment.
👍
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Also renamed Instruction:: Pop -> Instruction::PopTop
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.