mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-23 13:41:32 +00:00
Add caching. (#134)
* Allow a module to have a different signature registry than the process-specific * Add core ability to build compiled code caches * Remove timing printouts * Serialize/Deserialize memories to reduce copies * Work more on api * Relocate local functions relatively before external functions * Fix incorrect definition in test * merge errors caused by merge * Fix emscripten compile * Fix review comments
This commit is contained in:
@ -4,6 +4,7 @@ use cranelift_codegen::{
|
||||
ir::{self, InstBuilder},
|
||||
isa,
|
||||
};
|
||||
use cranelift_entity::EntityRef;
|
||||
use cranelift_wasm::{self, FuncEnvironment, ModuleEnvironment};
|
||||
use std::mem;
|
||||
use wasmer_runtime_core::{
|
||||
@ -162,7 +163,7 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
offset: (local_memory_ptr_offset as i64).into(),
|
||||
global_type: ptr_type,
|
||||
}),
|
||||
self.env.module.memories[local_mem_index],
|
||||
self.env.module.info.memories[local_mem_index],
|
||||
)
|
||||
}
|
||||
LocalOrImport::Import(import_mem_index) => {
|
||||
@ -182,7 +183,7 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
offset: (local_memory_ptr_offset as i64).into(),
|
||||
global_type: ptr_type,
|
||||
}),
|
||||
self.env.module.imported_memories[import_mem_index].1,
|
||||
self.env.module.info.imported_memories[import_mem_index].1,
|
||||
)
|
||||
}
|
||||
};
|
||||
@ -273,7 +274,7 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
|
||||
(
|
||||
table_struct_ptr_ptr,
|
||||
self.env.module.tables[local_table_index],
|
||||
self.env.module.info.tables[local_table_index],
|
||||
)
|
||||
}
|
||||
LocalOrImport::Import(import_table_index) => {
|
||||
@ -295,7 +296,7 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
|
||||
(
|
||||
table_struct_ptr_ptr,
|
||||
self.env.module.imported_tables[import_table_index].1,
|
||||
self.env.module.info.imported_tables[import_table_index].1,
|
||||
)
|
||||
}
|
||||
};
|
||||
@ -367,7 +368,8 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
func.import_function(ir::ExtFuncData {
|
||||
name,
|
||||
signature,
|
||||
colocated: false,
|
||||
// Make this colocated so all calls between local functions are relative.
|
||||
colocated: true,
|
||||
})
|
||||
}
|
||||
|
||||
@ -428,9 +430,24 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
|
||||
pos.ins().trapz(func_ptr, ir::TrapCode::IndirectCallToNull);
|
||||
|
||||
let sig_index = self.env.deduplicated[clif_sig_index];
|
||||
let expected_sig = {
|
||||
let sig_index_global = pos.func.create_global_value(ir::GlobalValueData::Symbol {
|
||||
// The index of the `ExternalName` is the undeduplicated, signature index.
|
||||
name: ir::ExternalName::user(
|
||||
call_names::SIG_NAMESPACE,
|
||||
clif_sig_index.index() as u32,
|
||||
),
|
||||
offset: 0.into(),
|
||||
colocated: false,
|
||||
});
|
||||
|
||||
pos.ins().symbol_value(ir::types::I64, sig_index_global)
|
||||
|
||||
// let expected_sig = pos.ins().iconst(ir::types::I32, sig_index.index() as i64);
|
||||
|
||||
// self.env.deduplicated[clif_sig_index]
|
||||
};
|
||||
|
||||
let expected_sig = pos.ins().iconst(ir::types::I32, sig_index.index() as i64);
|
||||
let not_equal_flags = pos.ins().ifcmp(found_sig, expected_sig);
|
||||
|
||||
pos.ins().trapif(
|
||||
@ -555,12 +572,12 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
LocalOrImport::Local(local_mem_index) => (
|
||||
call_names::LOCAL_NAMESPACE,
|
||||
local_mem_index.index(),
|
||||
self.env.module.memories[local_mem_index],
|
||||
self.env.module.info.memories[local_mem_index],
|
||||
),
|
||||
LocalOrImport::Import(import_mem_index) => (
|
||||
call_names::IMPORT_NAMESPACE,
|
||||
import_mem_index.index(),
|
||||
self.env.module.imported_memories[import_mem_index].1,
|
||||
self.env.module.info.imported_memories[import_mem_index].1,
|
||||
),
|
||||
};
|
||||
|
||||
@ -618,12 +635,12 @@ impl<'env, 'module, 'isa> FuncEnvironment for FuncEnv<'env, 'module, 'isa> {
|
||||
LocalOrImport::Local(local_mem_index) => (
|
||||
call_names::LOCAL_NAMESPACE,
|
||||
local_mem_index.index(),
|
||||
self.env.module.memories[local_mem_index],
|
||||
self.env.module.info.memories[local_mem_index],
|
||||
),
|
||||
LocalOrImport::Import(import_mem_index) => (
|
||||
call_names::IMPORT_NAMESPACE,
|
||||
import_mem_index.index(),
|
||||
self.env.module.imported_memories[import_mem_index].1,
|
||||
self.env.module.info.imported_memories[import_mem_index].1,
|
||||
),
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user