/// Helper function to instantiate Wasm module in Wasmtime and call "run"
/// function. The goal is to use plain Wasmtime, without any of our additions.
Helper function to instantiate Wasm module in Wasmtime and call "run"
function. The goal is to use plain Wasmtime, without any of our additions.
Helper function to instantiate Wasm module in Wasmtime and call " run " function . The goal is to use plain Wasmtime without any of our additions .
pub fn wasmtime_instantiate_and_call_run(wasm: &BinaryEncodedWasm) -> Vec<wasmtime::Val> {
    // check that instrumented module instantiates correctly
    let mut wasmtime = WasmtimeSimple::new();
    let (imports_module_instance, imports_module_exports) = {
        let imports_wasm = wabt::wat2wasm(
            r#"
            (module
                (func (export "out_of_instructions"))
                (func (export "update_available_memory") (param i32 i32) (result i32)
                    i32.const 42
                )
            )"#,
        )
        .unwrap();
        let i = wasmtime.instantiate(&HashMap::new(), &imports_wasm);
        let mut e = HashMap::new();
        e.insert("out_of_instructions".to_string(), 0);
        e.insert("update_available_memory".to_string(), 1);
        (i, e)
    };
    let mut registry = HashMap::new();
    registry.insert(
        "__".to_string(),
        (imports_module_instance, imports_module_exports),
    );
    let instance = wasmtime.instantiate(&registry, wasm.as_slice());
    invoke(wasmtime.store, &instance, "run", &[])
}
pub fn wasmtime_instantiate_and_call_run ( wasm : & BinaryEncodedWasm ) -> Vec < wasmtime :: Val > { // check that instrumented module instantiates correctly let mut wasmtime = WasmtimeSimple :: new ( ) ; let ( imports_module_instance , imports_module_exports ) = { let imports_wasm = wabt :: wat2wasm ( r#"
            (module
                (func (export "out_of_instructions"))
                (func (export "update_available_memory") (param i32 i32) (result i32)
                    i32.const 42
                )
            )"# , ) . unwrap ( ) ; let i = wasmtime . instantiate ( & HashMap :: new ( ) , & imports_wasm ) ; let mut e = HashMap :: new ( ) ; e . insert ( " " . to_string ( ) , 0 ) ; e . insert ( " " . to_string ( ) , 1 ) ; ( i , e ) } ; let mut registry = HashMap :: new ( ) ; registry . insert ( " " . to_string ( ) , ( imports_module_instance , imports_module_exports ) , ) ; let instance = wasmtime . instantiate ( & registry , wasm . as_slice ( ) ) ; invoke ( wasmtime . store , & instance , " " , & [ ] ) }
Helper function to instantiate Wasm module in Wasmtime and call "run"
function.
Helper function to instantiate Wasm module in Wasmtime and call " run " function .
wasm
&BinaryEncodedWasm