Simplify `Intruction.deopt()` by ShaharNaveh · Pull Request #7615 · RustPython/RustPython
📝 Walkthrough
Walkthrough
The changes refactor Instruction::deopt to delegate base opcode construction to Opcode::as_instruction() instead of inline argument handling. Correspondingly, the metadata generation script is rewritten to parse deopt match arms via brace-depth scanning and regex, replacing prior line-based filtering logic.
Changes
| Cohort / File(s) | Summary |
|---|---|
Opcode Deoptimization Refactoring crates/compiler-core/src/bytecode/instruction.rs |
Restructured Instruction::deopt to map specialized opcodes (e.g., ResumeCheck, LoadConstMortal, ToBool*, BinaryOp*, StoreSubscr*, etc.) to corresponding base Opcode variants, delegating marker-field construction to Opcode::as_instruction(). |
Metadata Parsing Update scripts/generate_opcode_metadata.py |
Rewrote build_deopts to parse deopt implementation using brace-depth scanning for match block extraction and regex for arm extraction, replacing line-based filtering heuristics with explicit error handling for missing match self. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
🐰 With ops that hop through deopt's door,
We delegate toas_instructionmore,
Brace-depths are scanned with careful care,
A refactor crisp floats through the air!
Bytecode now bounds with pattern so fair,
✨
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'Simplify Intruction.deopt()' directly matches the main change: refactoring the deopt method to delegate argument construction to Opcode::as_instruction() rather than inlining it. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
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 @coderabbitai help to get the list of available commands and usage tips.