Skip to content

Commit e9f33fc

Browse files
authored
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
1 parent 2da1b9d commit e9f33fc

File tree

24 files changed

+394
-480
lines changed

24 files changed

+394
-480
lines changed

Cargo.lock

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ path = "src/bin/wasmtime.rs"
2121
doc = false
2222

2323
[dependencies]
24-
# Enable all supported architectures by default.
2524
wasmtime = { path = "crates/wasmtime", version = "0.29.0", default-features = false, features = ['cache'] }
2625
wasmtime-cache = { path = "crates/cache", version = "0.29.0" }
2726
wasmtime-debug = { path = "crates/debug", version = "0.29.0" }
@@ -45,6 +44,7 @@ rayon = "1.5.0"
4544
humantime = "2.0.0"
4645
wasmparser = "0.80.0"
4746
lazy_static = "1.4.0"
47+
cranelift-native = { path = 'cranelift/native', version = '0.76.0' }
4848

4949
[dev-dependencies]
5050
env_logger = "0.8.1"

cranelift/wasm/src/func_translator.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ impl FuncTranslator {
3535
}
3636
}
3737

38+
/// Returns the underlying `FunctionBuilderContext` that this translator
39+
/// uses.
40+
pub fn context(&mut self) -> &mut FunctionBuilderContext {
41+
&mut self.func_ctx
42+
}
43+
3844
/// Translate a binary WebAssembly function.
3945
///
4046
/// The `code` slice contains the binary WebAssembly *function code* as it appears in the code

crates/cranelift/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ cranelift-frontend = { path = "../../cranelift/frontend", version = "0.76.0" }
1818
cranelift-entity = { path = "../../cranelift/entity", version = "0.76.0" }
1919
wasmparser = "0.80.0"
2020
target-lexicon = "0.12"
21+
22+
[features]
23+
all-arch = ["cranelift-codegen/all-arch"]
24+
old-x86-backend = ["cranelift-codegen/old-x86-backend"]

crates/cranelift/src/func_environ.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
12771277
index: TypeIndex,
12781278
) -> WasmResult<ir::SigRef> {
12791279
let index = self.module.types[index].unwrap_function();
1280-
let sig = crate::indirect_signature(self.isa, self.types, index);
1280+
let sig = crate::indirect_signature(self.isa, &self.types.wasm_signatures[index]);
12811281
Ok(func.import_signature(sig))
12821282
}
12831283

0 commit comments

Comments
 (0)