-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Support Emscripten EH/SjLj in Wasm64 #14108
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,15 +9,19 @@ | |
#include <stdlib.h> | ||
#include <setjmp.h> | ||
|
||
static uint32_t setjmpId = 0; | ||
// 0 - Nothing thrown | ||
// 1 - Exception thrown | ||
// Other values - jmpbuf pointer in the case that longjmp was thrown | ||
static uintptr_t setjmpId = 0; | ||
|
||
typedef struct TableEntry { | ||
uint32_t id, label; | ||
uintptr_t id; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this is an auto-incrementing counter.. set from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's tricky... It looks I need to turn even more variables into
5 was missing in this PR so I added it too. Not sure if this propagation of |
||
uint32_t label; | ||
} TableEntry; | ||
|
||
extern void setTempRet0(uint32_t value); | ||
|
||
TableEntry* saveSetjmp(uint32_t* env, uint32_t label, TableEntry* table, uint32_t size) { | ||
TableEntry* saveSetjmp(uintptr_t* env, uint32_t label, TableEntry* table, uint32_t size) { | ||
// Not particularly fast: slow table lookup of setjmpId to label. But setjmp | ||
// prevents relooping anyhow, so slowness is to be expected. And typical case | ||
// is 1 setjmp per invocation, or less. | ||
|
@@ -43,10 +47,10 @@ TableEntry* saveSetjmp(uint32_t* env, uint32_t label, TableEntry* table, uint32_ | |
return table; | ||
} | ||
|
||
uint32_t testSetjmp(uint32_t id, TableEntry* table, uint32_t size) { | ||
uint32_t i = 0, curr; | ||
uint32_t testSetjmp(uintptr_t id, TableEntry* table, uint32_t size) { | ||
uint32_t i = 0; | ||
while (i < size) { | ||
uint32_t curr = table[i].id; | ||
uintptr_t curr = table[i].id; | ||
if (curr == 0) break; | ||
if (curr == id) { | ||
return table[i].label; | ||
|
@@ -55,3 +59,8 @@ uint32_t testSetjmp(uint32_t id, TableEntry* table, uint32_t size) { | |
} | ||
return 0; | ||
} | ||
|
||
void emscripten_longjmp(uintptr_t env, int val) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool... I tried this but I got some odd crashed in the compiler.. but if this works that is great! |
||
setThrew(env, val || 1); | ||
aheejin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
emscripten_throw_longjmp(); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.