mirror of
https://github.com/fluencelabs/wasmer
synced 2025-07-30 14:52:01 +00:00
Add well placed unwind(allowed) attribute
This commit is contained in:
@@ -45,6 +45,7 @@ field-offset = "0.1.1"
|
||||
|
||||
[build-dependencies]
|
||||
blake2b_simd = "0.4.1"
|
||||
rustc_version = "0.2.3"
|
||||
|
||||
[features]
|
||||
debug = []
|
||||
|
@@ -23,4 +23,9 @@ fn main() {
|
||||
f_out
|
||||
.write_all(hash_string.as_bytes())
|
||||
.expect("Could not write to file for wasmer hash value");
|
||||
|
||||
// Enable "nightly" cfg if the current compiler is nightly.
|
||||
if rustc_version::version_meta().unwrap().channel == rustc_version::Channel::Nightly {
|
||||
println!("cargo:rustc-cfg=nightly");
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
#![cfg_attr(nightly, feature(unwind_attributes))]
|
||||
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
extern crate field_offset;
|
||||
|
@@ -339,11 +339,14 @@ macro_rules! impl_traits {
|
||||
fn to_raw(&self) -> NonNull<vm::Func> {
|
||||
assert_eq!(mem::size_of::<Self>(), 0, "you cannot use a closure that captures state for `Func`.");
|
||||
|
||||
/// This is required for the llvm backend to be able to unwind through this function.
|
||||
#[cfg_attr(nightly, unwind(allowed))]
|
||||
extern fn wrap<$( $x: WasmExternType, )* Rets: WasmTypeList, Trap: TrapEarly<Rets>, FN: Fn( &mut Ctx $( ,$x )* ) -> Trap>( ctx: &mut Ctx $( ,$x: $x )* ) -> Rets::CStruct {
|
||||
let f: FN = unsafe { mem::transmute_copy(&()) };
|
||||
|
||||
let err = match panic::catch_unwind(panic::AssertUnwindSafe(|| {
|
||||
f( ctx $( ,$x )* ).report()
|
||||
let res = f( ctx $( ,$x )* ).report();
|
||||
res
|
||||
})) {
|
||||
Ok(Ok(returns)) => return returns.into_c_struct(),
|
||||
Ok(Err(err)) => err,
|
||||
|
Reference in New Issue
Block a user