feat: JIT (unusable, segfault)

This commit is contained in:
2025-05-18 15:01:19 +08:00
parent 29e959894d
commit f98d623c13
8 changed files with 326 additions and 122 deletions

View File

@@ -110,10 +110,7 @@ impl<'vm, 'jit: 'vm> VM<'jit> {
OpCode::LoadThunk { idx } => {
stack.push(Value::Thunk(Thunk::new(self.get_thunk(idx)).into()))?
}
OpCode::CaptureEnv => match stack.tos()? {
Value::Thunk(thunk) => thunk.capture(env.clone()),
_ => (),
},
OpCode::CaptureEnv => stack.tos().unwrap().as_ref().unwrap_thunk().capture(env.clone()),
OpCode::ForceValue => {
stack.tos_mut()?.force(self)?;
}
@@ -267,7 +264,7 @@ impl<'vm, 'jit: 'vm> VM<'jit> {
Ok(0)
}
pub fn compile_func(&'vm self, func: &Func<'vm>) -> JITFunc {
pub fn compile_func(&'vm self, func: &'vm F) -> &'vm JITFunc<'vm> {
self.jit.compile_function(func, self).unwrap()
}
}