Remove some allocations in CodeMemory (#3253)
* Remove some allocations in `CodeMemory` This commit removes the `FinishedFunctions` type as well as allocations associated with trampolines when allocating inside of a `CodeMemory`. The main goal of this commit is to improve the time spent in `CodeMemory` where currently today a good portion of time is spent simply parsing symbol names and trying to extract function indices from them. Instead this commit implements a new strategy (different from #3236) where compilation records offset/length information for all functions/trampolines so this doesn't need to be re-learned from the object file later. A consequence of this commit is that this offset information will be decoded/encoded through `bincode` unconditionally, but we can also optimize that later if necessary as well. Internally this involved quite a bit of refactoring since the previous map for `FinishedFunctions` was relatively heavily relied upon. * comments
This commit is contained in:
@@ -95,7 +95,7 @@ use cranelift_entity::PrimaryMap;
|
||||
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, WasmFuncType, WasmType};
|
||||
use target_lexicon::CallingConvention;
|
||||
use wasmtime_environ::{
|
||||
FilePos, FunctionInfo, InstructionAddressMap, Module, TrapInformation, TypeTables,
|
||||
FilePos, FunctionInfo, InstructionAddressMap, ModuleTranslation, TrapInformation, TypeTables,
|
||||
};
|
||||
|
||||
pub use builder::builder;
|
||||
@@ -257,16 +257,16 @@ fn indirect_signature(isa: &dyn TargetIsa, wasm: &WasmFuncType) -> ir::Signature
|
||||
/// use a custom theoretically faster calling convention instead of the default.
|
||||
fn func_signature(
|
||||
isa: &dyn TargetIsa,
|
||||
module: &Module,
|
||||
translation: &ModuleTranslation,
|
||||
types: &TypeTables,
|
||||
index: FuncIndex,
|
||||
) -> ir::Signature {
|
||||
let call_conv = match module.defined_func_index(index) {
|
||||
let call_conv = match translation.module.defined_func_index(index) {
|
||||
// If this is a defined function in the module and it's never possibly
|
||||
// exported, then we can optimize this function to use the fastest
|
||||
// calling convention since it's purely an internal implementation
|
||||
// detail of the module itself.
|
||||
Some(idx) if !module.possibly_exported_funcs.contains(&idx) => CallConv::Fast,
|
||||
Some(idx) if !translation.escaped_funcs.contains(&idx) => CallConv::Fast,
|
||||
|
||||
// ... otherwise if it's an imported function or if it's a possibly
|
||||
// exported function then we use the default ABI wasmtime would
|
||||
@@ -277,7 +277,7 @@ fn func_signature(
|
||||
push_types(
|
||||
isa,
|
||||
&mut sig,
|
||||
&types.wasm_signatures[module.functions[index]],
|
||||
&types.wasm_signatures[translation.module.functions[index]],
|
||||
);
|
||||
return sig;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user