-
Notifications
You must be signed in to change notification settings - Fork 36
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
spec question; should <dfn>ToWebAssemblyValue</dfn> be updated to include exceptions? #328
Comments
The way to translate JS exceptions into wasm exceptions is to import the JavaScript exception tag. Then you can create a wasm catch with that tag, and when a JS function throws/propagates an exception, the thrown object is passed to wasm as a payload (see step 3.10.3 of create a host function). The reverse happens in step 11.3 of call an exported function. What you can't do though is get an |
This does not appear to address my concern. |
You can pass any JS value as an |
Hum, I'm confused by that statement. A Granted, you cannot directly manipulate an In fact, a JavaScript exception is not special at all. It's just like any other Wasm exception that happens to have the tag |
Yes, all of that is true. I probably should have said that you can't get a unique exnref that corresponds to the original JS throw. Because the exnref is actually created not at the time of the original JS throw, but when the exception propagates into wasm (3.10.3.3 of "create a host function"). Also, in the "sandwich" scenario with interleaved JS and wasm frames, if that same exception propagates back and forth between JS and wasm multiple times in a single unwind, a fresh exnref is actually created each time it goes from JS to wasm (rather than reusing the original one). I don't know of any case where that distinction actually matters though (and it's not observable in JS, and I guess not even in wasm; exnrefs are not eqrefs and you can't really do anything with them other than storing and throwing). When we discussed this before where I suggested that we could also allow passing exnrefs out of wasm by means other than throwing and catching; @rossberg noted the complications around throwing vs just allocating a |
From a potentially inadequate reading of the spec, there seems to be a gap in ToWebAssemblyValue: it does not seem to allow for a JavaScript exception value to be translated into a WebAssembly exception.
Something like this occurs in JSPI when the reject handler is called if the underlying Promise is rejected: it must be mapped (eventually) to a WebAssembly throw.
The text was updated successfully, but these errors were encountered: