mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 06:15:33 +00:00
Hack together enough emscripten stack stuff to make it happy
This commit is contained in:
parent
ecc8199855
commit
a8b62ae8a5
@ -1,11 +1,7 @@
|
||||
/// 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 byteorder::{ByteOrder, LittleEndian};
|
||||
use std::mem;
|
||||
=======
|
||||
use crate::webassembly::{ImportObject, ImportValue};
|
||||
>>>>>>> Add some syscalls
|
||||
|
||||
// EMSCRIPTEN APIS
|
||||
mod env;
|
||||
|
@ -1,18 +1,8 @@
|
||||
|
||||
use crate::webassembly::{LinearMemory, Instance};
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub fn align_memory(ptr: u32) -> u32 {
|
||||
(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 {
|
||||
@ -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 {
|
||||
let old_static_top = *static_top;
|
||||
<<<<<<< HEAD
|
||||
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.
|
||||
*static_top = (*static_top + size + 15) & 4294967280;
|
||||
assert!(*static_top < total_memory, "not enough memory for static allocation - increase total_memory!");
|
||||
|
Loading…
Reference in New Issue
Block a user