mirror of
https://github.com/fluencelabs/wasmer
synced 2025-03-31 23:11:04 +00:00
Addd stack_save, stack_restore and set_threw for longjmp
This commit is contained in:
parent
3b11da91c5
commit
dc3c2227dc
@ -37,6 +37,18 @@ pub fn __longjmp(ctx: &mut Ctx, env_addr: u32, val: c_int) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// _longjmp
|
||||||
|
pub fn _longjmp(ctx: &mut Ctx, env_addr: i32, val: c_int) {
|
||||||
|
let val = if val == 0 {
|
||||||
|
1
|
||||||
|
} else {
|
||||||
|
val
|
||||||
|
};
|
||||||
|
get_emscripten_data(ctx).set_threw.as_ref().expect("set_threw is None").call(env_addr, val).expect("set_threw failed to call");
|
||||||
|
panic!("longjmp");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn setjmp(env: *mut c_void) -> c_int;
|
fn setjmp(env: *mut c_void) -> c_int;
|
||||||
fn longjmp(env: *mut c_void, val: c_int) -> !;
|
fn longjmp(env: *mut c_void, val: c_int) -> !;
|
||||||
|
@ -127,6 +127,10 @@ pub struct EmscriptenData<'a> {
|
|||||||
pub dyn_call_vijj: Option<Func<'a, (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 dyn_call_viidii: Option<Func<'a, (i32, i32, i32, f64, i32, i32)>>,
|
||||||
pub temp_ret_0: i32,
|
pub temp_ret_0: i32,
|
||||||
|
|
||||||
|
pub stack_save: Option<Func<'a, (), i32>>,
|
||||||
|
pub stack_restore: Option<Func<'a, (i32)>>,
|
||||||
|
pub set_threw: Option<Func<'a, (i32, i32)>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> EmscriptenData<'a> {
|
impl<'a> EmscriptenData<'a> {
|
||||||
@ -186,6 +190,10 @@ impl<'a> EmscriptenData<'a> {
|
|||||||
let dyn_call_vijj = instance.func("dynCall_vijj").ok();
|
let dyn_call_vijj = instance.func("dynCall_vijj").ok();
|
||||||
let dyn_call_viidii = instance.func("dynCall_viidii").ok();
|
let dyn_call_viidii = instance.func("dynCall_viidii").ok();
|
||||||
|
|
||||||
|
let stack_save = instance.func("stackSave").ok();
|
||||||
|
let stack_restore = instance.func("stackRestore").ok();
|
||||||
|
let set_threw = instance.func("_setThrew").ok();
|
||||||
|
|
||||||
EmscriptenData {
|
EmscriptenData {
|
||||||
malloc,
|
malloc,
|
||||||
free,
|
free,
|
||||||
@ -238,6 +246,10 @@ impl<'a> EmscriptenData<'a> {
|
|||||||
dyn_call_vijj,
|
dyn_call_vijj,
|
||||||
dyn_call_viidii,
|
dyn_call_viidii,
|
||||||
temp_ret_0: 0,
|
temp_ret_0: 0,
|
||||||
|
|
||||||
|
stack_save,
|
||||||
|
stack_restore,
|
||||||
|
set_threw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -650,7 +662,8 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
|
|||||||
// Jump
|
// Jump
|
||||||
"__setjmp" => func!(crate::jmp::__setjmp),
|
"__setjmp" => func!(crate::jmp::__setjmp),
|
||||||
"__longjmp" => func!(crate::jmp::__longjmp),
|
"__longjmp" => func!(crate::jmp::__longjmp),
|
||||||
"_longjmp" => func!(crate::jmp::__longjmp),
|
"_longjmp" => func!(crate::jmp::_longjmp),
|
||||||
|
"_emscripten_longjmp" => func!(crate::jmp::_longjmp),
|
||||||
|
|
||||||
// Bitwise
|
// Bitwise
|
||||||
"_llvm_bswap_i64" => func!(crate::bitwise::_llvm_bswap_i64),
|
"_llvm_bswap_i64" => func!(crate::bitwise::_llvm_bswap_i64),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user