feat(jit): fib!
This commit is contained in:
@@ -9,7 +9,7 @@ use crate::error::Result;
|
||||
use crate::ir;
|
||||
use crate::jit::JITFunc;
|
||||
use crate::ty::internal::{Thunk, Value};
|
||||
use crate::vm::{Env, VM};
|
||||
use crate::vm::{LetEnv, VM};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Param {
|
||||
@@ -44,7 +44,7 @@ impl From<ir::Param> for Param {
|
||||
#[derive(Debug, Clone, Constructor)]
|
||||
pub struct Func<'jit: 'vm, 'vm> {
|
||||
pub func: &'vm BFunc,
|
||||
pub env: Env<'jit, 'vm>,
|
||||
pub env: LetEnv<'jit, 'vm>,
|
||||
pub compiled: OnceCell<JitFunction<'jit, JITFunc<'jit, 'vm>>>,
|
||||
pub count: Cell<usize>,
|
||||
}
|
||||
@@ -54,7 +54,7 @@ impl<'vm, 'jit: 'vm> Func<'jit, 'vm> {
|
||||
use Param::*;
|
||||
|
||||
let env = match self.func.param.clone() {
|
||||
Ident(ident) => self.env.clone().enter([(ident.into(), arg)].into_iter()),
|
||||
Ident(ident) => self.env.clone().enter_let([(ident.into(), arg)].into_iter()),
|
||||
Formals {
|
||||
formals,
|
||||
ellipsis,
|
||||
@@ -85,7 +85,7 @@ impl<'vm, 'jit: 'vm> Func<'jit, 'vm> {
|
||||
if let Some(alias) = alias {
|
||||
new.push((alias.clone().into(), Value::AttrSet(arg)));
|
||||
}
|
||||
self.env.clone().enter(new.into_iter())
|
||||
self.env.clone().enter_let(new.into_iter())
|
||||
}
|
||||
};
|
||||
|
||||
@@ -93,7 +93,7 @@ impl<'vm, 'jit: 'vm> Func<'jit, 'vm> {
|
||||
self.count.replace(count + 1);
|
||||
if count >= 1 {
|
||||
let compiled = self.compiled.get_or_init(|| vm.compile_func(self.func));
|
||||
let ret = unsafe { compiled.call(vm as *const VM, &env as *const Env) };
|
||||
let ret = unsafe { compiled.call(vm as *const VM, &env as *const LetEnv) };
|
||||
return Ok(ret.into());
|
||||
}
|
||||
vm.eval(self.func.opcodes.iter().copied(), env)
|
||||
|
||||
Reference in New Issue
Block a user