wasmtime_environ::component::dfg

Struct ComponentDfg

source
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 identifed 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

source

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.

source

pub fn resource_index(&self, defined: DefinedResourceIndex) -> ResourceIndex

Converts the provided defined index into a normal index, adding in the number of imported resources.

Trait Implementations§

source§

impl Default for ComponentDfg

source§

fn default() -> ComponentDfg

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.