Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Unified Diff: src/crankshaft/hydrogen.cc

Issue 1863123002: [crankshaft] Make infinite loop preserve control flow. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-599710.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen.cc
diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc
index 38a9fd0ad88425776d69b9485ac0ea852c81d91d..0de6dac78eca1008f326cebed6197a06cc7f68b4 100644
--- a/src/crankshaft/hydrogen.cc
+++ b/src/crankshaft/hydrogen.cc
@@ -5111,7 +5111,7 @@ void HOptimizedGraphBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) {
HBasicBlock* body_exit =
JoinContinue(stmt, current_block(), break_info.continue_block());
HBasicBlock* loop_successor = NULL;
- if (body_exit != NULL && !stmt->cond()->ToBooleanIsTrue()) {
+ if (body_exit != NULL) {
set_current_block(body_exit);
loop_successor = graph()->CreateBasicBlock();
if (stmt->cond()->ToBooleanIsFalse()) {
@@ -5153,19 +5153,17 @@ void HOptimizedGraphBuilder::VisitWhileStatement(WhileStatement* stmt) {
// If the condition is constant true, do not generate a branch.
HBasicBlock* loop_successor = NULL;
- if (!stmt->cond()->ToBooleanIsTrue()) {
- HBasicBlock* body_entry = graph()->CreateBasicBlock();
- loop_successor = graph()->CreateBasicBlock();
- CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor));
- if (body_entry->HasPredecessor()) {
- body_entry->SetJoinId(stmt->BodyId());
- set_current_block(body_entry);
- }
- if (loop_successor->HasPredecessor()) {
- loop_successor->SetJoinId(stmt->ExitId());
- } else {
- loop_successor = NULL;
- }
+ HBasicBlock* body_entry = graph()->CreateBasicBlock();
+ loop_successor = graph()->CreateBasicBlock();
+ CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor));
+ if (body_entry->HasPredecessor()) {
+ body_entry->SetJoinId(stmt->BodyId());
+ set_current_block(body_entry);
+ }
+ if (loop_successor->HasPredecessor()) {
+ loop_successor->SetJoinId(stmt->ExitId());
+ } else {
+ loop_successor = NULL;
}
BreakAndContinueInfo break_info(stmt, scope());
@@ -5194,10 +5192,9 @@ void HOptimizedGraphBuilder::VisitForStatement(ForStatement* stmt) {
DCHECK(current_block() != NULL);
HBasicBlock* loop_entry = BuildLoopEntry(stmt);
- HBasicBlock* loop_successor = NULL;
+ HBasicBlock* loop_successor = graph()->CreateBasicBlock();
+ HBasicBlock* body_entry = graph()->CreateBasicBlock();
if (stmt->cond() != NULL) {
- HBasicBlock* body_entry = graph()->CreateBasicBlock();
- loop_successor = graph()->CreateBasicBlock();
CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor));
if (body_entry->HasPredecessor()) {
body_entry->SetJoinId(stmt->BodyId());
@@ -5208,6 +5205,14 @@ void HOptimizedGraphBuilder::VisitForStatement(ForStatement* stmt) {
} else {
loop_successor = NULL;
}
+ } else {
+ // Create dummy control flow so that variable liveness analysis
+ // produces teh correct result.
+ HControlInstruction* branch = New<HBranch>(graph()->GetConstantTrue());
+ branch->SetSuccessorAt(0, body_entry);
+ branch->SetSuccessorAt(1, loop_successor);
+ FinishCurrentBlock(branch);
+ set_current_block(body_entry);
}
BreakAndContinueInfo break_info(stmt, scope());
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-599710.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698