Bytecode instrumented placeholder by ShaharNaveh · Pull Request #6741 · RustPython/RustPython
Repository navigation
Bytecode instrumented placeholder - #6741
Merged
youknowone merged 2 commits into RustPython:main from ShaharNaveh:bytecode-instrumented-placeholder Jan 16, 2026
Merged
Bytecode instrumented placeholder #6741 youknowone merged 2 commits into RustPython:main from ShaharNaveh:bytecode-instrumented-placeholder
Conversation
ShaharNaveh
commented
Jan 16, 2026
·
edited by coderabbitai
Bot
Loading
Copy link Copy Markdown
Contributor
Summary by CodeRabbit
-
New Features
- Expanded bytecode instruction set with specialized and instrumented opcodes to support enhanced code execution capabilities.
-
Refactor
- Updated instruction encoding, validation logic, and metadata implementation to accommodate expanded opcode set.
- Adjusted instruction discriminant values for improved alignment.
✏️ Tip: You can customize this high-level summary in your review settings.
ShaharNaveh added 2 commits January 16, 2026 11:21
Add all other bytecodes
6d33988
Mark passing/failing tests
79df18b
coderabbitai
Bot
commented
Jan 16, 2026
·
edited
Loading
Copy link Copy Markdown
Contributor
📝 Walkthrough
WalkthroughExpanded 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)
✏️ 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. ❤️ ShareComment |
View reviewed changes
Comment thread crates/compiler-core/src/bytecode/instruction.rs
| SetExcInfo = 134, | ||
| Subscript = 135, | ||
| SetExcInfo = 132, | ||
| Subscript = 133, |
Bot
reviewed Jan 16, 2026
View reviewed changes
coderabbitai
Bot
left a comment
Copy link Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Actionable comments posted: 1
🤖 Fix all issues with AI agentsIn `@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
📥 CommitsReviewing files that changed from the base of the PR and between 746e71a and 79df18b .
⛔ Files ignored due to path filters (2)Lib/_opcode_metadata.pyis excluded by!Lib/**Lib/test/test__opcode.pyis excluded by!Lib/**
crates/compiler-core/src/bytecode/instruction.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
- 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
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.
| Resume { | ||
| arg: Arg<u32>, | ||
| } = 149, | ||
| BinaryOpAddFloat = 150, // Placeholder | ||
| BinaryOpAddInt = 151, // Placeholder | ||
| BinaryOpAddUnicode = 152, // Placeholder | ||
| BinaryOpMultiplyFloat = 153, // Placeholder | ||
| BinaryOpMultiplyInt = 154, // Placeholder | ||
| BinaryOpSubtractFloat = 155, // Placeholder | ||
| BinaryOpSubtractInt = 156, // Placeholder | ||
| BinarySubscrDict = 157, // Placeholder | ||
| BinarySubscrGetitem = 158, // Placeholder | ||
| BinarySubscrListInt = 159, // Placeholder | ||
| BinarySubscrStrInt = 160, // Placeholder | ||
| BinarySubscrTupleInt = 161, // Placeholder | ||
| CallAllocAndEnterInit = 162, // Placeholder | ||
| CallBoundMethodExactArgs = 163, // Placeholder | ||
| CallBoundMethodGeneral = 164, // Placeholder | ||
| CallBuiltinClass = 165, // Placeholder | ||
| CallBuiltinFast = 166, // Placeholder | ||
| CallBuiltinFastWithKeywords = 167, // Placeholder | ||
| CallBuiltinO = 168, // Placeholder | ||
| CallIsinstance = 169, // Placeholder | ||
| CallLen = 170, // Placeholder | ||
| CallListAppend = 171, // Placeholder | ||
| CallMethodDescriptorFast = 172, // Placeholder | ||
| CallMethodDescriptorFastWithKeywords = 173, // Placeholder | ||
| CallMethodDescriptorNoargs = 174, // Placeholder | ||
| CallMethodDescriptorO = 175, // Placeholder | ||
| CallNonPyGeneral = 176, // Placeholder | ||
| CallPyExactArgs = 177, // Placeholder | ||
| CallPyGeneral = 178, // Placeholder | ||
| CallStr1 = 179, // Placeholder | ||
| CallTuple1 = 180, // Placeholder | ||
| CallType1 = 181, // Placeholder | ||
| CompareOpFloat = 182, // Placeholder | ||
| CompareOpInt = 183, // Placeholder | ||
| CompareOpStr = 184, // Placeholder | ||
| ContainsOpDict = 185, // Placeholder | ||
| ContainsOpSet = 186, // Placeholder | ||
| ForIterGen = 187, // Placeholder | ||
| ForIterList = 188, // Placeholder | ||
| ForIterRange = 189, // Placeholder | ||
| ForIterTuple = 190, // Placeholder | ||
| LoadAttrClass = 191, // Placeholder | ||
| LoadAttrGetattributeOverridden = 192, // Placeholder | ||
| LoadAttrInstanceValue = 193, // Placeholder | ||
| LoadAttrMethodLazyDict = 194, // Placeholder | ||
| LoadAttrMethodNoDict = 195, // Placeholder | ||
| LoadAttrMethodWithValues = 196, // Placeholder | ||
| LoadAttrModule = 197, // Placeholder | ||
| LoadAttrNondescriptorNoDict = 198, // Placeholder | ||
| LoadAttrNondescriptorWithValues = 199, // Placeholder | ||
| LoadAttrProperty = 200, // Placeholder | ||
| LoadAttrSlot = 201, // Placeholder | ||
| LoadAttrWithHint = 202, // Placeholder | ||
| LoadGlobalBuiltin = 203, // Placeholder | ||
| LoadGlobalModule = 204, // Placeholder | ||
| LoadSuperAttrAttr = 205, // Placeholder | ||
| LoadSuperAttrMethod = 206, // Placeholder | ||
| ResumeCheck = 207, // Placeholder | ||
| SendGen = 208, // Placeholder | ||
| StoreAttrInstanceValue = 209, // Placeholder | ||
| StoreAttrSlot = 210, // Placeholder | ||
| StoreAttrWithHint = 211, // Placeholder | ||
| StoreSubscrDict = 212, // Placeholder | ||
| StoreSubscrListInt = 213, // Placeholder | ||
| ToBoolAlwaysTrue = 214, // Placeholder | ||
| ToBoolBool = 215, // Placeholder | ||
| ToBoolInt = 216, // Placeholder | ||
| ToBoolList = 217, // Placeholder | ||
| ToBoolNone = 218, // Placeholder | ||
| ToBoolStr = 219, // Placeholder | ||
| UnpackSequenceList = 220, // Placeholder | ||
| UnpackSequenceTuple = 221, // Placeholder | ||
| UnpackSequenceTwoTuple = 222, // Placeholder | ||
| InstrumentedResume = 236, // Placeholder | ||
| InstrumentedEndFor = 237, // Placeholder | ||
| InstrumentedEndSend = 238, // Placeholder | ||
| InstrumentedReturnValue = 239, // Placeholder | ||
| InstrumentedReturnConst = 240, // Placeholder | ||
| InstrumentedYieldValue = 241, // Placeholder | ||
| InstrumentedLoadSuperAttr = 242, // Placeholder | ||
| InstrumentedForIter = 243, // Placeholder | ||
| InstrumentedCall = 244, // Placeholder | ||
| InstrumentedCallKw = 245, // Placeholder | ||
| InstrumentedCallFunctionEx = 246, // Placeholder | ||
| InstrumentedInstruction = 247, // Placeholder | ||
| InstrumentedJumpForward = 248, // Placeholder | ||
| InstrumentedJumpBackward = 249, // Placeholder | ||
| InstrumentedPopJumpIfTrue = 250, // Placeholder | ||
| InstrumentedPopJumpIfFalse = 251, // Placeholder | ||
| InstrumentedPopJumpIfNone = 252, // Placeholder | ||
| InstrumentedPopJumpIfNotNone = 253, // Placeholder | ||
| InstrumentedLine = 254, // Placeholder |
View reviewed changes
youknowone left a comment
Copy link Copy Markdown
Member
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
is the newly introduced ops all the pseudo ops?
Comment thread crates/compiler-core/src/bytecode/instruction.rs| SetExcInfo = 134, | ||
| Subscript = 135, | ||
| SetExcInfo = 132, | ||
| Subscript = 133, |
ShaharNaveh commented Jan 16, 2026
Copy link Copy Markdown
Contributor
Author
None are. All are either specialized or instrumented opcodes |
youknowone commented Jan 16, 2026
Copy link Copy Markdown
Member
|
Thanks! I didn't know about them. |
380fa39
into
RustPython : main
Jan 16, 2026
This was referenced Jan 17, 2026
PEP 750 tstring
#6744
Merged
LoadClosure as pseudo op
#6789
Merged
instruction improvements
#6829
Merged
Seperate between scope exit & unconditional jump opcodes
#6841
Merged
Align psuedo ops to CPython 3.14.2
#6846
Merged
This was referenced Jan 29, 2026
More Load instructions
#6886
Merged
Split stack_effect into pushed & popped
#6893
Merged
Rework exception compiler
#6909
Merged
This was referenced Feb 5, 2026
Newtype LoadSuperAttr oparg
#7002
Merged
Use num_enum crate for oparg types
#6980
Merged
This was referenced Feb 24, 2026
Instrumented instruction
#7212
Merged
instruction CACHE
#7251
Merged
Implement LOAD_ATTR inline caching with adaptive specialization
#7292
Merged
This was referenced Mar 14, 2026
Opcode name
#7433
Merged
Align _opcode_metadata.py to 3.14.3
#7456
Merged
coderabbitai
Bot
mentioned this pull request Mar 27, 2026 Oparg resume depth #7515 Merged Sign up for free to join this conversation on GitHub . Already have an account? Sign in to comment