Visitar URL original
Sort `Instruction` variants + Ensure each holds a singular oparg type by ShaharNaveh · Pull Request #6312 · RustPython/RustPython · GitHub
Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix jit add_instruction
  • Loading branch information
ShaharNaveh committed Nov 29, 2025
commit 6d5210750a91c3aada3a8dda8838250e6089cb5f
26 changes: 13 additions & 13 deletions crates/jit/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {

// If that was a return instruction, mark future instructions unreachable
match instruction {
Instruction::ReturnValue | Instruction::ReturnConst { .. } => {
Instruction::ReturnValue | Instruction::ReturnConst(_) => {
in_unreachable_code = true;
}
_ => {}
Expand Down Expand Up @@ -276,7 +276,7 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
) -> Result<(), JitCompileError> {
match instruction {
Instruction::ExtendedArg => Ok(()),
Instruction::PopJumpIfFalse { target } => {
Instruction::PopJumpIfFalse(target) => {
let cond = self.stack.pop().ok_or(JitCompileError::BadBytecode)?;
let val = self.boolean_val(cond)?;
let then_block = self.get_or_create_block(target.get(arg));
Expand All @@ -289,7 +289,7 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {

Ok(())
}
Instruction::PopJumpIfTrue { target } => {
Instruction::PopJumpIfTrue(target) => {
let cond = self.stack.pop().ok_or(JitCompileError::BadBytecode)?;
let val = self.boolean_val(cond)?;
let then_block = self.get_or_create_block(target.get(arg));
Expand All @@ -303,7 +303,7 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
Ok(())
}

Instruction::Jump { target } => {
Instruction::Jump(target) => {
let target_block = self.get_or_create_block(target.get(arg));
self.builder.ins().jump(target_block, &[]);
Ok(())
Expand All @@ -328,12 +328,12 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
self.stack.push(val);
Ok(())
}
Instruction::BuildTuple { size } => {
Instruction::BuildTuple(size) => {
let elements = self.pop_multiple(size.get(arg) as usize);
self.stack.push(JitValue::Tuple(elements));
Ok(())
}
Instruction::UnpackSequence { size } => {
Instruction::UnpackSequence(size) => {
let val = self.stack.pop().ok_or(JitCompileError::BadBytecode)?;

let elements = match val {
Expand All @@ -352,12 +352,12 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
let val = self.stack.pop().ok_or(JitCompileError::BadBytecode)?;
self.return_value(val)
}
Instruction::ReturnConst { idx } => {
Instruction::ReturnConst(idx) => {
let val = self
.prepare_const(bytecode.constants[idx.get(arg) as usize].borrow_constant())?;
self.return_value(val)
}
Instruction::CompareOperation { op, .. } => {
Instruction::CompareOperation(op) => {
let op = op.get(arg);
// the rhs is popped off first
let b = self.stack.pop().ok_or(JitCompileError::BadBytecode)?;
Expand Down Expand Up @@ -411,7 +411,7 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
_ => Err(JitCompileError::NotSupported),
}
}
Instruction::UnaryOperation { op, .. } => {
Instruction::UnaryOperation(op) => {
let op = op.get(arg);
let a = self.stack.pop().ok_or(JitCompileError::BadBytecode)?;
match (op, a) {
Expand All @@ -436,7 +436,7 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
_ => Err(JitCompileError::NotSupported),
}
}
Instruction::BinaryOperation { op } | Instruction::BinaryOperationInplace { op } => {
Instruction::BinaryOperation(op) | Instruction::BinaryOperationInplace(op) => {
let op = op.get(arg);
// the rhs is popped off first
let b = self.stack.pop().ok_or(JitCompileError::BadBytecode)?;
Expand Down Expand Up @@ -581,7 +581,7 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
Ok(())
}
}
Instruction::CallFunctionPositional { nargs } => {
Instruction::CallFunctionPositional(nargs) => {
let nargs = nargs.get(arg);

let mut args = Vec::new();
Expand All @@ -602,7 +602,7 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
}
}
Instruction::Nop => Ok(()),
Instruction::Swap { index } => {
Instruction::Swap(index) => {
let len = self.stack.len();
let i = len - 1;
let j = len - 1 - index.get(arg) as usize;
Expand All @@ -613,7 +613,7 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
self.stack.pop();
Ok(())
}
Instruction::Resume { arg: _resume_arg } => {
Instruction::Resume(_resume_arg) => {
// TODO: Implement the resume instruction
Ok(())
}
Expand Down