Skip to content

Commit

Permalink
Merge pull request #1 from MarkMcCaskey/deterministic
Browse files Browse the repository at this point in the history
Deterministic
  • Loading branch information
YaronWittenstein authored Dec 6, 2019
2 parents d144976 + 3ba355d commit 6da3b22
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
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
39 changes: 16 additions & 23 deletions lib/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,13 @@ pub fn default_compiler() -> impl Compiler {
not(feature = "docs"),
any(
feature = "default-backend-cranelift",
feature = "default-backend-singlepass",
feature = "deterministic-execution"
feature = "default-backend-singlepass"
)
),
all(
not(feature = "docs"),
feature = "default-backend-cranelift",
any(
feature = "default-backend-singlepass",
feature = "deterministic-execution"
)
),
all(
feature = "default-backend-singlepass",
feature = "deterministic-execution"
feature = "default-backend-singlepass"
)
))]
compile_error!(
Expand All @@ -235,13 +227,7 @@ pub fn default_compiler() -> impl Compiler {
#[cfg(all(feature = "default-backend-llvm", not(feature = "docs")))]
use wasmer_llvm_backend::LLVMCompiler as DefaultCompiler;

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

#[cfg(any(feature = "default-backend-cranelift", feature = "docs"))]
Expand All @@ -260,19 +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(any(feature = "singlepass", feature = "deterministic-execution"))]
#[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())),

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

0 comments on commit 6da3b22

Please sign in to comment.