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

Method for_component

crates/wasmtime/src/compile.rs:319–435  ·  view source on GitHub ↗
(
        engine: &'a Engine,
        types: &'a wasmtime_environ::component::ComponentTypesBuilder,
        component: &'a wasmtime_environ::component::ComponentTranslation,
        module_translatio

Source from the content-addressed store, hash-verified

317 /// Create a `CompileInputs` for a component.
318 #[cfg(feature = "component-model")]
319 fn for_component(
320 engine: &'a Engine,
321 types: &'a wasmtime_environ::component::ComponentTypesBuilder,
322 component: &'a wasmtime_environ::component::ComponentTranslation,
323 module_translations: impl IntoIterator<
324 Item = (
325 StaticModuleIndex,
326 &'a ModuleTranslation<'a>,
327 PrimaryMap<DefinedFuncIndex, FunctionBodyData<'a>>,
328 ),
329 >,
330 ) -> Self {
331 use wasmtime_environ::Abi;
332 use wasmtime_environ::component::UnsafeIntrinsic;
333
334 let mut ret = CompileInputs { inputs: vec![] };
335
336 ret.collect_inputs_in_translations(types.module_types_builder(), module_translations);
337 let tunables = engine.tunables();
338
339 for i in component
340 .component
341 .unsafe_intrinsics
342 .iter()
343 .enumerate()
344 .filter_map(|(i, ty)| if ty.is_some() { Some(i) } else { None })
345 {
346 let i = u32::try_from(i).unwrap();
347 let intrinsic = UnsafeIntrinsic::from_u32(i);
348 for abi in [Abi::Wasm, Abi::Array] {
349 ret.push_input(move |compiler| {
350 let symbol = format!(
351 "unsafe-intrinsics-{}-{}",
352 match abi {
353 Abi::Wasm => "wasm-call",
354 Abi::Array => "array-call",
355 Abi::Patchable => "patchable-call",
356 },
357 intrinsic.name(),
358 );
359 Ok(CompileOutput {
360 key: FuncKey::UnsafeIntrinsic(abi, intrinsic),
361 function: compiler
362 .component_compiler()
363 .compile_intrinsic(tunables, component, types, intrinsic, abi, &symbol)
364 .with_context(|| format!("failed to compile `{symbol}`"))?,
365 symbol,
366 start_srcloc: FilePos::default(),
367 translation: None,
368 func_body: None,
369 })
370 });
371 }
372 }
373
374 for (idx, trampoline) in component.trampolines.iter() {
375 for abi in [Abi::Wasm, Abi::Array] {
376 ret.push_input(move |compiler| {

Callers

nothing calls this directly

Calls 15

OkFunction · 0.85
push_inputMethod · 0.80
with_contextMethod · 0.80
module_types_builderMethod · 0.45
tunablesMethod · 0.45
iterMethod · 0.45
is_someMethod · 0.45
unwrapMethod · 0.45
compile_intrinsicMethod · 0.45
component_compilerMethod · 0.45

Tested by

no test coverage detected