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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 #include "src/compiler/typer.h" | 70 #include "src/compiler/typer.h" |
71 #include "src/compiler/value-numbering-reducer.h" | 71 #include "src/compiler/value-numbering-reducer.h" |
72 #include "src/compiler/verifier.h" | 72 #include "src/compiler/verifier.h" |
73 #include "src/compiler/zone-stats.h" | 73 #include "src/compiler/zone-stats.h" |
74 #include "src/isolate-inl.h" | 74 #include "src/isolate-inl.h" |
75 #include "src/ostreams.h" | 75 #include "src/ostreams.h" |
76 #include "src/parsing/parse-info.h" | 76 #include "src/parsing/parse-info.h" |
77 #include "src/register-configuration.h" | 77 #include "src/register-configuration.h" |
78 #include "src/type-info.h" | 78 #include "src/type-info.h" |
79 #include "src/utils.h" | 79 #include "src/utils.h" |
| 80 #include "src/wasm/wasm-module.h" |
80 | 81 |
81 namespace v8 { | 82 namespace v8 { |
82 namespace internal { | 83 namespace internal { |
83 namespace compiler { | 84 namespace compiler { |
84 | 85 |
85 class PipelineData { | 86 class PipelineData { |
86 public: | 87 public: |
87 // For main entry point. | 88 // For main entry point. |
88 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, | 89 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, |
89 PipelineStatistics* pipeline_statistics) | 90 PipelineStatistics* pipeline_statistics) |
(...skipping 18 matching lines...) Expand all Loading... |
108 InstructionSelector::SupportedMachineOperatorFlags(), | 109 InstructionSelector::SupportedMachineOperatorFlags(), |
109 InstructionSelector::AlignmentRequirements()); | 110 InstructionSelector::AlignmentRequirements()); |
110 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); | 111 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); |
111 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); | 112 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); |
112 jsgraph_ = new (graph_zone_) | 113 jsgraph_ = new (graph_zone_) |
113 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); | 114 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); |
114 } | 115 } |
115 | 116 |
116 // For WASM compile entry point. | 117 // For WASM compile entry point. |
117 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, | 118 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, |
118 SourcePositionTable* source_positions) | 119 SourcePositionTable* source_positions, |
| 120 ProtectedInstructionList* protected_instructions) |
119 : isolate_(info->isolate()), | 121 : isolate_(info->isolate()), |
120 info_(info), | 122 info_(info), |
121 debug_name_(info_->GetDebugName()), | 123 debug_name_(info_->GetDebugName()), |
122 zone_stats_(zone_stats), | 124 zone_stats_(zone_stats), |
123 graph_zone_scope_(zone_stats_, ZONE_NAME), | 125 graph_zone_scope_(zone_stats_, ZONE_NAME), |
124 graph_(graph), | 126 graph_(graph), |
125 source_positions_(source_positions), | 127 source_positions_(source_positions), |
126 instruction_zone_scope_(zone_stats_, ZONE_NAME), | 128 instruction_zone_scope_(zone_stats_, ZONE_NAME), |
127 instruction_zone_(instruction_zone_scope_.zone()), | 129 instruction_zone_(instruction_zone_scope_.zone()), |
128 register_allocation_zone_scope_(zone_stats_, ZONE_NAME), | 130 register_allocation_zone_scope_(zone_stats_, ZONE_NAME), |
129 register_allocation_zone_(register_allocation_zone_scope_.zone()) {} | 131 register_allocation_zone_(register_allocation_zone_scope_.zone()), |
| 132 protected_instructions_(protected_instructions) {} |
130 | 133 |
131 // For machine graph testing entry point. | 134 // For machine graph testing entry point. |
132 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, | 135 PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Graph* graph, |
133 Schedule* schedule) | 136 Schedule* schedule) |
134 : isolate_(info->isolate()), | 137 : isolate_(info->isolate()), |
135 info_(info), | 138 info_(info), |
136 debug_name_(info_->GetDebugName()), | 139 debug_name_(info_->GetDebugName()), |
137 zone_stats_(zone_stats), | 140 zone_stats_(zone_stats), |
138 graph_zone_scope_(zone_stats_, ZONE_NAME), | 141 graph_zone_scope_(zone_stats_, ZONE_NAME), |
139 graph_(graph), | 142 graph_(graph), |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 profiler_data_ = profiler_data; | 229 profiler_data_ = profiler_data; |
227 } | 230 } |
228 | 231 |
229 std::string const& source_position_output() const { | 232 std::string const& source_position_output() const { |
230 return source_position_output_; | 233 return source_position_output_; |
231 } | 234 } |
232 void set_source_position_output(std::string const& source_position_output) { | 235 void set_source_position_output(std::string const& source_position_output) { |
233 source_position_output_ = source_position_output; | 236 source_position_output_ = source_position_output; |
234 } | 237 } |
235 | 238 |
| 239 ProtectedInstructionList* protected_instructions() const { |
| 240 return protected_instructions_; |
| 241 } |
| 242 |
236 void DeleteGraphZone() { | 243 void DeleteGraphZone() { |
237 if (graph_zone_ == nullptr) return; | 244 if (graph_zone_ == nullptr) return; |
238 graph_zone_scope_.Destroy(); | 245 graph_zone_scope_.Destroy(); |
239 graph_zone_ = nullptr; | 246 graph_zone_ = nullptr; |
240 graph_ = nullptr; | 247 graph_ = nullptr; |
241 source_positions_ = nullptr; | 248 source_positions_ = nullptr; |
242 loop_assignment_ = nullptr; | 249 loop_assignment_ = nullptr; |
243 type_hint_analysis_ = nullptr; | 250 type_hint_analysis_ = nullptr; |
244 simplified_ = nullptr; | 251 simplified_ = nullptr; |
245 machine_ = nullptr; | 252 machine_ = nullptr; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 ZoneStats::Scope register_allocation_zone_scope_; | 355 ZoneStats::Scope register_allocation_zone_scope_; |
349 Zone* register_allocation_zone_; | 356 Zone* register_allocation_zone_; |
350 RegisterAllocationData* register_allocation_data_ = nullptr; | 357 RegisterAllocationData* register_allocation_data_ = nullptr; |
351 | 358 |
352 // Basic block profiling support. | 359 // Basic block profiling support. |
353 BasicBlockProfiler::Data* profiler_data_ = nullptr; | 360 BasicBlockProfiler::Data* profiler_data_ = nullptr; |
354 | 361 |
355 // Source position output for --trace-turbo. | 362 // Source position output for --trace-turbo. |
356 std::string source_position_output_; | 363 std::string source_position_output_; |
357 | 364 |
| 365 ProtectedInstructionList* protected_instructions_ = nullptr; |
| 366 |
358 DISALLOW_COPY_AND_ASSIGN(PipelineData); | 367 DISALLOW_COPY_AND_ASSIGN(PipelineData); |
359 }; | 368 }; |
360 | 369 |
361 class PipelineImpl final { | 370 class PipelineImpl final { |
362 public: | 371 public: |
363 explicit PipelineImpl(PipelineData* data) : data_(data) {} | 372 explicit PipelineImpl(PipelineData* data) : data_(data) {} |
364 | 373 |
365 // Helpers for executing pipeline phases. | 374 // Helpers for executing pipeline phases. |
366 template <typename Phase> | 375 template <typename Phase> |
367 void Run(); | 376 void Run(); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 info()->context()->native_context()->AddOptimizedCode(*code); | 616 info()->context()->native_context()->AddOptimizedCode(*code); |
608 RegisterWeakObjectsInOptimizedCode(code); | 617 RegisterWeakObjectsInOptimizedCode(code); |
609 } | 618 } |
610 return SUCCEEDED; | 619 return SUCCEEDED; |
611 } | 620 } |
612 | 621 |
613 class PipelineWasmCompilationJob final : public CompilationJob { | 622 class PipelineWasmCompilationJob final : public CompilationJob { |
614 public: | 623 public: |
615 explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph, | 624 explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph, |
616 CallDescriptor* descriptor, | 625 CallDescriptor* descriptor, |
617 SourcePositionTable* source_positions) | 626 SourcePositionTable* source_positions, |
| 627 ProtectedInstructionList* protected_insts) |
618 : CompilationJob(info->isolate(), info, "TurboFan", | 628 : CompilationJob(info->isolate(), info, "TurboFan", |
619 State::kReadyToExecute), | 629 State::kReadyToExecute), |
620 zone_stats_(info->isolate()->allocator()), | 630 zone_stats_(info->isolate()->allocator()), |
621 data_(&zone_stats_, info, graph, source_positions), | 631 data_(&zone_stats_, info, graph, source_positions, protected_insts), |
622 pipeline_(&data_), | 632 pipeline_(&data_), |
623 linkage_(descriptor) {} | 633 linkage_(descriptor) {} |
624 | 634 |
625 protected: | 635 protected: |
626 Status PrepareJobImpl() final; | 636 Status PrepareJobImpl() final; |
627 Status ExecuteJobImpl() final; | 637 Status ExecuteJobImpl() final; |
628 Status FinalizeJobImpl() final; | 638 Status FinalizeJobImpl() final; |
629 | 639 |
630 private: | 640 private: |
631 ZoneStats zone_stats_; | 641 ZoneStats zone_stats_; |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 } | 1407 } |
1398 } | 1408 } |
1399 }; | 1409 }; |
1400 | 1410 |
1401 | 1411 |
1402 struct GenerateCodePhase { | 1412 struct GenerateCodePhase { |
1403 static const char* phase_name() { return "generate code"; } | 1413 static const char* phase_name() { return "generate code"; } |
1404 | 1414 |
1405 void Run(PipelineData* data, Zone* temp_zone, Linkage* linkage) { | 1415 void Run(PipelineData* data, Zone* temp_zone, Linkage* linkage) { |
1406 CodeGenerator generator(data->frame(), linkage, data->sequence(), | 1416 CodeGenerator generator(data->frame(), linkage, data->sequence(), |
1407 data->info()); | 1417 data->info(), data->protected_instructions()); |
1408 data->set_code(generator.GenerateCode()); | 1418 data->set_code(generator.GenerateCode()); |
1409 } | 1419 } |
1410 }; | 1420 }; |
1411 | 1421 |
1412 | 1422 |
1413 struct PrintGraphPhase { | 1423 struct PrintGraphPhase { |
1414 static const char* phase_name() { return nullptr; } | 1424 static const char* phase_name() { return nullptr; } |
1415 | 1425 |
1416 void Run(PipelineData* data, Zone* temp_zone, const char* phase) { | 1426 void Run(PipelineData* data, Zone* temp_zone, const char* phase) { |
1417 CompilationInfo* info = data->info(); | 1427 CompilationInfo* info = data->info(); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 } | 1733 } |
1724 | 1734 |
1725 // static | 1735 // static |
1726 CompilationJob* Pipeline::NewCompilationJob(Handle<JSFunction> function) { | 1736 CompilationJob* Pipeline::NewCompilationJob(Handle<JSFunction> function) { |
1727 return new PipelineCompilationJob(function->GetIsolate(), function); | 1737 return new PipelineCompilationJob(function->GetIsolate(), function); |
1728 } | 1738 } |
1729 | 1739 |
1730 // static | 1740 // static |
1731 CompilationJob* Pipeline::NewWasmCompilationJob( | 1741 CompilationJob* Pipeline::NewWasmCompilationJob( |
1732 CompilationInfo* info, Graph* graph, CallDescriptor* descriptor, | 1742 CompilationInfo* info, Graph* graph, CallDescriptor* descriptor, |
1733 SourcePositionTable* source_positions) { | 1743 SourcePositionTable* source_positions, |
1734 return new PipelineWasmCompilationJob(info, graph, descriptor, | 1744 ProtectedInstructionList* protected_instructions) { |
1735 source_positions); | 1745 return new PipelineWasmCompilationJob( |
| 1746 info, graph, descriptor, source_positions, protected_instructions); |
1736 } | 1747 } |
1737 | 1748 |
1738 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, | 1749 bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config, |
1739 InstructionSequence* sequence, | 1750 InstructionSequence* sequence, |
1740 bool run_verifier) { | 1751 bool run_verifier) { |
1741 CompilationInfo info(ArrayVector("testing"), sequence->isolate(), | 1752 CompilationInfo info(ArrayVector("testing"), sequence->isolate(), |
1742 sequence->zone(), Code::ComputeFlags(Code::STUB)); | 1753 sequence->zone(), Code::ComputeFlags(Code::STUB)); |
1743 ZoneStats zone_stats(sequence->isolate()->allocator()); | 1754 ZoneStats zone_stats(sequence->isolate()->allocator()); |
1744 PipelineData data(&zone_stats, &info, sequence); | 1755 PipelineData data(&zone_stats, &info, sequence); |
1745 PipelineImpl pipeline(&data); | 1756 PipelineImpl pipeline(&data); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1974 data->DeleteRegisterAllocationZone(); | 1985 data->DeleteRegisterAllocationZone(); |
1975 } | 1986 } |
1976 | 1987 |
1977 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1988 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
1978 | 1989 |
1979 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1990 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
1980 | 1991 |
1981 } // namespace compiler | 1992 } // namespace compiler |
1982 } // namespace internal | 1993 } // namespace internal |
1983 } // namespace v8 | 1994 } // namespace v8 |
OLD | NEW |