MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / push

Method push

crates/wasmtime/src/runtime/store/func_refs.rs:90–109  ·  view source on GitHub ↗

Push the given `VMFuncRef` into this arena, returning a pinned pointer to it. # Safety You may only access the return value on the same thread as this `FuncRefs` and only while the store holding this `FuncRefs` exists. Additionally the `vmctx` field of `func_ref` must be valid to read.

(
        &mut self,
        func_ref: VMFuncRef,
        modules: &ModuleRegistry,
    )

Source from the content-addressed store, hash-verified

88 /// `FuncRefs` and only while the store holding this `FuncRefs` exists.
89 /// Additionally the `vmctx` field of `func_ref` must be valid to read.
90 pub unsafe fn push(
91 &mut self,
92 func_ref: VMFuncRef,
93 modules: &ModuleRegistry,
94 ) -> Result<NonNull<VMFuncRef>, OutOfMemory> {
95 debug_assert!(func_ref.wasm_call.is_none());
96 let func_ref = self
97 .bump
98 .get_mut()
99 .try_alloc(func_ref)
100 .map_err(|_| OutOfMemory::new(size_of::<VMFuncRef>()))?;
101 // SAFETY: it's a contract of this function itself that `func_ref` has a
102 // valid vmctx field to read.
103 let has_hole = unsafe { !try_fill(func_ref, modules) };
104 let unpatched = SendSyncPtr::from(func_ref);
105 if has_hole {
106 self.with_holes.push(unpatched)?;
107 }
108 Ok(unpatched.as_non_null())
109 }
110
111 /// Patch any `VMFuncRef::wasm_call`s that need filling in.
112 pub fn fill(&mut self, modules: &ModuleRegistry) {

Callers 15

push_inputMethod · 0.45
pre_linkMethod · 0.45
append_compiler_infoFunction · 0.45
test_isa_flags_mismatchFunction · 0.45
newMethod · 0.45
define_callMethod · 0.45
register_interpreterMethod · 0.45
replaceMethod · 0.45
load_untyped_paramsMethod · 0.45
validateMethod · 0.45

Calls 7

try_fillFunction · 0.85
fromFunction · 0.85
OkFunction · 0.85
try_allocMethod · 0.80
newFunction · 0.50
get_mutMethod · 0.45
as_non_nullMethod · 0.45

Tested by 6

test_isa_flags_mismatchFunction · 0.36
mainFunction · 0.36
mainFunction · 0.36
mainFunction · 0.36
exhausted_vmasFunction · 0.36