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

Unified Diff: src/compiler/graph-visualizer.cc

Issue 754803002: [turbofan] Dump graph in RPO order as text. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/graph-visualizer.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/graph-visualizer.cc
diff --git a/src/compiler/graph-visualizer.cc b/src/compiler/graph-visualizer.cc
index c9be0ac5ac2450f0f2bb2cde4a442aa0a264c11f..032bc9fac0a35c4cd2ce576ca0e28b9e0d3a6aad 100644
--- a/src/compiler/graph-visualizer.cc
+++ b/src/compiler/graph-visualizer.cc
@@ -27,6 +27,9 @@ namespace internal {
namespace compiler {
static int SafeId(Node* node) { return node == NULL ? -1 : node->id(); }
+static const char* SafeMnemonic(Node* node) {
+ return node == NULL ? "null" : node->op()->mnemonic();
+}
#define DEAD_COLOR "#999999"
@@ -790,6 +793,43 @@ std::ostream& operator<<(std::ostream& os, const AsC1VAllocator& ac) {
GraphC1Visualizer(os, &tmp_zone).PrintAllocator(ac.phase_, ac.allocator_);
return os;
}
+
+const int kUnvisited = 0;
+const int kOnStack = 1;
+const int kVisited = 2;
+
+std::ostream& operator<<(std::ostream& os, const AsRPO& ar) {
+ Zone local_zone(ar.graph.zone()->isolate());
+ ZoneVector<byte> state(ar.graph.NodeCount(), kUnvisited, &local_zone);
+ ZoneStack<Node*> stack(&local_zone);
+
+ stack.push(ar.graph.end());
+ state[ar.graph.end()->id()] = kOnStack;
+ while (!stack.empty()) {
+ Node* n = stack.top();
+ bool pop = true;
+ for (Node* const i : n->inputs()) {
+ if (state[i->id()] == kUnvisited) {
+ state[i->id()] = kOnStack;
+ stack.push(i);
+ pop = false;
+ break;
+ }
+ }
+ if (pop) {
+ state[n->id()] = kVisited;
+ stack.pop();
+ os << "#" << SafeId(n) << ":" << SafeMnemonic(n) << "(";
+ int j = 0;
+ for (Node* const i : n->inputs()) {
+ if (j++ > 0) os << ", ";
+ os << "#" << SafeId(i) << ":" << SafeMnemonic(i);
+ }
+ os << ")" << std::endl;
+ }
+ }
+ return os;
+}
}
}
} // namespace v8::internal::compiler
« no previous file with comments | « src/compiler/graph-visualizer.h ('k') | src/compiler/pipeline.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698