mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-29 08:31:32 +00:00
Recover safely from WebAssembly-generated traps
This commit is contained in:
@ -22,6 +22,7 @@ use std::slice;
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::super::common::slice::{BoundedSlice, UncheckedSlice};
|
||||
use super::super::recovery;
|
||||
use super::errors::ErrorKind;
|
||||
use super::import_object::{ImportObject, ImportValue};
|
||||
use super::math_intrinsics;
|
||||
@ -225,7 +226,8 @@ impl Instance {
|
||||
// let r = *Arc::from_raw(isa_ptr);
|
||||
compile_function(&*options.isa, function_body).unwrap()
|
||||
// unimplemented!()
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
|
||||
for compiled_func in compiled_funcs.into_iter() {
|
||||
let CompiledFunction {
|
||||
@ -475,7 +477,8 @@ impl Instance {
|
||||
&mem[..],
|
||||
mem.current as usize * LinearMemory::WASM_PAGE_SIZE,
|
||||
)
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
let globals_pointer: GlobalsSlice = globals[..].into();
|
||||
|
||||
let data_pointers = DataPointers {
|
||||
@ -513,10 +516,16 @@ impl Instance {
|
||||
get_function_addr(&func_index, &self.import_functions, &self.functions)
|
||||
}
|
||||
|
||||
pub fn start(&self) {
|
||||
pub fn start_func(&self, func_index: FuncIndex) -> Result<(), i32> {
|
||||
let func: fn(&Instance) = get_instance_function!(&self, func_index);
|
||||
unsafe { recovery::protected_call(func, self) }
|
||||
}
|
||||
|
||||
pub fn start(&self) -> Result<(), i32> {
|
||||
if let Some(func_index) = self.start_func {
|
||||
let func: fn(&Instance) = get_instance_function!(&self, func_index);
|
||||
func(self)
|
||||
self.start_func(func_index)
|
||||
} else {
|
||||
panic!("start func not found")
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user