This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Error out for setjmp within catch clause for Wasm SjLj
ClosedPublic

Authored by aheejin on Jan 26 2022, 2:27 PM.

Details

Summary

Wasm EH, used with either of Emscripten SjLj or Wasm SjLj, does not
allow setjmp calls to be placed within a catch clause, because we
don't support jumping into a catch block. Emscripten EH does not have
this restriction. But I think this restriction wouldn't prevent most of
use cases. This CL errors out with a clear messsage for this case.

Diff Detail

Event Timeline

aheejin created this revision.Jan 26 2022, 2:27 PM
aheejin requested review of this revision.Jan 26 2022, 2:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2022, 2:27 PM
aheejin updated this revision to Diff 403410.Jan 26 2022, 2:38 PM

Remove debug dump line

Wasm EH, used with either of Emscripten EH or Wasm EH, does not allow
Do you mean "Wasm SjLj?"

aheejin updated this revision to Diff 403411.Jan 26 2022, 2:39 PM

Cosmetic changes in the test

kripken accepted this revision.Jan 26 2022, 2:51 PM

Seems reasonable to me, this restriction doesn't worry me, and great to have a clear error.

This revision is now accepted and ready to land.Jan 26 2022, 2:51 PM
aheejin added a comment.EditedJan 26 2022, 3:58 PM

Wasm EH, used with either of Emscripten EH or Wasm EH, does not allow
Do you mean "Wasm SjLj?"

The main culprit(?) is Wasm EH. This doesn't work for Wasm EH + Emscripten SjLj either. But Wasm EH + Emscripten SjLj, which was never meant to be a final recommended way to use EH + SjLj but was used as an interim step until Wasm SjLj is not done, even has a broader restriction, so using setjmp with try-catch within the same function will fail anyway.

dschuff added a comment.EditedJan 26 2022, 4:11 PM

Mostly I was confused by the fact that it says Wasm EH "used with" either Emscripten EH (which doesn't make sense) or Wasm EH (redundant). But I guess you mean the wasm EH primitive, used to implement C++ EH and setjmp/longjmp?

dschuff accepted this revision.Jan 26 2022, 4:11 PM

The code, test and the behavior LGTM though.

aheejin edited the summary of this revision. (Show Details)Jan 27 2022, 1:33 PM

Mostly I was confused by the fact that it says Wasm EH "used with" either Emscripten EH (which doesn't make sense) or Wasm EH (redundant). But I guess you mean the wasm EH primitive, used to implement C++ EH and setjmp/longjmp?

Oh sorry, what I meant was "Wasm EH used with either Emscripten SjLj or Wasm SjLj". I fixed the CL description too.