Skip to content

[EH/SjLj] Support Wasm EH + Wasm SjLj #16072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1413,8 +1413,6 @@ def default_setting(name, new_default):
exit_with_error('SUPPORT_LONGJMP=wasm cannot be used with DISABLE_EXCEPTION_CATCHING=0')
if not settings.DISABLE_EXCEPTION_THROWING:
exit_with_error('SUPPORT_LONGJMP=wasm cannot be used with DISABLE_EXCEPTION_THROWING=0')
if settings.EXCEPTION_HANDLING:
exit_with_error('Wasm SjLj is not supported with Wasm exceptions yet')

return (newargs, input_files)

Expand Down
29 changes: 29 additions & 0 deletions tests/core/test_exceptions_longjmp4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <stdio.h>
#include <setjmp.h>

static jmp_buf buf;

void foo() {
throw 3;
}

int main() {
int jmpval = setjmp(buf);
if (jmpval != 0) {
// This is not reached, because foo() doesn't longjmp. This test checks
// compilation of a setjmp call with a nested try.
printf("setjmp returned for the second time\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this reached? I don't see a longjmp in the file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it's not gonna be reached; as well with printf("inner catch: caught %d\n");. These tests check if compilation of mixed setjmp and try-catch work because LLVM backend does heavy transformation on functions that has setjmp calls, so I think it's fine that this line is not reached.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, maybe add a comment then, that this just checks compilation, and it is never reached?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return 0;
}
try {
foo();
try {
foo();
} catch (int n) {
printf("inner catch: caught %d\n", n);
}
} catch (int n) {
printf("outer catch: caught %d\n", n);
}
return 0;
}
1 change: 1 addition & 0 deletions tests/core/test_exceptions_longjmp4.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
outer catch: caught 3
Loading