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:
@@ -51,6 +51,19 @@ pub trait FuncEnvironment {
|
||||
/// The signature will only be used for indirect calls, even if the module has direct function
|
||||
/// calls with the same WebAssembly type.
|
||||
fn make_indirect_sig(&self, func: &mut ir::Function, index: SignatureIndex) -> ir::SigRef;
|
||||
|
||||
/// Set up an external function definition in the preamble of `func` that can be used to
|
||||
/// directly call the function `index`.
|
||||
///
|
||||
/// The index space covers both imported functions and functions defined in the current module.
|
||||
///
|
||||
/// The function's signature may contain additional arguments needed for a direct call, but the
|
||||
/// arguments marked as `ArgumentPurpose::Normal` must correspond to the WebAssembly signature
|
||||
/// arguments.
|
||||
///
|
||||
/// The function's signature will only be used for direct calls, even if the module has
|
||||
/// indirect calls with the same WebAssembly type.
|
||||
fn make_direct_func(&self, func: &mut ir::Function, index: FunctionIndex) -> ir::FuncRef;
|
||||
}
|
||||
|
||||
/// An object satisfyng the `WasmRuntime` trait can be passed as argument to the
|
||||
@@ -60,6 +73,12 @@ pub trait WasmRuntime: FuncEnvironment {
|
||||
/// Declares a function signature to the runtime.
|
||||
fn declare_signature(&mut self, sig: &ir::Signature);
|
||||
|
||||
/// Declares a function import to the runtime.
|
||||
fn declare_func_import(&mut self, sig_index: SignatureIndex, module: &[u8], field: &[u8]);
|
||||
|
||||
/// Declares the type (signature) of a local function in the module.
|
||||
fn declare_func_type(&mut self, sig_index: SignatureIndex);
|
||||
|
||||
/// Declares a global to the runtime.
|
||||
fn declare_global(&mut self, global: Global);
|
||||
/// Declares a table to the runtime.
|
||||
|
||||
Reference in New Issue
Block a user