| 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 char buffer[256]; |
| 78 Vector<char> filename(buffer, sizeof(buffer)); |
| 79 SmartArrayPointer<char> functionname = |
| 80 info_->shared_info()->DebugName()->ToCString(); |
| 81 if (strlen(functionname.get()) > 0) { |
| 82 SNPrintF(filename, "turbo-%s-%s.dot", functionname.get(), phase); |
| 83 } else { |
| 84 SNPrintF(filename, "turbo-%p-%s.dot", static_cast<void*>(info_), phase); |
| 85 } |
| 86 std::replace(filename.start(), filename.start() + filename.length(), ' ', |
| 87 '_'); |
| 88 FILE* file = base::OS::FOpen(filename.start(), "w+"); |
| 89 OFStream of(file); |
| 90 of << AsDOT(*graph); |
| 91 fclose(file); |
| 92 |
| 76 OFStream os(stdout); | 93 OFStream os(stdout); |
| 77 os << "-- " << phase << " graph -----------------------------------\n" | 94 os << "-- " << phase << " graph printed to file " << filename.start() |
| 78 << AsDOT(*graph); | 95 << "\n"; |
| 79 } | 96 } |
| 80 if (VerifyGraphs()) Verifier::Run(graph); | 97 if (VerifyGraphs()) Verifier::Run(graph); |
| 81 } | 98 } |
| 82 | 99 |
| 83 | 100 |
| 84 class AstGraphBuilderWithPositions : public AstGraphBuilder { | 101 class AstGraphBuilderWithPositions : public AstGraphBuilder { |
| 85 public: | 102 public: |
| 86 explicit AstGraphBuilderWithPositions(CompilationInfo* info, JSGraph* jsgraph, | 103 explicit AstGraphBuilderWithPositions(CompilationInfo* info, JSGraph* jsgraph, |
| 87 SourcePositionTable* source_positions) | 104 SourcePositionTable* source_positions) |
| 88 : AstGraphBuilder(info, jsgraph), source_positions_(source_positions) {} | 105 : AstGraphBuilder(info, jsgraph), source_positions_(source_positions) {} |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 } | 320 } |
| 304 | 321 |
| 305 | 322 |
| 306 void Pipeline::TearDown() { | 323 void Pipeline::TearDown() { |
| 307 InstructionOperand::TearDownCaches(); | 324 InstructionOperand::TearDownCaches(); |
| 308 } | 325 } |
| 309 | 326 |
| 310 } // namespace compiler | 327 } // namespace compiler |
| 311 } // namespace internal | 328 } // namespace internal |
| 312 } // namespace v8 | 329 } // namespace v8 |
| OLD | NEW |