feat: less gc (WIP)

This commit is contained in:
2025-06-02 14:18:59 +08:00
parent d3442e87e7
commit 51f8df9cca
11 changed files with 125 additions and 179 deletions

View File

@@ -361,7 +361,7 @@ extern "C" fn helper_call<'gc>(
ValueTag::Function => {
let func = Value::from(func).unwrap_func();
let env = unsafe { &mut *env };
env.alloc_gc(func.call_compile(arg, vm, mc).unwrap(), mc).into()
func.call_compile(arg, vm, mc).unwrap().clone().into()
}
_ => todo!(),
}
@@ -369,19 +369,19 @@ extern "C" fn helper_call<'gc>(
extern "C" fn helper_arg(idx: usize, env: *const VmEnv) -> JITValue {
let env = unsafe { env.as_ref() }.unwrap();
let val: JITValue = env.lookup_arg(idx).into();
let val: JITValue = env.lookup_arg(idx).clone().into();
val
}
extern "C" fn helper_lookup_let(level: usize, idx: usize, env: *const VmEnv) -> JITValue {
let env = unsafe { env.as_ref() }.unwrap();
let val: JITValue = env.lookup_let(level, idx).into();
let val: JITValue = env.lookup_let(level, idx).clone().into();
val
}
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().into();
let val: JITValue = env.lookup_with(&sym).unwrap().clone().into();
val
}
@@ -399,7 +399,7 @@ extern "C" fn helper_force<'gc>(
let mc = unsafe { mc.as_ref() }.unwrap();
let thunk = Value::from(thunk).unwrap_thunk();
if let Some(val) = thunk.get_value() {
return val.into();
return val.clone().into();
}
let (opcodes, env) = thunk.suspend(mc).unwrap();
let func = unsafe { jit.as_ref() }
@@ -414,9 +414,9 @@ extern "C" fn helper_force<'gc>(
extern "C" fn helper_new_thunk<'gc>(opcodes: *const OpCodes, env: *mut VmEnv<'gc>, mc: *const Mutation<'gc>) -> JITValue {
let mc = unsafe { &*mc };
let env = unsafe { &mut *env };
env.alloc_gc(Value::Thunk(Thunk::new(
Value::Thunk(Thunk::new(
unsafe { opcodes.as_ref() }.unwrap(),
mc
)), mc)
))
.into()
}