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

Side by Side Diff: src/compiler/scheduler.cc

Issue 935033004: Introduce and test NodeProperties::CollectControlProjections. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « src/compiler/node-properties.cc ('k') | test/unittests/compiler/node-properties-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/compiler/scheduler.h" 5 #include "src/compiler/scheduler.h"
6 6
7 #include "src/bit-vector.h" 7 #include "src/bit-vector.h"
8 #include "src/compiler/common-operator.h" 8 #include "src/compiler/common-operator.h"
9 #include "src/compiler/control-equivalence.h" 9 #include "src/compiler/control-equivalence.h"
10 #include "src/compiler/graph.h" 10 #include "src/compiler/graph.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 if (block == NULL) { 357 if (block == NULL) {
358 block = schedule_->NewBasicBlock(); 358 block = schedule_->NewBasicBlock();
359 Trace("Create block B%d for #%d:%s\n", block->id().ToInt(), node->id(), 359 Trace("Create block B%d for #%d:%s\n", block->id().ToInt(), node->id(),
360 node->op()->mnemonic()); 360 node->op()->mnemonic());
361 FixNode(block, node); 361 FixNode(block, node);
362 } 362 }
363 return block; 363 return block;
364 } 364 }
365 365
366 void BuildBlocksForSuccessors(Node* node) { 366 void BuildBlocksForSuccessors(Node* node) {
367 size_t const successor_count = node->op()->ControlOutputCount(); 367 size_t const successor_cnt = node->op()->ControlOutputCount();
368 Node** successors = zone_->NewArray<Node*>(successor_count); 368 Node** successors = zone_->NewArray<Node*>(successor_cnt);
369 CollectSuccessorProjections(node, successors, successor_count); 369 NodeProperties::CollectControlProjections(node, successors, successor_cnt);
370 for (size_t index = 0; index < successor_count; ++index) { 370 for (size_t index = 0; index < successor_cnt; ++index) {
371 BuildBlockForNode(successors[index]); 371 BuildBlockForNode(successors[index]);
372 } 372 }
373 } 373 }
374 374
375 // Collect the branch-related projections from a node, such as IfTrue,
376 // IfFalse, Case and Default.
377 void CollectSuccessorProjections(Node* node, Node** successors,
378 size_t successor_count) {
379 #ifdef DEBUG
380 DCHECK_EQ(static_cast<int>(successor_count), node->UseCount());
381 std::memset(successors, 0, sizeof(*successors) * successor_count);
382 #endif
383 size_t if_value_index = 0;
384 for (Node* const use : node->uses()) {
385 size_t index;
386 switch (use->opcode()) {
387 default:
388 UNREACHABLE();
389 // Fall through.
390 case IrOpcode::kIfTrue:
391 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
392 index = 0;
393 break;
394 case IrOpcode::kIfFalse:
395 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
396 index = 1;
397 break;
398 case IrOpcode::kIfValue:
399 DCHECK_EQ(IrOpcode::kSwitch, node->opcode());
400 index = if_value_index++;
401 break;
402 case IrOpcode::kIfDefault:
403 DCHECK_EQ(IrOpcode::kSwitch, node->opcode());
404 index = successor_count - 1;
405 break;
406 }
407 DCHECK_LT(if_value_index, successor_count);
408 DCHECK_LT(index, successor_count);
409 DCHECK_NULL(successors[index]);
410 successors[index] = use;
411 }
412 #ifdef DEBUG
413 for (size_t index = 0; index < successor_count; ++index) {
414 DCHECK_NOT_NULL(successors[index]);
415 }
416 #endif
417 }
418
419 void CollectSuccessorBlocks(Node* node, BasicBlock** successor_blocks, 375 void CollectSuccessorBlocks(Node* node, BasicBlock** successor_blocks,
420 size_t successor_count) { 376 size_t successor_cnt) {
421 Node** successors = reinterpret_cast<Node**>(successor_blocks); 377 Node** successors = reinterpret_cast<Node**>(successor_blocks);
422 CollectSuccessorProjections(node, successors, successor_count); 378 NodeProperties::CollectControlProjections(node, successors, successor_cnt);
423 for (size_t index = 0; index < successor_count; ++index) { 379 for (size_t index = 0; index < successor_cnt; ++index) {
424 successor_blocks[index] = schedule_->block(successors[index]); 380 successor_blocks[index] = schedule_->block(successors[index]);
425 } 381 }
426 } 382 }
427 383
428 void ConnectBranch(Node* branch) { 384 void ConnectBranch(Node* branch) {
429 BasicBlock* successor_blocks[2]; 385 BasicBlock* successor_blocks[2];
430 CollectSuccessorBlocks(branch, successor_blocks, 386 CollectSuccessorBlocks(branch, successor_blocks,
431 arraysize(successor_blocks)); 387 arraysize(successor_blocks));
432 388
433 // Consider branch hints. 389 // Consider branch hints.
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 for (Node* const node : *nodes) { 1610 for (Node* const node : *nodes) {
1655 schedule_->SetBlockForNode(to, node); 1611 schedule_->SetBlockForNode(to, node);
1656 scheduled_nodes_[to->id().ToSize()].push_back(node); 1612 scheduled_nodes_[to->id().ToSize()].push_back(node);
1657 } 1613 }
1658 nodes->clear(); 1614 nodes->clear();
1659 } 1615 }
1660 1616
1661 } // namespace compiler 1617 } // namespace compiler
1662 } // namespace internal 1618 } // namespace internal
1663 } // namespace v8 1619 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/node-properties.cc ('k') | test/unittests/compiler/node-properties-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698