Move all trampoline compilation to wasmtime-cranelift (#3176)
* Move all trampoline compilation to `wasmtime-cranelift` This commit moves compilation of all the trampolines used in wasmtime behind the `Compiler` trait object to live in `wasmtime-cranelift`. The long-term goal of this is to enable depending on cranelift *only* from the `wasmtime-cranelift` crate, so by moving these dependencies we should make that a little more flexible. * Fix windows build
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
use crate::{FunctionAddressMap, FunctionBodyData, ModuleTranslation, Tunables, TypeTables};
|
||||
use cranelift_codegen::{binemit, ir, isa, isa::unwind::UnwindInfo};
|
||||
use cranelift_entity::PrimaryMap;
|
||||
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, WasmError};
|
||||
use cranelift_wasm::{DefinedFuncIndex, FuncIndex, WasmError, WasmFuncType};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -106,4 +106,24 @@ pub trait Compiler: Send + Sync {
|
||||
tunables: &Tunables,
|
||||
types: &TypeTables,
|
||||
) -> Result<CompiledFunction, CompileError>;
|
||||
|
||||
/// Creates a trampoline which the host can use to enter wasm. The
|
||||
/// trampoline has type `VMTrampoline` and will call a function of type `ty`
|
||||
/// specified.
|
||||
fn host_to_wasm_trampoline(
|
||||
&self,
|
||||
isa: &dyn isa::TargetIsa,
|
||||
ty: &WasmFuncType,
|
||||
) -> Result<CompiledFunction, CompileError>;
|
||||
|
||||
/// Creates a trampoline suitable for a wasm module to import.
|
||||
///
|
||||
/// The trampoline has the type specified by `ty` and will call the function
|
||||
/// `host_fn` which has type `VMTrampoline`.
|
||||
fn wasm_to_host_trampoline(
|
||||
&self,
|
||||
isa: &dyn isa::TargetIsa,
|
||||
ty: &WasmFuncType,
|
||||
host_fn: usize,
|
||||
) -> Result<CompiledFunction, CompileError>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user