[wasmtime-api] Record original Trap from API callback. (#657)

* Record original Trap from API callback.

Fixes #645

* use TrapRegistry

* comment about magic number
This commit is contained in:
Yury Delendik
2019-12-04 07:57:24 -06:00
committed by GitHub
parent fd8a5f62ed
commit 991592c4ba
6 changed files with 170 additions and 29 deletions

View File

@@ -1,7 +1,7 @@
use crate::data_structures::ir;
use crate::r#ref::HostRef;
use crate::runtime::Store;
use crate::trampoline::generate_func_export;
use crate::trampoline::{generate_func_export, take_api_trap};
use crate::trap::Trap;
use crate::types::FuncType;
use crate::values::Val;
@@ -90,7 +90,8 @@ impl WrappedCallable for WasmtimeFn {
values_vec.as_mut_ptr() as *mut u8,
)
} {
return Err(HostRef::new(Trap::new(message)));
let trap = take_api_trap().unwrap_or_else(|| HostRef::new(Trap::new(message)));
return Err(trap);
}
// Load the return values out of `values_vec`.