wasmtime_environ

Module component

Source
Expand description

Support for the component model in Wasmtime.

This module contains all of the internal type definitions used by Wasmtime to process the component model. Despite everything being pub here this is not the public interface of Wasmtime to the component model. Instead this is the internal support to mirror the core wasm support that Wasmtime already implements.

Some main items contained within here are:

  • Type hierarchy information for the component model
  • Translation of a component into Wasmtime’s representation
  • Type information about a component used at runtime

This module also contains a lot of Serialize/Deserialize types which are encoded in the final compiled image for a component.

Note that this entire module is gated behind the component-model Cargo feature.

§Warning: In-progress

As-of the time of this writing this module is incomplete and under development. It will be added to incrementally over time as more features are implemented. Current design decisions are also susceptible to change at any time. Some comments may reflect historical rather than current state as well (sorry).

Re-exports§

pub use crate::StaticModuleIndex;
pub use crate::FuncIndex;
pub use crate::GlobalIndex;
pub use crate::MemoryIndex;
pub use crate::TableIndex;

Modules§

dfg
A dataflow-graph-like intermediate representation of a component

Structs§

Adapter
Metadata information about a fused adapter.
AdapterOptions
Configuration options which can be specified as part of the canonical ABI in the component model.
AllCallFunc
A triple of related functions/trampolines variants with differing calling conventions: {wasm,array}_call.
CanonicalAbiInfo
Bye information about a type in the canonical ABI, with metadata for both memory32 and memory64-based types.
CanonicalOptions
Canonical ABI options associated with a lifted or lowered function.
CompiledComponentInfo
Runtime state that a component retains to support its operation.
Component
Run-time-type-information about a Component, its structure, and how to instantiate it.
ComponentArtifacts
Serializable state that’s stored in a compilation artifact.
ComponentBuiltinFunctionIndex
An index type for builtin functions.
ComponentFuncIndex
Index within a component’s component function index space.
ComponentIndex
Index within a component’s component index space.
ComponentInstanceIndex
Index within a component’s component instance index space.
ComponentTranslation
Metadata as a result of compiling a component.
ComponentTypeIndex
Index within a component’s component type index space.
ComponentTypes
Runtime information about the type information contained within a component.
ComponentTypesBuilder
Structured used to build a ComponentTypes during translation.
ComponentUpvarIndex
Same as ModuleUpvarIndex but for components.
CoreExport
Identifier of an exported item from a core WebAssembly module instance.
DefinedResourceIndex
Index pointing to a local resource defined within a component.
ExportIndex
An index into Component::export_items at the end of compilation.
ExtractMemory
Metadata for extraction of a memory of what’s being extracted and where it’s going.
ExtractPostReturn
Same as ExtractMemory but for the post-return canonical option.
ExtractRealloc
Same as ExtractMemory but for the realloc canonical option.
FlatTypes
Flat representation of a type in just core wasm types.
ImportIndex
Used to index imports into a Component
LoweredIndex
Index that represents a lowered host function and is used to represent host function lowerings with options and such.
ModuleIndex
Index within a component’s module index space.
ModuleInstanceIndex
Index within a component’s module instance index space.
ModuleUpvarIndex
Index into a “closed over variables” list for components used to implement outer aliases. For more information on this see the documentation for the LexicalScope structure.
NameMap
A semver-aware map for imports/exports of a component.
NameMapNoIntern
For use with NameMap when no interning should happen and instead string keys are copied as-is.
RecordField
One field within a record.
Resource
Description of a new resource declared in a GlobalInitializer::Resource variant.
ResourceIndex
Index pointing to a resource within a component.
ResourcesBuilder
Builder state used to translate wasmparser’s ResourceId types to Wasmtime’s TypeResourceTableIndex type.
RuntimeComponentInstanceIndex
Same as RuntimeInstanceIndex but tracks component instances instead.
RuntimeImportIndex
Index that represents a leaf item imported into a component where a “leaf” means “not an instance”.
RuntimeInstanceIndex
Index that represents a core wasm instance created at runtime.
RuntimeMemoryIndex
Index representing a linear memory extracted from a wasm instance which is stored in a VMComponentContext. This is used to deduplicate references to the same linear memory where it’s only stored once in a VMComponentContext.
RuntimePostReturnIndex
Same as RuntimeMemoryIndex except for the post-return function.
RuntimeReallocIndex
Same as RuntimeMemoryIndex except for the realloc function.
StaticComponentIndex
Same as StaticModuleIndex but for components.
TrampolineIndex
Index for all trampolines that are compiled in Cranelift for a component.
Translator
Structure used to translate a component and parse it.
TypeComponent
The type of a component in the component model.
TypeComponentIndex
Index pointing to a component’s type (exports/imports with component-model types)
TypeComponentInstance
The type of a component instance in the component model, or an instantiated component.
TypeComponentInstanceIndex
Index pointing to a component instance’s type (exports with component-model types, no imports)
TypeEnum
Shape of an “enum” type in interface types, not to be confused with a Rust enum type.
TypeEnumIndex
Index pointing to an enum type in the component model.
TypeFlags
Shape of a “flags” type in interface types.
TypeFlagsIndex
Index pointing to a flags type in the component model.
TypeFunc
A component function type in the component model.
TypeFuncIndex
Index pointing to a component model function type with arguments/result as interface types.
TypeList
Shape of a “list” interface type.
TypeListIndex
Index pointing to a list type in the component model.
TypeModule
The type of a module in the component model.
TypeModuleIndex
Index pointing to a core wasm module’s type (exports/imports with core wasm types)
TypeOption
Shape of an “option” interface type.
TypeOptionIndex
Index pointing to an option type in the component model (aka a Option<T, E>)
TypeRecord
Shape of a “record” type in interface types.
TypeRecordIndex
Index pointing to a record type in the component model (aka a struct).
TypeResourceTable
Metadata about a resource table added to a component.
TypeResourceTableIndex
Index pointing to a resource table within a component.
TypeResult
Shape of a “result” interface type.
TypeResultIndex
Index pointing to an result type in the component model (aka a Result<T, E>)
TypeTuple
Shape of a “tuple” type in interface types.
TypeTupleIndex
Index pointing to a tuple type in the component model.
TypeVariant
Shape of a “variant” type in interface types.
TypeVariantIndex
Index pointing to a variant type in the component model (aka an enum).
VMComponentOffsets
Runtime offsets within a VMComponentContext for a specific component.
VariantInfo
ABI information about the representation of a variant.

