Stream: git-wasmtime

Topic: wasmtime / PR #11160 Add `Send`/`Sync` bounds to `Compone...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 30 2025 at 19:03):

alexcrichton opened PR #11160 from alexcrichton:component-type-send-sync to bytecodealliance:main:

This commit is extracted from from review of #11123 and #11127. While not literally present in those PRs it's my own personal conclusion that it's best to just go ahead and add these bounds at the "base" of the component trait hierarchy. The current implementation in #11123 adds bounds in many locations and this would remove the need to add bounds everywhere and instead have everything inherited through the Lift and Lower traits.

This raises the question of: why? The main conclusion that I've reached leading to this change is that Wasmtime currently will store R, a return value, on the stack during the lowering process back into linear memory. This might involve allocation, however, meaning that wasm can be invoked and a context switch could happen. For Wasmtime's unsafe impl of Send and Sync on fibers to be sound it requires that this stack-local variable is also Send and Sync as it's an entirely user-provided type. Thus I've concluded that for results it's always required for these to be both Send and Sync (or at the very least, Send).

Given that I've gone ahead and updated to require both Send and Sync for both params and results. This is not expected to actually have any impact in practice since all primitives are already Send/Sync (minus Rc impls all removed here) and all bindgen!-generated types are compositions of Send/Sync primitives meaning that they're also Send and Sync.

<!--
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 (Jun 30 2025 at 19:03):

alexcrichton requested wasmtime-core-reviewers for a review on PR #11160.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 30 2025 at 19:03):

alexcrichton requested fitzgen for a review on PR #11160.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 30 2025 at 19:04):

alexcrichton commented on PR #11160:

cc @dicej

view this post on Zulip Wasmtime GitHub notifications bot (Jun 30 2025 at 19:05):

alexcrichton updated PR #11160.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 30 2025 at 19:59):

pchickey submitted PR review:

Looks good. Only suggestion is that all of the code-comments for ComponentType could be promoted to doc-comments.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 30 2025 at 20:03):

alexcrichton updated PR #11160.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 30 2025 at 20:03):

alexcrichton has enabled auto merge for PR #11160.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 30 2025 at 20:38):

alexcrichton merged PR #11160.


Last updated: Dec 06 2025 at 06:05 UTC