mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 18:26:37 +00:00
[WebAssembly] Upstream misc. EH changes (#92990)
This upstreams more recent, mostly EH changes from libcxx and libcxxabi: - `__cxa_init_primary_exception`-related changes made when updating to LLVM 18.1.2 (https://github.com/emscripten-core/emscripten/pull/21638) - Removes ctype macros (https://github.com/emscripten-core/emscripten/pull/20960) - Guard destructor changes with `__wasm__` (https://github.com/emscripten-core/emscripten/pull/21974)
This commit is contained in:
parent
e8dd4df72b
commit
271eb0686b
@ -38,11 +38,14 @@ struct __cxa_exception;
|
||||
_LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception(
|
||||
void*,
|
||||
std::type_info*,
|
||||
void(
|
||||
# if defined(_WIN32)
|
||||
__thiscall
|
||||
void(__thiscall*)(void*)) throw();
|
||||
# elif defined(__wasm__)
|
||||
// In Wasm, a destructor returns its argument
|
||||
void* (*)(void*)) throw();
|
||||
# else
|
||||
void (*)(void*)) throw();
|
||||
# endif
|
||||
*)(void*)) throw();
|
||||
}
|
||||
|
||||
} // namespace __cxxabiv1
|
||||
@ -92,8 +95,16 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
|
||||
using _Ep2 = __decay_t<_Ep>;
|
||||
|
||||
void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep));
|
||||
# ifdef __wasm__
|
||||
// In Wasm, a destructor returns its argument
|
||||
(void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) -> void* {
|
||||
# else
|
||||
(void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) {
|
||||
# endif
|
||||
std::__destroy_at(static_cast<_Ep2*>(__p));
|
||||
# ifdef __wasm__
|
||||
return __p;
|
||||
# endif
|
||||
});
|
||||
|
||||
try {
|
||||
|
@ -343,12 +343,12 @@ public:
|
||||
static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used
|
||||
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
|
||||
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
|
||||
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
# ifdef __APPLE__
|
||||
typedef __uint32_t mask;
|
||||
# elif defined(__FreeBSD__)
|
||||
typedef unsigned long mask;
|
||||
# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)
|
||||
# elif defined(__NetBSD__)
|
||||
typedef unsigned short mask;
|
||||
# endif
|
||||
static const mask space = _CTYPE_S;
|
||||
|
@ -48,13 +48,17 @@ extern _LIBCXXABI_FUNC_VIS void
|
||||
__cxa_free_exception(void *thrown_exception) throw();
|
||||
// This function is an LLVM extension, which mirrors the same extension in libsupc++ and libcxxrt
|
||||
extern _LIBCXXABI_FUNC_VIS __cxa_exception*
|
||||
#ifdef __wasm__
|
||||
// In Wasm, a destructor returns its argument
|
||||
__cxa_init_primary_exception(void* object, std::type_info* tinfo, void*(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
|
||||
#else
|
||||
__cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
|
||||
#endif
|
||||
|
||||
// 2.4.3 Throwing the Exception Object
|
||||
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
|
||||
__cxa_throw(void *thrown_exception, std::type_info *tinfo,
|
||||
#ifdef __WASM_EXCEPTIONS__
|
||||
// In Wasm, a destructor returns its argument
|
||||
#ifdef __wasm__
|
||||
void *(_LIBCXXABI_DTOR_FUNC *dest)(void *));
|
||||
#else
|
||||
void (_LIBCXXABI_DTOR_FUNC *dest)(void *));
|
||||
|
@ -207,7 +207,12 @@ void __cxa_free_exception(void *thrown_object) throw() {
|
||||
}
|
||||
|
||||
__cxa_exception* __cxa_init_primary_exception(void* object, std::type_info* tinfo,
|
||||
#ifdef __wasm__
|
||||
// In Wasm, a destructor returns its argument
|
||||
void *(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw() {
|
||||
#else
|
||||
void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw() {
|
||||
#endif
|
||||
__cxa_exception* exception_header = cxa_exception_from_thrown_object(object);
|
||||
exception_header->referenceCount = 0;
|
||||
exception_header->unexpectedHandler = std::get_unexpected();
|
||||
@ -267,7 +272,7 @@ will call terminate, assuming that there was no handler for the
|
||||
exception.
|
||||
*/
|
||||
void
|
||||
#ifdef __WASM_EXCEPTIONS__
|
||||
#ifdef __wasm__
|
||||
// In Wasm, a destructor returns its argument
|
||||
__cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)) {
|
||||
#else
|
||||
|
@ -43,7 +43,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception {
|
||||
|
||||
// Manage the exception object itself.
|
||||
std::type_info *exceptionType;
|
||||
#ifdef __WASM_EXCEPTIONS__
|
||||
#ifdef __wasm__
|
||||
// In Wasm, a destructor returns its argument
|
||||
void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *);
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user