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/ostreams.h" | 21 #include "src/ostreams.h" |
22 | 22 |
23 namespace v8 { | 23 namespace v8 { |
24 namespace internal { | 24 namespace internal { |
25 namespace compiler { | 25 namespace compiler { |
26 | 26 |
| 27 |
| 28 FILE* OpenVisualizerLogFile(CompilationInfo* info, const char* phase, |
| 29 const char* suffix, const char* mode) { |
| 30 EmbeddedVector<char, 256> filename; |
| 31 SmartArrayPointer<char> function_name; |
| 32 if (!info->shared_info().is_null()) { |
| 33 function_name = info->shared_info()->DebugName()->ToCString(); |
| 34 if (strlen(function_name.get()) > 0) { |
| 35 SNPrintF(filename, "turbo-%s", function_name.get()); |
| 36 } else { |
| 37 SNPrintF(filename, "turbo-%p", static_cast<void*>(info)); |
| 38 } |
| 39 } else { |
| 40 SNPrintF(filename, "turbo-none-%s", phase); |
| 41 } |
| 42 std::replace(filename.start(), filename.start() + filename.length(), ' ', |
| 43 '_'); |
| 44 |
| 45 EmbeddedVector<char, 256> full_filename; |
| 46 if (phase == NULL) { |
| 47 SNPrintF(full_filename, "%s.%s", filename.start(), suffix); |
| 48 } else { |
| 49 SNPrintF(full_filename, "%s-%s.%s", filename.start(), phase, suffix); |
| 50 } |
| 51 return base::OS::FOpen(full_filename.start(), mode); |
| 52 } |
| 53 |
| 54 |
27 static int SafeId(Node* node) { return node == NULL ? -1 : node->id(); } | 55 static int SafeId(Node* node) { return node == NULL ? -1 : node->id(); } |
28 static const char* SafeMnemonic(Node* node) { | 56 static const char* SafeMnemonic(Node* node) { |
29 return node == NULL ? "null" : node->op()->mnemonic(); | 57 return node == NULL ? "null" : node->op()->mnemonic(); |
30 } | 58 } |
31 | 59 |
32 #define DEAD_COLOR "#999999" | 60 #define DEAD_COLOR "#999999" |
33 | 61 |
34 class Escaped { | 62 class Escaped { |
35 public: | 63 public: |
36 explicit Escaped(const std::ostringstream& os, | 64 explicit Escaped(const std::ostringstream& os, |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); | 807 os << "#" << SafeId(i) << ":" << SafeMnemonic(i); |
780 } | 808 } |
781 os << ")" << std::endl; | 809 os << ")" << std::endl; |
782 } | 810 } |
783 } | 811 } |
784 return os; | 812 return os; |
785 } | 813 } |
786 } | 814 } |
787 } | 815 } |
788 } // namespace v8::internal::compiler | 816 } // namespace v8::internal::compiler |
OLD | NEW |