Chromium Code Reviews| 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 : 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 graph_zone_scope_(zone_pool_), | 92 graph_zone_scope_(zone_pool_), |
| 93 graph_zone_(graph_zone_scope_.zone()), | 93 graph_zone_(graph_zone_scope_.zone()), |
| 94 instruction_zone_scope_(zone_pool_), | 94 instruction_zone_scope_(zone_pool_), |
| 95 instruction_zone_(instruction_zone_scope_.zone()), | 95 instruction_zone_(instruction_zone_scope_.zone()), |
| 96 sequence_(nullptr), | |
| 97 frame_(nullptr), | |
| 98 code_generator_(instruction_zone_, info), | |
|
Michael Starzinger
2016/08/11 14:16:26
As discussed offline: Lets put this into the outer
ahaas
2016/08/11 14:54:19
Done.
| |
| 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), |
| 119 graph_zone_scope_(zone_pool_), | 122 graph_zone_scope_(zone_pool_), |
| 120 graph_(graph), | 123 graph_(graph), |
| 121 source_positions_(source_positions), | 124 source_positions_(source_positions), |
| 122 instruction_zone_scope_(zone_pool_), | 125 instruction_zone_scope_(zone_pool_), |
| 123 instruction_zone_(instruction_zone_scope_.zone()), | 126 instruction_zone_(instruction_zone_scope_.zone()), |
| 127 sequence_(nullptr), | |
| 128 frame_(nullptr), | |
| 129 code_generator_(instruction_zone_, info), | |
| 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), |
| 134 graph_zone_scope_(zone_pool_), | 140 graph_zone_scope_(zone_pool_), |
| 135 graph_(graph), | 141 graph_(graph), |
| 136 source_positions_(new (info->zone()) SourcePositionTable(graph_)), | 142 source_positions_(new (info->zone()) SourcePositionTable(graph_)), |
| 137 schedule_(schedule), | 143 schedule_(schedule), |
| 138 instruction_zone_scope_(zone_pool_), | 144 instruction_zone_scope_(zone_pool_), |
| 139 instruction_zone_(instruction_zone_scope_.zone()), | 145 instruction_zone_(instruction_zone_scope_.zone()), |
| 146 sequence_(nullptr), | |
| 147 frame_(nullptr), | |
| 148 code_generator_(instruction_zone_, info), | |
| 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), |
| 150 graph_zone_scope_(zone_pool_), | 159 graph_zone_scope_(zone_pool_), |
| 151 instruction_zone_scope_(zone_pool_), | 160 instruction_zone_scope_(zone_pool_), |
| 152 instruction_zone_(sequence->zone()), | 161 instruction_zone_(sequence->zone()), |
| 153 sequence_(sequence), | 162 sequence_(sequence), |
| 163 frame_(nullptr), | |
| 164 code_generator_(instruction_zone_, info), | |
| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 TypeHintAnalysis* type_hint_analysis_ = nullptr; | 339 TypeHintAnalysis* type_hint_analysis_ = nullptr; |
| 325 SimplifiedOperatorBuilder* simplified_ = nullptr; | 340 SimplifiedOperatorBuilder* simplified_ = nullptr; |
| 326 MachineOperatorBuilder* machine_ = nullptr; | 341 MachineOperatorBuilder* machine_ = nullptr; |
| 327 CommonOperatorBuilder* common_ = nullptr; | 342 CommonOperatorBuilder* common_ = nullptr; |
| 328 JSOperatorBuilder* javascript_ = nullptr; | 343 JSOperatorBuilder* javascript_ = nullptr; |
| 329 JSGraph* jsgraph_ = nullptr; | 344 JSGraph* jsgraph_ = nullptr; |
| 330 Schedule* schedule_ = nullptr; | 345 Schedule* schedule_ = nullptr; |
| 331 | 346 |
| 332 // All objects in the following group of fields are allocated in | 347 // All objects in the following group of fields are allocated in |
| 333 // instruction_zone_. They are all set to nullptr when the instruction_zone_ | 348 // instruction_zone_. They are all set to nullptr when the instruction_zone_ |
| 334 // is | 349 // is destroyed. |
| 335 // destroyed. | |
| 336 ZonePool::Scope instruction_zone_scope_; | 350 ZonePool::Scope instruction_zone_scope_; |
| 337 Zone* instruction_zone_; | 351 Zone* instruction_zone_; |
| 338 InstructionSequence* sequence_ = nullptr; | 352 InstructionSequence* sequence_; |
| 339 Frame* frame_ = nullptr; | 353 Frame* frame_; |
| 354 | |
| 355 // The code generator uses the instruction_zone_. | |
| 356 CodeGenerator code_generator_; | |
|
Michael Starzinger
2016/08/11 14:16:26
nit: Can be move up to the other fields not living
ahaas
2016/08/11 14:54:19
Done.
| |
| 340 | 357 |
| 341 // All objects in the following group of fields are allocated in | 358 // 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 | 359 // register_allocation_zone_. They are all set to nullptr when the zone is |
| 343 // destroyed. | 360 // destroyed. |
| 344 ZonePool::Scope register_allocation_zone_scope_; | 361 ZonePool::Scope register_allocation_zone_scope_; |
| 345 Zone* register_allocation_zone_; | 362 Zone* register_allocation_zone_; |
| 346 RegisterAllocationData* register_allocation_data_ = nullptr; | 363 RegisterAllocationData* register_allocation_data_ = nullptr; |
| 347 | 364 |
| 348 // Basic block profiling support. | 365 // Basic block profiling support. |
| 349 BasicBlockProfiler::Data* profiler_data_ = nullptr; | 366 BasicBlockProfiler::Data* profiler_data_ = nullptr; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 376 template <typename Phase, typename Arg0, typename Arg1> | 393 template <typename Phase, typename Arg0, typename Arg1> |
| 377 void Run(Arg0 arg_0, Arg1 arg_1); | 394 void Run(Arg0 arg_0, Arg1 arg_1); |
| 378 | 395 |
| 379 // Run the graph creation and initial optimization passes. | 396 // Run the graph creation and initial optimization passes. |
| 380 bool CreateGraph(); | 397 bool CreateGraph(); |
| 381 | 398 |
| 382 // Run the concurrent optimization passes. | 399 // Run the concurrent optimization passes. |
| 383 bool OptimizeGraph(Linkage* linkage); | 400 bool OptimizeGraph(Linkage* linkage); |
| 384 | 401 |
| 385 // Perform the actual code generation and return handle to a code object. | 402 // Perform the actual code generation and return handle to a code object. |
| 386 Handle<Code> GenerateCode(Linkage* linkage); | 403 bool AssembleCode(Linkage* linkage); |
| 404 Handle<Code> FinishCodeObject(); | |
| 387 | 405 |
| 388 bool ScheduleAndSelectInstructions(Linkage* linkage); | 406 bool ScheduleAndSelectInstructions(Linkage* linkage); |
| 389 void RunPrintAndVerify(const char* phase, bool untyped = false); | 407 void RunPrintAndVerify(const char* phase, bool untyped = false); |
| 390 Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor); | 408 Handle<Code> ScheduleAndGenerateCode(CallDescriptor* call_descriptor); |
| 391 void AllocateRegisters(const RegisterConfiguration* config, | 409 void AllocateRegisters(const RegisterConfiguration* config, |
| 392 CallDescriptor* descriptor, bool run_verifier); | 410 CallDescriptor* descriptor, bool run_verifier); |
| 393 | 411 |
| 394 CompilationInfo* info() const; | 412 CompilationInfo* info() const; |
| 395 Isolate* isolate() const; | 413 Isolate* isolate() const; |
| 396 | 414 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 632 | 650 |
| 633 return SUCCEEDED; | 651 return SUCCEEDED; |
| 634 } | 652 } |
| 635 | 653 |
| 636 PipelineCompilationJob::Status PipelineCompilationJob::OptimizeGraphImpl() { | 654 PipelineCompilationJob::Status PipelineCompilationJob::OptimizeGraphImpl() { |
| 637 if (!pipeline_.OptimizeGraph(linkage_)) return FAILED; | 655 if (!pipeline_.OptimizeGraph(linkage_)) return FAILED; |
| 638 return SUCCEEDED; | 656 return SUCCEEDED; |
| 639 } | 657 } |
| 640 | 658 |
| 641 PipelineCompilationJob::Status PipelineCompilationJob::GenerateCodeImpl() { | 659 PipelineCompilationJob::Status PipelineCompilationJob::GenerateCodeImpl() { |
| 642 Handle<Code> code = pipeline_.GenerateCode(linkage_); | 660 if (!pipeline_.AssembleCode(linkage_)) { |
| 661 return FAILED; | |
|
Michael Starzinger
2016/08/11 14:16:26
Can we unconditionally run both, "AssembleCode" an
ahaas
2016/08/11 14:54:19
Done.
| |
| 662 } | |
| 663 Handle<Code> code = pipeline_.FinishCodeObject(); | |
| 643 if (code.is_null()) { | 664 if (code.is_null()) { |
| 644 if (info()->bailout_reason() == kNoReason) { | 665 if (info()->bailout_reason() == kNoReason) { |
| 645 return AbortOptimization(kCodeGenerationFailed); | 666 return AbortOptimization(kCodeGenerationFailed); |
| 646 } | 667 } |
| 647 return FAILED; | 668 return FAILED; |
| 648 } | 669 } |
| 649 info()->dependencies()->Commit(code); | 670 info()->dependencies()->Commit(code); |
| 650 info()->SetCode(code); | 671 info()->SetCode(code); |
| 651 if (info()->is_deoptimization_enabled()) { | 672 if (info()->is_deoptimization_enabled()) { |
| 652 info()->context()->native_context()->AddOptimizedCode(*code); | 673 info()->context()->native_context()->AddOptimizedCode(*code); |
| 653 RegisterWeakObjectsInOptimizedCode(code); | 674 RegisterWeakObjectsInOptimizedCode(code); |
| 654 } | 675 } |
| 655 return SUCCEEDED; | 676 return SUCCEEDED; |
| 656 } | 677 } |
| 657 | 678 |
| 658 class PipelineWasmCompilationJob final : public CompilationJob { | 679 class PipelineWasmCompilationJob final : public CompilationJob { |
| 659 public: | 680 public: |
| 660 explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph, | 681 explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph, |
| 661 CallDescriptor* descriptor, | 682 CallDescriptor* descriptor, |
| 662 SourcePositionTable* source_positions) | 683 SourcePositionTable* source_positions) |
| 663 : CompilationJob(info, "TurboFan"), | 684 : CompilationJob(info, "TurboFan"), |
| 664 zone_pool_(info->isolate()->allocator()), | 685 zone_pool_(info->isolate()->allocator()), |
| 665 data_(&zone_pool_, info, graph, source_positions), | 686 data_(&zone_pool_, info, graph, source_positions), |
| 666 pipeline_(&data_), | 687 pipeline_(&data_), |
| 667 linkage_(descriptor) {} | 688 descriptor_(descriptor) {} |
| 668 | 689 |
| 669 protected: | 690 protected: |
| 670 Status CreateGraphImpl() final; | 691 Status CreateGraphImpl() final; |
| 671 Status OptimizeGraphImpl() final; | 692 Status OptimizeGraphImpl() final; |
| 672 Status GenerateCodeImpl() final; | 693 Status GenerateCodeImpl() final; |
| 673 | 694 |
| 674 private: | 695 private: |
| 675 ZonePool zone_pool_; | 696 ZonePool zone_pool_; |
| 676 PipelineData data_; | 697 PipelineData data_; |
| 677 PipelineImpl pipeline_; | 698 PipelineImpl pipeline_; |
| 678 Linkage linkage_; | 699 CallDescriptor* descriptor_; |
| 679 }; | 700 }; |
| 680 | 701 |
| 681 PipelineWasmCompilationJob::Status | 702 PipelineWasmCompilationJob::Status |
| 682 PipelineWasmCompilationJob::CreateGraphImpl() { | 703 PipelineWasmCompilationJob::CreateGraphImpl() { |
| 683 return SUCCEEDED; | 704 return SUCCEEDED; |
| 684 } | 705 } |
| 685 | 706 |
| 686 PipelineWasmCompilationJob::Status | 707 PipelineWasmCompilationJob::Status |
| 687 PipelineWasmCompilationJob::OptimizeGraphImpl() { | 708 PipelineWasmCompilationJob::OptimizeGraphImpl() { |
| 688 if (FLAG_trace_turbo) { | 709 if (FLAG_trace_turbo) { |
| 689 TurboJsonFile json_of(info(), std::ios_base::trunc); | 710 TurboJsonFile json_of(info(), std::ios_base::trunc); |
| 690 json_of << "{\"function\":\"" << info()->GetDebugName().get() | 711 json_of << "{\"function\":\"" << info()->GetDebugName().get() |
| 691 << "\", \"source\":\"\",\n\"phases\":["; | 712 << "\", \"source\":\"\",\n\"phases\":["; |
| 692 } | 713 } |
| 693 | 714 |
| 694 pipeline_.RunPrintAndVerify("Machine", true); | 715 pipeline_.RunPrintAndVerify("Machine", true); |
| 695 | 716 |
| 696 if (!pipeline_.ScheduleAndSelectInstructions(&linkage_)) return FAILED; | 717 Linkage linkage(descriptor_); |
| 718 if (!pipeline_.ScheduleAndSelectInstructions(&linkage)) return FAILED; | |
| 719 if (!pipeline_.AssembleCode(&linkage)) return FAILED; | |
| 697 return SUCCEEDED; | 720 return SUCCEEDED; |
| 698 } | 721 } |
| 699 | 722 |
| 700 PipelineWasmCompilationJob::Status | 723 PipelineWasmCompilationJob::Status |
| 701 PipelineWasmCompilationJob::GenerateCodeImpl() { | 724 PipelineWasmCompilationJob::GenerateCodeImpl() { |
| 702 pipeline_.GenerateCode(&linkage_); | 725 pipeline_.FinishCodeObject(); |
| 703 return SUCCEEDED; | 726 return SUCCEEDED; |
| 704 } | 727 } |
| 705 | 728 |
| 706 template <typename Phase> | 729 template <typename Phase> |
| 707 void PipelineImpl::Run() { | 730 void PipelineImpl::Run() { |
| 708 PipelineRunScope scope(this->data_, Phase::phase_name()); | 731 PipelineRunScope scope(this->data_, Phase::phase_name()); |
| 709 Phase phase; | 732 Phase phase; |
| 710 phase.Run(this->data_, scope.zone()); | 733 phase.Run(this->data_, scope.zone()); |
| 711 } | 734 } |
| 712 | 735 |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 | 1408 |
| 1386 void Run(PipelineData* data, Zone* temp_zone, bool frame_at_start) { | 1409 void Run(PipelineData* data, Zone* temp_zone, bool frame_at_start) { |
| 1387 ZoneVector<RpoNumber> result(temp_zone); | 1410 ZoneVector<RpoNumber> result(temp_zone); |
| 1388 if (JumpThreading::ComputeForwarding(temp_zone, result, data->sequence(), | 1411 if (JumpThreading::ComputeForwarding(temp_zone, result, data->sequence(), |
| 1389 frame_at_start)) { | 1412 frame_at_start)) { |
| 1390 JumpThreading::ApplyForwarding(result, data->sequence()); | 1413 JumpThreading::ApplyForwarding(result, data->sequence()); |
| 1391 } | 1414 } |
| 1392 } | 1415 } |
| 1393 }; | 1416 }; |
| 1394 | 1417 |
| 1395 | 1418 struct AssembleCodePhase { |
| 1396 struct GenerateCodePhase { | |
| 1397 static const char* phase_name() { return "generate code"; } | 1419 static const char* phase_name() { return "generate code"; } |
| 1398 | 1420 |
| 1399 void Run(PipelineData* data, Zone* temp_zone, Linkage* linkage) { | 1421 void Run(PipelineData* data, Zone* temp_zone, Linkage* linkage) { |
| 1400 CodeGenerator generator(data->frame(), linkage, data->sequence(), | 1422 data->code_generator()->Initialize(data->frame(), linkage, |
| 1401 data->info()); | 1423 data->sequence()); |
| 1402 data->set_code(generator.GenerateCode()); | 1424 data->code_generator()->AssembleCode(); |
| 1403 } | 1425 } |
| 1404 }; | 1426 }; |
| 1405 | 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 }; | |
| 1406 | 1435 |
| 1407 struct PrintGraphPhase { | 1436 struct PrintGraphPhase { |
| 1408 static const char* phase_name() { return nullptr; } | 1437 static const char* phase_name() { return nullptr; } |
| 1409 | 1438 |
| 1410 void Run(PipelineData* data, Zone* temp_zone, const char* phase) { | 1439 void Run(PipelineData* data, Zone* temp_zone, const char* phase) { |
| 1411 CompilationInfo* info = data->info(); | 1440 CompilationInfo* info = data->info(); |
| 1412 Graph* graph = data->graph(); | 1441 Graph* graph = data->graph(); |
| 1413 | 1442 |
| 1414 { // Print JSON. | 1443 { // Print JSON. |
| 1415 AllowHandleDereference allow_deref; | 1444 AllowHandleDereference allow_deref; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1648 ZonePool zone_pool(info->isolate()->allocator()); | 1677 ZonePool zone_pool(info->isolate()->allocator()); |
| 1649 std::unique_ptr<PipelineStatistics> pipeline_statistics( | 1678 std::unique_ptr<PipelineStatistics> pipeline_statistics( |
| 1650 CreatePipelineStatistics(info, &zone_pool)); | 1679 CreatePipelineStatistics(info, &zone_pool)); |
| 1651 PipelineData data(&zone_pool, info, pipeline_statistics.get()); | 1680 PipelineData data(&zone_pool, info, pipeline_statistics.get()); |
| 1652 PipelineImpl pipeline(&data); | 1681 PipelineImpl pipeline(&data); |
| 1653 | 1682 |
| 1654 Linkage linkage(Linkage::ComputeIncoming(data.instruction_zone(), info)); | 1683 Linkage linkage(Linkage::ComputeIncoming(data.instruction_zone(), info)); |
| 1655 | 1684 |
| 1656 if (!pipeline.CreateGraph()) return Handle<Code>::null(); | 1685 if (!pipeline.CreateGraph()) return Handle<Code>::null(); |
| 1657 if (!pipeline.OptimizeGraph(&linkage)) return Handle<Code>::null(); | 1686 if (!pipeline.OptimizeGraph(&linkage)) return Handle<Code>::null(); |
| 1658 return pipeline.GenerateCode(&linkage); | 1687 pipeline.AssembleCode(&linkage); |
| 1688 return pipeline.FinishCodeObject(); | |
| 1659 } | 1689 } |
| 1660 | 1690 |
| 1661 // static | 1691 // static |
| 1662 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, | 1692 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, |
| 1663 Graph* graph, | 1693 Graph* graph, |
| 1664 Schedule* schedule) { | 1694 Schedule* schedule) { |
| 1665 CallDescriptor* call_descriptor = | 1695 CallDescriptor* call_descriptor = |
| 1666 Linkage::ComputeIncoming(info->zone(), info); | 1696 Linkage::ComputeIncoming(info->zone(), info); |
| 1667 return GenerateCodeForTesting(info, call_descriptor, graph, schedule); | 1697 return GenerateCodeForTesting(info, call_descriptor, graph, schedule); |
| 1668 } | 1698 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1776 // Optimimize jumps. | 1806 // Optimimize jumps. |
| 1777 if (FLAG_turbo_jt) { | 1807 if (FLAG_turbo_jt) { |
| 1778 Run<JumpThreadingPhase>(generate_frame_at_start); | 1808 Run<JumpThreadingPhase>(generate_frame_at_start); |
| 1779 } | 1809 } |
| 1780 | 1810 |
| 1781 data->EndPhaseKind(); | 1811 data->EndPhaseKind(); |
| 1782 | 1812 |
| 1783 return true; | 1813 return true; |
| 1784 } | 1814 } |
| 1785 | 1815 |
| 1786 Handle<Code> PipelineImpl::GenerateCode(Linkage* linkage) { | 1816 bool PipelineImpl::AssembleCode(Linkage* linkage) { |
| 1787 PipelineData* data = this->data_; | 1817 PipelineData* data = this->data_; |
| 1788 | 1818 |
| 1789 data->BeginPhaseKind("code generation"); | 1819 data->BeginPhaseKind("assemble code"); |
| 1790 | 1820 |
| 1791 // Generate final machine code. | 1821 // Assemble machine code. |
| 1792 Run<GenerateCodePhase>(linkage); | 1822 Run<AssembleCodePhase>(linkage); |
| 1823 return data->assemble_code_successful(); | |
| 1824 } | |
| 1825 Handle<Code> PipelineImpl::FinishCodeObject() { | |
|
Michael Starzinger
2016/08/11 14:16:26
nit: Empty newline between functions.
ahaas
2016/08/11 14:54:19
Done.
| |
| 1826 PipelineData* data = this->data_; | |
| 1827 | |
| 1828 data->BeginPhaseKind("finish code generation"); | |
| 1829 | |
| 1830 // Generate final code object. | |
| 1831 Run<FinishCodeObjectPhase>(); | |
| 1793 | 1832 |
| 1794 Handle<Code> code = data->code(); | 1833 Handle<Code> code = data->code(); |
| 1795 if (data->profiler_data()) { | 1834 if (data->profiler_data()) { |
| 1796 #if ENABLE_DISASSEMBLER | 1835 #if ENABLE_DISASSEMBLER |
| 1797 std::ostringstream os; | 1836 std::ostringstream os; |
| 1798 code->Disassemble(nullptr, os); | 1837 code->Disassemble(nullptr, os); |
| 1799 data->profiler_data()->SetCode(&os); | 1838 data->profiler_data()->SetCode(&os); |
| 1800 #endif | 1839 #endif |
| 1801 } | 1840 } |
| 1802 | 1841 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1829 } | 1868 } |
| 1830 | 1869 |
| 1831 Handle<Code> PipelineImpl::ScheduleAndGenerateCode( | 1870 Handle<Code> PipelineImpl::ScheduleAndGenerateCode( |
| 1832 CallDescriptor* call_descriptor) { | 1871 CallDescriptor* call_descriptor) { |
| 1833 Linkage linkage(call_descriptor); | 1872 Linkage linkage(call_descriptor); |
| 1834 | 1873 |
| 1835 // Schedule the graph, perform instruction selection and register allocation. | 1874 // Schedule the graph, perform instruction selection and register allocation. |
| 1836 if (!ScheduleAndSelectInstructions(&linkage)) return Handle<Code>(); | 1875 if (!ScheduleAndSelectInstructions(&linkage)) return Handle<Code>(); |
| 1837 | 1876 |
| 1838 // Generate the final machine code. | 1877 // Generate the final machine code. |
| 1839 return GenerateCode(&linkage); | 1878 AssembleCode(&linkage); |
| 1879 return FinishCodeObject(); | |
| 1840 } | 1880 } |
| 1841 | 1881 |
| 1842 void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config, | 1882 void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config, |
| 1843 CallDescriptor* descriptor, | 1883 CallDescriptor* descriptor, |
| 1844 bool run_verifier) { | 1884 bool run_verifier) { |
| 1845 PipelineData* data = this->data_; | 1885 PipelineData* data = this->data_; |
| 1846 // Don't track usage for this zone in compiler stats. | 1886 // Don't track usage for this zone in compiler stats. |
| 1847 std::unique_ptr<Zone> verifier_zone; | 1887 std::unique_ptr<Zone> verifier_zone; |
| 1848 RegisterAllocatorVerifier* verifier = nullptr; | 1888 RegisterAllocatorVerifier* verifier = nullptr; |
| 1849 if (run_verifier) { | 1889 if (run_verifier) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1924 data->DeleteRegisterAllocationZone(); | 1964 data->DeleteRegisterAllocationZone(); |
| 1925 } | 1965 } |
| 1926 | 1966 |
| 1927 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1967 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
| 1928 | 1968 |
| 1929 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1969 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
| 1930 | 1970 |
| 1931 } // namespace compiler | 1971 } // namespace compiler |
| 1932 } // namespace internal | 1972 } // namespace internal |
| 1933 } // namespace v8 | 1973 } // namespace v8 |
| OLD | NEW |