pub enum Trampoline {
Show 38 variants
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),
TaskBackpressure {
instance: RuntimeComponentInstanceIndex,
},
TaskReturn,
TaskWait {
instance: RuntimeComponentInstanceIndex,
async_: bool,
memory: RuntimeMemoryIndex,
},
TaskPoll {
instance: RuntimeComponentInstanceIndex,
async_: bool,
memory: RuntimeMemoryIndex,
},
TaskYield {
async_: bool,
},
SubtaskDrop {
instance: RuntimeComponentInstanceIndex,
},
StreamNew {
ty: TypeStreamTableIndex,
},
StreamRead {
ty: TypeStreamTableIndex,
options: CanonicalOptions,
},
StreamWrite {
ty: TypeStreamTableIndex,
options: CanonicalOptions,
},
StreamCancelRead {
ty: TypeStreamTableIndex,
async_: bool,
},
StreamCancelWrite {
ty: TypeStreamTableIndex,
async_: bool,
},
StreamCloseReadable {
ty: TypeStreamTableIndex,
},
StreamCloseWritable {
ty: TypeStreamTableIndex,
},
FutureNew {
ty: TypeFutureTableIndex,
},
FutureRead {
ty: TypeFutureTableIndex,
options: CanonicalOptions,
},
FutureWrite {
ty: TypeFutureTableIndex,
options: CanonicalOptions,
},
FutureCancelRead {
ty: TypeFutureTableIndex,
async_: bool,
},
FutureCancelWrite {
ty: TypeFutureTableIndex,
async_: bool,
},
FutureCloseReadable {
ty: TypeFutureTableIndex,
},
FutureCloseWritable {
ty: TypeFutureTableIndex,
},
ErrorContextNew {
ty: TypeComponentLocalErrorContextTableIndex,
options: CanonicalOptions,
},
ErrorContextDebugMessage {
ty: TypeComponentLocalErrorContextTableIndex,
options: CanonicalOptions,
},
ErrorContextDrop {
ty: TypeComponentLocalErrorContextTableIndex,
},
ResourceTransferOwn,
ResourceTransferBorrow,
ResourceEnterCall,
ResourceExitCall,
AsyncEnterCall,
AsyncExitCall {
callback: Option<RuntimeCallbackIndex>,
post_return: Option<RuntimePostReturnIndex>,
},
FutureTransfer,
StreamTransfer,
ErrorContextTransfer,
}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: LoweredIndexThe runtime lowering state that this trampoline will access.
lower_ty: TypeFuncIndexThe type of the function that is being lowered, as perceived by the component doing the lowering.
options: CanonicalOptionsThe 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
reallocfor 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: RuntimeMemoryIndexThe linear memory that the string is being read from.
to: RuntimeMemoryIndexThe 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.
TaskBackpressure
A task.backpressure intrinsic, which tells the host to enable or
disable backpressure for the caller’s instance.
Fields
instance: RuntimeComponentInstanceIndexThe specific component instance which is calling the intrinsic.
TaskReturn
A task.return intrinsic, which returns a result to the caller of a
lifted export function. This allows the callee to continue executing
after returning a result.
TaskWait
A task.wait intrinsic, which waits for at least one outstanding async
task/stream/future to make progress, returning the first such event.
Fields
instance: RuntimeComponentInstanceIndexThe specific component instance which is calling the intrinsic.
memory: RuntimeMemoryIndexMemory to use when storing the event.
TaskPoll
A task.poll intrinsic, which checks whether any outstanding async
task/stream/future has made progress. Unlike task.wait, this does not
block and may return nothing if no such event has occurred.
Fields
instance: RuntimeComponentInstanceIndexThe specific component instance which is calling the intrinsic.
memory: RuntimeMemoryIndexMemory to use when storing the event.
TaskYield
A task.yield intrinsic, which yields control to the host so that other
tasks are able to make progress, if any.
SubtaskDrop
A subtask.drop intrinsic to drop a specified task which has completed.
Fields
instance: RuntimeComponentInstanceIndexThe specific component instance which is calling the intrinsic.
StreamNew
A stream.new intrinsic to create a new stream handle of the
specified type.
Fields
ty: TypeStreamTableIndexThe table index for the specific stream type and caller instance.
StreamRead
A stream.read intrinsic to read from a stream of the specified type.
Fields
ty: TypeStreamTableIndexThe table index for the specific stream type and caller instance.
options: CanonicalOptionsAny options (e.g. string encoding) to use when storing values to memory.
StreamWrite
A stream.write intrinsic to write to a stream of the specified type.
Fields
ty: TypeStreamTableIndexThe table index for the specific stream type and caller instance.
options: CanonicalOptionsAny options (e.g. string encoding) to use when storing values to memory.
StreamCancelRead
A stream.cancel-read intrinsic to cancel an in-progress read from a
stream of the specified type.
Fields
ty: TypeStreamTableIndexThe table index for the specific stream type and caller instance.
StreamCancelWrite
A stream.cancel-write intrinsic to cancel an in-progress write from a
stream of the specified type.
Fields
ty: TypeStreamTableIndexThe table index for the specific stream type and caller instance.
StreamCloseReadable
A stream.close-readable intrinsic to close the readable end of a
stream of the specified type.
Fields
ty: TypeStreamTableIndexThe table index for the specific stream type and caller instance.
StreamCloseWritable
A stream.close-writable intrinsic to close the writable end of a
stream of the specified type.
Fields
ty: TypeStreamTableIndexThe table index for the specific stream type and caller instance.
FutureNew
A future.new intrinsic to create a new future handle of the
specified type.
Fields
ty: TypeFutureTableIndexThe table index for the specific future type and caller instance.
FutureRead
A future.read intrinsic to read from a future of the specified type.
Fields
ty: TypeFutureTableIndexThe table index for the specific future type and caller instance.
options: CanonicalOptionsAny options (e.g. string encoding) to use when storing values to memory.
FutureWrite
A future.write intrinsic to write to a future of the specified type.
Fields
ty: TypeFutureTableIndexThe table index for the specific future type and caller instance.
options: CanonicalOptionsAny options (e.g. string encoding) to use when storing values to memory.
FutureCancelRead
A future.cancel-read intrinsic to cancel an in-progress read from a
future of the specified type.
Fields
ty: TypeFutureTableIndexThe table index for the specific future type and caller instance.
FutureCancelWrite
A future.cancel-write intrinsic to cancel an in-progress write from a
future of the specified type.
Fields
ty: TypeFutureTableIndexThe table index for the specific future type and caller instance.
FutureCloseReadable
A future.close-readable intrinsic to close the readable end of a
future of the specified type.
Fields
ty: TypeFutureTableIndexThe table index for the specific future type and caller instance.
FutureCloseWritable
A future.close-writable intrinsic to close the writable end of a
future of the specified type.
Fields
ty: TypeFutureTableIndexThe table index for the specific future type and caller instance.
ErrorContextNew
A error-context.new intrinsic to create a new error-context with a
specified debug message.
Fields
ty: TypeComponentLocalErrorContextTableIndexThe table index for the error-context type in the caller instance.
options: CanonicalOptionsString encoding, memory, etc. to use when loading debug message.
ErrorContextDebugMessage
A error-context.debug-message intrinsic to get the debug message for a
specified error-context.
Note that the debug message might not necessarily match what was passed
to error.new.
Fields
ty: TypeComponentLocalErrorContextTableIndexThe table index for the error-context type in the caller instance.
options: CanonicalOptionsString encoding, memory, etc. to use when storing debug message.
ErrorContextDrop
A error-context.drop intrinsic to drop a specified error-context.
Fields
ty: TypeComponentLocalErrorContextTableIndexThe table index for the error-context type in the caller instance.
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.
AsyncEnterCall
An intrinsic used by FACT-generated modules to begin a call to an async-lowered import function.
AsyncExitCall
An intrinsic used by FACT-generated modules to complete a call to an async-lowered import function.
Note that AsyncEnterCall and AsyncExitCall could theoretically be
combined into a single AsyncCall intrinsic, but we separate them to
allow the FACT-generated module to optionally call the callee directly
without an intermediate host stack frame.
Fields
callback: Option<RuntimeCallbackIndex>The callee’s callback, if any.
post_return: Option<RuntimePostReturnIndex>The callee’s post-return function, if any.
FutureTransfer
An intrinisic used by FACT-generated modules to (partially or entirely) transfer
ownership of a future.
Transfering a future can either mean giving away the readable end
while retaining the writable end or only the former, depending on the
ownership status of the future.
StreamTransfer
An intrinisic used by FACT-generated modules to (partially or entirely) transfer
ownership of a stream.
Transfering a stream can either mean giving away the readable end
while retaining the writable end or only the former, depending on the
ownership status of the stream.
ErrorContextTransfer
An intrinisic used by FACT-generated modules to (partially or entirely) transfer
ownership of an error-context.
Unlike futures, streams, and resource handles, error-context handles
are reference counted, meaning that sharing the handle with another
component does not invalidate the handle in the original component.
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