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

new feature flag: deterministic #709

Merged
merged 10 commits into from
Dec 6, 2019
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ check: check-bench
# as default, and test a minimal set of features with only one backend
# at a time.
cargo check --manifest-path lib/runtime/Cargo.toml
# Check some of the cases where deterministic execution could matter
cargo check --manifest-path lib/runtime/Cargo.toml --features "deterministic-execution"
cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features \
--features=default-backend-singlepass,deterministic-execution
cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features \
--features=default-backend-llvm,deterministic-execution
cargo check --release --manifest-path lib/runtime/Cargo.toml

$(RUNTIME_CHECK) \
Expand Down
1 change: 1 addition & 0 deletions lib/runtime-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ trace = ["debug"]
"backend-singlepass" = []
"backend-llvm" = []
managed = []
deterministic-execution = ["wasmparser/deterministic"]
3 changes: 3 additions & 0 deletions lib/runtime-core/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ pub fn validating_parser_config(features: &Features) -> wasmparser::ValidatingPa
enable_simd: features.simd,
enable_bulk_memory: false,
enable_multi_value: false,

#[cfg(feature = "deterministic-execution")]
deterministic_only: true,
},
}
}
Expand Down
3 changes: 3 additions & 0 deletions lib/runtime-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ pub fn validate_and_report_errors_with_features(
enable_multi_value: false,
enable_reference_types: false,
enable_threads: features.threads,

#[cfg(feature = "deterministic-execution")]
deterministic_only: true,
},
};
let mut parser = wasmparser::ValidatingParser::new(wasm, Some(config));
Expand Down
1 change: 1 addition & 0 deletions lib/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ singlepass = ["wasmer-singlepass-backend"]
default-backend-singlepass = ["singlepass"]
default-backend-llvm = ["llvm"]
default-backend-cranelift = ["cranelift"]
deterministic-execution = ["wasmer-singlepass-backend/deterministic-execution", "wasmer-runtime-core/deterministic-execution"]

[[bench]]
name = "nginx"
Expand Down
16 changes: 14 additions & 2 deletions lib/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
//! let value = add_one.call(42)?;
//!
//! assert_eq!(value, 43);
//!
//!
//! Ok(())
//! }
//! ```
Expand Down Expand Up @@ -246,14 +246,26 @@ pub fn compiler_for_backend(backend: Backend) -> Option<Box<dyn Compiler>> {
#[cfg(feature = "cranelift")]
Backend::Cranelift => Some(Box::new(wasmer_clif_backend::CraneliftCompiler::new())),

#[cfg(feature = "singlepass")]
#[cfg(any(feature = "singlepass"))]
Backend::Singlepass => Some(Box::new(
wasmer_singlepass_backend::SinglePassCompiler::new(),
)),

#[cfg(feature = "llvm")]
Backend::LLVM => Some(Box::new(wasmer_llvm_backend::LLVMCompiler::new())),

Backend::Auto => {
#[cfg(feature = "default-backend-singlepass")]
return Some(Box::new(
wasmer_singlepass_backend::SinglePassCompiler::new(),
));
#[cfg(feature = "default-backend-cranelift")]
return Some(Box::new(wasmer_clif_backend::CraneliftCompiler::new()));
#[cfg(feature = "default-backend-llvm")]
return Some(Box::new(wasmer_llvm_backend::LLVMCompiler::new()));
}

#[cfg(not(all(feature = "llvm", feature = "singlepass", feature = "cranelift")))]
_ => None,
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/singlepass-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ smallvec = "0.6"
serde = "1.0"
serde_derive = "1.0"
bincode = "1.2"

[features]
default = []
deterministic-execution = ["wasmer-runtime-core/deterministic-execution"]