| 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/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 SNPrintF(filename, "turbo-%s", debug_name.get()); | 34 SNPrintF(filename, "turbo-%s", debug_name.get()); |
| 35 } else if (info->has_shared_info()) { | 35 } else if (info->has_shared_info()) { |
| 36 SNPrintF(filename, "turbo-%p", static_cast<void*>(info)); | 36 SNPrintF(filename, "turbo-%p", static_cast<void*>(info)); |
| 37 } else { | 37 } else { |
| 38 SNPrintF(filename, "turbo-none-%s", phase); | 38 SNPrintF(filename, "turbo-none-%s", phase); |
| 39 } | 39 } |
| 40 std::replace(filename.start(), filename.start() + filename.length(), ' ', | 40 std::replace(filename.start(), filename.start() + filename.length(), ' ', |
| 41 '_'); | 41 '_'); |
| 42 | 42 |
| 43 EmbeddedVector<char, 256> full_filename; | 43 EmbeddedVector<char, 256> full_filename; |
| 44 if (phase == NULL) { | 44 if (phase == nullptr) { |
| 45 SNPrintF(full_filename, "%s.%s", filename.start(), suffix); | 45 SNPrintF(full_filename, "%s.%s", filename.start(), suffix); |
| 46 } else { | 46 } else { |
| 47 SNPrintF(full_filename, "%s-%s.%s", filename.start(), phase, suffix); | 47 SNPrintF(full_filename, "%s-%s.%s", filename.start(), phase, suffix); |
| 48 } | 48 } |
| 49 return base::OS::FOpen(full_filename.start(), mode); | 49 return base::OS::FOpen(full_filename.start(), mode); |
| 50 } | 50 } |
| 51 | 51 |
| 52 | 52 |
| 53 static int SafeId(Node* node) { return node == NULL ? -1 : node->id(); } | 53 static int SafeId(Node* node) { return node == nullptr ? -1 : node->id(); } |
| 54 static const char* SafeMnemonic(Node* node) { | 54 static const char* SafeMnemonic(Node* node) { |
| 55 return node == NULL ? "null" : node->op()->mnemonic(); | 55 return node == nullptr ? "null" : node->op()->mnemonic(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 #define DEAD_COLOR "#999999" | 58 #define DEAD_COLOR "#999999" |
| 59 | 59 |
| 60 class Escaped { | 60 class Escaped { |
| 61 public: | 61 public: |
| 62 explicit Escaped(const std::ostringstream& os, | 62 explicit Escaped(const std::ostringstream& os, |
| 63 const char* escaped_chars = "<>|{}") | 63 const char* escaped_chars = "<>|{}") |
| 64 : str_(os.str()), escaped_chars_(escaped_chars) {} | 64 : str_(os.str()), escaped_chars_(escaped_chars) {} |
| 65 | 65 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 : os_(os), all_(zone, graph), first_edge_(true) {} | 151 : os_(os), all_(zone, graph), first_edge_(true) {} |
| 152 | 152 |
| 153 void Print() { | 153 void Print() { |
| 154 for (Node* const node : all_.live) PrintEdges(node); | 154 for (Node* const node : all_.live) PrintEdges(node); |
| 155 os_ << "\n"; | 155 os_ << "\n"; |
| 156 } | 156 } |
| 157 | 157 |
| 158 void PrintEdges(Node* node) { | 158 void PrintEdges(Node* node) { |
| 159 for (int i = 0; i < node->InputCount(); i++) { | 159 for (int i = 0; i < node->InputCount(); i++) { |
| 160 Node* input = node->InputAt(i); | 160 Node* input = node->InputAt(i); |
| 161 if (input == NULL) continue; | 161 if (input == nullptr) continue; |
| 162 PrintEdge(node, i, input); | 162 PrintEdge(node, i, input); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 void PrintEdge(Node* from, int index, Node* to) { | 166 void PrintEdge(Node* from, int index, Node* to) { |
| 167 if (first_edge_) { | 167 if (first_edge_) { |
| 168 first_edge_ = false; | 168 first_edge_ = false; |
| 169 } else { | 169 } else { |
| 170 os_ << ",\n"; | 170 os_ << ",\n"; |
| 171 } | 171 } |
| 172 const char* edge_type = NULL; | 172 const char* edge_type = nullptr; |
| 173 if (index < NodeProperties::FirstValueIndex(from)) { | 173 if (index < NodeProperties::FirstValueIndex(from)) { |
| 174 edge_type = "unknown"; | 174 edge_type = "unknown"; |
| 175 } else if (index < NodeProperties::FirstContextIndex(from)) { | 175 } else if (index < NodeProperties::FirstContextIndex(from)) { |
| 176 edge_type = "value"; | 176 edge_type = "value"; |
| 177 } else if (index < NodeProperties::FirstFrameStateIndex(from)) { | 177 } else if (index < NodeProperties::FirstFrameStateIndex(from)) { |
| 178 edge_type = "context"; | 178 edge_type = "context"; |
| 179 } else if (index < NodeProperties::FirstEffectIndex(from)) { | 179 } else if (index < NodeProperties::FirstEffectIndex(from)) { |
| 180 edge_type = "frame-state"; | 180 edge_type = "frame-state"; |
| 181 } else if (index < NodeProperties::FirstControlIndex(from)) { | 181 } else if (index < NodeProperties::FirstControlIndex(from)) { |
| 182 edge_type = "effect"; | 182 edge_type = "effect"; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 os_ << " \"B" << successor->rpo_number() << "\""; | 390 os_ << " \"B" << successor->rpo_number() << "\""; |
| 391 } | 391 } |
| 392 os_ << "\n"; | 392 os_ << "\n"; |
| 393 | 393 |
| 394 PrintIndent(); | 394 PrintIndent(); |
| 395 os_ << "xhandlers\n"; | 395 os_ << "xhandlers\n"; |
| 396 | 396 |
| 397 PrintIndent(); | 397 PrintIndent(); |
| 398 os_ << "flags\n"; | 398 os_ << "flags\n"; |
| 399 | 399 |
| 400 if (current->dominator() != NULL) { | 400 if (current->dominator() != nullptr) { |
| 401 PrintBlockProperty("dominator", current->dominator()->rpo_number()); | 401 PrintBlockProperty("dominator", current->dominator()->rpo_number()); |
| 402 } | 402 } |
| 403 | 403 |
| 404 PrintIntProperty("loop_depth", current->loop_depth()); | 404 PrintIntProperty("loop_depth", current->loop_depth()); |
| 405 | 405 |
| 406 const InstructionBlock* instruction_block = | 406 const InstructionBlock* instruction_block = |
| 407 instructions->InstructionBlockAt( | 407 instructions->InstructionBlockAt( |
| 408 RpoNumber::FromInt(current->rpo_number())); | 408 RpoNumber::FromInt(current->rpo_number())); |
| 409 if (instruction_block->code_start() >= 0) { | 409 if (instruction_block->code_start() >= 0) { |
| 410 int first_index = instruction_block->first_instruction_index(); | 410 int first_index = instruction_block->first_instruction_index(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 Node* node = *i; | 448 Node* node = *i; |
| 449 if (node->opcode() == IrOpcode::kPhi) continue; | 449 if (node->opcode() == IrOpcode::kPhi) continue; |
| 450 int uses = node->UseCount(); | 450 int uses = node->UseCount(); |
| 451 PrintIndent(); | 451 PrintIndent(); |
| 452 os_ << "0 " << uses << " "; | 452 os_ << "0 " << uses << " "; |
| 453 PrintNode(node); | 453 PrintNode(node); |
| 454 if (FLAG_trace_turbo_types) { | 454 if (FLAG_trace_turbo_types) { |
| 455 os_ << " "; | 455 os_ << " "; |
| 456 PrintType(node); | 456 PrintType(node); |
| 457 } | 457 } |
| 458 if (positions != NULL) { | 458 if (positions != nullptr) { |
| 459 SourcePosition position = positions->GetSourcePosition(node); | 459 SourcePosition position = positions->GetSourcePosition(node); |
| 460 if (position.IsKnown()) { | 460 if (position.IsKnown()) { |
| 461 os_ << " pos:" << position.raw(); | 461 os_ << " pos:" << position.raw(); |
| 462 } | 462 } |
| 463 } | 463 } |
| 464 os_ << " <|@\n"; | 464 os_ << " <|@\n"; |
| 465 } | 465 } |
| 466 | 466 |
| 467 BasicBlock::Control control = current->control(); | 467 BasicBlock::Control control = current->control(); |
| 468 if (control != BasicBlock::kNone) { | 468 if (control != BasicBlock::kNone) { |
| 469 PrintIndent(); | 469 PrintIndent(); |
| 470 os_ << "0 0 "; | 470 os_ << "0 0 "; |
| 471 if (current->control_input() != NULL) { | 471 if (current->control_input() != nullptr) { |
| 472 PrintNode(current->control_input()); | 472 PrintNode(current->control_input()); |
| 473 } else { | 473 } else { |
| 474 os_ << -1 - current->rpo_number() << " Goto"; | 474 os_ << -1 - current->rpo_number() << " Goto"; |
| 475 } | 475 } |
| 476 os_ << " ->"; | 476 os_ << " ->"; |
| 477 for (BasicBlock* successor : current->successors()) { | 477 for (BasicBlock* successor : current->successors()) { |
| 478 os_ << " B" << successor->rpo_number(); | 478 os_ << " B" << successor->rpo_number(); |
| 479 } | 479 } |
| 480 if (FLAG_trace_turbo_types && current->control_input() != NULL) { | 480 if (FLAG_trace_turbo_types && current->control_input() != nullptr) { |
| 481 os_ << " "; | 481 os_ << " "; |
| 482 PrintType(current->control_input()); | 482 PrintType(current->control_input()); |
| 483 } | 483 } |
| 484 os_ << " <|@\n"; | 484 os_ << " <|@\n"; |
| 485 } | 485 } |
| 486 } | 486 } |
| 487 | 487 |
| 488 if (instructions != NULL) { | 488 if (instructions != nullptr) { |
| 489 Tag LIR_tag(this, "LIR"); | 489 Tag LIR_tag(this, "LIR"); |
| 490 for (int j = instruction_block->first_instruction_index(); | 490 for (int j = instruction_block->first_instruction_index(); |
| 491 j <= instruction_block->last_instruction_index(); j++) { | 491 j <= instruction_block->last_instruction_index(); j++) { |
| 492 PrintIndent(); | 492 PrintIndent(); |
| 493 PrintableInstruction printable = { | 493 PrintableInstruction printable = { |
| 494 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN), | 494 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN), |
| 495 instructions->InstructionAt(j)}; | 495 instructions->InstructionAt(j)}; |
| 496 os_ << j << " " << printable << " <|@\n"; | 496 os_ << j << " " << printable << " <|@\n"; |
| 497 } | 497 } |
| 498 } | 498 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 524 if (range == nullptr || range->IsEmpty()) return; | 524 if (range == nullptr || range->IsEmpty()) return; |
| 525 int vreg = range->vreg(); | 525 int vreg = range->vreg(); |
| 526 for (LiveRange* child = range; child != nullptr; child = child->next()) { | 526 for (LiveRange* child = range; child != nullptr; child = child->next()) { |
| 527 PrintLiveRange(child, type, vreg); | 527 PrintLiveRange(child, type, vreg); |
| 528 } | 528 } |
| 529 } | 529 } |
| 530 | 530 |
| 531 | 531 |
| 532 void GraphC1Visualizer::PrintLiveRange(LiveRange* range, const char* type, | 532 void GraphC1Visualizer::PrintLiveRange(LiveRange* range, const char* type, |
| 533 int vreg) { | 533 int vreg) { |
| 534 if (range != NULL && !range->IsEmpty()) { | 534 if (range != nullptr && !range->IsEmpty()) { |
| 535 PrintIndent(); | 535 PrintIndent(); |
| 536 os_ << vreg << ":" << range->relative_id() << " " << type; | 536 os_ << vreg << ":" << range->relative_id() << " " << type; |
| 537 if (range->HasRegisterAssigned()) { | 537 if (range->HasRegisterAssigned()) { |
| 538 AllocatedOperand op = AllocatedOperand::cast(range->GetAssignedOperand()); | 538 AllocatedOperand op = AllocatedOperand::cast(range->GetAssignedOperand()); |
| 539 if (op.IsDoubleRegister()) { | 539 if (op.IsDoubleRegister()) { |
| 540 DoubleRegister assigned_reg = op.GetDoubleRegister(); | 540 DoubleRegister assigned_reg = op.GetDoubleRegister(); |
| 541 os_ << " \"" << assigned_reg.ToString() << "\""; | 541 os_ << " \"" << assigned_reg.ToString() << "\""; |
| 542 } else { | 542 } else { |
| 543 DCHECK(op.IsRegister()); | 543 DCHECK(op.IsRegister()); |
| 544 Register assigned_reg = op.GetRegister(); | 544 Register assigned_reg = op.GetRegister(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 564 } | 564 } |
| 565 | 565 |
| 566 os_ << " " << vreg; | 566 os_ << " " << vreg; |
| 567 for (auto interval = range->first_interval(); interval != nullptr; | 567 for (auto interval = range->first_interval(); interval != nullptr; |
| 568 interval = interval->next()) { | 568 interval = interval->next()) { |
| 569 os_ << " [" << interval->start().value() << ", " | 569 os_ << " [" << interval->start().value() << ", " |
| 570 << interval->end().value() << "["; | 570 << interval->end().value() << "["; |
| 571 } | 571 } |
| 572 | 572 |
| 573 UsePosition* current_pos = range->first_pos(); | 573 UsePosition* current_pos = range->first_pos(); |
| 574 while (current_pos != NULL) { | 574 while (current_pos != nullptr) { |
| 575 if (current_pos->RegisterIsBeneficial() || FLAG_trace_all_uses) { | 575 if (current_pos->RegisterIsBeneficial() || FLAG_trace_all_uses) { |
| 576 os_ << " " << current_pos->pos().value() << " M"; | 576 os_ << " " << current_pos->pos().value() << " M"; |
| 577 } | 577 } |
| 578 current_pos = current_pos->next(); | 578 current_pos = current_pos->next(); |
| 579 } | 579 } |
| 580 | 580 |
| 581 os_ << " \"\"\n"; | 581 os_ << " \"\"\n"; |
| 582 } | 582 } |
| 583 } | 583 } |
| 584 | 584 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); | 637 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); |
| 638 } | 638 } |
| 639 os << ")" << std::endl; | 639 os << ")" << std::endl; |
| 640 } | 640 } |
| 641 } | 641 } |
| 642 return os; | 642 return os; |
| 643 } | 643 } |
| 644 } // namespace compiler | 644 } // namespace compiler |
| 645 } // namespace internal | 645 } // namespace internal |
| 646 } // namespace v8 | 646 } // namespace v8 |
| OLD | NEW |