|
19 | 19 | #include "unwind.h" |
20 | 20 | #include <threads.h> |
21 | 21 |
|
22 | | -_Unwind_Reason_Code __gxx_personality_wasm0(int version, _Unwind_Action actions, |
23 | | - uint64_t exceptionClass, |
24 | | - _Unwind_Exception *unwind_exception, |
25 | | - _Unwind_Context *context); |
26 | | - |
27 | | -struct _Unwind_LandingPadContext { |
28 | | - // Input information to personality function |
29 | | - uintptr_t lpad_index; // landing pad index |
30 | | - uintptr_t lsda; // LSDA address |
31 | | - |
32 | | - // Output information computed by personality function |
33 | | - uintptr_t selector; // selector value |
34 | | -}; |
35 | | - |
36 | | -// Communication channel between compiler-generated user code and personality |
37 | | -// function |
38 | | -thread_local struct _Unwind_LandingPadContext __wasm_lpad_context; |
39 | | - |
40 | | -/// Calls to this function are in landing pads in compiler-generated user code. |
41 | | -/// In other EH schemes, stack unwinding is done by libunwind library, which |
42 | | -/// calls the personality function for each frame it lands. On the other hand, |
43 | | -/// WebAssembly stack unwinding process is performed by a VM, and the |
44 | | -/// personality function cannot be called from there. So the compiler inserts a |
45 | | -/// call to this function in landing pads in the user code, which in turn calls |
46 | | -/// the personality function. |
47 | | -_Unwind_Reason_Code _Unwind_CallPersonality(void *exception_ptr) { |
48 | | - struct _Unwind_Exception *exception_object = |
49 | | - (struct _Unwind_Exception *)exception_ptr; |
50 | | - _LIBUNWIND_TRACE_API("_Unwind_CallPersonality(exception_object=%p)", |
51 | | - (void *)exception_object); |
52 | | - |
53 | | - // Reset the selector. |
54 | | - __wasm_lpad_context.selector = 0; |
55 | | - |
56 | | - // Call personality function. Wasm does not have two-phase unwinding, so we |
57 | | - // only do the cleanup phase. |
58 | | - return __gxx_personality_wasm0( |
59 | | - 1, _UA_SEARCH_PHASE, exception_object->exception_class, exception_object, |
60 | | - (struct _Unwind_Context *)&__wasm_lpad_context); |
61 | | -} |
| 22 | +_LIBUNWIND_EXPORT thread_local struct _Unwind_LandingPadContext |
| 23 | + __wasm_lpad_context; |
62 | 24 |
|
63 | 25 | /// Called by __cxa_throw. |
64 | 26 | _LIBUNWIND_EXPORT _Unwind_Reason_Code |
|
0 commit comments