feat: JIT (unusable, segfault)
This commit is contained in:
@@ -44,17 +44,19 @@ impl From<ir::Param> for Param {
|
||||
pub struct Func<'vm> {
|
||||
pub func: &'vm BFunc,
|
||||
pub env: Env<'vm>,
|
||||
pub compiled: OnceCell<JITFunc>,
|
||||
pub compiled: OnceCell<&'vm JITFunc<'vm>>,
|
||||
pub count: Cell<usize>
|
||||
}
|
||||
|
||||
impl<'vm> Func<'vm> {
|
||||
pub fn call(&self, vm: &'vm VM<'_>, arg: Value<'vm>) -> Result<Value<'vm>> {
|
||||
impl<'vm, 'jit: 'vm> Func<'vm> {
|
||||
pub fn call(&self, vm: &'vm VM<'jit>, arg: Value<'vm>) -> Result<Value<'vm>> {
|
||||
use Param::*;
|
||||
|
||||
let count = self.count.get();
|
||||
if count >= 1 {
|
||||
let compiled = self.compiled.get_or_init(|| vm.compile_func(self));
|
||||
let compiled = self.compiled.get_or_init(|| vm.compile_func(self.func));
|
||||
let ret = compiled(vm as _, &self.env as _, arg.into());
|
||||
return Ok(ret.into())
|
||||
}
|
||||
self.count.replace(count + 1);
|
||||
let mut env = self.env.clone();
|
||||
|
||||
Reference in New Issue
Block a user