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

Method typecheck_externs

crates/wasmtime/src/runtime/instance.rs:211–246  ·  view source on GitHub ↗
(
        store: &mut StoreOpaque,
        module: &Module,
        imports: &[Extern],
    )

Source from the content-addressed store, hash-verified

209 }
210
211 fn typecheck_externs(
212 store: &mut StoreOpaque,
213 module: &Module,
214 imports: &[Extern],
215 ) -> Result<OwnedImports> {
216 for import in imports {
217 if !import.comes_from_same_store(store) {
218 bail!("cross-`Store` instantiation is not currently supported");
219 }
220 }
221
222 typecheck(module, imports, |cx, ty, item| {
223 let item = DefinitionType::from(store, item);
224 cx.definition(ty, &item)
225 })?;
226
227 // When pushing functions into `OwnedImports` it's required that their
228 // `wasm_call` fields are all filled out. This `module` is guaranteed
229 // to have any trampolines necessary for functions so register the
230 // module with the store and then attempt to fill out any outstanding
231 // holes.
232 //
233 // Note that under normal operation this shouldn't do much as the list
234 // of funcs-with-holes should generally be empty. As a result the
235 // process of filling this out is not super optimized at this point.
236 let (modules, engine, breakpoints) = store.modules_and_engine_and_breakpoints_mut();
237 modules.register_module(module, engine, breakpoints)?;
238 let (funcrefs, modules) = store.func_refs_and_modules();
239 funcrefs.fill(modules);
240
241 let mut owned_imports = OwnedImports::new(module)?;
242 for import in imports {
243 owned_imports.push(import, store)?;
244 }
245 Ok(owned_imports)
246 }
247
248 /// Internal function to create an instance and run the start function.
249 ///

Callers

nothing calls this directly

Calls 11

fromFunction · 0.85
OkFunction · 0.85
func_refs_and_modulesMethod · 0.80
typecheckFunction · 0.70
newFunction · 0.50
comes_from_same_storeMethod · 0.45
definitionMethod · 0.45
register_moduleMethod · 0.45
fillMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected