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
LiftandLowertraits.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'sunsafe implofSendandSyncon fibers to be sound it requires that this stack-local variable is alsoSendandSyncas it's an entirely user-provided type. Thus I've concluded that for results it's always required for these to be bothSendandSync(or at the very least,Send).Given that I've gone ahead and updated to require both
SendandSyncfor both params and results. This is not expected to actually have any impact in practice since all primitives are alreadySend/Sync(minusRcimpls all removed here) and allbindgen!-generated types are compositions ofSend/Syncprimitives meaning that they're alsoSendandSync.<!--
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
-->
alexcrichton requested wasmtime-core-reviewers for a review on PR #11160.
alexcrichton requested fitzgen for a review on PR #11160.
alexcrichton commented on PR #11160:
cc @dicej
alexcrichton updated PR #11160.
pchickey submitted PR review:
Looks good. Only suggestion is that all of the code-comments for ComponentType could be promoted to doc-comments.
alexcrichton updated PR #11160.
alexcrichton has enabled auto merge for PR #11160.
alexcrichton merged PR #11160.
Last updated: Dec 06 2025 at 06:05 UTC