OLD | NEW |
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 void PrintLongProperty(const char* name, int64_t value); | 224 void PrintLongProperty(const char* name, int64_t value); |
225 void PrintIntProperty(const char* name, int value); | 225 void PrintIntProperty(const char* name, int value); |
226 void PrintBlockProperty(const char* name, int rpo_number); | 226 void PrintBlockProperty(const char* name, int rpo_number); |
227 void PrintNodeId(Node* n); | 227 void PrintNodeId(Node* n); |
228 void PrintNode(Node* n); | 228 void PrintNode(Node* n); |
229 void PrintInputs(Node* n); | 229 void PrintInputs(Node* n); |
230 template <typename InputIterator> | 230 template <typename InputIterator> |
231 void PrintInputs(InputIterator* i, int count, const char* prefix); | 231 void PrintInputs(InputIterator* i, int count, const char* prefix); |
232 void PrintType(Node* node); | 232 void PrintType(Node* node); |
233 | 233 |
234 void PrintLiveRange(LiveRange* range, const char* type, int vreg); | 234 void PrintLiveRange(const LiveRange* range, const char* type, int vreg); |
235 void PrintLiveRangeChain(TopLevelLiveRange* range, const char* type); | 235 void PrintLiveRangeChain(const TopLevelLiveRange* range, const char* type); |
236 | 236 |
237 class Tag final BASE_EMBEDDED { | 237 class Tag final BASE_EMBEDDED { |
238 public: | 238 public: |
239 Tag(GraphC1Visualizer* visualizer, const char* name) { | 239 Tag(GraphC1Visualizer* visualizer, const char* name) { |
240 name_ = name; | 240 name_ = name; |
241 visualizer_ = visualizer; | 241 visualizer_ = visualizer; |
242 visualizer->PrintIndent(); | 242 visualizer->PrintIndent(); |
243 visualizer_->os_ << "begin_" << name << "\n"; | 243 visualizer_->os_ << "begin_" << name << "\n"; |
244 visualizer->indent_++; | 244 visualizer->indent_++; |
245 } | 245 } |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 } | 498 } |
499 } | 499 } |
500 } | 500 } |
501 | 501 |
502 | 502 |
503 void GraphC1Visualizer::PrintLiveRanges(const char* phase, | 503 void GraphC1Visualizer::PrintLiveRanges(const char* phase, |
504 const RegisterAllocationData* data) { | 504 const RegisterAllocationData* data) { |
505 Tag tag(this, "intervals"); | 505 Tag tag(this, "intervals"); |
506 PrintStringProperty("name", phase); | 506 PrintStringProperty("name", phase); |
507 | 507 |
508 for (auto range : data->fixed_double_live_ranges()) { | 508 for (const TopLevelLiveRange* range : data->fixed_double_live_ranges()) { |
509 PrintLiveRangeChain(range, "fixed"); | 509 PrintLiveRangeChain(range, "fixed"); |
510 } | 510 } |
511 | 511 |
512 for (auto range : data->fixed_live_ranges()) { | 512 for (const TopLevelLiveRange* range : data->fixed_live_ranges()) { |
513 PrintLiveRangeChain(range, "fixed"); | 513 PrintLiveRangeChain(range, "fixed"); |
514 } | 514 } |
515 | 515 |
516 for (auto range : data->live_ranges()) { | 516 for (const TopLevelLiveRange* range : data->live_ranges()) { |
517 PrintLiveRangeChain(range, "object"); | 517 PrintLiveRangeChain(range, "object"); |
518 } | 518 } |
519 } | 519 } |
520 | 520 |
521 | 521 void GraphC1Visualizer::PrintLiveRangeChain(const TopLevelLiveRange* range, |
522 void GraphC1Visualizer::PrintLiveRangeChain(TopLevelLiveRange* range, | |
523 const char* type) { | 522 const char* type) { |
524 if (range == nullptr || range->IsEmpty()) return; | 523 if (range == nullptr || range->IsEmpty()) return; |
525 int vreg = range->vreg(); | 524 int vreg = range->vreg(); |
526 for (LiveRange* child = range; child != nullptr; child = child->next()) { | 525 for (const LiveRange* child = range; child != nullptr; |
| 526 child = child->next()) { |
527 PrintLiveRange(child, type, vreg); | 527 PrintLiveRange(child, type, vreg); |
528 } | 528 } |
529 } | 529 } |
530 | 530 |
531 | 531 void GraphC1Visualizer::PrintLiveRange(const LiveRange* range, const char* type, |
532 void GraphC1Visualizer::PrintLiveRange(LiveRange* range, const char* type, | |
533 int vreg) { | 532 int vreg) { |
534 if (range != nullptr && !range->IsEmpty()) { | 533 if (range != nullptr && !range->IsEmpty()) { |
535 PrintIndent(); | 534 PrintIndent(); |
536 os_ << vreg << ":" << range->relative_id() << " " << type; | 535 os_ << vreg << ":" << range->relative_id() << " " << type; |
537 if (range->HasRegisterAssigned()) { | 536 if (range->HasRegisterAssigned()) { |
538 AllocatedOperand op = AllocatedOperand::cast(range->GetAssignedOperand()); | 537 AllocatedOperand op = AllocatedOperand::cast(range->GetAssignedOperand()); |
539 if (op.IsDoubleRegister()) { | 538 if (op.IsDoubleRegister()) { |
540 DoubleRegister assigned_reg = op.GetDoubleRegister(); | 539 DoubleRegister assigned_reg = op.GetDoubleRegister(); |
541 os_ << " \"" << assigned_reg.ToString() << "\""; | 540 os_ << " \"" << assigned_reg.ToString() << "\""; |
542 } else { | 541 } else { |
543 DCHECK(op.IsRegister()); | 542 DCHECK(op.IsRegister()); |
544 Register assigned_reg = op.GetRegister(); | 543 Register assigned_reg = op.GetRegister(); |
545 os_ << " \"" << assigned_reg.ToString() << "\""; | 544 os_ << " \"" << assigned_reg.ToString() << "\""; |
546 } | 545 } |
547 } else if (range->spilled()) { | 546 } else if (range->spilled()) { |
548 auto top = range->TopLevel(); | 547 const TopLevelLiveRange* top = range->TopLevel(); |
549 int index = -1; | 548 int index = -1; |
550 if (top->HasSpillRange()) { | 549 if (top->HasSpillRange()) { |
551 index = kMaxInt; // This hasn't been set yet. | 550 index = kMaxInt; // This hasn't been set yet. |
552 } else if (top->GetSpillOperand()->IsConstant()) { | 551 } else if (top->GetSpillOperand()->IsConstant()) { |
553 os_ << " \"const(nostack):" | 552 os_ << " \"const(nostack):" |
554 << ConstantOperand::cast(top->GetSpillOperand())->virtual_register() | 553 << ConstantOperand::cast(top->GetSpillOperand())->virtual_register() |
555 << "\""; | 554 << "\""; |
556 } else { | 555 } else { |
557 index = AllocatedOperand::cast(top->GetSpillOperand())->index(); | 556 index = AllocatedOperand::cast(top->GetSpillOperand())->index(); |
558 if (top->kind() == DOUBLE_REGISTERS) { | 557 if (top->kind() == DOUBLE_REGISTERS) { |
559 os_ << " \"double_stack:" << index << "\""; | 558 os_ << " \"double_stack:" << index << "\""; |
560 } else if (top->kind() == GENERAL_REGISTERS) { | 559 } else if (top->kind() == GENERAL_REGISTERS) { |
561 os_ << " \"stack:" << index << "\""; | 560 os_ << " \"stack:" << index << "\""; |
562 } | 561 } |
563 } | 562 } |
564 } | 563 } |
565 | 564 |
566 os_ << " " << vreg; | 565 os_ << " " << vreg; |
567 for (auto interval = range->first_interval(); interval != nullptr; | 566 for (const UseInterval* interval = range->first_interval(); |
568 interval = interval->next()) { | 567 interval != nullptr; interval = interval->next()) { |
569 os_ << " [" << interval->start().value() << ", " | 568 os_ << " [" << interval->start().value() << ", " |
570 << interval->end().value() << "["; | 569 << interval->end().value() << "["; |
571 } | 570 } |
572 | 571 |
573 UsePosition* current_pos = range->first_pos(); | 572 UsePosition* current_pos = range->first_pos(); |
574 while (current_pos != nullptr) { | 573 while (current_pos != nullptr) { |
575 if (current_pos->RegisterIsBeneficial() || FLAG_trace_all_uses) { | 574 if (current_pos->RegisterIsBeneficial() || FLAG_trace_all_uses) { |
576 os_ << " " << current_pos->pos().value() << " M"; | 575 os_ << " " << current_pos->pos().value() << " M"; |
577 } | 576 } |
578 current_pos = current_pos->next(); | 577 current_pos = current_pos->next(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); | 636 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); |
638 } | 637 } |
639 os << ")" << std::endl; | 638 os << ")" << std::endl; |
640 } | 639 } |
641 } | 640 } |
642 return os; | 641 return os; |
643 } | 642 } |
644 } // namespace compiler | 643 } // namespace compiler |
645 } // namespace internal | 644 } // namespace internal |
646 } // namespace v8 | 645 } // namespace v8 |
OLD | NEW |