aheejin wrote:

I'm not sure if I understand why this is necessary.

> This is a setjmp-like API that catches JavaScript errors. Its signature is 
> `externref_t __builtin_wasm_js_catch(int *status);` The first time it 
> returns, the return value is `null` and *status is set to 0. If we later call 
> a function that raises a JavaScript error, control jumps back to the most 
> recently executed call to `__builtin_wasm_js_catch()` which this time sets 
> `*status` to 1 and returns the caught JS error.

Why this peculiar workflow? Why don't we catch something in a normal way, like, 
wrapping something with a JS `try` block?

> I think this is a generally useful thing to be able to do to handle errors in 
> `EM_JS` functions, but it is possible to use JS try/catch for that. However, 
> this is necessary in order to catch a SuspendError since it is generated 
> within the import wrapper internally to the runtime and there is no way to 
> catch the SuspendError in JavaScript.

Maybe I don't have the right context on what you're referring to, but
```js
try {
  jsfunc1();
} catch (e) {
  if (e instanceof WebAssembly.SuspendError) {
    // Do something...
  }
}
```
Why doesn't this work?

https://github.com/llvm/llvm-project/pull/153767
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to