Enums§

ComponentItem
Equivalent of EntityIndex but for the component model instead of core wasm.
CoreDef
Definition of a core wasm item and where it can come from within a component.
Export
Possible exports from a component.
ExportItem
An index at which to find an item within a runtime instance.
FixedEncoding
FlatType
GlobalInitializer
GlobalInitializer instructions to get processed when instantiating a component
InstantiateModule
Different methods of instantiating a core wasm module.
InterfaceType
All possible interface types that values can have.
StringEncoding
Possible encodings of strings within the component model.
Trampoline
A list of all possible trampolines that may be required to compile a component completely.
Transcode
Possible transcoding operations that must be provided by the host.
TypeDef
Types of imports and exports in the component model.

Constants§

FLAG_MAY_ENTER
Flag for the VMComponentContext::flags field which corresponds to the canonical ABI flag may_enter
FLAG_MAY_LEAVE
Flag for the VMComponentContext::flags field which corresponds to the canonical ABI flag may_leave
FLAG_NEEDS_POST_RETURN
Flag for the VMComponentContext::flags field which is set whenever a function is called to indicate that post_return must be called next.
MAX_FLAT_PARAMS
Canonical ABI-defined constant for the maximum number of “flat” parameters to a wasm function, or the maximum number of parameters a core wasm function will take for just the parameters used. Over this number the heap is used for transferring parameters.
MAX_FLAT_RESULTS
Canonical ABI-defined constant for the maximum number of “flat” results. This number of results are returned directly from wasm and otherwise results are transferred through memory.
MAX_FLAT_TYPES
Maximum number of flat types, for either params or results.
VMCOMPONENT_MAGIC
Equivalent of VMCONTEXT_MAGIC except for components.

Traits§

ComponentCompiler
Compilation support necessary for components.
NameMapIntern
A helper trait used in conjunction with NameMap to optionally intern keys to non-strings.