mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-24 14:11:32 +00:00
Merge branch 'master' into feature/make-instance-send
This commit is contained in:
@ -7,6 +7,9 @@ Blocks of changes will separated by version increments.
|
||||
## **[Unreleased]**
|
||||
|
||||
- [#807](https://github.com/wasmerio/wasmer/pull/807) Implement Send for `Instance`, breaking change on `ImportObject`, remove method `get_namespace` replaced with `with_namespace` and `maybe_with_namespace`
|
||||
- [#817](https://github.com/wasmerio/wasmer/pull/817) Add document for tracking features across backends and language integrations, [docs/feature_matrix.md]
|
||||
- [#823](https://github.com/wasmerio/wasmer/issues/823) Improved Emscripten / WASI integration
|
||||
- [#821](https://github.com/wasmerio/wasmer/issues/821) Remove patch version on most deps Cargo manifests. This gives Wasmer library users more control over which versions of the deps they use.
|
||||
- [#820](https://github.com/wasmerio/wasmer/issues/820) Remove null-pointer checks in `WasmPtr` from runtime-core, re-add them in Emscripten
|
||||
- [#803](https://github.com/wasmerio/wasmer/issues/803) Add method to `Ctx` to invoke functions by their `TableIndex`
|
||||
- [#790](https://github.com/wasmerio/wasmer/pull/790) Fix flaky test failure with LLVM, switch to large code model.
|
||||
|
10
Cargo.toml
10
Cargo.toml
@ -19,9 +19,9 @@ include = [
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
byteorder = "1.3.2"
|
||||
errno = "0.2.4"
|
||||
structopt = "0.3.0"
|
||||
byteorder = "1.3"
|
||||
errno = "0.2"
|
||||
structopt = "0.3"
|
||||
wabt = "0.9.1"
|
||||
wasmer-clif-backend = { path = "lib/clif-backend" }
|
||||
wasmer-singlepass-backend = { path = "lib/singlepass-backend", optional = true }
|
||||
@ -63,8 +63,8 @@ members = [
|
||||
|
||||
[build-dependencies]
|
||||
wabt = "0.9.1"
|
||||
glob = "0.3.0"
|
||||
rustc_version = "0.2.3"
|
||||
glob = "0.3"
|
||||
rustc_version = "0.2"
|
||||
|
||||
[dev-dependencies]
|
||||
serde = { version = "1", features = ["derive"] } # used by the plugin example
|
||||
|
8
Makefile
8
Makefile
@ -2,10 +2,14 @@
|
||||
|
||||
# Generate files
|
||||
generate-spectests:
|
||||
WASMER_RUNTIME_GENERATE_SPECTESTS=1 cargo build -p wasmer-runtime-core --release
|
||||
WASMER_RUNTIME_GENERATE_SPECTESTS=1 cargo build -p wasmer-runtime-core --release \
|
||||
&& echo "formatting" \
|
||||
&& cargo fmt
|
||||
|
||||
generate-emtests:
|
||||
WASM_EMSCRIPTEN_GENERATE_EMTESTS=1 cargo build -p wasmer-emscripten-tests --release
|
||||
WASM_EMSCRIPTEN_GENERATE_EMTESTS=1 cargo build -p wasmer-emscripten-tests --release \
|
||||
&& echo "formatting" \
|
||||
&& cargo fmt
|
||||
|
||||
generate-wasitests: wasitests-setup
|
||||
WASM_WASI_GENERATE_WASITESTS=1 cargo build -p wasmer-wasi-tests --release -vv \
|
||||
|
26
docs/feature_matrix.md
Normal file
26
docs/feature_matrix.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Feature Table
|
||||
|
||||
## Compiler Backend
|
||||
|
||||
| | Singlepass | Cranelift | LLVM |
|
||||
| - | - | - | - |
|
||||
| Caching | ❌ | ✅ | ✅ |
|
||||
| Emscripten | ✅ | ✅ | ✅ |
|
||||
| Metering | ✅ | ❌ | ✅ |
|
||||
| Multi-value return | ❌ | ❌ | ❌ |
|
||||
| OSR | 🚧 | ❓ | ❓ |
|
||||
| SIMD | ❌ | ❌ | ✅ |
|
||||
| WASI | ✅ | ✅ | ✅ |
|
||||
|
||||
|
||||
## Language integration
|
||||
|
||||
TODO: define a set of features that are relevant and mark them here
|
||||
|
||||
Current ideas:
|
||||
|
||||
- WASI FS API
|
||||
- Callbacks
|
||||
- Exiting early in hostcall
|
||||
- Metering
|
||||
- Caching
|
@ -15,26 +15,26 @@ cranelift-codegen = { version = "0.31" }
|
||||
cranelift-entity = { version = "0.31" }
|
||||
cranelift-frontend = { package = "wasmer-clif-fork-frontend", version = "0.33" }
|
||||
cranelift-wasm = { package = "wasmer-clif-fork-wasm", version = "0.33" }
|
||||
target-lexicon = "0.4.0"
|
||||
target-lexicon = "0.4"
|
||||
wasmparser = "0.35.1"
|
||||
byteorder = "1.3.2"
|
||||
nix = "0.15.0"
|
||||
byteorder = "1.3"
|
||||
nix = "0.15"
|
||||
libc = "0.2.60"
|
||||
rayon = "1.1.0"
|
||||
rayon = "1.1"
|
||||
|
||||
# Dependencies for caching.
|
||||
[dependencies.serde]
|
||||
version = "1.0.99"
|
||||
version = "1.0"
|
||||
features = ["rc"]
|
||||
[dependencies.serde_derive]
|
||||
version = "1.0.98"
|
||||
version = "1.0"
|
||||
[dependencies.serde_bytes]
|
||||
version = "0.11.2"
|
||||
version = "0.11"
|
||||
[dependencies.serde-bench]
|
||||
version = "0.0.7"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3.8", features = ["errhandlingapi", "minwindef", "minwinbase", "winnt"] }
|
||||
winapi = { version = "0.3", features = ["errhandlingapi", "minwindef", "minwinbase", "winnt"] }
|
||||
wasmer-win-exception-handler = { path = "../win-exception-handler", version = "0.7.0" }
|
||||
|
||||
[features]
|
||||
|
@ -20,7 +20,7 @@ wabt = "0.9.1"
|
||||
wasmer-dev-utils = { path = "../dev-utils", version = "0.7.0"}
|
||||
|
||||
[build-dependencies]
|
||||
glob = "0.3.0"
|
||||
glob = "0.3"
|
||||
|
||||
[features]
|
||||
clif = []
|
||||
|
@ -8,14 +8,14 @@ repository = "https://github.com/wasmerio/wasmer"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
byteorder = "1.3.2"
|
||||
lazy_static = "1.4.0"
|
||||
byteorder = "1.3"
|
||||
lazy_static = "1.4"
|
||||
libc = "0.2.60"
|
||||
time = "0.1.42"
|
||||
time = "0.1"
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.7.0" }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
rand = "0.7.0"
|
||||
rand = "0.7"
|
||||
|
||||
[features]
|
||||
debug = ["wasmer-runtime-core/debug"]
|
||||
|
@ -735,8 +735,9 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
"___syscall345" => func!(crate::syscalls::___syscall345),
|
||||
|
||||
// Process
|
||||
"abort" => func!(crate::process::em_abort),
|
||||
"abort" => func!(crate::process::_abort),
|
||||
"_abort" => func!(crate::process::_abort),
|
||||
"_prctl" => func!(crate::process::_prctl),
|
||||
"abortStackOverflow" => func!(crate::process::abort_stack_overflow),
|
||||
"_llvm_trap" => func!(crate::process::_llvm_trap),
|
||||
"_fork" => func!(crate::process::_fork),
|
||||
@ -829,6 +830,9 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
||||
"_gmtime" => func!(crate::time::_gmtime),
|
||||
|
||||
// Math
|
||||
"sqrt" => func!(crate::math::sqrt),
|
||||
"floor" => func!(crate::math::floor),
|
||||
"fabs" => func!(crate::math::fabs),
|
||||
"f64-rem" => func!(crate::math::f64_rem),
|
||||
"_llvm_copysign_f32" => func!(crate::math::_llvm_copysign_f32),
|
||||
"_llvm_copysign_f64" => func!(crate::math::_llvm_copysign_f64),
|
||||
|
@ -88,6 +88,21 @@ pub fn log(_ctx: &mut Ctx, value: f64) -> f64 {
|
||||
value.ln()
|
||||
}
|
||||
|
||||
// emscripten: global.Math sqrt
|
||||
pub fn sqrt(_ctx: &mut Ctx, value: f64) -> f64 {
|
||||
value.sqrt()
|
||||
}
|
||||
|
||||
// emscripten: global.Math floor
|
||||
pub fn floor(_ctx: &mut Ctx, value: f64) -> f64 {
|
||||
value.floor()
|
||||
}
|
||||
|
||||
// emscripten: global.Math fabs
|
||||
pub fn fabs(_ctx: &mut Ctx, value: f64) -> f64 {
|
||||
value.abs()
|
||||
}
|
||||
|
||||
// emscripten: asm2wasm.f64-to-int
|
||||
pub fn f64_to_int(_ctx: &mut Ctx, value: f64) -> i32 {
|
||||
debug!("emscripten::f64_to_int {}", value);
|
||||
|
@ -1,11 +1,10 @@
|
||||
use libc::{abort, c_char, c_int, exit, EAGAIN};
|
||||
use libc::{abort, c_int, exit, EAGAIN};
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
type PidT = libc::pid_t;
|
||||
#[cfg(target_os = "windows")]
|
||||
type PidT = c_int;
|
||||
|
||||
use std::ffi::CStr;
|
||||
use wasmer_runtime_core::vm::Ctx;
|
||||
|
||||
pub fn abort_with_message(ctx: &mut Ctx, message: &str) {
|
||||
@ -21,6 +20,12 @@ pub fn _abort(_ctx: &mut Ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn _prctl(ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
|
||||
debug!("emscripten::_prctl");
|
||||
abort_with_message(ctx, "missing function: prctl");
|
||||
-1
|
||||
}
|
||||
|
||||
pub fn _fork(_ctx: &mut Ctx) -> PidT {
|
||||
debug!("emscripten::_fork");
|
||||
// unsafe {
|
||||
@ -45,18 +50,6 @@ pub fn _exit(_ctx: &mut Ctx, status: c_int) {
|
||||
unsafe { exit(status) }
|
||||
}
|
||||
|
||||
pub fn em_abort(ctx: &mut Ctx, message: u32) {
|
||||
debug!("emscripten::em_abort {}", message);
|
||||
let message_addr = emscripten_memory_pointer!(ctx.memory(0), message) as *mut c_char;
|
||||
unsafe {
|
||||
let message = CStr::from_ptr(message_addr)
|
||||
.to_str()
|
||||
.unwrap_or("Unexpected abort");
|
||||
|
||||
abort_with_message(ctx, message);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn _kill(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
|
||||
debug!("emscripten::_kill");
|
||||
-1
|
||||
|
@ -24,7 +24,9 @@ pub fn is_emscripten_module(module: &Module) -> bool {
|
||||
.namespace_table
|
||||
.get(import_name.namespace_index);
|
||||
let field = module.info().name_table.get(import_name.name_index);
|
||||
if (field == "_emscripten_memcpy_big" || field == "emscripten_memcpy_big")
|
||||
if (field == "_emscripten_memcpy_big"
|
||||
|| field == "emscripten_memcpy_big"
|
||||
|| field == "__map_file")
|
||||
&& namespace == "env"
|
||||
{
|
||||
return true;
|
||||
|
@ -8,10 +8,10 @@ readme = "README.md"
|
||||
[dependencies]
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.7.0" }
|
||||
wasmparser = "0.35.1"
|
||||
smallvec = "0.6.10"
|
||||
smallvec = "0.6"
|
||||
goblin = "0.0.24"
|
||||
libc = "0.2.60"
|
||||
capstone = { version = "0.6.0", optional = true }
|
||||
capstone = { version = "0.6", optional = true }
|
||||
byteorder = "1"
|
||||
|
||||
[dependencies.inkwell]
|
||||
@ -21,17 +21,17 @@ default-features = false
|
||||
features = ["llvm8-0", "target-x86"]
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
nix = "0.15.0"
|
||||
nix = "0.15"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3.8", features = ["memoryapi"] }
|
||||
winapi = { version = "0.3", features = ["memoryapi"] }
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
||||
lazy_static = "1.4.0"
|
||||
regex = "1.2.1"
|
||||
lazy_static = "1.4"
|
||||
regex = "1.2"
|
||||
semver = "0.9"
|
||||
rustc_version = "0.2.3"
|
||||
rustc_version = "0.2"
|
||||
|
||||
[dev-dependencies]
|
||||
wabt = "0.9.1"
|
||||
|
@ -32,4 +32,4 @@ llvm-backend = ["wasmer-runtime/llvm", "wasmer-runtime/default-backend-llvm"]
|
||||
singlepass-backend = ["wasmer-runtime/singlepass", "wasmer-runtime/default-backend-singlepass"]
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = "0.9.1"
|
||||
cbindgen = "0.9"
|
||||
|
@ -8,46 +8,46 @@ repository = "https://github.com/wasmerio/wasmer"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
nix = "0.15.0"
|
||||
page_size = "0.4.1"
|
||||
nix = "0.15"
|
||||
page_size = "0.4"
|
||||
wasmparser = "0.35.1"
|
||||
parking_lot = "0.9.0"
|
||||
lazy_static = "1.4.0"
|
||||
errno = "0.2.4"
|
||||
parking_lot = "0.9"
|
||||
lazy_static = "1.4"
|
||||
errno = "0.2"
|
||||
libc = "0.2.60"
|
||||
hex = "0.3.2"
|
||||
smallvec = "0.6.10"
|
||||
hex = "0.3"
|
||||
smallvec = "0.6"
|
||||
bincode = "1.1"
|
||||
|
||||
[dependencies.indexmap]
|
||||
version = "1.2.0"
|
||||
version = "1.2"
|
||||
features = ["serde-1"]
|
||||
|
||||
# Dependencies for caching.
|
||||
[dependencies.serde]
|
||||
version = "1.0.99"
|
||||
version = "1.0"
|
||||
# This feature is required for serde to support serializing/deserializing reference counted pointers (e.g. Rc and Arc).
|
||||
features = ["rc"]
|
||||
[dependencies.serde_derive]
|
||||
version = "1.0.98"
|
||||
version = "1.0"
|
||||
[dependencies.serde_bytes]
|
||||
version = "0.11.2"
|
||||
version = "0.11"
|
||||
[dependencies.serde-bench]
|
||||
version = "0.0.7"
|
||||
[dependencies.blake2b_simd]
|
||||
version = "0.5.8"
|
||||
version = "0.5"
|
||||
[dependencies.digest]
|
||||
version = "0.8.1"
|
||||
version = "0.8"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3.8", features = ["memoryapi"] }
|
||||
winapi = { version = "0.3", features = ["memoryapi"] }
|
||||
|
||||
[dev-dependencies]
|
||||
field-offset = "0.1.1"
|
||||
field-offset = "0.1"
|
||||
|
||||
[build-dependencies]
|
||||
blake2b_simd = "0.5.8"
|
||||
rustc_version = "0.2.3"
|
||||
blake2b_simd = "0.5"
|
||||
rustc_version = "0.2"
|
||||
cc = "1.0"
|
||||
|
||||
[features]
|
||||
|
@ -81,7 +81,7 @@ pushq %r8
|
||||
pushq %r9
|
||||
pushq %r10
|
||||
|
||||
callq get_boundary_register_preservation
|
||||
callq get_boundary_register_preservation@PLT
|
||||
|
||||
# Keep this consistent with BoundaryRegisterPreservation
|
||||
movq %r15, 0(%rax)
|
||||
|
@ -39,6 +39,10 @@ where
|
||||
self.elems.len()
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.elems.is_empty()
|
||||
}
|
||||
|
||||
pub fn push(&mut self, value: V) -> K {
|
||||
let len = self.len();
|
||||
self.elems.push(value);
|
||||
|
@ -10,8 +10,8 @@ readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.7.0", optional = true }
|
||||
lazy_static = "1.4.0"
|
||||
memmap = "0.7.0"
|
||||
lazy_static = "1.4"
|
||||
memmap = "0.7"
|
||||
|
||||
[dependencies.wasmer-runtime-core]
|
||||
path = "../runtime-core"
|
||||
@ -23,7 +23,7 @@ version = "0.7.0"
|
||||
optional = true
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3.1.0"
|
||||
tempfile = "3.1"
|
||||
criterion = "0.2"
|
||||
wabt = "0.9.1"
|
||||
|
||||
|
@ -13,8 +13,8 @@ wasmer-runtime-core = { path = "../runtime-core", version = "0.7.0" }
|
||||
wasmparser = "0.35.1"
|
||||
dynasm = "0.3.2"
|
||||
dynasmrt = "0.3.1"
|
||||
lazy_static = "1.4.0"
|
||||
byteorder = "1.3.2"
|
||||
nix = "0.15.0"
|
||||
lazy_static = "1.4"
|
||||
byteorder = "1.3"
|
||||
nix = "0.15"
|
||||
libc = "0.2.60"
|
||||
smallvec = "0.6.10"
|
||||
smallvec = "0.6"
|
||||
|
@ -8,7 +8,7 @@ repository = "https://github.com/wasmerio/wasmer"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
glob = "0.3.0"
|
||||
glob = "0.3"
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.7.0" }
|
||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.7.0" }
|
||||
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.7.0", optional = true }
|
||||
|
@ -18,7 +18,7 @@ wasmer-llvm-backend = { path = "../llvm-backend", version = "0.7.0", optional =
|
||||
|
||||
|
||||
[build-dependencies]
|
||||
glob = "0.3.0"
|
||||
glob = "0.3"
|
||||
|
||||
[dev-dependencies]
|
||||
wasmer-clif-backend = { path = "../clif-backend", version = "0.7.0" }
|
||||
|
@ -9,16 +9,16 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
bincode = "1"
|
||||
byteorder = "1.3.2"
|
||||
generational-arena = { version = "0.2.2", features = ["serde"] }
|
||||
byteorder = "1.3"
|
||||
generational-arena = { version = "0.2", features = ["serde"] }
|
||||
libc = "0.2.60"
|
||||
log = "0.4.8"
|
||||
rand = "0.7.0"
|
||||
time = "0.1.42"
|
||||
log = "0.4"
|
||||
rand = "0.7"
|
||||
time = "0.1"
|
||||
typetag = "0.1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
# wasmer-runtime-abi = { path = "../runtime-abi" }
|
||||
wasmer-runtime-core = { path = "../runtime-core", version = "0.7.0" }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = "0.3.8"
|
||||
winapi = "0.3"
|
||||
|
@ -2,14 +2,17 @@ use wasmer_runtime_core::module::Module;
|
||||
|
||||
/// Check if a provided module is compiled with WASI support
|
||||
pub fn is_wasi_module(module: &Module) -> bool {
|
||||
if module.info().imported_functions.is_empty() {
|
||||
return false;
|
||||
}
|
||||
for (_, import_name) in &module.info().imported_functions {
|
||||
let namespace = module
|
||||
.info()
|
||||
.namespace_table
|
||||
.get(import_name.namespace_index);
|
||||
if namespace == "wasi_unstable" {
|
||||
return true;
|
||||
if namespace != "wasi_unstable" {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
false
|
||||
true
|
||||
}
|
||||
|
@ -13,6 +13,6 @@ winapi = { version = "0.3.8", features = ["winbase", "errhandlingapi", "minwinde
|
||||
libc = "0.2.60"
|
||||
|
||||
[build-dependencies]
|
||||
cmake = "0.1.40"
|
||||
bindgen = "0.51.0"
|
||||
regex = "1.2.1"
|
||||
cmake = "0.1"
|
||||
bindgen = "0.51"
|
||||
regex = "1.2"
|
||||
|
@ -512,7 +512,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
||||
import_object.allow_missing_functions = true; // Import initialization might be left to the loader.
|
||||
let instance = module
|
||||
.instantiate(&import_object)
|
||||
.map_err(|e| format!("Can't instantiate module: {:?}", e))?;
|
||||
.map_err(|e| format!("Can't instantiate loader module: {:?}", e))?;
|
||||
|
||||
let args: Vec<Value> = options
|
||||
.args
|
||||
@ -551,7 +551,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
||||
let import_object = wasmer_emscripten::generate_emscripten_env(&mut emscripten_globals);
|
||||
let mut instance = module
|
||||
.instantiate(&import_object)
|
||||
.map_err(|e| format!("Can't instantiate module: {:?}", e))?;
|
||||
.map_err(|e| format!("Can't instantiate emscripten module: {:?}", e))?;
|
||||
|
||||
wasmer_emscripten::run_emscripten_instance(
|
||||
&module,
|
||||
@ -591,7 +591,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
||||
#[allow(unused_mut)] // mut used in feature
|
||||
let mut instance = module
|
||||
.instantiate(&import_object)
|
||||
.map_err(|e| format!("Can't instantiate module: {:?}", e))?;
|
||||
.map_err(|e| format!("Can't instantiate WASI module: {:?}", e))?;
|
||||
|
||||
let start: Func<(), ()> = instance.func("_start").map_err(|e| format!("{:?}", e))?;
|
||||
|
||||
@ -752,7 +752,7 @@ fn run(options: Run) {
|
||||
match execute_wasm(&options) {
|
||||
Ok(()) => {}
|
||||
Err(message) => {
|
||||
eprintln!("execute_wasm: {:?}", message);
|
||||
eprintln!("Error: {}", message);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user