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