Skip to main content

wasmer_vm/libcalls/eh/
mod.rs

1// Part of the logic, here, is borrowed as-is from rust's stdlib.
2
3use crate::{InternalStoreHandle, VMContext, VMExceptionObj};
4
5mod dwarf;
6
7cfg_select! {
8    any(target_env = "msvc", target_family = "wasm") => {
9        /// The implementation of Wasmer's personality function.
10        ///
11        /// # Safety
12        ///
13        /// Performs libunwind unwinding magic.
14        pub unsafe fn wasmer_eh_personality() {
15            panic!()
16        }
17
18        /// The second stage of the personality function. See module level documentation
19        /// for an explanation of the exact procedure used during unwinding.
20        ///
21        /// # Safety
22        ///
23        /// Does pointer accesses, which must be valid.
24        pub unsafe fn wasmer_eh_personality2() {
25            panic!()
26        }
27
28        pub unsafe fn read_exnref(_exception: *mut std::ffi::c_void) -> u32 {
29            panic!()
30        }
31
32        /// # Safety
33        ///
34        /// Performs libunwind unwinding magic. Highly unsafe.
35        pub unsafe fn throw(_ctx: &crate::StoreObjects, _exnref: u32) -> ! {
36            panic!()
37        }
38
39        /// Given a pointer to a caught exception, return the exnref contained within.
40        ///
41        /// # Safety
42        ///
43        /// `exception` must be a pointer the platform-specific exception type; this is
44        /// `UwExceptionWrapper` for gcc.
45        pub unsafe fn delete_exception(_exception: *mut std::ffi::c_void) {
46            panic!()
47        }
48    }
49    any(
50        all(target_family = "windows", target_env = "gnu"),
51        target_family = "unix",
52    ) => {
53        // gcc-like eh-personality mechanisms.
54        mod gcc;
55        pub use gcc::*;
56    }
57    _ => {
58        // Targets that don't support unwinding.
59        // - os=none ("bare metal" targets)
60        // - os=uefi
61        // - os=espidf
62        // - os=hermit
63        // - nvptx64-nvidia-cuda
64        // - arch=avr
65    }
66}
67
68pub(crate) fn exn_obj_from_exnref(vmctx: *mut VMContext, exnref: u32) -> *mut VMExceptionObj {
69    let instance = unsafe { (*vmctx).instance_mut() };
70    let exnref = InternalStoreHandle::<VMExceptionObj>::from_index(exnref as usize).unwrap();
71    let exn = exnref.get_mut(instance.context_mut());
72    exn as *mut VMExceptionObj
73}