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

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

Issue 1668953002: [turbofan] Validate split-edge form (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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/instruction.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 #include "src/compiler/graph.h" 6 #include "src/compiler/graph.h"
7 #include "src/compiler/instruction.h" 7 #include "src/compiler/instruction.h"
8 #include "src/compiler/schedule.h" 8 #include "src/compiler/schedule.h"
9 #include "src/compiler/state-values-utils.h" 9 #include "src/compiler/state-values-utils.h"
10 10
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin(); 608 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin();
609 it != schedule->rpo_order()->end(); ++it, ++rpo_number) { 609 it != schedule->rpo_order()->end(); ++it, ++rpo_number) {
610 DCHECK(!(*blocks)[rpo_number]); 610 DCHECK(!(*blocks)[rpo_number]);
611 DCHECK(GetRpo(*it).ToSize() == rpo_number); 611 DCHECK(GetRpo(*it).ToSize() == rpo_number);
612 (*blocks)[rpo_number] = InstructionBlockFor(zone, *it); 612 (*blocks)[rpo_number] = InstructionBlockFor(zone, *it);
613 } 613 }
614 ComputeAssemblyOrder(blocks); 614 ComputeAssemblyOrder(blocks);
615 return blocks; 615 return blocks;
616 } 616 }
617 617
618 void InstructionSequence::Validate() {
619 // Validate blocks are in edge-split form: no block with multiple successors
620 // has an edge to a block (== a successor) with more than one predecessors.
621 for (const InstructionBlock* block : instruction_blocks()) {
622 if (block->SuccessorCount() > 1) {
623 for (const RpoNumber& successor_id : block->successors()) {
624 const InstructionBlock* successor = InstructionBlockAt(successor_id);
625 // Expect precisely one predecessor: "block".
626 CHECK(successor->PredecessorCount() == 1 &&
627 successor->predecessors()[0] == block->rpo_number());
628 }
629 }
630 }
631 }
618 632
619 void InstructionSequence::ComputeAssemblyOrder(InstructionBlocks* blocks) { 633 void InstructionSequence::ComputeAssemblyOrder(InstructionBlocks* blocks) {
620 int ao = 0; 634 int ao = 0;
621 for (auto const block : *blocks) { 635 for (auto const block : *blocks) {
622 if (!block->IsDeferred()) { 636 if (!block->IsDeferred()) {
623 block->set_ao_number(RpoNumber::FromInt(ao++)); 637 block->set_ao_number(RpoNumber::FromInt(ao++));
624 } 638 }
625 } 639 }
626 for (auto const block : *blocks) { 640 for (auto const block : *blocks) {
627 if (block->IsDeferred()) { 641 if (block->IsDeferred()) {
(...skipping 13 matching lines...) Expand all
641 block_starts_(zone()), 655 block_starts_(zone()),
642 constants_(ConstantMap::key_compare(), 656 constants_(ConstantMap::key_compare(),
643 ConstantMap::allocator_type(zone())), 657 ConstantMap::allocator_type(zone())),
644 immediates_(zone()), 658 immediates_(zone()),
645 instructions_(zone()), 659 instructions_(zone()),
646 next_virtual_register_(0), 660 next_virtual_register_(0),
647 reference_maps_(zone()), 661 reference_maps_(zone()),
648 representations_(zone()), 662 representations_(zone()),
649 deoptimization_entries_(zone()) { 663 deoptimization_entries_(zone()) {
650 block_starts_.reserve(instruction_blocks_->size()); 664 block_starts_.reserve(instruction_blocks_->size());
665
666 #if DEBUG
667 Validate();
668 #endif
651 } 669 }
652 670
653 671
654 int InstructionSequence::NextVirtualRegister() { 672 int InstructionSequence::NextVirtualRegister() {
655 int virtual_register = next_virtual_register_++; 673 int virtual_register = next_virtual_register_++;
656 CHECK_NE(virtual_register, InstructionOperand::kInvalidVirtualRegister); 674 CHECK_NE(virtual_register, InstructionOperand::kInvalidVirtualRegister);
657 return virtual_register; 675 return virtual_register;
658 } 676 }
659 677
660 678
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 } 976 }
959 for (int i = 0; i < code.InstructionBlockCount(); i++) { 977 for (int i = 0; i < code.InstructionBlockCount(); i++) {
960 printable.sequence_->PrintBlock(printable.register_configuration_, i); 978 printable.sequence_->PrintBlock(printable.register_configuration_, i);
961 } 979 }
962 return os; 980 return os;
963 } 981 }
964 982
965 } // namespace compiler 983 } // namespace compiler
966 } // namespace internal 984 } // namespace internal
967 } // namespace v8 985 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698