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.
- Adapter
Options - Configuration options which can be specified as part of the canonical ABI in the component model.
- AllCall
Func - A triple of related functions/trampolines variants with differing calling
conventions:
{wasm,array}_call
. - Canonical
AbiInfo - Bye information about a type in the canonical ABI, with metadata for both memory32 and memory64-based types.
- Canonical
Options - Canonical ABI options associated with a lifted or lowered function.
- Compiled
Component Info - 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. - Component
Artifacts - Serializable state that’s stored in a compilation artifact.
- Component
Builtin Function Index - An index type for builtin functions.
- Component
Func Index - Index within a component’s component function index space.
- Component
Index - Index within a component’s component index space.
- Component
Instance Index - Index within a component’s component instance index space.
- Component
Translation - Metadata as a result of compiling a component.
- Component
Type Index - Index within a component’s component type index space.
- Component
Types - Runtime information about the type information contained within a component.
- Component
Types Builder - Structured used to build a
ComponentTypes
during translation. - Component
Upvar Index - Same as
ModuleUpvarIndex
but for components. - Core
Export - Identifier of an exported item from a core WebAssembly module instance.
- Defined
Resource Index - Index pointing to a local resource defined within a component.
- Export
Index - An index into
Component::export_items
at the end of compilation. - Extract
Memory - Metadata for extraction of a memory of what’s being extracted and where it’s going.
- Extract
Post Return - Same as
ExtractMemory
but for thepost-return
canonical option. - Extract
Realloc - Same as
ExtractMemory
but for therealloc
canonical option. - Flat
Types - Flat representation of a type in just core wasm types.
- Import
Index - Used to index imports into a
Component
- Lowered
Index - Index that represents a lowered host function and is used to represent host function lowerings with options and such.
- Module
Index - Index within a component’s module index space.
- Module
Instance Index - Index within a component’s module instance index space.
- Module
Upvar Index - 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.
- Name
MapNo Intern - For use with
NameMap
when no interning should happen and instead string keys are copied as-is. - Record
Field - One field within a record.
- Resource
- Description of a new resource declared in a
GlobalInitializer::Resource
variant. - Resource
Index - Index pointing to a resource within a component.
- Resources
Builder - Builder state used to translate wasmparser’s
ResourceId
types to Wasmtime’sTypeResourceTableIndex
type. - Runtime
Component Instance Index - Same as
RuntimeInstanceIndex
but tracks component instances instead. - Runtime
Import Index - Index that represents a leaf item imported into a component where a “leaf” means “not an instance”.
- Runtime
Instance Index - Index that represents a core wasm instance created at runtime.
- Runtime
Memory Index - 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 aVMComponentContext
. - Runtime
Post Return Index - Same as
RuntimeMemoryIndex
except for thepost-return
function. - Runtime
Realloc Index - Same as
RuntimeMemoryIndex
except for therealloc
function. - Static
Component Index - Same as
StaticModuleIndex
but for components. - Trampoline
Index - Index for all trampolines that are compiled in Cranelift for a component.
- Translator
- Structure used to translate a component and parse it.
- Type
Component - The type of a component in the component model.
- Type
Component Index - Index pointing to a component’s type (exports/imports with component-model types)
- Type
Component Instance - The type of a component instance in the component model, or an instantiated component.
- Type
Component Instance Index - Index pointing to a component instance’s type (exports with component-model types, no imports)
- Type
Enum - Shape of an “enum” type in interface types, not to be confused with a Rust
enum
type. - Type
Enum Index - Index pointing to an enum type in the component model.
- Type
Flags - Shape of a “flags” type in interface types.
- Type
Flags Index - Index pointing to a flags type in the component model.
- Type
Func - A component function type in the component model.
- Type
Func Index - Index pointing to a component model function type with arguments/result as interface types.
- Type
List - Shape of a “list” interface type.
- Type
List Index - Index pointing to a list type in the component model.
- Type
Module - The type of a module in the component model.
- Type
Module Index - Index pointing to a core wasm module’s type (exports/imports with core wasm types)
- Type
Option - Shape of an “option” interface type.
- Type
Option Index - Index pointing to an option type in the component model (aka a
Option<T, E>
) - Type
Record - Shape of a “record” type in interface types.
- Type
Record Index - Index pointing to a record type in the component model (aka a struct).
- Type
Resource Table - Metadata about a resource table added to a component.
- Type
Resource Table Index - Index pointing to a resource table within a component.
- Type
Result - Shape of a “result” interface type.
- Type
Result Index - Index pointing to an result type in the component model (aka a
Result<T, E>
) - Type
Tuple - Shape of a “tuple” type in interface types.
- Type
Tuple Index - Index pointing to a tuple type in the component model.
- Type
Variant - Shape of a “variant” type in interface types.
- Type
Variant Index - Index pointing to a variant type in the component model (aka an enum).
- VMComponent
Offsets - Runtime offsets within a
VMComponentContext
for a specific component. - Variant
Info - ABI information about the representation of a variant.
Enums§
- Component
Item - 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.
- Export
Item - An index at which to find an item within a runtime instance.
- Fixed
Encoding - Flat
Type - Global
Initializer - GlobalInitializer instructions to get processed when instantiating a component
- Instantiate
Module - Different methods of instantiating a core wasm module.
- Interface
Type - All possible interface types that values can have.
- String
Encoding - 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 flagmay_enter
- FLAG_
MAY_ LEAVE - Flag for the
VMComponentContext::flags
field which corresponds to the canonical ABI flagmay_leave
- FLAG_
NEEDS_ POST_ RETURN - Flag for the
VMComponentContext::flags
field which is set whenever a function is called to indicate thatpost_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§
- Component
Compiler - Compilation support necessary for components.
- Name
MapIntern - A helper trait used in conjunction with
NameMap
to optionally intern keys to non-strings.