Merge branch 'master' into feature/llvm-cgapi

This commit is contained in:
Brandon Fish 2019-05-06 22:39:20 -05:00 committed by GitHub
commit 87a94657d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 327 additions and 151 deletions

View File

@ -5,6 +5,11 @@ All PRs to the Wasmer repository must add to this file.
Blocks of changes will separated by version increments.
## **[Unreleased]**
## 0.4.1 - 2018-05-06
- [#426](https://github.com/wasmerio/wasmer/pull/426) Update wapm-cli submodule, bump version to 0.4.1
- [#422](https://github.com/wasmerio/wasmer/pull/422) Improved Emscripten functions to run optipng and pngquant compiled to wasm
- [#409](https://github.com/wasmerio/wasmer/pull/409) Improved Emscripten functions to run JavascriptCore compiled to wasm
- [#399](https://github.com/wasmerio/wasmer/pull/399) Add example of using a plugin extended from WASI
- [#397](https://github.com/wasmerio/wasmer/pull/397) Fix WASI fs abstraction to work on Windows

88
Cargo.lock generated
View File

@ -2226,7 +2226,7 @@ dependencies = [
[[package]]
name = "wasmer"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2234,20 +2234,20 @@ dependencies = [
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"structopt 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.4.0",
"wasmer-emscripten 0.4.0",
"wasmer-llvm-backend 0.4.0",
"wasmer-middleware-common 0.4.0",
"wasmer-runtime 0.4.0",
"wasmer-runtime-abi 0.4.0",
"wasmer-runtime-core 0.4.0",
"wasmer-singlepass-backend 0.4.0",
"wasmer-wasi 0.4.0",
"wasmer-clif-backend 0.4.1",
"wasmer-emscripten 0.4.1",
"wasmer-llvm-backend 0.4.1",
"wasmer-middleware-common 0.4.1",
"wasmer-runtime 0.4.1",
"wasmer-runtime-abi 0.4.1",
"wasmer-runtime-core 0.4.1",
"wasmer-singlepass-backend 0.4.1",
"wasmer-wasi 0.4.1",
]
[[package]]
name = "wasmer-clif-backend"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cranelift-codegen 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2263,15 +2263,15 @@ dependencies = [
"serde_bytes 0.10.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
"target-lexicon 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-runtime-core 0.4.0",
"wasmer-win-exception-handler 0.4.0",
"wasmer-runtime-core 0.4.1",
"wasmer-win-exception-handler 0.4.1",
"wasmparser 0.29.2 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasmer-emscripten"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2280,15 +2280,15 @@ dependencies = [
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.4.0",
"wasmer-llvm-backend 0.4.0",
"wasmer-runtime-core 0.4.0",
"wasmer-singlepass-backend 0.4.0",
"wasmer-clif-backend 0.4.1",
"wasmer-llvm-backend 0.4.1",
"wasmer-runtime-core 0.4.1",
"wasmer-singlepass-backend 0.4.1",
]
[[package]]
name = "wasmer-llvm-backend"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"capstone 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cc 1.0.34 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2303,42 +2303,42 @@ dependencies = [
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-runtime-core 0.4.0",
"wasmer-runtime-core 0.4.1",
"wasmparser 0.29.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasmer-middleware-common"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"wasmer-runtime-core 0.4.0",
"wasmer-runtime-core 0.4.1",
]
[[package]]
name = "wasmer-runtime"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"criterion 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.4.0",
"wasmer-llvm-backend 0.4.0",
"wasmer-runtime-core 0.4.0",
"wasmer-singlepass-backend 0.4.0",
"wasmer-clif-backend 0.4.1",
"wasmer-llvm-backend 0.4.1",
"wasmer-runtime-core 0.4.1",
"wasmer-singlepass-backend 0.4.1",
]
[[package]]
name = "wasmer-runtime-abi"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"hashbrown 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"tar 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)",
"tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-runtime-core 0.4.0",
"wasmer-runtime-core 0.4.1",
"wasmparser 0.29.2 (registry+https://github.com/rust-lang/crates.io-index)",
"zbox 0.6.1 (git+https://github.com/wasmerio/zbox?branch=bundle-libsodium)",
"zstd 0.4.22+zstd.1.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2346,17 +2346,17 @@ dependencies = [
[[package]]
name = "wasmer-runtime-c-api"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"cbindgen 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-runtime 0.4.0",
"wasmer-runtime-core 0.4.0",
"wasmer-runtime 0.4.1",
"wasmer-runtime-core 0.4.1",
]
[[package]]
name = "wasmer-runtime-core"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"blake2b_simd 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"digest 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2382,7 +2382,7 @@ dependencies = [
[[package]]
name = "wasmer-singlepass-backend"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"dynasm 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2392,24 +2392,24 @@ dependencies = [
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-runtime-core 0.4.0",
"wasmer-runtime-core 0.4.1",
"wasmparser 0.29.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasmer-spectests"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"wabt 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-clif-backend 0.4.0",
"wasmer-llvm-backend 0.4.0",
"wasmer-runtime-core 0.4.0",
"wasmer-singlepass-backend 0.4.0",
"wasmer-clif-backend 0.4.1",
"wasmer-llvm-backend 0.4.1",
"wasmer-runtime-core 0.4.1",
"wasmer-singlepass-backend 0.4.1",
]
[[package]]
name = "wasmer-wasi"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"byteorder 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"generational-arena 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2417,18 +2417,18 @@ dependencies = [
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-runtime-core 0.4.0",
"wasmer-runtime-core 0.4.1",
]
[[package]]
name = "wasmer-win-exception-handler"
version = "0.4.0"
version = "0.4.1"
dependencies = [
"bindgen 0.46.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"wasmer-runtime-core 0.4.0",
"wasmer-runtime-core 0.4.1",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]

View File

@ -1,6 +1,6 @@
[package]
name = "wasmer"
version = "0.4.0"
version = "0.4.1"
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
edition = "2018"
repository = "https://github.com/wasmerio/wasmer"
@ -43,7 +43,8 @@ rustc_version = "0.2.3"
[features]
default = ["fast-tests", "wasi"]
debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
debug = ["wasmer-runtime-core/debug"]
extra-debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
# This feature will allow cargo test to run much faster
fast-tests = []
"backend:llvm" = ["wasmer-llvm-backend"]

View File

@ -84,5 +84,8 @@ production-release:
debug-release:
cargo build --release --features "debug"
extra-debug-release:
cargo build --release --features "extra-debug"
publish-release:
ghr -t ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -c ${CIRCLE_SHA1} -delete ${VERSION} ./artifacts/

9
examples/README.md Normal file
View File

@ -0,0 +1,9 @@
# WebAssembly Examples
In this directory you can find a set of different examples that can run on the Wasmer WebAssembly runtime:
* Cowsay (WASI ABI) [[source-code](https://github.com/wapm-packages/cowsay)] [[wapm-package](https://wapm.io/package/cowsay)]
* Nginx (Emscripten ABI) [[source-code](https://github.com/wapm-packages/nginx)] [[wapm-package](https://wapm.io/package/nginx)]
* Lua (Emscripten ABI) [[source-code](https://github.com/wapm-packages/lua)] [[wapm-package](https://wapm.io/package/lua)]
* PHP (Emscripten ABI) [[source-code](https://github.com/wapm-packages/php)] [[wapm-package](https://wapm.io/package/php)]
* SQLite (Emscripten ABI) [[source-code](https://github.com/wapm-packages/sqlite)] [[wapm-package](https://wapm.io/package/sqlite)]

View File

@ -1,6 +1,6 @@
[package]
name = "wasmer-clif-backend"
version = "0.4.0"
version = "0.4.1"
description = "Wasmer runtime Cranelift compiler backend"
license = "MIT"
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
@ -8,7 +8,7 @@ repository = "https://github.com/wasmerio/wasmer"
edition = "2018"
[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.0" }
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.1" }
cranelift-native = "0.30.0"
cranelift-codegen = "0.30.0"
cranelift-entity = "0.30.0"
@ -33,7 +33,7 @@ version = "0.0.7"
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["errhandlingapi", "minwindef", "minwinbase", "winnt"] }
wasmer-win-exception-handler = { path = "../win-exception-handler", version = "0.4.0" }
wasmer-win-exception-handler = { path = "../win-exception-handler", version = "0.4.1" }
[features]
debug = ["wasmer-runtime-core/debug"]

View File

@ -107,7 +107,7 @@ pub fn call_protected<T>(
Ok(SIGSEGV) => "segmentation violation",
Ok(SIGBUS) => "bus error",
Err(_) => "error while getting the Signal",
_ => "unkown trapped signal",
_ => "unknown trapped signal",
};
// When the trap-handler is fully implemented, this will return more information.
let s = format!("unknown trap at {:p} - {}", faulting_addr, signal);

View File

@ -4,7 +4,6 @@ use crate::trampoline::Trampoline;
use std::cell::Cell;
use std::ffi::c_void;
use std::ptr::{self, NonNull};
use wasmer_runtime_core::error::{RuntimeError, RuntimeResult};
use wasmer_runtime_core::typed_func::WasmTrapInfo;
use wasmer_runtime_core::vm::Ctx;
use wasmer_runtime_core::vm::Func;
@ -12,10 +11,14 @@ use wasmer_win_exception_handler::CallProtectedData;
pub use wasmer_win_exception_handler::_call_protected;
use winapi::shared::minwindef::DWORD;
use winapi::um::minwinbase::{
EXCEPTION_ACCESS_VIOLATION, EXCEPTION_FLT_DENORMAL_OPERAND, EXCEPTION_FLT_DIVIDE_BY_ZERO,
EXCEPTION_ACCESS_VIOLATION, EXCEPTION_ARRAY_BOUNDS_EXCEEDED, EXCEPTION_BREAKPOINT,
EXCEPTION_DATATYPE_MISALIGNMENT, EXCEPTION_FLT_DENORMAL_OPERAND, EXCEPTION_FLT_DIVIDE_BY_ZERO,
EXCEPTION_FLT_INEXACT_RESULT, EXCEPTION_FLT_INVALID_OPERATION, EXCEPTION_FLT_OVERFLOW,
EXCEPTION_FLT_STACK_CHECK, EXCEPTION_FLT_UNDERFLOW, EXCEPTION_ILLEGAL_INSTRUCTION,
EXCEPTION_INT_DIVIDE_BY_ZERO, EXCEPTION_INT_OVERFLOW, EXCEPTION_STACK_OVERFLOW,
EXCEPTION_FLT_STACK_CHECK, EXCEPTION_FLT_UNDERFLOW, EXCEPTION_GUARD_PAGE,
EXCEPTION_ILLEGAL_INSTRUCTION, EXCEPTION_INT_DIVIDE_BY_ZERO, EXCEPTION_INT_OVERFLOW,
EXCEPTION_INVALID_HANDLE, EXCEPTION_IN_PAGE_ERROR, EXCEPTION_NONCONTINUABLE_EXCEPTION,
EXCEPTION_POSSIBLE_DEADLOCK, EXCEPTION_PRIV_INSTRUCTION, EXCEPTION_SINGLE_STEP,
EXCEPTION_STACK_OVERFLOW,
};
thread_local! {
@ -43,7 +46,7 @@ pub fn call_protected(
}
let CallProtectedData {
code: signum,
code,
exception_address,
instruction_pointer,
} = result.unwrap_err();
@ -53,7 +56,7 @@ pub fn call_protected(
srcloc: _,
}) = handler_data.lookup(instruction_pointer as _)
{
Err(CallProtError::Trap(match signum as DWORD {
Err(CallProtError::Trap(match code as DWORD {
EXCEPTION_ACCESS_VIOLATION => WasmTrapInfo::MemoryOutOfBounds,
EXCEPTION_ILLEGAL_INSTRUCTION => match trapcode {
TrapCode::BadSignature => WasmTrapInfo::IncorrectCallIndirectSignature,
@ -70,7 +73,7 @@ pub fn call_protected(
_ => WasmTrapInfo::Unknown,
}))
} else {
let signal = match signum as DWORD {
let signal = match code as DWORD {
EXCEPTION_FLT_DENORMAL_OPERAND
| EXCEPTION_FLT_DIVIDE_BY_ZERO
| EXCEPTION_FLT_INEXACT_RESULT
@ -80,10 +83,26 @@ pub fn call_protected(
| EXCEPTION_FLT_UNDERFLOW => "floating-point exception",
EXCEPTION_ILLEGAL_INSTRUCTION => "illegal instruction",
EXCEPTION_ACCESS_VIOLATION => "segmentation violation",
_ => "unkown trapped signal",
EXCEPTION_DATATYPE_MISALIGNMENT => "datatype misalignment",
EXCEPTION_BREAKPOINT => "breakpoint",
EXCEPTION_SINGLE_STEP => "single step",
EXCEPTION_ARRAY_BOUNDS_EXCEEDED => "array bounds exceeded",
EXCEPTION_INT_DIVIDE_BY_ZERO => "int div by zero",
EXCEPTION_INT_OVERFLOW => "int overflow",
EXCEPTION_PRIV_INSTRUCTION => "priv instruction",
EXCEPTION_IN_PAGE_ERROR => "in page error",
EXCEPTION_NONCONTINUABLE_EXCEPTION => "non continuable exception",
EXCEPTION_STACK_OVERFLOW => "stack overflow",
EXCEPTION_GUARD_PAGE => "guard page",
EXCEPTION_INVALID_HANDLE => "invalid handle",
EXCEPTION_POSSIBLE_DEADLOCK => "possible deadlock",
_ => "unknown exception code",
};
let s = format!("unknown trap at {} - {}", exception_address, signal);
let s = format!(
"unhandled trap at {:x} - code #{:x}: {}",
exception_address, code, signal,
);
Err(CallProtError::Error(Box::new(s)))
}

View File

@ -1,6 +1,6 @@
[package]
name = "wasmer-emscripten"
version = "0.4.0"
version = "0.4.1"
description = "Wasmer runtime emscripten implementation library"
license = "MIT"
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
@ -9,14 +9,14 @@ edition = "2018"
build = "build/mod.rs"
[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.0" }
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.1" }
lazy_static = "1.2.0"
libc = "0.2.49"
byteorder = "1"
time = "0.1.41"
wasmer-clif-backend = { path = "../clif-backend", version = "0.4.0" }
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.4.0", optional = true }
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.4.0", optional = true }
wasmer-clif-backend = { path = "../clif-backend", version = "0.4.1" }
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.4.1", optional = true }
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.4.1", optional = true }
[target.'cfg(windows)'.dependencies]
rand = "0.6"

View File

@ -55,7 +55,7 @@ pub fn _dladdr(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
0
}
pub fn _pthread_attr_init(_ctx: &mut Ctx, _a: i32) -> i32 {
debug!("emscripten::_pthread_attr_init");
debug!("emscripten::_pthread_attr_init({})", _a);
0
}
pub fn _pthread_attr_destroy(_ctx: &mut Ctx, _a: i32) -> i32 {
@ -68,7 +68,10 @@ pub fn _pthread_attr_getstack(
_stacksize: i32,
_other: i32,
) -> i32 {
debug!("emscripten::_pthread_attr_getstack");
debug!(
"emscripten::_pthread_attr_getstack({}, {}, {})",
_stackaddr, _stacksize, _other
);
// TODO: Translate from Emscripten
// HEAP32[stackaddr >> 2] = STACK_BASE;
// HEAP32[stacksize >> 2] = TOTAL_STACK;
@ -87,7 +90,7 @@ pub fn _pthread_getspecific(_ctx: &mut Ctx, _a: i32) -> i32 {
0
}
pub fn _pthread_getattr_np(_ctx: &mut Ctx, _thread: i32, _attr: i32) -> i32 {
debug!("emscripten::_pthread_getattr_np");
debug!("emscripten::_pthread_getattr_np({}, {})", _thread, _attr);
0
}
pub fn _pthread_setspecific(_ctx: &mut Ctx, _a: i32, _b: i32) -> i32 {
@ -732,6 +735,10 @@ pub fn invoke_vj(ctx: &mut Ctx, index: i32, a1: i32, a2: i32) {
panic!("dyn_call_vj is set to None");
}
}
pub fn invoke_vjji(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) {
debug!("emscripten::invoke_vjji");
invoke_no_return!(ctx, dyn_call_vjji, index, a1, a2, a3, a4, a5)
}
pub fn invoke_vij(ctx: &mut Ctx, index: i32, a1: i32, a2: i32, a3: i32) {
debug!("emscripten::invoke_vij");
if let Some(dyn_call_vij) = &get_emscripten_data(ctx).dyn_call_vij {

View File

@ -60,21 +60,51 @@ pub fn ___build_environment(ctx: &mut Ctx, environ: c_int) {
const MAX_ENV_VALUES: u32 = 64;
const TOTAL_ENV_SIZE: u32 = 1024;
let environment = emscripten_memory_pointer!(ctx.memory(0), environ) as *mut c_int;
unsafe {
let (mut pool_offset, env_ptr, mut pool_ptr) = unsafe {
let (pool_offset, _pool_slice): (u32, &mut [u8]) =
allocate_on_stack(ctx, TOTAL_ENV_SIZE as u32);
let (env_offset, _env_slice): (u32, &mut [u8]) =
allocate_on_stack(ctx, (MAX_ENV_VALUES * 4) as u32);
let env_ptr = emscripten_memory_pointer!(ctx.memory(0), env_offset) as *mut c_int;
let mut _pool_ptr = emscripten_memory_pointer!(ctx.memory(0), pool_offset) as *mut c_int;
let pool_ptr = emscripten_memory_pointer!(ctx.memory(0), pool_offset) as *mut u8;
*env_ptr = pool_offset as i32;
*environment = env_offset as i32;
// *env_ptr = 0;
(pool_offset, env_ptr, pool_ptr)
};
// unsafe {
// *env_ptr = 0;
// };
// *env_ptr = 0;
let default_vars = vec![
["USER", "web_user"],
["LOGNAME", "web_user"],
["PATH", "/"],
["PWD", "/"],
["HOME", "/home/web_user"],
["LANG", "C.UTF-8"],
["_", "thisProgram"],
];
let mut strings = vec![];
let mut total_size = 0;
for [key, val] in &default_vars {
let line = key.to_string() + "=" + val;
total_size += line.len();
strings.push(line);
}
if total_size as u32 > TOTAL_ENV_SIZE {
panic!("Environment size exceeded TOTAL_ENV_SIZE!");
}
unsafe {
for (i, s) in strings.iter().enumerate() {
for (j, c) in s.chars().enumerate() {
debug_assert!(c < u8::max_value() as char);
*pool_ptr.add(j) = c as u8;
}
*env_ptr.add(i * 4) = pool_offset as i32;
pool_offset += s.len() as u32 + 1;
pool_ptr = pool_ptr.add(s.len() + 1);
}
*env_ptr.add(strings.len() * 4) = 0;
}
}
pub fn ___assert_fail(_ctx: &mut Ctx, _a: c_int, _b: c_int, _c: c_int, _d: c_int) {

View File

@ -7,7 +7,7 @@ use wasmer_runtime_core::vm::Ctx;
/// setjmp
pub fn __setjmp(ctx: &mut Ctx, _env_addr: u32) -> c_int {
debug!("emscripten::__setjmp (setjmp)");
abort_with_message(ctx, "missing function: _longjmp");
abort_with_message(ctx, "missing function: _setjmp");
unreachable!()
// unsafe {
// // Rather than using the env as the holder of the jump buffer pointer,

View File

@ -50,7 +50,7 @@ mod varargs;
pub use self::storage::{align_memory, static_alloc};
pub use self::utils::{
allocate_cstr_on_stack, allocate_on_stack, get_emscripten_memory_size,
allocate_cstr_on_stack, allocate_on_stack, get_emscripten_memory_size, get_emscripten_metadata,
get_emscripten_table_size, is_emscripten_module,
};
@ -127,6 +127,7 @@ pub struct EmscriptenData<'a> {
pub dyn_call_viijiii: Option<Func<'a, (i32, i32, i32, i32, i32, i32, i32, i32)>>,
pub dyn_call_viijj: Option<Func<'a, (i32, i32, i32, i32, i32, i32, i32)>>,
pub dyn_call_vj: Option<Func<'a, (i32, i32, i32)>>,
pub dyn_call_vjji: Option<Func<'a, (i32, i32, i32, i32, i32, i32)>>,
pub dyn_call_vij: Option<Func<'a, (i32, i32, i32, i32)>>,
pub dyn_call_viji: Option<Func<'a, (i32, i32, i32, i32, i32)>>,
pub dyn_call_vijiii: Option<Func<'a, (i32, i32, i32, i32, i32, i32, i32)>>,
@ -146,11 +147,7 @@ impl<'a> EmscriptenData<'a> {
pub fn new(instance: &'a mut Instance) -> EmscriptenData<'a> {
let malloc = instance.func("_malloc").unwrap();
let free = instance.func("_free").unwrap();
let memalign = if let Ok(func) = instance.func("_memalign") {
Some(func)
} else {
None
};
let memalign = instance.func("_memalign").ok();
let memset = instance.func("_memset").unwrap();
let stack_alloc = instance.func("stackAlloc").unwrap();
@ -198,6 +195,7 @@ impl<'a> EmscriptenData<'a> {
let dyn_call_viijiii = instance.func("dynCall_viijiii").ok();
let dyn_call_viijj = instance.func("dynCall_viijj").ok();
let dyn_call_vj = instance.func("dynCall_vj").ok();
let dyn_call_vjji = instance.func("dynCall_vjji").ok();
let dyn_call_vij = instance.func("dynCall_vij").ok();
let dyn_call_viji = instance.func("dynCall_viji").ok();
let dyn_call_vijiii = instance.func("dynCall_vijiii").ok();
@ -261,6 +259,7 @@ impl<'a> EmscriptenData<'a> {
dyn_call_viijiii,
dyn_call_viijj,
dyn_call_vj,
dyn_call_vjji,
dyn_call_vij,
dyn_call_viji,
dyn_call_vijiii,
@ -282,6 +281,7 @@ pub fn run_emscripten_instance(
instance: &mut Instance,
path: &str,
args: Vec<&str>,
entrypoint: Option<String>,
) -> CallResult<()> {
let mut data = EmscriptenData::new(instance);
let data_ptr = &mut data as *mut _ as *mut c_void;
@ -299,52 +299,58 @@ pub fn run_emscripten_instance(
// println!("running emscripten instance");
let main_func = instance.dyn_func("_main")?;
let num_params = main_func.signature().params().len();
let _result = match num_params {
2 => {
let (argc, argv) = store_module_arguments(instance.context_mut(), path, args);
instance.call("_main", &[Value::I32(argc as i32), Value::I32(argv as i32)])?;
}
0 => {
instance.call("_main", &[])?;
}
_ => panic!(
"The emscripten main function has received an incorrect number of params {}",
num_params
),
};
if let Some(ep) = entrypoint {
debug!("Running entry point: {}", &ep);
let arg = unsafe { allocate_cstr_on_stack(instance.context_mut(), args[0]).0 };
//let (argc, argv) = store_module_arguments(instance.context_mut(), args);
instance.call(&ep, &[Value::I32(arg as i32)])?;
} else {
let main_func = instance.dyn_func("_main")?;
let num_params = main_func.signature().params().len();
let _result = match num_params {
2 => {
let mut new_args = vec![path];
new_args.extend(args);
let (argc, argv) = store_module_arguments(instance.context_mut(), new_args);
instance.call("_main", &[Value::I32(argc as i32), Value::I32(argv as i32)])?;
}
0 => {
instance.call("_main", &[])?;
}
_ => panic!(
"The emscripten main function has received an incorrect number of params {}",
num_params
),
};
}
// TODO atexit for emscripten
// println!("{:?}", data);
Ok(())
}
fn store_module_arguments(ctx: &mut Ctx, path: &str, args: Vec<&str>) -> (u32, u32) {
fn store_module_arguments(ctx: &mut Ctx, args: Vec<&str>) -> (u32, u32) {
let argc = args.len() + 1;
let mut args_slice = vec![0; argc];
args_slice[0] = unsafe { allocate_cstr_on_stack(ctx, path).0 };
for (slot, arg) in args_slice[1..argc].iter_mut().zip(args.iter()) {
for (slot, arg) in args_slice[0..argc].iter_mut().zip(args.iter()) {
*slot = unsafe { allocate_cstr_on_stack(ctx, &arg).0 };
}
let (argv_offset, argv_slice): (_, &mut [u32]) =
unsafe { allocate_on_stack(ctx, ((argc + 1) * 4) as u32) };
unsafe { allocate_on_stack(ctx, ((argc) * 4) as u32) };
assert!(!argv_slice.is_empty());
for (slot, arg) in argv_slice[0..argc].iter_mut().zip(args_slice.iter()) {
*slot = *arg
}
argv_slice[argc] = 0;
(argc as u32, argv_offset)
(argc as u32 - 1, argv_offset)
}
pub fn emscripten_set_up_memory(memory: &Memory, globals: &EmscriptenGlobalsData) {
let dynamictop_ptr = globals.dynamictop_ptr;
let stack_max = globals.stack_max;
let dynamic_base = align_memory(stack_max);
let dynamic_base = globals.dynamic_base;
memory.view::<u32>()[(dynamictop_ptr / 4) as usize].set(dynamic_base);
}
@ -355,6 +361,7 @@ pub struct EmscriptenGlobalsData {
stacktop: u32,
stack_max: u32,
dynamictop_ptr: u32,
dynamic_base: u32,
memory_base: u32,
table_base: u32,
temp_double_ptr: u32,
@ -424,7 +431,14 @@ impl EmscriptenGlobals {
let temp_double_ptr = static_top;
static_top += 16;
let dynamictop_ptr = static_alloc(&mut static_top, 4);
let (dynamic_base, dynamictop_ptr) =
get_emscripten_metadata(&module).unwrap_or_else(|| {
let dynamictop_ptr = static_alloc(&mut static_top, 4);
(
align_memory(align_memory(static_top) + TOTAL_STACK),
dynamictop_ptr,
)
});
let stacktop = align_memory(static_top);
let stack_max = stacktop + TOTAL_STACK;
@ -434,6 +448,7 @@ impl EmscriptenGlobals {
stacktop,
stack_max,
dynamictop_ptr,
dynamic_base,
memory_base,
table_base,
temp_double_ptr,
@ -597,6 +612,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"___syscall272" => func!(crate::syscalls::___syscall272),
"___syscall295" => func!(crate::syscalls::___syscall295),
"___syscall300" => func!(crate::syscalls::___syscall300),
"___syscall320" => func!(crate::syscalls::___syscall320),
"___syscall324" => func!(crate::syscalls::___syscall324),
"___syscall330" => func!(crate::syscalls::___syscall330),
"___syscall334" => func!(crate::syscalls::___syscall334),
@ -718,6 +734,7 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"invoke_v" => func!(crate::emscripten_target::invoke_v),
"invoke_vi" => func!(crate::emscripten_target::invoke_vi),
"invoke_vj" => func!(crate::emscripten_target::invoke_vj),
"invoke_vjji" => func!(crate::emscripten_target::invoke_vjji),
"invoke_vii" => func!(crate::emscripten_target::invoke_vii),
"invoke_viii" => func!(crate::emscripten_target::invoke_viii),
"invoke_viiii" => func!(crate::emscripten_target::invoke_viiii),

View File

@ -21,8 +21,11 @@ pub fn _emscripten_memcpy_big(ctx: &mut Ctx, dest: u32, src: u32, len: u32) -> u
/// emscripten: _emscripten_get_heap_size
pub fn _emscripten_get_heap_size(ctx: &mut Ctx) -> u32 {
debug!("emscripten::_emscripten_get_heap_size",);
ctx.memory(0).size().bytes().0 as u32
debug!("emscripten::_emscripten_get_heap_size");
let result = ctx.memory(0).size().bytes().0 as u32;
debug!("=> {}", result);
result
}
// From emscripten implementation

View File

@ -82,7 +82,7 @@ pub fn _raise(_ctx: &mut Ctx, _one: i32) -> i32 {
}
pub fn _sem_init(_ctx: &mut Ctx, _one: i32, _two: i32, _three: i32) -> i32 {
debug!("emscripten::_sem_init");
debug!("emscripten::_sem_init: {}, {}, {}", _one, _two, _three);
0
}

View File

@ -31,12 +31,13 @@ use libc::{
off_t,
// open,
read,
rename,
// sockaddr_in,
// readv,
rmdir,
// writev,
stat,
write,
// sockaddr_in,
};
use wasmer_runtime_core::vm::Ctx;
@ -118,9 +119,21 @@ pub fn ___syscall20(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
unsafe { getpid() }
}
pub fn ___syscall38(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall38");
-1
// rename
pub fn ___syscall38(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> i32 {
debug!("emscripten::___syscall38 (rename)");
let old_path_addr: u32 = varargs.get(ctx);
let new_path_addr: u32 = varargs.get(ctx);
let old_path = emscripten_memory_pointer!(ctx.memory(0), old_path_addr) as *const i8;
let new_path = emscripten_memory_pointer!(ctx.memory(0), new_path_addr) as *const i8;
let result = unsafe { rename(old_path, new_path) };
debug!(
"=> old_path: {}, new_path: {}, result: {}",
unsafe { std::ffi::CStr::from_ptr(old_path).to_str().unwrap() },
unsafe { std::ffi::CStr::from_ptr(new_path).to_str().unwrap() },
result
);
result
}
// rmdir
@ -246,12 +259,21 @@ pub fn ___syscall192(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_in
if fd == -1 {
let ptr = env::call_memalign(ctx, 16384, len);
if ptr == 0 {
return -1;
// ENOMEM
return -12;
}
let real_ptr = emscripten_memory_pointer!(ctx.memory(0), ptr) as *const u8;
env::call_memset(ctx, ptr, 0, len);
ptr as _
for i in 0..(len as usize) {
unsafe {
assert_eq!(*real_ptr.add(i), 0);
}
}
debug!("=> ptr: {}", ptr);
return ptr as i32;
} else {
-1
// return ENODEV
return -19;
}
}
@ -461,6 +483,12 @@ pub fn ___syscall300(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
-1
}
// utimensat
pub fn ___syscall320(_ctx: &mut Ctx, _which: c_int, mut _varargs: VarArgs) -> c_int {
debug!("emscripten::___syscall320 (utimensat), {}", _which);
0
}
pub fn ___syscall334(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall334");
-1

View File

@ -251,8 +251,9 @@ pub fn ___syscall33(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
let path = emscripten_memory_pointer!(ctx.memory(0), path_ptr) as *const i8;
let result = unsafe { access(path, amode) };
debug!(
"=> path: {}, result: {}",
"=> path: {}, amode: {}, result: {}",
unsafe { std::ffi::CStr::from_ptr(path).to_str().unwrap() },
amode,
result
);
result
@ -354,8 +355,13 @@ pub fn ___syscall54(ctx: &mut Ctx, _which: c_int, mut varargs: VarArgs) -> c_int
debug!("emscripten::___syscall54 (ioctl) {}", _which);
let fd: i32 = varargs.get(ctx);
let request: u32 = varargs.get(ctx);
debug!("fd: {}, op: {}", fd, request);
debug!("=> fd: {}, op: {}", fd, request);
// Got the equivalents here: https://code.woboq.org/linux/linux/include/uapi/asm-generic/ioctls.h.html
// let argp: u32 = varargs.get(ctx);
// let argp_ptr = emscripten_memory_pointer!(ctx.memory(0), argp) as *mut c_void;
// let ret = unsafe { ioctl(fd, request as _, argp_ptr) };
// debug!("=> {}", ret);
// ret
match request as _ {
21537 => {
// FIONBIO

View File

@ -28,7 +28,9 @@ use wasmer_runtime_core::vm::Ctx;
use libc::{CLOCK_MONOTONIC, CLOCK_MONOTONIC_COARSE, CLOCK_REALTIME};
#[cfg(target_os = "macos")]
use libc::{CLOCK_MONOTONIC, CLOCK_REALTIME};
use libc::CLOCK_REALTIME;
#[cfg(target_os = "macos")]
const CLOCK_MONOTONIC: clockid_t = 1;
#[cfg(target_os = "macos")]
const CLOCK_MONOTONIC_COARSE: clockid_t = 6;

View File

@ -1,5 +1,6 @@
use super::env;
use super::env::get_emscripten_data;
use crate::storage::align_memory;
use libc::stat;
use std::ffi::CStr;
use std::mem::size_of;
@ -39,6 +40,43 @@ pub fn get_emscripten_memory_size(module: &Module) -> (Pages, Option<Pages>) {
(memory.minimum, memory.maximum)
}
/// Reads values written by `-s EMIT_EMSCRIPTEN_METADATA=1`
/// Assumes values start from the end in this order:
/// Last export: Dynamic Base
/// Second-to-Last export: Dynamic top pointer
pub fn get_emscripten_metadata(module: &Module) -> Option<(u32, u32)> {
let max_idx = &module.info().globals.iter().map(|(k, _)| k).max()?;
let snd_max_idx = &module
.info()
.globals
.iter()
.map(|(k, _)| k)
.filter(|k| k != max_idx)
.max()?;
use wasmer_runtime_core::types::{GlobalInit, Initializer::Const, Value::I32};
if let (
GlobalInit {
init: Const(I32(dynamic_base)),
..
},
GlobalInit {
init: Const(I32(dynamictop_ptr)),
..
},
) = (
&module.info().globals[*max_idx],
&module.info().globals[*snd_max_idx],
) {
Some((
align_memory(*dynamic_base as u32 - 32),
align_memory(*dynamictop_ptr as u32 - 32),
))
} else {
None
}
}
pub unsafe fn write_to_buf(ctx: &mut Ctx, string: *const c_char, buf: u32, max: u32) -> u32 {
let buf_addr = emscripten_memory_pointer!(ctx.memory(0), buf) as *mut c_char;

View File

@ -53,6 +53,7 @@ macro_rules! assert_emscripten_output {
&mut instance,
$name,
$args,
None,
).expect("run_emscripten_instance finishes");
let output = capturer.end().unwrap().0;

View File

@ -1,11 +1,11 @@
[package]
name = "wasmer-llvm-backend"
version = "0.4.0"
version = "0.4.1"
authors = ["Lachlan Sneff <lachlan.sneff@gmail.com>"]
edition = "2018"
[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.0" }
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.1" }
inkwell = { git = "https://github.com/wasmerio/inkwell", branch = "llvm7-0" }
wasmparser = "0.29.2"
hashbrown = "0.1.8"

View File

@ -1,6 +1,6 @@
[package]
name = "wasmer-middleware-common"
version = "0.4.0"
version = "0.4.1"
repository = "https://github.com/wasmerio/wasmer"
description = "Wasmer runtime common middlewares"
license = "MIT"
@ -8,4 +8,4 @@ authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
edition = "2018"
[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.0" }
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.1" }

View File

@ -1,6 +1,6 @@
[package]
name = "wasmer-runtime-abi"
version = "0.4.0"
version = "0.4.1"
description = "Wasmer runtime core library"
license = "MIT"
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]

View File

@ -1,6 +1,6 @@
[package]
name = "wasmer-runtime-c-api"
version = "0.4.0"
version = "0.4.1"
description = "Wasmer C API library"
license = "MIT"
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
@ -16,11 +16,11 @@ libc = "0.2"
[dependencies.wasmer-runtime]
path = "../runtime"
version = "0.4.0"
version = "0.4.1"
[dependencies.wasmer-runtime-core]
path = "../runtime-core"
version = "0.4.0"
version = "0.4.1"
[features]
debug = ["wasmer-runtime/debug"]

View File

@ -1,6 +1,6 @@
[package]
name = "wasmer-runtime-core"
version = "0.4.0"
version = "0.4.1"
description = "Wasmer runtime core library"
license = "MIT"
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]

View File

@ -4,7 +4,6 @@ use crate::{
cache::{Artifact, Error as CacheError},
error::{CompileError, CompileResult},
module::{ModuleInfo, ModuleInner},
parse::LoadError,
structures::Map,
types::{FuncIndex, FuncSig, SigIndex},
};

View File

@ -401,7 +401,7 @@ pub trait LocalImport {
macro_rules! define_map_index {
($ty:ident) => {
#[derive(Serialize, Deserialize)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct $ty (u32);
impl TypedIndex for $ty {
#[doc(hidden)]

View File

@ -1,6 +1,6 @@
[package]
name = "wasmer-runtime"
version = "0.4.0"
version = "0.4.1"
description = "Wasmer runtime library"
license = "MIT"
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
@ -9,17 +9,17 @@ edition = "2018"
readme = "README.md"
[dependencies]
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.4.0", optional = true }
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.4.1", optional = true }
lazy_static = "1.2.0"
memmap = "0.7.0"
[dependencies.wasmer-runtime-core]
path = "../runtime-core"
version = "0.4.0"
version = "0.4.1"
[dependencies.wasmer-clif-backend]
path = "../clif-backend"
version = "0.4.0"
version = "0.4.1"
optional = true
[dev-dependencies]

View File

@ -1,6 +1,6 @@
[package]
name = "wasmer-singlepass-backend"
version = "0.4.0"
version = "0.4.1"
repository = "https://github.com/wasmerio/wasmer"
description = "Wasmer runtime single pass compiler backend"
license = "MIT"
@ -8,7 +8,7 @@ authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
edition = "2018"
[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.0" }
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.1" }
wasmparser = "0.29.2"
dynasm = "0.3.1"
dynasmrt = "0.3.1"

View File

@ -111,7 +111,7 @@ pub fn call_protected<T>(f: impl FnOnce() -> T) -> Result<T, CallProtError> {
// Ok(SIGSEGV) => "segmentation violation",
// Ok(SIGBUS) => "bus error",
// Err(_) => "error while getting the Signal",
// _ => "unkown trapped signal",
// _ => "unknown trapped signal",
// };
// // When the trap-handler is fully implemented, this will return more information.
// Err(RuntimeError::Trap {

View File

@ -1,6 +1,6 @@
[package]
name = "wasmer-spectests"
version = "0.4.0"
version = "0.4.1"
description = "Wasmer spectests library"
license = "MIT"
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
@ -9,10 +9,10 @@ edition = "2018"
build = "build/mod.rs"
[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.0" }
wasmer-clif-backend = { path = "../clif-backend", version = "0.4.0" }
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.4.0", optional = true }
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.4.0", optional = true }
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.1" }
wasmer-clif-backend = { path = "../clif-backend", version = "0.4.1" }
wasmer-llvm-backend = { path = "../llvm-backend", version = "0.4.1", optional = true }
wasmer-singlepass-backend = { path = "../singlepass-backend", version = "0.4.1", optional = true }
[build-dependencies]
wabt = "0.7.2"

View File

@ -1,6 +1,6 @@
[package]
name = "wasmer-wasi"
version = "0.4.0"
version = "0.4.1"
description = "Wasmer runtime WASI implementation library"
license = "MIT"
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
@ -8,7 +8,7 @@ repository = "https://github.com/wasmerio/wasmer"
edition = "2018"
[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.0" }
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.1" }
libc = "0.2.50"
rand = "0.6.5"
# wasmer-runtime-abi = { path = "../runtime-abi" }

View File

@ -1,6 +1,6 @@
[package]
name = "wasmer-win-exception-handler"
version = "0.4.0"
version = "0.4.1"
description = "Wasmer runtime exception handling for Windows"
license = "MIT"
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
@ -8,7 +8,7 @@ repository = "https://github.com/wasmerio/wasmer"
edition = "2018"
[target.'cfg(windows)'.dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.0" }
wasmer-runtime-core = { path = "../runtime-core", version = "0.4.1" }
winapi = { version = "0.3", features = ["winbase", "errhandlingapi", "minwindef", "minwinbase", "winnt"] }
libc = "0.2.49"

View File

@ -5,6 +5,7 @@
#define CALL_FIRST 1
__declspec(thread) jmp_buf jmpBuf;
__declspec(thread) DWORD caughtExceptionCode;
__declspec(thread) PVOID caughtExceptionAddress;
__declspec(thread) DWORD64 caughtInstructionPointer;
__declspec(thread) PVOID savedStackPointer;
@ -25,6 +26,7 @@ static LONG WINAPI
exceptionHandler(struct _EXCEPTION_POINTERS *ExceptionInfo) {
EXCEPTION_RECORD* pExceptionRecord = ExceptionInfo->ExceptionRecord;
PCONTEXT pCONTEXT = ExceptionInfo->ContextRecord;
caughtExceptionCode = pExceptionRecord->ExceptionCode;
caughtExceptionAddress = pExceptionRecord->ExceptionAddress;
caughtInstructionPointer = pCONTEXT->Rip;
if (alreadyHandlingException == TRUE) {
@ -61,8 +63,9 @@ uint8_t callProtected(trampoline_t trampoline,
}
// jmp jmp jmp!
int signum = setjmp(jmpBuf);
if (signum == 0) {
int status = setjmp(jmpBuf);
if (status == 0) // 0 means the original call
{
// save the stack pointer
savedStackPointer = get_callee_frame_address();
trampoline(ctx, func, param_vec, return_vec);
@ -74,7 +77,7 @@ uint8_t callProtected(trampoline_t trampoline,
return TRUE;
}
out_result->code = (uint64_t)signum;
out_result->code = (uint64_t)caughtExceptionCode;
out_result->exception_address = (uint64_t)caughtExceptionAddress;
out_result->instruction_pointer = caughtInstructionPointer;
@ -83,4 +86,4 @@ uint8_t callProtected(trampoline_t trampoline,
removeExceptionHandler();
return FALSE;
}
}

View File

@ -86,6 +86,10 @@ struct Run {
#[structopt(long = "em-symbol-map", parse(from_os_str), group = "emscripten")]
em_symbol_map: Option<PathBuf>,
/// Begin execution at the specified symbol
#[structopt(long = "em-entrypoint", group = "emscripten")]
em_entrypoint: Option<String>,
/// WASI pre-opened directory
#[structopt(long = "dir", multiple = true, group = "wasi")]
pre_opened_directories: Vec<String>,
@ -320,6 +324,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
options.path.to_str().unwrap()
},
options.args.iter().map(|arg| arg.as_str()).collect(),
options.em_entrypoint.clone(),
)
.map_err(|e| format!("{:?}", e))?;
} else {

View File

@ -1,5 +1,5 @@
PREVIOUS_VERSION='0.3.0'
NEXT_VERSION='0.4.0'
PREVIOUS_VERSION='0.4.0'
NEXT_VERSION='0.4.1'
# quick hack
fd Cargo.toml --exec sed -i '' "s/version = \"$PREVIOUS_VERSION\"/version = \"$NEXT_VERSION\"/"

@ -1 +1 @@
Subproject commit c9399f3fb117c8ab1cbaf17b02bd5aeefb8e8e54
Subproject commit 8286d0a4bcd771c2f5e622b40543143e25e096df