summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-binary.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2020-03-03 18:49:31 -0800
committerGitHub <noreply@github.com>2020-03-03 18:49:31 -0800
commit2a0f6a513c6d6a99d16ca31de3e76a63b1490b4c (patch)
tree827e9de92f19a204eafd53369a442b302ef73f32 /src/wasm/wasm-binary.cpp
parent6371cf63687c3f638b599e086ca668c04a26cbbb (diff)
downloadbinaryen-2a0f6a513c6d6a99d16ca31de3e76a63b1490b4c.tar.gz
binaryen-2a0f6a513c6d6a99d16ca31de3e76a63b1490b4c.tar.bz2
binaryen-2a0f6a513c6d6a99d16ca31de3e76a63b1490b4c.zip
Improve a comment on unreachability [ci skip] (#2672)
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r--src/wasm/wasm-binary.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 538f66043..278a9ef44 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -2394,8 +2394,19 @@ void WasmBinaryBuilder::pushBlockElements(Block* curr,
}
// Everything else on the stack after `start` is either a none-type expression
// or a concretely-type expression that is implicitly dropped due to
- // unreachability at the end of the block. Because these expressions may have
- // side effects, preserve them by making the drop explicit.
+ // unreachability at the end of the block, like this:
+ //
+ // block i32
+ // i32.const 1
+ // i32.const 2
+ // i32.const 3
+ // return
+ // end
+ //
+ // The first two const elements will be emitted as drops in the block (the
+ // optimizer can remove them, of course, but in general we may need dropped
+ // items here as they may have side effects).
+ //
for (size_t i = start; i < expressionStack.size(); ++i) {
auto* item = expressionStack[i];
if (item->type.isConcrete()) {