diff options
author | Heejin Ahn <aheejin@gmail.com> | 2022-01-04 16:54:38 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-04 16:54:38 -0800 |
commit | 6b73aacf78d9883bff9890efa1ea00636be99ea3 (patch) | |
tree | 70b89845a7526178b4312196ae8db3479ab4b308 /src/wasm/wasm-binary.cpp | |
parent | 16ac2eb73a57eb530f78b632cffacac97c6b8fdd (diff) | |
download | binaryen-6b73aacf78d9883bff9890efa1ea00636be99ea3.tar.gz binaryen-6b73aacf78d9883bff9890efa1ea00636be99ea3.tar.bz2 binaryen-6b73aacf78d9883bff9890efa1ea00636be99ea3.zip |
[EH] Fixup nested pops after reading stacky binary (#4420)
When reading stacky code in the binary reader, we create `block`s to
make it fit into Binaryen AST, within which `pop`s can be nested, making
the resulting AST invalid. This PR runs the fixup function after reading
each `Try` to fix this.
Diffstat (limited to 'src/wasm/wasm-binary.cpp')
-rw-r--r-- | src/wasm/wasm-binary.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index d8a3c2f74..57a2bc95c 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -17,6 +17,7 @@ #include <algorithm> #include <fstream> +#include "ir/eh-utils.h" #include "ir/module-utils.h" #include "ir/table-utils.h" #include "ir/type-updating.h" @@ -6419,6 +6420,10 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) { } exceptionTargetNames.erase(catchLabel); } + + // If catch bodies contained stacky code, 'pop's can be nested within a block. + // Fix that up. + EHUtils::handleBlockNestedPop(curr, currFunction, wasm); curr->finalize(curr->type); // For simplicity, we create an inner block within the catch body too, but the |