summaryrefslogtreecommitdiff
path: root/src/s2wasm.h
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2016-06-10 13:08:58 -0700
committerGitHub <noreply@github.com>2016-06-10 13:08:58 -0700
commit996262dcdb88388717aab72bd8f37841aaabb24c (patch)
tree638216583c72db4b2dcffb77dc39e045742dc803 /src/s2wasm.h
parent59542c98459771905ef25c5fe48079f3353d6869 (diff)
downloadbinaryen-996262dcdb88388717aab72bd8f37841aaabb24c.tar.gz
binaryen-996262dcdb88388717aab72bd8f37841aaabb24c.tar.bz2
binaryen-996262dcdb88388717aab72bd8f37841aaabb24c.zip
s2wasm: Validate the result module (#574)
Add an s2wasm option `--no-validate` to disable validation for debugging purposes. Also fix several validation errors by adding calls to `finalize()` after creating expressions, and ensuring that an import is created earlier in `Linker::getImportThunk`.
Diffstat (limited to 'src/s2wasm.h')
-rw-r--r--src/s2wasm.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h
index afebd4d9c..bf66f4407 100644
--- a/src/s2wasm.h
+++ b/src/s2wasm.h
@@ -732,6 +732,7 @@ class S2WasmBuilder {
auto curr = allocator->alloc<Host>();
curr->op = op;
curr->operands.push_back(getInput());
+ curr->finalize();
setOutput(curr, assign);
};
auto makeLoad = [&](WasmType type) {
@@ -1028,8 +1029,12 @@ class S2WasmBuilder {
bstack.push_back(block);
bstack.push_back(curr);
} else if (match("end_loop")) {
+ auto* loop = bstack.back()->cast<Loop>();
bstack.pop_back();
+ auto* implicitBlock = bstack.back()->cast<Block>();
bstack.pop_back();
+ implicitBlock->finalize();
+ loop->finalize();
} else if (match("br_table")) {
auto curr = allocator->alloc<Switch>();
curr->condition = getInput();
@@ -1052,6 +1057,7 @@ class S2WasmBuilder {
skipComma();
curr->condition = getInput();
}
+ curr->finalize();
addToBlock(curr);
} else if (match("call")) {
makeCall(none);