/// Executes first exported method on an embedder instance, whose name
/// consists of one of the prefixes and method_name.
Executes first exported method on an embedder instance, whose name
consists of one of the prefixes and method_name.
Executes first exported method on an embedder instance whose name consists of one of the prefixes and method_name .
pub fn run(
        &mut self,
        system_api: &mut (dyn SystemApi + 'static),
        func_ref: FuncRef,
    ) -> HypervisorResult<InstanceRunResult> {
        self.system_api_handle.replace(system_api);
        let _alt_sig_stack = unsafe { self.signal_stack.register() };
        match &func_ref {
            FuncRef::Method(wasm_method) => self.invoke_export(&wasm_method.to_string(), &[]),
            FuncRef::QueryClosure(closure) | FuncRef::UpdateClosure(closure) => self
                .instance
                .get_export("table")
                .ok_or_else(|| HypervisorError::ContractViolation("table not found".to_string()))?
                .into_table()
                .ok_or_else(|| {
                    HypervisorError::ContractViolation("export 'table' is not a table".to_string())
                })?
                .get(closure.func_idx)
                .ok_or(HypervisorError::FunctionNotFound(0, closure.func_idx))?
                .funcref()
                .ok_or_else(|| {
                    HypervisorError::ContractViolation("not a function reference".to_string())
                })?
                .ok_or_else(|| {
                    HypervisorError::ContractViolation(
                        "unexpected null function reference".to_string(),
                    )
                })?
                .call(&[Val::I32(closure.env as i32)])
                .map_err(trap_to_error)
                .map(|boxed_slice| boxed_slice.to_vec()),
        }
        .map_err(|e| system_api.get_execution_error().cloned().unwrap_or(e))?;
        self.system_api_handle.clear();
        Ok(InstanceRunResult {
            exported_globals: self.get_exported_globals(),
            dirty_pages: self.dirty_pages(),
        })
    }
pub fn run ( & mut self , system_api : & mut ( dyn SystemApi + ' static ) , func_ref : FuncRef , ) -> HypervisorResult < InstanceRunResult > { self . system_api_handle . replace ( system_api ) ; let _alt_sig_stack = unsafe { self . signal_stack . register ( ) } ; match & func_ref { FuncRef :: Method ( wasm_method ) => self . invoke_export ( & wasm_method . to_string ( ) , & [ ] ) , FuncRef :: QueryClosure ( closure ) | FuncRef :: UpdateClosure ( closure ) => self . instance . get_export ( " " ) . ok_or_else ( | | HypervisorError :: ContractViolation ( " " . to_string ( ) ) ) ? . into_table ( ) . ok_or_else ( | | { HypervisorError :: ContractViolation ( " " . to_string ( ) ) } ) ? . get ( closure . func_idx ) . ok_or ( HypervisorError :: FunctionNotFound ( 0 , closure . func_idx ) ) ? . funcref ( ) . ok_or_else ( | | { HypervisorError :: ContractViolation ( " " . to_string ( ) ) } ) ? . ok_or_else ( | | { HypervisorError :: ContractViolation ( " " . to_string ( ) , ) } ) ? . call ( & [ Val :: I32 ( closure . env as i32 ) ] ) . map_err ( trap_to_error ) . map ( | boxed_slice | boxed_slice . to_vec ( ) ) , } . map_err ( | e | system_api . get_execution_error ( ) . cloned ( ) . unwrap_or ( e ) ) ? ; self . system_api_handle . clear ( ) ; Ok ( InstanceRunResult { exported_globals : self . get_exported_globals ( ) , dirty_pages : self . dirty_pages ( ) , } ) }
Executes first exported method on an embedder instance, whose name
consists of one of the prefixes and method_name.
Executes first exported method on an embedder instance whose name consists of one of the prefixes and method_name .
&mut self
system_api
&mut (dyn SystemApi + 'static)
func_ref
FuncRef