GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Instruction::Resume by youknowone · Pull Request #5944 · RustPython/RustPython 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 an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
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>, },
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
compiler/codegen/src/compile.rs (10 hunks)compiler/core/src/bytecode.rs (4 hunks)vm/src/frame.rs (1 hunks)
**/*.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.rsLearnt 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
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 an error while loading. Please reload this page.
| bytecode::Instruction::Resume { arg: resume_arg } => { | ||
| // Resume execution after yield, await, or at function start | ||
| // In CPython, this checks instrumentation and eval breaker | ||
| // For now, we just check for signals/interrupts | ||
| let _resume_type = resume_arg.get(arg); | ||
|
|
||
| // Temporarily disable signal checking to debug the issue | ||
| // Check for interrupts if not resuming from yield_from | ||
| // if resume_type < bytecode::ResumeType::AfterYieldFrom as u32 { | ||
| // vm.check_signals()?; | ||
| // } | ||
| Ok(None) | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
Complete the Resume instruction implementation or document the temporary nature.
The current implementation is essentially a no-op with critical signal checking logic commented out. This could lead to missing important interrupt handling during resume operations.
Issues identified:
_resume_type is extracted but never usedConsider these approaches:
Option 1: Implement proper signal checking
bytecode::Instruction::Resume { arg: resume_arg } => {
// Resume execution after yield, await, or at function start
- // In CPython, this checks instrumentation and eval breaker
- // For now, we just check for signals/interrupts
- let _resume_type = resume_arg.get(arg);
+ let resume_type = resume_arg.get(arg);
- // Temporarily disable signal checking to debug the issue
- // Check for interrupts if not resuming from yield_from
- // if resume_type < bytecode::ResumeType::AfterYieldFrom as u32 {
- // vm.check_signals()?;
- // }
+ // Check for interrupts if not resuming from yield_from
+ if resume_type < bytecode::ResumeType::AfterYieldFrom as u32 {
+ vm.check_signals()?;
+ }
Ok(None)
}Option 2: Document the temporary nature
bytecode::Instruction::Resume { arg: resume_arg } => {
+ // TODO: Temporary no-op implementation while debugging signal issues
+ // This instruction should check for interrupts and handle instrumentation
// Resume execution after yield, await, or at function start
- // In CPython, this checks instrumentation and eval breaker
- // For now, we just check for signals/interrupts
let _resume_type = resume_arg.get(arg);
- // Temporarily disable signal checking to debug the issue
// Check for interrupts if not resuming from yield_from
// if resume_type < bytecode::ResumeType::AfterYieldFrom as u32 {
// vm.check_signals()?;
// }
Ok(None)
}What specific issue is being debugged that requires disabling signal checking? This context would help determine the appropriate approach.
🏁 Script executed:
#!/bin/bash # Search for ResumeType definition and usages rg "ResumeType" -n . # Search for check_signals method to see its typical usage rg "fn check_signals" -n . # Search for other occurrences of vm.check_signals to understand context rg "check_signals" -n vm
Length of output: 2053
Implement signal checking in the Resume handler or document its temporary no-op
The new Instruction::Resume arm in vm/src/frame.rs currently ignores its resume_type and has all interrupt checks commented out. This placeholder will silently skip important vm.check_signals() calls and leave an unused variable.
Issues to address:
_resume_type is never used.vm.check_signals()? logic is disabled.Please update one of the following:
• Option A – Restore proper signal checks:
vm/src/frame.rs @@ -896,13 +896,15 @@ impl Frame { bytecode::Instruction::Resume { arg: resume_arg } => { - let _resume_type = resume_arg.get(arg); + let resume_type = resume_arg.get(arg); - // Temporarily disable signal checking to debug the issue - // Check for interrupts if not resuming from yield_from - // if resume_type < bytecode::ResumeType::AfterYieldFrom as u32 { - // vm.check_signals()?; - // } + // Check for interrupts unless we’re resuming from a yield_from + if resume_type < bytecode::ResumeType::AfterYieldFrom as u32 { + vm.check_signals()?; + } Ok(None) }
• Option B – Clearly mark as temporary:
vm/src/frame.rs @@ -896,6 +896,10 @@ impl Frame { bytecode::Instruction::Resume { arg: resume_arg } => { + // TODO: temporary no-op while debugging signal issues. + // This handler must later: + // 1) perform instrumentation/eval breaker checks + // 2) re-enable vm.check_signals() let _resume_type = resume_arg.get(arg); Ok(None) }
Also, please clarify “what specific issue is being debugged” that required disabling check_signals(), and when you plan to restore full behavior.
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| bytecode::Instruction::Resume { arg: resume_arg } => { | |
| // Resume execution after yield, await, or at function start | |
| // In CPython, this checks instrumentation and eval breaker | |
| // For now, we just check for signals/interrupts | |
| let _resume_type = resume_arg.get(arg); | |
| // Temporarily disable signal checking to debug the issue | |
| // Check for interrupts if not resuming from yield_from | |
| // if resume_type < bytecode::ResumeType::AfterYieldFrom as u32 { | |
| // vm.check_signals()?; | |
| // } | |
| Ok(None) | |
| } | |
| bytecode::Instruction::Resume { arg: resume_arg } => { | |
| // Resume execution after yield, await, or at function start | |
| // In CPython, this checks instrumentation and eval breaker | |
| // For now, we just check for signals/interrupts | |
| let resume_type = resume_arg.get(arg); | |
| // Check for interrupts unless we’re resuming from a yield_from | |
| if resume_type < bytecode::ResumeType::AfterYieldFrom as u32 { | |
| vm.check_signals()?; | |
| } | |
| Ok(None) | |
| } |
In vm/src/frame.rs around lines 896 to 908, the Resume instruction handler
currently disables signal checking and leaves the resume_type variable unused,
which can cause missed interrupt handling and unclear code intent. To fix this,
either restore the vm.check_signals()? call with the appropriate condition on
resume_type to ensure signals are checked as intended, or if signal checking is
temporarily disabled for debugging, add a clear comment explaining the specific
issue being debugged, why check_signals() is disabled, and when full signal
checking will be restored. Also, remove the unused _resume_type variable if not
used or rename it to _ to avoid warnings.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
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.
Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro
compiler/codegen/src/snapshots/rustpython_codegen__compile__tests__nested_double_async_with.snap is excluded by !**/*.snapcompiler/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)
**/*.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
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.