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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 public: | 82 public: |
83 // For main entry point. | 83 // For main entry point. |
84 PipelineData(ZonePool* zone_pool, CompilationInfo* info, | 84 PipelineData(ZonePool* zone_pool, CompilationInfo* info, |
85 PipelineStatistics* pipeline_statistics) | 85 PipelineStatistics* pipeline_statistics) |
86 : isolate_(info->isolate()), | 86 : isolate_(info->isolate()), |
87 info_(info), | 87 info_(info), |
88 debug_name_(info_->GetDebugName()), | 88 debug_name_(info_->GetDebugName()), |
89 outer_zone_(info_->zone()), | 89 outer_zone_(info_->zone()), |
90 zone_pool_(zone_pool), | 90 zone_pool_(zone_pool), |
91 pipeline_statistics_(pipeline_statistics), | 91 pipeline_statistics_(pipeline_statistics), |
| 92 code_generator_(info->zone(), info), |
92 graph_zone_scope_(zone_pool_), | 93 graph_zone_scope_(zone_pool_), |
93 graph_zone_(graph_zone_scope_.zone()), | 94 graph_zone_(graph_zone_scope_.zone()), |
94 instruction_zone_scope_(zone_pool_), | 95 instruction_zone_scope_(zone_pool_), |
95 instruction_zone_(instruction_zone_scope_.zone()), | 96 instruction_zone_(instruction_zone_scope_.zone()), |
| 97 sequence_(nullptr), |
| 98 frame_(nullptr), |
96 register_allocation_zone_scope_(zone_pool_), | 99 register_allocation_zone_scope_(zone_pool_), |
97 register_allocation_zone_(register_allocation_zone_scope_.zone()) { | 100 register_allocation_zone_(register_allocation_zone_scope_.zone()) { |
98 PhaseScope scope(pipeline_statistics, "init pipeline data"); | 101 PhaseScope scope(pipeline_statistics, "init pipeline data"); |
99 graph_ = new (graph_zone_) Graph(graph_zone_); | 102 graph_ = new (graph_zone_) Graph(graph_zone_); |
100 source_positions_ = new (graph_zone_) SourcePositionTable(graph_); | 103 source_positions_ = new (graph_zone_) SourcePositionTable(graph_); |
101 simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_); | 104 simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_); |
102 machine_ = new (graph_zone_) MachineOperatorBuilder( | 105 machine_ = new (graph_zone_) MachineOperatorBuilder( |
103 graph_zone_, MachineType::PointerRepresentation(), | 106 graph_zone_, MachineType::PointerRepresentation(), |
104 InstructionSelector::SupportedMachineOperatorFlags(), | 107 InstructionSelector::SupportedMachineOperatorFlags(), |
105 InstructionSelector::AlignmentRequirements()); | 108 InstructionSelector::AlignmentRequirements()); |
106 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); | 109 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); |
107 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); | 110 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); |
108 jsgraph_ = new (graph_zone_) | 111 jsgraph_ = new (graph_zone_) |
109 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); | 112 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); |
110 } | 113 } |
111 | 114 |
112 // For WASM compile entry point. | 115 // For WASM compile entry point. |
113 PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph, | 116 PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph, |
114 SourcePositionTable* source_positions) | 117 SourcePositionTable* source_positions) |
115 : isolate_(info->isolate()), | 118 : isolate_(info->isolate()), |
116 info_(info), | 119 info_(info), |
117 debug_name_(info_->GetDebugName()), | 120 debug_name_(info_->GetDebugName()), |
118 zone_pool_(zone_pool), | 121 zone_pool_(zone_pool), |
| 122 code_generator_(info->zone(), info), |
119 graph_zone_scope_(zone_pool_), | 123 graph_zone_scope_(zone_pool_), |
120 graph_(graph), | 124 graph_(graph), |
121 source_positions_(source_positions), | 125 source_positions_(source_positions), |
122 instruction_zone_scope_(zone_pool_), | 126 instruction_zone_scope_(zone_pool_), |
123 instruction_zone_(instruction_zone_scope_.zone()), | 127 instruction_zone_(instruction_zone_scope_.zone()), |
| 128 sequence_(nullptr), |
| 129 frame_(nullptr), |
124 register_allocation_zone_scope_(zone_pool_), | 130 register_allocation_zone_scope_(zone_pool_), |
125 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} | 131 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} |
126 | 132 |
127 // For machine graph testing entry point. | 133 // For machine graph testing entry point. |
128 PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph, | 134 PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph, |
129 Schedule* schedule) | 135 Schedule* schedule) |
130 : isolate_(info->isolate()), | 136 : isolate_(info->isolate()), |
131 info_(info), | 137 info_(info), |
132 debug_name_(info_->GetDebugName()), | 138 debug_name_(info_->GetDebugName()), |
133 zone_pool_(zone_pool), | 139 zone_pool_(zone_pool), |
| 140 code_generator_(info->zone(), info), |
134 graph_zone_scope_(zone_pool_), | 141 graph_zone_scope_(zone_pool_), |
135 graph_(graph), | 142 graph_(graph), |
136 source_positions_(new (info->zone()) SourcePositionTable(graph_)), | 143 source_positions_(new (info->zone()) SourcePositionTable(graph_)), |
137 schedule_(schedule), | 144 schedule_(schedule), |
138 instruction_zone_scope_(zone_pool_), | 145 instruction_zone_scope_(zone_pool_), |
139 instruction_zone_(instruction_zone_scope_.zone()), | 146 instruction_zone_(instruction_zone_scope_.zone()), |
| 147 sequence_(nullptr), |
| 148 frame_(nullptr), |
140 register_allocation_zone_scope_(zone_pool_), | 149 register_allocation_zone_scope_(zone_pool_), |
141 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} | 150 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} |
142 | 151 |
143 // For register allocation testing entry point. | 152 // For register allocation testing entry point. |
144 PipelineData(ZonePool* zone_pool, CompilationInfo* info, | 153 PipelineData(ZonePool* zone_pool, CompilationInfo* info, |
145 InstructionSequence* sequence) | 154 InstructionSequence* sequence) |
146 : isolate_(info->isolate()), | 155 : isolate_(info->isolate()), |
147 info_(info), | 156 info_(info), |
148 debug_name_(info_->GetDebugName()), | 157 debug_name_(info_->GetDebugName()), |
149 zone_pool_(zone_pool), | 158 zone_pool_(zone_pool), |
| 159 code_generator_(info->zone(), info), |
150 graph_zone_scope_(zone_pool_), | 160 graph_zone_scope_(zone_pool_), |
151 instruction_zone_scope_(zone_pool_), | 161 instruction_zone_scope_(zone_pool_), |
152 instruction_zone_(sequence->zone()), | 162 instruction_zone_(sequence->zone()), |
153 sequence_(sequence), | 163 sequence_(sequence), |
| 164 frame_(nullptr), |
154 register_allocation_zone_scope_(zone_pool_), | 165 register_allocation_zone_scope_(zone_pool_), |
155 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} | 166 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} |
156 | 167 |
157 ~PipelineData() { | 168 ~PipelineData() { |
158 DeleteRegisterAllocationZone(); | 169 DeleteRegisterAllocationZone(); |
159 DeleteInstructionZone(); | 170 DeleteInstructionZone(); |
160 DeleteGraphZone(); | 171 DeleteGraphZone(); |
161 } | 172 } |
162 | 173 |
163 Isolate* isolate() const { return isolate_; } | 174 Isolate* isolate() const { return isolate_; } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 Schedule* schedule() const { return schedule_; } | 215 Schedule* schedule() const { return schedule_; } |
205 void set_schedule(Schedule* schedule) { | 216 void set_schedule(Schedule* schedule) { |
206 DCHECK(!schedule_); | 217 DCHECK(!schedule_); |
207 schedule_ = schedule; | 218 schedule_ = schedule; |
208 } | 219 } |
209 void reset_schedule() { schedule_ = nullptr; } | 220 void reset_schedule() { schedule_ = nullptr; } |
210 | 221 |
211 Zone* instruction_zone() const { return instruction_zone_; } | 222 Zone* instruction_zone() const { return instruction_zone_; } |
212 InstructionSequence* sequence() const { return sequence_; } | 223 InstructionSequence* sequence() const { return sequence_; } |
213 Frame* frame() const { return frame_; } | 224 Frame* frame() const { return frame_; } |
| 225 CodeGenerator* code_generator() { return &code_generator_; } |
| 226 bool assemble_code_successful() { |
| 227 return code_generator_.assemble_code_successful(); |
| 228 } |
214 | 229 |
215 Zone* register_allocation_zone() const { return register_allocation_zone_; } | 230 Zone* register_allocation_zone() const { return register_allocation_zone_; } |
216 RegisterAllocationData* register_allocation_data() const { | 231 RegisterAllocationData* register_allocation_data() const { |
217 return register_allocation_data_; | 232 return register_allocation_data_; |
218 } | 233 } |
219 | 234 |
220 BasicBlockProfiler::Data* profiler_data() const { return profiler_data_; } | 235 BasicBlockProfiler::Data* profiler_data() const { return profiler_data_; } |
221 void set_profiler_data(BasicBlockProfiler::Data* profiler_data) { | 236 void set_profiler_data(BasicBlockProfiler::Data* profiler_data) { |
222 profiler_data_ = profiler_data; | 237 profiler_data_ = profiler_data; |
223 } | 238 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 321 |
307 private: | 322 private: |
308 Isolate* const isolate_; | 323 Isolate* const isolate_; |
309 CompilationInfo* const info_; | 324 CompilationInfo* const info_; |
310 std::unique_ptr<char[]> debug_name_; | 325 std::unique_ptr<char[]> debug_name_; |
311 Zone* outer_zone_ = nullptr; | 326 Zone* outer_zone_ = nullptr; |
312 ZonePool* const zone_pool_; | 327 ZonePool* const zone_pool_; |
313 PipelineStatistics* pipeline_statistics_ = nullptr; | 328 PipelineStatistics* pipeline_statistics_ = nullptr; |
314 bool compilation_failed_ = false; | 329 bool compilation_failed_ = false; |
315 Handle<Code> code_ = Handle<Code>::null(); | 330 Handle<Code> code_ = Handle<Code>::null(); |
| 331 CodeGenerator code_generator_; |
316 | 332 |
317 // All objects in the following group of fields are allocated in graph_zone_. | 333 // All objects in the following group of fields are allocated in graph_zone_. |
318 // They are all set to nullptr when the graph_zone_ is destroyed. | 334 // They are all set to nullptr when the graph_zone_ is destroyed. |
319 ZonePool::Scope graph_zone_scope_; | 335 ZonePool::Scope graph_zone_scope_; |
320 Zone* graph_zone_ = nullptr; | 336 Zone* graph_zone_ = nullptr; |
321 Graph* graph_ = nullptr; | 337 Graph* graph_ = nullptr; |
322 SourcePositionTable* source_positions_ = nullptr; | 338 SourcePositionTable* source_positions_ = nullptr; |
323 LoopAssignmentAnalysis* loop_assignment_ = nullptr; | 339 LoopAssignmentAnalysis* loop_assignment_ = nullptr; |
324 TypeHintAnalysis* type_hint_analysis_ = nullptr; | 340 TypeHintAnalysis* type_hint_analysis_ = nullptr; |
325 SimplifiedOperatorBuilder* simplified_ = nullptr; | 341 SimplifiedOperatorBuilder* simplified_ = nullptr; |
326 MachineOperatorBuilder* machine_ = nullptr; | 342 MachineOperatorBuilder* machine_ = nullptr; |
327 CommonOperatorBuilder* common_ = nullptr; | 343 CommonOperatorBuilder* common_ = nullptr; |
328 JSOperatorBuilder* javascript_ = nullptr; | 344 JSOperatorBuilder* javascript_ = nullptr; |
329 JSGraph* jsgraph_ = nullptr; | 345 JSGraph* jsgraph_ = nullptr; |
330 Schedule* schedule_ = nullptr; | 346 Schedule* schedule_ = nullptr; |
331 | 347 |
332 // All objects in the following group of fields are allocated in | 348 // All objects in the following group of fields are allocated in |
333 // instruction_zone_. They are all set to nullptr when the instruction_zone_ | 349 // instruction_zone_. They are all set to nullptr when the instruction_zone_ |
334 // is | 350 // is destroyed. |
335 // destroyed. | |
336 ZonePool::Scope instruction_zone_scope_; | 351 ZonePool::Scope instruction_zone_scope_; |
337 Zone* instruction_zone_; | 352 Zone* instruction_zone_; |
338 InstructionSequence* sequence_ = nullptr; | 353 InstructionSequence* sequence_; |
339 Frame* frame_ = nullptr; | 354 Frame* frame_; |
340 | 355 |
341 // All objects in the following group of fields are allocated in | 356 // All objects in the following group of fields are allocated in |
342 // register_allocation_zone_. They are all set to nullptr when the zone is | 357 // register_allocation_zone_. They are all set to nullptr when the zone is |
343 // destroyed. | 358 // destroyed. |
344 ZonePool::Scope register_allocation_zone_scope_; | 359 ZonePool::Scope register_allocation_zone_scope_; |
345 Zone* register_allocation_zone_; | 360 Zone* register_allocation_zone_; |
346 RegisterAllocationData* register_allocation_data_ = nullptr; | 361 RegisterAllocationData* register_allocation_data_ = nullptr; |
347 | 362 |
348 // Basic block profiling support. | 363 // Basic block profiling support. |
349 BasicBlockProfiler::Data* profiler_data_ = nullptr; | 364 BasicBlockProfiler::Data* profiler_data_ = nullptr; |
(...skipping 26 matching lines...) Expand all Loading... |
376 template <typename Phase, typename Arg0, typename Arg1> | 391 template <typename Phase, typename Arg0, typename Arg1> |
377 void Run(Arg0 arg_0, Arg1 arg_1); | 392 void Run(Arg0 arg_0, Arg1 arg_1); |
378 | 393 |
379 // Run the graph creation and initial optimization passes. | 394 // Run the graph creation and initial optimization passes. |
380 bool CreateGraph(); | 395 bool CreateGraph(); |
381 | 396 |
382 // Run the concurrent optimization passes. | 397 // Run the concurrent optimization passes. |
383 bool OptimizeGraph(Linkage* linkage); | 398 bool OptimizeGraph(Linkage* linkage); |
384 | 399 |
385 // Perform the actual code generation and return handle to a code object. | 400 // Perform the actual code generation and return handle to a code object. |
386 Handle<Code> GenerateCode(Linkage* linkage); | 401 bool AssembleCode(Linkage* linkage); |
| 402 Handle<Code> FinishCodeObject(); |
387 | 403 |
388 bool ScheduleAndSelectInstructions(Linkage* linkage); | 404 bool ScheduleAndSelectInstructions(Linkage* linkage); |
389 void RunPrintAndVerify(const char* phase, bool untyped = false); | 405 void RunPrintAndVerify(const char* phase, bool untyped = false); |
390 Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor); | 406 Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor); |
391 void AllocateRegisters(const RegisterConfiguration* config, | 407 void AllocateRegisters(const RegisterConfiguration* config, |
392 CallDescriptor* descriptor, bool run_verifier); | 408 CallDescriptor* descriptor, bool run_verifier); |
393 | 409 |
394 CompilationInfo* info() const; | 410 CompilationInfo* info() const; |
395 Isolate* isolate() const; | 411 Isolate* isolate() const; |
396 | 412 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 | 648 |
633 return SUCCEEDED; | 649 return SUCCEEDED; |
634 } | 650 } |
635 | 651 |
636 PipelineCompilationJob::Status PipelineCompilationJob::OptimizeGraphImpl() { | 652 PipelineCompilationJob::Status PipelineCompilationJob::OptimizeGraphImpl() { |
637 if (!pipeline_.OptimizeGraph(linkage_)) return FAILED; | 653 if (!pipeline_.OptimizeGraph(linkage_)) return FAILED; |
638 return SUCCEEDED; | 654 return SUCCEEDED; |
639 } | 655 } |
640 | 656 |
641 PipelineCompilationJob::Status PipelineCompilationJob::GenerateCodeImpl() { | 657 PipelineCompilationJob::Status PipelineCompilationJob::GenerateCodeImpl() { |
642 Handle<Code> code = pipeline_.GenerateCode(linkage_); | 658 pipeline_.AssembleCode(linkage_); |
| 659 Handle<Code> code = pipeline_.FinishCodeObject(); |
643 if (code.is_null()) { | 660 if (code.is_null()) { |
644 if (info()->bailout_reason() == kNoReason) { | 661 if (info()->bailout_reason() == kNoReason) { |
645 return AbortOptimization(kCodeGenerationFailed); | 662 return AbortOptimization(kCodeGenerationFailed); |
646 } | 663 } |
647 return FAILED; | 664 return FAILED; |
648 } | 665 } |
649 info()->dependencies()->Commit(code); | 666 info()->dependencies()->Commit(code); |
650 info()->SetCode(code); | 667 info()->SetCode(code); |
651 if (info()->is_deoptimization_enabled()) { | 668 if (info()->is_deoptimization_enabled()) { |
652 info()->context()->native_context()->AddOptimizedCode(*code); | 669 info()->context()->native_context()->AddOptimizedCode(*code); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 } | 709 } |
693 | 710 |
694 pipeline_.RunPrintAndVerify("Machine", true); | 711 pipeline_.RunPrintAndVerify("Machine", true); |
695 | 712 |
696 if (!pipeline_.ScheduleAndSelectInstructions(&linkage_)) return FAILED; | 713 if (!pipeline_.ScheduleAndSelectInstructions(&linkage_)) return FAILED; |
697 return SUCCEEDED; | 714 return SUCCEEDED; |
698 } | 715 } |
699 | 716 |
700 PipelineWasmCompilationJob::Status | 717 PipelineWasmCompilationJob::Status |
701 PipelineWasmCompilationJob::GenerateCodeImpl() { | 718 PipelineWasmCompilationJob::GenerateCodeImpl() { |
702 pipeline_.GenerateCode(&linkage_); | 719 pipeline_.AssembleCode(&linkage_); |
| 720 pipeline_.FinishCodeObject(); |
703 return SUCCEEDED; | 721 return SUCCEEDED; |
704 } | 722 } |
705 | 723 |
706 template <typename Phase> | 724 template <typename Phase> |
707 void PipelineImpl::Run() { | 725 void PipelineImpl::Run() { |
708 PipelineRunScope scope(this->data_, Phase::phase_name()); | 726 PipelineRunScope scope(this->data_, Phase::phase_name()); |
709 Phase phase; | 727 Phase phase; |
710 phase.Run(this->data_, scope.zone()); | 728 phase.Run(this->data_, scope.zone()); |
711 } | 729 } |
712 | 730 |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1390 | 1408 |
1391 void Run(PipelineData* data, Zone* temp_zone, bool frame_at_start) { | 1409 void Run(PipelineData* data, Zone* temp_zone, bool frame_at_start) { |
1392 ZoneVector<RpoNumber> result(temp_zone); | 1410 ZoneVector<RpoNumber> result(temp_zone); |
1393 if (JumpThreading::ComputeForwarding(temp_zone, result, data->sequence(), | 1411 if (JumpThreading::ComputeForwarding(temp_zone, result, data->sequence(), |
1394 frame_at_start)) { | 1412 frame_at_start)) { |
1395 JumpThreading::ApplyForwarding(result, data->sequence()); | 1413 JumpThreading::ApplyForwarding(result, data->sequence()); |
1396 } | 1414 } |
1397 } | 1415 } |
1398 }; | 1416 }; |
1399 | 1417 |
1400 | 1418 struct AssembleCodePhase { |
1401 struct GenerateCodePhase { | |
1402 static const char* phase_name() { return "generate code"; } | 1419 static const char* phase_name() { return "generate code"; } |
1403 | 1420 |
1404 void Run(PipelineData* data, Zone* temp_zone, Linkage* linkage) { | 1421 void Run(PipelineData* data, Zone* temp_zone, Linkage* linkage) { |
1405 CodeGenerator generator(data->frame(), linkage, data->sequence(), | 1422 data->code_generator()->Initialize(data->frame(), linkage, |
1406 data->info()); | 1423 data->sequence()); |
1407 data->set_code(generator.GenerateCode()); | 1424 data->code_generator()->AssembleCode(); |
1408 } | 1425 } |
1409 }; | 1426 }; |
1410 | 1427 |
| 1428 struct FinishCodeObjectPhase { |
| 1429 static const char* phase_name() { return "generate code"; } |
| 1430 |
| 1431 void Run(PipelineData* data, Zone* temp_zone) { |
| 1432 data->set_code(data->code_generator()->FinishCodeObject()); |
| 1433 } |
| 1434 }; |
1411 | 1435 |
1412 struct PrintGraphPhase { | 1436 struct PrintGraphPhase { |
1413 static const char* phase_name() { return nullptr; } | 1437 static const char* phase_name() { return nullptr; } |
1414 | 1438 |
1415 void Run(PipelineData* data, Zone* temp_zone, const char* phase) { | 1439 void Run(PipelineData* data, Zone* temp_zone, const char* phase) { |
1416 CompilationInfo* info = data->info(); | 1440 CompilationInfo* info = data->info(); |
1417 Graph* graph = data->graph(); | 1441 Graph* graph = data->graph(); |
1418 | 1442 |
1419 { // Print JSON. | 1443 { // Print JSON. |
1420 AllowHandleDereference allow_deref; | 1444 AllowHandleDereference allow_deref; |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1653 ZonePool zone_pool(info->isolate()->allocator()); | 1677 ZonePool zone_pool(info->isolate()->allocator()); |
1654 std::unique_ptr<PipelineStatistics> pipeline_statistics( | 1678 std::unique_ptr<PipelineStatistics> pipeline_statistics( |
1655 CreatePipelineStatistics(info, &zone_pool)); | 1679 CreatePipelineStatistics(info, &zone_pool)); |
1656 PipelineData data(&zone_pool, info, pipeline_statistics.get()); | 1680 PipelineData data(&zone_pool, info, pipeline_statistics.get()); |
1657 PipelineImpl pipeline(&data); | 1681 PipelineImpl pipeline(&data); |
1658 | 1682 |
1659 Linkage linkage(Linkage::ComputeIncoming(data.instruction_zone(), info)); | 1683 Linkage linkage(Linkage::ComputeIncoming(data.instruction_zone(), info)); |
1660 | 1684 |
1661 if (!pipeline.CreateGraph()) return Handle<Code>::null(); | 1685 if (!pipeline.CreateGraph()) return Handle<Code>::null(); |
1662 if (!pipeline.OptimizeGraph(&linkage)) return Handle<Code>::null(); | 1686 if (!pipeline.OptimizeGraph(&linkage)) return Handle<Code>::null(); |
1663 return pipeline.GenerateCode(&linkage); | 1687 pipeline.AssembleCode(&linkage); |
| 1688 return pipeline.FinishCodeObject(); |
1664 } | 1689 } |
1665 | 1690 |
1666 // static | 1691 // static |
1667 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, | 1692 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, |
1668 Graph* graph, | 1693 Graph* graph, |
1669 Schedule* schedule) { | 1694 Schedule* schedule) { |
1670 CallDescriptor* call_descriptor = | 1695 CallDescriptor* call_descriptor = |
1671 Linkage::ComputeIncoming(info->zone(), info); | 1696 Linkage::ComputeIncoming(info->zone(), info); |
1672 return GenerateCodeForTesting(info, call_descriptor, graph, schedule); | 1697 return GenerateCodeForTesting(info, call_descriptor, graph, schedule); |
1673 } | 1698 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1781 // Optimimize jumps. | 1806 // Optimimize jumps. |
1782 if (FLAG_turbo_jt) { | 1807 if (FLAG_turbo_jt) { |
1783 Run<JumpThreadingPhase>(generate_frame_at_start); | 1808 Run<JumpThreadingPhase>(generate_frame_at_start); |
1784 } | 1809 } |
1785 | 1810 |
1786 data->EndPhaseKind(); | 1811 data->EndPhaseKind(); |
1787 | 1812 |
1788 return true; | 1813 return true; |
1789 } | 1814 } |
1790 | 1815 |
1791 Handle<Code> PipelineImpl::GenerateCode(Linkage* linkage) { | 1816 bool PipelineImpl::AssembleCode(Linkage* linkage) { |
1792 PipelineData* data = this->data_; | 1817 PipelineData* data = this->data_; |
1793 | 1818 |
1794 data->BeginPhaseKind("code generation"); | 1819 data->BeginPhaseKind("assemble code"); |
1795 | 1820 |
1796 // Generate final machine code. | 1821 // Assemble machine code. |
1797 Run<GenerateCodePhase>(linkage); | 1822 Run<AssembleCodePhase>(linkage); |
| 1823 return data->assemble_code_successful(); |
| 1824 } |
| 1825 |
| 1826 Handle<Code> PipelineImpl::FinishCodeObject() { |
| 1827 PipelineData* data = this->data_; |
| 1828 |
| 1829 data->BeginPhaseKind("finish code generation"); |
| 1830 |
| 1831 // Generate final code object. |
| 1832 Run<FinishCodeObjectPhase>(); |
1798 | 1833 |
1799 Handle<Code> code = data->code(); | 1834 Handle<Code> code = data->code(); |
1800 if (data->profiler_data()) { | 1835 if (data->profiler_data()) { |
1801 #if ENABLE_DISASSEMBLER | 1836 #if ENABLE_DISASSEMBLER |
1802 std::ostringstream os; | 1837 std::ostringstream os; |
1803 code->Disassemble(nullptr, os); | 1838 code->Disassemble(nullptr, os); |
1804 data->profiler_data()->SetCode(&os); | 1839 data->profiler_data()->SetCode(&os); |
1805 #endif | 1840 #endif |
1806 } | 1841 } |
1807 | 1842 |
(...skipping 26 matching lines...) Expand all Loading... |
1834 } | 1869 } |
1835 | 1870 |
1836 Handle<Code> PipelineImpl::ScheduleAndGenerateCode( | 1871 Handle<Code> PipelineImpl::ScheduleAndGenerateCode( |
1837 CallDescriptor* call_descriptor) { | 1872 CallDescriptor* call_descriptor) { |
1838 Linkage linkage(call_descriptor); | 1873 Linkage linkage(call_descriptor); |
1839 | 1874 |
1840 // Schedule the graph, perform instruction selection and register allocation. | 1875 // Schedule the graph, perform instruction selection and register allocation. |
1841 if (!ScheduleAndSelectInstructions(&linkage)) return Handle<Code>(); | 1876 if (!ScheduleAndSelectInstructions(&linkage)) return Handle<Code>(); |
1842 | 1877 |
1843 // Generate the final machine code. | 1878 // Generate the final machine code. |
1844 return GenerateCode(&linkage); | 1879 AssembleCode(&linkage); |
| 1880 return FinishCodeObject(); |
1845 } | 1881 } |
1846 | 1882 |
1847 void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config, | 1883 void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config, |
1848 CallDescriptor* descriptor, | 1884 CallDescriptor* descriptor, |
1849 bool run_verifier) { | 1885 bool run_verifier) { |
1850 PipelineData* data = this->data_; | 1886 PipelineData* data = this->data_; |
1851 // Don't track usage for this zone in compiler stats. | 1887 // Don't track usage for this zone in compiler stats. |
1852 std::unique_ptr<Zone> verifier_zone; | 1888 std::unique_ptr<Zone> verifier_zone; |
1853 RegisterAllocatorVerifier* verifier = nullptr; | 1889 RegisterAllocatorVerifier* verifier = nullptr; |
1854 if (run_verifier) { | 1890 if (run_verifier) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1929 data->DeleteRegisterAllocationZone(); | 1965 data->DeleteRegisterAllocationZone(); |
1930 } | 1966 } |
1931 | 1967 |
1932 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1968 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
1933 | 1969 |
1934 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1970 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
1935 | 1971 |
1936 } // namespace compiler | 1972 } // namespace compiler |
1937 } // namespace internal | 1973 } // namespace internal |
1938 } // namespace v8 | 1974 } // namespace v8 |
OLD | NEW |