Commit b33f552f authored by mstarzinger's avatar mstarzinger Committed by Commit bot

Make sure exception handlers are deferred.

R=bmeurer@chromium.org
TEST=unittests/SchedulerTest.CallException

Review URL: https://codereview.chromium.org/944903002

Cr-Commit-Position: refs/heads/master@{#26816}
parent abf122cc
......@@ -1073,6 +1073,7 @@ void Scheduler::PropagateImmediateDominators(BasicBlock* block) {
auto end = block->predecessors().end();
DCHECK(pred != end); // All blocks except start have predecessors.
BasicBlock* dominator = *pred;
bool deferred = dominator->deferred();
// For multiple predecessors, walk up the dominator tree until a common
// dominator is found. Visitation order guarantees that all predecessors
// except for backwards edges have been visited.
......@@ -1080,11 +1081,11 @@ void Scheduler::PropagateImmediateDominators(BasicBlock* block) {
// Don't examine backwards edges.
if ((*pred)->dominator_depth() < 0) continue;
dominator = BasicBlock::GetCommonDominator(dominator, *pred);
deferred = deferred & (*pred)->deferred();
}
block->set_dominator(dominator);
block->set_dominator_depth(dominator->dominator_depth() + 1);
// Propagate "deferredness" of the dominator.
if (dominator->deferred()) block->set_deferred(true);
block->set_deferred(deferred | block->deferred());
Trace("Block B%d's idom is B%d, depth = %d\n", block->id().ToInt(),
dominator->id().ToInt(), block->dominator_depth());
}
......
......@@ -136,6 +136,8 @@ const Operator kHeapConstant(IrOpcode::kHeapConstant, Operator::kPure,
"HeapConstant", 0, 0, 0, 1, 0, 0);
const Operator kIntAdd(IrOpcode::kInt32Add, Operator::kPure, "Int32Add", 2, 0,
0, 1, 0, 0);
const Operator kMockCall(IrOpcode::kCall, Operator::kNoProperties, "MockCall",
0, 0, 1, 1, 0, 2);
} // namespace
......@@ -1962,6 +1964,34 @@ TARGET_TEST_F(SchedulerTest, BranchHintFalse) {
}
TARGET_TEST_F(SchedulerTest, CallException) {
Node* start = graph()->NewNode(common()->Start(1));
graph()->SetStart(start);
Node* p0 = graph()->NewNode(common()->Parameter(0), start);
Node* c1 = graph()->NewNode(&kMockCall, start);
Node* ok1 = graph()->NewNode(common()->IfSuccess(), c1);
Node* ex1 = graph()->NewNode(common()->IfException(), c1);
Node* c2 = graph()->NewNode(&kMockCall, ok1);
Node* ok2 = graph()->NewNode(common()->IfSuccess(), c2);
Node* ex2 = graph()->NewNode(common()->IfException(), c2);
Node* hdl = graph()->NewNode(common()->Merge(2), ex1, ex2);
Node* m = graph()->NewNode(common()->Merge(2), ok2, hdl);
Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), c2, p0, m);
Node* ret = graph()->NewNode(common()->Return(), phi, start, m);
Node* end = graph()->NewNode(common()->End(), ret);
graph()->SetEnd(end);
Schedule* schedule = ComputeAndVerifySchedule(17);
// Make sure the exception blocks as well as the handler are deferred.
EXPECT_TRUE(schedule->block(ex1)->deferred());
EXPECT_TRUE(schedule->block(ex2)->deferred());
EXPECT_TRUE(schedule->block(hdl)->deferred());
EXPECT_FALSE(schedule->block(m)->deferred());
}
TARGET_TEST_F(SchedulerTest, Switch) {
Node* start = graph()->NewNode(common()->Start(1));
graph()->SetStart(start);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment