Skip to content
Open
Show file tree
Hide file tree
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
rebinding fix
  • Loading branch information
LuigiTheJokesterAlvarez committed Jun 28, 2026
commit 1d155702709fe9ae9e6dfc5d1ee7ce63e0ae4659
49 changes: 7 additions & 42 deletions crates/jit/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,49 +180,14 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
}

fn store_variable(&mut self, idx: oparg::VarNum, val: JitValue) -> Result<(), JitCompileError> {
#[expect(clippy::mut_mut, reason = "This seems like a false positive")]
let builder = &mut self.builder;
match val {
JitValue::Tuple(elements) => {
let val = JitValue::Tuple(elements);
match &self.variables[idx] {
Some(existing @ Local::Tuple { .. }) => {
// reuse existing vars
Self::update_local(builder, existing, val)
}
Some(Local::Scalar { .. }) => Err(JitCompileError::NotSupported),
None => {
let local = Self::local_from_value(builder, val)?;
self.variables[idx] = Some(local);
Ok(())
}
}
}
_ => {
// primitive
let vty = val.to_jit_type().ok_or(JitCompileError::NotSupported)?;
let local = self.variables[idx].get_or_insert_with(|| {
let var = builder.declare_var(vty.to_cranelift());
Local::Scalar {
var,
ty: vty.clone(),
}
});

match local {
Local::Scalar { var, ty } => {
if vty != *ty {
Err(JitCompileError::NotSupported)
} else {
self.builder.def_var(*var, val.into_value().unwrap());
Ok(())
}
}
_ => Err(JitCompileError::NotSupported)
}
}
#[expect(clippy::mut_mut, reason = "This seems like a false positive")]
let builder = &mut self.builder;

let local = Self::local_from_value(builder, val)?;
self.variables[idx] = Some(local);

Ok(())
}
}

fn boolean_val(&mut self, val: JitValue) -> Result<Value, JitCompileError> {
match val {
Expand Down
1 change: 1 addition & 0 deletions testo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ def foo():
(3, 4),
1
)
t = 1
return 3

foo.__jit__()
Expand Down