Skip to content

Commit

Permalink
Merge #329
Browse files Browse the repository at this point in the history
329: changes to make PHP run better r=MarkMcCaskey a=MarkMcCaskey

Fixes:
- memory access when ending programs (by implementing `TempRet0`
- `munmap` errors from PHP by lying and just returning 0

Co-authored-by: Mark McCaskey <mark@wasmer.io>
  • Loading branch information
bors[bot] and Mark McCaskey committed Apr 5, 2019
2 parents 04d7cbc + 516b932 commit 1c2f0e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions lib/emscripten/src/emscripten_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ use crate::env::get_emscripten_data;
use libc::getdtablesize;
use wasmer_runtime_core::vm::Ctx;

pub fn setTempRet0(_ctx: &mut Ctx, _val: i32) {
debug!("emscripten::setTempRet0: {}", _val);
pub fn setTempRet0(ctx: &mut Ctx, val: i32) {
debug!("emscripten::setTempRet0: {}", val);
get_emscripten_data(ctx).temp_ret_0 = val;
}
pub fn getTempRet0(_ctx: &mut Ctx) -> i32 {

pub fn getTempRet0(ctx: &mut Ctx) -> i32 {
debug!("emscripten::getTempRet0");
0
get_emscripten_data(ctx).temp_ret_0
}

pub fn invoke_i(ctx: &mut Ctx, index: i32) -> i32 {
debug!("emscripten::invoke_i");
if let Some(dyn_call_i) = &get_emscripten_data(ctx).dyn_call_i {
Expand Down
2 changes: 2 additions & 0 deletions lib/emscripten/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ pub struct EmscriptenData<'a> {
pub dyn_call_vijiii: Option<Func<'a, (i32, i32, i32, i32, i32, i32, i32)>>,
pub dyn_call_vijj: Option<Func<'a, (i32, i32, i32, i32, i32, i32)>>,
pub dyn_call_viidii: Option<Func<'a, (i32, i32, i32, f64, i32, i32)>>,
pub temp_ret_0: i32,
}

impl<'a> EmscriptenData<'a> {
Expand Down Expand Up @@ -233,6 +234,7 @@ impl<'a> EmscriptenData<'a> {
dyn_call_vijiii,
dyn_call_vijj,
dyn_call_viidii,
temp_ret_0: 0,
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/emscripten/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ pub fn ___syscall85(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
}

pub fn ___syscall91(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
debug!("emscripten::___syscall91");
-1
debug!("emscripten::___syscall91 - stub");
0
}

pub fn ___syscall97(_ctx: &mut Ctx, _one: i32, _two: i32) -> i32 {
Expand Down

0 comments on commit 1c2f0e9

Please sign in to comment.