alexcrichton opened PR #10959 from alexcrichton:upstream-more-changes to bytecodealliance:main:
In the spirit of making Wasmtime's internals safer this is a step forward for components to a new paradigm for how libcalls/host functions are implemented. Previously
*mut ComponentInstancewas liberally used but this meant that situations would often simultaneously have&mut ComponentInstanceand&mut StoreOpaqueaccessible in the same function and there was no prevention of going from the store to the component instance, acquiring two aliasing mutable references (which would be unsound). The refactoring applied here is to redefine the entrypoints from the guest back into the host to operate on&mut dyn VMStore(orStoreContextMut<'_, T>) plus
wasmtime::component::Instance. This index-based approach means that there's no aliasing of component instances and stores and theInstancetype can be used to look up anything within the store that's necessary.This refactoring originated in the wasip3-prototyping repository and has been used to remove a good deal of
unsafecode now thatInstanceis effectively safe to pass around and the store was already passed around anyway everywhere.In the future I plan to apply a similar paradigm shift for core instances as well, but that'll require some more finesse for all the bits and bobs that core wasm does.
<!--
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 dicej for a review on PR #10959.
alexcrichton requested wasmtime-core-reviewers for a review on PR #10959.
pchickey submitted PR review.
alexcrichton merged PR #10959.
Last updated: Dec 06 2025 at 07:03 UTC