OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/pipeline.h" | 5 #include "src/compiler/pipeline.h" |
6 | 6 |
7 #include "src/base/platform/elapsed-timer.h" | 7 #include "src/base/platform/elapsed-timer.h" |
8 #include "src/compiler/ast-graph-builder.h" | 8 #include "src/compiler/ast-graph-builder.h" |
9 #include "src/compiler/code-generator.h" | 9 #include "src/compiler/code-generator.h" |
10 #include "src/compiler/graph-replay.h" | 10 #include "src/compiler/graph-replay.h" |
11 #include "src/compiler/graph-visualizer.h" | 11 #include "src/compiler/graph-visualizer.h" |
12 #include "src/compiler/instruction.h" | 12 #include "src/compiler/instruction.h" |
13 #include "src/compiler/instruction-selector.h" | 13 #include "src/compiler/instruction-selector.h" |
14 #include "src/compiler/js-context-specialization.h" | 14 #include "src/compiler/js-context-specialization.h" |
15 #include "src/compiler/js-generic-lowering.h" | 15 #include "src/compiler/js-generic-lowering.h" |
16 #include "src/compiler/js-typed-lowering.h" | 16 #include "src/compiler/js-typed-lowering.h" |
17 #include "src/compiler/register-allocator.h" | 17 #include "src/compiler/register-allocator.h" |
18 #include "src/compiler/schedule.h" | 18 #include "src/compiler/schedule.h" |
19 #include "src/compiler/scheduler.h" | 19 #include "src/compiler/scheduler.h" |
20 #include "src/compiler/simplified-lowering.h" | 20 #include "src/compiler/simplified-lowering.h" |
21 #include "src/compiler/typer.h" | 21 #include "src/compiler/typer.h" |
22 #include "src/compiler/verifier.h" | 22 #include "src/compiler/verifier.h" |
23 #include "src/hydrogen.h" | 23 #include "src/hydrogen.h" |
24 #include "src/ostreams.h" | 24 #include "src/ostreams.h" |
25 #include "src/utils.h" | |
25 | 26 |
26 namespace v8 { | 27 namespace v8 { |
27 namespace internal { | 28 namespace internal { |
28 namespace compiler { | 29 namespace compiler { |
29 | 30 |
30 class PhaseStats { | 31 class PhaseStats { |
31 public: | 32 public: |
32 enum PhaseKind { CREATE_GRAPH, OPTIMIZATION, CODEGEN }; | 33 enum PhaseKind { CREATE_GRAPH, OPTIMIZATION, CODEGEN }; |
33 | 34 |
34 PhaseStats(CompilationInfo* info, PhaseKind kind, const char* name) | 35 PhaseStats(CompilationInfo* info, PhaseKind kind, const char* name) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 CompilationInfo* info_; | 67 CompilationInfo* info_; |
67 PhaseKind kind_; | 68 PhaseKind kind_; |
68 const char* name_; | 69 const char* name_; |
69 size_t size_; | 70 size_t size_; |
70 base::ElapsedTimer timer_; | 71 base::ElapsedTimer timer_; |
71 }; | 72 }; |
72 | 73 |
73 | 74 |
74 void Pipeline::VerifyAndPrintGraph(Graph* graph, const char* phase) { | 75 void Pipeline::VerifyAndPrintGraph(Graph* graph, const char* phase) { |
75 if (FLAG_trace_turbo) { | 76 if (FLAG_trace_turbo) { |
77 Vector<char> str = Vector<char>::New(256); | |
Michael Starzinger
2014/08/11 18:31:23
nit: s/str/filename/
sigurds
2014/08/12 09:24:49
Done.
| |
78 SmartArrayPointer<char> name = | |
79 info_->shared_info()->DebugName()->ToCString(); | |
80 if (strlen(name.get()) > 0) { | |
81 SNPrintF(str, "%s-%s.dot", name.get(), phase); | |
Michael Starzinger
2014/08/11 18:31:23
Can we get a common prefix for all of the files? T
sigurds
2014/08/12 09:24:49
Done.
| |
82 } else { | |
83 SNPrintF(str, "%p-%s.dot", static_cast<void*>(info_), phase); | |
84 } | |
85 std::replace(str.start(), str.start() + str.length(), ' ', '_'); | |
86 FILE* file = fopen(str.start(), "w+"); | |
Michael Starzinger
2014/08/11 18:31:23
I think we will need to use base::OS::FOpen to mak
sigurds
2014/08/12 09:24:49
Done.
| |
87 OFStream of(file); | |
88 of << AsDOT(*graph); | |
89 fclose(file); | |
90 | |
76 OFStream os(stdout); | 91 OFStream os(stdout); |
77 os << "-- " << phase << " graph -----------------------------------\n" | 92 os << "-- " << phase << " graph printed to file " << str.start() << "\n"; |
78 << AsDOT(*graph); | |
79 } | 93 } |
80 if (VerifyGraphs()) Verifier::Run(graph); | 94 if (VerifyGraphs()) Verifier::Run(graph); |
81 } | 95 } |
82 | 96 |
83 | 97 |
84 class AstGraphBuilderWithPositions : public AstGraphBuilder { | 98 class AstGraphBuilderWithPositions : public AstGraphBuilder { |
85 public: | 99 public: |
86 explicit AstGraphBuilderWithPositions(CompilationInfo* info, JSGraph* jsgraph, | 100 explicit AstGraphBuilderWithPositions(CompilationInfo* info, JSGraph* jsgraph, |
87 SourcePositionTable* source_positions) | 101 SourcePositionTable* source_positions) |
88 : AstGraphBuilder(info, jsgraph), source_positions_(source_positions) {} | 102 : AstGraphBuilder(info, jsgraph), source_positions_(source_positions) {} |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 } | 317 } |
304 | 318 |
305 | 319 |
306 void Pipeline::TearDown() { | 320 void Pipeline::TearDown() { |
307 InstructionOperand::TearDownCaches(); | 321 InstructionOperand::TearDownCaches(); |
308 } | 322 } |
309 | 323 |
310 } // namespace compiler | 324 } // namespace compiler |
311 } // namespace internal | 325 } // namespace internal |
312 } // namespace v8 | 326 } // namespace v8 |
OLD | NEW |