Skip to content

Commit 2f99850

Browse files
aheejinsbc100
authored andcommitted
[EH/SjLj] Support Wasm EH + Wasm SjLj (#16072)
Now that llvm/llvm-project@eb675e9 has landed, we can use Wasm EH and Wasm SjLj together. This PR - enables Wasm EH + Wasm SjLj combination which was previously banned - unifies `@with_both_exception_handling` and `@with_both_sjlj_handling` into `@with_both_eh_sjlj`. Given that we don't really have a plan to test Wasm EH + Emscripten SjLj combination going forward, which was meant to be only a temporary measure during the period we have only Wasm EH but not Wasm SjLj, I don't think it's worth the hassle of keeping three different decorators like `@with_both_exception_handling`, `@with_both_sjlj_handling`, `@with_both_eh_sjlj`. - adds `@with_both_eh_sjlj` to several more tests that mix EH + SjLj - adds one more test that mixes EH + SjLj - duplicates `test_longjmp` into `test_longjmp_stadnalone`. I couldn't find a way to attach two decorators (`@with_both_eh_sjlj and `@also_with_standalone_wasm`) to a single test. - adds `test_longjmp_with_and_without_exceptions` and `test_exceptions_with_and_without_longjmp`. Fixes #15404.
1 parent 33c40be commit 2f99850

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

system/include/emscripten/bind.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,10 +1884,9 @@ void constant(const char* name, const ConstantType& v) {
18841884
static_cast<double>(asGenericValue(BT::toWireType(v))));
18851885
}
18861886

1887-
} // end namespace emscripten
1887+
// EMSCRIPTEN_BINDINGS simple creates a static constructor function which
1888+
// will get included in the program if the translation unit in which it is
1889+
// define gets linked into the program.
1890+
#define EMSCRIPTEN_BINDINGS(name) __attribute__((constructor)) static void __embind_init_##name(void)
18881891

1889-
#define EMSCRIPTEN_BINDINGS(name) \
1890-
static struct EmscriptenBindingInitializer_##name { \
1891-
EmscriptenBindingInitializer_##name(); \
1892-
} EmscriptenBindingInitializer_##name##_instance; \
1893-
EmscriptenBindingInitializer_##name::EmscriptenBindingInitializer_##name()
1892+
} // end namespace emscripten

system/lib/embind/bind.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ template <typename T> static void register_memory_view(const char* name) {
100100
} // namespace
101101

102102
extern "C" {
103-
void EMSCRIPTEN_KEEPALIVE __embind_register_native_and_builtin_types() {
103+
104+
// Normal initialization, executed through a global constructor. This
105+
// happens on the main thread; pthreads will call it manually, so make
106+
// sure we also export it (via EMSCRIPTEN_KEEPALIVE).
107+
EMSCRIPTEN_KEEPALIVE __attribute__((constructor))
108+
void __embind_register_native_and_builtin_types() {
104109
using namespace emscripten::internal;
105110

106111
_embind_register_void(TypeID<void>::get(), "void");
@@ -161,10 +166,5 @@ void EMSCRIPTEN_KEEPALIVE __embind_register_native_and_builtin_types() {
161166
register_memory_view<long double>("emscripten::memory_view<long double>");
162167
#endif
163168
}
164-
}
165169

166-
EMSCRIPTEN_BINDINGS(native_and_builtin_types) {
167-
// Normal initialization, executed through a global constructor. This
168-
// happens on the main thread; pthreads will call it manually.
169-
__embind_register_native_and_builtin_types();
170-
}
170+
} // extern "C"

0 commit comments

Comments
 (0)