Move native signatures out of Module (#2362)

After compilation there's actually no need to hold onto the native
signature for a wasm function type, so this commit moves out the
`ir::Signature` value from a `Module` into a separate field that's
deallocated when compilation is finished. This simplifies the
`SignatureRegistry` because it only needs to track wasm functino types
and it also means less work is done for `Func::wrap`.
This commit is contained in:
Alex Crichton
2020-11-04 14:22:37 -06:00
committed by GitHub
parent dd9bfcefaa
commit 6b137c2a3d
13 changed files with 65 additions and 66 deletions

View File

@@ -2,7 +2,6 @@
use crate::tunables::Tunables;
use crate::WASM_MAX_PAGES;
use cranelift_codegen::ir;
use cranelift_entity::{EntityRef, PrimaryMap};
use cranelift_wasm::{
DataIndex, DefinedFuncIndex, DefinedGlobalIndex, DefinedMemoryIndex, DefinedTableIndex,
@@ -169,7 +168,7 @@ pub struct Module {
pub func_names: HashMap<FuncIndex, String>,
/// Unprocessed signatures exactly as provided by `declare_signature()`.
pub signatures: PrimaryMap<SignatureIndex, (WasmFuncType, ir::Signature)>,
pub signatures: PrimaryMap<SignatureIndex, WasmFuncType>,
/// Number of imported functions in the module.
pub num_imported_funcs: usize,
@@ -319,16 +318,10 @@ impl Module {
index.index() < self.num_imported_globals
}
/// Convenience method for looking up the native signature of a compiled
/// Wasm function.
pub fn native_func_signature(&self, func_index: FuncIndex) -> &ir::Signature {
&self.signatures[self.functions[func_index]].1
}
/// Convenience method for looking up the original Wasm signature of a
/// function.
pub fn wasm_func_type(&self, func_index: FuncIndex) -> &WasmFuncType {
&self.signatures[self.functions[func_index]].0
&self.signatures[self.functions[func_index]]
}
}