Improved EngineBuilder and Store API

- Store::new() now takes an impl Into<Engine>.
- Added Into<Engine> impls in each of the compilers
- Updated docs/migration_to_3.0.0.md on API usage
This commit is contained in:
Syrus Akbary
2022-07-27 21:00:41 -07:00
committed by Manos Pitsidianakis
parent b2dc07e1ef
commit 4384ddf9cd
57 changed files with 191 additions and 263 deletions

View File

@@ -9,6 +9,7 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C
## **Unreleased** ## **Unreleased**
### Changed ### Changed
- [#3047](https://github.com/wasmerio/wasmer/pull/3047) `Store::new` now takes an `impl Into<Engine>`.
- [#3017](https://github.com/wasmerio/wasmer/pull/3017) Fix typo in README.md - [#3017](https://github.com/wasmerio/wasmer/pull/3017) Fix typo in README.md
- [#3008](https://github.com/wasmerio/wasmer/pull/3008) Add a new CI check that uses cargo public-api to track changes in the API between master and the last deployed version on crates.io - [#3008](https://github.com/wasmerio/wasmer/pull/3008) Add a new CI check that uses cargo public-api to track changes in the API between master and the last deployed version on crates.io
- [#3003](https://github.com/wasmerio/wasmer/pull/3003) Remove RuntimeError::raise from public API - [#3003](https://github.com/wasmerio/wasmer/pull/3003) Remove RuntimeError::raise from public API

1
Cargo.lock generated
View File

@@ -2902,7 +2902,6 @@ dependencies = [
"tempfile", "tempfile",
"thiserror", "thiserror",
"wasmer", "wasmer",
"wasmer-compiler",
"wasmer-compiler-singlepass", "wasmer-compiler-singlepass",
] ]

View File

@@ -149,35 +149,19 @@ pub fn run_basic_dynamic_function(store: &Store, compiler_name: &str, c: &mut Cr
fn run_static_benchmarks(_c: &mut Criterion) { fn run_static_benchmarks(_c: &mut Criterion) {
#[cfg(feature = "llvm")] #[cfg(feature = "llvm")]
{ {
let mut store = Store::new_with_engine( let mut store = Store::new(wasmer_compiler_llvm::LLVM::new());
&EngineBuilder::new(Some(wasmer_compiler_llvm::LLVM::new()), None, None).engine(),
);
run_basic_static_function(&store, "llvm", c); run_basic_static_function(&store, "llvm", c);
} }
#[cfg(feature = "cranelift")] #[cfg(feature = "cranelift")]
{ {
let mut store = Store::new_with_engine( let mut store = Store::new(wasmer_compiler_cranelift::Cranelift::new());
&EngineBuilder::new(
Some(wasmer_compiler_cranelift::Cranelift::new()),
None,
None,
)
.engine(),
);
run_basic_static_function(&store, "cranelift", c); run_basic_static_function(&store, "cranelift", c);
} }
#[cfg(feature = "singlepass")] #[cfg(feature = "singlepass")]
{ {
let mut store = Store::new_with_engine( let mut store = Store::new(wasmer_compiler_singlepass::Singlepass::new());
&EngineBuilder::new(
Some(wasmer_compiler_singlepass::Singlepass::new()),
None,
None,
)
.engine(),
);
run_basic_static_function(&store, "singlepass", c); run_basic_static_function(&store, "singlepass", c);
} }
} }
@@ -185,35 +169,19 @@ fn run_static_benchmarks(_c: &mut Criterion) {
fn run_dynamic_benchmarks(_c: &mut Criterion) { fn run_dynamic_benchmarks(_c: &mut Criterion) {
#[cfg(feature = "llvm")] #[cfg(feature = "llvm")]
{ {
let mut store = Store::new_with_engine( let mut store = Store::new(wasmer_compiler_llvm::LLVM::new());
&EngineBuilder::new(Some(wasmer_compiler_llvm::LLVM::new()), None, None).engine(),
);
run_basic_dynamic_function(&store, "llvm", c); run_basic_dynamic_function(&store, "llvm", c);
} }
#[cfg(feature = "cranelift")] #[cfg(feature = "cranelift")]
{ {
let mut store = Store::new_with_engine( let mut store = Store::new(wasmer_compiler_cranelift::Cranelift::new());
&EngineBuilder::new(
Some(wasmer_compiler_cranelift::Cranelift::new()),
None,
None,
)
.engine(),
);
run_basic_dynamic_function(&store, "cranelift", c); run_basic_dynamic_function(&store, "cranelift", c);
} }
#[cfg(feature = "singlepass")] #[cfg(feature = "singlepass")]
{ {
let mut store = Store::new_with_engine( let mut store = Store::new(wasmer_compiler_singlepass::Singlepass::new());
&EngineBuilder::new(
Some(wasmer_compiler_singlepass::Singlepass::new()),
None,
None,
)
.engine(),
);
run_basic_dynamic_function(&store, "singlepass", c); run_basic_dynamic_function(&store, "singlepass", c);
} }
} }

View File

@@ -145,12 +145,27 @@ let wasm_bytes = wat2wasm(
"..".as_bytes(), "..".as_bytes(),
)?; )?;
let compiler_config = Cranelift::default(); let compiler = Cranelift::default();
let mut store = Store::new(&compiler_config); let mut store = Store::new(compiler);
let module = Module::new(&store, wasm_bytes)?; let module = Module::new(&store, wasm_bytes)?;
let instance = Instance::new(&mut store, &module, &imports! {})?; let instance = Instance::new(&mut store, &module, &imports! {})?;
``` ```
#### Advanced configuration
The previous ability to define target and features remains in a new `EngineBuilder` interface:
```rust
let compiler = Cranelift::default();
let mut features = Features::new();
// Enable the multi-value feature.
features.multi_value(true);
let engine = EngineBuilder::new(compiler).set_features(Some(features));
let store = Store::new(engine);
```
[examples]: https://docs.wasmer.io/integrations/examples [examples]: https://docs.wasmer.io/integrations/examples
[wasmer]: https://crates.io/crates/wasmer [wasmer]: https://crates.io/crates/wasmer
[wasmer-wasi]: https://crates.io/crates/wasmer-wasi [wasmer-wasi]: https://crates.io/crates/wasmer-wasi

View File

@@ -11,7 +11,6 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -33,7 +32,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let compiler = Cranelift::default(); let compiler = Cranelift::default();
// Create the store // Create the store
let mut store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let mut store = Store::new(compiler);
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -11,7 +11,6 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_llvm::LLVM; use wasmer_compiler_llvm::LLVM;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -33,7 +32,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let compiler = LLVM::default(); let compiler = LLVM::default();
// Create the store // Create the store
let mut store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let mut store = Store::new(compiler);
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -11,7 +11,6 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_singlepass::Singlepass; use wasmer_compiler_singlepass::Singlepass;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -33,7 +32,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let compiler = Singlepass::default(); let compiler = Singlepass::default();
// Create the store // Create the store
let mut store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let mut store = Store::new(compiler);
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -20,7 +20,6 @@ use wasmer::{
imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store, imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store,
TypedFunction, TypedFunction,
}; };
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
// First we need to create an error type that we'll use to signal the end of execution. // First we need to create an error type that we'll use to signal the end of execution.
@@ -58,8 +57,7 @@ fn main() -> anyhow::Result<()> {
// Note that we don't need to specify the engine/compiler if we want to use // Note that we don't need to specify the engine/compiler if we want to use
// the default provided by Wasmer. // the default provided by Wasmer.
// You can use `Store::default()` for that. // You can use `Store::default()` for that.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
let env = FunctionEnv::new(&mut store, ()); let env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -18,8 +18,7 @@
//! //!
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer::{imports, wat2wasm, EngineBuilder, Instance, Module, Store, Value};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -49,10 +48,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// //
// In this case, the engine is `wasmer_compiler` which roughly // In this case, the engine is `wasmer_compiler` which roughly
// means that the executable code will live in memory. // means that the executable code will live in memory.
let engine = EngineBuilder::new(compiler_config, None, None).engine(); let engine = EngineBuilder::new(compiler_config);
// Create a store, that holds the engine. // Create a store, that holds the engine.
let mut store = Store::new_with_engine(&engine); let mut store = Store::new(engine);
println!("Compiling module..."); println!("Compiling module...");
// Here we go. // Here we go.

View File

@@ -19,8 +19,7 @@
//! Ready? //! Ready?
use std::str::FromStr; use std::str::FromStr;
use wasmer::{wat2wasm, Module, RuntimeError, Store}; use wasmer::{wat2wasm, EngineBuilder, Module, RuntimeError, Store};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
use wasmer_types::{CpuFeature, Target, Triple}; use wasmer_types::{CpuFeature, Target, Triple};
@@ -70,10 +69,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// That's where we specify the target for the compiler. // That's where we specify the target for the compiler.
// //
// Use the Universal engine. // Use the Universal engine.
let mut engine = EngineBuilder::new(compiler_config, Some(target), None).engine(); let mut engine = EngineBuilder::new(compiler_config).set_target(Some(target));
// Create a store, that holds the engine. // Create a store, that holds the engine.
let mut store = Store::new_with_engine(&engine); let mut store = Store::new(engine);
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -52,10 +52,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// //
// In this case, the engine is `wasmer_engine_dylib` which means // In this case, the engine is `wasmer_engine_dylib` which means
// that a shared object is going to be generated. // that a shared object is going to be generated.
let engine = Dylib::new(compiler_config).engine(); let engine = Dylib::new(compiler_config);
// Create a store, that holds the engine. // Create a store, that holds the engine.
let mut store = Store::new_with_engine(&engine); let mut store = Store::new(engine);
println!("Compiling module..."); println!("Compiling module...");
// Here we go. // Here we go.

View File

@@ -45,14 +45,7 @@
//! Ready? //! Ready?
use tempfile::NamedTempFile; use tempfile::NamedTempFile;
use wasmer::imports; use wasmer::{imports, wat2wasm, EngineBuilder, FunctionEnv, Instance, Module, Store, Value};
use wasmer::wat2wasm;
use wasmer::FunctionEnv;
use wasmer::Instance;
use wasmer::Module;
use wasmer::Store;
use wasmer::Value;
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -78,14 +71,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// In this situation, the compiler is // In this situation, the compiler is
// `wasmer_compiler_cranelift`. The compiler is responsible to // `wasmer_compiler_cranelift`. The compiler is responsible to
// compile the Wasm module into executable code. // compile the Wasm module into executable code.
let compiler_config = Cranelift::default(); let compiler = Cranelift::default();
println!("Creating univesral engine...");
// Define the engine that will drive everything.
let engine = EngineBuilder::new(compiler_config, None, None).engine();
// Create a store, that holds the engine. // Create a store, that holds the engine.
let mut store = Store::new_with_engine(&engine); let mut store = Store::new(compiler);
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.
@@ -105,8 +94,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
{ {
println!("Creating headless Universal engine..."); println!("Creating headless Universal engine...");
// We create a headless Universal engine. // We create a headless Universal engine.
let engine = EngineBuilder::headless().engine(); let engine = EngineBuilder::headless();
let mut store = Store::new_with_engine(&engine); let mut store = Store::new(engine);
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Deserializing module..."); println!("Deserializing module...");

View File

@@ -14,7 +14,6 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction}; use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -39,8 +38,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Note that we don't need to specify the engine/compiler if we want to use // Note that we don't need to specify the engine/compiler if we want to use
// the default provided by Wasmer. // the default provided by Wasmer.
// You can use `Store::default()` for that. // You can use `Store::default()` for that.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -18,7 +18,6 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction, Value}; use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction, Value};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -40,8 +39,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Note that we don't need to specify the engine/compiler if we want to use // Note that we don't need to specify the engine/compiler if we want to use
// the default provided by Wasmer. // the default provided by Wasmer.
// You can use `Store::default()` for that. // You can use `Store::default()` for that.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -18,7 +18,6 @@
use wasmer::{ use wasmer::{
imports, wat2wasm, FunctionEnv, Instance, Module, Mutability, Store, Type, TypedFunction, Value, imports, wat2wasm, FunctionEnv, Instance, Module, Mutability, Store, Type, TypedFunction, Value,
}; };
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -40,8 +39,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Note that we don't need to specify the engine/compiler if we want to use // Note that we don't need to specify the engine/compiler if we want to use
// the default provided by Wasmer. // the default provided by Wasmer.
// You can use `Store::default()` for that. // You can use `Store::default()` for that.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -12,7 +12,6 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction, WasmPtr}; use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction, WasmPtr};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -37,8 +36,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Note that we don't need to specify the engine/compiler if we want to use // Note that we don't need to specify the engine/compiler if we want to use
// the default provided by Wasmer. // the default provided by Wasmer.
// You can use `Store::default()` for that. // You can use `Store::default()` for that.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -10,8 +10,9 @@
//! //!
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, Features, FunctionEnv, Instance, Module, Store, Value}; use wasmer::{
use wasmer_compiler::EngineBuilder; imports, wat2wasm, EngineBuilder, Features, FunctionEnv, Instance, Module, Store, Value,
};
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
@@ -36,10 +37,10 @@ fn main() -> anyhow::Result<()> {
features.multi_value(true); features.multi_value(true);
// Set up the engine. That's where we define the features! // Set up the engine. That's where we define the features!
let engine = EngineBuilder::new(compiler, None, Some(features)); let engine = EngineBuilder::new(compiler).set_features(Some(features));
// Now, let's define the store, and compile the module. // Now, let's define the store, and compile the module.
let mut store = Store::new_with_engine(&engine.engine()); let mut store = Store::new(engine);
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
let module = Module::new(&store, wasm_bytes)?; let module = Module::new(&store, wasm_bytes)?;

View File

@@ -10,7 +10,6 @@ use wasmer::{
imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store, imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store,
TypedFunction, TypedFunction,
}; };
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
@@ -47,8 +46,7 @@ fn main() -> anyhow::Result<()> {
// However for the purposes of showing what's happening, we create a compiler // However for the purposes of showing what's happening, we create a compiler
// (`Cranelift`) and pass it to an engine (`Universal`). We then pass the engine to // (`Cranelift`) and pass it to an engine (`Universal`). We then pass the engine to
// the store and are now ready to compile and run WebAssembly! // the store and are now ready to compile and run WebAssembly!
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
// We then use our store and Wasm bytes to compile a `Module`. // We then use our store and Wasm bytes to compile a `Module`.
// A `Module` is a compiled WebAssembly module that isn't ready to execute yet. // A `Module` is a compiled WebAssembly module that isn't ready to execute yet.

View File

@@ -19,7 +19,6 @@ use wasmer::{
imports, wat2wasm, Function, FunctionEnv, FunctionType, Global, Instance, Memory, Module, imports, wat2wasm, Function, FunctionEnv, FunctionType, Global, Instance, Memory, Module,
Store, Table, Type, Value, Store, Table, Type, Value,
}; };
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -44,8 +43,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Note that we don't need to specify the engine/compiler if we want to use // Note that we don't need to specify the engine/compiler if we want to use
// the default provided by Wasmer. // the default provided by Wasmer.
// You can use `Store::default()` for that. // You can use `Store::default()` for that.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -21,7 +21,6 @@ use wasmer::{
imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, FunctionType, Instance, Module, imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, FunctionType, Instance, Module,
Store, Type, TypedFunction, Value, Store, Type, TypedFunction, Value,
}; };
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -45,8 +44,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Note that we don't need to specify the engine/compiler if we want to use // Note that we don't need to specify the engine/compiler if we want to use
// the default provided by Wasmer. // the default provided by Wasmer.
// You can use `Store::default()` for that. // You can use `Store::default()` for that.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
let mut env1 = FunctionEnv::new(&mut store, ()); let mut env1 = FunctionEnv::new(&mut store, ());
struct MyEnv; struct MyEnv;
let mut env2 = FunctionEnv::new(&mut store, MyEnv {}); let mut env2 = FunctionEnv::new(&mut store, MyEnv {});

View File

@@ -24,7 +24,6 @@ use wasmer::{
imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store, imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store,
TypedFunction, TypedFunction,
}; };
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -52,8 +51,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Note that we don't need to specify the engine/compiler if we want to use // Note that we don't need to specify the engine/compiler if we want to use
// the default provided by Wasmer. // the default provided by Wasmer.
// You can use `Store::default()` for that. // You can use `Store::default()` for that.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -18,7 +18,6 @@
use wasmer::{ use wasmer::{
imports, wat2wasm, FunctionEnv, Global, Instance, Module, Store, TypedFunction, Value, imports, wat2wasm, FunctionEnv, Global, Instance, Module, Store, TypedFunction, Value,
}; };
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -40,8 +39,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Note that we don't need to specify the engine/compiler if we want to use // Note that we don't need to specify the engine/compiler if we want to use
// the default provided by Wasmer. // the default provided by Wasmer.
// You can use `Store::default()` for that. // You can use `Store::default()` for that.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -15,7 +15,6 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction}; use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -39,8 +38,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Note that we don't need to specify the engine/compiler if we want to use // Note that we don't need to specify the engine/compiler if we want to use
// the default provided by Wasmer. // the default provided by Wasmer.
// You can use `Store::default()` for that. // You can use `Store::default()` for that.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -18,7 +18,6 @@ use std::mem;
use wasmer::{ use wasmer::{
imports, wat2wasm, Bytes, FunctionEnv, Instance, Module, Pages, Store, TypedFunction, imports, wat2wasm, Bytes, FunctionEnv, Instance, Module, Pages, Store, TypedFunction,
}; };
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
// this example is a work in progress: // this example is a work in progress:
@@ -59,8 +58,7 @@ fn main() -> anyhow::Result<()> {
// Note that we don't need to specify the engine/compiler if we want to use // Note that we don't need to specify the engine/compiler if we want to use
// the default provided by Wasmer. // the default provided by Wasmer.
// You can use `Store::default()` for that. // You can use `Store::default()` for that.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -18,8 +18,9 @@ use anyhow::bail;
use std::sync::Arc; use std::sync::Arc;
use wasmer::wasmparser::Operator; use wasmer::wasmparser::Operator;
use wasmer::CompilerConfig; use wasmer::CompilerConfig;
use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction}; use wasmer::{
use wasmer_compiler::EngineBuilder; imports, wat2wasm, EngineBuilder, FunctionEnv, Instance, Module, Store, TypedFunction,
};
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
use wasmer_middlewares::{ use wasmer_middlewares::{
metering::{get_remaining_points, set_remaining_points, MeteringPoints}, metering::{get_remaining_points, set_remaining_points, MeteringPoints},
@@ -70,8 +71,7 @@ fn main() -> anyhow::Result<()> {
// //
// We use our previously create compiler configuration // We use our previously create compiler configuration
// with the Universal engine. // with the Universal engine.
let mut store = let mut store = Store::new(EngineBuilder::new(compiler_config));
Store::new_with_engine(&EngineBuilder::new(compiler_config, None, None).engine());
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -50,10 +50,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Chosen target: {:?}", target); println!("Chosen target: {:?}", target);
println!("Creating Dylib engine..."); println!("Creating Dylib engine...");
let engine = Dylib::new(compiler_config).target(target).engine(); let engine = Dylib::new(compiler_config).target(target);
// Create a store, that holds the engine. // Create a store, that holds the engine.
let mut store = Store::new_with_engine(&engine); let mut store = Store::new(engine);
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -2,7 +2,6 @@ use wasmer::{
imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store, TableType, imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store, TableType,
Type, TypedFunction, Value, Type, TypedFunction, Value,
}; };
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
/// A function we'll call through a table. /// A function we'll call through a table.
@@ -52,8 +51,7 @@ fn main() -> anyhow::Result<()> {
)?; )?;
// We set up our store with an engine and a compiler. // We set up our store with an engine and a compiler.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
// Then compile our Wasm. // Then compile our Wasm.
let module = Module::new(&store, wasm_bytes)?; let module = Module::new(&store, wasm_bytes)?;

View File

@@ -6,7 +6,6 @@ use wasmer::{
wat2wasm, BaseTunables, FunctionEnv, Instance, Memory, MemoryType, Module, Pages, Store, wat2wasm, BaseTunables, FunctionEnv, Instance, Memory, MemoryType, Module, Pages, Store,
TableType, Target, Tunables, TableType, Target, Tunables,
}; };
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
/// A custom tunables that allows you to set a memory limit. /// A custom tunables that allows you to set a memory limit.
@@ -135,17 +134,15 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let wasm_bytes = wat2wasm(wat)?; let wasm_bytes = wat2wasm(wat)?;
// Any compiler and any engine do the job here // Any compiler do the job here
let compiler = Cranelift::default(); let compiler = Cranelift::default();
let engine = EngineBuilder::new(compiler, None, None).engine();
// Here is where the fun begins // Here is where the fun begins
let base = BaseTunables::for_target(&Target::default()); let base = BaseTunables::for_target(&Target::default());
let tunables = LimitingTunables::new(base, Pages(24)); let tunables = LimitingTunables::new(base, Pages(24));
// Create a store, that holds the engine and our custom tunables // Create a store, that holds the engine and our custom tunables
let mut store = Store::new_with_tunables(&engine, tunables); let mut store = Store::new_with_tunables(compiler, tunables);
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -16,7 +16,6 @@
//! Ready? //! Ready?
use wasmer::{FunctionEnv, Instance, Module, Store}; use wasmer::{FunctionEnv, Instance, Module, Store};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
use wasmer_wasi::WasiState; use wasmer_wasi::WasiState;
@@ -32,8 +31,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Note that we don't need to specify the engine/compiler if we want to use // Note that we don't need to specify the engine/compiler if we want to use
// the default provided by Wasmer. // the default provided by Wasmer.
// You can use `Store::default()` for that. // You can use `Store::default()` for that.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -13,7 +13,6 @@
use std::io::{Read, Write}; use std::io::{Read, Write};
use wasmer::{FunctionEnv, Instance, Module, Store}; use wasmer::{FunctionEnv, Instance, Module, Store};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
use wasmer_wasi::{Pipe, WasiState}; use wasmer_wasi::{Pipe, WasiState};
@@ -29,8 +28,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Note that we don't need to specify the engine/compiler if we want to use // Note that we don't need to specify the engine/compiler if we want to use
// the default provided by Wasmer. // the default provided by Wasmer.
// You can use `Store::default()` for that. // You can use `Store::default()` for that.
let mut store = let mut store = Store::new(Cranelift::default());
Store::new_with_engine(&EngineBuilder::new(Cranelift::default(), None, None).engine());
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -2,8 +2,7 @@
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target}; use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
use wasm_smith::{Config, ConfiguredModule}; use wasm_smith::{Config, ConfiguredModule};
use wasmer::{CompilerConfig, Engine, Module, Store}; use wasmer::{CompilerConfig, Engine, EngineBuilder, Module, Store};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
use wasmer_compiler_llvm::LLVM; use wasmer_compiler_llvm::LLVM;
use wasmer_compiler_singlepass::Singlepass; use wasmer_compiler_singlepass::Singlepass;
@@ -24,7 +23,7 @@ impl Config for NoImportsConfig {
} }
fn compile_and_compare(name: &str, engine: Engine, wasm: &[u8]) { fn compile_and_compare(name: &str, engine: Engine, wasm: &[u8]) {
let store = Store::new_with_engine(&engine); let store = Store::new(engine);
// compile for first time // compile for first time
let module = Module::new(&store, wasm).unwrap(); let module = Module::new(&store, wasm).unwrap();
@@ -47,7 +46,7 @@ fuzz_target!(|module: ConfiguredModule<NoImportsConfig>| {
compiler.enable_verifier(); compiler.enable_verifier();
compile_and_compare( compile_and_compare(
"universal-cranelift", "universal-cranelift",
EngineBuilder::new(compiler.clone(), None, None).engine(), EngineBuilder::new(compiler.clone()),
&wasm_bytes, &wasm_bytes,
); );
@@ -56,14 +55,14 @@ fuzz_target!(|module: ConfiguredModule<NoImportsConfig>| {
compiler.enable_verifier(); compiler.enable_verifier();
compile_and_compare( compile_and_compare(
"universal-llvm", "universal-llvm",
EngineBuilder::new(compiler.clone(), None, None).engine(), EngineBuilder::new(compiler.clone()),
&wasm_bytes, &wasm_bytes,
); );
let compiler = Singlepass::default(); let compiler = Singlepass::default();
compile_and_compare( compile_and_compare(
"universal-singlepass", "universal-singlepass",
EngineBuilder::new(compiler.clone(), None, None).engine(), EngineBuilder::new(compiler.clone()),
&wasm_bytes, &wasm_bytes,
); );
}); });

View File

@@ -4,8 +4,7 @@
use anyhow::Result; use anyhow::Result;
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target}; use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
use wasm_smith::{Config, ConfiguredModule}; use wasm_smith::{Config, ConfiguredModule};
use wasmer::{imports, CompilerConfig, Instance, Module, Store, Val}; use wasmer::{imports, CompilerConfig, EngineBuilder, Instance, Module, Store, Val};
use wasmer_compiler::EngineBuilder;
#[cfg(feature = "cranelift")] #[cfg(feature = "cranelift")]
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
#[cfg(feature = "llvm")] #[cfg(feature = "llvm")]
@@ -48,7 +47,7 @@ impl std::fmt::Debug for WasmSmithModule {
#[cfg(feature = "singlepass")] #[cfg(feature = "singlepass")]
fn maybe_instantiate_singlepass(wasm_bytes: &[u8]) -> Result<Option<Instance>> { fn maybe_instantiate_singlepass(wasm_bytes: &[u8]) -> Result<Option<Instance>> {
let compiler = Singlepass::default(); let compiler = Singlepass::default();
let mut store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let mut store = Store::new(compiler);
let module = Module::new(&store, &wasm_bytes); let module = Module::new(&store, &wasm_bytes);
let module = match module { let module = match module {
Ok(m) => m, Ok(m) => m,
@@ -69,7 +68,7 @@ fn maybe_instantiate_cranelift(wasm_bytes: &[u8]) -> Result<Option<Instance>> {
let mut compiler = Cranelift::default(); let mut compiler = Cranelift::default();
compiler.canonicalize_nans(true); compiler.canonicalize_nans(true);
compiler.enable_verifier(); compiler.enable_verifier();
let mut store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let mut store = Store::new(compiler);
let module = Module::new(&store, &wasm_bytes)?; let module = Module::new(&store, &wasm_bytes)?;
let instance = Instance::new(&module, &imports! {})?; let instance = Instance::new(&module, &imports! {})?;
Ok(Some(instance)) Ok(Some(instance))
@@ -80,7 +79,7 @@ fn maybe_instantiate_llvm(wasm_bytes: &[u8]) -> Result<Option<Instance>> {
let mut compiler = LLVM::default(); let mut compiler = LLVM::default();
compiler.canonicalize_nans(true); compiler.canonicalize_nans(true);
compiler.enable_verifier(); compiler.enable_verifier();
let mut store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let mut store = Store::new(compiler);
let module = Module::new(&store, &wasm_bytes)?; let module = Module::new(&store, &wasm_bytes)?;
let instance = Instance::new(&module, &imports! {})?; let instance = Instance::new(&module, &imports! {})?;
Ok(Some(instance)) Ok(Some(instance))

View File

@@ -4,8 +4,7 @@ use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
use std::sync::Arc; use std::sync::Arc;
use wasm_smith::{Config, ConfiguredModule}; use wasm_smith::{Config, ConfiguredModule};
use wasmer::wasmparser::Operator; use wasmer::wasmparser::Operator;
use wasmer::{imports, CompilerConfig, Instance, Module, Store}; use wasmer::{imports, CompilerConfig, EngineBuilder, Instance, Module, Store};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
use wasmer_middlewares::Metering; use wasmer_middlewares::Metering;
@@ -56,7 +55,7 @@ fuzz_target!(|module: WasmSmithModule| {
compiler.enable_verifier(); compiler.enable_verifier();
let metering = Arc::new(Metering::new(10, cost)); let metering = Arc::new(Metering::new(10, cost));
compiler.push_middleware(metering); compiler.push_middleware(metering);
let mut store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let mut store = Store::new(compiler);
let module = Module::new(&store, &wasm_bytes).unwrap(); let module = Module::new(&store, &wasm_bytes).unwrap();
match Instance::new(&module, &imports! {}) { match Instance::new(&module, &imports! {}) {
Ok(_) => {} Ok(_) => {}

View File

@@ -2,8 +2,7 @@
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target}; use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
use wasm_smith::{Config, ConfiguredModule}; use wasm_smith::{Config, ConfiguredModule};
use wasmer::{imports, CompilerConfig, Instance, Module, Store}; use wasmer::{imports, CompilerConfig, EngineBuilder, Instance, Module, Store};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
#[derive(Arbitrary, Debug, Default, Copy, Clone)] #[derive(Arbitrary, Debug, Default, Copy, Clone)]
@@ -42,7 +41,7 @@ fuzz_target!(|module: WasmSmithModule| {
let mut compiler = Cranelift::default(); let mut compiler = Cranelift::default();
compiler.canonicalize_nans(true); compiler.canonicalize_nans(true);
compiler.enable_verifier(); compiler.enable_verifier();
let mut store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let mut store = Store::new(compiler);
let module = Module::new(&store, &wasm_bytes).unwrap(); let module = Module::new(&store, &wasm_bytes).unwrap();
match Instance::new(&module, &imports! {}) { match Instance::new(&module, &imports! {}) {
Ok(_) => {} Ok(_) => {}

View File

@@ -2,8 +2,7 @@
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target}; use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
use wasm_smith::{Config, ConfiguredModule}; use wasm_smith::{Config, ConfiguredModule};
use wasmer::{imports, CompilerConfig, Instance, Module, Store}; use wasmer::{imports, CompilerConfig, EngineBuilder, Instance, Module, Store};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_llvm::LLVM; use wasmer_compiler_llvm::LLVM;
#[derive(Arbitrary, Debug, Default, Copy, Clone)] #[derive(Arbitrary, Debug, Default, Copy, Clone)]
@@ -42,7 +41,7 @@ fuzz_target!(|module: WasmSmithModule| {
let mut compiler = LLVM::default(); let mut compiler = LLVM::default();
compiler.canonicalize_nans(true); compiler.canonicalize_nans(true);
compiler.enable_verifier(); compiler.enable_verifier();
let mut store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let mut store = Store::new(compiler);
let module = Module::new(&store, &wasm_bytes).unwrap(); let module = Module::new(&store, &wasm_bytes).unwrap();
match Instance::new(&module, &imports! {}) { match Instance::new(&module, &imports! {}) {
Ok(_) => {} Ok(_) => {}

View File

@@ -2,8 +2,7 @@
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target}; use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
use wasm_smith::{Config, ConfiguredModule}; use wasm_smith::{Config, ConfiguredModule};
use wasmer::{imports, Instance, Module, Store}; use wasmer::{imports, EngineBuilder, Instance, Module, Store};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_singlepass::Singlepass; use wasmer_compiler_singlepass::Singlepass;
#[derive(Arbitrary, Debug, Default, Copy, Clone)] #[derive(Arbitrary, Debug, Default, Copy, Clone)]
@@ -40,7 +39,7 @@ fuzz_target!(|module: WasmSmithModule| {
} }
let compiler = Singlepass::default(); let compiler = Singlepass::default();
let mut store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let mut store = Store::new(compiler);
let module = Module::new(&store, &wasm_bytes); let module = Module::new(&store, &wasm_bytes);
let module = match module { let module = match module {
Ok(m) => m, Ok(m) => m,

View File

@@ -2,8 +2,6 @@ use crate::sys::tunables::BaseTunables;
use std::fmt; use std::fmt;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
#[cfg(feature = "compiler")] #[cfg(feature = "compiler")]
use wasmer_compiler::CompilerConfig;
#[cfg(feature = "compiler")]
use wasmer_compiler::{Engine, EngineBuilder, Tunables}; use wasmer_compiler::{Engine, EngineBuilder, Tunables};
use wasmer_vm::{init_traps, TrapHandler, TrapHandlerFn}; use wasmer_vm::{init_traps, TrapHandler, TrapHandlerFn};
@@ -37,15 +35,20 @@ pub struct Store {
impl Store { impl Store {
#[cfg(feature = "compiler")] #[cfg(feature = "compiler")]
/// Creates a new `Store` with a specific [`CompilerConfig`]. /// Creates a new `Store` with a specific [`Engine`].
pub fn new(compiler_config: Box<dyn CompilerConfig>) -> Self { pub fn new(engine: impl Into<Engine>) -> Self {
let engine = EngineBuilder::new(compiler_config, None, None).engine(); let engine = engine.into();
Self::new_with_tunables(&engine, BaseTunables::for_target(engine.target())) let target = engine.target().clone();
Self::new_with_tunables(engine, BaseTunables::for_target(&target))
} }
#[deprecated(
since = "3.0.0",
note = "Store::new_with_engine has been deprecated in favor of Store::new"
)]
/// Creates a new `Store` with a specific [`Engine`]. /// Creates a new `Store` with a specific [`Engine`].
pub fn new_with_engine(engine: &Engine) -> Self { pub fn new_with_engine(engine: impl Into<Engine>) -> Self {
Self::new_with_tunables(engine, BaseTunables::for_target(engine.target())) Self::new(engine)
} }
/// Set the trap handler in this store. /// Set the trap handler in this store.
@@ -55,9 +58,11 @@ impl Store {
/// Creates a new `Store` with a specific [`Engine`] and [`Tunables`]. /// Creates a new `Store` with a specific [`Engine`] and [`Tunables`].
pub fn new_with_tunables( pub fn new_with_tunables(
engine: &Engine, engine: impl Into<Engine>,
tunables: impl Tunables + Send + Sync + 'static, tunables: impl Tunables + Send + Sync + 'static,
) -> Self { ) -> Self {
let engine = engine.into();
// Make sure the signal handlers are installed. // Make sure the signal handlers are installed.
// This is required for handling traps. // This is required for handling traps.
init_traps(); init_traps();
@@ -128,7 +133,7 @@ impl Default for Store {
// more than one compiler is enabled. // more than one compiler is enabled.
#[allow(unreachable_code)] #[allow(unreachable_code)]
#[cfg(any(feature = "cranelift", feature = "llvm", feature = "singlepass"))] #[cfg(any(feature = "cranelift", feature = "llvm", feature = "singlepass"))]
fn get_config() -> impl CompilerConfig + 'static { fn get_config() -> impl wasmer_compiler::CompilerConfig + 'static {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(feature = "cranelift")] { if #[cfg(feature = "cranelift")] {
wasmer_compiler_cranelift::Cranelift::default() wasmer_compiler_cranelift::Cranelift::default()
@@ -151,10 +156,10 @@ impl Default for Store {
if #[cfg(any(feature = "cranelift", feature = "llvm", feature = "singlepass"))] if #[cfg(any(feature = "cranelift", feature = "llvm", feature = "singlepass"))]
{ {
let config = get_config(); let config = get_config();
wasmer_compiler::EngineBuilder::new(Box::new(config) as Box<dyn CompilerConfig>, None, None) EngineBuilder::new(Box::new(config) as Box<dyn wasmer_compiler::CompilerConfig>)
.engine() .engine()
} else { } else {
wasmer_compiler::EngineBuilder::headless() EngineBuilder::headless()
.engine() .engine()
} }
} }

View File

@@ -279,7 +279,7 @@ cfg_if! {
#[no_mangle] #[no_mangle]
pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> { pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
let compiler_config: Box<dyn CompilerConfig> = get_default_compiler_config(); let compiler_config: Box<dyn CompilerConfig> = get_default_compiler_config();
let engine: Engine = EngineBuilder::new(compiler_config, None, None).engine(); let engine: Engine = EngineBuilder::new(compiler_config).engine();
Box::new(wasm_engine_t { inner: engine }) Box::new(wasm_engine_t { inner: engine })
} }
} else if #[cfg(feature = "compiler-headless")] { } else if #[cfg(feature = "compiler-headless")] {
@@ -405,14 +405,14 @@ pub extern "C" fn wasm_engine_new_with_config(
let inner: Engine = let inner: Engine =
{ {
let mut builder = EngineBuilder::new(compiler_config, None, None); let mut builder = EngineBuilder::new(compiler_config);
if let Some(target) = config.target { if let Some(target) = config.target {
builder.set_target(Some(target.inner)); builder = builder.set_target(Some(target.inner));
} }
if let Some(features) = config.features { if let Some(features) = config.features {
builder.set_features(Some(features.inner)); builder = builder.set_features(Some(features.inner));
} }
builder.engine() builder.engine()
@@ -424,11 +424,11 @@ pub extern "C" fn wasm_engine_new_with_config(
let mut builder = EngineBuilder::headless(); let mut builder = EngineBuilder::headless();
if let Some(target) = config.target { if let Some(target) = config.target {
builder.set_target(Some(target.inner)); builder = builder.set_target(Some(target.inner));
} }
if let Some(features) = config.features { if let Some(features) = config.features {
builder.set_features(Some(features.inner)); builder = builder.set_features(Some(features.inner));
} }
builder.engine() builder.engine()

View File

@@ -34,7 +34,7 @@ pub unsafe extern "C" fn wasm_store_new(
engine: Option<&wasm_engine_t>, engine: Option<&wasm_engine_t>,
) -> Option<Box<wasm_store_t>> { ) -> Option<Box<wasm_store_t>> {
let engine = engine?; let engine = engine?;
let store = Store::new_with_engine(&engine.inner); let store = Store::new(&engine.inner);
Some(Box::new(wasm_store_t { Some(Box::new(wasm_store_t {
inner: StoreRef { inner: StoreRef {

View File

@@ -21,7 +21,6 @@ criterion = "0.3"
tempfile = "3" tempfile = "3"
rand = "0.8.3" rand = "0.8.3"
wasmer-compiler-singlepass = { path = "../compiler-singlepass", version = "=2.3.0" } wasmer-compiler-singlepass = { path = "../compiler-singlepass", version = "=2.3.0" }
wasmer-compiler = { path = "../compiler", version = "=2.3.0" }
[features] [features]
default = ["wasmer/js-serializable-module", "filesystem"] default = ["wasmer/js-serializable-module", "filesystem"]

View File

@@ -6,7 +6,6 @@ use tempfile::TempDir;
use wasmer::{Module, Store}; use wasmer::{Module, Store};
use wasmer_cache::Cache; use wasmer_cache::Cache;
use wasmer_cache::{FileSystemCache, Hash}; use wasmer_cache::{FileSystemCache, Hash};
use wasmer_compiler::EngineBuilder;
use wasmer_compiler_singlepass::Singlepass; use wasmer_compiler_singlepass::Singlepass;
fn random_key() -> Hash { fn random_key() -> Hash {
@@ -17,7 +16,7 @@ pub fn store_cache_universal(c: &mut Criterion) {
let tmp_dir = TempDir::new().unwrap(); let tmp_dir = TempDir::new().unwrap();
let mut fs_cache = FileSystemCache::new(tmp_dir.path()).unwrap(); let mut fs_cache = FileSystemCache::new(tmp_dir.path()).unwrap();
let compiler = Singlepass::default(); let compiler = Singlepass::default();
let store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let store = Store::new(compiler);
let module = Module::new( let module = Module::new(
&store, &store,
std::fs::read("../../lib/c-api/examples/assets/qjs.wasm").unwrap(), std::fs::read("../../lib/c-api/examples/assets/qjs.wasm").unwrap(),
@@ -36,7 +35,7 @@ pub fn load_cache_universal(c: &mut Criterion) {
let tmp_dir = TempDir::new().unwrap(); let tmp_dir = TempDir::new().unwrap();
let mut fs_cache = FileSystemCache::new(tmp_dir.path()).unwrap(); let mut fs_cache = FileSystemCache::new(tmp_dir.path()).unwrap();
let compiler = Singlepass::default(); let compiler = Singlepass::default();
let store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let store = Store::new(compiler);
let module = Module::new( let module = Module::new(
&store, &store,
std::fs::read("../../lib/c-api/examples/assets/qjs.wasm").unwrap(), std::fs::read("../../lib/c-api/examples/assets/qjs.wasm").unwrap(),
@@ -54,7 +53,7 @@ pub fn store_cache_native(c: &mut Criterion) {
let tmp_dir = TempDir::new().unwrap(); let tmp_dir = TempDir::new().unwrap();
let mut fs_cache = FileSystemCache::new(tmp_dir.path()).unwrap(); let mut fs_cache = FileSystemCache::new(tmp_dir.path()).unwrap();
let compiler = Singlepass::default(); let compiler = Singlepass::default();
let store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let store = Store::new(compiler);
let module = Module::new( let module = Module::new(
&store, &store,
std::fs::read("../../lib/c-api/examples/assets/qjs.wasm").unwrap(), std::fs::read("../../lib/c-api/examples/assets/qjs.wasm").unwrap(),
@@ -73,7 +72,7 @@ pub fn load_cache_native(c: &mut Criterion) {
let tmp_dir = TempDir::new().unwrap(); let tmp_dir = TempDir::new().unwrap();
let mut fs_cache = FileSystemCache::new(tmp_dir.path()).unwrap(); let mut fs_cache = FileSystemCache::new(tmp_dir.path()).unwrap();
let compiler = Singlepass::default(); let compiler = Singlepass::default();
let store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine()); let store = Store::new(compiler);
let module = Module::new( let module = Module::new(
&store, &store,
std::fs::read("../../lib/c-api/examples/assets/qjs.wasm").unwrap(), std::fs::read("../../lib/c-api/examples/assets/qjs.wasm").unwrap(),

View File

@@ -174,8 +174,9 @@ impl CompilerOptions {
compiler_config: Box<dyn CompilerConfig>, compiler_config: Box<dyn CompilerConfig>,
) -> Result<EngineBuilder> { ) -> Result<EngineBuilder> {
let features = self.get_features(compiler_config.default_features_for_target(&target))?; let features = self.get_features(compiler_config.default_features_for_target(&target))?;
let engine: EngineBuilder = let engine: EngineBuilder = EngineBuilder::new(compiler_config)
EngineBuilder::new(compiler_config, Some(target), Some(features)); .set_target(Some(target))
.set_features(Some(features));
Ok(engine) Ok(engine)
} }

View File

@@ -262,8 +262,8 @@ impl Run {
fn get_store_module(&self) -> Result<(Store, Module)> { fn get_store_module(&self) -> Result<(Store, Module)> {
let contents = std::fs::read(self.path.clone())?; let contents = std::fs::read(self.path.clone())?;
if wasmer_compiler::Artifact::is_deserializable(&contents) { if wasmer_compiler::Artifact::is_deserializable(&contents) {
let engine = wasmer_compiler::EngineBuilder::headless().engine(); let engine = wasmer_compiler::EngineBuilder::headless();
let store = Store::new_with_engine(&engine); let store = Store::new(engine);
let module = unsafe { Module::deserialize_from_file(&store, &self.path)? }; let module = unsafe { Module::deserialize_from_file(&store, &self.path)? };
return Ok((store, module)); return Ok((store, module));
} }

View File

@@ -105,7 +105,7 @@ impl CompilerOptions {
pub fn get_store_for_target(&self, target: Target) -> Result<(Store, CompilerType)> { pub fn get_store_for_target(&self, target: Target) -> Result<(Store, CompilerType)> {
let (compiler_config, compiler_type) = self.get_compiler_config()?; let (compiler_config, compiler_type) = self.get_compiler_config()?;
let engine = self.get_engine(target, compiler_config)?; let engine = self.get_engine(target, compiler_config)?;
let store = Store::new_with_engine(&engine); let store = Store::new(engine);
Ok((store, compiler_type)) Ok((store, compiler_type))
} }
@@ -114,12 +114,12 @@ impl CompilerOptions {
&self, &self,
target: Target, target: Target,
compiler_config: Box<dyn CompilerConfig>, compiler_config: Box<dyn CompilerConfig>,
) -> Result<Box<Engine>> { ) -> Result<Engine> {
let features = self.get_features(compiler_config.default_features_for_target(&target))?; let features = self.get_features(compiler_config.default_features_for_target(&target))?;
let engine: Box<Engine> = Box::new( let engine: Engine = wasmer_compiler::EngineBuilder::new(compiler_config)
wasmer_compiler::EngineBuilder::new(compiler_config, Some(target), Some(features)) .set_features(Some(features))
.engine(), .set_target(Some(target))
); .engine();
Ok(engine) Ok(engine)
} }
@@ -313,7 +313,7 @@ impl StoreOptions {
pub fn get_store_for_target(&self, target: Target) -> Result<(Store, CompilerType)> { pub fn get_store_for_target(&self, target: Target) -> Result<(Store, CompilerType)> {
let (compiler_config, compiler_type) = self.compiler.get_compiler_config()?; let (compiler_config, compiler_type) = self.compiler.get_compiler_config()?;
let engine = self.get_engine_with_compiler(target, compiler_config)?; let engine = self.get_engine_with_compiler(target, compiler_config)?;
let store = Store::new_with_engine(&engine); let store = Store::new(engine);
Ok((store, compiler_type)) Ok((store, compiler_type))
} }
@@ -322,9 +322,8 @@ impl StoreOptions {
&self, &self,
target: Target, target: Target,
compiler_config: Box<dyn CompilerConfig>, compiler_config: Box<dyn CompilerConfig>,
) -> Result<Box<Engine>> { ) -> Result<Engine> {
let engine = self.compiler.get_engine(target, compiler_config)?; let engine = self.compiler.get_engine(target, compiler_config)?;
Ok(engine) Ok(engine)
} }
} }
@@ -340,7 +339,7 @@ impl StoreOptions {
/// Get the store (headless engine) /// Get the store (headless engine)
pub fn get_store(&self) -> Result<(Store, CompilerType)> { pub fn get_store(&self) -> Result<(Store, CompilerType)> {
let engine = self.get_engine_headless()?; let engine = self.get_engine_headless()?;
let store = Store::new_with_engine(&engine); let store = Store::new(engine);
Ok((store, CompilerType::Headless)) Ok((store, CompilerType::Headless))
} }
} }

View File

@@ -9,8 +9,7 @@ use wasmer::{Store, EngineBuilder};
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
let compiler = Cranelift::new(); let compiler = Cranelift::new();
// Put it into an engine and add it to the store let mut store = Store::new(compiler);
let mut store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine());
``` ```
*Note: you can find a [full working example using Cranelift compiler *Note: you can find a [full working example using Cranelift compiler

View File

@@ -3,7 +3,7 @@ use cranelift_codegen::isa::{lookup, TargetIsa};
use cranelift_codegen::settings::{self, Configurable}; use cranelift_codegen::settings::{self, Configurable};
use cranelift_codegen::CodegenResult; use cranelift_codegen::CodegenResult;
use std::sync::Arc; use std::sync::Arc;
use wasmer_compiler::{Compiler, CompilerConfig, ModuleMiddleware}; use wasmer_compiler::{Compiler, CompilerConfig, Engine, EngineBuilder, ModuleMiddleware};
use wasmer_types::{Architecture, CpuFeature, Target}; use wasmer_types::{Architecture, CpuFeature, Target};
// Runtime Environment // Runtime Environment
@@ -214,3 +214,9 @@ impl Default for Cranelift {
Self::new() Self::new()
} }
} }
impl From<Cranelift> for Engine {
fn from(config: Cranelift) -> Self {
EngineBuilder::new(config).engine()
}
}

View File

@@ -9,8 +9,7 @@ use wasmer::{Store, EngineBuilder};
use wasmer_compiler_llvm::LLVM; use wasmer_compiler_llvm::LLVM;
let compiler = LLVM::new(); let compiler = LLVM::new();
// Put it into an engine and add it to the store let mut store = Store::new(compiler);
let mut store = Store::new_with_engine(&EngineBuilder::new(Some(Box::new(compiler)), None, None).engine());
``` ```
*Note: you can find a [full working example using LLVM compiler here][example].* *Note: you can find a [full working example using LLVM compiler here][example].*

View File

@@ -8,7 +8,7 @@ use itertools::Itertools;
use std::fmt::Debug; use std::fmt::Debug;
use std::sync::Arc; use std::sync::Arc;
use target_lexicon::Architecture; use target_lexicon::Architecture;
use wasmer_compiler::{Compiler, CompilerConfig, ModuleMiddleware}; use wasmer_compiler::{Compiler, CompilerConfig, Engine, EngineBuilder, ModuleMiddleware};
use wasmer_types::{FunctionType, LocalFunctionIndex, Target, Triple}; use wasmer_types::{FunctionType, LocalFunctionIndex, Target, Triple};
/// The InkWell ModuleInfo type /// The InkWell ModuleInfo type
@@ -227,3 +227,9 @@ impl Default for LLVM {
Self::new() Self::new()
} }
} }
impl From<LLVM> for Engine {
fn from(config: LLVM) -> Self {
EngineBuilder::new(config).engine()
}
}

View File

@@ -9,8 +9,7 @@ use wasmer::{Store, EngineBuilder};
use wasmer_compiler_singlepass::Singlepass; use wasmer_compiler_singlepass::Singlepass;
let compiler = Singlepass::new(); let compiler = Singlepass::new();
// Put it into an engine and add it to the store let mut store = Store::new(compiler);
let mut store = Store::new_with_engine(&EngineBuilder::new(compiler, None, None).engine());
``` ```
*Note: you can find a [full working example using Singlepass compiler *Note: you can find a [full working example using Singlepass compiler

View File

@@ -3,7 +3,7 @@
use crate::compiler::SinglepassCompiler; use crate::compiler::SinglepassCompiler;
use std::sync::Arc; use std::sync::Arc;
use wasmer_compiler::{Compiler, CompilerConfig, ModuleMiddleware}; use wasmer_compiler::{Compiler, CompilerConfig, Engine, EngineBuilder, ModuleMiddleware};
use wasmer_types::{CpuFeature, Features, Target}; use wasmer_types::{CpuFeature, Features, Target};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@@ -62,3 +62,9 @@ impl Default for Singlepass {
Self::new() Self::new()
} }
} }
impl From<Singlepass> for Engine {
fn from(config: Singlepass) -> Self {
EngineBuilder::new(config).engine()
}
}

View File

@@ -1,39 +0,0 @@
//! Universal compilation.
use crate::Compiler;
use wasmer_types::{CompileError, Features};
/// The Builder contents of `Engine`
pub struct EngineBuilder {
/// The compiler
compiler: Option<Box<dyn Compiler>>,
/// The features to compile the Wasm module with
features: Features,
}
impl EngineBuilder {
/// Create a new builder with pre-made components
pub fn new(compiler: Option<Box<dyn Compiler>>, features: Features) -> Self {
Self { compiler, features }
}
/// Gets the compiler associated to this engine.
pub fn compiler(&self) -> Result<&dyn Compiler, CompileError> {
if self.compiler.is_none() {
return Err(CompileError::Codegen(
"The Engine is not compiled in.".to_string(),
));
}
Ok(&**self.compiler.as_ref().unwrap())
}
/// Validate the module
pub fn validate(&self, data: &[u8]) -> Result<(), CompileError> {
self.compiler()?.validate_module(self.features(), data)
}
/// The Wasm features
pub fn features(&self) -> &Features {
&self.features
}
}

View File

@@ -14,14 +14,14 @@ pub struct EngineBuilder {
impl EngineBuilder { impl EngineBuilder {
/// Create a new builder with pre-made components /// Create a new builder with pre-made components
pub fn new<T>(compiler_config: T, target: Option<Target>, features: Option<Features>) -> Self pub fn new<T>(compiler_config: T) -> Self
where where
T: Into<Box<dyn CompilerConfig>>, T: Into<Box<dyn CompilerConfig>>,
{ {
Self { Self {
compiler_config: Some(compiler_config.into()), compiler_config: Some(compiler_config.into()),
target, target: None,
features, features: None,
} }
} }
@@ -35,13 +35,13 @@ impl EngineBuilder {
} }
/// Set the target /// Set the target
pub fn set_target(&mut self, target: Option<Target>) -> &mut Self { pub fn set_target(mut self, target: Option<Target>) -> Self {
self.target = target; self.target = target;
self self
} }
/// Set the features /// Set the features
pub fn set_features(&mut self, features: Option<Features>) -> &mut Self { pub fn set_features(mut self, features: Option<Features>) -> Self {
self.features = features; self.features = features;
self self
} }
@@ -70,4 +70,9 @@ impl EngineBuilder {
pub fn features(&self) -> Option<&Features> { pub fn features(&self) -> Option<&Features> {
self.features.as_ref() self.features.as_ref()
} }
/// The target
pub fn target(&self) -> Option<&Target> {
self.target.as_ref()
}
} }

View File

@@ -1,5 +1,6 @@
//! Universal compilation. //! Universal compilation.
use crate::engine::builder::EngineBuilder;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
use crate::Artifact; use crate::Artifact;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
@@ -347,6 +348,24 @@ impl EngineInner {
} }
} }
impl From<Box<dyn CompilerConfig>> for Engine {
fn from(config: Box<dyn CompilerConfig>) -> Self {
EngineBuilder::new(config).engine()
}
}
impl From<EngineBuilder> for Engine {
fn from(engine_builder: EngineBuilder) -> Self {
engine_builder.engine()
}
}
impl From<&Self> for Engine {
fn from(engine_ref: &Self) -> Self {
engine_ref.cloned()
}
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
#[repr(transparent)] #[repr(transparent)]
/// A unique identifier for an Engine. /// A unique identifier for an Engine.

View File

@@ -386,8 +386,7 @@ mod tests {
let metering = Arc::new(Metering::new(10, cost_function)); let metering = Arc::new(Metering::new(10, cost_function));
let mut compiler_config = Cranelift::default(); let mut compiler_config = Cranelift::default();
compiler_config.push_middleware(metering); compiler_config.push_middleware(metering);
let mut store = let mut store = Store::new(EngineBuilder::new(compiler_config));
Store::new_with_engine(&EngineBuilder::new(compiler_config, None, None).engine());
let module = Module::new(&store, bytecode()).unwrap(); let module = Module::new(&store, bytecode()).unwrap();
// Instantiate // Instantiate
@@ -435,8 +434,7 @@ mod tests {
let metering = Arc::new(Metering::new(10, cost_function)); let metering = Arc::new(Metering::new(10, cost_function));
let mut compiler_config = Cranelift::default(); let mut compiler_config = Cranelift::default();
compiler_config.push_middleware(metering); compiler_config.push_middleware(metering);
let mut store = let mut store = Store::new(EngineBuilder::new(compiler_config));
Store::new_with_engine(&EngineBuilder::new(compiler_config, None, None).engine());
let module = Module::new(&store, bytecode()).unwrap(); let module = Module::new(&store, bytecode()).unwrap();
// Instantiate // Instantiate

View File

@@ -42,24 +42,24 @@ impl Config {
pub fn store(&self) -> Store { pub fn store(&self) -> Store {
let compiler_config = self.compiler_config(self.canonicalize_nans); let compiler_config = self.compiler_config(self.canonicalize_nans);
let engine = self.engine(compiler_config); let engine = self.engine(compiler_config);
Store::new_with_engine(&*engine) Store::new(engine)
} }
pub fn headless_store(&self) -> Store { pub fn headless_store(&self) -> Store {
let engine = self.engine_headless(); let engine = self.engine_headless();
Store::new_with_engine(&*engine) Store::new(engine)
} }
pub fn engine(&self, compiler_config: Box<dyn CompilerConfig>) -> Box<Engine> { pub fn engine(&self, compiler_config: Box<dyn CompilerConfig>) -> Engine {
let mut engine = wasmer_compiler::EngineBuilder::new(compiler_config, None, None); let mut engine = wasmer_compiler::EngineBuilder::new(compiler_config);
if let Some(ref features) = self.features { if let Some(ref features) = self.features {
engine.set_features(Some(features.clone())); engine = engine.set_features(Some(features.clone()));
} }
Box::new(engine.engine()) engine.engine()
} }
pub fn engine_headless(&self) -> Box<Engine> { pub fn engine_headless(&self) -> Engine {
Box::new(wasmer_compiler::EngineBuilder::headless().engine()) wasmer_compiler::EngineBuilder::headless().engine()
} }
pub fn compiler_config( pub fn compiler_config(

View File

@@ -20,7 +20,6 @@ fn run_add_with_limit(mut config: crate::Config, limit: u64) -> Result<()> {
(i32.add (local.get 0) (i32.add (local.get 0)
(local.get 1))) (local.get 1)))
)"#; )"#;
let mut env = FunctionEnv::new(&mut store, ());
let import_object = imports! {}; let import_object = imports! {};
@@ -54,7 +53,6 @@ fn run_loop(mut config: crate::Config, limit: u64, iter_count: i32) -> Result<()
) )
)"#; )"#;
let module = Module::new(&store, wat).unwrap(); let module = Module::new(&store, wat).unwrap();
let mut env = FunctionEnv::new(&mut store, ());
let import_object = imports! {}; let import_object = imports! {};

View File

@@ -34,7 +34,7 @@ pub fn run_wast(mut config: crate::Config, wast_path: &str) -> anyhow::Result<()
config.set_features(features); config.set_features(features);
config.set_nan_canonicalization(try_nan_canonicalization); config.set_nan_canonicalization(try_nan_canonicalization);
let mut store = config.store(); let store = config.store();
let mut wast = Wast::new_with_spectest(store); let mut wast = Wast::new_with_spectest(store);
// `bulk-memory-operations/bulk.wast` checks for a message that // `bulk-memory-operations/bulk.wast` checks for a message that
// specifies which element is uninitialized, but our traps don't // specifies which element is uninitialized, but our traps don't