Merge branch 'master' into fix/emscripten-translate

This commit is contained in:
Brandon Fish
2019-01-29 23:07:32 -06:00
46 changed files with 2510 additions and 1514 deletions

View File

@ -5,16 +5,17 @@ use libc::c_int;
use std::cell::UnsafeCell;
use std::{ffi::c_void, fmt, mem, ptr};
use wasmer_runtime_core::{
error::CallResult,
export::{Context, Export, FuncPointer, GlobalPointer, MemoryPointer, TablePointer},
export::{Context, Export, FuncPointer},
func,
global::Global,
import::{ImportObject, Namespace},
instance::Instance,
memory::LinearMemory,
module::Module,
structures::TypedIndex,
table::TableBacking,
types::{ElementType, FuncSig, GlobalDesc, LocalMemoryIndex, Memory, Table, Type::*, Value},
vm::Ctx,
imports,
memory::Memory,
table::Table,
types::{
FuncSig, GlobalDescriptor,
Type::{self, *},
},
vm::LocalGlobal,
vm::LocalMemory,
vm::LocalTable,
@ -196,23 +197,24 @@ fn store_module_arguments(path: &str, args: Vec<&str>, ctx: &mut Ctx) -> (u32, u
(argc as u32, argv_offset)
}
pub fn emscripten_set_up_memory(memory: &mut LinearMemory) {
pub fn emscripten_set_up_memory(memory: &mut Memory) {
let dynamictop_ptr = dynamictop_ptr(STATIC_BUMP) as usize;
let dynamictop_ptr_offset = dynamictop_ptr + mem::size_of::<u32>();
// println!("value = {:?}");
// We avoid failures of setting the u32 in our memory if it's out of bounds
if dynamictop_ptr_offset > memory.len() {
return; // TODO: We should panic instead?
}
// debug!("###### dynamic_base = {:?}", dynamic_base(STATIC_BUMP));
// debug!("###### dynamictop_ptr = {:?}", dynamictop_ptr);
// debug!("###### dynamictop_ptr_offset = {:?}", dynamictop_ptr_offset);
let mem = &mut memory[dynamictop_ptr..dynamictop_ptr_offset];
LittleEndian::write_u32(mem, dynamic_base(STATIC_BUMP));
unimplemented!()
// if dynamictop_ptr_offset > memory.len() {
// return; // TODO: We should panic instead?
// }
//
// // debug!("###### dynamic_base = {:?}", dynamic_base(STATIC_BUMP));
// // debug!("###### dynamictop_ptr = {:?}", dynamictop_ptr);
// // debug!("###### dynamictop_ptr_offset = {:?}", dynamictop_ptr_offset);
//
// let mem = &mut memory[dynamictop_ptr..dynamictop_ptr_offset];
// LittleEndian::write_u32(mem, dynamic_base(STATIC_BUMP));
}
macro_rules! mock_external {

View File

@ -1,7 +1,3 @@
macro_rules! debug {
($fmt:expr) => (if cfg!(any(debug_assertions, feature="debug")) { println!(concat!("wasmer-runtime(:{})::", $fmt), line!()) });
($fmt:expr, $($arg:tt)*) => (if cfg!(any(debug_assertions, feature="debug")) { println!(concat!("wasmer-runtime(:{})::", $fmt, "\n"), line!(), $($arg)*) });
}
macro_rules! emscripten_memory_pointer {
($memory:expr, $pointer:expr) => {

View File

@ -1,12 +1,12 @@
// use crate::webassembly::LinearMemory;
// use crate::webassembly::Memory;
pub fn align_memory(ptr: u32) -> u32 {
(ptr + 15) & !15
}
// pub fn static_alloc(size: u32, static_top: &mut u32, memory: &LinearMemory) -> u32 {
// pub fn static_alloc(size: u32, static_top: &mut u32, memory: &Memory) -> u32 {
// let old_static_top = *static_top;
// let total_memory = memory.maximum_size() * LinearMemory::PAGE_SIZE;
// let total_memory = memory.maximum_size() * Memory::PAGE_SIZE;
// // NOTE: The `4294967280` is a u32 conversion of -16 as gotten from emscripten.
// *static_top = (*static_top + size + 15) & 4294967280;
// assert!(