Skip to content

Commit cada1eb

Browse files
authored
[EH] __USING_WASM_EXCEPTIONS__ -> __WASM_EXCEPTIONS__ (#21970)
We've decided to change `__USING_WASM_EXCEPTIONS__` preprocessor to `__WASM_EXCEPTIONS__` given that it's more concise.
1 parent 29f5136 commit cada1eb

File tree

8 files changed

+34
-34
lines changed

8 files changed

+34
-34
lines changed

system/lib/libcxxabi/include/cxxabi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXAB
5858
// 2.4.3 Throwing the Exception Object
5959
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
6060
__cxa_throw(void *thrown_exception, std::type_info *tinfo,
61-
#ifdef __USING_WASM_EXCEPTIONS__
61+
#ifdef __WASM_EXCEPTIONS__
6262
void *(_LIBCXXABI_DTOR_FUNC *dest)(void *));
6363
#else
6464
void (_LIBCXXABI_DTOR_FUNC *dest)(void *));

system/lib/libcxxabi/src/cxa_exception.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ void __cxa_free_exception(void *thrown_object) throw() {
207207
}
208208

209209
__cxa_exception* __cxa_init_primary_exception(void* object, std::type_info* tinfo,
210-
#ifdef __USING_WASM_EXCEPTIONS__
210+
#ifdef __WASM_EXCEPTIONS__
211211
// In Wasm, a destructor returns its argument
212212
void *(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw() {
213213
#else
@@ -272,14 +272,14 @@ will call terminate, assuming that there was no handler for the
272272
exception.
273273
*/
274274

275-
#if defined(__EMSCRIPTEN__) && defined(__USING_WASM_EXCEPTIONS__) && !defined(NDEBUG)
275+
#if defined(__EMSCRIPTEN__) && defined(__WASM_EXCEPTIONS__) && !defined(NDEBUG)
276276
extern "C" {
277277
void __throw_exception_with_stack_trace(_Unwind_Exception*);
278278
} // extern "C"
279279
#endif
280280

281281
void
282-
#ifdef __USING_WASM_EXCEPTIONS__
282+
#ifdef __WASM_EXCEPTIONS__
283283
// In Wasm, a destructor returns its argument
284284
__cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)) {
285285
#else
@@ -298,7 +298,7 @@ __cxa_throw(void *thrown_object, std::type_info *tinfo, void (_LIBCXXABI_DTOR_FU
298298

299299
#ifdef __USING_SJLJ_EXCEPTIONS__
300300
_Unwind_SjLj_RaiseException(&exception_header->unwindHeader);
301-
#elif defined(__EMSCRIPTEN__) && defined(__USING_WASM_EXCEPTIONS__) && !defined(NDEBUG)
301+
#elif defined(__EMSCRIPTEN__) && defined(__WASM_EXCEPTIONS__) && !defined(NDEBUG)
302302
// In debug mode, call a JS library function to use WebAssembly.Exception JS
303303
// API, which enables us to include stack traces
304304
__throw_exception_with_stack_trace(&exception_header->unwindHeader);
@@ -651,7 +651,7 @@ void __cxa_rethrow() {
651651
}
652652
#ifdef __USING_SJLJ_EXCEPTIONS__
653653
_Unwind_SjLj_RaiseException(&exception_header->unwindHeader);
654-
#elif defined(__EMSCRIPTEN__) && defined(__USING_WASM_EXCEPTIONS__) && !defined(NDEBUG)
654+
#elif defined(__EMSCRIPTEN__) && defined(__WASM_EXCEPTIONS__) && !defined(NDEBUG)
655655
// In debug mode, call a JS library function to use WebAssembly.Exception JS
656656
// API, which enables us to include stack traces
657657
__throw_exception_with_stack_trace(&exception_header->unwindHeader);
@@ -780,7 +780,7 @@ __cxa_rethrow_primary_exception(void* thrown_object)
780780
dep_exception_header->unwindHeader.exception_cleanup = dependent_exception_cleanup;
781781
#ifdef __USING_SJLJ_EXCEPTIONS__
782782
_Unwind_SjLj_RaiseException(&dep_exception_header->unwindHeader);
783-
#elif defined(__EMSCRIPTEN__) && defined(__USING_WASM_EXCEPTIONS__) && !defined(NDEBUG)
783+
#elif defined(__EMSCRIPTEN__) && defined(__WASM_EXCEPTIONS__) && !defined(NDEBUG)
784784
// In debug mode, call a JS library function to use
785785
// WebAssembly.Exception JS API, which enables us to include stack
786786
// traces

system/lib/libcxxabi/src/cxa_exception.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception {
6363

6464
// Manage the exception object itself.
6565
std::type_info *exceptionType;
66-
#ifdef __USING_WASM_EXCEPTIONS__
66+
#ifdef __WASM_EXCEPTIONS__
6767
// In Wasm, a destructor returns its argument
6868
void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *);
6969
#else

system/lib/libcxxabi/src/cxa_personality.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD,
7070
+------------------+--+-----+-----+------------------------+--------------------------+
7171
| callSiteTableLength | (ULEB128) | Call Site Table length, used to find Action table |
7272
+---------------------+-----------+---------------------------------------------------+
73-
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__)
73+
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__)
7474
+---------------------+-----------+------------------------------------------------+
7575
| Beginning of Call Site Table The current ip lies within the |
7676
| ... (start, length) range of one of these |
@@ -84,7 +84,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD,
8484
| +-------------+---------------------------------+------------------------------+ |
8585
| ... |
8686
+----------------------------------------------------------------------------------+
87-
#else // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__
87+
#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
8888
+---------------------+-----------+------------------------------------------------+
8989
| Beginning of Call Site Table The current ip is a 1-based index into |
9090
| ... this table. Or it is -1 meaning no |
@@ -97,7 +97,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD,
9797
| +-------------+---------------------------------+------------------------------+ |
9898
| ... |
9999
+----------------------------------------------------------------------------------+
100-
#endif // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__
100+
#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
101101
+---------------------------------------------------------------------+
102102
| Beginning of Action Table ttypeIndex == 0 : cleanup |
103103
| ... ttypeIndex > 0 : catch |
@@ -547,7 +547,7 @@ void
547547
set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context,
548548
const scan_results& results)
549549
{
550-
#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__USING_WASM_EXCEPTIONS__)
550+
#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__WASM_EXCEPTIONS__)
551551
#define __builtin_eh_return_data_regno(regno) regno
552552
#elif defined(__ibmxl__)
553553
// 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,
642642
// Get beginning current frame's code (as defined by the
643643
// emitted dwarf code)
644644
uintptr_t funcStart = _Unwind_GetRegionStart(context);
645-
#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__USING_WASM_EXCEPTIONS__)
645+
#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__WASM_EXCEPTIONS__)
646646
if (ip == uintptr_t(-1))
647647
{
648648
// no action
@@ -652,9 +652,9 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
652652
else if (ip == 0)
653653
call_terminate(native_exception, unwind_exception);
654654
// ip is 1-based index into call site table
655-
#else // !__USING_SJLJ_EXCEPTIONS__ && !__USING_WASM_EXCEPTIONS__
655+
#else // !__USING_SJLJ_EXCEPTIONS__ && !__WASM_EXCEPTIONS__
656656
uintptr_t ipOffset = ip - funcStart;
657-
#endif // !__USING_SJLJ_EXCEPTIONS__ && !__USING_WASM_EXCEPTIONS__
657+
#endif // !__USING_SJLJ_EXCEPTIONS__ && !__WASM_EXCEPTIONS__
658658
const uint8_t* classInfo = NULL;
659659
// Note: See JITDwarfEmitter::EmitExceptionTable(...) for corresponding
660660
// dwarf emission
@@ -676,7 +676,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
676676
// Walk call-site table looking for range that
677677
// includes current PC.
678678
uint8_t callSiteEncoding = *lsda++;
679-
#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__USING_WASM_EXCEPTIONS__)
679+
#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__WASM_EXCEPTIONS__)
680680
(void)callSiteEncoding; // Unused when using SjLj/Wasm exceptions
681681
#endif
682682
uint32_t callSiteTableLength = static_cast<uint32_t>(readULEB128(&lsda));
@@ -687,33 +687,33 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
687687
while (callSitePtr < callSiteTableEnd)
688688
{
689689
// There is one entry per call site.
690-
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__)
690+
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__)
691691
// The call sites are non-overlapping in [start, start+length)
692692
// The call sites are ordered in increasing value of start
693693
uintptr_t start = readEncodedPointer(&callSitePtr, callSiteEncoding);
694694
uintptr_t length = readEncodedPointer(&callSitePtr, callSiteEncoding);
695695
uintptr_t landingPad = readEncodedPointer(&callSitePtr, callSiteEncoding);
696696
uintptr_t actionEntry = readULEB128(&callSitePtr);
697697
if ((start <= ipOffset) && (ipOffset < (start + length)))
698-
#else // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__
698+
#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
699699
// ip is 1-based index into this table
700700
uintptr_t landingPad = readULEB128(&callSitePtr);
701701
uintptr_t actionEntry = readULEB128(&callSitePtr);
702702
if (--ip == 0)
703-
#endif // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__
703+
#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
704704
{
705705
// Found the call site containing ip.
706-
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__)
706+
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__)
707707
if (landingPad == 0)
708708
{
709709
// No handler here
710710
results.reason = _URC_CONTINUE_UNWIND;
711711
return;
712712
}
713713
landingPad = (uintptr_t)lpStart + landingPad;
714-
#else // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__
714+
#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
715715
++landingPad;
716-
#endif // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__
716+
#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
717717
results.landingPad = landingPad;
718718
if (actionEntry == 0)
719719
{
@@ -841,15 +841,15 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
841841
action += actionOffset;
842842
} // there is no break out of this loop, only return
843843
}
844-
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__)
844+
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__)
845845
else if (ipOffset < start)
846846
{
847847
// There is no call site for this ip
848848
// Something bad has happened. We should never get here.
849849
// Possible stack corruption.
850850
call_terminate(native_exception, unwind_exception);
851851
}
852-
#endif // !__USING_SJLJ_EXCEPTIONS__ && !__USING_WASM_EXCEPTIONS__
852+
#endif // !__USING_SJLJ_EXCEPTIONS__ && !__WASM_EXCEPTIONS__
853853
} // there might be some tricky cases which break out of this loop
854854

