Skip to content

Support Emscripten EH/SjLj in Wasm64 #14357

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 1 commit into from
Jun 3, 2021
Merged

Conversation

aheejin
Copy link
Member

@aheejin aheejin commented Jun 3, 2021

This mostly changes some uint32_ts to uintptr_t in libraries for EH
and SjLj to support wasm64.

More details in case you are interested:

  1. I described in https://reviews.llvm.org/D101985 how changing the
    first argument of emscripten_longjmp in turn changed testSetjmp's
    first argument to uintptr_t.
  2. testSetjmp's first argument id is compared with the local
    variable curr. So it's uintptr_t now:
    Link
  3. That curr is set from table[i].id, which is TableEntry.id. So
    id in TableEntry here is now uintptr_t:
    Link
  4. Because table[i].id is set from setjmpId, setjmpId needs to be
    uintptr_t too:
    Link
  5. Because setjmpId is stored in env (first parameter) in
    saveSetjmp, saveSetjmp's first argument has to change to
    uintptr_t:
    Link

Not sure how to add tests for this given that wasm64 support is not
ready yet. Existing tests run fine.

This mostly changes some `uint32_t`s to `uintptr_t` in libraries for EH
and SjLj to support wasm64.

More details in case you are interested:
1. I described in https://reviews.llvm.org/D101985 how changing the
   first argument of `emscripten_longjmp` in turn changed `testSetjmp`'s
   first argument to `uintptr_t`.
2. `testSetjmp`'s first argument `id` is compared with the local
   variable `curr`. So it's `uintptr_t` now:
   [Link](https://github.com/emscripten-core/emscripten/blob/aa2bad5d6a0de5b175688fc8ead46f70a1b43a0d/system/lib/compiler-rt/emscripten_setjmp.c#L53)
3. That `curr` is set from `table[i].id`, which is `TableEntry.id`. So
   `id` in `TableEntry` here is now `uintptr_t`:
   [Link](https://github.com/emscripten-core/emscripten/blob/aa2bad5d6a0de5b175688fc8ead46f70a1b43a0d/system/lib/compiler-rt/emscripten_setjmp.c#L51)
4. Because `table[i].id` is set from `setjmpId`, `setjmpId` needs to be
   `uintptr_t` too:
   [Link](https://github.com/emscripten-core/emscripten/blob/aa2bad5d6a0de5b175688fc8ead46f70a1b43a0d/system/lib/compiler-rt/emscripten_setjmp.c#L31)
5. Because `setjmpId` is stored in `env` (first parameter) in
   `saveSetjmp`, `saveSetjmp`'s first argument has to change to
   `uintptr_t`:
   [Link](https://github.com/emscripten-core/emscripten/blob/aa2bad5d6a0de5b175688fc8ead46f70a1b43a0d/system/lib/compiler-rt/emscripten_setjmp.c#L28)

Not sure how to add tests for this given that wasm64 support is not
ready yet. Existing tests run fine.
@aheejin aheejin requested review from sbc100 and aardappel June 3, 2021 05:42
@aheejin
Copy link
Member Author

aheejin commented Jun 3, 2021

This is the second half of #14108.

@aheejin aheejin merged commit 8f38f35 into emscripten-core:main Jun 3, 2021
@aheejin aheejin deleted the wasm64_eh branch June 3, 2021 18:56
@aardappel
Copy link
Collaborator

nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants