This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] allow EM_ASM to be used with setjmp
AbandonedPublic

Authored by quantum on Jul 26 2019, 4:40 PM.

Details

Summary

Avoid wrapping emscripten_asm_* calls in __invoke_* wrappers, which breaks
EM_ASM. See https://github.com/emscripten-core/emscripten/issues/8894.

Event Timeline

quantum created this revision.Jul 26 2019, 4:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 26 2019, 4:40 PM
quantum edited the summary of this revision. (Show Details)Jul 26 2019, 4:40 PM

Interesting!

To make sure I understand, is the issue that in the presence of a setjmp we turn those calls into invokes, which means in wasm we end up with an indirect call - and then in binaryen we don't see the emscripten_asm_const_int etc., and instead just the indirect call? (Or does the backend do more processing here?)

if so, then I'm not sure this is the correct fix, since EM_ASM calls *may* throw (not just JS exceptions, but also they may call back into compiled code and do a longjmp from there, and that should work). Perhaps what we need to do is, in Binaryen, look at indirect calls and see if they are done with a constant index, and the function at that index is emscripten_asm_const_int? (Maybe this is what you were thinking earlier, and I didn't understand it? Sorry if so!)

quantum abandoned this revision.Jul 26 2019, 5:26 PM

Now that you mention it, it doesn't feel correct to me either. I think the fix would have to be in binaryen.