Add importable memories and dynamic memories

This commit is contained in:
Lachlan Sneff
2019-01-25 15:28:54 -08:00
parent a20627964c
commit e4686e67c4
26 changed files with 992 additions and 694 deletions

View File

@ -7,7 +7,7 @@ use std::mem;
use wasmer_runtime_core::{
export::{Context, Export, FuncPointer, GlobalPointer},
import::{ImportObject, Namespace},
memory::LinearMemory,
memory::Memory,
types::{
FuncSig, GlobalDesc,
Type::{self, *},
@ -74,7 +74,7 @@ fn dynamictop_ptr(static_bump: u32) -> u32 {
// pub jumps: Vec<UnsafeCell<[c_int; 27]>>,
//}
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>();

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!(