Merge remote-tracking branch 'origin/feature/singlepass-aarch64' into feature/singlepass-aarch64

This commit is contained in:
losfair 2019-11-22 23:39:07 +08:00
commit 80fb5b4da8
18 changed files with 106 additions and 290 deletions

View File

@ -4,6 +4,7 @@
- [#713](https://github.com/wasmerio/wasmer/pull/713) Add AArch64 support for singlepass.
- [#995](https://github.com/wasmerio/wasmer/pull/995) Detect when a global is read without being initialized (emit a proper error instead of panicking)
- [#996](https://github.com/wasmerio/wasmer/pull/997) Refactored spectests, emtests and wasitests to use default compiler logic
- [#992](https://github.com/wasmerio/wasmer/pull/992) Updates WAPM version to 0.4.1, fix arguments issue introduced in #990
- [#990](https://github.com/wasmerio/wasmer/pull/990) Default wasmer CLI to `run`. Wasmer will now attempt to parse unrecognized command line options as if they were applied to the run command: `wasmer mywasm.wasm --dir=.` now works!
- [#987](https://github.com/wasmerio/wasmer/pull/987) Fix `runtime-c-api` header files when compiled by gnuc.

5
Cargo.lock generated
View File

@ -1431,7 +1431,7 @@ dependencies = [
"wasmer-dev-utils 0.10.2",
"wasmer-emscripten 0.10.2",
"wasmer-llvm-backend 0.10.2",
"wasmer-runtime-core 0.10.2",
"wasmer-runtime 0.10.2",
"wasmer-singlepass-backend 0.10.2",
]
@ -1569,7 +1569,7 @@ dependencies = [
"wabt 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.10.2",
"wasmer-llvm-backend 0.10.2",
"wasmer-runtime-core 0.10.2",
"wasmer-runtime 0.10.2",
"wasmer-singlepass-backend 0.10.2",
]
@ -1599,7 +1599,6 @@ dependencies = [
"wasmer-dev-utils 0.10.2",
"wasmer-llvm-backend 0.10.2",
"wasmer-runtime 0.10.2",
"wasmer-runtime-core 0.10.2",
"wasmer-singlepass-backend 0.10.2",
"wasmer-wasi 0.10.2",
]

View File

@ -77,6 +77,7 @@ default = ["fast-tests", "wasi"]
"loader-kernel" = ["wasmer-kernel-loader"]
debug = ["wasmer-runtime-core/debug"]
trace = ["wasmer-runtime-core/trace"]
docs = ["wasmer-runtime/docs"]
extra-debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
# This feature will allow cargo test to run much faster
fast-tests = []
@ -85,21 +86,18 @@ backend-cranelift = [
"wasmer-runtime-core/backend-cranelift",
"wasmer-runtime/cranelift",
"wasmer-middleware-common-tests/clif",
"wasmer-wasi-tests/clif"
]
backend-llvm = [
"wasmer-llvm-backend",
"wasmer-runtime-core/backend-llvm",
"wasmer-runtime/llvm",
"wasmer-middleware-common-tests/llvm",
"wasmer-wasi-tests/llvm"
]
backend-singlepass = [
"wasmer-singlepass-backend",
"wasmer-runtime-core/backend-singlepass",
"wasmer-runtime/singlepass",
"wasmer-middleware-common-tests/singlepass",
"wasmer-wasi-tests/singlepass"
]
wasi = ["wasmer-wasi"]
managed = ["backend-singlepass", "wasmer-runtime-core/managed"]

View File

@ -220,7 +220,7 @@ check: check-bench
# Release
release:
cargo build --release --features backend-cranelift,backend-singlepass,backend-llvm,loader-kernel
cargo build --release --features backend-singlepass,backend-cranelift,backend-llvm,loader-kernel
# Only one backend (cranelift)
release-clif:
@ -265,7 +265,7 @@ dep-graph:
cargo deps --optional-deps --filter wasmer-wasi wasmer-wasi-tests wasmer-kernel-loader wasmer-dev-utils wasmer-llvm-backend wasmer-emscripten wasmer-emscripten-tests wasmer-runtime-core wasmer-runtime wasmer-middleware-common wasmer-middleware-common-tests wasmer-singlepass-backend wasmer-clif-backend wasmer --manifest-path Cargo.toml | dot -Tpng > wasmer_depgraph.png
docs:
cargo doc --features=backend-singlepass,backend-llvm,wasi,managed
cargo doc --features=backend-singlepass,backend-cranelift,backend-llvm,docs,wasi,managed
wapm:
cargo build --release --manifest-path wapm-cli/Cargo.toml --features "telemetry update-notifications"

View File

@ -235,7 +235,7 @@ Each integration can be tested separately:
* Spec tests: `make spectests`
* Emscripten: `make emtests`
* WASI: `make wasi`
* WASI: `make wasitests`
* Middleware: `make middleware`
* C API: `make capi`

View File

@ -10,8 +10,8 @@ build = "build/mod.rs"
[dependencies]
wasmer-emscripten = { path = "../emscripten", version = "0.10.2" }
wasmer-runtime-core = { path = "../runtime-core", version = "0.10.2" }
wasmer-clif-backend = { path = "../clif-backend", version = "0.10.2" }
wasmer-runtime = { path = "../runtime", version = "0.10.2", default-features = false }
wasmer-clif-backend = { path = "../clif-backend", version = "0.10.2", optional = true}
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.10.2", optional = true }
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.10.2", optional = true }
@ -23,6 +23,6 @@ wasmer-dev-utils = { path = "../dev-utils", version = "0.10.2"}
glob = "0.3"
[features]
clif = []
llvm = ["wasmer-llvm-backend"]
singlepass = ["wasmer-singlepass-backend"]
clif = ["wasmer-clif-backend", "wasmer-runtime/default-backend-cranelift"]
singlepass = ["wasmer-singlepass-backend", "wasmer-runtime/default-backend-singlepass"]
llvm = ["wasmer-llvm-backend", "wasmer-runtime/default-backend-llvm"]

View File

@ -3,40 +3,13 @@ mod tests {
use std::sync::Arc;
use wabt::wat2wasm;
use wasmer_emscripten::is_emscripten_module;
use wasmer_runtime_core::backend::Compiler;
use wasmer_runtime_core::compile_with;
#[cfg(feature = "clif")]
fn get_compiler() -> impl Compiler {
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
#[cfg(feature = "llvm")]
fn get_compiler() -> impl Compiler {
use wasmer_llvm_backend::LLVMCompiler;
LLVMCompiler::new()
}
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
use wasmer_runtime::compile;
#[test]
fn should_detect_emscripten_files() {
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_true.wast");
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
let module =
compile_with(&wasm_binary[..], &get_compiler()).expect("WASM can't be compiled");
let module = compile(&wasm_binary[..]).expect("WASM can't be compiled");
let module = Arc::new(module);
assert!(is_emscripten_module(&module));
}
@ -45,8 +18,7 @@ mod tests {
fn should_detect_non_emscripten_files() {
const WAST_BYTES: &[u8] = include_bytes!("tests/is_emscripten_false.wast");
let wasm_binary = wat2wasm(WAST_BYTES.to_vec()).expect("Can't convert to wasm");
let module =
compile_with(&wasm_binary[..], &get_compiler()).expect("WASM can't be compiled");
let module = compile(&wasm_binary[..]).expect("WASM can't be compiled");
let module = Arc::new(module);
assert!(!is_emscripten_module(&module));
}

View File

@ -5,39 +5,12 @@ macro_rules! assert_emscripten_output {
EmscriptenGlobals,
generate_emscripten_env,
};
use wasmer_runtime_core::{
backend::Compiler,
};
use wasmer_runtime::compile;
use wasmer_dev_utils::stdio::StdioCapturer;
#[cfg(feature = "clif")]
fn get_compiler() -> impl Compiler {
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
#[cfg(feature = "llvm")]
fn get_compiler() -> impl Compiler {
use wasmer_llvm_backend::LLVMCompiler;
LLVMCompiler::new()
}
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
let wasm_bytes = include_bytes!($file);
let module = wasmer_runtime_core::compile_with(&wasm_bytes[..], &get_compiler())
let module = compile(&wasm_bytes[..])
.expect("WASM can't be compiled");
// let module = compile(&wasm_bytes[..])

View File

@ -35,6 +35,7 @@ optional = true
[features]
default = ["cranelift", "default-backend-cranelift"]
docs = []
cranelift = ["wasmer-clif-backend"]
cache = ["cranelift"]
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]

View File

@ -87,11 +87,11 @@
//! [`wasmer-clif-backend`]: https://crates.io/crates/wasmer-clif-backend
//! [`compile_with`]: fn.compile_with.html
pub use wasmer_runtime_core::backend::Backend;
pub use wasmer_runtime_core::backend::{Backend, Features};
pub use wasmer_runtime_core::codegen::{MiddlewareChain, StreamingCompiler};
pub use wasmer_runtime_core::export::Export;
pub use wasmer_runtime_core::global::Global;
pub use wasmer_runtime_core::import::ImportObject;
pub use wasmer_runtime_core::import::{ImportObject, LikeNamespace};
pub use wasmer_runtime_core::instance::{DynFunc, Instance};
pub use wasmer_runtime_core::memory::ptr::{Array, Item, WasmPtr};
pub use wasmer_runtime_core::memory::Memory;
@ -131,9 +131,14 @@ pub mod units {
pub use wasmer_runtime_core::units::{Bytes, Pages};
}
pub mod types {
//! Various types.
pub use wasmer_runtime_core::types::*;
}
pub mod cache;
use wasmer_runtime_core::backend::{Compiler, CompilerConfig};
pub use wasmer_runtime_core::backend::{Compiler, CompilerConfig};
/// Compile WebAssembly binary code into a [`Module`].
/// This function is useful if it is necessary to
@ -203,12 +208,14 @@ pub fn default_compiler() -> impl Compiler {
#[cfg(any(
all(
feature = "default-backend-llvm",
not(feature = "docs"),
any(
feature = "default-backend-cranelift",
feature = "default-backend-singlepass"
)
),
all(
not(feature = "docs"),
feature = "default-backend-cranelift",
feature = "default-backend-singlepass"
)
@ -217,13 +224,13 @@ pub fn default_compiler() -> impl Compiler {
"The `default-backend-X` features are mutually exclusive. Please choose just one"
);
#[cfg(feature = "default-backend-llvm")]
#[cfg(all(feature = "default-backend-llvm", not(feature = "docs")))]
use wasmer_llvm_backend::LLVMCompiler as DefaultCompiler;
#[cfg(feature = "default-backend-singlepass")]
#[cfg(all(feature = "default-backend-singlepass", not(feature = "docs")))]
use wasmer_singlepass_backend::SinglePassCompiler as DefaultCompiler;
#[cfg(feature = "default-backend-cranelift")]
#[cfg(any(feature = "default-backend-cranelift", feature = "docs"))]
use wasmer_clif_backend::CraneliftCompiler as DefaultCompiler;
DefaultCompiler::new()

View File

@ -9,8 +9,8 @@ edition = "2018"
[dependencies]
glob = "0.3"
wasmer-runtime-core = { path = "../runtime-core", version = "0.10.2" }
wasmer-clif-backend = { path = "../clif-backend", version = "0.10.2" }
wasmer-runtime = { path = "../runtime", version = "0.10.2", default-features = false}
wasmer-clif-backend = { path = "../clif-backend", version = "0.10.2", optional = true}
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.10.2", optional = true }
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.10.2", optional = true }
@ -23,6 +23,6 @@ wabt = "0.9.1"
[features]
default = ["fast-tests"]
fast-tests = []
clif = []
llvm = ["wasmer-llvm-backend"]
singlepass = ["wasmer-singlepass-backend"]
clif = ["wasmer-clif-backend", "wasmer-runtime/default-backend-cranelift"]
singlepass = ["wasmer-singlepass-backend", "wasmer-runtime/default-backend-singlepass"]
llvm = ["wasmer-llvm-backend", "wasmer-runtime/default-backend-llvm"]

View File

@ -1,46 +1,17 @@
use wabt::wat2wasm;
use wasmer_runtime_core::{
backend::Compiler,
error,
global::Global,
memory::Memory,
prelude::*,
table::Table,
use wasmer_runtime::{
compile, error, func, imports,
types::{ElementType, MemoryDescriptor, TableDescriptor, Value},
units::Pages,
Ctx, Global, Memory, Table,
};
#[cfg(feature = "clif")]
fn get_compiler() -> impl Compiler {
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
#[cfg(feature = "llvm")]
fn get_compiler() -> impl Compiler {
use wasmer_llvm_backend::LLVMCompiler;
LLVMCompiler::new()
}
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
static EXAMPLE_WASM: &'static [u8] = include_bytes!("simple.wasm");
fn main() -> error::Result<()> {
let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed");
let inner_module = wasmer_runtime_core::compile_with(&wasm_binary, &get_compiler())?;
let inner_module = compile(&wasm_binary)?;
let memory_desc = MemoryDescriptor::new(Pages(1), Some(Pages(1)), false).unwrap();
let memory = Memory::new(memory_desc).unwrap();
@ -71,7 +42,7 @@ fn main() -> error::Result<()> {
"env" => inner_instance,
};
let outer_module = wasmer_runtime_core::compile_with(EXAMPLE_WASM, &get_compiler())?;
let outer_module = compile(EXAMPLE_WASM)?;
let outer_instance = outer_module.instantiate(&outer_imports)?;
let ret = outer_instance.call("main", &[Value::I32(42)])?;
println!("ret: {:?}", ret);
@ -79,7 +50,7 @@ fn main() -> error::Result<()> {
Ok(())
}
fn print_num(ctx: &mut vm::Ctx, n: i32) -> Result<i32, ()> {
fn print_num(ctx: &mut Ctx, n: i32) -> Result<i32, ()> {
println!("print_num({})", n);
let memory: &Memory = ctx.memory(0);

View File

@ -1,5 +1,5 @@
use wabt::wat2wasm;
use wasmer_runtime_core::{backend::Compiler, import::ImportObject, Instance};
use wasmer_runtime::{compile, ImportObject, Instance};
fn main() {
let instance = create_module_1();
@ -23,38 +23,12 @@ fn create_module_1() -> Instance {
(elem (;1;) (i32.const 9) 1))
"#;
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &get_compiler())
.expect("WASM can't be compiled");
let module = compile(&wasm_binary[..]).expect("WASM can't be compiled");
module
.instantiate(&generate_imports())
.expect("WASM can't be instantiated")
}
#[cfg(feature = "clif")]
fn get_compiler() -> impl Compiler {
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
#[cfg(feature = "llvm")]
fn get_compiler() -> impl Compiler {
use wasmer_llvm_backend::LLVMCompiler;
LLVMCompiler::new()
}
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
static IMPORT_MODULE: &str = r#"
(module
(type $t0 (func (param i32)))
@ -68,8 +42,7 @@ static IMPORT_MODULE: &str = r#"
pub fn generate_imports() -> ImportObject {
let wasm_binary = wat2wasm(IMPORT_MODULE.as_bytes()).expect("WAST not valid or malformed");
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &get_compiler())
.expect("WASM can't be compiled");
let module = compile(&wasm_binary[..]).expect("WASM can't be compiled");
let instance = module
.instantiate(&ImportObject::new())
.expect("WASM can't be instantiated");

View File

@ -1,10 +1,9 @@
#[cfg(test)]
mod tests {
use wabt::wat2wasm;
use wasmer_clif_backend::CraneliftCompiler;
use wasmer_runtime_core::{
use wasmer_runtime::{
error::{CallError, RuntimeError},
import::ImportObject,
ImportObject,
};
// The semantics of stack overflow are documented at:
@ -22,8 +21,7 @@ mod tests {
(elem (;0;) (i32.const 0) 0))
"#;
let wasm_binary = wat2wasm(module_str.as_bytes()).expect("WAST not valid or malformed");
let module = wasmer_runtime_core::compile_with(&wasm_binary[..], &CraneliftCompiler::new())
.expect("WASM can't be compiled");
let module = wasmer_runtime::compile(&wasm_binary[..]).expect("WASM can't be compiled");
let instance = module
.instantiate(&ImportObject::new())
.expect("WASM can't be instantiated");

View File

@ -63,31 +63,6 @@ mod tests {
}
}
#[cfg(feature = "clif")]
fn get_compiler() -> impl Compiler {
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
#[cfg(feature = "llvm")]
fn get_compiler() -> impl Compiler {
use wasmer_llvm_backend::LLVMCompiler;
LLVMCompiler::new()
}
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
panic!("compiler not specified, activate a compiler via features");
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
#[cfg(feature = "clif")]
fn get_compiler_name() -> &'static str {
"clif"
@ -241,20 +216,15 @@ mod tests {
use std::panic::AssertUnwindSafe;
use std::path::PathBuf;
use wabt::script::{Action, Command, CommandKind, ScriptParser, Value};
use wasmer_runtime_core::backend::{Compiler, CompilerConfig, Features};
use wasmer_runtime_core::error::CompileError;
use wasmer_runtime_core::import::ImportObject;
use wasmer_runtime_core::Instance;
use wasmer_runtime_core::{
export::Export,
global::Global,
import::LikeNamespace,
memory::Memory,
table::Table,
use wasmer_runtime::{
compile_with_config,
error::CompileError,
func, imports,
types::{ElementType, MemoryDescriptor, TableDescriptor},
units::Pages,
CompilerConfig, Ctx, Export, Features, Global, ImportObject, Instance, LikeNamespace,
Memory, Table,
};
use wasmer_runtime_core::{func, imports, vm::Ctx};
fn parse_and_run(
path: &PathBuf,
@ -328,12 +298,8 @@ mod tests {
},
..Default::default()
};
let module = wasmer_runtime_core::compile_with_config(
&module.into_vec(),
&get_compiler(),
config,
)
.expect("WASM can't be compiled");
let module = compile_with_config(&module.into_vec(), config)
.expect("WASM can't be compiled");
let i = module
.instantiate(&spectest_import_object)
.expect("WASM can't be instantiated");
@ -375,7 +341,7 @@ mod tests {
&named_modules,
&module,
|instance| {
let params: Vec<wasmer_runtime_core::types::Value> =
let params: Vec<wasmer_runtime::types::Value> =
args.iter().cloned().map(convert_value).collect();
instance.call(&field, &params[..])
},
@ -507,7 +473,7 @@ mod tests {
} => {
let maybe_call_result =
with_instance(instance.clone(), &named_modules, &module, |instance| {
let params: Vec<wasmer_runtime_core::types::Value> =
let params: Vec<wasmer_runtime::types::Value> =
args.iter().cloned().map(convert_value).collect();
instance.call(&field, &params[..])
});
@ -578,7 +544,7 @@ mod tests {
} => {
let maybe_call_result =
with_instance(instance.clone(), &named_modules, &module, |instance| {
let params: Vec<wasmer_runtime_core::types::Value> =
let params: Vec<wasmer_runtime::types::Value> =
args.iter().cloned().map(convert_value).collect();
instance.call(&field, &params[..])
});
@ -649,7 +615,7 @@ mod tests {
} => {
let maybe_call_result =
with_instance(instance.clone(), &named_modules, &module, |instance| {
let params: Vec<wasmer_runtime_core::types::Value> =
let params: Vec<wasmer_runtime::types::Value> =
args.iter().cloned().map(convert_value).collect();
instance.call(&field, &params[..])
});
@ -667,7 +633,7 @@ mod tests {
);
} else {
let call_result = maybe_call_result.unwrap();
use wasmer_runtime_core::error::{CallError, RuntimeError};
use wasmer_runtime::error::{CallError, RuntimeError};
match call_result {
Err(e) => {
match e {
@ -738,11 +704,7 @@ mod tests {
},
..Default::default()
};
wasmer_runtime_core::compile_with_config(
&module.into_vec(),
&get_compiler(),
config,
)
compile_with_config(&module.into_vec(), config)
});
match result {
Ok(module) => {
@ -794,11 +756,7 @@ mod tests {
},
..Default::default()
};
wasmer_runtime_core::compile_with_config(
&module.into_vec(),
&get_compiler(),
config,
)
compile_with_config(&module.into_vec(), config)
});
match result {
@ -849,12 +807,8 @@ mod tests {
},
..Default::default()
};
let module = wasmer_runtime_core::compile_with_config(
&module.into_vec(),
&get_compiler(),
config,
)
.expect("WASM can't be compiled");
let module = compile_with_config(&module.into_vec(), config)
.expect("WASM can't be compiled");
let result = panic::catch_unwind(AssertUnwindSafe(|| {
module
.instantiate(&spectest_import_object)
@ -891,7 +845,7 @@ mod tests {
&named_modules,
&module,
|instance| {
let params: Vec<wasmer_runtime_core::types::Value> =
let params: Vec<wasmer_runtime::types::Value> =
args.iter().cloned().map(convert_value).collect();
instance.call(&field, &params[..])
},
@ -948,12 +902,8 @@ mod tests {
},
..Default::default()
};
let module = wasmer_runtime_core::compile_with_config(
&module.into_vec(),
&get_compiler(),
config,
)
.expect("WASM can't be compiled");
let module = compile_with_config(&module.into_vec(), config)
.expect("WASM can't be compiled");
module.instantiate(&spectest_import_object)
}));
match result {
@ -987,7 +937,7 @@ mod tests {
);
}
Err(e) => match e {
wasmer_runtime_core::error::Error::LinkError(_) => {
wasmer_runtime::error::Error::LinkError(_) => {
test_report.count_passed();
}
_ => {
@ -1046,7 +996,7 @@ mod tests {
} => {
let maybe_call_result =
with_instance(instance.clone(), &named_modules, &module, |instance| {
let params: Vec<wasmer_runtime_core::types::Value> =
let params: Vec<wasmer_runtime::types::Value> =
args.iter().cloned().map(convert_value).collect();
instance.call(&field, &params[..])
});
@ -1094,29 +1044,29 @@ mod tests {
Ok(test_report)
}
fn is_canonical_nan(val: wasmer_runtime_core::types::Value) -> bool {
fn is_canonical_nan(val: wasmer_runtime::types::Value) -> bool {
match val {
wasmer_runtime_core::types::Value::F32(x) => x.is_canonical_nan(),
wasmer_runtime_core::types::Value::F64(x) => x.is_canonical_nan(),
wasmer_runtime::types::Value::F32(x) => x.is_canonical_nan(),
wasmer_runtime::types::Value::F64(x) => x.is_canonical_nan(),
_ => panic!("value is not a float {:?}", val),
}
}
fn is_arithmetic_nan(val: wasmer_runtime_core::types::Value) -> bool {
fn is_arithmetic_nan(val: wasmer_runtime::types::Value) -> bool {
match val {
wasmer_runtime_core::types::Value::F32(x) => x.is_quiet_nan(),
wasmer_runtime_core::types::Value::F64(x) => x.is_quiet_nan(),
wasmer_runtime::types::Value::F32(x) => x.is_quiet_nan(),
wasmer_runtime::types::Value::F64(x) => x.is_quiet_nan(),
_ => panic!("value is not a float {:?}", val),
}
}
fn value_to_hex(val: wasmer_runtime_core::types::Value) -> String {
fn value_to_hex(val: wasmer_runtime::types::Value) -> String {
match val {
wasmer_runtime_core::types::Value::I32(x) => format!("{:#x}", x),
wasmer_runtime_core::types::Value::I64(x) => format!("{:#x}", x),
wasmer_runtime_core::types::Value::F32(x) => format!("{:#x}", x.to_bits()),
wasmer_runtime_core::types::Value::F64(x) => format!("{:#x}", x.to_bits()),
wasmer_runtime_core::types::Value::V128(x) => format!("{:#x}", x),
wasmer_runtime::types::Value::I32(x) => format!("{:#x}", x),
wasmer_runtime::types::Value::I64(x) => format!("{:#x}", x),
wasmer_runtime::types::Value::F32(x) => format!("{:#x}", x.to_bits()),
wasmer_runtime::types::Value::F64(x) => format!("{:#x}", x.to_bits()),
wasmer_runtime::types::Value::V128(x) => format!("{:#x}", x),
}
}
@ -1129,13 +1079,13 @@ mod tests {
V128(u128),
}
fn convert_wasmer_value(other: wasmer_runtime_core::types::Value) -> SpectestValue {
fn convert_wasmer_value(other: wasmer_runtime::types::Value) -> SpectestValue {
match other {
wasmer_runtime_core::types::Value::I32(v) => SpectestValue::I32(v),
wasmer_runtime_core::types::Value::I64(v) => SpectestValue::I64(v),
wasmer_runtime_core::types::Value::F32(v) => SpectestValue::F32(v.to_bits()),
wasmer_runtime_core::types::Value::F64(v) => SpectestValue::F64(v.to_bits()),
wasmer_runtime_core::types::Value::V128(v) => SpectestValue::V128(v),
wasmer_runtime::types::Value::I32(v) => SpectestValue::I32(v),
wasmer_runtime::types::Value::I64(v) => SpectestValue::I64(v),
wasmer_runtime::types::Value::F32(v) => SpectestValue::F32(v.to_bits()),
wasmer_runtime::types::Value::F64(v) => SpectestValue::F64(v.to_bits()),
wasmer_runtime::types::Value::V128(v) => SpectestValue::V128(v),
}
}
@ -1149,13 +1099,13 @@ mod tests {
}
}
fn convert_value(other: Value<f32, f64>) -> wasmer_runtime_core::types::Value {
fn convert_value(other: Value<f32, f64>) -> wasmer_runtime::types::Value {
match other {
Value::I32(v) => wasmer_runtime_core::types::Value::I32(v),
Value::I64(v) => wasmer_runtime_core::types::Value::I64(v),
Value::F32(v) => wasmer_runtime_core::types::Value::F32(v),
Value::F64(v) => wasmer_runtime_core::types::Value::F64(v),
Value::V128(v) => wasmer_runtime_core::types::Value::V128(v),
Value::I32(v) => wasmer_runtime::types::Value::I32(v),
Value::I64(v) => wasmer_runtime::types::Value::I64(v),
Value::F32(v) => wasmer_runtime::types::Value::F32(v),
Value::F64(v) => wasmer_runtime::types::Value::F64(v),
Value::V128(v) => wasmer_runtime::types::Value::V128(v),
}
}
@ -1199,9 +1149,9 @@ mod tests {
let memory_desc = MemoryDescriptor::new(Pages(1), Some(Pages(2)), false).unwrap();
let memory = Memory::new(memory_desc).unwrap();
let global_i32 = Global::new(wasmer_runtime_core::types::Value::I32(666));
let global_f32 = Global::new(wasmer_runtime_core::types::Value::F32(666.0));
let global_f64 = Global::new(wasmer_runtime_core::types::Value::F64(666.0));
let global_i32 = Global::new(wasmer_runtime::types::Value::I32(666));
let global_f32 = Global::new(wasmer_runtime::types::Value::F32(666.0));
let global_f64 = Global::new(wasmer_runtime::types::Value::F64(666.0));
let table = Table::new(TableDescriptor {
element: ElementType::Anyfunc,

View File

@ -9,22 +9,21 @@ publish = false
build = "build/mod.rs"
[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.10.2" }
wasmer-runtime = { path = "../runtime", version = "0.10.2" }
# We set default features to false to be able to use the singlepass backend properly
wasmer-runtime = { path = "../runtime", version = "0.10.2", default-features = false }
wasmer-wasi = { path = "../wasi", version = "0.10.2" }
# hack to get tests to work
wasmer-clif-backend = { path = "../clif-backend", version = "0.10.2", optional = true}
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.10.2", optional = true }
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.10.2", optional = true }
[build-dependencies]
glob = "0.3"
[dev-dependencies]
wasmer-clif-backend = { path = "../clif-backend", version = "0.10.2" }
wasmer-dev-utils = { path = "../dev-utils", version = "0.10.2"}
[features]
clif = []
singlepass = ["wasmer-singlepass-backend"]
llvm = ["wasmer-llvm-backend"]
clif = ["wasmer-clif-backend", "wasmer-runtime/default-backend-cranelift"]
singlepass = ["wasmer-singlepass-backend", "wasmer-runtime/default-backend-singlepass"]
llvm = ["wasmer-llvm-backend", "wasmer-runtime/default-backend-llvm"]

View File

@ -1,6 +1,5 @@
#![cfg(test)]
use wasmer_runtime::{compile, Func};
use wasmer_runtime_core::vm::Ctx;
use wasmer_runtime::{compile, Ctx, Func};
use wasmer_wasi::{state::*, *};
use std::ffi::c_void;

View File

@ -1,37 +1,12 @@
macro_rules! assert_wasi_output {
($file:expr, $name:expr, $po_dir_args: expr, $mapdir_args:expr, $envvar_args:expr, $expected:expr) => {{
use wasmer_dev_utils::stdio::StdioCapturer;
use wasmer_runtime_core::{backend::Compiler, Func};
use wasmer_runtime::Func;
use wasmer_wasi::{generate_import_object_for_version, get_wasi_version};
#[cfg(feature = "clif")]
fn get_compiler() -> impl Compiler {
use wasmer_clif_backend::CraneliftCompiler;
CraneliftCompiler::new()
}
#[cfg(feature = "llvm")]
fn get_compiler() -> impl Compiler {
use wasmer_llvm_backend::LLVMCompiler;
LLVMCompiler::new()
}
#[cfg(feature = "singlepass")]
fn get_compiler() -> impl Compiler {
use wasmer_singlepass_backend::SinglePassCompiler;
SinglePassCompiler::new()
}
#[cfg(not(any(feature = "llvm", feature = "clif", feature = "singlepass")))]
fn get_compiler() -> impl Compiler {
compile_error!("compiler not specified, activate a compiler via features");
unreachable!();
}
let wasm_bytes = include_bytes!($file);
let module = wasmer_runtime_core::compile_with(&wasm_bytes[..], &get_compiler())
.expect("WASM can't be compiled");
let module = wasmer_runtime::compile(&wasm_bytes[..]).expect("WASM can't be compiled");
let wasi_version = get_wasi_version(&module).expect("WASI module");