| 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 <sstream> | 7 #include <sstream> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "src/compiler/generic-algorithm.h" | 10 #include "src/compiler/generic-algorithm.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 std::ostream& os_; | 184 std::ostream& os_; |
| 185 const Graph* const graph_; | 185 const Graph* const graph_; |
| 186 | 186 |
| 187 DISALLOW_COPY_AND_ASSIGN(GraphVisualizer); | 187 DISALLOW_COPY_AND_ASSIGN(GraphVisualizer); |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 | 190 |
| 191 static Node* GetControlCluster(Node* node) { | 191 static Node* GetControlCluster(Node* node) { |
| 192 if (OperatorProperties::IsBasicBlockBegin(node->op())) { | 192 if (OperatorProperties::IsBasicBlockBegin(node->op())) { |
| 193 return node; | 193 return node; |
| 194 } else if (OperatorProperties::GetControlInputCount(node->op()) == 1) { | 194 } else if (node->op()->ControlInputCount() == 1) { |
| 195 Node* control = NodeProperties::GetControlInput(node, 0); | 195 Node* control = NodeProperties::GetControlInput(node, 0); |
| 196 return OperatorProperties::IsBasicBlockBegin(control->op()) ? control | 196 return OperatorProperties::IsBasicBlockBegin(control->op()) ? control |
| 197 : NULL; | 197 : NULL; |
| 198 } else { | 198 } else { |
| 199 return NULL; | 199 return NULL; |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 | 203 |
| 204 GenericGraphVisit::Control GraphVisualizer::Pre(Node* node) { | 204 GenericGraphVisit::Control GraphVisualizer::Pre(Node* node) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 break; | 252 break; |
| 253 default: | 253 default: |
| 254 break; | 254 break; |
| 255 } | 255 } |
| 256 | 256 |
| 257 std::ostringstream label; | 257 std::ostringstream label; |
| 258 label << *node->op(); | 258 label << *node->op(); |
| 259 os_ << " label=\"{{#" << node->id() << ":" << Escaped(label); | 259 os_ << " label=\"{{#" << node->id() << ":" << Escaped(label); |
| 260 | 260 |
| 261 InputIter i = node->inputs().begin(); | 261 InputIter i = node->inputs().begin(); |
| 262 for (int j = OperatorProperties::GetValueInputCount(node->op()); j > 0; | 262 for (int j = node->op()->ValueInputCount(); j > 0; ++i, j--) { |
| 263 ++i, j--) { | |
| 264 os_ << "|<I" << i.index() << ">#" << (*i)->id(); | 263 os_ << "|<I" << i.index() << ">#" << (*i)->id(); |
| 265 } | 264 } |
| 266 for (int j = OperatorProperties::GetContextInputCount(node->op()); j > 0; | 265 for (int j = OperatorProperties::GetContextInputCount(node->op()); j > 0; |
| 267 ++i, j--) { | 266 ++i, j--) { |
| 268 os_ << "|<I" << i.index() << ">X #" << (*i)->id(); | 267 os_ << "|<I" << i.index() << ">X #" << (*i)->id(); |
| 269 } | 268 } |
| 270 for (int j = OperatorProperties::GetFrameStateInputCount(node->op()); j > 0; | 269 for (int j = OperatorProperties::GetFrameStateInputCount(node->op()); j > 0; |
| 271 ++i, j--) { | 270 ++i, j--) { |
| 272 os_ << "|<I" << i.index() << ">F #" << (*i)->id(); | 271 os_ << "|<I" << i.index() << ">F #" << (*i)->id(); |
| 273 } | 272 } |
| 274 for (int j = OperatorProperties::GetEffectInputCount(node->op()); j > 0; | 273 for (int j = node->op()->EffectInputCount(); j > 0; ++i, j--) { |
| 275 ++i, j--) { | |
| 276 os_ << "|<I" << i.index() << ">E #" << (*i)->id(); | 274 os_ << "|<I" << i.index() << ">E #" << (*i)->id(); |
| 277 } | 275 } |
| 278 | 276 |
| 279 if (!use_to_def_ || OperatorProperties::IsBasicBlockBegin(node->op()) || | 277 if (!use_to_def_ || OperatorProperties::IsBasicBlockBegin(node->op()) || |
| 280 GetControlCluster(node) == NULL) { | 278 GetControlCluster(node) == NULL) { |
| 281 for (int j = OperatorProperties::GetControlInputCount(node->op()); j > 0; | 279 for (int j = node->op()->ControlInputCount(); j > 0; ++i, j--) { |
| 282 ++i, j--) { | |
| 283 os_ << "|<I" << i.index() << ">C #" << (*i)->id(); | 280 os_ << "|<I" << i.index() << ">C #" << (*i)->id(); |
| 284 } | 281 } |
| 285 } | 282 } |
| 286 os_ << "}"; | 283 os_ << "}"; |
| 287 | 284 |
| 288 if (FLAG_trace_turbo_types && NodeProperties::IsTyped(node)) { | 285 if (FLAG_trace_turbo_types && NodeProperties::IsTyped(node)) { |
| 289 Bounds bounds = NodeProperties::GetBounds(node); | 286 Bounds bounds = NodeProperties::GetBounds(node); |
| 290 std::ostringstream upper; | 287 std::ostringstream upper; |
| 291 bounds.upper->PrintTo(upper); | 288 bounds.upper->PrintTo(upper); |
| 292 std::ostringstream lower; | 289 std::ostringstream lower; |
| 293 bounds.lower->PrintTo(lower); | 290 bounds.lower->PrintTo(lower); |
| 294 os_ << "|" << Escaped(upper) << "|" << Escaped(lower); | 291 os_ << "|" << Escaped(upper) << "|" << Escaped(lower); |
| 295 } | 292 } |
| 296 os_ << "}\"\n"; | 293 os_ << "}\"\n"; |
| 297 } | 294 } |
| 298 | 295 |
| 299 | 296 |
| 300 void GraphVisualizer::PrintEdge(Node::Edge edge) { | 297 void GraphVisualizer::PrintEdge(Node::Edge edge) { |
| 301 Node* from = edge.from(); | 298 Node* from = edge.from(); |
| 302 int index = edge.index(); | 299 int index = edge.index(); |
| 303 Node* to = edge.to(); | 300 Node* to = edge.to(); |
| 304 bool unconstrained = IsLikelyBackEdge(from, index, to); | 301 bool unconstrained = IsLikelyBackEdge(from, index, to); |
| 305 os_ << " ID" << from->id(); | 302 os_ << " ID" << from->id(); |
| 306 if (all_nodes_.count(to) == 0) { | 303 if (all_nodes_.count(to) == 0) { |
| 307 os_ << ":I" << index << ":n -> DEAD_INPUT"; | 304 os_ << ":I" << index << ":n -> DEAD_INPUT"; |
| 308 } else if (OperatorProperties::IsBasicBlockBegin(from->op()) || | 305 } else if (OperatorProperties::IsBasicBlockBegin(from->op()) || |
| 309 GetControlCluster(from) == NULL || | 306 GetControlCluster(from) == NULL || |
| 310 (OperatorProperties::GetControlInputCount(from->op()) > 0 && | 307 (from->op()->ControlInputCount() > 0 && |
| 311 NodeProperties::GetControlInput(from) != to)) { | 308 NodeProperties::GetControlInput(from) != to)) { |
| 312 os_ << ":I" << index << ":n -> ID" << to->id() << ":s" | 309 os_ << ":I" << index << ":n -> ID" << to->id() << ":s" |
| 313 << "[" << (unconstrained ? "constraint=false, " : "") | 310 << "[" << (unconstrained ? "constraint=false, " : "") |
| 314 << (NodeProperties::IsControlEdge(edge) ? "style=bold, " : "") | 311 << (NodeProperties::IsControlEdge(edge) ? "style=bold, " : "") |
| 315 << (NodeProperties::IsEffectEdge(edge) ? "style=dotted, " : "") | 312 << (NodeProperties::IsEffectEdge(edge) ? "style=dotted, " : "") |
| 316 << (NodeProperties::IsContextEdge(edge) ? "style=dashed, " : "") << "]"; | 313 << (NodeProperties::IsContextEdge(edge) ? "style=dashed, " : "") << "]"; |
| 317 } else { | 314 } else { |
| 318 os_ << " -> ID" << to->id() << ":s [color=transparent, " | 315 os_ << " -> ID" << to->id() << ":s [color=transparent, " |
| 319 << (unconstrained ? "constraint=false, " : "") | 316 << (unconstrained ? "constraint=false, " : "") |
| 320 << (NodeProperties::IsControlEdge(edge) ? "style=dashed, " : "") << "]"; | 317 << (NodeProperties::IsControlEdge(edge) ? "style=dashed, " : "") << "]"; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 os_ << " "; | 505 os_ << " "; |
| 509 PrintNodeId(**i); | 506 PrintNodeId(**i); |
| 510 ++(*i); | 507 ++(*i); |
| 511 count--; | 508 count--; |
| 512 } | 509 } |
| 513 } | 510 } |
| 514 | 511 |
| 515 | 512 |
| 516 void GraphC1Visualizer::PrintInputs(Node* node) { | 513 void GraphC1Visualizer::PrintInputs(Node* node) { |
| 517 InputIter i = node->inputs().begin(); | 514 InputIter i = node->inputs().begin(); |
| 518 PrintInputs(&i, OperatorProperties::GetValueInputCount(node->op()), " "); | 515 PrintInputs(&i, node->op()->ValueInputCount(), " "); |
| 519 PrintInputs(&i, OperatorProperties::GetContextInputCount(node->op()), | 516 PrintInputs(&i, OperatorProperties::GetContextInputCount(node->op()), |
| 520 " Ctx:"); | 517 " Ctx:"); |
| 521 PrintInputs(&i, OperatorProperties::GetFrameStateInputCount(node->op()), | 518 PrintInputs(&i, OperatorProperties::GetFrameStateInputCount(node->op()), |
| 522 " FS:"); | 519 " FS:"); |
| 523 PrintInputs(&i, OperatorProperties::GetEffectInputCount(node->op()), " Eff:"); | 520 PrintInputs(&i, node->op()->EffectInputCount(), " Eff:"); |
| 524 PrintInputs(&i, OperatorProperties::GetControlInputCount(node->op()), | 521 PrintInputs(&i, node->op()->ControlInputCount(), " Ctrl:"); |
| 525 " Ctrl:"); | |
| 526 } | 522 } |
| 527 | 523 |
| 528 | 524 |
| 529 void GraphC1Visualizer::PrintType(Node* node) { | 525 void GraphC1Visualizer::PrintType(Node* node) { |
| 530 if (NodeProperties::IsTyped(node)) { | 526 if (NodeProperties::IsTyped(node)) { |
| 531 Bounds bounds = NodeProperties::GetBounds(node); | 527 Bounds bounds = NodeProperties::GetBounds(node); |
| 532 os_ << " type:"; | 528 os_ << " type:"; |
| 533 bounds.upper->PrintTo(os_); | 529 bounds.upper->PrintTo(os_); |
| 534 os_ << ".."; | 530 os_ << ".."; |
| 535 bounds.lower->PrintTo(os_); | 531 bounds.lower->PrintTo(os_); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 | 763 |
| 768 | 764 |
| 769 std::ostream& operator<<(std::ostream& os, const AsC1VAllocator& ac) { | 765 std::ostream& operator<<(std::ostream& os, const AsC1VAllocator& ac) { |
| 770 Zone tmp_zone(ac.allocator_->code()->zone()->isolate()); | 766 Zone tmp_zone(ac.allocator_->code()->zone()->isolate()); |
| 771 GraphC1Visualizer(os, &tmp_zone).PrintAllocator(ac.phase_, ac.allocator_); | 767 GraphC1Visualizer(os, &tmp_zone).PrintAllocator(ac.phase_, ac.allocator_); |
| 772 return os; | 768 return os; |
| 773 } | 769 } |
| 774 } | 770 } |
| 775 } | 771 } |
| 776 } // namespace v8::internal::compiler | 772 } // namespace v8::internal::compiler |
| OLD | NEW |