From f1f95f5c8cbf389bb223013bae7d311cf8bad319 Mon Sep 17 00:00:00 2001 From: Wilfried Chauveau Date: Fri, 15 Jan 2021 11:18:06 +0000 Subject: [PATCH] renders wasmi constrained system friendly (#220) --- src/module.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/module.rs b/src/module.rs index 033bccbfe2..a94e639989 100644 --- a/src/module.rs +++ b/src/module.rs @@ -730,6 +730,26 @@ impl<'a> NotStartedModuleRef<'a> { Ok(self.instance) } + /// Executes `start` function (if any) and returns fully instantiated module. + /// + /// # Errors + /// + /// Returns `Err` if start function traps. + pub fn run_start_with_stack( + self, + state: &mut E, + stack_recycler: &mut StackRecycler, + ) -> Result { + if let Some(start_fn_idx) = self.loaded_module.module().start_section() { + let start_func = self + .instance + .func_by_index(start_fn_idx) + .expect("Due to validation start function should exists"); + FuncInstance::invoke_with_stack(&start_func, &[], state, stack_recycler)?; + } + Ok(self.instance) + } + /// Returns fully instantiated module without running `start` function. /// /// # Panics