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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 public: | 86 public: |
87 // For main entry point. | 87 // For main entry point. |
88 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, | 88 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, |
89 PipelineStatistics* pipeline_statistics) | 89 PipelineStatistics* pipeline_statistics) |
90 : isolate_(info->isolate()), | 90 : isolate_(info->isolate()), |
91 info_(info), | 91 info_(info), |
92 debug_name_(info_->GetDebugName()), | 92 debug_name_(info_->GetDebugName()), |
93 outer_zone_(info_->zone()), | 93 outer_zone_(info_->zone()), |
94 zone_stats_(zone_stats), | 94 zone_stats_(zone_stats), |
95 pipeline_statistics_(pipeline_statistics), | 95 pipeline_statistics_(pipeline_statistics), |
96 graph_zone_scope_(zone_stats_), | 96 graph_zone_scope_(zone_stats_, ZONE_NAME), |
97 graph_zone_(graph_zone_scope_.zone()), | 97 graph_zone_(graph_zone_scope_.zone()), |
98 instruction_zone_scope_(zone_stats_), | 98 instruction_zone_scope_(zone_stats_, ZONE_NAME), |
99 instruction_zone_(instruction_zone_scope_.zone()), | 99 instruction_zone_(instruction_zone_scope_.zone()), |
100 register_allocation_zone_scope_(zone_stats_), | 100 register_allocation_zone_scope_(zone_stats_, ZONE_NAME), |
101 register_allocation_zone_(register_allocation_zone_scope_.zone()) { | 101 register_allocation_zone_(register_allocation_zone_scope_.zone()) { |
102 PhaseScope scope(pipeline_statistics, "init pipeline data"); | 102 PhaseScope scope(pipeline_statistics, "init pipeline data"); |
103 graph_ = new (graph_zone_) Graph(graph_zone_); | 103 graph_ = new (graph_zone_) Graph(graph_zone_); |
104 source_positions_ = new (graph_zone_) SourcePositionTable(graph_); | 104 source_positions_ = new (graph_zone_) SourcePositionTable(graph_); |
105 simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_); | 105 simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_); |
106 machine_ = new (graph_zone_) MachineOperatorBuilder( | 106 machine_ = new (graph_zone_) MachineOperatorBuilder( |
107 graph_zone_, MachineType::PointerRepresentation(), | 107 graph_zone_, MachineType::PointerRepresentation(), |
108 InstructionSelector::SupportedMachineOperatorFlags(), | 108 InstructionSelector::SupportedMachineOperatorFlags(), |
109 InstructionSelector::AlignmentRequirements()); | 109 InstructionSelector::AlignmentRequirements()); |
110 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); | 110 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); |
111 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); | 111 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); |
112 jsgraph_ = new (graph_zone_) | 112 jsgraph_ = new (graph_zone_) |
113 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); | 113 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); |
114 } | 114 } |
115 | 115 |
116 // For WASM compile entry point. | 116 // For WASM compile entry point. |
117 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, | 117 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, |
118 SourcePositionTable* source_positions) | 118 SourcePositionTable* source_positions) |
119 : isolate_(info->isolate()), | 119 : isolate_(info->isolate()), |
120 info_(info), | 120 info_(info), |
121 debug_name_(info_->GetDebugName()), | 121 debug_name_(info_->GetDebugName()), |
122 zone_stats_(zone_stats), | 122 zone_stats_(zone_stats), |
123 graph_zone_scope_(zone_stats_), | 123 graph_zone_scope_(zone_stats_, ZONE_NAME), |
124 graph_(graph), | 124 graph_(graph), |
125 source_positions_(source_positions), | 125 source_positions_(source_positions), |
126 instruction_zone_scope_(zone_stats_), | 126 instruction_zone_scope_(zone_stats_, ZONE_NAME), |
127 instruction_zone_(instruction_zone_scope_.zone()), | 127 instruction_zone_(instruction_zone_scope_.zone()), |
128 register_allocation_zone_scope_(zone_stats_), | 128 register_allocation_zone_scope_(zone_stats_, ZONE_NAME), |
129 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} | 129 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} |
130 | 130 |
131 // For machine graph testing entry point. | 131 // For machine graph testing entry point. |
132 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, | 132 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, |
133 Schedule* schedule) | 133 Schedule* schedule) |
134 : isolate_(info->isolate()), | 134 : isolate_(info->isolate()), |
135 info_(info), | 135 info_(info), |
136 debug_name_(info_->GetDebugName()), | 136 debug_name_(info_->GetDebugName()), |
137 zone_stats_(zone_stats), | 137 zone_stats_(zone_stats), |
138 graph_zone_scope_(zone_stats_), | 138 graph_zone_scope_(zone_stats_, ZONE_NAME), |
139 graph_(graph), | 139 graph_(graph), |
140 source_positions_(new (info->zone()) SourcePositionTable(graph_)), | 140 source_positions_(new (info->zone()) SourcePositionTable(graph_)), |
141 schedule_(schedule), | 141 schedule_(schedule), |
142 instruction_zone_scope_(zone_stats_), | 142 instruction_zone_scope_(zone_stats_, ZONE_NAME), |
143 instruction_zone_(instruction_zone_scope_.zone()), | 143 instruction_zone_(instruction_zone_scope_.zone()), |
144 register_allocation_zone_scope_(zone_stats_), | 144 register_allocation_zone_scope_(zone_stats_, ZONE_NAME), |
145 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} | 145 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} |
146 | 146 |
147 // For register allocation testing entry point. | 147 // For register allocation testing entry point. |
148 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, | 148 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, |
149 InstructionSequence* sequence) | 149 InstructionSequence* sequence) |
150 : isolate_(info->isolate()), | 150 : isolate_(info->isolate()), |
151 info_(info), | 151 info_(info), |
152 debug_name_(info_->GetDebugName()), | 152 debug_name_(info_->GetDebugName()), |
153 zone_stats_(zone_stats), | 153 zone_stats_(zone_stats), |
154 graph_zone_scope_(zone_stats_), | 154 graph_zone_scope_(zone_stats_, ZONE_NAME), |
155 instruction_zone_scope_(zone_stats_), | 155 instruction_zone_scope_(zone_stats_, ZONE_NAME), |
156 instruction_zone_(sequence->zone()), | 156 instruction_zone_(sequence->zone()), |
157 sequence_(sequence), | 157 sequence_(sequence), |
158 register_allocation_zone_scope_(zone_stats_), | 158 register_allocation_zone_scope_(zone_stats_, ZONE_NAME), |
159 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} | 159 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} |
160 | 160 |
161 ~PipelineData() { | 161 ~PipelineData() { |
162 DeleteRegisterAllocationZone(); | 162 DeleteRegisterAllocationZone(); |
163 DeleteInstructionZone(); | 163 DeleteInstructionZone(); |
164 DeleteGraphZone(); | 164 DeleteGraphZone(); |
165 } | 165 } |
166 | 166 |
167 Isolate* isolate() const { return isolate_; } | 167 Isolate* isolate() const { return isolate_; } |
168 CompilationInfo* info() const { return info_; } | 168 CompilationInfo* info() const { return info_; } |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 } | 511 } |
512 } | 512 } |
513 | 513 |
514 | 514 |
515 class PipelineRunScope { | 515 class PipelineRunScope { |
516 public: | 516 public: |
517 PipelineRunScope(PipelineData* data, const char* phase_name) | 517 PipelineRunScope(PipelineData* data, const char* phase_name) |
518 : phase_scope_( | 518 : phase_scope_( |
519 phase_name == nullptr ? nullptr : data->pipeline_statistics(), | 519 phase_name == nullptr ? nullptr : data->pipeline_statistics(), |
520 phase_name), | 520 phase_name), |
521 zone_scope_(data->zone_stats()) {} | 521 zone_scope_(data->zone_stats(), ZONE_NAME) {} |
522 | 522 |
523 Zone* zone() { return zone_scope_.zone(); } | 523 Zone* zone() { return zone_scope_.zone(); } |
524 | 524 |
525 private: | 525 private: |
526 PhaseScope phase_scope_; | 526 PhaseScope phase_scope_; |
527 ZoneStats::Scope zone_scope_; | 527 ZoneStats::Scope zone_scope_; |
528 }; | 528 }; |
529 | 529 |
530 PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info, | 530 PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info, |
531 ZoneStats* zone_stats) { | 531 ZoneStats* zone_stats) { |
(...skipping 29 matching lines...) Expand all Loading... |
561 } | 561 } |
562 | 562 |
563 } // namespace | 563 } // namespace |
564 | 564 |
565 class PipelineCompilationJob final : public CompilationJob { | 565 class PipelineCompilationJob final : public CompilationJob { |
566 public: | 566 public: |
567 PipelineCompilationJob(Isolate* isolate, Handle<JSFunction> function) | 567 PipelineCompilationJob(Isolate* isolate, Handle<JSFunction> function) |
568 // Note that the CompilationInfo is not initialized at the time we pass it | 568 // Note that the CompilationInfo is not initialized at the time we pass it |
569 // to the CompilationJob constructor, but it is not dereferenced there. | 569 // to the CompilationJob constructor, but it is not dereferenced there. |
570 : CompilationJob(isolate, &info_, "TurboFan"), | 570 : CompilationJob(isolate, &info_, "TurboFan"), |
571 zone_(isolate->allocator()), | 571 zone_(isolate->allocator(), ZONE_NAME), |
572 zone_stats_(isolate->allocator()), | 572 zone_stats_(isolate->allocator()), |
573 parse_info_(&zone_, handle(function->shared())), | 573 parse_info_(&zone_, handle(function->shared())), |
574 info_(&parse_info_, function), | 574 info_(&parse_info_, function), |
575 pipeline_statistics_(CreatePipelineStatistics(info(), &zone_stats_)), | 575 pipeline_statistics_(CreatePipelineStatistics(info(), &zone_stats_)), |
576 data_(&zone_stats_, info(), pipeline_statistics_.get()), | 576 data_(&zone_stats_, info(), pipeline_statistics_.get()), |
577 pipeline_(&data_), | 577 pipeline_(&data_), |
578 linkage_(nullptr) {} | 578 linkage_(nullptr) {} |
579 | 579 |
580 protected: | 580 protected: |
581 Status PrepareJobImpl() final; | 581 Status PrepareJobImpl() final; |
(...skipping 1198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1780 | 1780 |
1781 if (FLAG_turbo_profiling) { | 1781 if (FLAG_turbo_profiling) { |
1782 data->set_profiler_data(BasicBlockInstrumentor::Instrument( | 1782 data->set_profiler_data(BasicBlockInstrumentor::Instrument( |
1783 info(), data->graph(), data->schedule())); | 1783 info(), data->graph(), data->schedule())); |
1784 } | 1784 } |
1785 | 1785 |
1786 if (FLAG_turbo_verify_machine_graph != nullptr && | 1786 if (FLAG_turbo_verify_machine_graph != nullptr && |
1787 (!strcmp(FLAG_turbo_verify_machine_graph, "*") || | 1787 (!strcmp(FLAG_turbo_verify_machine_graph, "*") || |
1788 !strcmp(FLAG_turbo_verify_machine_graph, | 1788 !strcmp(FLAG_turbo_verify_machine_graph, |
1789 data->info()->GetDebugName().get()))) { | 1789 data->info()->GetDebugName().get()))) { |
1790 Zone temp_zone(data->isolate()->allocator()); | 1790 Zone temp_zone(data->isolate()->allocator(), ZONE_NAME); |
1791 MachineGraphVerifier::Run(data->graph(), data->schedule(), linkage, | 1791 MachineGraphVerifier::Run(data->graph(), data->schedule(), linkage, |
1792 &temp_zone); | 1792 &temp_zone); |
1793 } | 1793 } |
1794 | 1794 |
1795 data->InitializeInstructionSequence(call_descriptor); | 1795 data->InitializeInstructionSequence(call_descriptor); |
1796 | 1796 |
1797 data->InitializeFrameData(call_descriptor); | 1797 data->InitializeFrameData(call_descriptor); |
1798 // Select and schedule instructions covering the scheduled graph. | 1798 // Select and schedule instructions covering the scheduled graph. |
1799 Run<InstructionSelectionPhase>(linkage); | 1799 Run<InstructionSelectionPhase>(linkage); |
1800 if (data->compilation_failed()) { | 1800 if (data->compilation_failed()) { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 } | 1904 } |
1905 | 1905 |
1906 void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config, | 1906 void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config, |
1907 CallDescriptor* descriptor, | 1907 CallDescriptor* descriptor, |
1908 bool run_verifier) { | 1908 bool run_verifier) { |
1909 PipelineData* data = this->data_; | 1909 PipelineData* data = this->data_; |
1910 // Don't track usage for this zone in compiler stats. | 1910 // Don't track usage for this zone in compiler stats. |
1911 std::unique_ptr<Zone> verifier_zone; | 1911 std::unique_ptr<Zone> verifier_zone; |
1912 RegisterAllocatorVerifier* verifier = nullptr; | 1912 RegisterAllocatorVerifier* verifier = nullptr; |
1913 if (run_verifier) { | 1913 if (run_verifier) { |
1914 verifier_zone.reset(new Zone(isolate()->allocator())); | 1914 verifier_zone.reset(new Zone(isolate()->allocator(), ZONE_NAME)); |
1915 verifier = new (verifier_zone.get()) RegisterAllocatorVerifier( | 1915 verifier = new (verifier_zone.get()) RegisterAllocatorVerifier( |
1916 verifier_zone.get(), config, data->sequence()); | 1916 verifier_zone.get(), config, data->sequence()); |
1917 } | 1917 } |
1918 | 1918 |
1919 #ifdef DEBUG | 1919 #ifdef DEBUG |
1920 data_->sequence()->ValidateEdgeSplitForm(); | 1920 data_->sequence()->ValidateEdgeSplitForm(); |
1921 data_->sequence()->ValidateDeferredBlockEntryPaths(); | 1921 data_->sequence()->ValidateDeferredBlockEntryPaths(); |
1922 data_->sequence()->ValidateDeferredBlockExitPaths(); | 1922 data_->sequence()->ValidateDeferredBlockExitPaths(); |
1923 #endif | 1923 #endif |
1924 | 1924 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 data->DeleteRegisterAllocationZone(); | 1990 data->DeleteRegisterAllocationZone(); |
1991 } | 1991 } |
1992 | 1992 |
1993 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1993 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
1994 | 1994 |
1995 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1995 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
1996 | 1996 |
1997 } // namespace compiler | 1997 } // namespace compiler |
1998 } // namespace internal | 1998 } // namespace internal |
1999 } // namespace v8 | 1999 } // namespace v8 |
OLD | NEW |