Rename engine's Universal type to Backend

The Universal type was essentially a builder of engines that's given a
compiler backend and creates an Engine with .engine() method. The name
was not clear.
This commit is contained in:
Manos Pitsidianakis
2022-07-25 11:48:04 +03:00
parent b9ab9515c1
commit 4a06b1d3f6
45 changed files with 109 additions and 109 deletions

View File

@@ -150,14 +150,14 @@ fn run_static_benchmarks(_c: &mut Criterion) {
#[cfg(feature = "llvm")] #[cfg(feature = "llvm")]
{ {
let mut store = let mut store =
Store::new_with_engine(&Universal::new(wasmer_compiler_llvm::LLVM::new()).engine()); Store::new_with_engine(&Backend::new(wasmer_compiler_llvm::LLVM::new()).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_with_engine(
&Universal::new(wasmer_compiler_cranelift::Cranelift::new()).engine(), &Backend::new(wasmer_compiler_cranelift::Cranelift::new()).engine(),
); );
run_basic_static_function(&store, "cranelift", c); run_basic_static_function(&store, "cranelift", c);
} }
@@ -165,7 +165,7 @@ fn run_static_benchmarks(_c: &mut Criterion) {
#[cfg(feature = "singlepass")] #[cfg(feature = "singlepass")]
{ {
let mut store = Store::new_with_engine( let mut store = Store::new_with_engine(
&Universal::new(wasmer_compiler_singlepass::Singlepass::new()).engine(), &Backend::new(wasmer_compiler_singlepass::Singlepass::new()).engine(),
); );
run_basic_static_function(&store, "singlepass", c); run_basic_static_function(&store, "singlepass", c);
} }
@@ -175,14 +175,14 @@ fn run_dynamic_benchmarks(_c: &mut Criterion) {
#[cfg(feature = "llvm")] #[cfg(feature = "llvm")]
{ {
let mut store = let mut store =
Store::new_with_engine(&Universal::new(wasmer_compiler_llvm::LLVM::new()).engine()); Store::new_with_engine(&Backend::new(wasmer_compiler_llvm::LLVM::new()).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_with_engine(
&Universal::new(wasmer_compiler_cranelift::Cranelift::new()).engine(), &Backend::new(wasmer_compiler_cranelift::Cranelift::new()).engine(),
); );
run_basic_dynamic_function(&store, "cranelift", c); run_basic_dynamic_function(&store, "cranelift", c);
} }
@@ -190,7 +190,7 @@ fn run_dynamic_benchmarks(_c: &mut Criterion) {
#[cfg(feature = "singlepass")] #[cfg(feature = "singlepass")]
{ {
let mut store = Store::new_with_engine( let mut store = Store::new_with_engine(
&Universal::new(wasmer_compiler_singlepass::Singlepass::new()).engine(), &Backend::new(wasmer_compiler_singlepass::Singlepass::new()).engine(),
); );
run_basic_dynamic_function(&store, "singlepass", c); run_basic_dynamic_function(&store, "singlepass", c);
} }

View File

@@ -130,7 +130,7 @@ let wasm_bytes = wat2wasm(
)?; )?;
let compiler_config = Cranelift::default(); let compiler_config = Cranelift::default();
let engine = Universal::new(compiler_config).engine(); let engine = Backend::new(compiler_config).engine();
let mut store = Store::new(&engine); let mut store = Store::new(&engine);
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! {})?;

View File

@@ -11,7 +11,7 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
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 +33,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(&Universal::new(compiler).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler).engine());
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -11,7 +11,7 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
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 +33,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(&Universal::new(compiler).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler).engine());
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -11,7 +11,7 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
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 +33,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(&Universal::new(compiler).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler).engine());
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -20,7 +20,7 @@ use wasmer::{
imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store, imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store,
TypedFunction, TypedFunction,
}; };
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
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,7 +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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).engine());
let env = FunctionEnv::new(&mut store, ()); let env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -19,7 +19,7 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, Instance, Module, Store, Value}; use wasmer::{imports, wat2wasm, Instance, Module, Store, Value};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
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,7 +49,7 @@ 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 = Universal::new(compiler_config).engine(); let engine = Backend::new(compiler_config).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_with_engine(&engine);

