exception-handling icon indicating copy to clipboard operation
exception-handling copied to clipboard

wast doesn't seem to have a way to test uncaught exception in start function

Open yamt opened this issue 1 year ago • 1 comments

maybe we need to add assert_exception for a module?

yamt avatar Jul 05 '24 08:07 yamt

Usually one can encode such checks in Wasm itself with some wrapper function, but the start function is an interesting exception.

An assert_exception might make sense, the only problem is that there is no obvious way to refer to a specific exception, i.e., a tag, outside of a module. We could have an assertion that cannot check the exception, but that seems a bit half-arsed. Perhaps the tag would have to be identified by a module + export name?

Strawman:

(assert_exception (tag moduleid? "name") value*)

where the values are the exception's expected payload.

But can such an assertion always be translated to JS easily, e.g., if the exception carries a v128? In the case of call results, the interpreter's JS translation synthesises a Wasm wrapper performing the check in such cases, but for exceptions that's a bit more more work and won't directly extend to the implicit invocation of the start function. It would at least require some extra indirection bouncing back between Wasm and JS to wrap a Wasm handler around module instantiation.

rossberg avatar Jul 05 '24 09:07 rossberg