cfallin requested fitzgen for a review on PR #12861.
cfallin requested wasmtime-core-reviewers for a review on PR #12861.
cfallin opened PR #12861 from cfallin:exceptions-c-api to bytecodealliance:main:
This PR implements C (and C++) API support for Wasm exceptions, one final remaining hurdle (aside from fuzz-testing) for making exceptions tier-1 and on-by-default.
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
github-actions[bot] added the label wasmtime:c-api on PR #12861.
cfallin updated PR #12861.
cfallin updated PR #12861.
alexcrichton created PR review comment:
Similar to below, these don't exist in C headers (not yet at least), so it should be ok to drop these
alexcrichton created PR review comment:
Mind also adding
tag.hhere?
alexcrichton created PR review comment:
s/&mut Tag/&mut MaybeUninit<Tag>/(it may not yet be initialized)
alexcrichton submitted PR review.
alexcrichton created PR review comment:
I think these functions don't exist in headers?
This should in theory exist in
wasm.hbutwasm.hdoesn't support tags. In the meantime can these be added under awasmtime_*prefix in thewasmtime/tag.hheader?
alexcrichton created PR review comment:
I had no idea
friendfunctions existed...The design of the C++ API has changed a bit over time where originally C-API-stuff was aggressively kept private, necessitating
friends here, but nowadays most C-API-bits are public. For example nowadays there'scapi()functions below to get the raw pointer out. Could that be used instead of adding morefreinds here? (I haven't ever gotten around to going back and removing allfriends entirely)
alexcrichton created PR review comment:
How come this takes both a
tagand atag_type? Could thetag_typebe inferred from thetag?
alexcrichton created PR review comment:
I'd recommend moving this all into
handle_resultbelow to enable using?inExnType::from_tag_typefor example
alexcrichton created PR review comment:
Can this document that
val_retmust be deallocated by the caller? Or basically that it's owned by the caller.
alexcrichton created PR review comment:
How come this was added? (I'd expect to see other changes here too)
alexcrichton created PR review comment:
Like above, should this have a scope on it?
alexcrichton created PR review comment:
It's ok to drop all the doc comments on the C API functions, they're basically redudant with the C API documentation and IMO don't buy much here (it's just annoying to handwrite all the duplication)
alexcrichton created PR review comment:
Should this have a scope above it to avoid permanently rooting the returned exception?
alexcrichton created PR review comment:
Or, alternatively, just drop these entirely. I think this is the only use of
wasm_tag_t(which also doesn't exist in C headers), so I think that type could be dropped too?
alexcrichton created PR review comment:
I think this (and maybe other header files?) will want a guard with
WASMTIME_FEATURE_GCto basically skip the header. That's defined by includingwasmtime/conf.h
alexcrichton created PR review comment:
The scoping here is a bit more suspect to me, so I don't know if this needs a new scope, but if not can this have a comment explaining why?
alexcrichton created PR review comment:
Like in Rust could these be direct methods on
Store::Context?
alexcrichton unassigned fitzgen from PR #12861 Exceptions: implement C API..
cfallin submitted PR review.
cfallin created PR review comment:
Done!
cfallin submitted PR review.
cfallin created PR review comment:
Done!
cfallin submitted PR review.
cfallin created PR review comment:
Done!
cfallin submitted PR review.
cfallin created PR review comment:
Ah, stray bit here from earlier changes that is indeed unneeded; removed
cfallin submitted PR review.
cfallin created PR review comment:
OK, yep, didn't need to access
.ptr-- updated to usecapi()and removed. No new friends for this class (sad)...
cfallin submitted PR review.
cfallin created PR review comment:
Done!
cfallin submitted PR review.
cfallin created PR review comment:
Yep, I'm not sure why I didn't catch this -- removed the
tag_typearg.
cfallin submitted PR review.
cfallin created PR review comment:
Done!
cfallin created PR review comment:
Done-ish (it takes a Result directly and not as a closure's return so wrapped the fallible bit in an invoked-in-place closure just above)
cfallin submitted PR review.
cfallin submitted PR review.
cfallin created PR review comment:
Indeed it should have had that -- added.
cfallin submitted PR review.
cfallin created PR review comment:
Added as well, thanks.
cfallin created PR review comment:
Ah, yes, the store takes ownership, so we indeed should have a subscope to wrap up the temporary here.
cfallin submitted PR review.
cfallin submitted PR review.
cfallin created PR review comment:
Done.
cfallin submitted PR review.
cfallin created PR review comment:
Done.
cfallin updated PR #12861.
cfallin submitted PR review.
cfallin created PR review comment:
Done!
cfallin commented on PR #12861:
Updated based on feedback (thanks!) and also added a case to
wasmtime_val_tforexnref, plus a test that uses it, as I realized I had missed that bit.
cfallin updated PR #12861.
alexcrichton submitted PR review.
alexcrichton added PR #12861 Exceptions: implement C API. to the merge queue
alexcrichton commented on PR #12861:
Oh as a follow-up want to update https://github.com/bytecodealliance/wasmtime/blob/main/docs/stability-wasm-proposals.md#tier-2-webassembly-proposals too?
github-merge-queue[bot] removed PR #12861 Exceptions: implement C API. from the merge queue
cfallin updated PR #12861.
cfallin has enabled auto merge for PR #12861.
cfallin added PR #12861 Exceptions: implement C API. to the merge queue
github-merge-queue[bot] removed PR #12861 Exceptions: implement C API. from the merge queue
cfallin added PR #12861 Exceptions: implement C API. to the merge queue
cfallin updated PR #12861.
cfallin removed PR #12861 Exceptions: implement C API. from the merge queue
cfallin has enabled auto merge for PR #12861.
cfallin added PR #12861 Exceptions: implement C API. to the merge queue
cfallin merged PR #12861.
cfallin removed PR #12861 Exceptions: implement C API. from the merge queue
Last updated: Apr 13 2026 at 00:25 UTC