Stream: git-wasmtime

Topic: wasmtime / PR #12861 Exceptions: implement C API.


view this post on Zulip Wasmtime GitHub notifications bot (Mar 27 2026 at 23:43):

cfallin requested fitzgen for a review on PR #12861.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 27 2026 at 23:43):

cfallin requested wasmtime-core-reviewers for a review on PR #12861.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 27 2026 at 23:43):

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:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Mar 28 2026 at 03:34):

github-actions[bot] added the label wasmtime:c-api on PR #12861.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 28 2026 at 15:03):

cfallin updated PR #12861.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 28 2026 at 15:17):

cfallin updated PR #12861.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

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

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton created PR review comment:

Mind also adding tag.h here?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton created PR review comment:

s/&mut Tag/&mut MaybeUninit<Tag>/ (it may not yet be initialized)

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton created PR review comment:

I think these functions don't exist in headers?

This should in theory exist in wasm.h but wasm.h doesn't support tags. In the meantime can these be added under a wasmtime_* prefix in the wasmtime/tag.h header?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton created PR review comment:

I had no idea friend functions 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's capi() functions below to get the raw pointer out. Could that be used instead of adding more freinds here? (I haven't ever gotten around to going back and removing all friends entirely)

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton created PR review comment:

How come this takes both a tag and a tag_type? Could the tag_type be inferred from the tag?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton created PR review comment:

I'd recommend moving this all into handle_result below to enable using ? in ExnType::from_tag_type for example

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton created PR review comment:

Can this document that val_ret must be deallocated by the caller? Or basically that it's owned by the caller.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton created PR review comment:

How come this was added? (I'd expect to see other changes here too)

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton created PR review comment:

Like above, should this have a scope on it?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

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)

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton created PR review comment:

Should this have a scope above it to avoid permanently rooting the returned exception?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

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?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton created PR review comment:

I think this (and maybe other header files?) will want a guard with WASMTIME_FEATURE_GC to basically skip the header. That's defined by including wasmtime/conf.h

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

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?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton created PR review comment:

Like in Rust could these be direct methods on Store::Context?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 30 2026 at 13:25):

alexcrichton unassigned fitzgen from PR #12861 Exceptions: implement C API..

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:00):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:00):

cfallin created PR review comment:

Done!

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:00):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:00):

cfallin created PR review comment:

Done!

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:00):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:00):

cfallin created PR review comment:

Done!

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:00):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:00):

cfallin created PR review comment:

Ah, stray bit here from earlier changes that is indeed unneeded; removed

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:00):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:00):

cfallin created PR review comment:

OK, yep, didn't need to access .ptr -- updated to use capi() and removed. No new friends for this class (sad)...

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin created PR review comment:

Done!

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin created PR review comment:

Yep, I'm not sure why I didn't catch this -- removed the tag_type arg.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin created PR review comment:

Done!

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

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)

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin created PR review comment:

Indeed it should have had that -- added.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin created PR review comment:

Added as well, thanks.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin created PR review comment:

Ah, yes, the store takes ownership, so we indeed should have a subscope to wrap up the temporary here.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin created PR review comment:

Done.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:01):

cfallin created PR review comment:

Done.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:04):

cfallin updated PR #12861.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:05):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:05):

cfallin created PR review comment:

Done!

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:05):

cfallin commented on PR #12861:

Updated based on feedback (thanks!) and also added a case to wasmtime_val_t for exnref, plus a test that uses it, as I realized I had missed that bit.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 05:06):

cfallin updated PR #12861.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 18:03):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 18:04):

alexcrichton added PR #12861 Exceptions: implement C API. to the merge queue

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 18:04):

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?

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 18:33):

github-merge-queue[bot] removed PR #12861 Exceptions: implement C API. from the merge queue

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 21:39):

cfallin updated PR #12861.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 21:40):

cfallin has enabled auto merge for PR #12861.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 21:54):

cfallin added PR #12861 Exceptions: implement C API. to the merge queue

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 22:14):

github-merge-queue[bot] removed PR #12861 Exceptions: implement C API. from the merge queue

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 22:17):

cfallin added PR #12861 Exceptions: implement C API. to the merge queue

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 22:40):

cfallin updated PR #12861.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 22:40):

cfallin removed PR #12861 Exceptions: implement C API. from the merge queue

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 22:40):

cfallin has enabled auto merge for PR #12861.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 22:56):

cfallin added PR #12861 Exceptions: implement C API. to the merge queue

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 23:19):

cfallin merged PR #12861.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2026 at 23:19):

cfallin removed PR #12861 Exceptions: implement C API. from the merge queue


Last updated: Apr 13 2026 at 00:25 UTC