diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-stack.h | 2 | ||||
-rw-r--r-- | src/wasm/wasm-stack.cpp | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/wasm-stack.h b/src/wasm-stack.h index 7f94573fa..5af9adbce 100644 --- a/src/wasm-stack.h +++ b/src/wasm-stack.h @@ -350,6 +350,8 @@ template<typename SubType> void BinaryenIRWriter<SubType>::visitTry(Try* curr) { } if (curr->isDelegate()) { emitDelegate(curr); + // Note that when we emit a delegate we do not need to also emit a scope + // ending, as the delegate ends the scope. } else { emitScopeEnd(curr); } diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp index b6c0392ca..4c4e4e9d1 100644 --- a/src/wasm/wasm-stack.cpp +++ b/src/wasm/wasm-stack.cpp @@ -1925,6 +1925,9 @@ void BinaryInstWriter::emitCatchAll(Try* curr) { } void BinaryInstWriter::emitDelegate(Try* curr) { + // The delegate ends the scope in effect, and pops the try's name. Note that + // the getBreakIndex is intentionally after that pop, as the delegate cannot + // target its own try. assert(!breakStack.empty()); breakStack.pop_back(); o << int8_t(BinaryConsts::Delegate) @@ -2333,6 +2336,8 @@ void StackIRToBinaryWriter::write() { } case StackInst::Delegate: { writer.emitDelegate(inst->origin->cast<Try>()); + // Delegates end the try, like a TryEnd. + catchIndexStack.pop_back(); break; } default: |