View File

@@ -20,7 +20,7 @@
use std::str::FromStr; use std::str::FromStr;
use wasmer::{wat2wasm, Module, RuntimeError, Store}; use wasmer::{wat2wasm, Module, RuntimeError, Store};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
use wasmer_types::{CpuFeature, Target, Triple}; use wasmer_types::{CpuFeature, Target, Triple};
@@ -70,7 +70,7 @@ 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 engine = Universal::new(compiler_config) let engine = Backend::new(compiler_config)
// Here we go. // Here we go.
// Pass the target to the engine! The engine will share // Pass the target to the engine! The engine will share
// this information with the compiler. // this information with the compiler.

View File

@@ -52,7 +52,7 @@ use wasmer::Instance;
use wasmer::Module; use wasmer::Module;
use wasmer::Store; use wasmer::Store;
use wasmer::Value; use wasmer::Value;
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
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>> {
@@ -82,7 +82,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Creating univesral engine..."); println!("Creating univesral engine...");
// Define the engine that will drive everything. // Define the engine that will drive everything.
let engine = Universal::new(compiler_config).engine(); let engine = Backend::new(compiler_config).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_with_engine(&engine);
@@ -105,7 +105,7 @@ 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 = Universal::headless().engine(); let engine = Backend::headless().engine();
let mut store = Store::new_with_engine(&engine); let mut store = Store::new_with_engine(&engine);
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());

View File

@@ -14,7 +14,7 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction}; use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
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,7 +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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).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,7 @@
//! 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::Universal; use wasmer_compiler::Backend;
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,7 +40,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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).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,7 @@
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::Universal; use wasmer_compiler::Backend;
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,7 +40,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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).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,7 @@
//! 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::Universal; use wasmer_compiler::Backend;
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,7 +37,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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).engine());
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -11,7 +11,7 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, Features, FunctionEnv, Instance, Module, Store, Value}; use wasmer::{imports, wat2wasm, Features, FunctionEnv, Instance, Module, Store, Value};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
@@ -36,7 +36,7 @@ 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 = Universal::new(compiler).features(features); let engine = Backend::new(compiler).features(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_with_engine(&engine.engine());

View File

@@ -10,7 +10,7 @@ use wasmer::{
imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store, imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store,
TypedFunction, TypedFunction,
}; };
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
@@ -47,7 +47,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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).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,7 @@ 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::Universal; use wasmer_compiler::Backend;
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,7 +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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).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,7 @@ 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::Universal; use wasmer_compiler::Backend;
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,7 +45,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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).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,7 @@ use wasmer::{
imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store, imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store,
TypedFunction, TypedFunction,
}; };
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
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,7 +52,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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).engine());
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -18,7 +18,7 @@
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::Universal; use wasmer_compiler::Backend;
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,7 +40,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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).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,7 @@
//! Ready? //! Ready?
use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction}; use wasmer::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
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,7 +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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).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,7 @@ 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::Universal; use wasmer_compiler::Backend;
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,7 +59,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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).engine());
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -19,7 +19,7 @@ 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::{imports, wat2wasm, FunctionEnv, Instance, Module, Store, TypedFunction};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
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,7 +70,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 = Store::new_with_engine(&Universal::new(compiler_config).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler_config).engine());
let mut env = FunctionEnv::new(&mut store, ()); let mut env = FunctionEnv::new(&mut store, ());
println!("Compiling module..."); println!("Compiling module...");

View File

@@ -2,7 +2,7 @@ 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::Universal; use wasmer_compiler::Backend;
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,7 +52,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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).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,7 @@ 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::Universal; use wasmer_compiler::Backend;
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.
@@ -137,7 +137,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Any compiler and any engine do the job here // Any compiler and any engine do the job here
let compiler = Cranelift::default(); let compiler = Cranelift::default();
let engine = Universal::new(compiler).engine(); let engine = Backend::new(compiler).engine();
// Here is where the fun begins // Here is where the fun begins

View File

