Skip to content

Commit

Permalink
Merge branch 'feature/make-instance-send' of github.com:wasmerio/wasm…
Browse files Browse the repository at this point in the history
…er into feature/make-instance-send
  • Loading branch information
Mark McCaskey committed Sep 23, 2019
2 parents c4818f1 + 705287c commit 9cab6d7
Show file tree
Hide file tree
Showing 24 changed files with 141 additions and 87 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
26 changes: 26 additions & 0 deletions docs/feature_matrix.md
Original file line number Diff line number Diff line change
@@ -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
16 changes: 8 additions & 8 deletions lib/clif-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion lib/emscripten-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
8 changes: 4 additions & 4 deletions lib/emscripten/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
6 changes: 5 additions & 1 deletion lib/emscripten/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
15 changes: 15 additions & 0 deletions lib/emscripten/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 7 additions & 14 deletions lib/emscripten/src/process.rs
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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 {
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/emscripten/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions lib/llvm-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime-c-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
34 changes: 17 additions & 17 deletions lib/runtime-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime-core/image-loading-linux-x86-64.s
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions lib/runtime-core/src/structures/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions lib/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
8 changes: 4 additions & 4 deletions lib/singlepass-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading

0 comments on commit 9cab6d7

Please sign in to comment.