Skip to content

Commit f1f95f5

Browse files
authored
renders wasmi constrained system friendly (#220)
1 parent e6134c7 commit f1f95f5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/module.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,26 @@ impl<'a> NotStartedModuleRef<'a> {
730730
Ok(self.instance)
731731
}
732732

733+
/// Executes `start` function (if any) and returns fully instantiated module.
734+
///
735+
/// # Errors
736+
///
737+
/// Returns `Err` if start function traps.
738+
pub fn run_start_with_stack<E: Externals>(
739+
self,
740+
state: &mut E,
741+
stack_recycler: &mut StackRecycler,
742+
) -> Result<ModuleRef, Trap> {
743+
if let Some(start_fn_idx) = self.loaded_module.module().start_section() {
744+
let start_func = self
745+
.instance
746+
.func_by_index(start_fn_idx)
747+
.expect("Due to validation start function should exists");
748+
FuncInstance::invoke_with_stack(&start_func, &[], state, stack_recycler)?;
749+
}
750+
Ok(self.instance)
751+
}
752+
733753
/// Returns fully instantiated module without running `start` function.
734754
///
735755
/// # Panics

0 commit comments

Comments
 (0)