Fixup/comment out to get things compiling

This commit is contained in:
Brandon Fish
2019-01-29 23:08:03 -06:00
parent 30caeb0810
commit cf325f7cd6
7 changed files with 1998 additions and 1990 deletions

View File

@ -7,19 +7,20 @@ use wasmer_runtime_core::vm::Ctx;
pub extern "C" fn __setjmp(env_addr: u32, ctx: &mut Ctx) -> c_int { pub extern "C" fn __setjmp(env_addr: u32, ctx: &mut Ctx) -> c_int {
debug!("emscripten::__setjmp (setjmp)"); debug!("emscripten::__setjmp (setjmp)");
unsafe { unsafe {
// Rather than using the env as the holder of the jump buffer pointer, unimplemented!()
// we use the environment address to store the index relative to jumps // // Rather than using the env as the holder of the jump buffer pointer,
// so the address of the jump it's outside the wasm memory itself. // // we use the environment address to store the index relative to jumps
let jump_index = ctx.memory(0).as_ptr().add(env_addr as usize) as *mut i8; // // so the address of the jump it's outside the wasm memory itself.
// We create the jump buffer outside of the wasm memory // let jump_index = ctx.memory(0).as_ptr().add(env_addr as usize) as *mut i8;
let jump_buf: UnsafeCell<[c_int; 27]> = UnsafeCell::new([0; 27]); // // We create the jump buffer outside of the wasm memory
let jumps = &mut get_emscripten_data(ctx).jumps; // let jump_buf: UnsafeCell<[c_int; 27]> = UnsafeCell::new([0; 27]);
let result = setjmp(jump_buf.get() as _); // let jumps = &mut get_emscripten_data(ctx).jumps;
// We set the jump index to be the last value of jumps // let result = setjmp(jump_buf.get() as _);
*jump_index = jumps.len() as _; // // We set the jump index to be the last value of jumps
// We hold the reference of the jump buffer // *jump_index = jumps.len() as _;
jumps.push(jump_buf); // // We hold the reference of the jump buffer
result // jumps.push(jump_buf);
// result
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
macro_rules! emscripten_memory_pointer { macro_rules! emscripten_memory_pointer {
($memory:expr, $pointer:expr) => { ($memory:expr, $pointer:expr) => {
unsafe { $memory.as_ptr().add($pointer as usize) } 0 as usize
// unsafe { $memory.as_ptr().add($pointer as usize) }
}; };
} }

View File

@ -9,6 +9,7 @@ use wasmer_runtime_core::{
module::Module, module::Module,
structures::TypedIndex, structures::TypedIndex,
types::{ImportedMemoryIndex, ImportedTableIndex}, types::{ImportedMemoryIndex, ImportedTableIndex},
units::Pages,
vm::Ctx, vm::Ctx,
}; };
@ -24,12 +25,12 @@ pub fn is_emscripten_module(module: &Module) -> bool {
pub fn get_emscripten_table_size(module: &Module) -> (u32, Option<u32>) { pub fn get_emscripten_table_size(module: &Module) -> (u32, Option<u32>) {
let (_, table) = &module.0.imported_tables[ImportedTableIndex::new(0)]; let (_, table) = &module.0.imported_tables[ImportedTableIndex::new(0)];
(table.min, table.max) (table.minimum, table.maximum)
} }
pub fn get_emscripten_memory_size(module: &Module) -> (u32, Option<u32>) { pub fn get_emscripten_memory_size(module: &Module) -> (Pages, Option<Pages>) {
let (_, memory) = &module.0.imported_memories[ImportedMemoryIndex::new(0)]; let (_, memory) = &module.0.imported_memories[ImportedMemoryIndex::new(0)];
(memory.min, memory.max) (memory.minimum, memory.maximum)
} }
pub unsafe fn write_to_buf(string: *const c_char, buf: u32, max: u32, ctx: &mut Ctx) -> u32 { pub unsafe fn write_to_buf(string: *const c_char, buf: u32, max: u32, ctx: &mut Ctx) -> u32 {

View File

@ -195,9 +195,6 @@ impl Instance {
Module::new(Arc::clone(&self.module)) Module::new(Arc::clone(&self.module))
} }
pub fn ctx(&mut self) -> &mut vm::Ctx {
&mut self.inner.vmctx
}
} }
impl Instance { impl Instance {

View File

@ -230,7 +230,7 @@ impl Memory {
f(t_buffer) f(t_buffer)
} }
pub(crate) fn vm_local_memory(&mut self) -> *mut vm::LocalMemory { pub fn vm_local_memory(&mut self) -> *mut vm::LocalMemory {
&mut *self.storage.borrow_mut().1 &mut *self.storage.borrow_mut().1
} }
} }

View File

@ -112,7 +112,7 @@ impl Table {
} }
} }
pub(crate) fn vm_local_table(&mut self) -> *mut vm::LocalTable { pub fn vm_local_table(&mut self) -> *mut vm::LocalTable {
&mut self.storage.borrow_mut().1 &mut self.storage.borrow_mut().1
} }
} }