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 <deque> | 5 #include <deque> |
6 #include <queue> | 6 #include <queue> |
7 | 7 |
8 #include "src/compiler/scheduler.h" | 8 #include "src/compiler/scheduler.h" |
9 | 9 |
10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 IrOpcode::kIfFalse); | 276 IrOpcode::kIfFalse); |
277 | 277 |
278 TraceConnect(branch, branch_block, successor_blocks[0]); | 278 TraceConnect(branch, branch_block, successor_blocks[0]); |
279 TraceConnect(branch, branch_block, successor_blocks[1]); | 279 TraceConnect(branch, branch_block, successor_blocks[1]); |
280 | 280 |
281 schedule_->AddBranch(branch_block, branch, successor_blocks[0], | 281 schedule_->AddBranch(branch_block, branch, successor_blocks[0], |
282 successor_blocks[1]); | 282 successor_blocks[1]); |
283 } | 283 } |
284 | 284 |
285 void ConnectMerge(Node* merge) { | 285 void ConnectMerge(Node* merge) { |
| 286 // Don't connect the special merge at the end to its predecessors. |
| 287 if (IsFinalMerge(merge)) return; |
| 288 |
286 BasicBlock* block = schedule_->block(merge); | 289 BasicBlock* block = schedule_->block(merge); |
287 DCHECK(block != NULL); | 290 DCHECK(block != NULL); |
288 // For all of the merge's control inputs, add a goto at the end to the | 291 // For all of the merge's control inputs, add a goto at the end to the |
289 // merge's basic block. | 292 // merge's basic block. |
290 for (InputIter j = merge->inputs().begin(); j != merge->inputs().end(); | 293 for (InputIter j = merge->inputs().begin(); j != merge->inputs().end(); |
291 ++j) { | 294 ++j) { |
292 BasicBlock* predecessor_block = schedule_->block(*j); | 295 BasicBlock* predecessor_block = schedule_->block(*j); |
293 if ((*j)->opcode() != IrOpcode::kReturn) { | 296 TraceConnect(merge, predecessor_block, block); |
294 TraceConnect(merge, predecessor_block, block); | 297 schedule_->AddGoto(predecessor_block, block); |
295 schedule_->AddGoto(predecessor_block, block); | |
296 } | |
297 } | 298 } |
298 } | 299 } |
299 | 300 |
300 void ConnectReturn(Node* ret) { | 301 void ConnectReturn(Node* ret) { |
301 Node* return_block_node = NodeProperties::GetControlInput(ret); | 302 Node* return_block_node = NodeProperties::GetControlInput(ret); |
302 BasicBlock* return_block = schedule_->block(return_block_node); | 303 BasicBlock* return_block = schedule_->block(return_block_node); |
303 TraceConnect(ret, return_block, NULL); | 304 TraceConnect(ret, return_block, NULL); |
304 schedule_->AddReturn(return_block, ret); | 305 schedule_->AddReturn(return_block, ret); |
305 } | 306 } |
306 | 307 |
307 void TraceConnect(Node* node, BasicBlock* block, BasicBlock* succ) { | 308 void TraceConnect(Node* node, BasicBlock* block, BasicBlock* succ) { |
308 DCHECK_NE(NULL, block); | 309 DCHECK_NE(NULL, block); |
309 if (succ == NULL) { | 310 if (succ == NULL) { |
310 Trace("Connect #%d:%s, B%d -> end\n", node->id(), node->op()->mnemonic(), | 311 Trace("Connect #%d:%s, B%d -> end\n", node->id(), node->op()->mnemonic(), |
311 block->id().ToInt()); | 312 block->id().ToInt()); |
312 } else { | 313 } else { |
313 Trace("Connect #%d:%s, B%d -> B%d\n", node->id(), node->op()->mnemonic(), | 314 Trace("Connect #%d:%s, B%d -> B%d\n", node->id(), node->op()->mnemonic(), |
314 block->id().ToInt(), succ->id().ToInt()); | 315 block->id().ToInt(), succ->id().ToInt()); |
315 } | 316 } |
316 } | 317 } |
| 318 |
| 319 bool IsFinalMerge(Node* node) { |
| 320 return (node == scheduler_->graph_->end()->InputAt(0)); |
| 321 } |
317 }; | 322 }; |
318 | 323 |
319 | 324 |
320 void Scheduler::BuildCFG() { | 325 void Scheduler::BuildCFG() { |
321 Trace("--- CREATING CFG -------------------------------------------\n"); | 326 Trace("--- CREATING CFG -------------------------------------------\n"); |
322 CFGBuilder cfg_builder(zone_, this); | 327 CFGBuilder cfg_builder(zone_, this); |
323 cfg_builder.Run(); | 328 cfg_builder.Run(); |
324 // Initialize per-block data. | 329 // Initialize per-block data. |
325 scheduled_nodes_.resize(schedule_->BasicBlockCount(), NodeVector(zone_)); | 330 scheduled_nodes_.resize(schedule_->BasicBlockCount(), NodeVector(zone_)); |
326 } | 331 } |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 #if DEBUG | 1198 #if DEBUG |
1194 if (FLAG_trace_turbo_scheduler) PrintRPO(num_loops, loops, final_order); | 1199 if (FLAG_trace_turbo_scheduler) PrintRPO(num_loops, loops, final_order); |
1195 VerifySpecialRPO(num_loops, loops, final_order); | 1200 VerifySpecialRPO(num_loops, loops, final_order); |
1196 #endif | 1201 #endif |
1197 return final_order; | 1202 return final_order; |
1198 } | 1203 } |
1199 | 1204 |
1200 } // namespace compiler | 1205 } // namespace compiler |
1201 } // namespace internal | 1206 } // namespace internal |
1202 } // namespace v8 | 1207 } // namespace v8 |
OLD | NEW |