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

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

Issue 931623002: [turbofan] Optimize certain chains of Branch into a Switch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addrssed comments. 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/schedule.h ('k') | src/compiler/simplified-lowering.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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 void BuildBlocksForSuccessors(Node* node) { 366 void BuildBlocksForSuccessors(Node* node) {
367 size_t const successor_count = node->op()->ControlOutputCount(); 367 size_t const successor_count = node->op()->ControlOutputCount();
368 Node** successors = zone_->NewArray<Node*>(successor_count); 368 Node** successors = zone_->NewArray<Node*>(successor_count);
369 CollectSuccessorProjections(node, successors, successor_count); 369 CollectSuccessorProjections(node, successors, successor_count);
370 for (size_t index = 0; index < successor_count; ++index) { 370 for (size_t index = 0; index < successor_count; ++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, 375 // Collect the branch-related projections from a node, such as IfTrue,
376 // IfFalse, and Case. 376 // IfFalse, Case and Default.
377 void CollectSuccessorProjections(Node* node, Node** successors, 377 void CollectSuccessorProjections(Node* node, Node** successors,
378 size_t successor_count) { 378 size_t successor_count) {
379 #ifdef DEBUG 379 #ifdef DEBUG
380 DCHECK_EQ(static_cast<int>(successor_count), node->UseCount()); 380 DCHECK_EQ(static_cast<int>(successor_count), node->UseCount());
381 std::memset(successors, 0, sizeof(*successors) * successor_count); 381 std::memset(successors, 0, sizeof(*successors) * successor_count);
382 #endif 382 #endif
383 size_t if_value_index = 0;
383 for (Node* const use : node->uses()) { 384 for (Node* const use : node->uses()) {
384 size_t index; 385 size_t index;
385 switch (use->opcode()) { 386 switch (use->opcode()) {
386 default: 387 default:
387 UNREACHABLE(); 388 UNREACHABLE();
388 // Fall through. 389 // Fall through.
389 case IrOpcode::kIfTrue: 390 case IrOpcode::kIfTrue:
390 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); 391 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
391 index = 0; 392 index = 0;
392 break; 393 break;
393 case IrOpcode::kIfFalse: 394 case IrOpcode::kIfFalse:
394 DCHECK_EQ(IrOpcode::kBranch, node->opcode()); 395 DCHECK_EQ(IrOpcode::kBranch, node->opcode());
395 index = 1; 396 index = 1;
396 break; 397 break;
397 case IrOpcode::kCase: 398 case IrOpcode::kIfValue:
398 DCHECK_EQ(IrOpcode::kSwitch, node->opcode()); 399 DCHECK_EQ(IrOpcode::kSwitch, node->opcode());
399 index = CaseIndexOf(use->op()); 400 index = if_value_index++;
401 break;
402 case IrOpcode::kIfDefault:
403 DCHECK_EQ(IrOpcode::kSwitch, node->opcode());
404 index = successor_count - 1;
400 break; 405 break;
401 } 406 }
407 DCHECK_LT(if_value_index, successor_count);
402 DCHECK_LT(index, successor_count); 408 DCHECK_LT(index, successor_count);
403 DCHECK(successors[index] == nullptr); 409 DCHECK_NULL(successors[index]);
404 successors[index] = use; 410 successors[index] = use;
405 } 411 }
406 #ifdef DEBUG 412 #ifdef DEBUG
407 for (size_t index = 0; index < successor_count; ++index) { 413 for (size_t index = 0; index < successor_count; ++index) {
408 DCHECK_NOT_NULL(successors[index]); 414 DCHECK_NOT_NULL(successors[index]);
409 } 415 }
410 #endif 416 #endif
411 } 417 }
412 418
413 void CollectSuccessorBlocks(Node* node, BasicBlock** successor_blocks, 419 void CollectSuccessorBlocks(Node* node, BasicBlock** successor_blocks,
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 for (Node* const node : *nodes) { 1654 for (Node* const node : *nodes) {
1649 schedule_->SetBlockForNode(to, node); 1655 schedule_->SetBlockForNode(to, node);
1650 scheduled_nodes_[to->id().ToSize()].push_back(node); 1656 scheduled_nodes_[to->id().ToSize()].push_back(node);
1651 } 1657 }
1652 nodes->clear(); 1658 nodes->clear();
1653 } 1659 }
1654 1660
1655 } // namespace compiler 1661 } // namespace compiler
1656 } // namespace internal 1662 } // namespace internal
1657 } // namespace v8 1663 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/schedule.h ('k') | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698