diff --git a/system/lib/libcxxabi/src/cxa_exception.cpp b/system/lib/libcxxabi/src/cxa_exception.cpp index 4b82d0bf066ee..33e5a4d7d4dbf 100644 --- a/system/lib/libcxxabi/src/cxa_exception.cpp +++ b/system/lib/libcxxabi/src/cxa_exception.cpp @@ -272,7 +272,7 @@ will call terminate, assuming that there was no handler for the exception. */ -#if defined(__EMSCRIPTEN__) && defined(__WASM_EXCEPTIONS__) && !defined(NDEBUG) +#if defined(__EMSCRIPTEN__) && defined(__wasm_exception_handling__) && !defined(NDEBUG) extern "C" { void __throw_exception_with_stack_trace(_Unwind_Exception*); } // extern "C" @@ -298,7 +298,7 @@ __cxa_throw(void *thrown_object, std::type_info *tinfo, void (_LIBCXXABI_DTOR_FU #ifdef __USING_SJLJ_EXCEPTIONS__ _Unwind_SjLj_RaiseException(&exception_header->unwindHeader); -#elif defined(__EMSCRIPTEN__) && defined(__WASM_EXCEPTIONS__) && !defined(NDEBUG) +#elif defined(__EMSCRIPTEN__) && defined(__wasm_exception_handling__) && !defined(NDEBUG) // 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); @@ -656,7 +656,7 @@ void __cxa_rethrow() { } #ifdef __USING_SJLJ_EXCEPTIONS__ _Unwind_SjLj_RaiseException(&exception_header->unwindHeader); -#elif defined(__EMSCRIPTEN__) && defined(__WASM_EXCEPTIONS__) && !defined(NDEBUG) +#elif defined(__EMSCRIPTEN__) && defined(__wasm_exception_handling__) && !defined(NDEBUG) // 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); @@ -785,7 +785,7 @@ __cxa_rethrow_primary_exception(void* thrown_object) dep_exception_header->unwindHeader.exception_cleanup = dependent_exception_cleanup; #ifdef __USING_SJLJ_EXCEPTIONS__ _Unwind_SjLj_RaiseException(&dep_exception_header->unwindHeader); -#elif defined(__EMSCRIPTEN__) && defined(__WASM_EXCEPTIONS__) && !defined(NDEBUG) +#elif defined(__EMSCRIPTEN__) && defined(__wasm_exception_handling__) && !defined(NDEBUG) // In debug mode, call a JS library function to use // WebAssembly.Exception JS API, which enables us to include stack // traces diff --git a/system/lib/libcxxabi/src/cxa_exception_emscripten.cpp b/system/lib/libcxxabi/src/cxa_exception_emscripten.cpp index 20a3ba56816c0..b9b9feaf9ff61 100644 --- a/system/lib/libcxxabi/src/cxa_exception_emscripten.cpp +++ b/system/lib/libcxxabi/src/cxa_exception_emscripten.cpp @@ -21,7 +21,7 @@ #include "stdio.h" #include "assert.h" -#ifdef __WASM_EXCEPTIONS__ +#ifdef __wasm_exception_handling__ #error "This file should only be included when building with emscripten exceptions" #endif diff --git a/system/lib/libcxxabi/src/cxa_exception_js_utils.cpp b/system/lib/libcxxabi/src/cxa_exception_js_utils.cpp index 05d908d45577d..c4227c24ba740 100644 --- a/system/lib/libcxxabi/src/cxa_exception_js_utils.cpp +++ b/system/lib/libcxxabi/src/cxa_exception_js_utils.cpp @@ -39,7 +39,7 @@ static inline __cxa_exception* cxa_exception_from_unwind_exception( return cxa_exception_from_thrown_object(unwind_exception + 1); } -#ifdef __WASM_EXCEPTIONS__ +#ifdef __wasm_exception_handling__ struct __cxa_dependent_exception; uint64_t __getExceptionClass(const _Unwind_Exception* unwind_exception); static bool isDependentException(_Unwind_Exception* unwind_exception) { @@ -87,7 +87,7 @@ void __get_exception_message(void* thrown_object, char** type, char** message) { static_cast(&typeid(std::exception)); int can_catch = catch_type->can_catch(thrown_type, thrown_object); if (can_catch) { -#if __WASM_EXCEPTIONS__ +#if __wasm_exception_handling__ if (isDependentException(&exception_header->unwindHeader)) { thrown_object = reinterpret_cast<__cxa_dependent_exception*>(exception_header) diff --git a/system/lib/libcxxabi/src/cxa_personality.cpp b/system/lib/libcxxabi/src/cxa_personality.cpp index 1dc47b6d8bc1b..e1321e3fff916 100644 --- a/system/lib/libcxxabi/src/cxa_personality.cpp +++ b/system/lib/libcxxabi/src/cxa_personality.cpp @@ -70,7 +70,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, +------------------+--+-----+-----+------------------------+--------------------------+ | callSiteTableLength | (ULEB128) | Call Site Table length, used to find Action table | +---------------------+-----------+---------------------------------------------------+ -#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__) +#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm_exception_handling__) +---------------------+-----------+------------------------------------------------+ | Beginning of Call Site Table The current ip lies within the | | ... (start, length) range of one of these | @@ -84,7 +84,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, | +-------------+---------------------------------+------------------------------+ | | ... | +----------------------------------------------------------------------------------+ -#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +#else // __USING_SJLJ_EXCEPTIONS__ || __wasm_exception_handling__ +---------------------+-----------+------------------------------------------------+ | Beginning of Call Site Table The current ip is a 1-based index into | | ... this table. Or it is -1 meaning no | @@ -97,7 +97,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, | +-------------+---------------------------------+------------------------------+ | | ... | +----------------------------------------------------------------------------------+ -#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +#endif // __USING_SJLJ_EXCEPTIONS__ || __wasm_exception_handling__ +---------------------------------------------------------------------+ | Beginning of Action Table ttypeIndex == 0 : cleanup | | ... ttypeIndex > 0 : catch | @@ -547,7 +547,7 @@ void set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context, const scan_results& results) { -#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__WASM_EXCEPTIONS__) +#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__wasm_exception_handling__) #define __builtin_eh_return_data_regno(regno) regno #elif defined(__ibmxl__) // IBM xlclang++ compiler does not support __builtin_eh_return_data_regno. @@ -642,7 +642,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions, // Get beginning current frame's code (as defined by the // emitted dwarf code) uintptr_t funcStart = _Unwind_GetRegionStart(context); -#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__WASM_EXCEPTIONS__) +#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__wasm_exception_handling__) if (ip == uintptr_t(-1)) { // no action @@ -652,9 +652,9 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions, else if (ip == 0) call_terminate(native_exception, unwind_exception); // ip is 1-based index into call site table -#else // !__USING_SJLJ_EXCEPTIONS__ && !__WASM_EXCEPTIONS__ +#else // !__USING_SJLJ_EXCEPTIONS__ && !__wasm_exception_handling__ uintptr_t ipOffset = ip - funcStart; -#endif // !__USING_SJLJ_EXCEPTIONS__ && !__WASM_EXCEPTIONS__ +#endif // !__USING_SJLJ_EXCEPTIONS__ && !__wasm_exception_handling__ const uint8_t* classInfo = NULL; // Note: See JITDwarfEmitter::EmitExceptionTable(...) for corresponding // dwarf emission @@ -676,7 +676,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions, // Walk call-site table looking for range that // includes current PC. uint8_t callSiteEncoding = *lsda++; -#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__WASM_EXCEPTIONS__) +#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__wasm_exception_handling__) (void)callSiteEncoding; // Unused when using SjLj/Wasm exceptions #endif uint32_t callSiteTableLength = static_cast(readULEB128(&lsda)); @@ -687,7 +687,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions, while (callSitePtr < callSiteTableEnd) { // There is one entry per call site. -#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__) +#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm_exception_handling__) // The call sites are non-overlapping in [start, start+length) // The call sites are ordered in increasing value of start uintptr_t start = readEncodedPointer(&callSitePtr, callSiteEncoding); @@ -695,15 +695,15 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions, uintptr_t landingPad = readEncodedPointer(&callSitePtr, callSiteEncoding); uintptr_t actionEntry = readULEB128(&callSitePtr); if ((start <= ipOffset) && (ipOffset < (start + length))) -#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +#else // __USING_SJLJ_EXCEPTIONS__ || __wasm_exception_handling__ // ip is 1-based index into this table uintptr_t landingPad = readULEB128(&callSitePtr); uintptr_t actionEntry = readULEB128(&callSitePtr); if (--ip == 0) -#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +#endif // __USING_SJLJ_EXCEPTIONS__ || __wasm_exception_handling__ { // Found the call site containing ip. -#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__) +#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm_exception_handling__) if (landingPad == 0) { // No handler here @@ -711,9 +711,9 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions, return; } landingPad = (uintptr_t)lpStart + landingPad; -#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +#else // __USING_SJLJ_EXCEPTIONS__ || __wasm_exception_handling__ ++landingPad; -#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__ +#endif // __USING_SJLJ_EXCEPTIONS__ || __wasm_exception_handling__ results.landingPad = landingPad; if (actionEntry == 0) { @@ -839,7 +839,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions, action += actionOffset; } // there is no break out of this loop, only return } -#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__) +#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm_exception_handling__) else if (ipOffset < start) { // There is no call site for this ip @@ -847,7 +847,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions, // Possible stack corruption. call_terminate(native_exception, unwind_exception); } -#endif // !__USING_SJLJ_EXCEPTIONS__ && !__WASM_EXCEPTIONS__ +#endif // !__USING_SJLJ_EXCEPTIONS__ && !__wasm_exception_handling__ } // there might be some tricky cases which break out of this loop // It is possible that no eh table entry specify how to handle @@ -904,7 +904,7 @@ _UA_CLEANUP_PHASE */ #if !defined(_LIBCXXABI_ARM_EHABI) -#ifdef __WASM_EXCEPTIONS__ +#ifdef __wasm_exception_handling__ _Unwind_Reason_Code __gxx_personality_wasm0 #elif defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__) static _Unwind_Reason_Code __gxx_personality_imp @@ -973,7 +973,7 @@ __gxx_personality_v0 exc->languageSpecificData = results.languageSpecificData; exc->catchTemp = reinterpret_cast(results.landingPad); exc->adjustedPtr = results.adjustedPtr; -#ifdef __WASM_EXCEPTIONS__ +#ifdef __wasm_exception_handling__ // Wasm only uses a single phase (_UA_SEARCH_PHASE), so save the // results here. set_registers(unwind_exception, context, results); diff --git a/system/lib/libcxxabi/src/private_typeinfo.cpp b/system/lib/libcxxabi/src/private_typeinfo.cpp index 750375e5c5e00..06cd70c110960 100644 --- a/system/lib/libcxxabi/src/private_typeinfo.cpp +++ b/system/lib/libcxxabi/src/private_typeinfo.cpp @@ -1547,7 +1547,7 @@ __base_class_type_info::search_below_dst(__dynamic_cast_info* info, // XXX EMSCRIPTEN -#if defined(__wasm__) && !defined(__WASM_EXCEPTIONS__) +#if defined(__wasm__) && !defined(__wasm_exception_handling__) #include "cxa_exception.h" @@ -1602,5 +1602,4 @@ void *__cxa_get_exception_ptr(void *thrown_object) throw() { } // __cxxabiv1 -#endif // __wasm__ && !__WASM_EXCEPTIONS__ - +#endif // __wasm__ && !__wasm_exception_handling__ diff --git a/system/lib/libunwind/src/Unwind-wasm.c b/system/lib/libunwind/src/Unwind-wasm.c index b18b32c5d1784..b21348acc90e8 100644 --- a/system/lib/libunwind/src/Unwind-wasm.c +++ b/system/lib/libunwind/src/Unwind-wasm.c @@ -14,7 +14,7 @@ #include "config.h" -#ifdef __WASM_EXCEPTIONS__ +#ifdef __wasm_exception_handling__ #include "unwind.h" #include @@ -120,4 +120,4 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) { return 0; } -#endif // defined(__WASM_EXCEPTIONS__) +#endif // defined(__wasm_exception_handling__) diff --git a/tools/system_libs.py b/tools/system_libs.py index 1d88c31a29dfd..d17c049405147 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -1640,8 +1640,6 @@ def get_cflags(self): # The code used to interpret exceptions during terminate # is not compatible with emscripten exceptions. cflags.append('-DLIBCXXABI_SILENT_TERMINATE') - elif self.eh_mode == Exceptions.WASM_LEGACY: - cflags.append('-D__WASM_EXCEPTIONS__') return cflags def get_files(self): @@ -1721,8 +1719,6 @@ class libcxx(ExceptionLibrary, MTLibrary, DebugLibrary): def get_cflags(self): cflags = super().get_cflags() - if self.eh_mode in (Exceptions.WASM_LEGACY, Exceptions.WASM): - cflags.append('-D__WASM_EXCEPTIONS__') return cflags @@ -1755,8 +1751,6 @@ def get_cflags(self): cflags.append('-D_LIBUNWIND_HAS_NO_EXCEPTIONS') elif self.eh_mode == Exceptions.EMSCRIPTEN: cflags.append('-D__EMSCRIPTEN_EXCEPTIONS__') - elif self.eh_mode in (Exceptions.WASM_LEGACY, Exceptions.WASM): - cflags.append('-D__WASM_EXCEPTIONS__') return cflags