pub enum Trampoline {
LowerImport {
index: LoweredIndex,
lower_ty: TypeFuncIndex,
options: CanonicalOptions,
},
Transcoder {
op: Transcode,
from: RuntimeMemoryIndex,
from64: bool,
to: RuntimeMemoryIndex,
to64: bool,
},
AlwaysTrap,
ResourceNew(TypeResourceTableIndex),
ResourceRep(TypeResourceTableIndex),
ResourceDrop(TypeResourceTableIndex),
ResourceTransferOwn,
ResourceTransferBorrow,
ResourceEnterCall,
ResourceExitCall,
}
Expand description
A list of all possible trampolines that may be required to compile a component completely.
These trampolines are used often as core wasm definitions and require Cranelift support to generate these functions. Each trampoline serves a different purpose for implementing bits and pieces of the component model.
All trampolines have a core wasm function signature associated with them
which is stored in the Component::trampolines
array.
Note that this type does not implement Serialize
or Deserialize
and
that’s intentional as this isn’t stored in the final compilation artifact.
Variants§
LowerImport
Description of a lowered import used in conjunction with
GlobalInitializer::LowerImport
.
Fields
index: LoweredIndex
The runtime lowering state that this trampoline will access.
lower_ty: TypeFuncIndex
The type of the function that is being lowered, as perceived by the component doing the lowering.
options: CanonicalOptions
The canonical ABI options used when lowering this function specified in the original component.
Transcoder
Information about a string transcoding function required by an adapter module.
A transcoder is used when strings are passed between adapter modules, optionally changing string encodings at the same time. The transcoder is implemented in a few different layers:
- Each generated adapter module has some glue around invoking the
transcoder represented by this item. This involves bounds-checks and
handling
realloc
for example. - Each transcoder gets a cranelift-generated trampoline which has the appropriate signature for the adapter module in question. Existence of this initializer indicates that this should be compiled by Cranelift.
- The cranelift-generated trampoline will invoke a “transcoder libcall” which is implemented natively in Rust that has a signature independent of memory64 configuration options for example.
Fields
from: RuntimeMemoryIndex
The linear memory that the string is being read from.
to: RuntimeMemoryIndex
The linear memory that the string is being written to.
AlwaysTrap
A small adapter which simply traps, used for degenerate lift/lower combinations.
ResourceNew(TypeResourceTableIndex)
A resource.new
intrinsic which will inject a new resource into the
table specified.
ResourceRep(TypeResourceTableIndex)
Same as ResourceNew
, but for the resource.rep
intrinsic.
ResourceDrop(TypeResourceTableIndex)
Same as ResourceNew
, but for the resource.drop
intrinsic.
ResourceTransferOwn
An intrinsic used by FACT-generated modules which will transfer an owned resource from one table to another. Used in component-to-component adapter trampolines.
ResourceTransferBorrow
Same as ResourceTransferOwn
but for borrows.
ResourceEnterCall
An intrinsic used by FACT-generated modules which indicates that a call is being entered and resource-related metadata needs to be configured.
Note that this is currently only invoked when borrowed resources are detected, otherwise this is “optimized out”.
ResourceExitCall
Same as ResourceEnterCall
except for when exiting a call.
Implementations§
Source§impl Trampoline
impl Trampoline
Sourcepub fn symbol_name(&self) -> String
pub fn symbol_name(&self) -> String
Returns the name to use for the symbol of this trampoline in the final compiled artifact