summaryrefslogtreecommitdiff
path: root/src/wasm2js.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2019-04-23 14:26:57 -0700
committerGitHub <noreply@github.com>2019-04-23 14:26:57 -0700
commit4c3297bba82905994a36e52701696be412573b3f (patch)
tree511b141c9ee6e09e8a652ac3de757f6496b854f4 /src/wasm2js.h
parent455f431260efbd48f018259bf8db544e1b9d03c4 (diff)
downloadbinaryen-4c3297bba82905994a36e52701696be412573b3f.tar.gz
binaryen-4c3297bba82905994a36e52701696be412573b3f.tar.bz2
binaryen-4c3297bba82905994a36e52701696be412573b3f.zip
wasm2js: emit calls for memory growth helper only if memory growth is used (#2042)
Diffstat (limited to 'src/wasm2js.h')
-rw-r--r--src/wasm2js.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/wasm2js.h b/src/wasm2js.h
index d77b6d06c..0bccf7dee 100644
--- a/src/wasm2js.h
+++ b/src/wasm2js.h
@@ -1529,18 +1529,19 @@ Ref Wasm2JSBuilder::processFunctionBody(Module* m, Function* func) {
}
Ref visitHost(Host* curr) {
- Ref call;
if (curr->op == HostOp::GrowMemory) {
- call = ValueBuilder::makeCall(WASM_GROW_MEMORY,
- makeAsmCoercion(
- visit(curr->operands[0], EXPRESSION_RESULT),
- wasmToAsmType(curr->operands[0]->type)));
+ if (module->memory.exists && module->memory.max > module->memory.initial) {
+ return ValueBuilder::makeCall(WASM_GROW_MEMORY,
+ makeAsmCoercion(
+ visit(curr->operands[0], EXPRESSION_RESULT),
+ wasmToAsmType(curr->operands[0]->type)));
+ } else {
+ return ValueBuilder::makeCall(ABORT_FUNC);
+ }
} else if (curr->op == HostOp::CurrentMemory) {
- call = ValueBuilder::makeCall(WASM_CURRENT_MEMORY);
- } else {
- return ValueBuilder::makeCall(ABORT_FUNC);
+ return ValueBuilder::makeCall(WASM_CURRENT_MEMORY);
}
- return call;
+ WASM_UNREACHABLE(); // TODO
}
Ref visitNop(Nop* curr) {