Stream: git-wasmtime

Topic: wasmtime / PR #10959 Refactor component host/libcalls


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

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 ComponentInstance was liberally used but this meant that situations would often simultaneously have &mut ComponentInstance and &mut StoreOpaque accessible 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 (or StoreContextMut<'_, T>) plus
wasmtime::component::Instance. This index-based approach means that there's no aliasing of component instances and stores and the Instance type 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 unsafe code now that Instance is 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:

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 06 2025 at 19:27):

alexcrichton requested dicej for a review on PR #10959.

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

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

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

pchickey submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 06 2025 at 21:23):

alexcrichton merged PR #10959.


Last updated: Dec 06 2025 at 07:03 UTC