855855
// It is possible that no eh table entry specify how to handle
@@ -906,7 +906,7 @@ _UA_CLEANUP_PHASE
906906
*/
907907

908908
#if !defined(_LIBCXXABI_ARM_EHABI)
909-
#ifdef __USING_WASM_EXCEPTIONS__
909+
#ifdef __WASM_EXCEPTIONS__
910910
_Unwind_Reason_Code __gxx_personality_wasm0
911911
#elif defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)
912912
static _Unwind_Reason_Code __gxx_personality_imp
@@ -975,7 +975,7 @@ __gxx_personality_v0
975975
exc->languageSpecificData = results.languageSpecificData;
976976
exc->catchTemp = reinterpret_cast<void*>(results.landingPad);
977977
exc->adjustedPtr = results.adjustedPtr;
978-
#ifdef __USING_WASM_EXCEPTIONS__
978+
#ifdef __WASM_EXCEPTIONS__
979979
// Wasm only uses a single phase (_UA_SEARCH_PHASE), so save the
980980
// results here.
981981
set_registers(unwind_exception, context, results);

system/lib/libcxxabi/src/private_typeinfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ __base_class_type_info::search_below_dst(__dynamic_cast_info* info,
15331533

15341534
// XXX EMSCRIPTEN
15351535

1536-
#ifndef __USING_WASM_EXCEPTIONS__
1536+
#ifndef __WASM_EXCEPTIONS__
15371537

15381538
// These functions are used by the emscripten-style exception handling
15391539
// mechanism.

system/lib/libunwind/src/Unwind-wasm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "config.h"
1616

17-
#ifdef __USING_WASM_EXCEPTIONS__
17+
#ifdef __WASM_EXCEPTIONS__
1818

1919
#include "unwind.h"
2020
#include <threads.h>
@@ -120,4 +120,4 @@ _Unwind_GetRegionStart(struct _Unwind_Context *context) {
120120
return 0;
121121
}
122122

123-
#endif // defined(__USING_WASM_EXCEPTIONS__)
123+
#endif // defined(__WASM_EXCEPTIONS__)

system/lib/libunwind/src/libunwind.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <sanitizer/asan_interface.h>
2727
#endif
2828

29-
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__)
29+
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__)
3030
#include "AddressSpace.hpp"
3131
#include "UnwindCursor.hpp"
3232

