Hack together enough emscripten stack stuff to make it happy

This commit is contained in:
Lachlan Sneff 2018-11-25 23:56:21 -05:00
parent ecc8199855
commit a8b62ae8a5
2 changed files with 0 additions and 18 deletions

View File

@ -1,11 +1,7 @@
/// NOTE: TODO: These emscripten api implementation only support wasm32 for now because they assume offsets are u32 /// NOTE: TODO: These emscripten api implementation only support wasm32 for now because they assume offsets are u32
<<<<<<< HEAD
use crate::webassembly::{ImportObject, ImportValue, LinearMemory}; use crate::webassembly::{ImportObject, ImportValue, LinearMemory};
use byteorder::{ByteOrder, LittleEndian}; use byteorder::{ByteOrder, LittleEndian};
use std::mem; use std::mem;
=======
use crate::webassembly::{ImportObject, ImportValue};
>>>>>>> Add some syscalls
// EMSCRIPTEN APIS // EMSCRIPTEN APIS
mod env; mod env;

View File

@ -1,18 +1,8 @@
use crate::webassembly::{LinearMemory, Instance}; use crate::webassembly::{LinearMemory, Instance};
<<<<<<< HEAD
pub fn align_memory(ptr: u32) -> u32 { pub fn align_memory(ptr: u32) -> u32 {
(ptr + 15) & !15 (ptr + 15) & !15
=======
pub fn align_memory(size: u32, factor: u32) -> u32 {
assert!(factor != 0, "memory cannot be aligned by 0 offset!");
if size % factor == 1 {
(size) - (size % factor) + (factor)
} else {
size
}
>>>>>>> Add some syscalls
} }
// pub fn static_alloc(size: u32, instance: &mut Instance) -> u32 { // pub fn static_alloc(size: u32, instance: &mut Instance) -> u32 {
@ -25,11 +15,7 @@ pub fn align_memory(size: u32, factor: u32) -> u32 {
pub fn static_alloc(size: u32, static_top: &mut u32, memory: &LinearMemory) -> u32 { pub fn static_alloc(size: u32, static_top: &mut u32, memory: &LinearMemory) -> u32 {
let old_static_top = *static_top; let old_static_top = *static_top;
<<<<<<< HEAD
let total_memory = memory.maximum_size() * LinearMemory::PAGE_SIZE; let total_memory = memory.maximum_size() * LinearMemory::PAGE_SIZE;
=======
let total_memory = memory.maximum.unwrap_or(LinearMemory::MAX_PAGES as u32) * LinearMemory::PAGE_SIZE;
>>>>>>> Add some syscalls
// NOTE: The `4294967280` is a u32 conversion of -16 as gotten from emscripten. // NOTE: The `4294967280` is a u32 conversion of -16 as gotten from emscripten.
*static_top = (*static_top + size + 15) & 4294967280; *static_top = (*static_top + size + 15) & 4294967280;
assert!(*static_top < total_memory, "not enough memory for static allocation - increase total_memory!"); assert!(*static_top < total_memory, "not enough memory for static allocation - increase total_memory!");