| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 #include "src/compiler/simplified-lowering.h" | 62 #include "src/compiler/simplified-lowering.h" |
| 63 #include "src/compiler/simplified-operator-reducer.h" | 63 #include "src/compiler/simplified-operator-reducer.h" |
| 64 #include "src/compiler/simplified-operator.h" | 64 #include "src/compiler/simplified-operator.h" |
| 65 #include "src/compiler/store-store-elimination.h" | 65 #include "src/compiler/store-store-elimination.h" |
| 66 #include "src/compiler/tail-call-optimization.h" | 66 #include "src/compiler/tail-call-optimization.h" |
| 67 #include "src/compiler/type-hint-analyzer.h" | 67 #include "src/compiler/type-hint-analyzer.h" |
| 68 #include "src/compiler/typed-optimization.h" | 68 #include "src/compiler/typed-optimization.h" |
| 69 #include "src/compiler/typer.h" | 69 #include "src/compiler/typer.h" |
| 70 #include "src/compiler/value-numbering-reducer.h" | 70 #include "src/compiler/value-numbering-reducer.h" |
| 71 #include "src/compiler/verifier.h" | 71 #include "src/compiler/verifier.h" |
| 72 #include "src/compiler/zone-stats.h" | 72 #include "src/compiler/zone-pool.h" |
| 73 #include "src/isolate-inl.h" | 73 #include "src/isolate-inl.h" |
| 74 #include "src/ostreams.h" | 74 #include "src/ostreams.h" |
| 75 #include "src/parsing/parse-info.h" | 75 #include "src/parsing/parse-info.h" |
| 76 #include "src/register-configuration.h" | 76 #include "src/register-configuration.h" |
| 77 #include "src/type-info.h" | 77 #include "src/type-info.h" |
| 78 #include "src/utils.h" | 78 #include "src/utils.h" |
| 79 | 79 |
| 80 namespace v8 { | 80 namespace v8 { |
| 81 namespace internal { | 81 namespace internal { |
| 82 namespace compiler { | 82 namespace compiler { |
| 83 | 83 |
| 84 class PipelineData { | 84 class PipelineData { |
| 85 public: | 85 public: |
| 86 // For main entry point. | 86 // For main entry point. |
| 87 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, | 87 PipelineData(ZonePool* zone_pool, CompilationInfo* info, |
| 88 PipelineStatistics* pipeline_statistics) | 88 PipelineStatistics* pipeline_statistics) |
| 89 : isolate_(info->isolate()), | 89 : isolate_(info->isolate()), |
| 90 info_(info), | 90 info_(info), |
| 91 debug_name_(info_->GetDebugName()), | 91 debug_name_(info_->GetDebugName()), |
| 92 outer_zone_(info_->zone()), | 92 outer_zone_(info_->zone()), |
| 93 zone_stats_(zone_stats), | 93 zone_pool_(zone_pool), |
| 94 pipeline_statistics_(pipeline_statistics), | 94 pipeline_statistics_(pipeline_statistics), |
| 95 graph_zone_scope_(zone_stats_), | 95 graph_zone_scope_(zone_pool_), |
| 96 graph_zone_(graph_zone_scope_.zone()), | 96 graph_zone_(graph_zone_scope_.zone()), |
| 97 instruction_zone_scope_(zone_stats_), | 97 instruction_zone_scope_(zone_pool_), |
| 98 instruction_zone_(instruction_zone_scope_.zone()), | 98 instruction_zone_(instruction_zone_scope_.zone()), |
| 99 register_allocation_zone_scope_(zone_stats_), | 99 register_allocation_zone_scope_(zone_pool_), |
| 100 register_allocation_zone_(register_allocation_zone_scope_.zone()) { | 100 register_allocation_zone_(register_allocation_zone_scope_.zone()) { |
| 101 PhaseScope scope(pipeline_statistics, "init pipeline data"); | 101 PhaseScope scope(pipeline_statistics, "init pipeline data"); |
| 102 graph_ = new (graph_zone_) Graph(graph_zone_); | 102 graph_ = new (graph_zone_) Graph(graph_zone_); |
| 103 source_positions_ = new (graph_zone_) SourcePositionTable(graph_); | 103 source_positions_ = new (graph_zone_) SourcePositionTable(graph_); |
| 104 simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_); | 104 simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_); |
| 105 machine_ = new (graph_zone_) MachineOperatorBuilder( | 105 machine_ = new (graph_zone_) MachineOperatorBuilder( |
| 106 graph_zone_, MachineType::PointerRepresentation(), | 106 graph_zone_, MachineType::PointerRepresentation(), |
| 107 InstructionSelector::SupportedMachineOperatorFlags(), | 107 InstructionSelector::SupportedMachineOperatorFlags(), |
| 108 InstructionSelector::AlignmentRequirements()); | 108 InstructionSelector::AlignmentRequirements()); |
| 109 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); | 109 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); |
| 110 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); | 110 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); |
| 111 jsgraph_ = new (graph_zone_) | 111 jsgraph_ = new (graph_zone_) |
| 112 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); | 112 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // For WASM compile entry point. | 115 // For WASM compile entry point. |
| 116 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, | 116 PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph, |
| 117 SourcePositionTable* source_positions) | 117 SourcePositionTable* source_positions) |
| 118 : isolate_(info->isolate()), | 118 : isolate_(info->isolate()), |
| 119 info_(info), | 119 info_(info), |
| 120 debug_name_(info_->GetDebugName()), | 120 debug_name_(info_->GetDebugName()), |
| 121 zone_stats_(zone_stats), | 121 zone_pool_(zone_pool), |
| 122 graph_zone_scope_(zone_stats_), | 122 graph_zone_scope_(zone_pool_), |
| 123 graph_(graph), | 123 graph_(graph), |
| 124 source_positions_(source_positions), | 124 source_positions_(source_positions), |
| 125 instruction_zone_scope_(zone_stats_), | 125 instruction_zone_scope_(zone_pool_), |
| 126 instruction_zone_(instruction_zone_scope_.zone()), | 126 instruction_zone_(instruction_zone_scope_.zone()), |
| 127 register_allocation_zone_scope_(zone_stats_), | 127 register_allocation_zone_scope_(zone_pool_), |
| 128 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} | 128 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} |
| 129 | 129 |
| 130 // For machine graph testing entry point. | 130 // For machine graph testing entry point. |
| 131 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, | 131 PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph, |
| 132 Schedule* schedule) | 132 Schedule* schedule) |
| 133 : isolate_(info->isolate()), | 133 : isolate_(info->isolate()), |
| 134 info_(info), | 134 info_(info), |
| 135 debug_name_(info_->GetDebugName()), | 135 debug_name_(info_->GetDebugName()), |
| 136 zone_stats_(zone_stats), | 136 zone_pool_(zone_pool), |
| 137 graph_zone_scope_(zone_stats_), | 137 graph_zone_scope_(zone_pool_), |
| 138 graph_(graph), | 138 graph_(graph), |
| 139 source_positions_(new (info->zone()) SourcePositionTable(graph_)), | 139 source_positions_(new (info->zone()) SourcePositionTable(graph_)), |
| 140 schedule_(schedule), | 140 schedule_(schedule), |
| 141 instruction_zone_scope_(zone_stats_), | 141 instruction_zone_scope_(zone_pool_), |
| 142 instruction_zone_(instruction_zone_scope_.zone()), | 142 instruction_zone_(instruction_zone_scope_.zone()), |
| 143 register_allocation_zone_scope_(zone_stats_), | 143 register_allocation_zone_scope_(zone_pool_), |
| 144 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} | 144 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} |
| 145 | 145 |
| 146 // For register allocation testing entry point. | 146 // For register allocation testing entry point. |
| 147 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, | 147 PipelineData(ZonePool* zone_pool, CompilationInfo* info, |
| 148 InstructionSequence* sequence) | 148 InstructionSequence* sequence) |
| 149 : isolate_(info->isolate()), | 149 : isolate_(info->isolate()), |
| 150 info_(info), | 150 info_(info), |
| 151 debug_name_(info_->GetDebugName()), | 151 debug_name_(info_->GetDebugName()), |
| 152 zone_stats_(zone_stats), | 152 zone_pool_(zone_pool), |
| 153 graph_zone_scope_(zone_stats_), | 153 graph_zone_scope_(zone_pool_), |
| 154 instruction_zone_scope_(zone_stats_), | 154 instruction_zone_scope_(zone_pool_), |
| 155 instruction_zone_(sequence->zone()), | 155 instruction_zone_(sequence->zone()), |
| 156 sequence_(sequence), | 156 sequence_(sequence), |
| 157 register_allocation_zone_scope_(zone_stats_), | 157 register_allocation_zone_scope_(zone_pool_), |
| 158 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} | 158 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} |
| 159 | 159 |
| 160 ~PipelineData() { | 160 ~PipelineData() { |
| 161 DeleteRegisterAllocationZone(); | 161 DeleteRegisterAllocationZone(); |
| 162 DeleteInstructionZone(); | 162 DeleteInstructionZone(); |
| 163 DeleteGraphZone(); | 163 DeleteGraphZone(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 Isolate* isolate() const { return isolate_; } | 166 Isolate* isolate() const { return isolate_; } |
| 167 CompilationInfo* info() const { return info_; } | 167 CompilationInfo* info() const { return info_; } |
| 168 ZoneStats* zone_stats() const { return zone_stats_; } | 168 ZonePool* zone_pool() const { return zone_pool_; } |
| 169 PipelineStatistics* pipeline_statistics() { return pipeline_statistics_; } | 169 PipelineStatistics* pipeline_statistics() { return pipeline_statistics_; } |
| 170 bool compilation_failed() const { return compilation_failed_; } | 170 bool compilation_failed() const { return compilation_failed_; } |
| 171 void set_compilation_failed() { compilation_failed_ = true; } | 171 void set_compilation_failed() { compilation_failed_ = true; } |
| 172 Handle<Code> code() { return code_; } | 172 Handle<Code> code() { return code_; } |
| 173 void set_code(Handle<Code> code) { | 173 void set_code(Handle<Code> code) { |
| 174 DCHECK(code_.is_null()); | 174 DCHECK(code_.is_null()); |
| 175 code_ = code; | 175 code_ = code; |
| 176 } | 176 } |
| 177 | 177 |
| 178 // RawMachineAssembler generally produces graphs which cannot be verified. | 178 // RawMachineAssembler generally produces graphs which cannot be verified. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 if (pipeline_statistics() != nullptr) { | 305 if (pipeline_statistics() != nullptr) { |
| 306 pipeline_statistics()->EndPhaseKind(); | 306 pipeline_statistics()->EndPhaseKind(); |
| 307 } | 307 } |
| 308 } | 308 } |
| 309 | 309 |
| 310 private: | 310 private: |
| 311 Isolate* const isolate_; | 311 Isolate* const isolate_; |
| 312 CompilationInfo* const info_; | 312 CompilationInfo* const info_; |
| 313 std::unique_ptr<char[]> debug_name_; | 313 std::unique_ptr<char[]> debug_name_; |
| 314 Zone* outer_zone_ = nullptr; | 314 Zone* outer_zone_ = nullptr; |
| 315 ZoneStats* const zone_stats_; | 315 ZonePool* const zone_pool_; |
| 316 PipelineStatistics* pipeline_statistics_ = nullptr; | 316 PipelineStatistics* pipeline_statistics_ = nullptr; |
| 317 bool compilation_failed_ = false; | 317 bool compilation_failed_ = false; |
| 318 Handle<Code> code_ = Handle<Code>::null(); | 318 Handle<Code> code_ = Handle<Code>::null(); |
| 319 | 319 |
| 320 // All objects in the following group of fields are allocated in graph_zone_. | 320 // All objects in the following group of fields are allocated in graph_zone_. |
| 321 // They are all set to nullptr when the graph_zone_ is destroyed. | 321 // They are all set to nullptr when the graph_zone_ is destroyed. |
| 322 ZoneStats::Scope graph_zone_scope_; | 322 ZonePool::Scope graph_zone_scope_; |
| 323 Zone* graph_zone_ = nullptr; | 323 Zone* graph_zone_ = nullptr; |
| 324 Graph* graph_ = nullptr; | 324 Graph* graph_ = nullptr; |
| 325 SourcePositionTable* source_positions_ = nullptr; | 325 SourcePositionTable* source_positions_ = nullptr; |
| 326 LoopAssignmentAnalysis* loop_assignment_ = nullptr; | 326 LoopAssignmentAnalysis* loop_assignment_ = nullptr; |
| 327 TypeHintAnalysis* type_hint_analysis_ = nullptr; | 327 TypeHintAnalysis* type_hint_analysis_ = nullptr; |
| 328 SimplifiedOperatorBuilder* simplified_ = nullptr; | 328 SimplifiedOperatorBuilder* simplified_ = nullptr; |
| 329 MachineOperatorBuilder* machine_ = nullptr; | 329 MachineOperatorBuilder* machine_ = nullptr; |
| 330 CommonOperatorBuilder* common_ = nullptr; | 330 CommonOperatorBuilder* common_ = nullptr; |
| 331 JSOperatorBuilder* javascript_ = nullptr; | 331 JSOperatorBuilder* javascript_ = nullptr; |
| 332 JSGraph* jsgraph_ = nullptr; | 332 JSGraph* jsgraph_ = nullptr; |
| 333 Schedule* schedule_ = nullptr; | 333 Schedule* schedule_ = nullptr; |
| 334 | 334 |
| 335 // All objects in the following group of fields are allocated in | 335 // All objects in the following group of fields are allocated in |
| 336 // instruction_zone_. They are all set to nullptr when the instruction_zone_ | 336 // instruction_zone_. They are all set to nullptr when the instruction_zone_ |
| 337 // is | 337 // is |
| 338 // destroyed. | 338 // destroyed. |
| 339 ZoneStats::Scope instruction_zone_scope_; | 339 ZonePool::Scope instruction_zone_scope_; |
| 340 Zone* instruction_zone_; | 340 Zone* instruction_zone_; |
| 341 InstructionSequence* sequence_ = nullptr; | 341 InstructionSequence* sequence_ = nullptr; |
| 342 Frame* frame_ = nullptr; | 342 Frame* frame_ = nullptr; |
| 343 | 343 |
| 344 // All objects in the following group of fields are allocated in | 344 // All objects in the following group of fields are allocated in |
| 345 // register_allocation_zone_. They are all set to nullptr when the zone is | 345 // register_allocation_zone_. They are all set to nullptr when the zone is |
| 346 // destroyed. | 346 // destroyed. |
| 347 ZoneStats::Scope register_allocation_zone_scope_; | 347 ZonePool::Scope register_allocation_zone_scope_; |
| 348 Zone* register_allocation_zone_; | 348 Zone* register_allocation_zone_; |
| 349 RegisterAllocationData* register_allocation_data_ = nullptr; | 349 RegisterAllocationData* register_allocation_data_ = nullptr; |
| 350 | 350 |
| 351 // Basic block profiling support. | 351 // Basic block profiling support. |
| 352 BasicBlockProfiler::Data* profiler_data_ = nullptr; | 352 BasicBlockProfiler::Data* profiler_data_ = nullptr; |
| 353 | 353 |
| 354 // Source position output for --trace-turbo. | 354 // Source position output for --trace-turbo. |
| 355 std::string source_position_output_; | 355 std::string source_position_output_; |
| 356 | 356 |
| 357 int CalculateFixedFrameSize(CallDescriptor* descriptor) { | 357 int CalculateFixedFrameSize(CallDescriptor* descriptor) { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 } | 510 } |
| 511 } | 511 } |
| 512 | 512 |
| 513 | 513 |
| 514 class PipelineRunScope { | 514 class PipelineRunScope { |
| 515 public: | 515 public: |
| 516 PipelineRunScope(PipelineData* data, const char* phase_name) | 516 PipelineRunScope(PipelineData* data, const char* phase_name) |
| 517 : phase_scope_( | 517 : phase_scope_( |
| 518 phase_name == nullptr ? nullptr : data->pipeline_statistics(), | 518 phase_name == nullptr ? nullptr : data->pipeline_statistics(), |
| 519 phase_name), | 519 phase_name), |
| 520 zone_scope_(data->zone_stats()) {} | 520 zone_scope_(data->zone_pool()) {} |
| 521 | 521 |
| 522 Zone* zone() { return zone_scope_.zone(); } | 522 Zone* zone() { return zone_scope_.zone(); } |
| 523 | 523 |
| 524 private: | 524 private: |
| 525 PhaseScope phase_scope_; | 525 PhaseScope phase_scope_; |
| 526 ZoneStats::Scope zone_scope_; | 526 ZonePool::Scope zone_scope_; |
| 527 }; | 527 }; |
| 528 | 528 |
| 529 PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info, | 529 PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info, |
| 530 ZoneStats* zone_stats) { | 530 ZonePool* zone_pool) { |
| 531 PipelineStatistics* pipeline_statistics = nullptr; | 531 PipelineStatistics* pipeline_statistics = nullptr; |
| 532 | 532 |
| 533 if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { | 533 if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { |
| 534 pipeline_statistics = new PipelineStatistics(info, zone_stats); | 534 pipeline_statistics = new PipelineStatistics(info, zone_pool); |
| 535 pipeline_statistics->BeginPhaseKind("initializing"); | 535 pipeline_statistics->BeginPhaseKind("initializing"); |
| 536 } | 536 } |
| 537 | 537 |
| 538 if (FLAG_trace_turbo) { | 538 if (FLAG_trace_turbo) { |
| 539 TurboJsonFile json_of(info, std::ios_base::trunc); | 539 TurboJsonFile json_of(info, std::ios_base::trunc); |
| 540 Handle<Script> script = info->script(); | 540 Handle<Script> script = info->script(); |
| 541 std::unique_ptr<char[]> function_name = info->GetDebugName(); | 541 std::unique_ptr<char[]> function_name = info->GetDebugName(); |
| 542 int pos = info->shared_info()->start_position(); | 542 int pos = info->shared_info()->start_position(); |
| 543 json_of << "{\"function\":\"" << function_name.get() | 543 json_of << "{\"function\":\"" << function_name.get() |
| 544 << "\", \"sourcePosition\":" << pos << ", \"source\":\""; | 544 << "\", \"sourcePosition\":" << pos << ", \"source\":\""; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 561 | 561 |
| 562 } // namespace | 562 } // namespace |
| 563 | 563 |
| 564 class PipelineCompilationJob final : public CompilationJob { | 564 class PipelineCompilationJob final : public CompilationJob { |
| 565 public: | 565 public: |
| 566 PipelineCompilationJob(Isolate* isolate, Handle<JSFunction> function) | 566 PipelineCompilationJob(Isolate* isolate, Handle<JSFunction> function) |
| 567 // Note that the CompilationInfo is not initialized at the time we pass it | 567 // Note that the CompilationInfo is not initialized at the time we pass it |
| 568 // to the CompilationJob constructor, but it is not dereferenced there. | 568 // to the CompilationJob constructor, but it is not dereferenced there. |
| 569 : CompilationJob(isolate, &info_, "TurboFan"), | 569 : CompilationJob(isolate, &info_, "TurboFan"), |
| 570 zone_(isolate->allocator()), | 570 zone_(isolate->allocator()), |
| 571 zone_stats_(isolate->allocator()), | 571 zone_pool_(isolate->allocator()), |
| 572 parse_info_(&zone_, function), | 572 parse_info_(&zone_, function), |
| 573 info_(&parse_info_, function), | 573 info_(&parse_info_, function), |
| 574 pipeline_statistics_(CreatePipelineStatistics(info(), &zone_stats_)), | 574 pipeline_statistics_(CreatePipelineStatistics(info(), &zone_pool_)), |
| 575 data_(&zone_stats_, info(), pipeline_statistics_.get()), | 575 data_(&zone_pool_, info(), pipeline_statistics_.get()), |
| 576 pipeline_(&data_), | 576 pipeline_(&data_), |
| 577 linkage_(nullptr) {} | 577 linkage_(nullptr) {} |
| 578 | 578 |
| 579 protected: | 579 protected: |
| 580 Status PrepareJobImpl() final; | 580 Status PrepareJobImpl() final; |
| 581 Status ExecuteJobImpl() final; | 581 Status ExecuteJobImpl() final; |
| 582 Status FinalizeJobImpl() final; | 582 Status FinalizeJobImpl() final; |
| 583 | 583 |
| 584 private: | 584 private: |
| 585 Zone zone_; | 585 Zone zone_; |
| 586 ZoneStats zone_stats_; | 586 ZonePool zone_pool_; |
| 587 ParseInfo parse_info_; | 587 ParseInfo parse_info_; |
| 588 CompilationInfo info_; | 588 CompilationInfo info_; |
| 589 std::unique_ptr<PipelineStatistics> pipeline_statistics_; | 589 std::unique_ptr<PipelineStatistics> pipeline_statistics_; |
| 590 PipelineData data_; | 590 PipelineData data_; |
| 591 PipelineImpl pipeline_; | 591 PipelineImpl pipeline_; |
| 592 Linkage* linkage_; | 592 Linkage* linkage_; |
| 593 | 593 |
| 594 DISALLOW_COPY_AND_ASSIGN(PipelineCompilationJob); | 594 DISALLOW_COPY_AND_ASSIGN(PipelineCompilationJob); |
| 595 }; | 595 }; |
| 596 | 596 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 return SUCCEEDED; | 662 return SUCCEEDED; |
| 663 } | 663 } |
| 664 | 664 |
| 665 class PipelineWasmCompilationJob final : public CompilationJob { | 665 class PipelineWasmCompilationJob final : public CompilationJob { |
| 666 public: | 666 public: |
| 667 explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph, | 667 explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph, |
| 668 CallDescriptor* descriptor, | 668 CallDescriptor* descriptor, |
| 669 SourcePositionTable* source_positions) | 669 SourcePositionTable* source_positions) |
| 670 : CompilationJob(info->isolate(), info, "TurboFan", | 670 : CompilationJob(info->isolate(), info, "TurboFan", |
| 671 State::kReadyToExecute), | 671 State::kReadyToExecute), |
| 672 zone_stats_(info->isolate()->allocator()), | 672 zone_pool_(info->isolate()->allocator()), |
| 673 data_(&zone_stats_, info, graph, source_positions), | 673 data_(&zone_pool_, info, graph, source_positions), |
| 674 pipeline_(&data_), | 674 pipeline_(&data_), |
| 675 linkage_(descriptor) {} | 675 linkage_(descriptor) {} |
| 676 | 676 |
| 677 protected: | 677 protected: |
| 678 Status PrepareJobImpl() final; | 678 Status PrepareJobImpl() final; |
| 679 Status ExecuteJobImpl() final; | 679 Status ExecuteJobImpl() final; |
| 680 Status FinalizeJobImpl() final; | 680 Status FinalizeJobImpl() final; |
| 681 | 681 |
| 682 private: | 682 private: |
| 683 ZoneStats zone_stats_; | 683 ZonePool zone_pool_; |
| 684 PipelineData data_; | 684 PipelineData data_; |
| 685 PipelineImpl pipeline_; | 685 PipelineImpl pipeline_; |
| 686 Linkage linkage_; | 686 Linkage linkage_; |
| 687 }; | 687 }; |
| 688 | 688 |
| 689 PipelineWasmCompilationJob::Status | 689 PipelineWasmCompilationJob::Status |
| 690 PipelineWasmCompilationJob::PrepareJobImpl() { | 690 PipelineWasmCompilationJob::PrepareJobImpl() { |
| 691 UNREACHABLE(); // Prepare should always be skipped for WasmCompilationJob. | 691 UNREACHABLE(); // Prepare should always be skipped for WasmCompilationJob. |
| 692 return SUCCEEDED; | 692 return SUCCEEDED; |
| 693 } | 693 } |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 } | 1631 } |
| 1632 | 1632 |
| 1633 Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate, | 1633 Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate, |
| 1634 CallDescriptor* call_descriptor, | 1634 CallDescriptor* call_descriptor, |
| 1635 Graph* graph, Schedule* schedule, | 1635 Graph* graph, Schedule* schedule, |
| 1636 Code::Flags flags, | 1636 Code::Flags flags, |
| 1637 const char* debug_name) { | 1637 const char* debug_name) { |
| 1638 CompilationInfo info(CStrVector(debug_name), isolate, graph->zone(), flags); | 1638 CompilationInfo info(CStrVector(debug_name), isolate, graph->zone(), flags); |
| 1639 | 1639 |
| 1640 // Construct a pipeline for scheduling and code generation. | 1640 // Construct a pipeline for scheduling and code generation. |
| 1641 ZoneStats zone_stats(isolate->allocator()); | 1641 ZonePool zone_pool(isolate->allocator()); |
| 1642 PipelineData data(&zone_stats, &info, graph, schedule); | 1642 PipelineData data(&zone_pool, &info, graph, schedule); |
| 1643 std::unique_ptr<PipelineStatistics> pipeline_statistics; | 1643 std::unique_ptr<PipelineStatistics> pipeline_statistics; |
| 1644 if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { | 1644 if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { |
| 1645 pipeline_statistics.reset(new PipelineStatistics(&info, &zone_stats)); | 1645 pipeline_statistics.reset(new PipelineStatistics(&info, &zone_pool)); |
| 1646 pipeline_statistics->BeginPhaseKind("stub codegen"); | 1646 pipeline_statistics->BeginPhaseKind("stub codegen"); |
| 1647 } | 1647 } |
| 1648 | 1648 |
| 1649 PipelineImpl pipeline(&data); | 1649 PipelineImpl pipeline(&data); |
| 1650 DCHECK_NOT_NULL(data.schedule()); | 1650 DCHECK_NOT_NULL(data.schedule()); |
| 1651 | 1651 |
| 1652 if (FLAG_trace_turbo) { | 1652 if (FLAG_trace_turbo) { |
| 1653 { | 1653 { |
| 1654 TurboJsonFile json_of(&info, std::ios_base::trunc); | 1654 TurboJsonFile json_of(&info, std::ios_base::trunc); |
| 1655 json_of << "{\"function\":\"" << info.GetDebugName().get() | 1655 json_of << "{\"function\":\"" << info.GetDebugName().get() |
| 1656 << "\", \"source\":\"\",\n\"phases\":["; | 1656 << "\", \"source\":\"\",\n\"phases\":["; |
| 1657 } | 1657 } |
| 1658 pipeline.Run<PrintGraphPhase>("Machine"); | 1658 pipeline.Run<PrintGraphPhase>("Machine"); |
| 1659 } | 1659 } |
| 1660 | 1660 |
| 1661 pipeline.Run<VerifyGraphPhase>(false, true); | 1661 pipeline.Run<VerifyGraphPhase>(false, true); |
| 1662 return pipeline.ScheduleAndGenerateCode(call_descriptor); | 1662 return pipeline.ScheduleAndGenerateCode(call_descriptor); |
| 1663 } | 1663 } |
| 1664 | 1664 |
| 1665 // static | 1665 // static |
| 1666 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info) { | 1666 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info) { |
| 1667 ZoneStats zone_stats(info->isolate()->allocator()); | 1667 ZonePool zone_pool(info->isolate()->allocator()); |
| 1668 std::unique_ptr<PipelineStatistics> pipeline_statistics( | 1668 std::unique_ptr<PipelineStatistics> pipeline_statistics( |
| 1669 CreatePipelineStatistics(info, &zone_stats)); | 1669 CreatePipelineStatistics(info, &zone_pool)); |
| 1670 PipelineData data(&zone_stats, info, pipeline_statistics.get()); | 1670 PipelineData data(&zone_pool, info, pipeline_statistics.get()); |
| 1671 PipelineImpl pipeline(&data); | 1671 PipelineImpl pipeline(&data); |
| 1672 | 1672 |
| 1673 Linkage linkage(Linkage::ComputeIncoming(data.instruction_zone(), info)); | 1673 Linkage linkage(Linkage::ComputeIncoming(data.instruction_zone(), info)); |
| 1674 | 1674 |
| 1675 if (!pipeline.CreateGraph()) return Handle<Code>::null(); | 1675 if (!pipeline.CreateGraph()) return Handle<Code>::null(); |
| 1676 if (!pipeline.OptimizeGraph(&linkage)) return Handle<Code>::null(); | 1676 if (!pipeline.OptimizeGraph(&linkage)) return Handle<Code>::null(); |
| 1677 return pipeline.GenerateCode(&linkage); | 1677 return pipeline.GenerateCode(&linkage); |
| 1678 } | 1678 } |
| 1679 | 1679 |
| 1680 // static | 1680 // static |
| 1681 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, | 1681 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, |
| 1682 Graph* graph, | 1682 Graph* graph, |
| 1683 Schedule* schedule) { | 1683 Schedule* schedule) { |
| 1684 CallDescriptor* call_descriptor = | 1684 CallDescriptor* call_descriptor = |
| 1685 Linkage::ComputeIncoming(info->zone(), info); | 1685 Linkage::ComputeIncoming(info->zone(), info); |
| 1686 return GenerateCodeForTesting(info, call_descriptor, graph, schedule); | 1686 return GenerateCodeForTesting(info, call_descriptor, graph, schedule); |
| 1687 } | 1687 } |
| 1688 | 1688 |
| 1689 // static | 1689 // static |
| 1690 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, | 1690 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, |
| 1691 CallDescriptor* call_descriptor, | 1691 CallDescriptor* call_descriptor, |
| 1692 Graph* graph, | 1692 Graph* graph, |
| 1693 Schedule* schedule) { | 1693 Schedule* schedule) { |
| 1694 // Construct a pipeline for scheduling and code generation. | 1694 // Construct a pipeline for scheduling and code generation. |
| 1695 ZoneStats zone_stats(info->isolate()->allocator()); | 1695 ZonePool zone_pool(info->isolate()->allocator()); |
| 1696 PipelineData data(&zone_stats, info, graph, schedule); | 1696 PipelineData data(&zone_pool, info, graph, schedule); |
| 1697 std::unique_ptr<PipelineStatistics> pipeline_statistics; | 1697 std::unique_ptr<PipelineStatistics> pipeline_statistics; |
| 1698 if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { | 1698 if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { |
| 1699 pipeline_statistics.reset(new PipelineStatistics(info, &zone_stats)); | 1699 pipeline_statistics.reset(new PipelineStatistics(info, &zone_pool)); |
| 1700 pipeline_statistics->BeginPhaseKind("test codegen"); | 1700 pipeline_statistics->BeginPhaseKind("test codegen"); |
| 1701 } | 1701 } |
| 1702 | 1702 |
| 1703 PipelineImpl pipeline(&data); | 1703 PipelineImpl pipeline(&data); |
| 1704 | 1704 |
| 1705 if (FLAG_trace_turbo) { | 1705 if (FLAG_trace_turbo) { |
| 1706 TurboJsonFile json_of(info, std::ios_base::trunc); | 1706 TurboJsonFile json_of(info, std::ios_base::trunc); |
| 1707 json_of << "{\"function\":\"" << info->GetDebugName().get() | 1707 json_of << "{\"function\":\"" << info->GetDebugName().get() |
| 1708 << "\", \"source\":\"\",\n\"phases\":["; | 1708 << "\", \"source\":\"\",\n\"phases\":["; |
| 1709 } | 1709 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1724 SourcePositionTable* source_positions) { | 1724 SourcePositionTable* source_positions) { |
| 1725 return new PipelineWasmCompilationJob(info, graph, descriptor, | 1725 return new PipelineWasmCompilationJob(info, graph, descriptor, |
| 1726 source_positions); | 1726 source_positions); |
| 1727 } | 1727 } |
| 1728 | 1728 |
| 1729 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, | 1729 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, |
| 1730 InstructionSequence* sequence, | 1730 InstructionSequence* sequence, |
| 1731 bool run_verifier) { | 1731 bool run_verifier) { |
| 1732 CompilationInfo info(ArrayVector("testing"), sequence->isolate(), | 1732 CompilationInfo info(ArrayVector("testing"), sequence->isolate(), |
| 1733 sequence->zone(), Code::ComputeFlags(Code::STUB)); | 1733 sequence->zone(), Code::ComputeFlags(Code::STUB)); |
| 1734 ZoneStats zone_stats(sequence->isolate()->allocator()); | 1734 ZonePool zone_pool(sequence->isolate()->allocator()); |
| 1735 PipelineData data(&zone_stats, &info, sequence); | 1735 PipelineData data(&zone_pool, &info, sequence); |
| 1736 PipelineImpl pipeline(&data); | 1736 PipelineImpl pipeline(&data); |
| 1737 pipeline.data_->InitializeFrameData(nullptr); | 1737 pipeline.data_->InitializeFrameData(nullptr); |
| 1738 pipeline.AllocateRegisters(config, nullptr, run_verifier); | 1738 pipeline.AllocateRegisters(config, nullptr, run_verifier); |
| 1739 return !data.compilation_failed(); | 1739 return !data.compilation_failed(); |
| 1740 } | 1740 } |
| 1741 | 1741 |
| 1742 bool PipelineImpl::ScheduleAndSelectInstructions(Linkage* linkage) { | 1742 bool PipelineImpl::ScheduleAndSelectInstructions(Linkage* linkage) { |
| 1743 CallDescriptor* call_descriptor = linkage->GetIncomingDescriptor(); | 1743 CallDescriptor* call_descriptor = linkage->GetIncomingDescriptor(); |
| 1744 PipelineData* data = this->data_; | 1744 PipelineData* data = this->data_; |
| 1745 | 1745 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1946 data->DeleteRegisterAllocationZone(); | 1946 data->DeleteRegisterAllocationZone(); |
| 1947 } | 1947 } |
| 1948 | 1948 |
| 1949 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1949 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
| 1950 | 1950 |
| 1951 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1951 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
| 1952 | 1952 |
| 1953 } // namespace compiler | 1953 } // namespace compiler |
| 1954 } // namespace internal | 1954 } // namespace internal |
| 1955 } // namespace v8 | 1955 } // namespace v8 |
| OLD | NEW |