Skip to content

Conversation

@youknowone
Copy link
Member

@youknowone youknowone commented Jan 20, 2026

Summary by CodeRabbit

  • Refactor
    • Optimized bytecode instruction set by consolidating control-flow and return mechanisms for improved efficiency and simplified internal handling.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

This PR removes three specialized bytecode instruction variants (Break, Continue, and ReturnConst) from the instruction set and consolidates their functionality into generic alternatives (Jump for break/continue control flow, ReturnValue for constant returns), simplifying the bytecode instruction architecture.

Changes

Cohort / File(s) Summary
Instruction Definition
crates/compiler-core/src/bytecode/instruction.rs
Removes Break, Continue, and ReturnConst enum variants and all associated metadata handling (label arguments, unconditional branch detection, stack effect calculations, and disassembler formatting).
Code Generation
crates/codegen/src/compile.rs
Replaces emit_return_const() to load constants and emit ReturnValue instead; removes optimization in emit_return_value() that reused trailing LoadConst as ReturnConst; updates emit_jump() for break/continue to emit generic Jump to computed targets.
Opcode Predicates
crates/stdlib/src/opcode.rs
Updates has_const() to exclude ReturnConst from constant-returning opcodes; removes Break and Continue from has_jump() matching.
VM Runtime Execution
crates/vm/src/frame.rs
Removes Break and Continue variants from UnwindReason enum; deletes instruction handling for Break, Continue, and ReturnConst in execute_instruction(); eliminates break/continue unwinding paths.
JIT Instruction Handling
crates/jit/src/instructions.rs
Removes ReturnConst from instruction termination recognition and instruction emitter logic.
Test Utilities
crates/jit/tests/common.rs
Removes ReturnConst handling from annotation extraction and StackMachine execution flow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Instruction 3.14 #6805: Directly inverse operation—adds Break, Continue, and ReturnConst variants that this PR removes.
  • Bytecode pseudo opcodes #6715: Introduces PseudoInstruction and instruction enum consolidation that likely motivates this removal.
  • Fix opcode args #6649: Modifies the same opcode predicate functions (has_const, has_jump) in crates/stdlib/src/opcode.rs.

Suggested reviewers

  • ShaharNaveh

Poem

🐰 Hops along with glee,
Break and Continue—now set free!
ReturnConst fades from bytecode bright,
Jump and ReturnValue shine so right.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title precisely summarizes the main change: removing three instruction variants (ReturnConst, Break, Continue) from the bytecode instruction set across multiple crates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@youknowone youknowone changed the title Break continue Remove ReturnConst/Break/Continue Jan 20, 2026
@youknowone youknowone changed the title Remove ReturnConst/Break/Continue Remove ReturnConst/Break/Continue ops Jan 20, 2026
@youknowone youknowone marked this pull request as ready for review January 20, 2026 14:58
@youknowone youknowone merged commit e0cceaf into RustPython:main Jan 20, 2026
13 checks passed
@youknowone youknowone deleted the break-continue branch January 20, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant