pub struct ExceptionTableData { /* private fields */ }
Expand description
Contents of an exception table.
An exception table consists of a “no exception” (“normal”) destination block-call, and a series of exceptional destination block-calls associated with tags.
The exceptional tags can also be interspersed with “dynamic context” entries, which result in a particular value being stored in the stack frame and accessible at an offset given in the compiled exception-table metadata. This is needed for some kinds of tag-matching where different dynamic instances of tags may exist (e.g., in the WebAssembly exception-handling proposal).
The sequence of targets is semantically a list of
context-or-tagged-blockcall; e.g., [context v0, tag1: block1(v1, v2), context v2, tag2: block2(), tag3: block3()]
.
The “no exception” target can be accessed through the
normal_return
and normal_return_mut
functions. Exceptional
catch clauses may be iterated using the catches
and
catches_mut
functions. All targets may be iterated over using
the all_targets
and all_targets_mut
functions.
Implementations§
Source§impl ExceptionTableData
impl ExceptionTableData
Sourcepub fn new(
sig: SigRef,
normal_return: BlockCall,
matches: impl IntoIterator<Item = ExceptionTableItem>,
) -> Self
pub fn new( sig: SigRef, normal_return: BlockCall, matches: impl IntoIterator<Item = ExceptionTableItem>, ) -> Self
Create new exception-table data.
This data represents the destinations upon return from
try_call
or try_call_indirect
instruction. There are two
possibilities: “normal return” (no exception thrown), or an
exceptional return corresponding to one of the listed
exception tags.
The given tags are passed through to the metadata provided
alongside the provided function body, and Cranelift itself
does not implement an unwinder; thus, the meaning of the tags
is ultimately up to the embedder of Cranelift. The tags are
wrapped in Option
to allow encoding a “catch-all” handler.
The BlockCalls must have signatures that match the targeted
blocks, as usual. These calls are allowed to use
BlockArg::TryCallRet
in the normal-return case, with types
corresponding to the signature’s return values, and
BlockArg::TryCallExn
in the exceptional-return cases, with
types corresponding to native machine words and an arity
corresponding to the number of payload values that the calling
convention and platform support. (See [isa::CallConv
] for
more details.)
Sourcepub fn display<'a>(
&'a self,
pool: &'a ValueListPool,
) -> DisplayExceptionTable<'a>
pub fn display<'a>( &'a self, pool: &'a ValueListPool, ) -> DisplayExceptionTable<'a>
Return a value that can display the contents of this exception table.
Sourcepub fn deep_clone(&self, pool: &mut ValueListPool) -> Self
pub fn deep_clone(&self, pool: &mut ValueListPool) -> Self
Deep-clone this exception table.
Sourcepub fn normal_return(&self) -> &BlockCall
pub fn normal_return(&self) -> &BlockCall
Get the default target for the non-exceptional return case.
Sourcepub fn normal_return_mut(&mut self) -> &mut BlockCall
pub fn normal_return_mut(&mut self) -> &mut BlockCall
Get the default target for the non-exceptional return case.
Sourcepub fn items(&self) -> impl Iterator<Item = ExceptionTableItem> + '_
pub fn items(&self) -> impl Iterator<Item = ExceptionTableItem> + '_
Get the exception-catch items: dynamic context updates for interpreting tags, tag-associated targets, and catch-all targets.
Sourcepub fn all_branches(&self) -> &[BlockCall]
pub fn all_branches(&self) -> &[BlockCall]
Get all branch targets.
Sourcepub fn all_branches_mut(&mut self) -> &mut [BlockCall]
pub fn all_branches_mut(&mut self) -> &mut [BlockCall]
Get all branch targets.
Trait Implementations§
Source§impl Clone for ExceptionTableData
impl Clone for ExceptionTableData
Source§fn clone(&self) -> ExceptionTableData
fn clone(&self) -> ExceptionTableData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more