Issue 149086
Summary [WebAssembly] Could C++ EH avoid `catch_ref` and `throw_ref`?
Labels new issue
Assignees
Reporter sunfishcode
    Currently, WebAssemblyLateEHPrepare.cpp rewrites pseudo "rethrow" instructions to `catch_ref` and `throw_ref`.

Would it work to instead rewrite it to `catch` and `throw`, effectively discarding the old exception object and creating a new one? From my reading of the code, it doesn't look like clang/libcxxabi/libunwind/etc. depend on the state or identity of the thrown exception object, so I'm curious if this might work.

Doing this could help Wasm engines that don't implement Wasm GC, as they could then omit `throw_ref`, `catch_ref`, `catch_all_ref`, and `exnref`, while still supporting enough to run C++ exceptions and setjmp/longjmp.

Would it be less efficient? In an engine that omits `catch_ref`/`catch_all_ref`, there wouldn't be any overhead to creating a new exception object because it wouldn't ever need to be reified. In an engine that does implement Wasm GC, optimized implementations often use bump allocation for short-lived objects, and these would be very short-lived objects. It also seems like there might be ways engines could avoid using the GC heap in common cases. But I'm curious what others think.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to