From eca1a663fead59b2b70271a96abb6793e366b7e6 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Wed, 19 Feb 2020 02:06:31 -0800 Subject: 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. --- src/dataflow/graph.h | 2 ++ src/passes/CodePushing.cpp | 2 +- src/passes/Vacuum.cpp | 3 +++ src/wasm-traversal.h | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') 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 { // 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()) { 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()) { curr = drop->value; } - if (curr->is()) { + if (curr->is() || curr->is()) { return true; } if (auto* br = curr->dynCast()) { 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> { 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 { return curr; } } else { - // an if, ignorable + // an if or try, ignorable assert(curr->template is() || curr->template is()); } if (i == 0) { -- cgit v1.2.3