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 <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
8 #include <memory> | 8 #include <memory> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 DeleteInstructionZone(); | 170 DeleteInstructionZone(); |
171 DeleteGraphZone(); | 171 DeleteGraphZone(); |
172 } | 172 } |
173 | 173 |
174 Isolate* isolate() const { return isolate_; } | 174 Isolate* isolate() const { return isolate_; } |
175 CompilationInfo* info() const { return info_; } | 175 CompilationInfo* info() const { return info_; } |
176 ZoneStats* zone_stats() const { return zone_stats_; } | 176 ZoneStats* zone_stats() const { return zone_stats_; } |
177 PipelineStatistics* pipeline_statistics() { return pipeline_statistics_; } | 177 PipelineStatistics* pipeline_statistics() { return pipeline_statistics_; } |
178 bool compilation_failed() const { return compilation_failed_; } | 178 bool compilation_failed() const { return compilation_failed_; } |
179 void set_compilation_failed() { compilation_failed_ = true; } | 179 void set_compilation_failed() { compilation_failed_ = true; } |
| 180 |
| 181 bool verify_graph() const { return verify_graph_; } |
| 182 void set_verify_graph(bool value) { verify_graph_ = value; } |
| 183 |
180 Handle<Code> code() { return code_; } | 184 Handle<Code> code() { return code_; } |
181 void set_code(Handle<Code> code) { | 185 void set_code(Handle<Code> code) { |
182 DCHECK(code_.is_null()); | 186 DCHECK(code_.is_null()); |
183 code_ = code; | 187 code_ = code; |
184 } | 188 } |
185 | 189 |
186 // RawMachineAssembler generally produces graphs which cannot be verified. | 190 // RawMachineAssembler generally produces graphs which cannot be verified. |
187 bool MayHaveUnverifiableGraph() const { return outer_zone_ == nullptr; } | 191 bool MayHaveUnverifiableGraph() const { return outer_zone_ == nullptr; } |
188 | 192 |
189 Zone* graph_zone() const { return graph_zone_; } | 193 Zone* graph_zone() const { return graph_zone_; } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 318 } |
315 | 319 |
316 private: | 320 private: |
317 Isolate* const isolate_; | 321 Isolate* const isolate_; |
318 CompilationInfo* const info_; | 322 CompilationInfo* const info_; |
319 std::unique_ptr<char[]> debug_name_; | 323 std::unique_ptr<char[]> debug_name_; |
320 Zone* outer_zone_ = nullptr; | 324 Zone* outer_zone_ = nullptr; |
321 ZoneStats* const zone_stats_; | 325 ZoneStats* const zone_stats_; |
322 PipelineStatistics* pipeline_statistics_ = nullptr; | 326 PipelineStatistics* pipeline_statistics_ = nullptr; |
323 bool compilation_failed_ = false; | 327 bool compilation_failed_ = false; |
| 328 bool verify_graph_ = false; |
324 Handle<Code> code_ = Handle<Code>::null(); | 329 Handle<Code> code_ = Handle<Code>::null(); |
325 | 330 |
326 // All objects in the following group of fields are allocated in graph_zone_. | 331 // All objects in the following group of fields are allocated in graph_zone_. |
327 // They are all set to nullptr when the graph_zone_ is destroyed. | 332 // They are all set to nullptr when the graph_zone_ is destroyed. |
328 ZoneStats::Scope graph_zone_scope_; | 333 ZoneStats::Scope graph_zone_scope_; |
329 Zone* graph_zone_ = nullptr; | 334 Zone* graph_zone_ = nullptr; |
330 Graph* graph_ = nullptr; | 335 Graph* graph_ = nullptr; |
331 SourcePositionTable* source_positions_ = nullptr; | 336 SourcePositionTable* source_positions_ = nullptr; |
332 LoopAssignmentAnalysis* loop_assignment_ = nullptr; | 337 LoopAssignmentAnalysis* loop_assignment_ = nullptr; |
333 SimplifiedOperatorBuilder* simplified_ = nullptr; | 338 SimplifiedOperatorBuilder* simplified_ = nullptr; |
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1624 // Lower changes that have been inserted before. | 1629 // Lower changes that have been inserted before. |
1625 Run<LateOptimizationPhase>(); | 1630 Run<LateOptimizationPhase>(); |
1626 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. | 1631 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
1627 RunPrintAndVerify("Late optimized", true); | 1632 RunPrintAndVerify("Late optimized", true); |
1628 | 1633 |
1629 data->source_positions()->RemoveDecorator(); | 1634 data->source_positions()->RemoveDecorator(); |
1630 | 1635 |
1631 return ScheduleAndSelectInstructions(linkage, true); | 1636 return ScheduleAndSelectInstructions(linkage, true); |
1632 } | 1637 } |
1633 | 1638 |
| 1639 // TODO(ishell): Remove verify_graph parameter and always enable the |
| 1640 // verification once all the issues are fixed. |
1634 Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate, | 1641 Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate, |
1635 CallDescriptor* call_descriptor, | 1642 CallDescriptor* call_descriptor, |
1636 Graph* graph, Schedule* schedule, | 1643 Graph* graph, Schedule* schedule, |
1637 Code::Flags flags, | 1644 Code::Flags flags, |
1638 const char* debug_name) { | 1645 const char* debug_name, |
| 1646 bool verify_graph) { |
1639 CompilationInfo info(CStrVector(debug_name), isolate, graph->zone(), flags); | 1647 CompilationInfo info(CStrVector(debug_name), isolate, graph->zone(), flags); |
1640 if (isolate->serializer_enabled()) info.PrepareForSerializing(); | 1648 if (isolate->serializer_enabled()) info.PrepareForSerializing(); |
1641 | 1649 |
1642 // Construct a pipeline for scheduling and code generation. | 1650 // Construct a pipeline for scheduling and code generation. |
1643 ZoneStats zone_stats(isolate->allocator()); | 1651 ZoneStats zone_stats(isolate->allocator()); |
1644 SourcePositionTable source_positions(graph); | 1652 SourcePositionTable source_positions(graph); |
1645 PipelineData data(&zone_stats, &info, graph, schedule, &source_positions); | 1653 PipelineData data(&zone_stats, &info, graph, schedule, &source_positions); |
| 1654 data.set_verify_graph(verify_graph); |
1646 std::unique_ptr<PipelineStatistics> pipeline_statistics; | 1655 std::unique_ptr<PipelineStatistics> pipeline_statistics; |
1647 if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { | 1656 if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { |
1648 pipeline_statistics.reset(new PipelineStatistics(&info, &zone_stats)); | 1657 pipeline_statistics.reset(new PipelineStatistics(&info, &zone_stats)); |
1649 pipeline_statistics->BeginPhaseKind("stub codegen"); | 1658 pipeline_statistics->BeginPhaseKind("stub codegen"); |
1650 } | 1659 } |
1651 | 1660 |
1652 PipelineImpl pipeline(&data); | 1661 PipelineImpl pipeline(&data); |
1653 DCHECK_NOT_NULL(data.schedule()); | 1662 DCHECK_NOT_NULL(data.schedule()); |
1654 | 1663 |
1655 if (FLAG_trace_turbo) { | 1664 if (FLAG_trace_turbo) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 RunPrintAndVerify("Late trimmed", true); | 1774 RunPrintAndVerify("Late trimmed", true); |
1766 } | 1775 } |
1767 if (data->schedule() == nullptr) Run<ComputeSchedulePhase>(); | 1776 if (data->schedule() == nullptr) Run<ComputeSchedulePhase>(); |
1768 TraceSchedule(data->info(), data->schedule()); | 1777 TraceSchedule(data->info(), data->schedule()); |
1769 | 1778 |
1770 if (FLAG_turbo_profiling) { | 1779 if (FLAG_turbo_profiling) { |
1771 data->set_profiler_data(BasicBlockInstrumentor::Instrument( | 1780 data->set_profiler_data(BasicBlockInstrumentor::Instrument( |
1772 info(), data->graph(), data->schedule())); | 1781 info(), data->graph(), data->schedule())); |
1773 } | 1782 } |
1774 | 1783 |
1775 // TODO(ishell): Always enable graph verification of stubs in debug mode | 1784 bool verify_stub_graph = data->verify_graph(); |
1776 // once all the issues are fixed. | |
1777 bool verify_stub_graph = | |
1778 DEBUG_BOOL && FLAG_csa_verify && data->info()->IsStub(); | |
1779 | |
1780 if (verify_stub_graph || (FLAG_turbo_verify_machine_graph != nullptr && | 1785 if (verify_stub_graph || (FLAG_turbo_verify_machine_graph != nullptr && |
1781 (!strcmp(FLAG_turbo_verify_machine_graph, "*") || | 1786 (!strcmp(FLAG_turbo_verify_machine_graph, "*") || |
1782 !strcmp(FLAG_turbo_verify_machine_graph, | 1787 !strcmp(FLAG_turbo_verify_machine_graph, |
1783 data->info()->GetDebugName().get())))) { | 1788 data->info()->GetDebugName().get())))) { |
1784 if (FLAG_trace_csa_verify) { | 1789 if (FLAG_trace_csa_verify) { |
1785 AllowHandleDereference allow_deref; | 1790 AllowHandleDereference allow_deref; |
1786 CompilationInfo* info = data->info(); | 1791 CompilationInfo* info = data->info(); |
1787 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); | 1792 CodeTracer::Scope tracing_scope(info->isolate()->GetCodeTracer()); |
1788 OFStream os(tracing_scope.file()); | 1793 OFStream os(tracing_scope.file()); |
1789 os << "--------------------------------------------------\n" | 1794 os << "--------------------------------------------------\n" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1999 data->DeleteRegisterAllocationZone(); | 2004 data->DeleteRegisterAllocationZone(); |
2000 } | 2005 } |
2001 | 2006 |
2002 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 2007 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
2003 | 2008 |
2004 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 2009 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
2005 | 2010 |
2006 } // namespace compiler | 2011 } // namespace compiler |
2007 } // namespace internal | 2012 } // namespace internal |
2008 } // namespace v8 | 2013 } // namespace v8 |
OLD | NEW |