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

Side by Side 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: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 return os; 611 return os;
612 } 612 }
613 613
614 const int kUnvisited = 0; 614 const int kUnvisited = 0;
615 const int kOnStack = 1; 615 const int kOnStack = 1;
616 const int kVisited = 2; 616 const int kVisited = 2;
617 617
618 std::ostream& operator<<(std::ostream& os, const AsRPO& ar) { 618 std::ostream& operator<<(std::ostream& os, const AsRPO& ar) {
619 base::AccountingAllocator allocator; 619 base::AccountingAllocator allocator;
620 Zone local_zone(&allocator); 620 Zone local_zone(&allocator);
621
622 // Do a post-order depth-first search on the RPO graph. For every node,
623 // print:
624 //
625 // - the node id
626 // - the operator mnemonic
627 // - in square brackets its parameter (if present)
628 // - in parentheses the list of argument ids and their mnemonics
629 // - the node type (if it is typed)
630
631 // Post-order guarantees that all inputs of a node will be printed before
632 // the node itself.
Jarin 2016/06/07 19:35:31 Maybe you should hedge with "(if possible, cycles
bgeron 2016/06/08 12:04:56 Done.
633
621 ZoneVector<byte> state(ar.graph.NodeCount(), kUnvisited, &local_zone); 634 ZoneVector<byte> state(ar.graph.NodeCount(), kUnvisited, &local_zone);
622 ZoneStack<Node*> stack(&local_zone); 635 ZoneStack<Node*> stack(&local_zone);
623 636
624 stack.push(ar.graph.end()); 637 stack.push(ar.graph.end());
625 state[ar.graph.end()->id()] = kOnStack; 638 state[ar.graph.end()->id()] = kOnStack;
626 while (!stack.empty()) { 639 while (!stack.empty()) {
627 Node* n = stack.top(); 640 Node* n = stack.top();
628 bool pop = true; 641 bool pop = true;
629 for (Node* const i : n->inputs()) { 642 for (Node* const i : n->inputs()) {
630 if (state[i->id()] == kUnvisited) { 643 if (state[i->id()] == kUnvisited) {
631 state[i->id()] = kOnStack; 644 state[i->id()] = kOnStack;
632 stack.push(i); 645 stack.push(i);
633 pop = false; 646 pop = false;
634 break; 647 break;
635 } 648 }
636 } 649 }
637 if (pop) { 650 if (pop) {
638 state[n->id()] = kVisited; 651 state[n->id()] = kVisited;
639 stack.pop(); 652 stack.pop();
640 os << "#" << n->id() << ":" << *n->op() << "("; 653 os << "#" << n->id() << ":" << *n->op() << "(";
654 // Print the arguments
Jarin 2016/06/07 19:35:31 arguments -> inputs. Please end sentences in comm
bgeron 2016/06/08 12:04:56 Done.
641 int j = 0; 655 int j = 0;
642 for (Node* const i : n->inputs()) { 656 for (Node* const i : n->inputs()) {
643 if (j++ > 0) os << ", "; 657 if (j++ > 0) os << ", ";
644 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); 658 os << "#" << SafeId(i) << ":" << SafeMnemonic(i);
645 } 659 }
646 os << ")"; 660 os << ")";
661 // Print the node type, if any
647 if (NodeProperties::IsTyped(n)) { 662 if (NodeProperties::IsTyped(n)) {
648 os << " [Type: "; 663 os << " [Type: ";
649 NodeProperties::GetType(n)->PrintTo(os); 664 NodeProperties::GetType(n)->PrintTo(os);
650 os << "]"; 665 os << "]";
651 } 666 }
652 os << std::endl; 667 os << std::endl;
653 } 668 }
654 } 669 }
655 return os; 670 return os;
656 } 671 }
657 } // namespace compiler 672 } // namespace compiler
658 } // namespace internal 673 } // namespace internal
659 } // namespace v8 674 } // namespace v8
OLDNEW
« 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