pub struct Component {Show 16 fields
pub import_types: PrimaryMap<ImportIndex, (String, TypeDef)>,
pub imports: PrimaryMap<RuntimeImportIndex, (ImportIndex, Vec<String>)>,
pub exports: NameMap<String, ExportIndex>,
pub export_items: PrimaryMap<ExportIndex, Export>,
pub initializers: Vec<GlobalInitializer>,
pub num_runtime_instances: u32,
pub num_runtime_component_instances: u32,
pub num_runtime_memories: u32,
pub num_runtime_reallocs: u32,
pub num_runtime_post_returns: u32,
pub trampolines: PrimaryMap<TrampolineIndex, ModuleInternedTypeIndex>,
pub num_lowerings: u32,
pub num_resource_tables: usize,
pub num_resources: u32,
pub imported_resources: PrimaryMap<ResourceIndex, RuntimeImportIndex>,
pub defined_resource_instances: PrimaryMap<DefinedResourceIndex, RuntimeComponentInstanceIndex>,
}
Expand description
Run-time-type-information about a Component
, its structure, and how to
instantiate it.
This type is intended to mirror the Module
type in this crate which
provides all the runtime information about the structure of a module and
how it works.
NB: Lots of the component model is not yet implemented in the runtime so this is going to undergo a lot of churn.
Fields§
§import_types: PrimaryMap<ImportIndex, (String, TypeDef)>
A list of typed values that this component imports.
Note that each name is given an ImportIndex
here for the next map to
refer back to.
imports: PrimaryMap<RuntimeImportIndex, (ImportIndex, Vec<String>)>
A list of “flattened” imports that are used by this instance.
This import map represents extracting imports, as necessary, from the general imported types by this component. The flattening here refers to extracting items from instances. Currently the flat imports are either a host function or a core wasm module.
For example if ImportIndex(0)
pointed to an instance then this import
map represent extracting names from that map, for example extracting an
exported module or an exported function.
Each import item is keyed by a RuntimeImportIndex
which is referred to
by types below whenever something refers to an import. The value for
each RuntimeImportIndex
in this map is the ImportIndex
for where
this items comes from (which can be associated with a name above in the
import_types
array) as well as the list of export names if
ImportIndex
refers to an instance. The export names array represents
recursively fetching names within an instance.
exports: NameMap<String, ExportIndex>
This component’s own root exports from the component itself.
export_items: PrimaryMap<ExportIndex, Export>
All exports of this component and exported instances of this component.
This is indexed by ExportIndex
for fast lookup and Export::Instance
will refer back into this list.
initializers: Vec<GlobalInitializer>
Initializers that must be processed when instantiating this component.
This list of initializers does not correspond directly to the component
itself. The general goal with this is that the recursive nature of
components is “flattened” with an array like this which is a linear
sequence of instructions of how to instantiate a component. This will
have instantiations, for example, in addition to entries which
initialize VMComponentContext
fields with previously instantiated
instances.
num_runtime_instances: u32
The number of runtime instances (maximum RuntimeInstanceIndex
) created
when instantiating this component.
num_runtime_component_instances: u32
Same as num_runtime_instances
, but for RuntimeComponentInstanceIndex
instead.
num_runtime_memories: u32
The number of runtime memories (maximum RuntimeMemoryIndex
) needed to
instantiate this component.
Note that this many memories will be stored in the VMComponentContext
and each memory is intended to be unique (e.g. the same memory isn’t
stored in two different locations).
num_runtime_reallocs: u32
The number of runtime reallocs (maximum RuntimeReallocIndex
) needed to
instantiate this component.
Note that this many function pointers will be stored in the
VMComponentContext
.
num_runtime_post_returns: u32
Same as num_runtime_reallocs
, but for post-return functions.
trampolines: PrimaryMap<TrampolineIndex, ModuleInternedTypeIndex>
WebAssembly type signature of all trampolines.
num_lowerings: u32
The number of lowered host functions (maximum LoweredIndex
) needed to
instantiate this component.
num_resource_tables: usize
Maximal number of tables that required at runtime for resource-related information in this component.
num_resources: u32
Total number of resources both imported and defined within this component.
imported_resources: PrimaryMap<ResourceIndex, RuntimeImportIndex>
Metadata about imported resources and where they are within the runtime imports array.
This map is only as large as the number of imported resources.
defined_resource_instances: PrimaryMap<DefinedResourceIndex, RuntimeComponentInstanceIndex>
Metadata about which component instances defined each resource within this component.
This is used to determine which set of instance flags are inspected when testing reentrance.
Implementations§
Source§impl Component
impl Component
Sourcepub fn defined_resource_index(
&self,
idx: ResourceIndex,
) -> Option<DefinedResourceIndex>
pub fn defined_resource_index( &self, idx: ResourceIndex, ) -> Option<DefinedResourceIndex>
Attempts to convert a resource index into a defined index.
Returns None
if idx
is for an imported resource in this component or
Some
if it’s a locally defined resource.
Sourcepub fn resource_index(&self, idx: DefinedResourceIndex) -> ResourceIndex
pub fn resource_index(&self, idx: DefinedResourceIndex) -> ResourceIndex
Converts a defined resource index to a component-local resource index which includes all imports.