cranelift-module: expose trap information when defining functions

The current interface of `cranelift-module` requires consumers who want
to be informed about traps to discover that information through
`Module::Product`, which is backend-specific.  Since it's advantageous
to manipulate this information in a backend-agnostic way, this patch
changes `Module::define_function{,_bytes}` to return information about
the traps contained in the function being defined.
This commit is contained in:
Nathan Froyd
2020-03-03 11:27:45 -05:00
parent f7c2a58d23
commit 0f49a830c9
6 changed files with 60 additions and 37 deletions

View File

@@ -86,7 +86,7 @@ where
ctx: &Context,
namespace: &ModuleNamespace<Self>,
code_size: u32,
) -> ModuleResult<Self::CompiledFunction>;
) -> ModuleResult<(Self::CompiledFunction, Option<&Vec<TrapSite>>)>;
/// Define a function, taking the function body from the given `bytes`.
///
@@ -98,7 +98,7 @@ where
bytes: &[u8],
namespace: &ModuleNamespace<Self>,
traps: Vec<TrapSite>,
) -> ModuleResult<Self::CompiledFunction>;
) -> ModuleResult<(Self::CompiledFunction, Option<&Vec<TrapSite>>)>;
/// Define a zero-initialized data object of the given size.
///