bytecodealliance / jco

JavaScript toolchain for working with WebAssembly Components
https://bytecodealliance.github.io/jco/
Apache License 2.0
619 stars 62 forks source link

Strict trap handling #250

Open guybedford opened 11 months ago

guybedford commented 11 months ago

We should be stricter about traps in jco.

When a component traps it moves into a trapped state and is no longer callable, so this should be a flagged state of the component.

All call validation errors should also be traps as well, trickling up and setting the trapped flag on call calling components.

In the case or exported function validation errors, these do not need to trap as they happen before entering the component.

guybedford commented 10 months ago

Here's my best shot at formal trap semantics:

Even if we don't get to the full trap handling right now, at the very least we can start to formalize WebAssembly.RuntimeError checks as the primary mechanism where traps are being initiated and caught already currently.

guybedford commented 6 months ago

For now, all errors are now TypeError and we added stricter error coercion in the most recent release where only result<_, string> is permitted to coerce JS errors for called functions.

We should still ensure that all type validations are traps though (TypeError at the very least), and working towards that being comprehensively done is an ongoing concern.