Add a FuncEnvironment::make_direct_func() callback.
This allows the environment to control the signatures used for direct
function calls. The signature and calling convention may depend on
whether the function is imported or local.
Also add WasmRuntime::declare_func_{import,type} to notify the runtime
about imported and local functions. This is necessary so the runtime
knows what function indexes are referring to .
Since imported and local functions are now declared to the runtime, it
is no longer necessary to return hashes mapping between WebAssembly
indexes and Cretonne entities.
Also stop return null entries for the imported functions in the
TranslationResult. Just return a vector of local functions.
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
use wasmparser;
|
||||
use cretonne;
|
||||
use std::u32;
|
||||
use code_translator;
|
||||
use module_translator;
|
||||
|
||||
/// Index of a function (imported or defined) inside the WebAssembly module.
|
||||
pub type FunctionIndex = usize;
|
||||
@@ -135,19 +133,3 @@ pub fn translate_type(ty: wasmparser::Type) -> Result<Vec<cretonne::ir::Type>, (
|
||||
_ => panic!("unsupported return value type"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Inverts the key-value relation in the imports hashmap. Indeed, these hashmaps are built by
|
||||
/// feeding the function indexes in the module but are used by the runtime with the `FuncRef` as
|
||||
/// keys.
|
||||
pub fn invert_hashmaps(
|
||||
imports: &code_translator::FunctionImports,
|
||||
) -> module_translator::ImportMappings {
|
||||
let mut new_imports = module_translator::ImportMappings::new();
|
||||
for (func_index, func_ref) in &imports.functions {
|
||||
new_imports.functions.insert(*func_ref, *func_index);
|
||||
}
|
||||
for (sig_index, sig_ref) in &imports.signatures {
|
||||
new_imports.signatures.insert(*sig_ref, *sig_index);
|
||||
}
|
||||
new_imports
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user