diff options
author | Alon Zakai <azakai@google.com> | 2022-09-13 15:10:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-13 22:10:00 +0000 |
commit | 795a70b02032f57f14d97d7555af97f0e527b4b0 (patch) | |
tree | ec3f0625ddfef2b831b1801990a39eafb912d328 /src/ir/effects.h | |
parent | f1a3e682e864fcb827a01d3c5725d847053fe149 (diff) | |
download | binaryen-795a70b02032f57f14d97d7555af97f0e527b4b0.tar.gz binaryen-795a70b02032f57f14d97d7555af97f0e527b4b0.tar.bz2 binaryen-795a70b02032f57f14d97d7555af97f0e527b4b0.zip |
[Exceptions] Optimize in CodePushing even with exceptions thrown (#5028)
We had some concerns about this not working in the past, but thinking about it
now, I believe it is safe to do. Specifically, a throw is either like a break or a return -
either it jumps out to an outer scope (like a break) or it jumps out of the function
(like a return), and both breaks and returns have already been handled here.
This change has some nice effects on J2Wasm output, where there are quite a
lot of throws, which we can now optimize around.
Diffstat (limited to 'src/ir/effects.h')
-rw-r--r-- | src/ir/effects.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ir/effects.h b/src/ir/effects.h index d3ae9ba20..ad3ab235d 100644 --- a/src/ir/effects.h +++ b/src/ir/effects.h @@ -881,9 +881,19 @@ public: return effects; } - void ignoreBranches() { + // Ignores all forms of control flow transfers: breaks, returns, and + // exceptions. (Note that traps are not considered relevant here - a trap does + // not just transfer control flow, but can be seen as halting the entire + // program.) + // + // This function matches transfersControlFlow(), that is, after calling this + // method transfersControlFlow() will always return false. + void ignoreControlFlowTransfers() { branchesOut = false; breakTargets.clear(); + throws_ = false; + delegateTargets.clear(); + assert(!transfersControlFlow()); } private: |