@@ -16,7 +16,7 @@
//! Ready? //! Ready?
use wasmer::{FunctionEnv, Instance, Module, Store}; use wasmer::{FunctionEnv, Instance, Module, Store};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
use wasmer_wasi::WasiState; use wasmer_wasi::WasiState;
@@ -32,7 +32,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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).engine());
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -13,7 +13,7 @@
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::Universal; use wasmer_compiler::Backend;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
use wasmer_wasi::{Pipe, WasiState}; use wasmer_wasi::{Pipe, WasiState};
@@ -29,7 +29,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 = Store::new_with_engine(&Universal::new(Cranelift::default()).engine()); let mut store = Store::new_with_engine(&Backend::new(Cranelift::default()).engine());
println!("Compiling module..."); println!("Compiling module...");
// Let's compile the Wasm module. // Let's compile the Wasm module.

View File

@@ -3,7 +3,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, Module, Store};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
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;
@@ -47,7 +47,7 @@ fuzz_target!(|module: ConfiguredModule<NoImportsConfig>| {
compiler.enable_verifier(); compiler.enable_verifier();
compile_and_compare( compile_and_compare(
"universal-cranelift", "universal-cranelift",
Universal::new(compiler.clone()).engine(), Backend::new(compiler.clone()).engine(),
&wasm_bytes, &wasm_bytes,
); );
@@ -56,14 +56,14 @@ fuzz_target!(|module: ConfiguredModule<NoImportsConfig>| {
compiler.enable_verifier(); compiler.enable_verifier();
compile_and_compare( compile_and_compare(
"universal-llvm", "universal-llvm",
Universal::new(compiler.clone()).engine(), Backend::new(compiler.clone()).engine(),
&wasm_bytes, &wasm_bytes,
); );
let compiler = Singlepass::default(); let compiler = Singlepass::default();
compile_and_compare( compile_and_compare(
"universal-singlepass", "universal-singlepass",
Universal::new(compiler.clone()).engine(), Backend::new(compiler.clone()).engine(),
&wasm_bytes, &wasm_bytes,
); );
}); });

View File

@@ -5,7 +5,7 @@ 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, Instance, Module, Store, Val};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
#[cfg(feature = "cranelift")] #[cfg(feature = "cranelift")]
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
#[cfg(feature = "llvm")] #[cfg(feature = "llvm")]
@@ -48,7 +48,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(&Universal::new(compiler).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler).engine());
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 +69,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(&Universal::new(compiler).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler).engine());
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 +80,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(&Universal::new(compiler).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler).engine());
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

@@ -5,7 +5,7 @@ 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, Instance, Module, Store};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
use wasmer_middlewares::Metering; use wasmer_middlewares::Metering;
@@ -56,7 +56,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(&Universal::new(compiler).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler).engine());
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

@@ -3,7 +3,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, Instance, Module, Store};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
use wasmer_compiler_cranelift::Cranelift; use wasmer_compiler_cranelift::Cranelift;
#[derive(Arbitrary, Debug, Default, Copy, Clone)] #[derive(Arbitrary, Debug, Default, Copy, Clone)]
@@ -42,7 +42,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(&Universal::new(compiler).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler).engine());
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

@@ -3,7 +3,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, Instance, Module, Store};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
use wasmer_compiler_llvm::LLVM; use wasmer_compiler_llvm::LLVM;
#[derive(Arbitrary, Debug, Default, Copy, Clone)] #[derive(Arbitrary, Debug, Default, Copy, Clone)]
@@ -42,7 +42,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(&Universal::new(compiler).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler).engine());
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

@@ -3,7 +3,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, Instance, Module, Store};
use wasmer_compiler::Universal; use wasmer_compiler::Backend;
use wasmer_compiler_singlepass::Singlepass; use wasmer_compiler_singlepass::Singlepass;
#[derive(Arbitrary, Debug, Default, Copy, Clone)] #[derive(Arbitrary, Debug, Default, Copy, Clone)]
@@ -40,7 +40,7 @@ fuzz_target!(|module: WasmSmithModule| {
} }
let compiler = Singlepass::default(); let compiler = Singlepass::default();
let mut store = Store::new_with_engine(&Universal::new(compiler).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler).engine());
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

