Module wasmtime_environ::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§
- A dataflow-graph-like intermediate representation of a component
Structs§
- Metadata information about a fused adapter.
- Configuration options which can be specified as part of the canonical ABI in the component model.
- A triple of related functions/trampolines variants with differing calling conventions:
{wasm,array}_call
. - Bye information about a type in the canonical ABI, with metadata for both memory32 and memory64-based types.
- Canonical ABI options associated with a lifted or lowered function.
- Runtime state that a component retains to support its operation.
- Run-time-type-information about a
Component
, its structure, and how to instantiate it. - Serializable state that’s stored in a compilation artifact.
- Index within a component’s component function index space.
- Index within a component’s component index space.
- Index within a component’s component instance index space.
- Metadata as a result of compiling a component.
- Index within a component’s component type index space.
- Runtime information about the type information contained within a component.
- Structured used to build a
ComponentTypes
during translation. - Same as
ModuleUpvarIndex
but for components. - Identifier of an exported item from a core WebAssembly module instance.
- Index pointing to a local resource defined within a component.
- An index into
Component::export_items
at the end of compilation. - Metadata for extraction of a memory of what’s being extracted and where it’s going.
- Same as
ExtractMemory
but for thepost-return
canonical option. - Same as
ExtractMemory
but for therealloc
canonical option. - Flat representation of a type in just core wasm types.
- Used to index imports into a
Component
- Index that represents a lowered host function and is used to represent host function lowerings with options and such.
- Index within a component’s module index space.
- Index within a component’s module instance index space.
- 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. - A semver-aware map for imports/exports of a component.
- For use with
NameMap
when no interning should happen and instead string keys are copied as-is. - One field within a record.
- Description of a new resource declared in a
GlobalInitializer::Resource
variant. - Index pointing to a resource within a component.
- Builder state used to translate wasmparser’s
ResourceId
types to Wasmtime’sTypeResourceTableIndex
type. - Same as
RuntimeInstanceIndex
but tracks component instances instead. - Index that represents a leaf item imported into a component where a “leaf” means “not an instance”.
- Index that represents a core wasm instance created at runtime.
- 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
. - Same as
RuntimeMemoryIndex
except for thepost-return
function. - Same as
RuntimeMemoryIndex
except for therealloc
function. - Same as
StaticModuleIndex
but for components. - Index for all trampolines that are compiled in Cranelift for a component.
- Structure used to translate a component and parse it.
- The type of a component in the component model.
- Index pointing to a component’s type (exports/imports with component-model types)
- The type of a component instance in the component model, or an instantiated component.
- Index pointing to a component instance’s type (exports with component-model types, no imports)
- Shape of an “enum” type in interface types, not to be confused with a Rust
enum
type. - Index pointing to an enum type in the component model.
- Shape of a “flags” type in interface types.
- Index pointing to a flags type in the component model.
- A component function type in the component model.
- Index pointing to a component model function type with arguments/result as interface types.
- Shape of a “list” interface type.
- Index pointing to a list type in the component model.
- The type of a module in the component model.
- Index pointing to a core wasm module’s type (exports/imports with core wasm types)
- Shape of an “option” interface type.
- Index pointing to an option type in the component model (aka a
Option<T, E>
) - Shape of a “record” type in interface types.
- Index pointing to a record type in the component model (aka a struct).
- Metadata about a resource table added to a component.
- Index pointing to a resource table within a component.
- Shape of a “result” interface type.
- Index pointing to an result type in the component model (aka a
Result<T, E>
) - Shape of a “tuple” type in interface types.
- Index pointing to a tuple type in the component model.
- Shape of a “variant” type in interface types.
- Index pointing to a variant type in the component model (aka an enum).
- Runtime offsets within a
VMComponentContext
for a specific component. - ABI information about the representation of a variant.
Enums§
- Equivalent of
EntityIndex
but for the component model instead of core wasm. - Definition of a core wasm item and where it can come from within a component.
- Possible exports from a component.
- An index at which to find an item within a runtime instance.
- GlobalInitializer instructions to get processed when instantiating a component
- Different methods of instantiating a core wasm module.
- All possible interface types that values can have.
- Possible encodings of strings within the component model.
- A list of all possible trampolines that may be required to compile a component completely.
- Possible transcoding operations that must be provided by the host.
- Types of imports and exports in the component model.
Constants§
- Flag for the
VMComponentContext::flags
field which corresponds to the canonical ABI flagmay_enter
- Flag for the
VMComponentContext::flags
field which corresponds to the canonical ABI flagmay_leave
- Flag for the
VMComponentContext::flags
field which is set whenever a function is called to indicate thatpost_return
must be called next. - 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.
- 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.
- Maximum number of flat types, for either params or results.
- Equivalent of
VMCONTEXT_MAGIC
except for components.
Traits§
- Compilation support necessary for components.
- A helper trait used in conjunction with
NameMap
to optionally intern keys to non-strings.