| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
| 10 #include "src/ast/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
| (...skipping 5093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5104 HBasicBlock* loop_entry = BuildLoopEntry(stmt); | 5104 HBasicBlock* loop_entry = BuildLoopEntry(stmt); |
| 5105 | 5105 |
| 5106 BreakAndContinueInfo break_info(stmt, scope()); | 5106 BreakAndContinueInfo break_info(stmt, scope()); |
| 5107 { | 5107 { |
| 5108 BreakAndContinueScope push(&break_info, this); | 5108 BreakAndContinueScope push(&break_info, this); |
| 5109 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry)); | 5109 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry)); |
| 5110 } | 5110 } |
| 5111 HBasicBlock* body_exit = | 5111 HBasicBlock* body_exit = |
| 5112 JoinContinue(stmt, current_block(), break_info.continue_block()); | 5112 JoinContinue(stmt, current_block(), break_info.continue_block()); |
| 5113 HBasicBlock* loop_successor = NULL; | 5113 HBasicBlock* loop_successor = NULL; |
| 5114 if (body_exit != NULL && !stmt->cond()->ToBooleanIsTrue()) { | 5114 if (body_exit != NULL) { |
| 5115 set_current_block(body_exit); | 5115 set_current_block(body_exit); |
| 5116 loop_successor = graph()->CreateBasicBlock(); | 5116 loop_successor = graph()->CreateBasicBlock(); |
| 5117 if (stmt->cond()->ToBooleanIsFalse()) { | 5117 if (stmt->cond()->ToBooleanIsFalse()) { |
| 5118 loop_entry->loop_information()->stack_check()->Eliminate(); | 5118 loop_entry->loop_information()->stack_check()->Eliminate(); |
| 5119 Goto(loop_successor); | 5119 Goto(loop_successor); |
| 5120 body_exit = NULL; | 5120 body_exit = NULL; |
| 5121 } else { | 5121 } else { |
| 5122 // The block for a true condition, the actual predecessor block of the | 5122 // The block for a true condition, the actual predecessor block of the |
| 5123 // back edge. | 5123 // back edge. |
| 5124 body_exit = graph()->CreateBasicBlock(); | 5124 body_exit = graph()->CreateBasicBlock(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5146 | 5146 |
| 5147 void HOptimizedGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { | 5147 void HOptimizedGraphBuilder::VisitWhileStatement(WhileStatement* stmt) { |
| 5148 DCHECK(!HasStackOverflow()); | 5148 DCHECK(!HasStackOverflow()); |
| 5149 DCHECK(current_block() != NULL); | 5149 DCHECK(current_block() != NULL); |
| 5150 DCHECK(current_block()->HasPredecessor()); | 5150 DCHECK(current_block()->HasPredecessor()); |
| 5151 DCHECK(current_block() != NULL); | 5151 DCHECK(current_block() != NULL); |
| 5152 HBasicBlock* loop_entry = BuildLoopEntry(stmt); | 5152 HBasicBlock* loop_entry = BuildLoopEntry(stmt); |
| 5153 | 5153 |
| 5154 // If the condition is constant true, do not generate a branch. | 5154 // If the condition is constant true, do not generate a branch. |
| 5155 HBasicBlock* loop_successor = NULL; | 5155 HBasicBlock* loop_successor = NULL; |
| 5156 if (!stmt->cond()->ToBooleanIsTrue()) { | 5156 HBasicBlock* body_entry = graph()->CreateBasicBlock(); |
| 5157 HBasicBlock* body_entry = graph()->CreateBasicBlock(); | 5157 loop_successor = graph()->CreateBasicBlock(); |
| 5158 loop_successor = graph()->CreateBasicBlock(); | 5158 CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor)); |
| 5159 CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor)); | 5159 if (body_entry->HasPredecessor()) { |
| 5160 if (body_entry->HasPredecessor()) { | 5160 body_entry->SetJoinId(stmt->BodyId()); |
| 5161 body_entry->SetJoinId(stmt->BodyId()); | 5161 set_current_block(body_entry); |
| 5162 set_current_block(body_entry); | 5162 } |
| 5163 } | 5163 if (loop_successor->HasPredecessor()) { |
| 5164 if (loop_successor->HasPredecessor()) { | 5164 loop_successor->SetJoinId(stmt->ExitId()); |
| 5165 loop_successor->SetJoinId(stmt->ExitId()); | 5165 } else { |
| 5166 } else { | 5166 loop_successor = NULL; |
| 5167 loop_successor = NULL; | |
| 5168 } | |
| 5169 } | 5167 } |
| 5170 | 5168 |
| 5171 BreakAndContinueInfo break_info(stmt, scope()); | 5169 BreakAndContinueInfo break_info(stmt, scope()); |
| 5172 if (current_block() != NULL) { | 5170 if (current_block() != NULL) { |
| 5173 BreakAndContinueScope push(&break_info, this); | 5171 BreakAndContinueScope push(&break_info, this); |
| 5174 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry)); | 5172 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry)); |
| 5175 } | 5173 } |
| 5176 HBasicBlock* body_exit = | 5174 HBasicBlock* body_exit = |
| 5177 JoinContinue(stmt, current_block(), break_info.continue_block()); | 5175 JoinContinue(stmt, current_block(), break_info.continue_block()); |
| 5178 HBasicBlock* loop_exit = CreateLoop(stmt, | 5176 HBasicBlock* loop_exit = CreateLoop(stmt, |
| 5179 loop_entry, | 5177 loop_entry, |
| 5180 body_exit, | 5178 body_exit, |
| 5181 loop_successor, | 5179 loop_successor, |
| 5182 break_info.break_block()); | 5180 break_info.break_block()); |
| 5183 set_current_block(loop_exit); | 5181 set_current_block(loop_exit); |
| 5184 } | 5182 } |
| 5185 | 5183 |
| 5186 | 5184 |
| 5187 void HOptimizedGraphBuilder::VisitForStatement(ForStatement* stmt) { | 5185 void HOptimizedGraphBuilder::VisitForStatement(ForStatement* stmt) { |
| 5188 DCHECK(!HasStackOverflow()); | 5186 DCHECK(!HasStackOverflow()); |
| 5189 DCHECK(current_block() != NULL); | 5187 DCHECK(current_block() != NULL); |
| 5190 DCHECK(current_block()->HasPredecessor()); | 5188 DCHECK(current_block()->HasPredecessor()); |
| 5191 if (stmt->init() != NULL) { | 5189 if (stmt->init() != NULL) { |
| 5192 CHECK_ALIVE(Visit(stmt->init())); | 5190 CHECK_ALIVE(Visit(stmt->init())); |
| 5193 } | 5191 } |
| 5194 DCHECK(current_block() != NULL); | 5192 DCHECK(current_block() != NULL); |
| 5195 HBasicBlock* loop_entry = BuildLoopEntry(stmt); | 5193 HBasicBlock* loop_entry = BuildLoopEntry(stmt); |
| 5196 | 5194 |
| 5197 HBasicBlock* loop_successor = NULL; | 5195 HBasicBlock* loop_successor = graph()->CreateBasicBlock(); |
| 5196 HBasicBlock* body_entry = graph()->CreateBasicBlock(); |
| 5198 if (stmt->cond() != NULL) { | 5197 if (stmt->cond() != NULL) { |
| 5199 HBasicBlock* body_entry = graph()->CreateBasicBlock(); | |
| 5200 loop_successor = graph()->CreateBasicBlock(); | |
| 5201 CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor)); | 5198 CHECK_BAILOUT(VisitForControl(stmt->cond(), body_entry, loop_successor)); |
| 5202 if (body_entry->HasPredecessor()) { | 5199 if (body_entry->HasPredecessor()) { |
| 5203 body_entry->SetJoinId(stmt->BodyId()); | 5200 body_entry->SetJoinId(stmt->BodyId()); |
| 5204 set_current_block(body_entry); | 5201 set_current_block(body_entry); |
| 5205 } | 5202 } |
| 5206 if (loop_successor->HasPredecessor()) { | 5203 if (loop_successor->HasPredecessor()) { |
| 5207 loop_successor->SetJoinId(stmt->ExitId()); | 5204 loop_successor->SetJoinId(stmt->ExitId()); |
| 5208 } else { | 5205 } else { |
| 5209 loop_successor = NULL; | 5206 loop_successor = NULL; |
| 5210 } | 5207 } |
| 5208 } else { |
| 5209 // Create dummy control flow so that variable liveness analysis |
| 5210 // produces teh correct result. |
| 5211 HControlInstruction* branch = New<HBranch>(graph()->GetConstantTrue()); |
| 5212 branch->SetSuccessorAt(0, body_entry); |
| 5213 branch->SetSuccessorAt(1, loop_successor); |
| 5214 FinishCurrentBlock(branch); |
| 5215 set_current_block(body_entry); |
| 5211 } | 5216 } |
| 5212 | 5217 |
| 5213 BreakAndContinueInfo break_info(stmt, scope()); | 5218 BreakAndContinueInfo break_info(stmt, scope()); |
| 5214 if (current_block() != NULL) { | 5219 if (current_block() != NULL) { |
| 5215 BreakAndContinueScope push(&break_info, this); | 5220 BreakAndContinueScope push(&break_info, this); |
| 5216 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry)); | 5221 CHECK_BAILOUT(VisitLoopBody(stmt, loop_entry)); |
| 5217 } | 5222 } |
| 5218 HBasicBlock* body_exit = | 5223 HBasicBlock* body_exit = |
| 5219 JoinContinue(stmt, current_block(), break_info.continue_block()); | 5224 JoinContinue(stmt, current_block(), break_info.continue_block()); |
| 5220 | 5225 |
| (...skipping 8349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13570 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13575 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13571 } | 13576 } |
| 13572 | 13577 |
| 13573 #ifdef DEBUG | 13578 #ifdef DEBUG |
| 13574 graph_->Verify(false); // No full verify. | 13579 graph_->Verify(false); // No full verify. |
| 13575 #endif | 13580 #endif |
| 13576 } | 13581 } |
| 13577 | 13582 |
| 13578 } // namespace internal | 13583 } // namespace internal |
| 13579 } // namespace v8 | 13584 } // namespace v8 |
| OLD | NEW |