feat: JIT (WIP)

This commit is contained in:
2025-05-17 12:18:02 +08:00
parent 15df7e55c9
commit 85f06a30cd
3 changed files with 60 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
use std::cell::RefCell;
use std::collections::HashMap;
use std::pin::Pin;
use std::rc::Rc;
use crate::builtins::env;
@@ -21,9 +22,9 @@ mod jit;
#[cfg(test)]
mod test;
const STACK_SIZE: usize = 8 * 1024 / size_of::<Value>();
pub const STACK_SIZE: usize = 8 * 1024 / size_of::<Value>();
pub fn run(prog: Program, jit: JITContext<'_>) -> Result<p::Value> {
pub fn run(prog: Program, jit: Pin<Box<JITContext<'_>>>) -> Result<p::Value> {
let vm = VM::new(
prog.thunks,
prog.funcs,
@@ -45,7 +46,7 @@ pub struct VM<'jit> {
symbols: RefCell<Vec<EcoString>>,
symmap: RefCell<HashMap<EcoString, usize>>,
consts: Box<[Const]>,
jit: JITContext<'jit>,
jit: Pin<Box<JITContext<'jit>>>
}
impl<'vm, 'jit: 'vm> VM<'jit> {