Added support for conditional emscripten

This commit is contained in:
Syrus Akbary
2018-11-28 13:25:08 -08:00
parent 1f49f0358f
commit 02477b6e5e
7 changed files with 48 additions and 25 deletions

View File

@ -52,6 +52,10 @@ fn dynamictop_ptr(static_bump: u32) -> u32 {
pub fn emscripten_set_up_memory(memory: &mut LinearMemory) {
let dynamictop_ptr = dynamictop_ptr(STATIC_BUMP) as usize;
// We avoid failures of setting the u32
if (dynamictop_ptr > memory.len()) {
return;
}
let mem = &mut memory[dynamictop_ptr..dynamictop_ptr + mem::size_of::<u32>()];
LittleEndian::write_u32(mem, dynamic_base(STATIC_BUMP));
}