Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm: switch to cranelift compiler #3183

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 2 additions & 47 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ tracing-subscriber = {version = "0.3.7", default-features = false, features = ["
wasmparser = "0.107.0"
wasm-instrument = {version = "0.4.0", features = ["sign_ext"]}
wasmer = {git = "https://github.com/heliaxdev/wasmer", rev = "255054f7f58b7b4a525f2fee6b9b86422d1ca15b"}
wasmer-compiler-singlepass = { git = "https://github.com/heliaxdev/wasmer", rev = "255054f7f58b7b4a525f2fee6b9b86422d1ca15b" }
wasmer-compiler-cranelift = { git = "https://github.com/heliaxdev/wasmer", rev = "255054f7f58b7b4a525f2fee6b9b86422d1ca15b" }
wasmer-engine-universal = { git = "https://github.com/heliaxdev/wasmer", rev = "255054f7f58b7b4a525f2fee6b9b86422d1ca15b" }
winapi = "0.3.9"
yansi = "0.5.1"
Expand Down
2 changes: 1 addition & 1 deletion crates/benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ rand.workspace = true
tempfile.workspace = true
sha2.workspace = true
wasm-instrument.workspace = true
wasmer-compiler-singlepass.workspace = true
wasmer-compiler-cranelift.workspace = true
wasmer-engine-universal.workspace = true
wasmer.workspace = true
4 changes: 2 additions & 2 deletions crates/benches/wasm_opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,13 @@ impl Display for WatBuilder {
}
}

// Use singlepass compiler (the same one used in protocol) to prevent
// Use Cranelift compiler (the same one used in protocol) to prevent
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cranelift might actually do a couple of optimizations; nothing too aggressive, but probably enough to optimize things like loop {}

// optimizations that would compile out the benchmarks since most of them are
// trivial operations
fn get_wasm_store() -> Store {
wasmer::Store::new(
&wasmer_engine_universal::Universal::new(
wasmer_compiler_singlepass::Singlepass::default(),
wasmer_compiler_cranelift::Cranelift::default(),
)
.engine(),
)
Expand Down
4 changes: 2 additions & 2 deletions crates/namada/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ wasm-runtime = [
"rayon",
"wasm-instrument",
"wasmer-cache",
"wasmer-compiler-singlepass",
"wasmer-compiler-cranelift",
"wasmer-engine-dylib",
"wasmer-engine-universal",
"wasmer-vm",
Expand Down Expand Up @@ -151,7 +151,7 @@ tracing.workspace = true
wasm-instrument = { workspace = true, optional = true }
wasmer = { workspace = true, optional = true }
wasmer-cache = { git = "https://github.com/heliaxdev/wasmer", rev = "255054f7f58b7b4a525f2fee6b9b86422d1ca15b", optional = true }
wasmer-compiler-singlepass = { workspace = true, optional = true }
wasmer-compiler-cranelift = { workspace = true, optional = true }
wasmer-engine-dylib = { git = "https://github.com/heliaxdev/wasmer", rev = "255054f7f58b7b4a525f2fee6b9b86422d1ca15b", optional = true }
wasmer-engine-universal = { workspace = true, optional = true }
wasmer-vm = { git = "https://github.com/heliaxdev/wasmer", rev = "255054f7f58b7b4a525f2fee6b9b86422d1ca15b", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/namada/src/vm/wasm/compilation_cache/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ mod dylib {
/// Dylib WASM store
#[allow(dead_code)]
pub fn store() -> Store {
let compiler = wasmer_compiler_singlepass::Singlepass::default();
let compiler = wasmer_compiler_cranelift::Cranelift::default();
let engine = wasmer_engine_dylib::Dylib::new(compiler).engine();
Store::new_with_tunables(&engine, memory::vp_limit())
}
Expand Down
4 changes: 2 additions & 2 deletions crates/namada/src/vm/wasm/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,8 @@ where

/// Prepare a wasm store for untrusted code.
pub fn untrusted_wasm_store(limit: Limit<BaseTunables>) -> wasmer::Store {
// Use Singlepass compiler with the default settings
let compiler = wasmer_compiler_singlepass::Singlepass::default();
// Use Cranelift compiler with the default settings
let compiler = wasmer_compiler_cranelift::Cranelift::default();
wasmer::Store::new_with_tunables(
&wasmer_engine_universal::Universal::new(compiler).engine(),
limit,
Expand Down
47 changes: 1 addition & 46 deletions wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 1 addition & 46 deletions wasm_for_tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading