Skip to content
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

Request for Position: WebAssembly Exception Handling #573

Closed
gahaas opened this issue Aug 27, 2021 · 3 comments
Closed

Request for Position: WebAssembly Exception Handling #573

gahaas opened this issue Aug 27, 2021 · 3 comments

Comments

@gahaas
Copy link

@gahaas gahaas commented Aug 27, 2021

Request for Mozilla Position on WebAssembly Exception Handling

@mconca
Copy link

@mconca mconca commented Aug 30, 2021

@lars-t-hansen
Copy link
Contributor

@lars-t-hansen lars-t-hansen commented Aug 30, 2021

We're talking about it, I'll file something within a day or two.

lars-t-hansen added a commit to lars-t-hansen/standards-positions that referenced this issue Aug 31, 2021
@lars-t-hansen
Copy link
Contributor

@lars-t-hansen lars-t-hansen commented Sep 1, 2021

In #575 I was asked by @tantek for a little more background on our position.

TLDR: we consider exception handling important because it plugs a large gap in the wasm platform, we think the design is good because it is an MVP with few constraints on future growth, and we plan to implement and ship this ourselves.

The feature adds the necessary structure to webassembly to efficiently model the semantics of exception propagation, exception handling, and unwinding (eg for executing destructors). "Efficiency" here has two aspects. Functions or parts of programs that do not need exception handling or unwinding pays nothing in run-time cost (time or memory) for its presence in the language, even when other parts of the same program do use it. At the same time, the design supports an implementation that requires less (on-the-wire) bytecode and (on-device) machine code and metadata than the comparable translation that simulates these semantics using existing wasm structures. (We're still waiting on concrete data from a good implementation to back these claims up but we believe this to be the case, and our own prototype design is aligned with these claims.)

Regarding the importance of the feature: Exception handling has immediate applicability to existing C++ code bases, many of which are built around efficient exception handling to propagate errors and perform unwinding during exception propagation. Partners with large existing code bases have been asking for this feature repeatedly. Exception handling is one of the last missing large pieces for good C++ support in webassembly.

The current design is the result of extensive discussions and prototyping work in the wasm CG and has benefited from considering languages other than C++ (which was initially the only focus). It is a forward-looking MVP; we know it is possible to add tweaks such as "finally" and we believe it is compatible with larger semantic changes such as two-phase exception handling. The current design is likely sufficient to model exceptions in languages such as Java and is forward-compatible to a richer system that can handle languages such as C#. The design is web-aware and it is possible for JS code to interact smoothly with wasm code that uses exceptions.

We are already prototyping this feature (cf intent-to-prototype sent to the old dev-platform@moz by Asumu Takikawa on 25 March 2021, https://groups.google.com/g/mozilla.dev.platform/c/9ioehBRsEnw) and plan to ship it once it is complete and standardized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants