Bytecode instrumented placeholder#6741
Conversation
📝 WalkthroughWalkthroughExpanded the Instruction enum with 70+ specialized and instrumented RustPython-only opcodes ranging from 149–254, including Resume, BinaryOp variants, LoadAttr variants, Call variants, and instrumented operations. Moved SetExcInfo/Subscript to positions 132/133 and LoadClosure to 255. Updated TryFrom converter and InstructionMetadata to handle new opcode ranges. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ 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. Comment |
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@crates/compiler-core/src/bytecode/instruction.rs`:
- Around line 280-374: Instrumented jump opcodes (InstrumentedJumpForward,
InstrumentedJumpBackward, InstrumentedPopJumpIfTrue, InstrumentedPopJumpIfFalse,
InstrumentedPopJumpIfNone, InstrumentedPopJumpIfNotNone) are currently no-arg
placeholders but should either be real control-flow ops or explicit no-op
instrumentation; update them accordingly: if they represent instrumented
control-flow, change their variants to carry Arg<Label>, update their
stack_effects, and add them to label_arg() and
unconditional_branch()/conditional-branch logic so control-flow analysis
recognizes their targets (refer to these enum variants and the functions
label_arg() and unconditional_branch()); if they are only markers, leave them
no-arg but document that intent and add explicit comments/tests and ensure they
are never used in control-flow analysis (e.g., assert they are ignored) so
behavior is clear and consistent across the codebase.
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
Lib/_opcode_metadata.pyis excluded by!Lib/**Lib/test/test__opcode.pyis excluded by!Lib/**
📒 Files selected for processing (1)
crates/compiler-core/src/bytecode/instruction.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style usingcargo fmtto format Rust code
Always run clippy to lint 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:
crates/compiler-core/src/bytecode/instruction.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 (macos-latest)
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Run rust tests (macos-latest)
- GitHub Check: Ensure compilation on various targets
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Run rust tests (windows-2025)
- GitHub Check: Run snippets and cpython tests (windows-2025)
- GitHub Check: Run tests under miri
- GitHub Check: Check Rust code with clippy
- GitHub Check: Run snippets and cpython tests on wasm-wasi
- GitHub Check: Check the WASM package and demo
🔇 Additional comments (3)
crates/compiler-core/src/bytecode/instruction.rs (3)
248-279: Custom-opcode range update looks consistent.Thanks for tightening the RustPython-only block and moving
SetExcInfo/Subscript; the enum layout now cleanly documents the custom range.
401-448: Validator range updates look good.The specialized/instrumented ranges are now explicitly accepted, which keeps
TryFrom<u8>aligned with the expanded opcode space.
693-784: These are CPython 3.13 bytecode compatibility placeholders that are never emitted.All the opcodes marked as "Placeholder" (BinaryOpAddFloat, CallBuiltinFast, LoadGlobalBuiltin, InstrumentedJumpForward, etc.) are included in the instruction enum to support deserializing CPython 3.13 bytecode, but they are never actually generated by the RustPython compiler itself. The stack effect of
0for these opcodes is correct since they will never execute—the actual bytecode generation always uses the primary (non-specialized) instruction variants. No stack-depth analysis issues will occur because the code paths that emit bytecode never produce these placeholder instructions.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Sorry, something went wrong.
youknowone
left a comment
There was a problem hiding this comment.
is the newly introduced ops all the pseudo ops?
Sorry, something went wrong.
None are. All are either specialized or instrumented opcodes |
Sorry, something went wrong.
|
Thanks! I didn't know about them. |
Sorry, something went wrong.
380fa39
into
RustPython:main
Jan 16, 2026
Summary by CodeRabbit
New Features
Refactor
✏️ Tip: You can customize this high-level summary in your review settings.