| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 class GraphVisualizer { | 221 class GraphVisualizer { |
| 222 public: | 222 public: |
| 223 GraphVisualizer(std::ostream& os, Zone* zone, const Graph* graph) | 223 GraphVisualizer(std::ostream& os, Zone* zone, const Graph* graph) |
| 224 : all_(zone, graph), os_(os) {} | 224 : all_(zone, graph), os_(os) {} |
| 225 | 225 |
| 226 void Print(); | 226 void Print(); |
| 227 | 227 |
| 228 void PrintNode(Node* node, bool gray); | 228 void PrintNode(Node* node, bool gray); |
| 229 | 229 |
| 230 private: | 230 private: |
| 231 void PrintEdge(Node::Edge edge); | 231 void PrintEdge(Edge edge); |
| 232 | 232 |
| 233 AllNodes all_; | 233 AllNodes all_; |
| 234 std::ostream& os_; | 234 std::ostream& os_; |
| 235 | 235 |
| 236 DISALLOW_COPY_AND_ASSIGN(GraphVisualizer); | 236 DISALLOW_COPY_AND_ASSIGN(GraphVisualizer); |
| 237 }; | 237 }; |
| 238 | 238 |
| 239 | 239 |
| 240 static Node* GetControlCluster(Node* node) { | 240 static Node* GetControlCluster(Node* node) { |
| 241 if (OperatorProperties::IsBasicBlockBegin(node->op())) { | 241 if (OperatorProperties::IsBasicBlockBegin(node->op())) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 279 if (gray) { | 279 if (gray) { |
| 280 os_ << " style=\"filled\"\n" | 280 os_ << " style=\"filled\"\n" |
| 281 << " fillcolor=\"" DEAD_COLOR "\"\n"; | 281 << " fillcolor=\"" DEAD_COLOR "\"\n"; |
| 282 } | 282 } |
| 283 | 283 |
| 284 std::ostringstream label; | 284 std::ostringstream label; |
| 285 label << *node->op(); | 285 label << *node->op(); |
| 286 os_ << " label=\"{{#" << SafeId(node) << ":" << Escaped(label); | 286 os_ << " label=\"{{#" << SafeId(node) << ":" << Escaped(label); |
| 287 | 287 |
| 288 InputIter i = node->inputs().begin(); | 288 auto i = node->input_edges().begin(); |
| 289 for (int j = node->op()->ValueInputCount(); j > 0; ++i, j--) { | 289 for (int j = node->op()->ValueInputCount(); j > 0; ++i, j--) { |
| 290 os_ << "|<I" << i.index() << ">#" << SafeId(*i); | 290 os_ << "|<I" << (*i).index() << ">#" << SafeId((*i).to()); |
| 291 } | 291 } |
| 292 for (int j = OperatorProperties::GetContextInputCount(node->op()); j > 0; | 292 for (int j = OperatorProperties::GetContextInputCount(node->op()); j > 0; |
| 293 ++i, j--) { | 293 ++i, j--) { |
| 294 os_ << "|<I" << i.index() << ">X #" << SafeId(*i); | 294 os_ << "|<I" << (*i).index() << ">X #" << SafeId((*i).to()); |
| 295 } | 295 } |
| 296 for (int j = OperatorProperties::GetFrameStateInputCount(node->op()); j > 0; | 296 for (int j = OperatorProperties::GetFrameStateInputCount(node->op()); j > 0; |
| 297 ++i, j--) { | 297 ++i, j--) { |
| 298 os_ << "|<I" << i.index() << ">F #" << SafeId(*i); | 298 os_ << "|<I" << (*i).index() << ">F #" << SafeId((*i).to()); |
| 299 } | 299 } |
| 300 for (int j = node->op()->EffectInputCount(); j > 0; ++i, j--) { | 300 for (int j = node->op()->EffectInputCount(); j > 0; ++i, j--) { |
| 301 os_ << "|<I" << i.index() << ">E #" << SafeId(*i); | 301 os_ << "|<I" << (*i).index() << ">E #" << SafeId((*i).to()); |
| 302 } | 302 } |
| 303 | 303 |
| 304 if (OperatorProperties::IsBasicBlockBegin(node->op()) || | 304 if (OperatorProperties::IsBasicBlockBegin(node->op()) || |
| 305 GetControlCluster(node) == NULL) { | 305 GetControlCluster(node) == NULL) { |
| 306 for (int j = node->op()->ControlInputCount(); j > 0; ++i, j--) { | 306 for (int j = node->op()->ControlInputCount(); j > 0; ++i, j--) { |
| 307 os_ << "|<I" << i.index() << ">C #" << SafeId(*i); | 307 os_ << "|<I" << (*i).index() << ">C #" << SafeId((*i).to()); |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 os_ << "}"; | 310 os_ << "}"; |
| 311 | 311 |
| 312 if (FLAG_trace_turbo_types && NodeProperties::IsTyped(node)) { | 312 if (FLAG_trace_turbo_types && NodeProperties::IsTyped(node)) { |
| 313 Bounds bounds = NodeProperties::GetBounds(node); | 313 Bounds bounds = NodeProperties::GetBounds(node); |
| 314 std::ostringstream upper; | 314 std::ostringstream upper; |
| 315 bounds.upper->PrintTo(upper); | 315 bounds.upper->PrintTo(upper); |
| 316 std::ostringstream lower; | 316 std::ostringstream lower; |
| 317 bounds.lower->PrintTo(lower); | 317 bounds.lower->PrintTo(lower); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 331 return control != NULL && control->opcode() != IrOpcode::kMerge && | 331 return control != NULL && control->opcode() != IrOpcode::kMerge && |
| 332 control != to && index != 0; | 332 control != to && index != 0; |
| 333 } else if (from->opcode() == IrOpcode::kLoop) { | 333 } else if (from->opcode() == IrOpcode::kLoop) { |
| 334 return index != 0; | 334 return index != 0; |
| 335 } else { | 335 } else { |
| 336 return false; | 336 return false; |
| 337 } | 337 } |
| 338 } | 338 } |
| 339 | 339 |
| 340 | 340 |
| 341 void GraphVisualizer::PrintEdge(Node::Edge edge) { | 341 void GraphVisualizer::PrintEdge(Edge edge) { |
| 342 Node* from = edge.from(); | 342 Node* from = edge.from(); |
| 343 int index = edge.index(); | 343 int index = edge.index(); |
| 344 Node* to = edge.to(); | 344 Node* to = edge.to(); |
| 345 | 345 |
| 346 if (!all_.IsLive(to)) return; // skip inputs that point to dead or NULL. | 346 if (!all_.IsLive(to)) return; // skip inputs that point to dead or NULL. |
| 347 | 347 |
| 348 bool unconstrained = IsLikelyBackEdge(from, index, to); | 348 bool unconstrained = IsLikelyBackEdge(from, index, to); |
| 349 os_ << " ID" << SafeId(from); | 349 os_ << " ID" << SafeId(from); |
| 350 | 350 |
| 351 if (OperatorProperties::IsBasicBlockBegin(from->op()) || | 351 if (OperatorProperties::IsBasicBlockBegin(from->op()) || |
| (...skipping 23 matching lines...) Expand all Loading... |
| 375 << " splines=\"true\"\n" | 375 << " splines=\"true\"\n" |
| 376 << " concentrate=\"true\"\n" | 376 << " concentrate=\"true\"\n" |
| 377 << " \n"; | 377 << " \n"; |
| 378 | 378 |
| 379 // Make sure all nodes have been output before writing out the edges. | 379 // Make sure all nodes have been output before writing out the edges. |
| 380 for (Node* const node : all_.live) PrintNode(node, false); | 380 for (Node* const node : all_.live) PrintNode(node, false); |
| 381 for (Node* const node : all_.gray) PrintNode(node, true); | 381 for (Node* const node : all_.gray) PrintNode(node, true); |
| 382 | 382 |
| 383 // With all the nodes written, add the edges. | 383 // With all the nodes written, add the edges. |
| 384 for (Node* const node : all_.live) { | 384 for (Node* const node : all_.live) { |
| 385 for (UseIter i = node->uses().begin(); i != node->uses().end(); ++i) { | 385 for (Edge edge : node->use_edges()) { |
| 386 PrintEdge(i.edge()); | 386 PrintEdge(edge); |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 os_ << "}\n"; | 389 os_ << "}\n"; |
| 390 } | 390 } |
| 391 | 391 |
| 392 | 392 |
| 393 std::ostream& operator<<(std::ostream& os, const AsDOT& ad) { | 393 std::ostream& operator<<(std::ostream& os, const AsDOT& ad) { |
| 394 Zone tmp_zone(ad.graph.zone()->isolate()); | 394 Zone tmp_zone(ad.graph.zone()->isolate()); |
| 395 GraphVisualizer(os, &tmp_zone, &ad.graph).Print(); | 395 GraphVisualizer(os, &tmp_zone, &ad.graph).Print(); |
| 396 return os; | 396 return os; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 while (count > 0) { | 524 while (count > 0) { |
| 525 os_ << " "; | 525 os_ << " "; |
| 526 PrintNodeId(**i); | 526 PrintNodeId(**i); |
| 527 ++(*i); | 527 ++(*i); |
| 528 count--; | 528 count--; |
| 529 } | 529 } |
| 530 } | 530 } |
| 531 | 531 |
| 532 | 532 |
| 533 void GraphC1Visualizer::PrintInputs(Node* node) { | 533 void GraphC1Visualizer::PrintInputs(Node* node) { |
| 534 InputIter i = node->inputs().begin(); | 534 auto i = node->inputs().begin(); |
| 535 PrintInputs(&i, node->op()->ValueInputCount(), " "); | 535 PrintInputs(&i, node->op()->ValueInputCount(), " "); |
| 536 PrintInputs(&i, OperatorProperties::GetContextInputCount(node->op()), | 536 PrintInputs(&i, OperatorProperties::GetContextInputCount(node->op()), |
| 537 " Ctx:"); | 537 " Ctx:"); |
| 538 PrintInputs(&i, OperatorProperties::GetFrameStateInputCount(node->op()), | 538 PrintInputs(&i, OperatorProperties::GetFrameStateInputCount(node->op()), |
| 539 " FS:"); | 539 " FS:"); |
| 540 PrintInputs(&i, node->op()->EffectInputCount(), " Eff:"); | 540 PrintInputs(&i, node->op()->EffectInputCount(), " Eff:"); |
| 541 PrintInputs(&i, node->op()->ControlInputCount(), " Ctrl:"); | 541 PrintInputs(&i, node->op()->ControlInputCount(), " Ctrl:"); |
| 542 } | 542 } |
| 543 | 543 |
| 544 | 544 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); | 824 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); |
| 825 } | 825 } |
| 826 os << ")" << std::endl; | 826 os << ")" << std::endl; |
| 827 } | 827 } |
| 828 } | 828 } |
| 829 return os; | 829 return os; |
| 830 } | 830 } |
| 831 } | 831 } |
| 832 } | 832 } |
| 833 } // namespace v8::internal::compiler | 833 } // namespace v8::internal::compiler |
| OLD | NEW |