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 18 matching lines...) Expand all Loading... |
29 CompilationInfo* info, const char* phase, const char* suffix) { | 29 CompilationInfo* info, const char* phase, const char* suffix) { |
30 EmbeddedVector<char, 256> filename(0); | 30 EmbeddedVector<char, 256> filename(0); |
31 base::SmartArrayPointer<char> debug_name = info->GetDebugName(); | 31 base::SmartArrayPointer<char> debug_name = info->GetDebugName(); |
32 if (strlen(debug_name.get()) > 0) { | 32 if (strlen(debug_name.get()) > 0) { |
33 SNPrintF(filename, "turbo-%s", debug_name.get()); | 33 SNPrintF(filename, "turbo-%s", debug_name.get()); |
34 } else if (info->has_shared_info()) { | 34 } else if (info->has_shared_info()) { |
35 SNPrintF(filename, "turbo-%p", static_cast<void*>(info)); | 35 SNPrintF(filename, "turbo-%p", static_cast<void*>(info)); |
36 } else { | 36 } else { |
37 SNPrintF(filename, "turbo-none-%s", phase); | 37 SNPrintF(filename, "turbo-none-%s", phase); |
38 } | 38 } |
39 char* source_file = nullptr; | |
40 if (FLAG_trace_file_names && info->parse_info()) { | |
41 Object* source_name = info->script()->name(); | |
42 if (source_name->IsString()) { | |
43 String* str = String::cast(source_name); | |
44 if (str->length() > 0) { | |
45 source_file = str->ToCString().get(); | |
46 } | |
47 } | |
48 } | |
49 std::replace(filename.start(), filename.start() + filename.length(), ' ', | 39 std::replace(filename.start(), filename.start() + filename.length(), ' ', |
50 '_'); | 40 '_'); |
51 | 41 |
52 EmbeddedVector<char, 256> full_filename; | 42 EmbeddedVector<char, 256> full_filename; |
53 if (phase == nullptr && source_file == nullptr) { | 43 if (phase == nullptr) { |
54 SNPrintF(full_filename, "%s.%s", filename.start(), suffix); | 44 SNPrintF(full_filename, "%s.%s", filename.start(), suffix); |
55 } else if (phase != nullptr && source_file == nullptr) { | 45 } else { |
56 SNPrintF(full_filename, "%s-%s.%s", filename.start(), phase, suffix); | 46 SNPrintF(full_filename, "%s-%s.%s", filename.start(), phase, suffix); |
57 } else if (phase == nullptr && source_file != nullptr) { | |
58 SNPrintF(full_filename, "%s_%s.%s", filename.start(), source_file, suffix); | |
59 } else { | |
60 SNPrintF(full_filename, "%s_%s-%s.%s", filename.start(), source_file, phase, | |
61 suffix); | |
62 } | 47 } |
63 std::replace(full_filename.start(), | |
64 full_filename.start() + full_filename.length(), '/', '_'); | |
65 | 48 |
66 char* buffer = new char[full_filename.length() + 1]; | 49 char* buffer = new char[full_filename.length() + 1]; |
67 memcpy(buffer, full_filename.start(), full_filename.length()); | 50 memcpy(buffer, full_filename.start(), full_filename.length()); |
68 buffer[full_filename.length()] = '\0'; | 51 buffer[full_filename.length()] = '\0'; |
69 return base::SmartArrayPointer<const char>(buffer); | 52 return base::SmartArrayPointer<const char>(buffer); |
70 } | 53 } |
71 | 54 |
72 | 55 |
73 static int SafeId(Node* node) { return node == nullptr ? -1 : node->id(); } | 56 static int SafeId(Node* node) { return node == nullptr ? -1 : node->id(); } |
74 static const char* SafeMnemonic(Node* node) { | 57 static const char* SafeMnemonic(Node* node) { |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 os << "]"; | 666 os << "]"; |
684 } | 667 } |
685 os << std::endl; | 668 os << std::endl; |
686 } | 669 } |
687 } | 670 } |
688 return os; | 671 return os; |
689 } | 672 } |
690 } // namespace compiler | 673 } // namespace compiler |
691 } // namespace internal | 674 } // namespace internal |
692 } // namespace v8 | 675 } // namespace v8 |
OLD | NEW |