pub struct ComponentDfg {Show 16 fields
pub import_types: PrimaryMap<ImportIndex, (String, TypeDef)>,
pub imports: PrimaryMap<RuntimeImportIndex, (ImportIndex, Vec<String>)>,
pub exports: IndexMap<String, Export>,
pub trampolines: Intern<TrampolineIndex, (ModuleInternedTypeIndex, Trampoline)>,
pub reallocs: Intern<ReallocId, CoreDef>,
pub post_returns: Intern<PostReturnId, CoreDef>,
pub memories: Intern<MemoryId, CoreExport<MemoryIndex>>,
pub adapters: Intern<AdapterId, Adapter>,
pub instances: PrimaryMap<InstanceId, Instance>,
pub num_runtime_component_instances: u32,
pub adapter_modules: PrimaryMap<AdapterModuleId, (StaticModuleIndex, Vec<CoreDef>)>,
pub adapter_paritionings: PrimaryMap<AdapterId, (AdapterModuleId, EntityIndex)>,
pub resources: PrimaryMap<DefinedResourceIndex, Resource>,
pub imported_resources: PrimaryMap<ResourceIndex, RuntimeImportIndex>,
pub num_resource_tables: usize,
pub side_effects: Vec<SideEffect>,
}
Fields§
§import_types: PrimaryMap<ImportIndex, (String, TypeDef)>
Same as Component::import_types
imports: PrimaryMap<RuntimeImportIndex, (ImportIndex, Vec<String>)>
Same as Component::imports
exports: IndexMap<String, Export>
Same as Component::exports
trampolines: Intern<TrampolineIndex, (ModuleInternedTypeIndex, Trampoline)>
All trampolines and their type signature which will need to get compiled by Cranelift.
reallocs: Intern<ReallocId, CoreDef>
Know reallocation functions which are used by lowerings
(e.g. will be
used by the host)
post_returns: Intern<PostReturnId, CoreDef>
Same as reallocs
, but for post-return.
memories: Intern<MemoryId, CoreExport<MemoryIndex>>
Same as reallocs
, but for post-return.
adapters: Intern<AdapterId, Adapter>
Metadata about identified fused adapters.
Note that this list is required to be populated in-order where the “left” adapters cannot depend on “right” adapters. Currently this falls out of the inlining pass of translation.
instances: PrimaryMap<InstanceId, Instance>
Metadata about all known core wasm instances created.
This is mostly an ordered list and is not deduplicated based on contents
unlike the items above. Creation of an Instance
is side-effectful and
all instances here are always required to be created. These are
considered “roots” in dataflow.
num_runtime_component_instances: u32
Number of component instances that were created during the inlining phase (this is not edited after creation).
adapter_modules: PrimaryMap<AdapterModuleId, (StaticModuleIndex, Vec<CoreDef>)>
Known adapter modules and how they are instantiated.
This map is not filled in on the initial creation of a ComponentDfg
.
Instead these modules are filled in by the inline::adapt
phase where
adapter modules are identified and filled in here.
The payload here is the static module index representing the core wasm adapter module that was generated as well as the arguments to the instantiation of the adapter module.
adapter_paritionings: PrimaryMap<AdapterId, (AdapterModuleId, EntityIndex)>
Metadata about where adapters can be found within their respective adapter modules.
Like adapter_modules
this is not filled on the initial creation of
ComponentDfg
but rather is created alongside adapter_modules
during
the inline::adapt
phase of translation.
The values here are the module that the adapter is present within along as the core wasm index of the export corresponding to the lowered version of the adapter.
resources: PrimaryMap<DefinedResourceIndex, Resource>
Defined resources in this component sorted by index with metadata about each resource.
Note that each index here is a unique resource, and that may mean it was the same component instantiated twice for example.
imported_resources: PrimaryMap<ResourceIndex, RuntimeImportIndex>
Metadata about all imported resources into this component. This records both how many imported resources there are (the size of this map) along with what the corresponding runtime import is.
num_resource_tables: usize
The total number of resource tables that will be used by this component,
currently the number of unique TypeResourceTableIndex
allocations for
this component.
side_effects: Vec<SideEffect>
An ordered list of side effects induced by instantiating this component.
Currently all side effects are either instantiating core wasm modules or declaring a resource. These side effects affect the dataflow processing of this component by idnicating what order operations should be performed during instantiation.
Implementations§
Source§impl ComponentDfg
impl ComponentDfg
Sourcepub fn finish(
self,
wasmtime_types: &mut ComponentTypesBuilder,
wasmparser_types: TypesRef<'_>,
) -> Result<ComponentTranslation>
pub fn finish( self, wasmtime_types: &mut ComponentTypesBuilder, wasmparser_types: TypesRef<'_>, ) -> Result<ComponentTranslation>
Consumes the intermediate ComponentDfg
to produce a final Component
with a linear innitializer list.
Sourcepub fn resource_index(&self, defined: DefinedResourceIndex) -> ResourceIndex
pub fn resource_index(&self, defined: DefinedResourceIndex) -> ResourceIndex
Converts the provided defined index into a normal index, adding in the number of imported resources.