extern "C" fn start_from_compile_result(compile_result: *mut CompileResult) {
    let compile_result = unsafe { Box::from_raw(compile_result) };
    let instantiation = compile_result.instantiate();

    match instantiation.emit_and_link() {
        Ok(wasm_instance) => {
            let vmctx = wasm_instance.vmctx_container.ptr();

            let func: extern "C" fn(*const VmContext) =
                unsafe { mem::transmute(wasm_instance.start_address.as_usize()) };

            with_current_thread(|thread| {
                // Safety: this is a new thread without existing wasm data.
                unsafe {
                    thread.set_wasm_data(
                        wasm_instance.code_vma,
                        wasm_instance.heap_vma,
                        wasm_instance.vmctx_container,
                    )
                }
            });

            drop(compile_result);

            func(vmctx);
        }

        Err(e) => {
            drop(compile_result);
            println!("Error while starting: {:?}", e);
        }
    }

    thread_exit(0);
}
/// Start the wasm application from compile result.
Start the wasm application from compile result.
Start the wasm application from compile result .
extern "C" fn start_from_compile_result(compile_result: *mut CompileResult) {
    let compile_result = unsafe { Box::from_raw(compile_result) };
    let instantiation = compile_result.instantiate();
    match instantiation.emit_and_link() {
        Ok(wasm_instance) => {
            let vmctx = wasm_instance.vmctx_container.ptr();
            let func: extern "C" fn(*const VmContext) =
                unsafe { mem::transmute(wasm_instance.start_address.as_usize()) };
            with_current_thread(|thread| {
                // Safety: this is a new thread without existing wasm data.
                unsafe {
                    thread.set_wasm_data(
                        wasm_instance.code_vma,
                        wasm_instance.heap_vma,
                        wasm_instance.vmctx_container,
                    )
                }
            });
            drop(compile_result);
            func(vmctx);
        }
        Err(e) => {
            drop(compile_result);
            println!("Error while starting: {:?}", e);
        }
    }
    thread_exit(0);
}
extern " " fn start_from_compile_result ( compile_result : * mut CompileResult ) { let compile_result = unsafe { Box :: from_raw ( compile_result ) } ; let instantiation = compile_result . instantiate ( ) ; match instantiation . emit_and_link ( ) { Ok ( wasm_instance ) => { let vmctx = wasm_instance . vmctx_container . ptr ( ) ; let func : extern " " fn ( * const VmContext ) = unsafe { mem :: transmute ( wasm_instance . start_address . as_usize ( ) ) } ; with_current_thread ( | thread | { // Safety: this is a new thread without existing wasm data. unsafe { thread . set_wasm_data ( wasm_instance . code_vma , wasm_instance . heap_vma , wasm_instance . vmctx_container , ) } } ) ; drop ( compile_result ) ; func ( vmctx ) ; } Err ( e ) => { drop ( compile_result ) ; println ! ( " " e ) ; } } thread_exit ( 0 ) ; }
Start the wasm application from compile result.
Start the wasm application from compile result .
compile_result
*mut CompileResult
compile_result
*mut CompileResult