Instruction::Resume#5944
Conversation
WalkthroughThe changes introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant Compiler
participant Bytecode
participant VM
Compiler->>Bytecode: Emit function body
Compiler->>Bytecode: Emit Resume(AtFuncStart)
Compiler->>Bytecode: Emit YieldValue/YieldFrom/Await
Compiler->>Bytecode: Emit Resume(AfterYield/AfterYieldFrom/AfterAwait)
VM->>Bytecode: Fetch Instruction
alt Instruction is Resume
VM->>VM: (Currently no-op, signal check commented out)
end
Poem
✨ 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
compiler/core/src/bytecode.rs (2)
27-35: Consider implementing OpArgType for ResumeType for better type safety.The ResumeType enum is well-defined with appropriate variants and representation. However, to improve type safety and consistency with other instruction-specific enums, consider implementing OpArgType for ResumeType.
+impl OpArgType for ResumeType { + fn from_op_arg(x: u32) -> Option<Self> { + match x { + 0 => Some(Self::AtFuncStart), + 1 => Some(Self::AfterYield), + 2 => Some(Self::AfterYieldFrom), + 3 => Some(Self::AfterAwait), + _ => None, + } + } + fn to_op_arg(self) -> u32 { + self as u32 + } +}
577-581: Consider using Arg instead of Arg for better type safety.The Resume instruction is well-implemented, but using
Arg<u32>instead ofArg<ResumeType>reduces type safety and consistency with other instruction designs. This would require implementing OpArgType for ResumeType (see previous comment).Resume { - arg: Arg<u32>, + arg: Arg<ResumeType>, },
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
compiler/codegen/src/compile.rs(10 hunks)compiler/core/src/bytecode.rs(4 hunks)vm/src/frame.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.rs`: Follow the default rustfmt code style (`cargo fmt` to format) Always ...
**/*.rs: Follow the default rustfmt code style (cargo fmtto format)
Always run clippy to lint code (cargo clippy) before completing tasks. Fix any warnings or lints that are introduced by your 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
📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md)
List of files the instruction was applied to:
vm/src/frame.rscompiler/core/src/bytecode.rscompiler/codegen/src/compile.rs
🧠 Learnings (1)
compiler/core/src/bytecode.rs (1)
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T10:08:48.858Z
Learning: Applies to **/*.rs : Follow Rust best practices for error handling and memory management
⏰ 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). (11)
- GitHub Check: Run rust tests (macos-latest)
- GitHub Check: Run snippets and cpython tests on wasm-wasi
- GitHub Check: Run snippets and cpython tests (macos-latest)
- GitHub Check: Run snippets and cpython tests (windows-latest)
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Check the WASM package and demo
- GitHub Check: Run tests under miri
- GitHub Check: Check Rust code with rustfmt and clippy
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Ensure compilation on various targets
- GitHub Check: Run rust tests (windows-latest)
🔇 Additional comments (10)
compiler/core/src/bytecode.rs (2)
1344-1344: LGTM - Correct stack effect for Resume instruction.The stack effect of 0 is appropriate for the Resume instruction as it's a no-op operation that doesn't modify the stack.
1539-1539: LGTM - Consistent formatting implementation.The fmt_dis implementation for Resume follows the standard pattern and is consistent with other instructions.
compiler/codegen/src/compile.rs (8)
1531-1537: Correct placement of Resume instruction at function start.The Resume instruction is properly emitted at the function entry point after the None constant insertion.
3522-3527: Proper Resume instruction after yield expressions.The Resume instruction with
AfterYieldtype is correctly placed after the YieldValue instruction.
3537-3542: Correct Resume instruction after await expressions.The Resume instruction with
AfterAwaittype is properly emitted after the YieldFrom instruction in await expressions.
3559-3564: Appropriate Resume instruction for yield from expressions.The Resume instruction correctly uses
AfterYieldFromtype to distinguish yield from operations from await operations, even though both use the YieldFrom instruction.
1954-1959: Consistent Resume instructions in async with statements.Both the async with enter and cleanup sections correctly emit Resume instructions with
AfterAwaittype after their respective YieldFrom operations.Also applies to: 2001-2006
2045-2050: Proper Resume instruction in async for loops.The Resume instruction with
AfterAwaittype is correctly emitted after the YieldFrom operation in async iteration.
1691-1696: Correct Resume instruction in generator expressions.The Resume instruction with
AfterYieldtype is properly placed after the YieldValue instruction in generator expressions.
4092-4097: Consistent Resume instructions in async comprehensions.Resume instructions with
AfterAwaittype are correctly emitted after YieldFrom operations in both async generator comprehensions and async list/set/dict comprehensions.Also applies to: 4176-4181
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
jit/src/instructions.rs (1)
615-618: Placeholder implementation is appropriate for current development phase.The TODO comment clearly indicates the pending work for implementing the Resume instruction. This placeholder approach allows the JIT compiler to recognize the instruction while core functionality is developed elsewhere first.
Would you like me to help implement the Resume instruction functionality for the JIT compiler? I can generate a solution that handles the different resume types (
AtFuncStart,AfterYield,AfterYieldFrom,AfterAwait) mentioned in the broader codebase changes.
📜 Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
compiler/codegen/src/snapshots/rustpython_codegen__compile__tests__nested_double_async_with.snapis excluded by!**/*.snap
📒 Files selected for processing (4)
compiler/codegen/src/compile.rs(11 hunks)compiler/core/src/bytecode.rs(5 hunks)jit/src/instructions.rs(1 hunks)vm/src/frame.rs(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- vm/src/frame.rs
- compiler/core/src/bytecode.rs
- compiler/codegen/src/compile.rs
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.rs`: Follow the default rustfmt code style (`cargo fmt` to format) Always ...
**/*.rs: Follow the default rustfmt code style (cargo fmtto format)
Always run clippy to lint code (cargo clippy) before completing tasks. Fix any warnings or lints that are introduced by your 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
📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md)
List of files the instruction was applied to:
jit/src/instructions.rs
⏰ 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). (11)
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Check Rust code with rustfmt and clippy
- GitHub Check: Run snippets and cpython tests on wasm-wasi
- GitHub Check: Run snippets and cpython tests (macos-latest)
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Run snippets and cpython tests (windows-latest)
- GitHub Check: Run tests under miri
- GitHub Check: Check the WASM package and demo
- GitHub Check: Ensure compilation on various targets
- GitHub Check: Run rust tests (windows-latest)
- GitHub Check: Run rust tests (macos-latest)
Sorry, something went wrong.
392f9c2
into
RustPython:main
Jul 11, 2025
Summary by CodeRabbit
New Features
Bug Fixes
Chores