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
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
29 changes: 24 additions & 5 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 @@ -211,13 +211,21 @@ pub fn default_compiler() -> impl Compiler {
not(feature = "docs"),
any(
feature = "default-backend-cranelift",
feature = "default-backend-singlepass"
feature = "default-backend-singlepass",
feature = "deterministic-execution"
)
),
all(
not(feature = "docs"),
feature = "default-backend-cranelift",
feature = "default-backend-singlepass"
any(
feature = "default-backend-singlepass",
feature = "deterministic-execution"
)
),
all(
feature = "default-backend-singlepass",
feature = "deterministic-execution"
)
))]
compile_error!(
Expand All @@ -227,7 +235,13 @@ pub fn default_compiler() -> impl Compiler {
#[cfg(all(feature = "default-backend-llvm", not(feature = "docs")))]
use wasmer_llvm_backend::LLVMCompiler as DefaultCompiler;

#[cfg(all(feature = "default-backend-singlepass", not(feature = "docs")))]
#[cfg(all(
any(
feature = "default-backend-singlepass",
all(feature = "deterministic-execution", feature = "singlepass")
),
not(feature = "docs")
))]
use wasmer_singlepass_backend::SinglePassCompiler as DefaultCompiler;

#[cfg(any(feature = "default-backend-cranelift", feature = "docs"))]
Expand All @@ -246,14 +260,19 @@ 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", feature = "deterministic-execution"))]
Backend::Singlepass => Some(Box::new(
wasmer_singlepass_backend::SinglePassCompiler::new(),
)),

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

#[cfg(not(all(
feature = "llvm",
any(feature = "singlepass", feature = "deterministic-execution"),
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"]