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,
)
| 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) { |