implementing Func::wrap support for reference types right now, and WasmTy::{load,store} need to take a &Store argument to pass in/receive ExternRefs to/from Wasm, which means that the trampoline in impl_into_func! needs to get a Store from ... somewhere? presumably from either the callee_vmctx or caller_vmctx?
cc @Alex Crichton
hm... so the only guaranteed non-null value is caller_vmctx (the first one)
ah, host_state()?
nah that probably doesn't have a Store
er or it might
just above trampoline, in shim:
debug_assert!(state.is::<(F, Weak<StoreInner>)>());
ah yeah no nvmd looks like it's there
thanks
so yeah that looks to be it
but I'd avoid upgrading the Weak unelss an ExternRef is actually used
either way is fine though
good call
ah hm, that's actually a little funky -- are you thinking that WasmTy::{load,store} should instead take a &dyn Fn() -> &Store or a &Weak<StoreInner>? because we don't know at the call site what the T: WasmTy is and whether it will use the store or not
@Alex Crichton
either way I think is fine
ExternRef stores a weak anyway, right?
it's an internal trait FWIW (the mehtods at least) so it's fine to do whatever works best
ah yeah, so I guess it is only WasmTy::load that really needs it
Last updated: Dec 06 2025 at 06:05 UTC