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

@@ -7,7 +7,7 @@ use cranelift_entity::PrimaryMap;
use cranelift_wasm::{
self, translate_module, DataIndex, DefinedFuncIndex, ElemIndex, FuncIndex, Global, GlobalIndex,
Memory, MemoryIndex, ModuleTranslationState, SignatureIndex, Table, TableIndex,
TargetEnvironment, WasmError, WasmResult,
TargetEnvironment, WasmError, WasmFuncType, WasmResult,
};
use std::convert::TryFrom;
use std::sync::Arc;
@@ -106,7 +106,7 @@ impl<'data> cranelift_wasm::ModuleEnvironment<'data> for ModuleEnvironment<'data
Ok(())
}
fn declare_signature(&mut self, sig: ir::Signature) -> WasmResult<()> {
fn declare_signature(&mut self, _wasm: &WasmFuncType, sig: ir::Signature) -> WasmResult<()> {
let sig = translate_signature(sig, self.pointer_type());
// TODO: Deduplicate signatures.
self.result.module.local.signatures.push(sig);