pub enum GlobalInitializer {
InstantiateModule(InstantiateModule),
LowerImport {
index: LoweredIndex,
import: RuntimeImportIndex,
},
ExtractMemory(ExtractMemory),
ExtractRealloc(ExtractRealloc),
ExtractPostReturn(ExtractPostReturn),
Resource(Resource),
}Expand description
GlobalInitializer instructions to get processed when instantiating a component
The variants of this enum are processed during the instantiation phase of a component in-order from front-to-back. These are otherwise emitted as a component is parsed and read and translated.
Variants§
InstantiateModule(InstantiateModule)
A core wasm module is being instantiated.
This will result in a new core wasm instance being created, which may
involve running the start function of the instance as well if it’s
specified. This largely delegates to the same standard instantiation
process as the rest of the core wasm machinery already uses.
LowerImport
A host function is being lowered, creating a core wasm function.
This initializer entry is intended to be used to fill out the
VMComponentContext and information about this lowering such as the
cranelift-compiled trampoline function pointer, the host function
pointer the trampoline calls, and the canonical ABI options.
Fields
index: LoweredIndexThe index of the lowered function that’s being created.
This is guaranteed to be the nth LowerImport instruction
if the index is n.
import: RuntimeImportIndexThe index of the imported host function that is being lowered.
It’s guaranteed that this RuntimeImportIndex points to a function.
ExtractMemory(ExtractMemory)
A core wasm linear memory is going to be saved into the
VMComponentContext.
This instruction indicates that the indexth core wasm linear memory
needs to be extracted from the export specified, a pointer to a
previously created module instance, and stored into the
VMComponentContext at the index specified. This lowering is then
used in the future by pointers from CanonicalOptions.
ExtractRealloc(ExtractRealloc)
Same as ExtractMemory, except it’s extracting a function pointer to be
used as a realloc function.
ExtractPostReturn(ExtractPostReturn)
Same as ExtractMemory, except it’s extracting a function pointer to be
used as a post-return function.
Resource(Resource)
Declares a new defined resource within this component.
Contains information about the destructor, for example.