optimize(value): less clone

This commit is contained in:
2025-05-22 21:24:19 +08:00
parent b0b73439fd
commit f380e5fd70
6 changed files with 105 additions and 106 deletions

View File

@@ -12,24 +12,29 @@ pub fn env<'jit, 'vm>(vm: &'vm VM<'jit>) -> VmEnv<'jit, 'vm> {
let primops = [
PrimOp::new("add", 2, |_, args| {
let [first, second]: [Value; 2] = args.try_into().unwrap();
first.add(second).ok()
let [mut first, second]: [Value; 2] = args.try_into().unwrap();
first.add(second);
first.ok()
}),
PrimOp::new("sub", 2, |_, args| {
let [first, second]: [Value; 2] = args.try_into().unwrap();
first.add(second.neg()).ok()
let [mut first, second]: [Value; 2] = args.try_into().unwrap();
first.add(second.neg());
first.ok()
}),
PrimOp::new("mul", 2, |_, args| {
let [first, second]: [Value; 2] = args.try_into().unwrap();
first.mul(second).ok()
let [mut first, second]: [Value; 2] = args.try_into().unwrap();
first.mul(second);
first.ok()
}),
PrimOp::new("div", 2, |_, args| {
let [first, second]: [Value; 2] = args.try_into().unwrap();
first.div(second)
let [mut first, second]: [Value; 2] = args.try_into().unwrap();
first.div(second)?;
first.ok()
}),
PrimOp::new("lessThan", 2, |_, args| {
let [first, second]: [Value; 2] = args.try_into().unwrap();
first.lt(second).ok()
let [mut first, second]: [Value; 2] = args.try_into().unwrap();
first.lt(second);
first.ok()
}),
PrimOp::new("seq", 2, |vm, args| {
let [mut first, second]: [Value; 2] = args.try_into().unwrap();