feat: gc-arena (WIP, does not compile)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use gc_arena::{Gc, Mutation};
|
||||
use inkwell::AddressSpace;
|
||||
use inkwell::context::Context;
|
||||
use inkwell::execution_engine::ExecutionEngine;
|
||||
@@ -56,7 +57,7 @@ impl<'ctx> Helpers<'ctx> {
|
||||
"capture_env",
|
||||
context
|
||||
.void_type()
|
||||
.fn_type(&[value_type.into(), ptr_type.into()], false),
|
||||
.fn_type(&[value_type.into(), ptr_type.into(), ptr_type.into()], false),
|
||||
None,
|
||||
);
|
||||
let neg = module.add_function(
|
||||
@@ -202,10 +203,10 @@ extern "C" fn helper_debug(value: JITValue) {
|
||||
dbg!(value.tag);
|
||||
}
|
||||
|
||||
extern "C" fn helper_capture_env(thunk: JITValue, env: *const VmEnv) {
|
||||
extern "C" fn helper_capture_env<'gc>(thunk: JITValue, env: *const VmEnv<'gc>, mc: *const Mutation<'gc>) {
|
||||
let thunk = unsafe { (thunk.data.ptr as *const Thunk).as_ref().unwrap() };
|
||||
let env = unsafe { env.as_ref() }.unwrap();
|
||||
thunk.capture(env);
|
||||
let env = unsafe { Gc::from_ptr(env) };
|
||||
thunk.capture(env, unsafe { mc.as_ref() }.unwrap());
|
||||
}
|
||||
|
||||
extern "C" fn helper_neg(rhs: JITValue, _env: *const VmEnv) -> JITValue {
|
||||
@@ -308,12 +309,12 @@ extern "C" fn helper_or(lhs: JITValue, rhs: JITValue) -> JITValue {
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" fn helper_call<'jit>(func: JITValue, arg: JITValue, vm: *const VM<'jit>) -> JITValue {
|
||||
extern "C" fn helper_call(func: JITValue, arg: JITValue, vm: *const VM, mc: *const Mutation) -> JITValue {
|
||||
use ValueTag::*;
|
||||
match func.tag {
|
||||
Function => {
|
||||
let mut func: Value = func.into();
|
||||
func.call(unsafe { vm.as_ref() }.unwrap(), arg.into())
|
||||
func.call(arg.into(), unsafe { vm.as_ref() }.unwrap(), unsafe { mc.as_ref() }.unwrap())
|
||||
.unwrap();
|
||||
func.into()
|
||||
}
|
||||
@@ -321,14 +322,14 @@ extern "C" fn helper_call<'jit>(func: JITValue, arg: JITValue, vm: *const VM<'ji
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" fn helper_lookup<'jit, 'vm>(sym: usize, env: *const VmEnv<'jit, 'vm>) -> JITValue {
|
||||
extern "C" fn helper_lookup(sym: usize, env: *const VmEnv) -> JITValue {
|
||||
let env = unsafe { env.as_ref() }.unwrap();
|
||||
let val: JITValue = env.lookup(&sym).unwrap().into();
|
||||
val
|
||||
}
|
||||
|
||||
extern "C" fn helper_force<'jit>(thunk: JITValue, vm: *const VM<'jit>) -> JITValue {
|
||||
extern "C" fn helper_force(thunk: JITValue, vm: *const VM, mc: *const Mutation) -> JITValue {
|
||||
let mut val = Value::from(thunk);
|
||||
val.force(unsafe { vm.as_ref() }.unwrap()).unwrap();
|
||||
val.force(unsafe { vm.as_ref() }.unwrap(), unsafe { mc.as_ref() }.unwrap()).unwrap();
|
||||
val.into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user