alexcrichton opened PR #11453 from alexcrichton:always-mut to bytecodealliance:main:
This commit adds a newtype wrapper to Wasmtime,
AlwaysMut, which is unconditionallySyncif the stored type isSend. This is similar to aMutex<T>where it promotes aSendbound to aSyncbound, but it's unlikeMutex<T>in thatAlwaysMut<T>has no synchronization. The reason that this is safe is thatAlwaysMut<T>completely disallows access to the underlying data through&selfand requires&mut self. This is similar to howMutex::get_mutis safe, for example.This type cleans up a preexisting
unsafe impl Syncblock in funcref management aroundSendSyncBump(bumpalo::BumpisSend, notSync, but we only access it through&mut self). This then additionally removesunsafe impl Sync for StoreFiberwhich, upon reflection, is not sound because we don't ever constraint the store'sTtype toSync, onlySend. This is effectively no change throughout Wasmtime, however, as fibers are only accessed with&mut.Overall this is mostly just internal refactoring to reduce the amount of
unsafeinside of Wasmtime and to add a new utility to use in the future too.<!--
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 #11453.
alexcrichton requested fitzgen for a review on PR #11453.
alexcrichton updated PR #11453.
fitzgen submitted PR review:
Nice!
fitzgen created PR review comment:
Maybe add a
impl From<T> for AlwaysMut<T>impl so tha this can just.into()?
fitzgen created PR review comment:
Safety comment?
alexcrichton updated PR #11453.
alexcrichton has enabled auto merge for PR #11453.
alexcrichton updated PR #11453.
alexcrichton merged PR #11453.
Last updated: Dec 06 2025 at 06:05 UTC