(&self, store: &StoreOpaque)
| 1213 | } |
| 1214 | |
| 1215 | pub(crate) fn vmimport(&self, store: &StoreOpaque) -> VMFunctionImport { |
| 1216 | // Safety: it should be fine to dereference the funcref pointer while we |
| 1217 | // borrow the store. |
| 1218 | let func_ref = unsafe { self.vm_func_ref(store).as_ref() }; |
| 1219 | |
| 1220 | // Note that this is a load-bearing `unwrap` here, but is never expected |
| 1221 | // to trip at runtime. The general problem is that host functions do not |
| 1222 | // have a `wasm_call` function so the `VMFuncRef` type has an optional |
| 1223 | // pointer there. This is only able to be filled out when a function is |
| 1224 | // "paired" with a module where trampolines are present to fill out |
| 1225 | // `wasm_call` pointers. |
| 1226 | // |
| 1227 | // This pairing of modules doesn't happen explicitly but is instead |
| 1228 | // managed lazily throughout Wasmtime. Specifically the way this works |
| 1229 | // is one of: |
| 1230 | // |
| 1231 | // * When a host function is created the store's list of modules are |
| 1232 | // searched for a wasm trampoline. If not found the `wasm_call` field |
| 1233 | // is left blank. |
| 1234 | // |
| 1235 | // * When a module instantiation happens, which uses this function, the |
| 1236 | // module will be used to fill any outstanding holes that it has |
| 1237 | // trampolines for. |
| 1238 | // |
| 1239 | // This means that by the time we get to this point any relevant holes |
| 1240 | // should be filled out. Thus if this panic actually triggers then it's |
| 1241 | // indicative of a missing `fill` call somewhere else. |
| 1242 | let func_import = func_ref.as_vm_function_import().unwrap(); |
| 1243 | |
| 1244 | func_import.clone() |
| 1245 | } |
| 1246 | |
| 1247 | pub(crate) fn comes_from_same_store(&self, store: &StoreOpaque) -> bool { |
| 1248 | self.store == store.id() |
no test coverage detected