12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- From fd92733b4753ad0efdb916a5aca3742b555c9de0 Mon Sep 17 00:00:00 2001
- From: Sam Clegg <sbc@chromium.org>
- Date: Tue, 6 Dec 2022 17:01:34 -0800
- Subject: [PATCH] Patches from emscripten 3.1.27
- diff --git a/src/cxa_exception.cpp b/src/cxa_exception.cpp
- --- a/src/cxa_exception.cpp
- +++ b/src/cxa_exception.cpp
- @@ -263,6 +263,13 @@ handler, _Unwind_RaiseException may return. In that case, __cxa_throw
- will call terminate, assuming that there was no handler for the
- exception.
- */
- +
- +#if defined(__USING_WASM_EXCEPTIONS__) && !defined(NDEBUG)
- +extern "C" {
- +void __throw_exception_with_stack_trace(_Unwind_Exception*);
- +} // extern "C"
- +#endif
- +
- void
- #ifdef __USING_WASM_EXCEPTIONS__
- // In wasm, destructors return their argument
- @@ -289,11 +296,27 @@ __cxa_throw(void *thrown_object, std::type_info *tinfo, void (_LIBCXXABI_DTOR_FU
- __asan_handle_no_return();
- #endif
-
- +#ifdef __EMSCRIPTEN__
- #ifdef __USING_SJLJ_EXCEPTIONS__
- _Unwind_SjLj_RaiseException(&exception_header->unwindHeader);
- +#elif __USING_WASM_EXCEPTIONS__
- +#ifdef NDEBUG
- + _Unwind_RaiseException(&exception_header->unwindHeader);
- +#else
- + // In debug mode, call a JS library function to use WebAssembly.Exception JS
- + // API, which enables us to include stack traces
- + __throw_exception_with_stack_trace(&exception_header->unwindHeader);
- +#endif
- #else
- _Unwind_RaiseException(&exception_header->unwindHeader);
- #endif
- +#else // !__EMSCRIPTEN__
- +#ifdef __USING_SJLJ_EXCEPTIONS__
- + _Unwind_SjLj_RaiseException(&exception_header->unwindHeader);
- +#else
- + _Unwind_RaiseException(&exception_header->unwindHeader);
- +#endif
- +#endif
- // This only happens when there is no handler, or some unexpected unwinding
- // error happens.
- failed_throw(exception_header);
- diff --git a/src/cxa_personality.cpp b/src/cxa_personality.cpp
- --- a/src/cxa_personality.cpp
- +++ b/src/cxa_personality.cpp
- @@ -977,6 +977,11 @@ __gxx_personality_v0
- exc->languageSpecificData = results.languageSpecificData;
- exc->catchTemp = reinterpret_cast<void*>(results.landingPad);
- exc->adjustedPtr = results.adjustedPtr;
- +#ifdef __USING_WASM_EXCEPTIONS__
- + // Wasm only uses a single phase (_UA_SEARCH_PHASE), so save the
- + // results here.
- + set_registers(unwind_exception, context, results);
- +#endif
- }
- return _URC_HANDLER_FOUND;
- }
- @@ -994,16 +999,6 @@ __gxx_personality_v0
- exception_header->catchTemp = 0;
- #endif
- }
- -#ifdef __USING_WASM_EXCEPTIONS__
- - // Wasm uses only one phase in _UA_CLEANUP_PHASE, so we should set
- - // these here.
- - __cxa_exception* exception_header = (__cxa_exception*)(unwind_exception+1) - 1;
- - exception_header->handlerSwitchValue = static_cast<int>(results.ttypeIndex);
- - exception_header->actionRecord = results.actionRecord;
- - exception_header->languageSpecificData = results.languageSpecificData;
- - exception_header->catchTemp = reinterpret_cast<void*>(results.landingPad);
- - exception_header->adjustedPtr = results.adjustedPtr;
- -#endif
- return _URC_INSTALL_CONTEXT;
- }
-
|