@@ -348,7 +348,7 @@ void __unw_remove_dynamic_eh_frame_section(unw_word_t eh_frame_start) {
348348

349349
#endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
350350
#endif // !defined(__USING_SJLJ_EXCEPTIONS__) &&
351-
// !defined(__USING_WASM_EXCEPTIONS__)
351+
// !defined(__WASM_EXCEPTIONS__)
352352

353353
#ifdef __APPLE__
354354

tools/system_libs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ def get_cflags(self):
15751575
# is not compatible with emscripten exceptions.
15761576
cflags.append('-DLIBCXXABI_SILENT_TERMINATE')
15771577
elif self.eh_mode == Exceptions.WASM:
1578-
cflags.append('-D__USING_WASM_EXCEPTIONS__')
1578+
cflags.append('-D__WASM_EXCEPTIONS__')
15791579
return cflags
15801580

15811581
def get_files(self):
@@ -1652,7 +1652,7 @@ class libcxx(NoExceptLibrary, MTLibrary):
16521652
def get_cflags(self):
16531653
cflags = super().get_cflags()
16541654
if self.eh_mode == Exceptions.WASM:
1655-
cflags.append('-D__USING_WASM_EXCEPTIONS__')
1655+
cflags.append('-D__WASM_EXCEPTIONS__')
16561656
return cflags
16571657

16581658

@@ -1686,7 +1686,7 @@ def get_cflags(self):
16861686
elif self.eh_mode == Exceptions.EMSCRIPTEN:
16871687
cflags.append('-D__USING_EMSCRIPTEN_EXCEPTIONS__')
16881688
elif self.eh_mode == Exceptions.WASM:
1689-
cflags.append('-D__USING_WASM_EXCEPTIONS__')
1689+
cflags.append('-D__WASM_EXCEPTIONS__')
16901690
return cflags
16911691

16921692

0 commit comments

Comments
 (0)