You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[EH] Make getCppExceptionThrownValue return thrown value (#17157)
In Emscripten EH, the thrown value by the JS library is the original
user-thrown value itself.
But in Wasm EH, what we throw is an `WebAssembly.Exception` object. You
can use getArg method to get the value thrown. But even this value is
not the actual user-thrown value; in libc++abi, which Wasm EH uses, what
we actually throw is a pointer to something called unwind header,
represented by `_Unwind_Exception`:
https://github.com/emscripten-core/emscripten/blob/1f6b136d75c9a6a89d07ed069b9cede80b39cebd/system/lib/libcxxabi/src/cxa_exception.cpp#L284
The current `getCppExceptionThrownValue` in our JS exception library
returns the `_Unwind_Exception` pointer, which is the value actually
thrown by libc++abi, and not the original user-thrown value. This is
confusing in the first place, and I got requests from users who want to
access the original user-thrown value.
Because of `WebAssembly.Exception` object, we still have some
discrepancy between Emscripten EH and Wasm EH, but I think this is more
intuitive, and it actually simplifies libc++abi code as well.
So the current state:
- Emscripten EH: Throws original user-thrown value
- Wasm EH: Throws `WebAssembly.Exception` object, which contains the
pointer to the unwind header
After this PR:
- Emscripten EH: Throws original user-thrown value
- Wasm EH: Throws `WebAssembly.Exception` object, which contains the
original user-thrown value
0 commit comments