Commit 8872ec5e authored by jarin's avatar jarin Committed by Commit bot

[Crankshaft] Check that both sides of test context are connected.

R=bmeurer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#34918}
parent 811137ff
...@@ -4773,23 +4773,24 @@ void HOptimizedGraphBuilder::VisitIfStatement(IfStatement* stmt) { ...@@ -4773,23 +4773,24 @@ void HOptimizedGraphBuilder::VisitIfStatement(IfStatement* stmt) {
HBasicBlock* cond_false = graph()->CreateBasicBlock(); HBasicBlock* cond_false = graph()->CreateBasicBlock();
CHECK_BAILOUT(VisitForControl(stmt->condition(), cond_true, cond_false)); CHECK_BAILOUT(VisitForControl(stmt->condition(), cond_true, cond_false));
if (cond_true->HasPredecessor()) { // Technically, we should be able to handle the case when one side of
cond_true->SetJoinId(stmt->ThenId()); // the test is not connected, but this can trip up liveness analysis
set_current_block(cond_true); // if we did not fully connect the test context based on some optimistic
CHECK_BAILOUT(Visit(stmt->then_statement())); // assumption. If such an assumption was violated, we would end up with
cond_true = current_block(); // an environment with optimized-out values. So we should always
} else { // conservatively connect the test context.
cond_true = NULL; CHECK(cond_true->HasPredecessor());
} CHECK(cond_false->HasPredecessor());
cond_true->SetJoinId(stmt->ThenId());
set_current_block(cond_true);
CHECK_BAILOUT(Visit(stmt->then_statement()));
cond_true = current_block();
if (cond_false->HasPredecessor()) { cond_false->SetJoinId(stmt->ElseId());
cond_false->SetJoinId(stmt->ElseId()); set_current_block(cond_false);
set_current_block(cond_false); CHECK_BAILOUT(Visit(stmt->else_statement()));
CHECK_BAILOUT(Visit(stmt->else_statement())); cond_false = current_block();
cond_false = current_block();
} else {
cond_false = NULL;
}
HBasicBlock* join = CreateJoin(cond_true, cond_false, stmt->IfId()); HBasicBlock* join = CreateJoin(cond_true, cond_false, stmt->IfId());
set_current_block(join); set_current_block(join);
...@@ -11319,12 +11320,10 @@ void HOptimizedGraphBuilder::VisitLogicalExpression(BinaryOperation* expr) { ...@@ -11319,12 +11320,10 @@ void HOptimizedGraphBuilder::VisitLogicalExpression(BinaryOperation* expr) {
// Translate right subexpression by visiting it in the same AST // Translate right subexpression by visiting it in the same AST
// context as the entire expression. // context as the entire expression.
if (eval_right->HasPredecessor()) { CHECK(eval_right->HasPredecessor());
eval_right->SetJoinId(expr->RightId()); eval_right->SetJoinId(expr->RightId());
set_current_block(eval_right); set_current_block(eval_right);
Visit(expr->right()); Visit(expr->right());
}
} else if (ast_context()->IsValue()) { } else if (ast_context()->IsValue()) {
CHECK_ALIVE(VisitForValue(expr->left())); CHECK_ALIVE(VisitForValue(expr->left()));
DCHECK(current_block() != NULL); DCHECK(current_block() != NULL);
...@@ -11380,20 +11379,22 @@ void HOptimizedGraphBuilder::VisitLogicalExpression(BinaryOperation* expr) { ...@@ -11380,20 +11379,22 @@ void HOptimizedGraphBuilder::VisitLogicalExpression(BinaryOperation* expr) {
// second one is not a merge node, and that we really have no good AST ID to // second one is not a merge node, and that we really have no good AST ID to
// put on that first HSimulate. // put on that first HSimulate.
if (empty_block->HasPredecessor()) { // Technically, we should be able to handle the case when one side of
empty_block->SetJoinId(expr->id()); // the test is not connected, but this can trip up liveness analysis
} else { // if we did not fully connect the test context based on some optimistic
empty_block = NULL; // assumption. If such an assumption was violated, we would end up with
} // an environment with optimized-out values. So we should always
// conservatively connect the test context.
if (right_block->HasPredecessor()) { CHECK(right_block->HasPredecessor());
right_block->SetJoinId(expr->RightId()); CHECK(empty_block->HasPredecessor());
set_current_block(right_block);
CHECK_BAILOUT(VisitForEffect(expr->right())); empty_block->SetJoinId(expr->id());
right_block = current_block();
} else { right_block->SetJoinId(expr->RightId());
right_block = NULL; set_current_block(right_block);
} CHECK_BAILOUT(VisitForEffect(expr->right()));
right_block = current_block();
HBasicBlock* join_block = HBasicBlock* join_block =
CreateJoin(empty_block, right_block, expr->id()); CreateJoin(empty_block, right_block, expr->id());
......
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