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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(ZoneStats* zone_stats, CompilationInfo* info, JSGraph* jsgraph, |
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_stats_(zone_stats), |
122 graph_zone_scope_(zone_stats_, ZONE_NAME), | 122 graph_zone_scope_(zone_stats_, ZONE_NAME), |
123 graph_(graph), | 123 graph_(jsgraph->graph()), |
124 source_positions_(source_positions), | 124 source_positions_(source_positions), |
| 125 machine_(jsgraph->machine()), |
| 126 common_(jsgraph->common()), |
| 127 javascript_(jsgraph->javascript()), |
| 128 jsgraph_(jsgraph), |
125 instruction_zone_scope_(zone_stats_, ZONE_NAME), | 129 instruction_zone_scope_(zone_stats_, ZONE_NAME), |
126 instruction_zone_(instruction_zone_scope_.zone()), | 130 instruction_zone_(instruction_zone_scope_.zone()), |
127 register_allocation_zone_scope_(zone_stats_, ZONE_NAME), | 131 register_allocation_zone_scope_(zone_stats_, ZONE_NAME), |
128 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} | 132 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} |
129 | 133 |
130 // For machine graph testing entry point. | 134 // For machine graph testing entry point. |
131 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, | 135 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, |
132 Schedule* schedule) | 136 Schedule* schedule) |
133 : isolate_(info->isolate()), | 137 : isolate_(info->isolate()), |
134 info_(info), | 138 info_(info), |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 info()->SetCode(code); | 600 info()->SetCode(code); |
597 if (info()->is_deoptimization_enabled()) { | 601 if (info()->is_deoptimization_enabled()) { |
598 info()->context()->native_context()->AddOptimizedCode(*code); | 602 info()->context()->native_context()->AddOptimizedCode(*code); |
599 RegisterWeakObjectsInOptimizedCode(code); | 603 RegisterWeakObjectsInOptimizedCode(code); |
600 } | 604 } |
601 return SUCCEEDED; | 605 return SUCCEEDED; |
602 } | 606 } |
603 | 607 |
604 class PipelineWasmCompilationJob final : public CompilationJob { | 608 class PipelineWasmCompilationJob final : public CompilationJob { |
605 public: | 609 public: |
606 explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph, | 610 explicit PipelineWasmCompilationJob(CompilationInfo* info, JSGraph* jsgraph, |
607 CallDescriptor* descriptor, | 611 CallDescriptor* descriptor, |
608 SourcePositionTable* source_positions) | 612 SourcePositionTable* source_positions) |
609 : CompilationJob(info->isolate(), info, "TurboFan", | 613 : CompilationJob(info->isolate(), info, "TurboFan", |
610 State::kReadyToExecute), | 614 State::kReadyToExecute), |
611 zone_stats_(info->isolate()->allocator()), | 615 zone_stats_(info->isolate()->allocator()), |
612 data_(&zone_stats_, info, graph, source_positions), | 616 data_(&zone_stats_, info, jsgraph, source_positions), |
613 pipeline_(&data_), | 617 pipeline_(&data_), |
614 linkage_(descriptor) {} | 618 linkage_(descriptor) {} |
615 | 619 |
616 protected: | 620 protected: |
617 Status PrepareJobImpl() final; | 621 Status PrepareJobImpl() final; |
618 Status ExecuteJobImpl() final; | 622 Status ExecuteJobImpl() final; |
619 Status FinalizeJobImpl() final; | 623 Status FinalizeJobImpl() final; |
620 | 624 |
621 private: | 625 private: |
622 ZoneStats zone_stats_; | 626 ZoneStats zone_stats_; |
(...skipping 10 matching lines...) Expand all Loading... |
633 | 637 |
634 PipelineWasmCompilationJob::Status | 638 PipelineWasmCompilationJob::Status |
635 PipelineWasmCompilationJob::ExecuteJobImpl() { | 639 PipelineWasmCompilationJob::ExecuteJobImpl() { |
636 if (FLAG_trace_turbo) { | 640 if (FLAG_trace_turbo) { |
637 TurboJsonFile json_of(info(), std::ios_base::trunc); | 641 TurboJsonFile json_of(info(), std::ios_base::trunc); |
638 json_of << "{\"function\":\"" << info()->GetDebugName().get() | 642 json_of << "{\"function\":\"" << info()->GetDebugName().get() |
639 << "\", \"source\":\"\",\n\"phases\":["; | 643 << "\", \"source\":\"\",\n\"phases\":["; |
640 } | 644 } |
641 | 645 |
642 pipeline_.RunPrintAndVerify("Machine", true); | 646 pipeline_.RunPrintAndVerify("Machine", true); |
| 647 if (FLAG_wasm_opt) { |
| 648 PipelineData* data = &data_; |
| 649 PipelineRunScope scope(data, "WASM optimization"); |
| 650 JSGraphReducer graph_reducer(data->jsgraph(), scope.zone()); |
| 651 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
| 652 data->common()); |
| 653 ValueNumberingReducer value_numbering(scope.zone(), data->graph()->zone()); |
| 654 MachineOperatorReducer machine_reducer(data->jsgraph()); |
| 655 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), |
| 656 data->common(), data->machine()); |
| 657 AddReducer(data, &graph_reducer, &dead_code_elimination); |
| 658 AddReducer(data, &graph_reducer, &value_numbering); |
| 659 AddReducer(data, &graph_reducer, &machine_reducer); |
| 660 AddReducer(data, &graph_reducer, &common_reducer); |
| 661 graph_reducer.ReduceGraph(); |
| 662 pipeline_.RunPrintAndVerify("Optimized Machine", true); |
| 663 } |
643 | 664 |
644 if (!pipeline_.ScheduleAndSelectInstructions(&linkage_, true)) return FAILED; | 665 if (!pipeline_.ScheduleAndSelectInstructions(&linkage_, true)) return FAILED; |
645 return SUCCEEDED; | 666 return SUCCEEDED; |
646 } | 667 } |
647 | 668 |
648 PipelineWasmCompilationJob::Status | 669 PipelineWasmCompilationJob::Status |
649 PipelineWasmCompilationJob::FinalizeJobImpl() { | 670 PipelineWasmCompilationJob::FinalizeJobImpl() { |
650 pipeline_.GenerateCode(&linkage_); | 671 pipeline_.GenerateCode(&linkage_); |
651 return SUCCEEDED; | 672 return SUCCEEDED; |
652 } | 673 } |
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1696 return pipeline.ScheduleAndGenerateCode(call_descriptor); | 1717 return pipeline.ScheduleAndGenerateCode(call_descriptor); |
1697 } | 1718 } |
1698 | 1719 |
1699 // static | 1720 // static |
1700 CompilationJob* Pipeline::NewCompilationJob(Handle<JSFunction> function) { | 1721 CompilationJob* Pipeline::NewCompilationJob(Handle<JSFunction> function) { |
1701 return new PipelineCompilationJob(function->GetIsolate(), function); | 1722 return new PipelineCompilationJob(function->GetIsolate(), function); |
1702 } | 1723 } |
1703 | 1724 |
1704 // static | 1725 // static |
1705 CompilationJob* Pipeline::NewWasmCompilationJob( | 1726 CompilationJob* Pipeline::NewWasmCompilationJob( |
1706 CompilationInfo* info, Graph* graph, CallDescriptor* descriptor, | 1727 CompilationInfo* info, JSGraph* jsgraph, CallDescriptor* descriptor, |
1707 SourcePositionTable* source_positions) { | 1728 SourcePositionTable* source_positions) { |
1708 return new PipelineWasmCompilationJob(info, graph, descriptor, | 1729 return new PipelineWasmCompilationJob(info, jsgraph, descriptor, |
1709 source_positions); | 1730 source_positions); |
1710 } | 1731 } |
1711 | 1732 |
1712 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, | 1733 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, |
1713 InstructionSequence* sequence, | 1734 InstructionSequence* sequence, |
1714 bool run_verifier) { | 1735 bool run_verifier) { |
1715 CompilationInfo info(ArrayVector("testing"), sequence->isolate(), | 1736 CompilationInfo info(ArrayVector("testing"), sequence->isolate(), |
1716 sequence->zone(), Code::ComputeFlags(Code::STUB)); | 1737 sequence->zone(), Code::ComputeFlags(Code::STUB)); |
1717 ZoneStats zone_stats(sequence->isolate()->allocator()); | 1738 ZoneStats zone_stats(sequence->isolate()->allocator()); |
1718 PipelineData data(&zone_stats, &info, sequence); | 1739 PipelineData data(&zone_stats, &info, sequence); |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1948 data->DeleteRegisterAllocationZone(); | 1969 data->DeleteRegisterAllocationZone(); |
1949 } | 1970 } |
1950 | 1971 |
1951 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1972 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
1952 | 1973 |
1953 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1974 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
1954 | 1975 |
1955 } // namespace compiler | 1976 } // namespace compiler |
1956 } // namespace internal | 1977 } // namespace internal |
1957 } // namespace v8 | 1978 } // namespace v8 |
OLD | NEW |