diff --git a/Cargo.toml b/Cargo.toml index 2ed45f1da..7d3cce9c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ autoexamples = false wasmer = { version = "=3.2.0-alpha.1", path = "lib/api", default-features = false } wasmer-compiler = { version = "=3.2.0-alpha.1", path = "lib/compiler", features = [ "compiler", -] } +], optional=true } wasmer-compiler-cranelift = { version = "=3.2.0-alpha.1", path = "lib/compiler-cranelift", optional = true } wasmer-compiler-singlepass = { version = "=3.2.0-alpha.1", path = "lib/compiler-singlepass", optional = true } wasmer-compiler-llvm = { version = "=3.2.0-alpha.1", path = "lib/compiler-llvm", optional = true } @@ -74,7 +74,7 @@ rustc_version = "0.4" [dev-dependencies] wasmer = { version = "=3.2.0-alpha.1", path = "lib/api", default-features = false, features = [ - "cranelift", + "jsc", ] } anyhow = "1.0" criterion = "0.3" @@ -102,6 +102,7 @@ default = [ "emscripten", "middlewares", ] +jsc = ["wasmer/jsc", "wat", "wasmer/std"] engine = ["universal"] universal = [] cache = ["wasmer-cache"] @@ -140,10 +141,10 @@ split-debuginfo = "unpacked" name = "static_and_dynamic_functions" harness = false -[[example]] -name = "early-exit" -path = "examples/early_exit.rs" -required-features = ["cranelift"] +# [[example]] +# name = "early-exit" +# path = "examples/early_exit.rs" +# required-features = [] [[example]] name = "engine" @@ -183,27 +184,27 @@ required-features = ["llvm"] [[example]] name = "exported-function" path = "examples/exports_function.rs" -required-features = ["cranelift"] +required-features = [] [[example]] name = "exported-global" path = "examples/exports_global.rs" -required-features = ["cranelift"] +required-features = [] -[[example]] -name = "exported-memory" -path = "examples/exports_memory.rs" -required-features = ["cranelift"] +# [[example]] +# name = "exported-memory" +# path = "examples/exports_memory.rs" +# required-features = [] [[example]] name = "imported-function" path = "examples/imports_function.rs" -required-features = ["cranelift"] +required-features = [] [[example]] name = "imported-global" path = "examples/imports_global.rs" -required-features = ["cranelift"] +required-features = [] [[example]] name = "tunables-limit-memory" @@ -213,52 +214,52 @@ required-features = ["cranelift"] [[example]] name = "wasi" path = "examples/wasi.rs" -required-features = ["cranelift", "wasi"] +required-features = ["wasi"] [[example]] name = "wasi-manual-setup" path = "examples/wasi_manual_setup.rs" -required-features = ["cranelift", "wasi"] +required-features = ["wasi"] [[example]] name = "wasi-pipes" path = "examples/wasi_pipes.rs" -required-features = ["cranelift", "wasi"] +required-features = ["wasi"] [[example]] name = "table" path = "examples/table.rs" -required-features = ["cranelift"] +required-features = [] -[[example]] -name = "memory" -path = "examples/memory.rs" -required-features = ["cranelift"] +# [[example]] +# name = "memory" +# path = "examples/memory.rs" +# required-features = [] [[example]] name = "instance" path = "examples/instance.rs" -required-features = ["cranelift"] +required-features = [] [[example]] name = "errors" path = "examples/errors.rs" -required-features = ["cranelift"] +required-features = ["sys"] [[example]] name = "imported-function-env" path = "examples/imports_function_env.rs" -required-features = ["cranelift"] +required-features = [] [[example]] name = "imported-function-env-global" path = "examples/imports_function_env_global.rs" -required-features = ["cranelift"] +required-features = [] [[example]] name = "hello-world" path = "examples/hello_world.rs" -required-features = ["cranelift"] +required-features = [] [[example]] name = "metering" @@ -268,7 +269,7 @@ required-features = ["cranelift"] [[example]] name = "imports-exports" path = "examples/imports_exports.rs" -required-features = ["cranelift"] +required-features = [] [[example]] name = "features" diff --git a/examples/early_exit.rs b/examples/early_exit.rs index 17d1b2ef9..95d9a801c 100644 --- a/examples/early_exit.rs +++ b/examples/early_exit.rs @@ -17,7 +17,6 @@ use anyhow::bail; use std::fmt; use wasmer::{imports, wat2wasm, Function, Instance, Module, Store, TypedFunction}; -use wasmer_compiler_cranelift::Cranelift; // First we need to create an error type that we'll use to signal the end of execution. #[derive(Debug, Clone, Copy)] @@ -51,10 +50,7 @@ fn main() -> anyhow::Result<()> { )?; // Create a Store. - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/errors.rs b/examples/errors.rs index c2035cbcd..c034c409d 100644 --- a/examples/errors.rs +++ b/examples/errors.rs @@ -14,7 +14,6 @@ //! Ready? use wasmer::{imports, wat2wasm, Instance, Module, Store, TypedFunction}; -use wasmer_compiler_cranelift::Cranelift; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -38,7 +37,7 @@ fn main() -> Result<(), Box> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/exports_function.rs b/examples/exports_function.rs index 4eb9cf5f6..e984322cf 100644 --- a/examples/exports_function.rs +++ b/examples/exports_function.rs @@ -18,7 +18,6 @@ //! Ready? use wasmer::{imports, wat2wasm, Instance, Module, Store, TypedFunction, Value}; -use wasmer_compiler_cranelift::Cranelift; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -36,10 +35,7 @@ fn main() -> Result<(), Box> { )?; // Create a Store. - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/exports_global.rs b/examples/exports_global.rs index 86787d878..cdb8455ac 100644 --- a/examples/exports_global.rs +++ b/examples/exports_global.rs @@ -16,7 +16,6 @@ //! Ready? use wasmer::{imports, wat2wasm, Instance, Module, Mutability, Store, Type, TypedFunction, Value}; -use wasmer_compiler_cranelift::Cranelift; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -34,10 +33,7 @@ fn main() -> Result<(), Box> { )?; // Create a Store. - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module. @@ -105,10 +101,12 @@ fn main() -> Result<(), Box> { // Trying to set the value of a immutable global (`const`) // will result in a `RuntimeError`. let result = one.set(&mut store, Value::F32(42.0)); - assert_eq!( - result.expect_err("Expected an error").message(), - "Attempted to set an immutable global" - ); + // The global is immutable + assert!(result.is_err()); + // assert_eq!( + // result.expect_err("Expected an error").message(), + // "Attempted to set an immutable global" + // ); let one_result = one.get(&mut store); println!("`one` value after `set`: {:?}", one_result); diff --git a/examples/exports_memory.rs b/examples/exports_memory.rs index 8cb29e2e6..3990efca3 100644 --- a/examples/exports_memory.rs +++ b/examples/exports_memory.rs @@ -12,7 +12,6 @@ //! Ready? use wasmer::{imports, wat2wasm, Instance, Module, Store, TypedFunction, WasmPtr}; -use wasmer_compiler_cranelift::Cranelift; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -33,10 +32,7 @@ fn main() -> Result<(), Box> { )?; // Create a Store. - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/hello_world.rs b/examples/hello_world.rs index 35a10f4b2..83d16ff6f 100644 --- a/examples/hello_world.rs +++ b/examples/hello_world.rs @@ -7,7 +7,6 @@ //! ``` use wasmer::{imports, wat2wasm, Function, Instance, Module, Store, TypedFunction}; -use wasmer_compiler_cranelift::Cranelift; fn main() -> anyhow::Result<()> { // First we create a simple Wasm program to use with Wasmer. @@ -34,16 +33,8 @@ fn main() -> anyhow::Result<()> { "#, )?; - // Next we create the `Store`, the top level type in the Wasmer API. - // - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - // - // 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 - // the store and are now ready to compile and run WebAssembly! - let mut store = Store::new(Cranelift::default()); + // Create a Store. + let mut store = Store::default(); // 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. diff --git a/examples/imports_exports.rs b/examples/imports_exports.rs index 193fae479..bb430b15c 100644 --- a/examples/imports_exports.rs +++ b/examples/imports_exports.rs @@ -19,7 +19,6 @@ use wasmer::{ imports, wat2wasm, Function, FunctionType, Global, Instance, Memory, Module, Store, Table, Type, Value, }; -use wasmer_compiler_cranelift::Cranelift; fn main() -> Result<(), Box> { // Let's declare the Wasm module. @@ -40,10 +39,7 @@ fn main() -> Result<(), Box> { )?; // Create a Store. - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/imports_function.rs b/examples/imports_function.rs index 61612b21f..b8eff999a 100644 --- a/examples/imports_function.rs +++ b/examples/imports_function.rs @@ -21,7 +21,6 @@ use wasmer::{ imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, FunctionType, Instance, Module, Store, Type, TypedFunction, Value, }; -use wasmer_compiler_cranelift::Cranelift; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -41,10 +40,8 @@ fn main() -> Result<(), Box> { )?; // Create a Store. - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); + struct MyEnv; let env = FunctionEnv::new(&mut store, MyEnv {}); diff --git a/examples/imports_function_env.rs b/examples/imports_function_env.rs index 0b235f93f..fa0f338dd 100644 --- a/examples/imports_function_env.rs +++ b/examples/imports_function_env.rs @@ -24,7 +24,6 @@ use wasmer::{ imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Instance, Module, Store, TypedFunction, }; -use wasmer_compiler_cranelift::Cranelift; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -48,10 +47,7 @@ fn main() -> Result<(), Box> { )?; // Create a Store. - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/imports_function_env_global.rs b/examples/imports_function_env_global.rs index 6102905fe..46126f98b 100644 --- a/examples/imports_function_env_global.rs +++ b/examples/imports_function_env_global.rs @@ -25,7 +25,6 @@ use wasmer::{ imports, wat2wasm, Function, FunctionEnv, FunctionEnvMut, Global, Instance, Module, Store, TypedFunction, Value, }; -use wasmer_compiler_cranelift::Cranelift; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -50,10 +49,7 @@ fn main() -> Result<(), Box> { )?; // Create a Store. - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/imports_global.rs b/examples/imports_global.rs index 44a2946c9..7080f6b22 100644 --- a/examples/imports_global.rs +++ b/examples/imports_global.rs @@ -16,7 +16,6 @@ //! Ready? use wasmer::{imports, wat2wasm, Global, Instance, Module, Store, TypedFunction, Value}; -use wasmer_compiler_cranelift::Cranelift; fn main() -> Result<(), Box> { // Let's declare the Wasm module with the text representation. @@ -34,10 +33,7 @@ fn main() -> Result<(), Box> { )?; // Create a Store. - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module. @@ -88,10 +84,7 @@ fn main() -> Result<(), Box> { // Trying to set the value of a immutable global (`const`) // will result in a `RuntimeError`. let result = some.set(&mut store, Value::F32(42.0)); - assert_eq!( - result.expect_err("Expected an error").message(), - "Attempted to set an immutable global" - ); + assert!(result.is_err()); other.set(&mut store, Value::F32(21.0))?; let other_result = other.get(&mut store); diff --git a/examples/instance.rs b/examples/instance.rs index fa57d2dc6..35cc70748 100644 --- a/examples/instance.rs +++ b/examples/instance.rs @@ -15,7 +15,6 @@ //! Ready? use wasmer::{imports, wat2wasm, Instance, Module, Store, TypedFunction}; -use wasmer_compiler_cranelift::Cranelift; fn main() -> Result<(), Box> { // Let's declare the Wasm module. @@ -38,7 +37,7 @@ fn main() -> Result<(), Box> { // Note that we don't need to specify the engine/compiler if we want to use // the default provided by Wasmer. // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/memory.rs b/examples/memory.rs index 52528e3dc..15ed18cc9 100644 --- a/examples/memory.rs +++ b/examples/memory.rs @@ -16,7 +16,6 @@ use std::mem; use wasmer::{imports, wat2wasm, Bytes, Instance, Module, Pages, Store, TypedFunction}; -use wasmer_compiler_cranelift::Cranelift; // this example is a work in progress: // TODO: clean it up and comment it https://github.com/wasmerio/wasmer/issues/1749 @@ -53,10 +52,7 @@ fn main() -> anyhow::Result<()> { )?; // Create a Store. - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/table.rs b/examples/table.rs index 65dc3f4f4..cd7408369 100644 --- a/examples/table.rs +++ b/examples/table.rs @@ -1,7 +1,6 @@ use wasmer::{ imports, wat2wasm, Function, Instance, Module, Store, TableType, Type, TypedFunction, Value, }; -use wasmer_compiler_cranelift::Cranelift; /// A function we'll call through a table. fn host_callback(arg1: i32, arg2: i32) -> i32 { @@ -49,8 +48,8 @@ fn main() -> anyhow::Result<()> { .as_bytes(), )?; - // We set up our store with an engine and a compiler. - let mut store = Store::new(Cranelift::default()); + // Create a Store. + let mut store = Store::default(); // Then compile our Wasm. let module = Module::new(&store, wasm_bytes)?; let import_object = imports! {}; diff --git a/examples/wasi.rs b/examples/wasi.rs index 15c537a94..46d1114e5 100644 --- a/examples/wasi.rs +++ b/examples/wasi.rs @@ -17,7 +17,6 @@ use std::io::Read; use wasmer::{Module, Store}; -use wasmer_compiler_cranelift::Cranelift; use wasmer_wasi::{Pipe, WasiEnv}; fn main() -> Result<(), Box> { @@ -29,10 +28,7 @@ fn main() -> Result<(), Box> { let wasm_bytes = std::fs::read(wasm_path)?; // Create a Store. - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/wasi_manual_setup.rs b/examples/wasi_manual_setup.rs index 60a1f95b2..4d5ab6724 100644 --- a/examples/wasi_manual_setup.rs +++ b/examples/wasi_manual_setup.rs @@ -16,7 +16,6 @@ //! Ready? use wasmer::{Instance, Module, Store}; -use wasmer_compiler_cranelift::Cranelift; use wasmer_wasi::WasiEnv; fn main() -> Result<(), Box> { @@ -28,10 +27,7 @@ fn main() -> Result<(), Box> { let wasm_bytes = std::fs::read(wasm_path)?; // Create a Store. - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module. diff --git a/examples/wasi_pipes.rs b/examples/wasi_pipes.rs index ff10933ae..0f1442acb 100644 --- a/examples/wasi_pipes.rs +++ b/examples/wasi_pipes.rs @@ -13,7 +13,6 @@ use std::io::{Read, Write}; use wasmer::{Module, Store}; -use wasmer_compiler_cranelift::Cranelift; use wasmer_wasi::{Pipe, WasiEnv}; fn main() -> Result<(), Box> { @@ -25,10 +24,7 @@ fn main() -> Result<(), Box> { let wasm_bytes = std::fs::read(wasm_path)?; // Create a Store. - // Note that we don't need to specify the engine/compiler if we want to use - // the default provided by Wasmer. - // You can use `Store::default()` for that. - let mut store = Store::new(Cranelift::default()); + let mut store = Store::default(); println!("Compiling module..."); // Let's compile the Wasm module.