Skip to content

Commit

Permalink
Merge pull request #173 from davidMcneil/172
Browse files Browse the repository at this point in the history
Fix emscripten environment (#172)
  • Loading branch information
syrusakbary authored Feb 17, 2019
2 parents cb29261 + a9b1c6c commit 7602071
Show file tree
Hide file tree
Showing 205 changed files with 67 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/emscripten/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ build = "build/mod.rs"

[dependencies]
wasmer-runtime-core = { path = "../runtime-core", version = "0.1.0" }
lazy_static = "1.2.0"
libc = { git = "https://github.com/rust-lang/libc" }
byteorder = "1"
time = "0.1.41"
Expand Down
Binary file modified lib/emscripten/emtests/FS_exports.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/clock_gettime.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/closebitcasts.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/dyncall.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/dyncall_specific.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/emscripten_get_compiler_setting.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/env.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/getValue_setValue.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/legacy_exported_runtime_numbers.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/localtime.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/modularize_closure_pre.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/printf.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/puts.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/stackAlloc.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/stack_overflow.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_addr_of_stacked.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_alloca.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_alloca_stack.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_array2.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_array2b.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_atoX.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_atomic.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_atomic_cxx.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_bsearch.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_ccall.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_complex.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_demangle_stacks.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_demangle_stacks_noassert.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_dlmalloc_partial_2.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_double_varargs.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_em_asm.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_em_asm_2.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_em_asm_parameter_pack.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_em_asm_signatures.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_em_asm_unicode.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_em_asm_unused_arguments.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_em_js.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_emscripten_api.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_emulate_function_pointer_casts.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_erf.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_errar.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_2.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_convert.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_destroy_virtual.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_libcxx.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_multi.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_multiple_inherit.wasm
Binary file not shown.
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_primary.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_refcount.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_resume.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_rethrow.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_simplify_cfg.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_std.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_virtual_inheritance.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_exceptions_white_list.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_fast_math.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_flexarray_struct.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_float32_precise.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_float_builtins.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_frexp.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_funcptr.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_funcptr_namecollide.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_funcptrfunc.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_funcs.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_functionpointer_libfunc_varargs.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_fwrite_0.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_getgep.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_getloadavg.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_getopt.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_getopt_long.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_globaldoubles.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_globals.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_gmtime.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_hello_world.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i16_emcc_intrinsic.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i32_mul_precise.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i64.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i64_4.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i64_7z.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i64_cmp2.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i64_i16.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i64_llabs.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i64_precise.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i64_precise_needed.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i64_precise_unneeded.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i64_qdouble.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i64_umul.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i64_varargs.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_i64_zextneg.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_if.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_if_else.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_indirectbr.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_indirectbr_many.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_intentional_fault.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_isnan.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_libcextra.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_libgen.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_literal_negative_zero.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_llrint.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_llvm_fabs.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_llvm_intrinsics.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_llvmswitch.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_longjmp.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_longjmp2.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_longjmp3.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_longjmp4.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_longjmp_exc.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_longjmp_funcptr.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_longjmp_repeat.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_longjmp_stacked.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_longjmp_throw.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_longjmp_unwind.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_loop.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_lower_intrinsics.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_main_module_static_align.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_main_thread_async_em_asm.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_mainenv.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_mathfuncptr.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_memcpy2.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_memcpy3.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_memcpy_memcmp.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_memmove.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_memmove2.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_memmove3.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_memorygrowth.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_memorygrowth_2.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_memorygrowth_3.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_memorygrowth_wasm_mem_max.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_memset.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_mmap.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_negative_zero.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_nested_struct_varargs.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_nl_types.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_perrar.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_phiundef.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_poll.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_posixtime.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_printf_2.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_printf_more.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_regex.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_relocatable_void_function.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_rounding.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_runtime_stacksave.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_set_align.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_siglongjmp.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sintvars.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sizeof.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sscanf.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sscanf_3.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sscanf_4.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sscanf_5.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sscanf_6.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sscanf_caps.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sscanf_float.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sscanf_hex.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sscanf_n.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sscanf_other_whitespace.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sscanf_skip.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_sscanf_whitespace.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_stack_align.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_stack_varargs.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_stack_void.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_statvfs.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_std_cout_new.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strcasecmp.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strcmp_uni.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strftime.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strings.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strndup.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strptime_days.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strptime_reentrant.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strstr.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strtod.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strtok.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strtol_bin.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strtol_dec.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strtol_hex.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strtol_oct.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strtold.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strtoll_bin.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strtoll_dec.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strtoll_hex.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_strtoll_oct.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_struct_varargs.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_time_c.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_tracing.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_transtrcase.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_trickystring.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_uname.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_unary_literal.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_utf.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_varargs.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_varargs_multi.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_vprintf.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_vsnprintf.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_wprintf.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_write_stdout_fileno.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_zero_multiplication.wasm
Binary file not shown.
Binary file modified lib/emscripten/emtests/test_zerodiv.wasm
Binary file not shown.
44 changes: 41 additions & 3 deletions lib/emscripten/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[macro_use]
extern crate wasmer_runtime_core;

use lazy_static::lazy_static;
use std::cell::UnsafeCell;
use std::{f64, ffi::c_void};
use wasmer_runtime_core::{
Expand All @@ -11,11 +12,12 @@ use wasmer_runtime_core::{
import::ImportObject,
imports,
memory::Memory,
module::ImportName,
table::Table,
types::{ElementType, MemoryDescriptor, TableDescriptor, Value},
types::{ElementType, FuncSig, MemoryDescriptor, TableDescriptor, Type, Value},
units::Pages,
vm::Ctx,
Func, Instance, Module,
Func, Instance, IsExport, Module,
};

#[macro_use]
Expand Down Expand Up @@ -56,6 +58,11 @@ const DYNAMICTOP_PTR_DIFF: u32 = 1088;
// TODO: make this variable
const STATIC_BUMP: u32 = 215_536;

lazy_static! {
static ref OLD_ABORT_ON_CANNOT_GROW_MEMORY_SIG: FuncSig =
{ FuncSig::new(vec![], vec![Type::I32]) };
}

// The address globals begin at. Very low in memory, for code size and optimization opportunities.
// Above 0 is static memory, starting with globals.
// Then the stack.
Expand Down Expand Up @@ -187,6 +194,7 @@ pub struct EmscriptenGlobalsData {
memory_base: u32,
table_base: u32,
temp_double_ptr: u32,
use_old_abort_on_cannot_grow_memory: bool,

// Global namespace
infinity: f64,
Expand All @@ -205,6 +213,27 @@ pub struct EmscriptenGlobals {

impl EmscriptenGlobals {
pub fn new(module: &Module /*, static_bump: u32 */) -> Self {
let mut use_old_abort_on_cannot_grow_memory = false;
for (
index,
ImportName {
namespace_index,
name_index,
},
) in &module.0.info.imported_functions
{
let namespace = module.0.info.namespace_table.get(*namespace_index);
let name = module.0.info.name_table.get(*name_index);
if name == "abortOnCannotGrowMemory" && namespace == "env" {
let sig_index = module.0.info.func_assoc[index.convert_up(&module.0)];
let expected_sig = &module.0.info.signatures[sig_index];
if **expected_sig == *OLD_ABORT_ON_CANNOT_GROW_MEMORY_SIG {
use_old_abort_on_cannot_grow_memory = true;
}
break;
}
}

let (table_min, table_max) = get_emscripten_table_size(&module);
let (memory_min, memory_max) = get_emscripten_memory_size(&module);

Expand Down Expand Up @@ -247,6 +276,7 @@ impl EmscriptenGlobals {
memory_base,
table_base,
temp_double_ptr,
use_old_abort_on_cannot_grow_memory,

infinity: std::f64::INFINITY,
nan: std::f64::NAN,
Expand All @@ -266,6 +296,12 @@ impl EmscriptenGlobals {
}

pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject {
let abort_on_cannot_grow_memory_export = if globals.data.use_old_abort_on_cannot_grow_memory {
func!(crate::memory::abort_on_cannot_grow_memory_old).to_export()
} else {
func!(crate::memory::abort_on_cannot_grow_memory).to_export()
};

imports! {
"env" => {
"memory" => Export::Memory(globals.memory.clone()),
Expand Down Expand Up @@ -409,8 +445,10 @@ pub fn generate_emscripten_env(globals: &mut EmscriptenGlobals) -> ImportObject
"_sigsuspend" => func!(crate::signal::_sigsuspend),

// Memory
"abortOnCannotGrowMemory" => func!(crate::memory::abort_on_cannot_grow_memory),
"abortOnCannotGrowMemory" => abort_on_cannot_grow_memory_export,
"_emscripten_memcpy_big" => func!(crate::memory::_emscripten_memcpy_big),
"_emscripten_get_heap_size" => func!(crate::memory::_emscripten_get_heap_size),
"_emscripten_resize_heap" => func!(crate::memory::_emscripten_resize_heap),
"enlargeMemory" => func!(crate::memory::enlarge_memory),
"getTotalMemory" => func!(crate::memory::get_total_memory),
"___map_file" => func!(crate::memory::___map_file),
Expand Down
23 changes: 22 additions & 1 deletion lib/emscripten/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ pub fn _emscripten_memcpy_big(ctx: &mut Ctx, dest: u32, src: u32, len: u32) -> u
dest
}

/// emscripten: _emscripten_get_heap_size
pub fn _emscripten_get_heap_size(ctx: &mut Ctx) -> u32 {
debug!("emscripten::_emscripten_get_heap_size",);
// TODO: Fix implementation
16_777_216
}

/// emscripten: _emscripten_resize_heap
pub fn _emscripten_resize_heap(ctx: &mut Ctx, requested_size: u32) -> u32 {
debug!("emscripten::_emscripten_resize_heap {}", requested_size);
// TODO: Fix implementation
0
}

/// emscripten: getTotalMemory
pub fn get_total_memory(_ctx: &mut Ctx) -> u32 {
debug!("emscripten::get_total_memory");
Expand All @@ -33,7 +47,14 @@ pub fn enlarge_memory(_ctx: &mut Ctx) -> u32 {
}

/// emscripten: abortOnCannotGrowMemory
pub fn abort_on_cannot_grow_memory(ctx: &mut Ctx) -> u32 {
pub fn abort_on_cannot_grow_memory(ctx: &mut Ctx, requested_size: u32) -> u32 {
debug!("emscripten::abort_on_cannot_grow_memory {}", requested_size);
abort_with_message(ctx, "Cannot enlarge memory arrays!");
0
}

/// emscripten: abortOnCannotGrowMemory
pub fn abort_on_cannot_grow_memory_old(ctx: &mut Ctx) -> u32 {
debug!("emscripten::abort_on_cannot_grow_memory");
abort_with_message(ctx, "Cannot enlarge memory arrays!");
0
Expand Down
2 changes: 2 additions & 0 deletions lib/runtime-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ use self::error::CompileResult;
#[doc(inline)]
pub use self::error::Result;
#[doc(inline)]
pub use self::import::IsExport;
#[doc(inline)]
pub use self::instance::Instance;
#[doc(inline)]
pub use self::module::Module;
Expand Down

0 comments on commit 7602071

Please sign in to comment.