wasmer_vm/libcalls/eh/
mod.rs

1// Part of the logic, here, is borrowed as-is from rust's stdlib.
2
3mod dwarf;
4
5cfg_if::cfg_if! {
6    if #[cfg(any(target_env = "msvc", target_family = "wasm"))] {
7        // We have yet to figure this out.
8        #[repr(C)]
9        pub struct UwExceptionWrapper {
10            pub _uwe: (),
11            pub cause: Box<dyn std::any::Any + Send>,
12        }
13
14        impl UwExceptionWrapper {
15            pub fn new(tag: u64, data_ptr: usize, data_size: u64) -> Self {
16                Self {
17                    _uwe: (),
18                    cause: Box::new(WasmerException {
19                        tag,
20                        data_ptr,
21                        data_size,
22                    }),
23                }
24            }
25        }
26
27        #[repr(C)]
28        #[derive(Debug, thiserror::Error, Clone)]
29        #[error("Uncaught exception in wasm code!")]
30        pub struct WasmerException {
31            pub tag: u64,
32            pub data_ptr: usize,
33            pub data_size: u64,
34        }
35
36        pub fn wasmer_eh_personality() {
37            panic!()
38        }
39
40        pub fn wasmer_eh_personality2() {
41            panic!()
42        }
43
44        pub unsafe fn throw(
45            _tag: u32,
46            _vmctx: *mut crate::VMContext,
47            _data_ptr: usize,
48            _data_size: u64,
49        ) -> ! {
50            panic!()
51        }
52
53        pub fn rethrow(_exc: *mut UwExceptionWrapper) -> ! {
54            panic!()
55        }
56
57
58    } else if #[cfg(any(
59        all(target_family = "windows", target_env = "gnu"),
60        target_family = "unix",
61    ))] {
62        // gcc-like eh-personality mechanisms.
63        mod gcc;
64        pub use gcc::*;
65    } else {
66        // Targets that don't support unwinding.
67        // - os=none ("bare metal" targets)
68        // - os=uefi
69        // - os=espidf
70        // - os=hermit
71        // - nvptx64-nvidia-cuda
72        // - arch=avr
73    }
74}