Merge branch 'master' into feature/nightly-release

This commit is contained in:
Lachlan Sneff
2019-04-11 14:36:18 -07:00
committed by GitHub
10 changed files with 88 additions and 4 deletions

View File

@ -1,3 +1,5 @@
#![cfg_attr(nightly, feature(unwind_attributes))]
#[cfg(test)]
#[macro_use]
extern crate field_offset;

View File

@ -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,