feat: JIT (WIP)

This commit is contained in:
2025-05-17 20:54:36 +08:00
parent c3d365d486
commit 95ebddf272
15 changed files with 175 additions and 274 deletions

View File

@@ -1,9 +1,12 @@
use derive_more::Constructor;
use std::cell::{Cell, OnceCell};
use itertools::Itertools;
use derive_more::Constructor;
use crate::bytecode::Func as BFunc;
use crate::error::Result;
use crate::ir;
use crate::jit::JITFunc;
use crate::ty::internal::{Thunk, Value};
use crate::vm::{Env, VM};
@@ -37,14 +40,12 @@ impl From<ir::Param> for Param {
}
}
pub type JITFunc<'vm> =
unsafe extern "C" fn(vm: *mut VM<'_>, *mut Env<'vm>, *mut Value<'vm>) -> Value<'vm>;
#[derive(Debug, Clone, Constructor)]
pub struct Func<'vm> {
pub func: &'vm BFunc,
pub env: Env<'vm>,
pub compiled: Option<JITFunc<'vm>>,
pub compiled: OnceCell<JITFunc>,
pub count: Cell<usize>
}
impl<'vm> Func<'vm> {