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

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

Issue 1760323002: [turbofan] SSA Validation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: just ssa validation, after other fixed made it in Created 4 years, 9 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') | src/compiler/instruction-selector.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 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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin(); 613 for (BasicBlockVector::const_iterator it = schedule->rpo_order()->begin();
614 it != schedule->rpo_order()->end(); ++it, ++rpo_number) { 614 it != schedule->rpo_order()->end(); ++it, ++rpo_number) {
615 DCHECK(!(*blocks)[rpo_number]); 615 DCHECK(!(*blocks)[rpo_number]);
616 DCHECK(GetRpo(*it).ToSize() == rpo_number); 616 DCHECK(GetRpo(*it).ToSize() == rpo_number);
617 (*blocks)[rpo_number] = InstructionBlockFor(zone, *it); 617 (*blocks)[rpo_number] = InstructionBlockFor(zone, *it);
618 } 618 }
619 ComputeAssemblyOrder(blocks); 619 ComputeAssemblyOrder(blocks);
620 return blocks; 620 return blocks;
621 } 621 }
622 622
623 void InstructionSequence::Validate() { 623 void InstructionSequence::ValidateEdgeSplitForm() {
624 // Validate blocks are in edge-split form: no block with multiple successors 624 // Validate blocks are in edge-split form: no block with multiple successors
625 // has an edge to a block (== a successor) with more than one predecessors. 625 // has an edge to a block (== a successor) with more than one predecessors.
626 for (const InstructionBlock* block : instruction_blocks()) { 626 for (const InstructionBlock* block : instruction_blocks()) {
627 if (block->SuccessorCount() > 1) { 627 if (block->SuccessorCount() > 1) {
628 for (const RpoNumber& successor_id : block->successors()) { 628 for (const RpoNumber& successor_id : block->successors()) {
629 const InstructionBlock* successor = InstructionBlockAt(successor_id); 629 const InstructionBlock* successor = InstructionBlockAt(successor_id);
630 // Expect precisely one predecessor: "block". 630 // Expect precisely one predecessor: "block".
631 CHECK(successor->PredecessorCount() == 1 && 631 CHECK(successor->PredecessorCount() == 1 &&
632 successor->predecessors()[0] == block->rpo_number()); 632 successor->predecessors()[0] == block->rpo_number());
633 } 633 }
634 } 634 }
635 } 635 }
636 } 636 }
637 637
638 void InstructionSequence::ValidateSSA() {
639 // TODO(mtrofin): We could use a local zone here instead.
640 BitVector definitions(VirtualRegisterCount(), zone());
641 for (const Instruction* instruction : *this) {
642 for (size_t i = 0; i < instruction->OutputCount(); ++i) {
643 const InstructionOperand* output = instruction->OutputAt(i);
644 int vreg = (output->IsConstant())
645 ? ConstantOperand::cast(output)->virtual_register()
646 : UnallocatedOperand::cast(output)->virtual_register();
647 CHECK(!definitions.Contains(vreg));
648 definitions.Add(vreg);
649 }
650 }
651 }
652
638 void InstructionSequence::ComputeAssemblyOrder(InstructionBlocks* blocks) { 653 void InstructionSequence::ComputeAssemblyOrder(InstructionBlocks* blocks) {
639 int ao = 0; 654 int ao = 0;
640 for (InstructionBlock* const block : *blocks) { 655 for (InstructionBlock* const block : *blocks) {
641 if (!block->IsDeferred()) { 656 if (!block->IsDeferred()) {
642 block->set_ao_number(RpoNumber::FromInt(ao++)); 657 block->set_ao_number(RpoNumber::FromInt(ao++));
643 } 658 }
644 } 659 }
645 for (InstructionBlock* const block : *blocks) { 660 for (InstructionBlock* const block : *blocks) {
646 if (block->IsDeferred()) { 661 if (block->IsDeferred()) {
647 block->set_ao_number(RpoNumber::FromInt(ao++)); 662 block->set_ao_number(RpoNumber::FromInt(ao++));
(...skipping 14 matching lines...) Expand all
662 ConstantMap::allocator_type(zone())), 677 ConstantMap::allocator_type(zone())),
663 immediates_(zone()), 678 immediates_(zone()),
664 instructions_(zone()), 679 instructions_(zone()),
665 next_virtual_register_(0), 680 next_virtual_register_(0),
666 reference_maps_(zone()), 681 reference_maps_(zone()),
667 representations_(zone()), 682 representations_(zone()),
668 deoptimization_entries_(zone()) { 683 deoptimization_entries_(zone()) {
669 block_starts_.reserve(instruction_blocks_->size()); 684 block_starts_.reserve(instruction_blocks_->size());
670 685
671 #if DEBUG 686 #if DEBUG
672 Validate(); 687 ValidateEdgeSplitForm();
673 #endif 688 #endif
674 } 689 }
675 690
676 691
677 int InstructionSequence::NextVirtualRegister() { 692 int InstructionSequence::NextVirtualRegister() {
678 int virtual_register = next_virtual_register_++; 693 int virtual_register = next_virtual_register_++;
679 CHECK_NE(virtual_register, InstructionOperand::kInvalidVirtualRegister); 694 CHECK_NE(virtual_register, InstructionOperand::kInvalidVirtualRegister);
680 return virtual_register; 695 return virtual_register;
681 } 696 }
682 697
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 } 997 }
983 for (int i = 0; i < code.InstructionBlockCount(); i++) { 998 for (int i = 0; i < code.InstructionBlockCount(); i++) {
984 printable.sequence_->PrintBlock(printable.register_configuration_, i); 999 printable.sequence_->PrintBlock(printable.register_configuration_, i);
985 } 1000 }
986 return os; 1001 return os;
987 } 1002 }
988 1003
989 } // namespace compiler 1004 } // namespace compiler
990 } // namespace internal 1005 } // namespace internal
991 } // namespace v8 1006 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction.h ('k') | src/compiler/instruction-selector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698