This repository was archived by the owner on Apr 25, 2025. It is now read-only.
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
Proposed exnref value type semantics #282
Closed
Description
I don't believe this was discussed elsewhere, apologies if I missed it.
Here's a proposal for the semantics of the new exnref value type.
- Contains any reference that a wasm
catch
orcatch_all
may receive- In browsers this is a union of any JS value (primitives included) and any wasm exception reference
- On other hosts this may just be a limited exception object hierarchy and not included primitives
- New top type, creating an independent type hierarchy
- JS-API
ToWebAssemblyValue(value, 'exnref')
succeeds for any value (like externref)- This is due to every JS value being a possible thrown value in JS hosts
- JS-API
ToJSValue(value, 'exnref')
succeeds for any value (like externref) - Add an
extern.convert_exn
instruction for getting an externref from an exnref - Add an
any.convert_exn
instruction for getting an anyref from an exnref - With GC: introduce a
noexn
heap type to mirror the other bottom types - With GC: introduce a
nullexnref
alias for(ref null noexn)
- With GC:
ref.cast exnref/nullexnref
are valid instructions similar, but do very little like in the externref hierarchy.
Note, there is no exn.convert_any
or exn.convert_extern
as we don't want to assume in core wasm that exnref
can hold any host value. That's true on JS hosts though, which is why the JS-API allows conversions on the boundary.
Did I miss anything?
There is a world where we do something more conservative and don't allow exnref in ToWebAssemblyValue
ToJSValue
or introduce the conversion instructions. But I don't think they are much work, and would be useful.
Metadata
Metadata
Assignees
Labels
No labels