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

Side by Side Diff: src/compiler/graph-visualizer.cc

Issue 1311983002: [turbofan] Separate LiveRange and TopLevelLiveRange concepts (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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 | « no previous file | src/compiler/greedy-allocator.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/graph-visualizer.h" 5 #include "src/compiler/graph-visualizer.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 #include <string> 8 #include <string>
9 9
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 void PrintLongProperty(const char* name, int64_t value); 413 void PrintLongProperty(const char* name, int64_t value);
414 void PrintIntProperty(const char* name, int value); 414 void PrintIntProperty(const char* name, int value);
415 void PrintBlockProperty(const char* name, int rpo_number); 415 void PrintBlockProperty(const char* name, int rpo_number);
416 void PrintNodeId(Node* n); 416 void PrintNodeId(Node* n);
417 void PrintNode(Node* n); 417 void PrintNode(Node* n);
418 void PrintInputs(Node* n); 418 void PrintInputs(Node* n);
419 template <typename InputIterator> 419 template <typename InputIterator>
420 void PrintInputs(InputIterator* i, int count, const char* prefix); 420 void PrintInputs(InputIterator* i, int count, const char* prefix);
421 void PrintType(Node* node); 421 void PrintType(Node* node);
422 422
423 void PrintLiveRange(LiveRange* range, const char* type); 423 void PrintLiveRange(LiveRange* range, const char* type, int vreg);
424 void PrintLiveRangeChain(TopLevelLiveRange* range, const char* type);
425
424 class Tag final BASE_EMBEDDED { 426 class Tag final BASE_EMBEDDED {
425 public: 427 public:
426 Tag(GraphC1Visualizer* visualizer, const char* name) { 428 Tag(GraphC1Visualizer* visualizer, const char* name) {
427 name_ = name; 429 name_ = name;
428 visualizer_ = visualizer; 430 visualizer_ = visualizer;
429 visualizer->PrintIndent(); 431 visualizer->PrintIndent();
430 visualizer_->os_ << "begin_" << name << "\n"; 432 visualizer_->os_ << "begin_" << name << "\n";
431 visualizer->indent_++; 433 visualizer->indent_++;
432 } 434 }
433 435
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 } 689 }
688 } 690 }
689 691
690 692
691 void GraphC1Visualizer::PrintLiveRanges(const char* phase, 693 void GraphC1Visualizer::PrintLiveRanges(const char* phase,
692 const RegisterAllocationData* data) { 694 const RegisterAllocationData* data) {
693 Tag tag(this, "intervals"); 695 Tag tag(this, "intervals");
694 PrintStringProperty("name", phase); 696 PrintStringProperty("name", phase);
695 697
696 for (auto range : data->fixed_double_live_ranges()) { 698 for (auto range : data->fixed_double_live_ranges()) {
697 PrintLiveRange(range, "fixed"); 699 PrintLiveRangeChain(range, "fixed");
698 } 700 }
699 701
700 for (auto range : data->fixed_live_ranges()) { 702 for (auto range : data->fixed_live_ranges()) {
701 PrintLiveRange(range, "fixed"); 703 PrintLiveRangeChain(range, "fixed");
702 } 704 }
703 705
704 for (auto range : data->live_ranges()) { 706 for (auto range : data->live_ranges()) {
705 PrintLiveRange(range, "object"); 707 PrintLiveRangeChain(range, "object");
706 } 708 }
707 } 709 }
708 710
709 711
710 void GraphC1Visualizer::PrintLiveRange(LiveRange* range, const char* type) { 712 void GraphC1Visualizer::PrintLiveRangeChain(TopLevelLiveRange* range,
713 const char* type) {
714 int vreg = range->vreg();
715 for (LiveRange* child = range; child != nullptr; child = child->next()) {
716 PrintLiveRange(child, type, vreg);
717 }
718 }
719
720
721 void GraphC1Visualizer::PrintLiveRange(LiveRange* range, const char* type,
722 int vreg) {
711 if (range != NULL && !range->IsEmpty()) { 723 if (range != NULL && !range->IsEmpty()) {
712 PrintIndent(); 724 PrintIndent();
713 os_ << range->id() << " " << type; 725 os_ << vreg << ":" << range->relative_id() << " " << type;
714 if (range->HasRegisterAssigned()) { 726 if (range->HasRegisterAssigned()) {
715 AllocatedOperand op = AllocatedOperand::cast(range->GetAssignedOperand()); 727 AllocatedOperand op = AllocatedOperand::cast(range->GetAssignedOperand());
716 int assigned_reg = op.index(); 728 int assigned_reg = op.index();
717 if (op.IsDoubleRegister()) { 729 if (op.IsDoubleRegister()) {
718 os_ << " \"" << DoubleRegister::AllocationIndexToString(assigned_reg) 730 os_ << " \"" << DoubleRegister::AllocationIndexToString(assigned_reg)
719 << "\""; 731 << "\"";
720 } else { 732 } else {
721 DCHECK(op.IsRegister()); 733 DCHECK(op.IsRegister());
722 os_ << " \"" << Register::AllocationIndexToString(assigned_reg) << "\""; 734 os_ << " \"" << Register::AllocationIndexToString(assigned_reg) << "\"";
723 } 735 }
724 } else if (range->spilled()) { 736 } else if (range->spilled()) {
725 auto top = range->TopLevel(); 737 auto top = range->TopLevel();
726 int index = -1; 738 int index = -1;
727 if (top->HasSpillRange()) { 739 if (top->HasSpillRange()) {
728 index = kMaxInt; // This hasn't been set yet. 740 index = kMaxInt; // This hasn't been set yet.
729 } else if (top->GetSpillOperand()->IsConstant()) { 741 } else if (top->GetSpillOperand()->IsConstant()) {
730 os_ << " \"const(nostack):" 742 os_ << " \"const(nostack):"
731 << ConstantOperand::cast(top->GetSpillOperand())->virtual_register() 743 << ConstantOperand::cast(top->GetSpillOperand())->virtual_register()
732 << "\""; 744 << "\"";
733 } else { 745 } else {
734 index = AllocatedOperand::cast(top->GetSpillOperand())->index(); 746 index = AllocatedOperand::cast(top->GetSpillOperand())->index();
735 if (top->kind() == DOUBLE_REGISTERS) { 747 if (top->kind() == DOUBLE_REGISTERS) {
736 os_ << " \"double_stack:" << index << "\""; 748 os_ << " \"double_stack:" << index << "\"";
737 } else if (top->kind() == GENERAL_REGISTERS) { 749 } else if (top->kind() == GENERAL_REGISTERS) {
738 os_ << " \"stack:" << index << "\""; 750 os_ << " \"stack:" << index << "\"";
739 } 751 }
740 } 752 }
741 } 753 }
742 int parent_index = -1; 754
743 if (range->IsChild()) { 755 os_ << " " << vreg;
744 parent_index = range->parent()->id();
745 } else {
746 parent_index = range->id();
747 }
748 os_ << " " << parent_index;
749 for (auto interval = range->first_interval(); interval != nullptr; 756 for (auto interval = range->first_interval(); interval != nullptr;
750 interval = interval->next()) { 757 interval = interval->next()) {
751 os_ << " [" << interval->start().value() << ", " 758 os_ << " [" << interval->start().value() << ", "
752 << interval->end().value() << "["; 759 << interval->end().value() << "[";
753 } 760 }
754 761
755 UsePosition* current_pos = range->first_pos(); 762 UsePosition* current_pos = range->first_pos();
756 while (current_pos != NULL) { 763 while (current_pos != NULL) {
757 if (current_pos->RegisterIsBeneficial() || FLAG_trace_all_uses) { 764 if (current_pos->RegisterIsBeneficial() || FLAG_trace_all_uses) {
758 os_ << " " << current_pos->pos().value() << " M"; 765 os_ << " " << current_pos->pos().value() << " M";
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); 826 os << "#" << SafeId(i) << ":" << SafeMnemonic(i);
820 } 827 }
821 os << ")" << std::endl; 828 os << ")" << std::endl;
822 } 829 }
823 } 830 }
824 return os; 831 return os;
825 } 832 }
826 } // namespace compiler 833 } // namespace compiler
827 } // namespace internal 834 } // namespace internal
828 } // namespace v8 835 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/greedy-allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698