feat: initial parallel impl

This commit is contained in:
2025-06-08 17:27:43 +08:00
parent 3797544fc2
commit 7293cb9f75
18 changed files with 529 additions and 934 deletions

View File

@@ -1,5 +1,4 @@
use std::ptr::NonNull;
use std::rc::Rc;
use inkwell::AddressSpace;
use inkwell::context::Context;
@@ -10,7 +9,6 @@ use inkwell::values::{BasicValueEnum, FunctionValue};
use crate::env::VmEnv;
use crate::eval::Engine;
use crate::ty::internal::{Thunk, Value};
use super::{JITContext, JITValue, ValueTag, JITValueData};
@@ -228,11 +226,8 @@ extern "C" fn helper_debug(value: JITValue) {
dbg!(value.tag);
}
extern "C" fn helper_capture_env<'gc>(thunk: JITValue, env: *const VmEnv<'gc>) {
let thunk = unsafe { (thunk.data.ptr as *const Thunk).as_ref().unwrap() };
let env = unsafe { Rc::from_raw(env) };
thunk.capture_env(env.clone());
std::mem::forget(env);
extern "C" fn helper_capture_env(thunk: JITValue, env: *const VmEnv) {
todo!()
}
extern "C" fn helper_neg(rhs: JITValue, _env: *const VmEnv) -> JITValue {
@@ -335,7 +330,7 @@ extern "C" fn helper_or(lhs: JITValue, rhs: JITValue) -> JITValue {
}
}
extern "C" fn helper_call<'gc>(func: JITValue, arg: JITValue, engine: *mut Engine) -> JITValue {
extern "C" fn helper_call(func: JITValue, arg: JITValue, engine: *mut Engine) -> JITValue {
todo!()
}
@@ -352,15 +347,13 @@ extern "C" fn helper_lookup_let(level: usize, idx: usize, env: *const VmEnv) ->
}
extern "C" fn helper_lookup(sym: usize, env: *const VmEnv) -> JITValue {
let env = unsafe { env.as_ref() }.unwrap();
let val: JITValue = env.lookup_with(&sym).unwrap().clone().into();
val
todo!()
}
extern "C" fn helper_force<'gc>(
extern "C" fn helper_force(
thunk: JITValue,
vm: NonNull<Engine>,
jit: *const JITContext<'gc>,
jit: *const JITContext,
) -> JITValue {
if !matches!(thunk.tag, ValueTag::Thunk) {
return thunk;