@@ -77,9 +77,9 @@ compile_error!(
If you wish to use more than one compiler, you can simply create the own store. Eg.: If you wish to use more than one compiler, you can simply create the own store. Eg.:
``` ```
use wasmer::{Store, Universal, Singlepass}; use wasmer::{Store, Backend, Singlepass};
let engine = Universal::new(Singlepass::default()).engine(); let engine = Backend::new(Singlepass::default()).engine();
let mut store = Store::new_with_engine(&engine); let mut store = Store::new_with_engine(&engine);
```"# ```"#
); );
@@ -94,7 +94,7 @@ pub use wasmer_compiler_cranelift::{Cranelift, CraneliftOptLevel};
pub use wasmer_compiler_llvm::{LLVMOptLevel, LLVM}; pub use wasmer_compiler_llvm::{LLVMOptLevel, LLVM};
#[cfg(feature = "universal")] #[cfg(feature = "universal")]
pub use wasmer_compiler::{Artifact, Engine, Universal}; pub use wasmer_compiler::{Artifact, Backend, Engine};
/// Version number of this crate. /// Version number of this crate.
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); pub const VERSION: &str = env!("CARGO_PKG_VERSION");
@@ -102,7 +102,7 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");
/// The Deprecated JIT Engine (please use `Universal` instead) /// The Deprecated JIT Engine (please use `Universal` instead)
#[cfg(feature = "jit")] #[cfg(feature = "jit")]
#[deprecated(since = "2.0.0", note = "Please use the `universal` feature instead")] #[deprecated(since = "2.0.0", note = "Please use the `universal` feature instead")]
pub type JIT = Universal; pub type JIT = Backend;
/// This type is deprecated, it has been replaced by TypedFunction. /// This type is deprecated, it has been replaced by TypedFunction.
#[deprecated( #[deprecated(

View File

