From 2a0f6a513c6d6a99d16ca31de3e76a63b1490b4c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 3 Mar 2020 18:49:31 -0800 Subject: Improve a comment on unreachability [ci skip] (#2672) --- src/wasm/wasm-binary.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/wasm/wasm-binary.cpp') 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()) { -- cgit v1.2.3