| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 private: | 201 private: |
| 202 std::ostream& os_; | 202 std::ostream& os_; |
| 203 AllNodes all_; | 203 AllNodes all_; |
| 204 bool first_edge_; | 204 bool first_edge_; |
| 205 | 205 |
| 206 DISALLOW_COPY_AND_ASSIGN(JSONGraphEdgeWriter); | 206 DISALLOW_COPY_AND_ASSIGN(JSONGraphEdgeWriter); |
| 207 }; | 207 }; |
| 208 | 208 |
| 209 | 209 |
| 210 std::ostream& operator<<(std::ostream& os, const AsJSON& ad) { | 210 std::ostream& operator<<(std::ostream& os, const AsJSON& ad) { |
| 211 Zone tmp_zone(ad.graph.zone()->isolate()); | 211 Zone tmp_zone; |
| 212 os << "{\"nodes\":["; | 212 os << "{\"nodes\":["; |
| 213 JSONGraphNodeWriter(os, &tmp_zone, &ad.graph).Print(); | 213 JSONGraphNodeWriter(os, &tmp_zone, &ad.graph).Print(); |
| 214 os << "],\"edges\":["; | 214 os << "],\"edges\":["; |
| 215 JSONGraphEdgeWriter(os, &tmp_zone, &ad.graph).Print(); | 215 JSONGraphEdgeWriter(os, &tmp_zone, &ad.graph).Print(); |
| 216 os << "]}"; | 216 os << "]}"; |
| 217 return os; | 217 return os; |
| 218 } | 218 } |
| 219 | 219 |
| 220 | 220 |
| 221 class GraphVisualizer { | 221 class GraphVisualizer { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 for (Node* const node : all_.live) { | 383 for (Node* const node : all_.live) { |
| 384 for (Edge edge : node->use_edges()) { | 384 for (Edge edge : node->use_edges()) { |
| 385 PrintEdge(edge); | 385 PrintEdge(edge); |
| 386 } | 386 } |
| 387 } | 387 } |
| 388 os_ << "}\n"; | 388 os_ << "}\n"; |
| 389 } | 389 } |
| 390 | 390 |
| 391 | 391 |
| 392 std::ostream& operator<<(std::ostream& os, const AsDOT& ad) { | 392 std::ostream& operator<<(std::ostream& os, const AsDOT& ad) { |
| 393 Zone tmp_zone(ad.graph.zone()->isolate()); | 393 Zone tmp_zone; |
| 394 GraphVisualizer(os, &tmp_zone, &ad.graph).Print(); | 394 GraphVisualizer(os, &tmp_zone, &ad.graph).Print(); |
| 395 return os; | 395 return os; |
| 396 } | 396 } |
| 397 | 397 |
| 398 | 398 |
| 399 class GraphC1Visualizer { | 399 class GraphC1Visualizer { |
| 400 public: | 400 public: |
| 401 GraphC1Visualizer(std::ostream& os, Zone* zone); // NOLINT | 401 GraphC1Visualizer(std::ostream& os, Zone* zone); // NOLINT |
| 402 | 402 |
| 403 void PrintCompilation(const CompilationInfo* info); | 403 void PrintCompilation(const CompilationInfo* info); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 } | 762 } |
| 763 current_pos = current_pos->next(); | 763 current_pos = current_pos->next(); |
| 764 } | 764 } |
| 765 | 765 |
| 766 os_ << " \"\"\n"; | 766 os_ << " \"\"\n"; |
| 767 } | 767 } |
| 768 } | 768 } |
| 769 | 769 |
| 770 | 770 |
| 771 std::ostream& operator<<(std::ostream& os, const AsC1VCompilation& ac) { | 771 std::ostream& operator<<(std::ostream& os, const AsC1VCompilation& ac) { |
| 772 Zone tmp_zone(ac.info_->isolate()); | 772 Zone tmp_zone; |
| 773 GraphC1Visualizer(os, &tmp_zone).PrintCompilation(ac.info_); | 773 GraphC1Visualizer(os, &tmp_zone).PrintCompilation(ac.info_); |
| 774 return os; | 774 return os; |
| 775 } | 775 } |
| 776 | 776 |
| 777 | 777 |
| 778 std::ostream& operator<<(std::ostream& os, const AsC1V& ac) { | 778 std::ostream& operator<<(std::ostream& os, const AsC1V& ac) { |
| 779 Zone tmp_zone(ac.schedule_->zone()->isolate()); | 779 Zone tmp_zone; |
| 780 GraphC1Visualizer(os, &tmp_zone) | 780 GraphC1Visualizer(os, &tmp_zone) |
| 781 .PrintSchedule(ac.phase_, ac.schedule_, ac.positions_, ac.instructions_); | 781 .PrintSchedule(ac.phase_, ac.schedule_, ac.positions_, ac.instructions_); |
| 782 return os; | 782 return os; |
| 783 } | 783 } |
| 784 | 784 |
| 785 | 785 |
| 786 std::ostream& operator<<(std::ostream& os, const AsC1VAllocator& ac) { | 786 std::ostream& operator<<(std::ostream& os, const AsC1VAllocator& ac) { |
| 787 Zone tmp_zone(ac.allocator_->code()->zone()->isolate()); | 787 Zone tmp_zone; |
| 788 GraphC1Visualizer(os, &tmp_zone).PrintAllocator(ac.phase_, ac.allocator_); | 788 GraphC1Visualizer(os, &tmp_zone).PrintAllocator(ac.phase_, ac.allocator_); |
| 789 return os; | 789 return os; |
| 790 } | 790 } |
| 791 | 791 |
| 792 const int kUnvisited = 0; | 792 const int kUnvisited = 0; |
| 793 const int kOnStack = 1; | 793 const int kOnStack = 1; |
| 794 const int kVisited = 2; | 794 const int kVisited = 2; |
| 795 | 795 |
| 796 std::ostream& operator<<(std::ostream& os, const AsRPO& ar) { | 796 std::ostream& operator<<(std::ostream& os, const AsRPO& ar) { |
| 797 Zone local_zone(ar.graph.zone()->isolate()); | 797 Zone local_zone; |
| 798 ZoneVector<byte> state(ar.graph.NodeCount(), kUnvisited, &local_zone); | 798 ZoneVector<byte> state(ar.graph.NodeCount(), kUnvisited, &local_zone); |
| 799 ZoneStack<Node*> stack(&local_zone); | 799 ZoneStack<Node*> stack(&local_zone); |
| 800 | 800 |
| 801 stack.push(ar.graph.end()); | 801 stack.push(ar.graph.end()); |
| 802 state[ar.graph.end()->id()] = kOnStack; | 802 state[ar.graph.end()->id()] = kOnStack; |
| 803 while (!stack.empty()) { | 803 while (!stack.empty()) { |
| 804 Node* n = stack.top(); | 804 Node* n = stack.top(); |
| 805 bool pop = true; | 805 bool pop = true; |
| 806 for (Node* const i : n->inputs()) { | 806 for (Node* const i : n->inputs()) { |
| 807 if (state[i->id()] == kUnvisited) { | 807 if (state[i->id()] == kUnvisited) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 821 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); | 821 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); |
| 822 } | 822 } |
| 823 os << ")" << std::endl; | 823 os << ")" << std::endl; |
| 824 } | 824 } |
| 825 } | 825 } |
| 826 return os; | 826 return os; |
| 827 } | 827 } |
| 828 } | 828 } |
| 829 } | 829 } |
| 830 } // namespace v8::internal::compiler | 830 } // namespace v8::internal::compiler |
| OLD | NEW |