cranelift_wasm: expose the original Wasm function signature

In the `ModuleEnvironment::declare_signature` callback, also pass the original
Wasm function signature, so that consumers may associate this information with
each compiled function. This is often necessary because while each Wasm
signature gets compiled down into a single native signature, multiple Wasm
signatures might compile down into the same native signature, and in these cases
the original Wasm signature is required for dynamic type checking of calls.
This commit is contained in:
Nick Fitzgerald
2020-05-22 15:00:52 -07:00
parent 38a92d89de
commit acf8ad0df7
6 changed files with 36 additions and 36 deletions

View File

@@ -22,6 +22,13 @@ use thiserror::Error;
use wasmparser::BinaryReaderError;
use wasmparser::Operator;
// Re-export `wasmparser`'s function and value types so that consumers can
// associate this the original Wasm signature with each compiled function. This
// is often necessary because while each Wasm signature gets compiled down into
// a single native signature, multiple Wasm signatures might compile down into
// the same native signature.
pub use wasmparser::{FuncType as WasmFuncType, Type as WasmType};
/// The value of a WebAssembly global variable.
#[derive(Clone, Copy)]
pub enum GlobalVariable {
@@ -472,7 +479,11 @@ pub trait ModuleEnvironment<'data>: TargetEnvironment {
}
/// Declares a function signature to the environment.
fn declare_signature(&mut self, sig: ir::Signature) -> WasmResult<()>;
fn declare_signature(
&mut self,
wasm_func_type: &WasmFuncType,
sig: ir::Signature,
) -> WasmResult<()>;
/// Provides the number of imports up front. By default this does nothing, but
/// implementations can use this to preallocate memory if desired.