|
@@ -32,6 +32,8 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD,
|
|
|
_Unwind_Personality_Fn);
|
|
|
#endif
|
|
|
|
|
|
+#define __USING_SJLJ_OR_WASM_EXCEPTIONS__ (__USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__)
|
|
|
+
|
|
|
/*
|
|
|
Exception Header Layout:
|
|
|
|
|
@@ -61,7 +63,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD,
|
|
|
+------------------+--+-----+-----+------------------------+--------------------------+
|
|
|
| callSiteTableLength | (ULEB128) | Call Site Table length, used to find Action table |
|
|
|
+---------------------+-----------+---------------------------------------------------+
|
|
|
-#ifndef __USING_SJLJ_EXCEPTIONS__
|
|
|
+#ifndef __USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
+---------------------+-----------+------------------------------------------------+
|
|
|
| Beginning of Call Site Table The current ip lies within the |
|
|
|
| ... (start, length) range of one of these |
|
|
@@ -75,7 +77,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD,
|
|
|
| +-------------+---------------------------------+------------------------------+ |
|
|
|
| ... |
|
|
|
+----------------------------------------------------------------------------------+
|
|
|
-#else // __USING_SJLJ_EXCEPTIONS__
|
|
|
+#else // !__USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
+---------------------+-----------+------------------------------------------------+
|
|
|
| Beginning of Call Site Table The current ip is a 1-based index into |
|
|
|
| ... this table. Or it is -1 meaning no |
|
|
@@ -88,7 +90,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD,
|
|
|
| +-------------+---------------------------------+------------------------------+ |
|
|
|
| ... |
|
|
|
+----------------------------------------------------------------------------------+
|
|
|
-#endif // __USING_SJLJ_EXCEPTIONS__
|
|
|
+#endif // __USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
+---------------------------------------------------------------------+
|
|
|
| Beginning of Action Table ttypeIndex == 0 : cleanup |
|
|
|
| ... ttypeIndex > 0 : catch |
|
|
@@ -538,7 +540,7 @@ void
|
|
|
set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context,
|
|
|
const scan_results& results)
|
|
|
{
|
|
|
-#if defined(__USING_SJLJ_EXCEPTIONS__)
|
|
|
+#ifdef __USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
#define __builtin_eh_return_data_regno(regno) regno
|
|
|
#elif defined(__ibmxl__)
|
|
|
// IBM xlclang++ compiler does not support __builtin_eh_return_data_regno.
|
|
@@ -633,7 +635,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);
|
|
|
-#ifdef __USING_SJLJ_EXCEPTIONS__
|
|
|
+#ifdef __USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
if (ip == uintptr_t(-1))
|
|
|
{
|
|
|
// no action
|
|
@@ -643,9 +645,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__
|
|
|
+#else // !__USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
uintptr_t ipOffset = ip - funcStart;
|
|
|
-#endif // !defined(_USING_SLJL_EXCEPTIONS__)
|
|
|
+#endif // !defined(__USING_SJLJ_OR_WASM_EXCEPTIONS__)
|
|
|
const uint8_t* classInfo = NULL;
|
|
|
// Note: See JITDwarfEmitter::EmitExceptionTable(...) for corresponding
|
|
|
// dwarf emission
|
|
@@ -667,7 +669,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++;
|
|
|
-#ifdef __USING_SJLJ_EXCEPTIONS__
|
|
|
+#ifdef __USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
(void)callSiteEncoding; // When using SjLj exceptions, callSiteEncoding is never used
|
|
|
#endif
|
|
|
uint32_t callSiteTableLength = static_cast<uint32_t>(readULEB128(&lsda));
|
|
@@ -678,7 +680,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
|
|
|
while (callSitePtr < callSiteTableEnd)
|
|
|
{
|
|
|
// There is one entry per call site.
|
|
|
-#ifndef __USING_SJLJ_EXCEPTIONS__
|
|
|
+#ifndef __USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
// 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);
|
|
@@ -686,15 +688,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__
|
|
|
+#else // __USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
// 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__
|
|
|
+#endif // __USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
{
|
|
|
// Found the call site containing ip.
|
|
|
-#ifndef __USING_SJLJ_EXCEPTIONS__
|
|
|
+#ifndef __USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
if (landingPad == 0)
|
|
|
{
|
|
|
// No handler here
|
|
@@ -702,9 +704,9 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
|
|
|
return;
|
|
|
}
|
|
|
landingPad = (uintptr_t)lpStart + landingPad;
|
|
|
-#else // __USING_SJLJ_EXCEPTIONS__
|
|
|
+#else // __USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
++landingPad;
|
|
|
-#endif // __USING_SJLJ_EXCEPTIONS__
|
|
|
+#endif // __USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
results.landingPad = landingPad;
|
|
|
if (actionEntry == 0)
|
|
|
{
|
|
@@ -832,7 +834,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
|
|
|
action += actionOffset;
|
|
|
} // there is no break out of this loop, only return
|
|
|
}
|
|
|
-#ifndef __USING_SJLJ_EXCEPTIONS__
|
|
|
+#ifndef __USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
else if (ipOffset < start)
|
|
|
{
|
|
|
// There is no call site for this ip
|
|
@@ -840,7 +842,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__
|
|
|
+#endif // !__USING_SJLJ_OR_WASM_EXCEPTIONS__
|
|
|
} // there might be some tricky cases which break out of this loop
|
|
|
|
|
|
// It is possible that no eh table entry specify how to handle
|
|
@@ -897,7 +899,9 @@ _UA_CLEANUP_PHASE
|
|
|
*/
|
|
|
|
|
|
#if !defined(_LIBCXXABI_ARM_EHABI)
|
|
|
-#if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)
|
|
|
+#ifdef __USING_WASM_EXCEPTIONS__
|
|
|
+_Unwind_Reason_Code __gxx_personality_wasm0
|
|
|
+#elif defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)
|
|
|
static _Unwind_Reason_Code __gxx_personality_imp
|
|
|
#else
|
|
|
_LIBCXXABI_FUNC_VIS _Unwind_Reason_Code
|
|
@@ -962,6 +966,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;
|
|
|
}
|