| 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 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 protected: | 573 protected: |
| 574 Status CreateGraphImpl() final; | 574 Status CreateGraphImpl() final; |
| 575 Status OptimizeGraphImpl() final; | 575 Status OptimizeGraphImpl() final; |
| 576 Status GenerateCodeImpl() final; | 576 Status GenerateCodeImpl() final; |
| 577 | 577 |
| 578 private: | 578 private: |
| 579 Zone zone_; | 579 Zone zone_; |
| 580 ZonePool zone_pool_; | 580 ZonePool zone_pool_; |
| 581 ParseInfo parse_info_; | 581 ParseInfo parse_info_; |
| 582 CompilationInfo info_; | 582 CompilationInfo info_; |
| 583 base::SmartPointer<PipelineStatistics> pipeline_statistics_; | 583 std::unique_ptr<PipelineStatistics> pipeline_statistics_; |
| 584 PipelineData data_; | 584 PipelineData data_; |
| 585 PipelineImpl pipeline_; | 585 PipelineImpl pipeline_; |
| 586 Linkage* linkage_; | 586 Linkage* linkage_; |
| 587 |
| 588 DISALLOW_COPY_AND_ASSIGN(PipelineCompilationJob); |
| 587 }; | 589 }; |
| 588 | 590 |
| 589 PipelineCompilationJob::Status PipelineCompilationJob::CreateGraphImpl() { | 591 PipelineCompilationJob::Status PipelineCompilationJob::CreateGraphImpl() { |
| 590 if (info()->shared_info()->asm_function()) { | 592 if (info()->shared_info()->asm_function()) { |
| 591 if (info()->osr_frame()) info()->MarkAsFrameSpecializing(); | 593 if (info()->osr_frame()) info()->MarkAsFrameSpecializing(); |
| 592 info()->MarkAsFunctionContextSpecializing(); | 594 info()->MarkAsFunctionContextSpecializing(); |
| 593 } else { | 595 } else { |
| 594 if (!FLAG_always_opt) { | 596 if (!FLAG_always_opt) { |
| 595 info()->MarkAsBailoutOnUninitialized(); | 597 info()->MarkAsBailoutOnUninitialized(); |
| 596 } | 598 } |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate, | 1559 Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate, |
| 1558 CallDescriptor* call_descriptor, | 1560 CallDescriptor* call_descriptor, |
| 1559 Graph* graph, Schedule* schedule, | 1561 Graph* graph, Schedule* schedule, |
| 1560 Code::Flags flags, | 1562 Code::Flags flags, |
| 1561 const char* debug_name) { | 1563 const char* debug_name) { |
| 1562 CompilationInfo info(CStrVector(debug_name), isolate, graph->zone(), flags); | 1564 CompilationInfo info(CStrVector(debug_name), isolate, graph->zone(), flags); |
| 1563 | 1565 |
| 1564 // Construct a pipeline for scheduling and code generation. | 1566 // Construct a pipeline for scheduling and code generation. |
| 1565 ZonePool zone_pool(isolate->allocator()); | 1567 ZonePool zone_pool(isolate->allocator()); |
| 1566 PipelineData data(&zone_pool, &info, graph, schedule); | 1568 PipelineData data(&zone_pool, &info, graph, schedule); |
| 1567 base::SmartPointer<PipelineStatistics> pipeline_statistics; | 1569 std::unique_ptr<PipelineStatistics> pipeline_statistics; |
| 1568 if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { | 1570 if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { |
| 1569 pipeline_statistics.Reset(new PipelineStatistics(&info, &zone_pool)); | 1571 pipeline_statistics.reset(new PipelineStatistics(&info, &zone_pool)); |
| 1570 pipeline_statistics->BeginPhaseKind("stub codegen"); | 1572 pipeline_statistics->BeginPhaseKind("stub codegen"); |
| 1571 } | 1573 } |
| 1572 | 1574 |
| 1573 PipelineImpl pipeline(&data); | 1575 PipelineImpl pipeline(&data); |
| 1574 DCHECK_NOT_NULL(data.schedule()); | 1576 DCHECK_NOT_NULL(data.schedule()); |
| 1575 | 1577 |
| 1576 if (FLAG_trace_turbo) { | 1578 if (FLAG_trace_turbo) { |
| 1577 { | 1579 { |
| 1578 TurboJsonFile json_of(&info, std::ios_base::trunc); | 1580 TurboJsonFile json_of(&info, std::ios_base::trunc); |
| 1579 json_of << "{\"function\":\"" << info.GetDebugName().get() | 1581 json_of << "{\"function\":\"" << info.GetDebugName().get() |
| 1580 << "\", \"source\":\"\",\n\"phases\":["; | 1582 << "\", \"source\":\"\",\n\"phases\":["; |
| 1581 } | 1583 } |
| 1582 pipeline.Run<PrintGraphPhase>("Machine"); | 1584 pipeline.Run<PrintGraphPhase>("Machine"); |
| 1583 } | 1585 } |
| 1584 | 1586 |
| 1585 pipeline.Run<VerifyGraphPhase>(false, true); | 1587 pipeline.Run<VerifyGraphPhase>(false, true); |
| 1586 return pipeline.ScheduleAndGenerateCode(call_descriptor); | 1588 return pipeline.ScheduleAndGenerateCode(call_descriptor); |
| 1587 } | 1589 } |
| 1588 | 1590 |
| 1589 // static | 1591 // static |
| 1590 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info) { | 1592 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info) { |
| 1591 ZonePool zone_pool(info->isolate()->allocator()); | 1593 ZonePool zone_pool(info->isolate()->allocator()); |
| 1592 base::SmartPointer<PipelineStatistics> pipeline_statistics( | 1594 std::unique_ptr<PipelineStatistics> pipeline_statistics( |
| 1593 CreatePipelineStatistics(info, &zone_pool)); | 1595 CreatePipelineStatistics(info, &zone_pool)); |
| 1594 PipelineData data(&zone_pool, info, pipeline_statistics.get()); | 1596 PipelineData data(&zone_pool, info, pipeline_statistics.get()); |
| 1595 PipelineImpl pipeline(&data); | 1597 PipelineImpl pipeline(&data); |
| 1596 | 1598 |
| 1597 Linkage linkage(Linkage::ComputeIncoming(data.instruction_zone(), info)); | 1599 Linkage linkage(Linkage::ComputeIncoming(data.instruction_zone(), info)); |
| 1598 | 1600 |
| 1599 if (!pipeline.CreateGraph()) return Handle<Code>::null(); | 1601 if (!pipeline.CreateGraph()) return Handle<Code>::null(); |
| 1600 if (!pipeline.OptimizeGraph(&linkage)) return Handle<Code>::null(); | 1602 if (!pipeline.OptimizeGraph(&linkage)) return Handle<Code>::null(); |
| 1601 return pipeline.GenerateCode(&linkage); | 1603 return pipeline.GenerateCode(&linkage); |
| 1602 } | 1604 } |
| 1603 | 1605 |
| 1604 // static | 1606 // static |
| 1605 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, | 1607 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, |
| 1606 Graph* graph, | 1608 Graph* graph, |
| 1607 Schedule* schedule) { | 1609 Schedule* schedule) { |
| 1608 CallDescriptor* call_descriptor = | 1610 CallDescriptor* call_descriptor = |
| 1609 Linkage::ComputeIncoming(info->zone(), info); | 1611 Linkage::ComputeIncoming(info->zone(), info); |
| 1610 return GenerateCodeForTesting(info, call_descriptor, graph, schedule); | 1612 return GenerateCodeForTesting(info, call_descriptor, graph, schedule); |
| 1611 } | 1613 } |
| 1612 | 1614 |
| 1613 // static | 1615 // static |
| 1614 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, | 1616 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, |
| 1615 CallDescriptor* call_descriptor, | 1617 CallDescriptor* call_descriptor, |
| 1616 Graph* graph, | 1618 Graph* graph, |
| 1617 Schedule* schedule) { | 1619 Schedule* schedule) { |
| 1618 // Construct a pipeline for scheduling and code generation. | 1620 // Construct a pipeline for scheduling and code generation. |
| 1619 ZonePool zone_pool(info->isolate()->allocator()); | 1621 ZonePool zone_pool(info->isolate()->allocator()); |
| 1620 PipelineData data(&zone_pool, info, graph, schedule); | 1622 PipelineData data(&zone_pool, info, graph, schedule); |
| 1621 base::SmartPointer<PipelineStatistics> pipeline_statistics; | 1623 std::unique_ptr<PipelineStatistics> pipeline_statistics; |
| 1622 if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { | 1624 if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { |
| 1623 pipeline_statistics.Reset(new PipelineStatistics(info, &zone_pool)); | 1625 pipeline_statistics.reset(new PipelineStatistics(info, &zone_pool)); |
| 1624 pipeline_statistics->BeginPhaseKind("test codegen"); | 1626 pipeline_statistics->BeginPhaseKind("test codegen"); |
| 1625 } | 1627 } |
| 1626 | 1628 |
| 1627 PipelineImpl pipeline(&data); | 1629 PipelineImpl pipeline(&data); |
| 1628 | 1630 |
| 1629 if (FLAG_trace_turbo) { | 1631 if (FLAG_trace_turbo) { |
| 1630 TurboJsonFile json_of(info, std::ios_base::trunc); | 1632 TurboJsonFile json_of(info, std::ios_base::trunc); |
| 1631 json_of << "{\"function\":\"" << info->GetDebugName().get() | 1633 json_of << "{\"function\":\"" << info->GetDebugName().get() |
| 1632 << "\", \"source\":\"\",\n\"phases\":["; | 1634 << "\", \"source\":\"\",\n\"phases\":["; |
| 1633 } | 1635 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1780 | 1782 |
| 1781 // Generate the final machine code. | 1783 // Generate the final machine code. |
| 1782 return GenerateCode(&linkage); | 1784 return GenerateCode(&linkage); |
| 1783 } | 1785 } |
| 1784 | 1786 |
| 1785 void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config, | 1787 void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config, |
| 1786 CallDescriptor* descriptor, | 1788 CallDescriptor* descriptor, |
| 1787 bool run_verifier) { | 1789 bool run_verifier) { |
| 1788 PipelineData* data = this->data_; | 1790 PipelineData* data = this->data_; |
| 1789 // Don't track usage for this zone in compiler stats. | 1791 // Don't track usage for this zone in compiler stats. |
| 1790 base::SmartPointer<Zone> verifier_zone; | 1792 std::unique_ptr<Zone> verifier_zone; |
| 1791 RegisterAllocatorVerifier* verifier = nullptr; | 1793 RegisterAllocatorVerifier* verifier = nullptr; |
| 1792 if (run_verifier) { | 1794 if (run_verifier) { |
| 1793 verifier_zone.Reset(new Zone(isolate()->allocator())); | 1795 verifier_zone.reset(new Zone(isolate()->allocator())); |
| 1794 verifier = new (verifier_zone.get()) RegisterAllocatorVerifier( | 1796 verifier = new (verifier_zone.get()) RegisterAllocatorVerifier( |
| 1795 verifier_zone.get(), config, data->sequence()); | 1797 verifier_zone.get(), config, data->sequence()); |
| 1796 } | 1798 } |
| 1797 | 1799 |
| 1798 #ifdef DEBUG | 1800 #ifdef DEBUG |
| 1799 data_->sequence()->ValidateEdgeSplitForm(); | 1801 data_->sequence()->ValidateEdgeSplitForm(); |
| 1800 data_->sequence()->ValidateDeferredBlockEntryPaths(); | 1802 data_->sequence()->ValidateDeferredBlockEntryPaths(); |
| 1801 data_->sequence()->ValidateDeferredBlockExitPaths(); | 1803 data_->sequence()->ValidateDeferredBlockExitPaths(); |
| 1802 #endif | 1804 #endif |
| 1803 | 1805 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1866 data->DeleteRegisterAllocationZone(); | 1868 data->DeleteRegisterAllocationZone(); |
| 1867 } | 1869 } |
| 1868 | 1870 |
| 1869 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1871 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
| 1870 | 1872 |
| 1871 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1873 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
| 1872 | 1874 |
| 1873 } // namespace compiler | 1875 } // namespace compiler |
| 1874 } // namespace internal | 1876 } // namespace internal |
| 1875 } // namespace v8 | 1877 } // namespace v8 |
| OLD | NEW |