summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild.sh2
-rw-r--r--src/wasm-js.cpp13
2 files changed, 12 insertions, 3 deletions
diff --git a/build.sh b/build.sh
index 0e104532f..d4f0825f8 100755
--- a/build.sh
+++ b/build.sh
@@ -1,6 +1,6 @@
echo "building asm2wasm"
g++ -O2 -std=c++11 src/asm2wasm-main.cpp src/parser.cpp src/simple_ast.cpp src/optimizer-shared.cpp -g -o bin/asm2wasm
echo "building interpreter/js"
-em++ -std=c++11 src/wasm-js.cpp src/parser.cpp src/simple_ast.cpp src/optimizer-shared.cpp -o bin/wasm.js -s MODULARIZE=1 -s 'EXPORT_NAME="WasmJS"' --memory-init-file 0 -s DEMANGLE_SUPPORT=1 -O3 -profiling -s TOTAL_MEMORY=67108864 #-DWASM_INTERPRETER_DEBUG
+em++ -std=c++11 src/wasm-js.cpp src/parser.cpp src/simple_ast.cpp src/optimizer-shared.cpp -o bin/wasm.js -s MODULARIZE=1 -s 'EXPORT_NAME="WasmJS"' --memory-init-file 0 -s DEMANGLE_SUPPORT=1 -O3 -profiling -s TOTAL_MEMORY=67108864 -s SAFE_HEAP=1 #-DWASM_INTERPRETER_DEBUG
cat src/js/post.js >> bin/wasm.js
diff --git a/src/wasm-js.cpp b/src/wasm-js.cpp
index 36ce6c4c7..2ee6e9683 100644
--- a/src/wasm-js.cpp
+++ b/src/wasm-js.cpp
@@ -167,8 +167,17 @@ extern "C" double EMSCRIPTEN_KEEPALIVE call_from_js(const char *target) {
assert(instance->functions.find(name) != instance->functions.end());
Function *function = instance->functions[name];
size_t num = EM_ASM_INT_V({ return Module['tempArguments'].length });
- assert(num == function->params.size()); // TODO: fake missing/extra args?
-
+ if (num != function->params.size()) {
+ std::cerr << "warning: bad # of arguments to " << target << ": got " << num << ", but expect " << function->params.size() << '\n';
+ abort(); // TODO: fake missing/extra args?
+#if 0
+ if (num > function->params.size()) {
+ num = function->params.size(); // ignore the rest
+ } else {
+ .. fake missing ..
+ }
+#endif
+ }
ModuleInstance::LiteralList arguments;
for (size_t i = 0; i < num; i++) {
WasmType type = function->params[i].type;