summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-08-03 14:49:41 -0700
committerAlon Zakai (kripken) <alonzakai@gmail.com>2017-08-05 13:45:27 -0700
commit5b9fff4399b959a4af28a6c82e8ab9243898f360 (patch)
tree5007f2b6e3f5ff0a18b20ae4e9b1e442405985a7 /src
parent9149f4cdeee0949e5dab4b0e0e076c73b822cbfc (diff)
downloadbinaryen-5b9fff4399b959a4af28a6c82e8ab9243898f360.tar.gz
binaryen-5b9fff4399b959a4af28a6c82e8ab9243898f360.tar.bz2
binaryen-5b9fff4399b959a4af28a6c82e8ab9243898f360.zip
emit an unreachable if an unreachable block context does not end in an unreachable
Diffstat (limited to 'src')
-rw-r--r--src/wasm/wasm-binary.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 018e463e0..63dddbdd6 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -583,6 +583,11 @@ void WasmBinaryWriter::recursePossibleBlockContents(Expression* curr) {
for (auto* child : block->list) {
recurse(child);
}
+ if (block->type == unreachable && block->list.back()->type != unreachable) {
+ // similar to in visitBlock, here we could skip emitting the block itself,
+ // but must still end the 'block' (the contents, really) with an unreachable
+ o << int8_t(BinaryConsts::Unreachable);
+ }
}
void WasmBinaryWriter::visitIf(If *curr) {