| 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" |
| 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" |
| 16 #include "src/compiler/operator.h" | 16 #include "src/compiler/operator.h" |
| 17 #include "src/compiler/operator-properties.h" | 17 #include "src/compiler/operator-properties.h" |
| 18 #include "src/compiler/register-allocator.h" | 18 #include "src/compiler/register-allocator.h" |
| 19 #include "src/compiler/schedule.h" | 19 #include "src/compiler/schedule.h" |
| 20 #include "src/compiler/scheduler.h" | 20 #include "src/compiler/scheduler.h" |
| 21 #include "src/interpreter/bytecodes.h" | 21 #include "src/interpreter/bytecodes.h" |
| 22 #include "src/ostreams.h" | 22 #include "src/ostreams.h" |
| 23 | 23 |
| 24 namespace v8 { | 24 namespace v8 { |
| 25 namespace internal { | 25 namespace internal { |
| 26 namespace compiler { | 26 namespace compiler { |
| 27 | 27 |
| 28 | 28 base::SmartArrayPointer<const char> GetVisualizerLogFileName( |
| 29 FILE* OpenVisualizerLogFile(CompilationInfo* info, const char* phase, | 29 CompilationInfo* info, const char* phase, const char* suffix) { |
| 30 const char* suffix, const char* mode) { | |
| 31 EmbeddedVector<char, 256> filename(0); | 30 EmbeddedVector<char, 256> filename(0); |
| 32 base::SmartArrayPointer<char> debug_name = info->GetDebugName(); | 31 base::SmartArrayPointer<char> debug_name = info->GetDebugName(); |
| 33 if (strlen(debug_name.get()) > 0) { | 32 if (strlen(debug_name.get()) > 0) { |
| 34 SNPrintF(filename, "turbo-%s", debug_name.get()); | 33 SNPrintF(filename, "turbo-%s", debug_name.get()); |
| 35 } else if (info->has_shared_info()) { | 34 } else if (info->has_shared_info()) { |
| 36 SNPrintF(filename, "turbo-%p", static_cast<void*>(info)); | 35 SNPrintF(filename, "turbo-%p", static_cast<void*>(info)); |
| 37 } else { | 36 } else { |
| 38 SNPrintF(filename, "turbo-none-%s", phase); | 37 SNPrintF(filename, "turbo-none-%s", phase); |
| 39 } | 38 } |
| 40 std::replace(filename.start(), filename.start() + filename.length(), ' ', | 39 std::replace(filename.start(), filename.start() + filename.length(), ' ', |
| 41 '_'); | 40 '_'); |
| 42 | 41 |
| 43 EmbeddedVector<char, 256> full_filename; | 42 EmbeddedVector<char, 256> full_filename; |
| 44 if (phase == nullptr) { | 43 if (phase == nullptr) { |
| 45 SNPrintF(full_filename, "%s.%s", filename.start(), suffix); | 44 SNPrintF(full_filename, "%s.%s", filename.start(), suffix); |
| 46 } else { | 45 } else { |
| 47 SNPrintF(full_filename, "%s-%s.%s", filename.start(), phase, suffix); | 46 SNPrintF(full_filename, "%s-%s.%s", filename.start(), phase, suffix); |
| 48 } | 47 } |
| 49 return base::OS::FOpen(full_filename.start(), mode); | 48 |
| 49 char* buffer = new char[full_filename.length() + 1]; |
| 50 memcpy(buffer, full_filename.start(), full_filename.length()); |
| 51 buffer[full_filename.length()] = '\0'; |
| 52 return base::SmartArrayPointer<const char>(buffer); |
| 50 } | 53 } |
| 51 | 54 |
| 52 | 55 |
| 53 static int SafeId(Node* node) { return node == nullptr ? -1 : node->id(); } | 56 static int SafeId(Node* node) { return node == nullptr ? -1 : node->id(); } |
| 54 static const char* SafeMnemonic(Node* node) { | 57 static const char* SafeMnemonic(Node* node) { |
| 55 return node == nullptr ? "null" : node->op()->mnemonic(); | 58 return node == nullptr ? "null" : node->op()->mnemonic(); |
| 56 } | 59 } |
| 57 | 60 |
| 58 #define DEAD_COLOR "#999999" | 61 #define DEAD_COLOR "#999999" |
| 59 | 62 |
| (...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 os << "]"; | 650 os << "]"; |
| 648 } | 651 } |
| 649 os << std::endl; | 652 os << std::endl; |
| 650 } | 653 } |
| 651 } | 654 } |
| 652 return os; | 655 return os; |
| 653 } | 656 } |
| 654 } // namespace compiler | 657 } // namespace compiler |
| 655 } // namespace internal | 658 } // namespace internal |
| 656 } // namespace v8 | 659 } // namespace v8 |
| OLD | NEW |