optimize: make all call single arg
to allow more aggressive optimization
This commit is contained in:
@@ -122,14 +122,11 @@ impl<'vm, 'jit: 'vm> VM<'jit> {
|
||||
return Ok(step);
|
||||
}
|
||||
}
|
||||
OpCode::Call { arity } => {
|
||||
let mut args = Vec::with_capacity(arity);
|
||||
for _ in 0..arity {
|
||||
args.insert(0, stack.pop());
|
||||
}
|
||||
let mut func = stack.pop();
|
||||
OpCode::Call => {
|
||||
let arg = stack.pop();
|
||||
let func = stack.tos_mut();
|
||||
func.force(self)?;
|
||||
stack.push(func.call(self, args)?)?;
|
||||
func.call(self, arg)?;
|
||||
}
|
||||
OpCode::Func { idx } => {
|
||||
let func = self.get_func(idx);
|
||||
@@ -139,12 +136,12 @@ impl<'vm, 'jit: 'vm> VM<'jit> {
|
||||
}
|
||||
OpCode::UnOp { op } => {
|
||||
use UnOp::*;
|
||||
let mut value = stack.pop();
|
||||
let value = stack.tos_mut();
|
||||
value.force(self)?;
|
||||
stack.push(match op {
|
||||
match op {
|
||||
Neg => value.neg(),
|
||||
Not => value.not(),
|
||||
})?;
|
||||
}
|
||||
}
|
||||
OpCode::BinOp { op } => {
|
||||
use BinOp::*;
|
||||
@@ -154,7 +151,10 @@ impl<'vm, 'jit: 'vm> VM<'jit> {
|
||||
rhs.force(self)?;
|
||||
match op {
|
||||
Add => lhs.add(rhs),
|
||||
Sub => lhs.add(rhs.neg()),
|
||||
Sub => {
|
||||
rhs.neg();
|
||||
lhs.add(rhs);
|
||||
},
|
||||
Mul => lhs.mul(rhs),
|
||||
Div => lhs.div(rhs)?,
|
||||
And => lhs.and(rhs),
|
||||
|
||||
Reference in New Issue
Block a user