Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 for (Node* const node : all_.live) PrintNode(node); | 119 for (Node* const node : all_.live) PrintNode(node); |
| 120 os_ << "\n"; | 120 os_ << "\n"; |
| 121 } | 121 } |
| 122 | 122 |
| 123 void PrintNode(Node* node) { | 123 void PrintNode(Node* node) { |
| 124 if (first_node_) { | 124 if (first_node_) { |
| 125 first_node_ = false; | 125 first_node_ = false; |
| 126 } else { | 126 } else { |
| 127 os_ << ",\n"; | 127 os_ << ",\n"; |
| 128 } | 128 } |
| 129 std::ostringstream label, title; | 129 std::ostringstream label, title, properties; |
| 130 node->op()->PrintTo(label, Operator::PrintVerbosity::kSilent); | 130 node->op()->PrintTo(label, Operator::PrintVerbosity::kSilent); |
| 131 node->op()->PrintTo(title, Operator::PrintVerbosity::kVerbose); | 131 node->op()->PrintTo(title, Operator::PrintVerbosity::kVerbose); |
| 132 node->op()->PrintPropsTo(properties); | |
| 132 os_ << "{\"id\":" << SafeId(node) << ",\"label\":\"" << Escaped(label, "\"") | 133 os_ << "{\"id\":" << SafeId(node) << ",\"label\":\"" << Escaped(label, "\"") |
| 133 << "\"" | 134 << "\"" |
| 134 << ",\"title\":\"" << Escaped(title, "\"") << "\""; | 135 << ",\"title\":\"" << Escaped(title, "\"") << "\"" |
| 136 << ",\"properties\":\"" << Escaped(properties, "\"") << "\""; | |
| 135 IrOpcode::Value opcode = node->opcode(); | 137 IrOpcode::Value opcode = node->opcode(); |
| 136 if (IrOpcode::IsPhiOpcode(opcode)) { | 138 if (IrOpcode::IsPhiOpcode(opcode)) { |
| 137 os_ << ",\"rankInputs\":[0," << NodeProperties::FirstControlIndex(node) | 139 os_ << ",\"rankInputs\":[0," << NodeProperties::FirstControlIndex(node) |
| 138 << "]"; | 140 << "]"; |
| 139 os_ << ",\"rankWithInput\":[" << NodeProperties::FirstControlIndex(node) | 141 os_ << ",\"rankWithInput\":[" << NodeProperties::FirstControlIndex(node) |
| 140 << "]"; | 142 << "]"; |
| 141 } else if (opcode == IrOpcode::kIfTrue || opcode == IrOpcode::kIfFalse || | 143 } else if (opcode == IrOpcode::kIfTrue || opcode == IrOpcode::kIfFalse || |
| 142 opcode == IrOpcode::kLoop) { | 144 opcode == IrOpcode::kLoop) { |
| 143 os_ << ",\"rankInputs\":[" << NodeProperties::FirstControlIndex(node) | 145 os_ << ",\"rankInputs\":[" << NodeProperties::FirstControlIndex(node) |
| 144 << "]"; | 146 << "]"; |
| 145 } | 147 } |
| 146 if (opcode == IrOpcode::kBranch) { | 148 if (opcode == IrOpcode::kBranch) { |
| 147 os_ << ",\"rankInputs\":[0]"; | 149 os_ << ",\"rankInputs\":[0]"; |
| 148 } | 150 } |
| 149 SourcePosition position = positions_->GetSourcePosition(node); | 151 SourcePosition position = positions_->GetSourcePosition(node); |
| 150 if (position.IsKnown()) { | 152 if (position.IsKnown()) { |
| 151 os_ << ",\"pos\":" << position.raw(); | 153 os_ << ",\"pos\":" << position.raw(); |
| 152 } | 154 } |
| 153 os_ << ",\"opcode\":\"" << IrOpcode::Mnemonic(node->opcode()) << "\""; | 155 os_ << ",\"opcode\":\"" << IrOpcode::Mnemonic(node->opcode()) << "\""; |
| 154 os_ << ",\"control\":" << (NodeProperties::IsControl(node) ? "true" | 156 os_ << ",\"control\":" << (NodeProperties::IsControl(node) ? "true" |
| 155 : "false"); | 157 : "false"); |
| 158 os_ << ",\"opinfo\":\"" << node->op()->ValueInputCount() << " v " | |
|
danno
2016/08/09 13:53:49
how about using a JSON object for these and making
| |
| 159 << node->op()->EffectInputCount() << " eff " | |
| 160 << node->op()->ControlInputCount() << " ctrl in, " | |
| 161 << node->op()->ValueOutputCount() << " v " | |
| 162 << node->op()->EffectOutputCount() << " eff " | |
| 163 << node->op()->ControlOutputCount() << " ctrl out\""; | |
| 156 if (NodeProperties::IsTyped(node)) { | 164 if (NodeProperties::IsTyped(node)) { |
| 157 Type* type = NodeProperties::GetType(node); | 165 Type* type = NodeProperties::GetType(node); |
| 158 std::ostringstream type_out; | 166 std::ostringstream type_out; |
| 159 type->PrintTo(type_out); | 167 type->PrintTo(type_out); |
| 160 os_ << ",\"type\":\"" << Escaped(type_out, "\"") << "\""; | 168 os_ << ",\"type\":\"" << Escaped(type_out, "\"") << "\""; |
| 161 } | 169 } |
| 162 os_ << "}"; | 170 os_ << "}"; |
| 163 } | 171 } |
| 164 | 172 |
| 165 private: | 173 private: |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 693 os << "]"; | 701 os << "]"; |
| 694 } | 702 } |
| 695 os << std::endl; | 703 os << std::endl; |
| 696 } | 704 } |
| 697 } | 705 } |
| 698 return os; | 706 return os; |
| 699 } | 707 } |
| 700 } // namespace compiler | 708 } // namespace compiler |
| 701 } // namespace internal | 709 } // namespace internal |
| 702 } // namespace v8 | 710 } // namespace v8 |
| OLD | NEW |