pub extern "win64" fn trampoline(
        vm: &VM,
        state: &mut VMState,
        target: CallTarget,
        arg: u64,
    ) -> u64 {
        let func = vm
            .module_loader
            .get_by_id(target.module)
            .expect("missing module")
            .as_ref()
            .expect("missing impl")
            .get_function_by_id(target.function)
            .expect("function id");

        if func.has_native_impl() {
            unsafe {
                let unsafe_fn_ptr = std::mem::transmute::<_, fn(&mut VMState, u64) -> u64>(
                    func.native_impl().unwrap().fn_ptr,
                );
                (unsafe_fn_ptr)(state, arg)
            }
        } else if func.has_bytecode_impl() {
            if let Some(res) = JITEngine::call_if_compiled(vm, state, target, arg) {
                res
            } else {
                vm.interpreter.push_native_caller_frame(
                    vm,
                    &mut state.interpreter_state,
                    target,
                    arg,
                );
                vm.interpreter.finish_function(vm, state);
                let res = vm
                    .interpreter
                    .pop_native_caller_frame(&mut state.interpreter_state);
                res
            }
        } else {
            panic!("Unknown implementation type");
        }
    }
// Jump from native to bytecode or native
Jump from native to bytecode or native
Jump from native to bytecode or native
pub extern "win64" fn trampoline(
        vm: &VM,
        state: &mut VMState,
        target: CallTarget,
        arg: u64,
    ) -> u64 {
        let func = vm
            .module_loader
            .get_by_id(target.module)
            .expect("missing module")
            .as_ref()
            .expect("missing impl")
            .get_function_by_id(target.function)
            .expect("function id");
        if func.has_native_impl() {
            unsafe {
                let unsafe_fn_ptr = std::mem::transmute::<_, fn(&mut VMState, u64) -> u64>(
                    func.native_impl().unwrap().fn_ptr,
                );
                (unsafe_fn_ptr)(state, arg)
            }
        } else if func.has_bytecode_impl() {
            if let Some(res) = JITEngine::call_if_compiled(vm, state, target, arg) {
                res
            } else {
                vm.interpreter.push_native_caller_frame(
                    vm,
                    &mut state.interpreter_state,
                    target,
                    arg,
                );
                vm.interpreter.finish_function(vm, state);
                let res = vm
                    .interpreter
                    .pop_native_caller_frame(&mut state.interpreter_state);
                res
            }
        } else {
            panic!("Unknown implementation type");
        }
    }
pub extern " " fn trampoline ( vm : & VM , state : & mut VMState , target : CallTarget , arg : u64 , ) -> u64 { let func = vm . module_loader . get_by_id ( target . module ) . expect ( " " ) . as_ref ( ) . expect ( " " ) . get_function_by_id ( target . function ) . expect ( " " ) ; if func . has_native_impl ( ) { unsafe { let unsafe_fn_ptr = std :: mem :: transmute :: < _ , fn ( & mut VMState , u64 ) -> u64 > ( func . native_impl ( ) . unwrap ( ) . fn_ptr , ) ; ( unsafe_fn_ptr ) ( state , arg ) } } else if func . has_bytecode_impl ( ) { if let Some ( res ) = JITEngine :: call_if_compiled ( vm , state , target , arg ) { res } else { vm . interpreter . push_native_caller_frame ( vm , & mut state . interpreter_state , target , arg , ) ; vm . interpreter . finish_function ( vm , state ) ; let res = vm . interpreter . pop_native_caller_frame ( & mut state . interpreter_state ) ; res } } else { panic ! ( " " ) ; } }
Jump from native to bytecode or native
Jump from native to bytecode or native
vm
&VM
state
&mut VMState
target
CallTarget
arg
u64
vm
&VM
state
&mut VMState
target
CallTarget
arg
u64