Stream: git-wasmtime

Topic: wasmtime / PR #11453 Add a helper always-`Sync` utility t...


view this post on Zulip Wasmtime GitHub notifications bot (Aug 18 2025 at 19:55):

alexcrichton opened PR #11453 from alexcrichton:always-mut to bytecodealliance:main:

This commit adds a newtype wrapper to Wasmtime, AlwaysMut, which is unconditionally Sync if the stored type is Send. This is similar to a Mutex<T> where it promotes a Send bound to a Sync bound, but it's unlike Mutex<T> in that AlwaysMut<T> has no synchronization. The reason that this is safe is that AlwaysMut<T> completely disallows access to the underlying data through &self and requires &mut self. This is similar to how Mutex::get_mut is safe, for example.

This type cleans up a preexisting unsafe impl Sync block in funcref management around SendSyncBump (bumpalo::Bump is Send, not Sync, but we only access it through &mut self). This then additionally removes unsafe impl Sync for StoreFiber which, upon reflection, is not sound because we don't ever constraint the store's T type to Sync, only Send. 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 unsafe inside of Wasmtime and to add a new utility to use in the future too.

<!--
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 (Aug 18 2025 at 19:55):

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

view this post on Zulip Wasmtime GitHub notifications bot (Aug 18 2025 at 19:55):

alexcrichton requested fitzgen for a review on PR #11453.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 18 2025 at 20:01):

alexcrichton updated PR #11453.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 18 2025 at 20:58):

fitzgen submitted PR review:

Nice!

view this post on Zulip Wasmtime GitHub notifications bot (Aug 18 2025 at 20:58):

fitzgen created PR review comment:

Maybe add a impl From<T> for AlwaysMut<T> impl so tha this can just .into()?

view this post on Zulip Wasmtime GitHub notifications bot (Aug 18 2025 at 20:58):

fitzgen created PR review comment:

Safety comment?

view this post on Zulip Wasmtime GitHub notifications bot (Aug 18 2025 at 21:47):

alexcrichton updated PR #11453.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 18 2025 at 21:47):

alexcrichton has enabled auto merge for PR #11453.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 18 2025 at 21:55):

alexcrichton updated PR #11453.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 18 2025 at 22:29):

alexcrichton merged PR #11453.


Last updated: Dec 06 2025 at 06:05 UTC