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

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

Issue 2040243002: [turbofan] add more comments to compiler/graph-visualizer.cc. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Polish Created 4 years, 6 months 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 | « no previous file | no next file » | 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 aca9dbcba3642a9b2acd60153530865d99254f06..f2368931fa21ec3283c84f9260673b8e8b64464c 100644
--- a/src/compiler/graph-visualizer.cc
+++ b/src/compiler/graph-visualizer.cc
@@ -618,6 +618,20 @@ const int kVisited = 2;
std::ostream& operator<<(std::ostream& os, const AsRPO& ar) {
base::AccountingAllocator allocator;
Zone local_zone(&allocator);
+
+ // Do a post-order depth-first search on the RPO graph. For every node,
+ // print:
+ //
+ // - the node id
+ // - the operator mnemonic
+ // - in square brackets its parameter (if present)
+ // - in parentheses the list of argument ids and their mnemonics
+ // - the node type (if it is typed)
+
+ // Post-order guarantees that all inputs of a node will be printed before
+ // the node itself, if there are no cycles. Any cycles are broken
+ // arbitrarily.
+
ZoneVector<byte> state(ar.graph.NodeCount(), kUnvisited, &local_zone);
ZoneStack<Node*> stack(&local_zone);
@@ -638,12 +652,14 @@ std::ostream& operator<<(std::ostream& os, const AsRPO& ar) {
state[n->id()] = kVisited;
stack.pop();
os << "#" << n->id() << ":" << *n->op() << "(";
+ // Print the inputs.
int j = 0;
for (Node* const i : n->inputs()) {
if (j++ > 0) os << ", ";
os << "#" << SafeId(i) << ":" << SafeMnemonic(i);
}
os << ")";
+ // Print the node type, if any.
if (NodeProperties::IsTyped(n)) {
os << " [Type: ";
NodeProperties::GetType(n)->PrintTo(os);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698