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
This feature would improve the ergonomics of FunctionEnvMut<T>.
In wasmer 3.x an &mut impl AsStoreMut, commonly a &mut StoreMut in practice, is needed to modify a Global.
If a FunctionEnvMut<T> carries a Global, then modification requires cloning it since FunctionEnv::as_store_mut() yields the needed StoreMut. This works fine if the FunctionEnvMut<T>'s underlying T is cheap to Clone, but for more complicated FunctionEnv's, one need discard references to produced by FunctionEnvMut::data_mut.
This is awkward, since it means designing host functions like
fnhost_foo(mutenv:WasmEnvMut){let global = env.data().global.clone().unwrap();letmut store = env.as_store_mut();
global.set(&mut store,0);let rest_of_state = env.data_mut();// can't use `store` anymore due to `rest_of_state`drop(rest_of_state)letmut store = env.as_store_mut();// back to being able to modify globals}
Proposed solution
We add a new method to FunctionEnvMut<T> that somehow returns both a StoreMut and the underlying &mut T. This would require deeper changes since these currently entail aliasing.
Alternatives
Don't require Global, Memory, and the like need a Store for access as was the case in wasmer 2.x.
We found the upgrade to wasmer 3.x to be quite difficult due to the above. Needing a Storerequired we re-architect our host functions, using complex types to achieve what used to be given for free.
The text was updated successfully, but these errors were encountered:
Motivation
This feature would improve the ergonomics of
FunctionEnvMut<T>
.In
wasmer 3.x
an&mut impl AsStoreMut
, commonly a&mut StoreMut
in practice, is needed to modify aGlobal
.If a
FunctionEnvMut<T>
carries aGlobal
, then modification requires cloning it sinceFunctionEnv::as_store_mut()
yields the neededStoreMut
. This works fine if theFunctionEnvMut<T>
's underlyingT
is cheap toClone
, but for more complicatedFunctionEnv
's, one need discard references to produced byFunctionEnvMut::data_mut
.This is awkward, since it means designing host functions like
Proposed solution
We add a new method to
FunctionEnvMut<T>
that somehow returns both aStoreMut
and the underlying&mut T
. This would require deeper changes since these currently entail aliasing.Alternatives
Don't require
Global
,Memory
, and the like need aStore
for access as was the case inwasmer 2.x
.We found the upgrade to
wasmer 3.x
to be quite difficult due to the above. Needing aStore
required we re-architect our host functions, using complex types to achieve what used to be given for free.The text was updated successfully, but these errors were encountered: