Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions system/lib/libcxxabi/src/cxa_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion system/lib/libcxxabi/src/cxa_exception_emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions system/lib/libcxxabi/src/cxa_exception_js_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -87,7 +87,7 @@ void __get_exception_message(void* thrown_object, char** type, char** message) {
static_cast<const __shim_type_info*>(&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)
Expand Down
36 changes: 18 additions & 18 deletions system/lib/libcxxabi/src/cxa_personality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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<uint32_t>(readULEB128(&lsda));
Expand All @@ -687,33 +687,33 @@ 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);
uintptr_t length = readEncodedPointer(&callSitePtr, callSiteEncoding);
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
results.reason = _URC_CONTINUE_UNWIND;
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)
{
Expand Down Expand Up @@ -839,15 +839,15 @@ 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
// Something bad has happened. We should never get here.
// 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -973,7 +973,7 @@ __gxx_personality_v0
exc->languageSpecificData = results.languageSpecificData;
exc->catchTemp = reinterpret_cast<void*>(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);
Expand Down
5 changes: 2 additions & 3 deletions system/lib/libcxxabi/src/private_typeinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -1602,5 +1602,4 @@ void *__cxa_get_exception_ptr(void *thrown_object) throw() {

} // __cxxabiv1

#endif // __wasm__ && !__WASM_EXCEPTIONS__

#endif // __wasm__ && !__wasm_exception_handling__
4 changes: 2 additions & 2 deletions system/lib/libunwind/src/Unwind-wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "config.h"

#ifdef __WASM_EXCEPTIONS__
#ifdef __wasm_exception_handling__

#include "unwind.h"
#include <threads.h>
Expand Down Expand Up @@ -120,4 +120,4 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) {
return 0;
}

#endif // defined(__WASM_EXCEPTIONS__)
#endif // defined(__wasm_exception_handling__)
6 changes: 0 additions & 6 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some reason why this one is only comparing with WASM_LEGACY and not WASM?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I forgot to update it. But anyway this is not necessary because we define it in the clang preprocessor: https://github.com/llvm/llvm-project/blob/82acc31fd4b26723b61dae76da120c0c649d0b97/clang/lib/Frontend/InitPreprocessor.cpp#L1034-L1035
So if we are to change the name we have to update this too.

cflags.append('-D__WASM_EXCEPTIONS__')
return cflags

def get_files(self):
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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


Expand Down