optimize(env): single arg

This commit is contained in:
2025-05-20 09:47:30 +08:00
parent b4db46d48a
commit d0298ce2a6
8 changed files with 76 additions and 38 deletions

View File

@@ -1,3 +1,5 @@
use std::rc::Rc;
use inkwell::AddressSpace;
use inkwell::context::Context;
use inkwell::execution_engine::ExecutionEngine;
@@ -205,7 +207,11 @@ extern "C" fn helper_debug(value: JITValue) {
#[unsafe(no_mangle)]
extern "C" fn helper_capture_env(thunk: JITValue, env: *const LetEnv) {
let thunk: &Thunk = unsafe { std::mem::transmute(thunk.data.ptr.as_ref().unwrap()) };
thunk.capture(unsafe { env.as_ref().unwrap() }.clone());
let env = unsafe {
Rc::from_raw(env)
};
thunk.capture(env.clone());
std::mem::forget(env);
}
#[unsafe(no_mangle)]