@@ -4,7 +4,7 @@ use std::sync::{Arc, RwLock};
#[cfg(feature = "compiler")] #[cfg(feature = "compiler")]
use wasmer_compiler::CompilerConfig; use wasmer_compiler::CompilerConfig;
#[cfg(feature = "compiler")] #[cfg(feature = "compiler")]
use wasmer_compiler::{Engine, Tunables, Universal}; use wasmer_compiler::{Backend, Engine, Tunables};
use wasmer_vm::{init_traps, TrapHandler, TrapHandlerFn}; use wasmer_vm::{init_traps, TrapHandler, TrapHandlerFn};
use wasmer_vm::StoreObjects; use wasmer_vm::StoreObjects;
@@ -39,7 +39,7 @@ impl Store {
#[cfg(feature = "compiler")] #[cfg(feature = "compiler")]
/// Creates a new `Store` with a specific [`CompilerConfig`]. /// Creates a new `Store` with a specific [`CompilerConfig`].
pub fn new(compiler_config: Box<dyn CompilerConfig>) -> Self { pub fn new(compiler_config: Box<dyn CompilerConfig>) -> Self {
let engine = Universal::new(compiler_config).engine(); let engine = Backend::new(compiler_config).engine();
Self::new_with_tunables(&engine, BaseTunables::for_target(engine.target())) Self::new_with_tunables(&engine, BaseTunables::for_target(engine.target()))
} }
@@ -145,7 +145,7 @@ impl Default for Store {
fn get_engine(mut config: impl CompilerConfig + 'static) -> Engine { fn get_engine(mut config: impl CompilerConfig + 'static) -> Engine {
cfg_if::cfg_if! { cfg_if::cfg_if! {
if #[cfg(feature = "default-universal")] { if #[cfg(feature = "default-universal")] {
wasmer_compiler::Universal::new(config) wasmer_compiler::Backend::new(config)
.engine() .engine()
} else { } else {
compile_error!("No default engine chosen") compile_error!("No default engine chosen")

View File

@@ -13,7 +13,7 @@ use crate::error::update_last_error;
use cfg_if::cfg_if; use cfg_if::cfg_if;
use std::sync::Arc; use std::sync::Arc;
#[cfg(feature = "universal")] #[cfg(feature = "universal")]
use wasmer_compiler::{Engine, Universal}; use wasmer_compiler::{Backend, Engine};
/// Kind of compilers that can be used by the engines. /// Kind of compilers that can be used by the engines.
/// ///
@@ -295,7 +295,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: Arc<Engine> = Arc::new(Universal::new(compiler_config).engine()); let engine: Arc<Engine> = Arc::new(Backend::new(compiler_config).engine());
Box::new(wasm_engine_t { inner: engine }) Box::new(wasm_engine_t { inner: engine })
} }
} else if #[cfg(feature = "universal")] { } else if #[cfg(feature = "universal")] {
@@ -308,7 +308,7 @@ cfg_if! {
/// cbindgen:ignore /// cbindgen:ignore
#[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 engine: Arc<Engine> = Arc::new(Universal::headless().engine()); let engine: Arc<Engine> = Arc::new(Backend::headless().engine());
Box::new(wasm_engine_t { inner: engine }) Box::new(wasm_engine_t { inner: engine })
} }
} else { } else {
@@ -423,7 +423,7 @@ pub extern "C" fn wasm_engine_new_with_config(
#[cfg(feature = "universal")] #[cfg(feature = "universal")]
let inner: Arc<Engine> = let inner: Arc<Engine> =
{ {
let mut builder = Universal::new(compiler_config); let mut builder = Backend::new(compiler_config);
if let Some(target) = config.target { if let Some(target) = config.target {
builder = builder.target(target.inner); builder = builder.target(target.inner);
@@ -440,7 +440,7 @@ pub extern "C" fn wasm_engine_new_with_config(
let inner: Arc<Engine> = let inner: Arc<Engine> =
cfg_if! { cfg_if! {
if #[cfg(feature = "universal")] { if #[cfg(feature = "universal")] {
let mut builder = Universal::headless(); let mut builder = Backend::headless();
if let Some(target) = config.target { if let Some(target) = config.target {
builder = builder.target(target.inner); builder = builder.target(target.inner);

View File

@@ -6,7 +6,7 @@ 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::Universal; use wasmer_compiler::Backend;
use wasmer_compiler_singlepass::Singlepass; use wasmer_compiler_singlepass::Singlepass;
fn random_key() -> Hash { fn random_key() -> Hash {
@@ -17,7 +17,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(&Universal::new(compiler).engine()); let store = Store::new_with_engine(&Backend::new(compiler).engine());
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 +36,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(&Universal::new(compiler).engine()); let store = Store::new_with_engine(&Backend::new(compiler).engine());
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 +54,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(&Universal::new(compiler).engine()); let store = Store::new_with_engine(&Backend::new(compiler).engine());
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 +73,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(&Universal::new(compiler).engine()); let store = Store::new_with_engine(&Backend::new(compiler).engine());
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

@@ -262,7 +262,7 @@ 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::Universal::headless().engine(); let engine = wasmer_compiler::Backend::headless().engine();
let store = Store::new_with_engine(&engine); let store = Store::new_with_engine(&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

@@ -115,7 +115,7 @@ impl CompilerOptions {
) -> Result<Box<Engine>> { ) -> Result<Box<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: Box<Engine> = Box::new(
wasmer_compiler::Universal::new(compiler_config) wasmer_compiler::Backend::new(compiler_config)
.features(features) .features(features)
.target(target) .target(target)
.engine(), .engine(),
@@ -332,7 +332,7 @@ impl StoreOptions {
#[cfg(not(feature = "compiler"))] #[cfg(not(feature = "compiler"))]
impl StoreOptions { impl StoreOptions {
fn get_engine_headless(&self) -> Result<Arc<Engine>> { fn get_engine_headless(&self) -> Result<Arc<Engine>> {
let engine: Arc<Engine> = Arc::new(wasmer_compiler::Universal::headless().engine()); let engine: Arc<Engine> = Arc::new(wasmer_compiler::Backend::headless().engine());
Ok(engine) Ok(engine)
} }

View File

@@ -5,12 +5,12 @@ This crate contains a compiler implementation based on Cranelift.
## Usage ## Usage
```rust ```rust
use wasmer::{Store, Universal}; use wasmer::{Store, Backend};
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 // Put it into an engine and add it to the store
let mut store = Store::new_with_engine(&Universal::new(compiler).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler).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

@@ -5,12 +5,12 @@ This crate contains a compiler implementation based on [the LLVM Compiler Infras
## Usage ## Usage
```rust ```rust
use wasmer::{Store, Universal}; use wasmer::{Store, Backend};
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 // Put it into an engine and add it to the store
let mut store = Store::new_with_engine(&Universal::new(compiler).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler).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

@@ -5,12 +5,12 @@ This crate contains a compiler implementation based on the Singlepass linear com
## Usage ## Usage
```rust ```rust
use wasmer::{Store, Universal}; use wasmer::{Store, Backend};
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 // Put it into an engine and add it to the store
let mut store = Store::new_with_engine(&Universal::new(compiler).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler).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

@@ -2,16 +2,16 @@ use super::Engine;
use crate::{CompilerConfig, Features}; use crate::{CompilerConfig, Features};
use wasmer_types::Target; use wasmer_types::Target;
/// The Universal builder /// The Backend builder
pub struct Universal { pub struct Backend {
#[allow(dead_code)] #[allow(dead_code)]
compiler_config: Option<Box<dyn CompilerConfig>>, compiler_config: Option<Box<dyn CompilerConfig>>,
target: Option<Target>, target: Option<Target>,
features: Option<Features>, features: Option<Features>,
} }
impl Universal { impl Backend {
/// Create a new Universal /// Create a new Backend
pub fn new<T>(compiler_config: T) -> Self pub fn new<T>(compiler_config: T) -> Self
where where
T: Into<Box<dyn CompilerConfig>>, T: Into<Box<dyn CompilerConfig>>,
@@ -23,7 +23,7 @@ impl Universal {
} }
} }
/// Create a new headless Universal /// Create a new headless Backend
pub fn headless() -> Self { pub fn headless() -> Self {
Self { Self {
compiler_config: None, compiler_config: None,

View File

@@ -12,7 +12,7 @@ mod link;
mod unwind; mod unwind;
pub use self::artifact::Artifact; pub use self::artifact::Artifact;
pub use self::builder::Universal; pub use self::builder::Backend;
pub use self::code_memory::CodeMemory; pub use self::code_memory::CodeMemory;
pub use self::engine::Engine; pub use self::engine::Engine;
pub use self::link::link_module; pub use self::link::link_module;

View File

@@ -354,7 +354,7 @@ mod tests {
use std::sync::Arc; use std::sync::Arc;
use wasmer::{ use wasmer::{
imports, wat2wasm, CompilerConfig, Cranelift, Module, Store, TypedFunction, Universal, imports, wat2wasm, Backend, CompilerConfig, Cranelift, Module, Store, TypedFunction,
}; };
fn cost_function(operator: &Operator) -> u64 { fn cost_function(operator: &Operator) -> u64 {
@@ -386,7 +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 = Store::new_with_engine(&Universal::new(compiler_config).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler_config).engine());
let module = Module::new(&store, bytecode()).unwrap(); let module = Module::new(&store, bytecode()).unwrap();
// Instantiate // Instantiate
@@ -434,7 +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 = Store::new_with_engine(&Universal::new(compiler_config).engine()); let mut store = Store::new_with_engine(&Backend::new(compiler_config).engine());
let module = Module::new(&store, bytecode()).unwrap(); let module = Module::new(&store, bytecode()).unwrap();
// Instantiate // Instantiate

View File

@@ -51,7 +51,7 @@ impl Config {
} }
pub fn engine(&self, compiler_config: Box<dyn CompilerConfig>) -> Box<Engine> { pub fn engine(&self, compiler_config: Box<dyn CompilerConfig>) -> Box<Engine> {
let mut engine = wasmer_compiler::Universal::new(compiler_config); let mut engine = wasmer_compiler::Backend::new(compiler_config);
if let Some(ref features) = self.features { if let Some(ref features) = self.features {
engine = engine.features(features.clone()) engine = engine.features(features.clone())
} }
@@ -59,7 +59,7 @@ impl Config {
} }
pub fn engine_headless(&self) -> Box<Engine> { pub fn engine_headless(&self) -> Box<Engine> {
Box::new(wasmer_compiler::Universal::headless().engine()) Box::new(wasmer_compiler::Backend::headless().engine())
} }
pub fn compiler_config( pub fn compiler_config(