-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 1 commit
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 |
|---|---|---|
|
|
@@ -12,7 +12,8 @@ | |
| static uint32_t setjmpId = 0; | ||
|
|
||
| typedef struct TableEntry { | ||
| uint32_t id, label; | ||
| uintptr_t id; | ||
|
Collaborator
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
Member
Author
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); | ||
|
|
@@ -44,9 +45,9 @@ TableEntry* saveSetjmp(uint32_t* env, uint32_t label, TableEntry* table, uint32_ | |
| } | ||
|
|
||
| uint32_t testSetjmp(uint32_t id, TableEntry* table, uint32_t size) { | ||
| uint32_t i = 0, curr; | ||
| 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; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this I think we can maybe avoid this change by moving
longjmpitself into have code and then renaming this functions to just be_emscripten_throw_longjmp:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds really good if possible. But not sure how to resolve this case.
There are two cases we generate a call to
emscripten_longjmpin WebAssemblyLowerEmscriptenEHSjLj pass in LLVM;longjmpcall withemscripten_longjmp: Detail linkemscripten_longjmpis called somewhere in the middle of it: Detail linkThe second case is fine, because we know the two parameters to
emscripten_longjmpwhile generating the call. The first case is tricky, because existinglongjmpcalls can be indirect calls, in which case we don't know those two arguments tolongjmpare. So in that case we just cast the value to the type ofemscripten_longjmp: (i32, i32). Because we don't know the two parameters, we can't generatesetThrewandemscripten_throw_longjmpsequence there. So with this I think it will be hard to removeemscripten_longjmpfunction. WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't suggesting changing anything about codegen. Only that we move this function from js code the c code. It shouldn't be a change the makes any difference to the calling code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I misunderstood what you said, sorry. Yeah, will do.