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