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/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" |
11 #include "src/compiler/all-nodes.h" | 11 #include "src/compiler/all-nodes.h" |
12 #include "src/compiler/graph.h" | 12 #include "src/compiler/graph.h" |
13 #include "src/compiler/node.h" | 13 #include "src/compiler/node.h" |
14 #include "src/compiler/node-properties.h" | 14 #include "src/compiler/node-properties.h" |
15 #include "src/compiler/opcodes.h" | 15 #include "src/compiler/opcodes.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 | 186 |
187 private: | 187 private: |
188 std::ostream& os_; | 188 std::ostream& os_; |
189 AllNodes all_; | 189 AllNodes all_; |
190 bool first_edge_; | 190 bool first_edge_; |
191 | 191 |
192 DISALLOW_COPY_AND_ASSIGN(JSONGraphEdgeWriter); | 192 DISALLOW_COPY_AND_ASSIGN(JSONGraphEdgeWriter); |
193 }; | 193 }; |
194 | 194 |
195 | 195 |
196 std::ostream& operator<<(std::ostream& os, const AsJSON& ad) { | 196 std::ostream& operator<<(std::ostream& os, const GraphAsJSON& ad) { |
197 Zone tmp_zone; | 197 Zone tmp_zone; |
198 os << "{\n\"nodes\":["; | 198 os << "{\n\"nodes\":["; |
199 JSONGraphNodeWriter(os, &tmp_zone, &ad.graph, ad.positions).Print(); | 199 JSONGraphNodeWriter(os, &tmp_zone, &ad.graph, ad.positions).Print(); |
200 os << "],\n\"edges\":["; | 200 os << "],\n\"edges\":["; |
201 JSONGraphEdgeWriter(os, &tmp_zone, &ad.graph).Print(); | 201 JSONGraphEdgeWriter(os, &tmp_zone, &ad.graph).Print(); |
202 os << "]}"; | 202 os << "]}"; |
203 return os; | 203 return os; |
204 } | 204 } |
205 | 205 |
206 | 206 |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
812 int j = 0; | 812 int j = 0; |
813 for (Node* const i : n->inputs()) { | 813 for (Node* const i : n->inputs()) { |
814 if (j++ > 0) os << ", "; | 814 if (j++ > 0) os << ", "; |
815 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); | 815 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); |
816 } | 816 } |
817 os << ")" << std::endl; | 817 os << ")" << std::endl; |
818 } | 818 } |
819 } | 819 } |
820 return os; | 820 return os; |
821 } | 821 } |
822 | |
823 | |
824 std::ostream& operator<<(std::ostream& os, const ScheduleAsJSON& aj) { | |
Michael Starzinger
2015/03/06 17:51:55
Why is this called ScheduleAsJSON, there doesn't s
danno
2015/04/09 13:50:33
Done.
| |
825 for (const BasicBlock* block : *(aj.schedule.rpo_order())) { | |
826 os << "--- BLOCK B" << block->id(); | |
827 if (block->deferred()) os << " (deferred)"; | |
828 if (block->PredecessorCount() != 0) os << " <- "; | |
829 bool comma = false; | |
830 for (BasicBlock const* predecessor : block->predecessors()) { | |
831 if (comma) os << ", "; | |
832 comma = true; | |
833 os << "B" << predecessor->id(); | |
834 } | |
835 os << " ---\n"; | |
836 int previous_pos = -1; | |
837 for (Node* node : *block) { | |
838 os << " " << *node; | |
839 if (NodeProperties::IsTyped(node)) { | |
840 Bounds bounds = NodeProperties::GetBounds(node); | |
841 os << " : "; | |
842 bounds.lower->PrintTo(os); | |
843 if (!bounds.upper->Is(bounds.lower)) { | |
844 os << ".."; | |
845 bounds.upper->PrintTo(os); | |
846 } | |
847 } | |
848 if (aj.positions != NULL) { | |
849 SourcePosition p = aj.positions->GetSourcePosition(node); | |
Michael Starzinger
2015/03/06 17:51:55
I assume the visualizer parses these source positi
danno
2015/04/09 13:50:33
Done.
| |
850 int current_pos = p.raw(); | |
851 if (current_pos != -1) { | |
852 if (current_pos != previous_pos) { | |
853 os << " ;; position " << current_pos; | |
854 previous_pos = current_pos; | |
855 } | |
856 } | |
857 } | |
858 os << "\n"; | |
859 } | |
860 BasicBlock::Control control = block->control(); | |
861 if (control != BasicBlock::kNone) { | |
862 os << " "; | |
863 if (block->control_input() != NULL) { | |
864 os << *block->control_input(); | |
865 } else { | |
866 os << "Goto"; | |
867 } | |
868 os << " -> "; | |
869 comma = false; | |
870 for (BasicBlock const* successor : block->successors()) { | |
871 if (comma) os << ", "; | |
872 comma = true; | |
873 os << "B" << successor->id(); | |
874 } | |
875 os << "\n"; | |
876 } | |
877 } | |
878 return os; | |
879 } | |
822 } | 880 } |
823 } | 881 } |
824 } // namespace v8::internal::compiler | 882 } // namespace v8::internal::compiler |
OLD | NEW |