mirror of
https://github.com/mii443/wasmer.git
synced 2025-08-28 19:29:28 +00:00
63 lines
1.9 KiB
Rust
63 lines
1.9 KiB
Rust
use std::sync::Arc;
|
|
use test_utils::get_compiler_config_from_str;
|
|
use wasmer::{Features, FunctionMiddlewareGenerator, Store, Triple, Tunables};
|
|
use wasmer_engine_jit::JITEngine;
|
|
|
|
fn get_compiler_str() -> &'static str {
|
|
cfg_if::cfg_if! {
|
|
if #[cfg(any(
|
|
all(feature = "test-llvm", any(feature = "test-cranelift", feature = "test-singlepass")),
|
|
all(feature = "test-cranelift", feature = "test-singlepass")
|
|
))] {
|
|
compile_error!("Only one compiler can be selected")
|
|
} else if #[cfg(feature = "test-cranelift")] {
|
|
"cranelift"
|
|
} else if #[cfg(feature = "test-llvm")] {
|
|
"llvm"
|
|
} else if #[cfg(feature = "test-singlepass")] {
|
|
"singlepass"
|
|
} else {
|
|
compile_error!("No compiler chosen for the tests")
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn get_store() -> Store {
|
|
let features = Features::default();
|
|
let try_nan_canonicalization = false;
|
|
let compiler_config =
|
|
get_compiler_config_from_str(get_compiler_str(), try_nan_canonicalization);
|
|
let tunables = Tunables::default();
|
|
let store = Store::new(Arc::new(JITEngine::new(
|
|
compiler_config,
|
|
tunables,
|
|
features,
|
|
)));
|
|
store
|
|
}
|
|
|
|
pub fn get_store_with_middlewares<I: Iterator<Item = Arc<dyn FunctionMiddlewareGenerator>>>(
|
|
middlewares: I,
|
|
) -> Store {
|
|
let features = Features::default();
|
|
let try_nan_canonicalization = false;
|
|
let mut compiler_config =
|
|
get_compiler_config_from_str(get_compiler_str(), try_nan_canonicalization);
|
|
for x in middlewares {
|
|
compiler_config.push_middleware(x);
|
|
}
|
|
let tunables = Tunables::default();
|
|
let store = Store::new(Arc::new(JITEngine::new(
|
|
compiler_config,
|
|
tunables,
|
|
features,
|
|
)));
|
|
store
|
|
}
|
|
|
|
pub fn get_headless_store() -> Store {
|
|
let tunables = Tunables::default();
|
|
let store = Store::new(Arc::new(JITEngine::headless(tunables)));
|
|
store
|
|
}
|