Skip to content

Commit 33c40be

Browse files
authored
[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 89eef69 commit 33c40be

File tree

4 files changed

+142
-82
lines changed

4 files changed

+142
-82
lines changed

emcc.py

-2
Original file line numberDiff line numberDiff line change
@@ -1413,8 +1413,6 @@ def default_setting(name, new_default):
14131413
exit_with_error('SUPPORT_LONGJMP=wasm cannot be used with DISABLE_EXCEPTION_CATCHING=0')
14141414
if not settings.DISABLE_EXCEPTION_THROWING:
14151415
exit_with_error('SUPPORT_LONGJMP=wasm cannot be used with DISABLE_EXCEPTION_THROWING=0')
1416-
if settings.EXCEPTION_HANDLING:
1417-
exit_with_error('Wasm SjLj is not supported with Wasm exceptions yet')
14181416

14191417
return (newargs, input_files)
14201418

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <stdio.h>
2+
#include <setjmp.h>
3+
4+
static jmp_buf buf;
5+
6+
void foo() {
7+
throw 3;
8+
}
9+
10+
int main() {
11+
int jmpval = setjmp(buf);
12+
if (jmpval != 0) {
13+
// This is not reached, because foo() doesn't longjmp. This test checks
14+
// compilation of a setjmp call with a nested try.
15+
printf("setjmp returned for the second time\n");
16+
return 0;
17+
}
18+
try {
19+
foo();
20+
try {
21+
foo();
22+
} catch (int n) {
23+
printf("inner catch: caught %d\n", n);
24+
}
25+
} catch (int n) {
26+
printf("outer catch: caught %d\n", n);
27+
}
28+
return 0;
29+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
outer catch: caught 3

0 commit comments

Comments
 (0)