| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 JSONGraphNodeWriter(os, &tmp_zone, &ad.graph).Print(); | 212 JSONGraphNodeWriter(os, &tmp_zone, &ad.graph).Print(); |
| 213 os << "],\"edges\":["; | 213 os << "],\"edges\":["; |
| 214 JSONGraphEdgeWriter(os, &tmp_zone, &ad.graph).Print(); | 214 JSONGraphEdgeWriter(os, &tmp_zone, &ad.graph).Print(); |
| 215 os << "]}"; | 215 os << "]}"; |
| 216 return os; | 216 return os; |
| 217 } | 217 } |
| 218 | 218 |
| 219 | 219 |
| 220 class GraphVisualizer { | 220 class GraphVisualizer { |
| 221 public: | 221 public: |
| 222 GraphVisualizer(std::ostream& os, Zone* zone, const Graph* graph); // NOLINT | 222 GraphVisualizer(std::ostream& os, Zone* zone, const Graph* graph) |
| 223 : all_(zone, graph), os_(os) {} |
| 223 | 224 |
| 224 void Print(); | 225 void Print(); |
| 225 | 226 |
| 226 void PrintNode(Node* node, bool gray); | 227 void PrintNode(Node* node, bool gray); |
| 227 | 228 |
| 228 private: | 229 private: |
| 229 void PrintEdge(Node::Edge edge); | 230 void PrintEdge(Node::Edge edge); |
| 230 | 231 |
| 231 Zone* zone_; | |
| 232 AllNodes all_; | 232 AllNodes all_; |
| 233 std::ostream& os_; | 233 std::ostream& os_; |
| 234 const Graph* const graph_; | |
| 235 | 234 |
| 236 DISALLOW_COPY_AND_ASSIGN(GraphVisualizer); | 235 DISALLOW_COPY_AND_ASSIGN(GraphVisualizer); |
| 237 }; | 236 }; |
| 238 | 237 |
| 239 | 238 |
| 240 static Node* GetControlCluster(Node* node) { | 239 static Node* GetControlCluster(Node* node) { |
| 241 if (OperatorProperties::IsBasicBlockBegin(node->op())) { | 240 if (OperatorProperties::IsBasicBlockBegin(node->op())) { |
| 242 return node; | 241 return node; |
| 243 } else if (node->op()->ControlInputCount() == 1) { | 242 } else if (node->op()->ControlInputCount() == 1) { |
| 244 Node* control = NodeProperties::GetControlInput(node, 0); | 243 Node* control = NodeProperties::GetControlInput(node, 0); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 // With all the nodes written, add the edges. | 382 // With all the nodes written, add the edges. |
| 384 for (Node* const node : all_.live) { | 383 for (Node* const node : all_.live) { |
| 385 for (UseIter i = node->uses().begin(); i != node->uses().end(); ++i) { | 384 for (UseIter i = node->uses().begin(); i != node->uses().end(); ++i) { |
| 386 PrintEdge(i.edge()); | 385 PrintEdge(i.edge()); |
| 387 } | 386 } |
| 388 } | 387 } |
| 389 os_ << "}\n"; | 388 os_ << "}\n"; |
| 390 } | 389 } |
| 391 | 390 |
| 392 | 391 |
| 393 GraphVisualizer::GraphVisualizer(std::ostream& os, Zone* zone, | |
| 394 const Graph* graph) // NOLINT | |
| 395 : zone_(zone), | |
| 396 all_(zone, graph), | |
| 397 os_(os), | |
| 398 graph_(graph) {} | |
| 399 | |
| 400 | |
| 401 std::ostream& operator<<(std::ostream& os, const AsDOT& ad) { | 392 std::ostream& operator<<(std::ostream& os, const AsDOT& ad) { |
| 402 Zone tmp_zone(ad.graph.zone()->isolate()); | 393 Zone tmp_zone(ad.graph.zone()->isolate()); |
| 403 GraphVisualizer(os, &tmp_zone, &ad.graph).Print(); | 394 GraphVisualizer(os, &tmp_zone, &ad.graph).Print(); |
| 404 return os; | 395 return os; |
| 405 } | 396 } |
| 406 | 397 |
| 407 | 398 |
| 408 class GraphC1Visualizer { | 399 class GraphC1Visualizer { |
| 409 public: | 400 public: |
| 410 GraphC1Visualizer(std::ostream& os, Zone* zone); // NOLINT | 401 GraphC1Visualizer(std::ostream& os, Zone* zone); // NOLINT |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 | 779 |
| 789 | 780 |
| 790 std::ostream& operator<<(std::ostream& os, const AsC1VAllocator& ac) { | 781 std::ostream& operator<<(std::ostream& os, const AsC1VAllocator& ac) { |
| 791 Zone tmp_zone(ac.allocator_->code()->zone()->isolate()); | 782 Zone tmp_zone(ac.allocator_->code()->zone()->isolate()); |
| 792 GraphC1Visualizer(os, &tmp_zone).PrintAllocator(ac.phase_, ac.allocator_); | 783 GraphC1Visualizer(os, &tmp_zone).PrintAllocator(ac.phase_, ac.allocator_); |
| 793 return os; | 784 return os; |
| 794 } | 785 } |
| 795 } | 786 } |
| 796 } | 787 } |
| 797 } // namespace v8::internal::compiler | 788 } // namespace v8::internal::compiler |
| OLD | NEW |