You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
0 commit comments