diff options
author | Heejin Ahn <aheejin@gmail.com> | 2020-02-19 02:06:31 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-19 02:06:31 -0800 |
commit | eca1a663fead59b2b70271a96abb6793e366b7e6 (patch) | |
tree | 6dd931afad2ee031e760c8a54c7647d49a3c17bc /src | |
parent | 4b79514283d5f6a4fdd058690b78b3bd97e193b0 (diff) | |
download | binaryen-eca1a663fead59b2b70271a96abb6793e366b7e6.tar.gz binaryen-eca1a663fead59b2b70271a96abb6793e366b7e6.tar.bz2 binaryen-eca1a663fead59b2b70271a96abb6793e366b7e6.zip |
Code pushing support for br_on_exn (#2660)
Like `br_if`, `br_on_exn` is a conditional branch and across which code
can be pushed past when conditions are satisfied.
Also adds a few lines of comments and NFC changes in a couple places.
Changes in Vacuum are NFC because they were being handled in `default:`
in the same way anyway, but I added them to be more explicit and
consistent with existing code.
Diffstat (limited to 'src')
-rw-r--r-- | src/dataflow/graph.h | 2 | ||||
-rw-r--r-- | src/passes/CodePushing.cpp | 2 | ||||
-rw-r--r-- | src/passes/Vacuum.cpp | 3 | ||||
-rw-r--r-- | src/wasm-traversal.h | 2 |
4 files changed, 7 insertions, 2 deletions
diff --git a/src/dataflow/graph.h b/src/dataflow/graph.h index 41b145ee9..02679995b 100644 --- a/src/dataflow/graph.h +++ b/src/dataflow/graph.h @@ -198,6 +198,8 @@ struct Graph : public UnifiedExpressionVisitor<Graph, Node*> { // Visiting. Node* visitExpression(Expression* curr) { + // TODO Exception handling instruction support + // Control flow and get/set etc. are special. Aside from them, we just need // to do something very generic. if (auto* block = curr->dynCast<Block>()) { diff --git a/src/passes/CodePushing.cpp b/src/passes/CodePushing.cpp index 6907f4fdc..7fa50f39b 100644 --- a/src/passes/CodePushing.cpp +++ b/src/passes/CodePushing.cpp @@ -141,7 +141,7 @@ private: if (auto* drop = curr->dynCast<Drop>()) { curr = drop->value; } - if (curr->is<If>()) { + if (curr->is<If>() || curr->is<BrOnExn>()) { return true; } if (auto* br = curr->dynCast<Break>()) { diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index 54707fddc..9b67a3a16 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -80,9 +80,12 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> { return curr; // not always needed, but handled in visitLoop() case Expression::Id::DropId: return curr; // not always needed, but handled in visitDrop() + case Expression::Id::TryId: + return curr; // not always needed, but handled in visitTry() case Expression::Id::BreakId: case Expression::Id::SwitchId: + case Expression::Id::BrOnExnId: case Expression::Id::CallId: case Expression::Id::CallIndirectId: case Expression::Id::LocalSetId: diff --git a/src/wasm-traversal.h b/src/wasm-traversal.h index eae4634b5..ee6d22aa5 100644 --- a/src/wasm-traversal.h +++ b/src/wasm-traversal.h @@ -1159,7 +1159,7 @@ struct ControlFlowWalker : public PostWalker<SubType, VisitorType> { return curr; } } else { - // an if, ignorable + // an if or try, ignorable assert(curr->template is<If>() || curr->template is<Try>()); } if (i == 0) { |