| 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 <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "src/base/adapters.h" | 10 #include "src/base/adapters.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 schedule_(nullptr), | 96 schedule_(nullptr), |
| 97 instruction_zone_scope_(zone_pool_), | 97 instruction_zone_scope_(zone_pool_), |
| 98 instruction_zone_(instruction_zone_scope_.zone()), | 98 instruction_zone_(instruction_zone_scope_.zone()), |
| 99 sequence_(nullptr), | 99 sequence_(nullptr), |
| 100 frame_(nullptr), | 100 frame_(nullptr), |
| 101 register_allocation_zone_scope_(zone_pool_), | 101 register_allocation_zone_scope_(zone_pool_), |
| 102 register_allocation_zone_(register_allocation_zone_scope_.zone()), | 102 register_allocation_zone_(register_allocation_zone_scope_.zone()), |
| 103 register_allocation_data_(nullptr) { | 103 register_allocation_data_(nullptr) { |
| 104 PhaseScope scope(pipeline_statistics, "init pipeline data"); | 104 PhaseScope scope(pipeline_statistics, "init pipeline data"); |
| 105 graph_ = new (graph_zone_) Graph(graph_zone_); | 105 graph_ = new (graph_zone_) Graph(graph_zone_); |
| 106 source_positions_.Reset(new SourcePositionTable(graph_)); | |
| 107 simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_); | 106 simplified_ = new (graph_zone_) SimplifiedOperatorBuilder(graph_zone_); |
| 108 machine_ = new (graph_zone_) MachineOperatorBuilder( | 107 machine_ = new (graph_zone_) MachineOperatorBuilder( |
| 109 graph_zone_, MachineType::PointerRepresentation(), | 108 graph_zone_, MachineType::PointerRepresentation(), |
| 110 InstructionSelector::SupportedMachineOperatorFlags()); | 109 InstructionSelector::SupportedMachineOperatorFlags()); |
| 111 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); | 110 common_ = new (graph_zone_) CommonOperatorBuilder(graph_zone_); |
| 112 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); | 111 javascript_ = new (graph_zone_) JSOperatorBuilder(graph_zone_); |
| 113 jsgraph_ = new (graph_zone_) | 112 jsgraph_ = new (graph_zone_) |
| 114 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); | 113 JSGraph(isolate_, graph_, common_, javascript_, simplified_, machine_); |
| 115 } | 114 } |
| 116 | 115 |
| 117 // For machine graph testing entry point. | 116 // For machine graph testing entry point. |
| 118 PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph, | 117 PipelineData(ZonePool* zone_pool, CompilationInfo* info, Graph* graph, |
| 119 Schedule* schedule) | 118 Schedule* schedule) |
| 120 : isolate_(info->isolate()), | 119 : isolate_(info->isolate()), |
| 121 info_(info), | 120 info_(info), |
| 122 outer_zone_(nullptr), | 121 outer_zone_(nullptr), |
| 123 zone_pool_(zone_pool), | 122 zone_pool_(zone_pool), |
| 124 pipeline_statistics_(nullptr), | 123 pipeline_statistics_(nullptr), |
| 125 compilation_failed_(false), | 124 compilation_failed_(false), |
| 126 code_(Handle<Code>::null()), | 125 code_(Handle<Code>::null()), |
| 127 graph_zone_scope_(zone_pool_), | 126 graph_zone_scope_(zone_pool_), |
| 128 graph_zone_(nullptr), | 127 graph_zone_(nullptr), |
| 129 graph_(graph), | 128 graph_(graph), |
| 130 source_positions_(new SourcePositionTable(graph_)), | |
| 131 loop_assignment_(nullptr), | 129 loop_assignment_(nullptr), |
| 132 simplified_(nullptr), | 130 simplified_(nullptr), |
| 133 machine_(nullptr), | 131 machine_(nullptr), |
| 134 common_(nullptr), | 132 common_(nullptr), |
| 135 javascript_(nullptr), | 133 javascript_(nullptr), |
| 136 jsgraph_(nullptr), | 134 jsgraph_(nullptr), |
| 137 schedule_(schedule), | 135 schedule_(schedule), |
| 138 instruction_zone_scope_(zone_pool_), | 136 instruction_zone_scope_(zone_pool_), |
| 139 instruction_zone_(instruction_zone_scope_.zone()), | 137 instruction_zone_(instruction_zone_scope_.zone()), |
| 140 sequence_(nullptr), | 138 sequence_(nullptr), |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 void set_code(Handle<Code> code) { | 185 void set_code(Handle<Code> code) { |
| 188 DCHECK(code_.is_null()); | 186 DCHECK(code_.is_null()); |
| 189 code_ = code; | 187 code_ = code; |
| 190 } | 188 } |
| 191 | 189 |
| 192 // RawMachineAssembler generally produces graphs which cannot be verified. | 190 // RawMachineAssembler generally produces graphs which cannot be verified. |
| 193 bool MayHaveUnverifiableGraph() const { return outer_zone_ == nullptr; } | 191 bool MayHaveUnverifiableGraph() const { return outer_zone_ == nullptr; } |
| 194 | 192 |
| 195 Zone* graph_zone() const { return graph_zone_; } | 193 Zone* graph_zone() const { return graph_zone_; } |
| 196 Graph* graph() const { return graph_; } | 194 Graph* graph() const { return graph_; } |
| 197 SourcePositionTable* source_positions() const { | 195 SourcePositionTable* source_positions() { |
| 196 // First check whether the CompilationInfo provides the table |
| 197 if (auto* table = info()->GetSourcePositionTable()) return table; |
| 198 // Lazy initialization |
| 199 if (source_positions_.is_empty()) |
| 200 source_positions_.Reset(new SourcePositionTable(graph())); |
| 198 return source_positions_.get(); | 201 return source_positions_.get(); |
| 199 } | 202 } |
| 200 MachineOperatorBuilder* machine() const { return machine_; } | 203 MachineOperatorBuilder* machine() const { return machine_; } |
| 201 CommonOperatorBuilder* common() const { return common_; } | 204 CommonOperatorBuilder* common() const { return common_; } |
| 202 JSOperatorBuilder* javascript() const { return javascript_; } | 205 JSOperatorBuilder* javascript() const { return javascript_; } |
| 203 JSGraph* jsgraph() const { return jsgraph_; } | 206 JSGraph* jsgraph() const { return jsgraph_; } |
| 204 MaybeHandle<Context> native_context() const { | 207 MaybeHandle<Context> native_context() const { |
| 205 if (info()->is_native_context_specializing()) { | 208 if (info()->is_native_context_specializing()) { |
| 206 return handle(info()->native_context(), isolate()); | 209 return handle(info()->native_context(), isolate()); |
| 207 } | 210 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 JSGraph* jsgraph, | 396 JSGraph* jsgraph, |
| 394 LoopAssignmentAnalysis* loop_assignment, | 397 LoopAssignmentAnalysis* loop_assignment, |
| 395 TypeHintAnalysis* type_hint_analysis, | 398 TypeHintAnalysis* type_hint_analysis, |
| 396 SourcePositionTable* source_positions) | 399 SourcePositionTable* source_positions) |
| 397 : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment, | 400 : AstGraphBuilder(local_zone, info, jsgraph, loop_assignment, |
| 398 type_hint_analysis), | 401 type_hint_analysis), |
| 399 source_positions_(source_positions), | 402 source_positions_(source_positions), |
| 400 start_position_(info->shared_info()->start_position()) {} | 403 start_position_(info->shared_info()->start_position()) {} |
| 401 | 404 |
| 402 bool CreateGraph(bool stack_check) { | 405 bool CreateGraph(bool stack_check) { |
| 403 SourcePositionTable::Scope pos_scope(source_positions_, start_position_); | 406 SourcePositionScope pos_scope(source_positions_, start_position_); |
| 404 return AstGraphBuilder::CreateGraph(stack_check); | 407 return AstGraphBuilder::CreateGraph(stack_check); |
| 405 } | 408 } |
| 406 | 409 |
| 407 #define DEF_VISIT(type) \ | 410 #define DEF_VISIT(type) \ |
| 408 void Visit##type(type* node) override { \ | 411 void Visit##type(type* node) override { \ |
| 409 SourcePositionTable::Scope pos(source_positions_, \ | 412 SourcePositionScope pos(source_positions_, \ |
| 410 SourcePosition(node->position())); \ | 413 SourcePosition(node->position())); \ |
| 411 AstGraphBuilder::Visit##type(node); \ | 414 AstGraphBuilder::Visit##type(node); \ |
| 412 } | 415 } |
| 413 AST_NODE_LIST(DEF_VISIT) | 416 AST_NODE_LIST(DEF_VISIT) |
| 414 #undef DEF_VISIT | 417 #undef DEF_VISIT |
| 415 | 418 |
| 416 private: | 419 private: |
| 417 SourcePositionTable* const source_positions_; | 420 SourcePositionTable* const source_positions_; |
| 418 SourcePosition const start_position_; | 421 SourcePosition const start_position_; |
| 419 }; | 422 }; |
| 420 | 423 |
| 421 | 424 |
| 422 class SourcePositionWrapper final : public Reducer { | 425 class SourcePositionWrapper final : public Reducer { |
| 423 public: | 426 public: |
| 424 SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) | 427 SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) |
| 425 : reducer_(reducer), table_(table) {} | 428 : reducer_(reducer), table_(table) {} |
| 426 ~SourcePositionWrapper() final {} | 429 ~SourcePositionWrapper() final {} |
| 427 | 430 |
| 428 Reduction Reduce(Node* node) final { | 431 Reduction Reduce(Node* node) final { |
| 429 SourcePosition const pos = table_->GetSourcePosition(node); | 432 SourcePosition const pos = table_->GetSourcePosition(node); |
| 430 SourcePositionTable::Scope position(table_, pos); | 433 SourcePositionScope position(table_, pos); |
| 431 return reducer_->Reduce(node); | 434 return reducer_->Reduce(node); |
| 432 } | 435 } |
| 433 | 436 |
| 434 void Finalize() final { reducer_->Finalize(); } | 437 void Finalize() final { reducer_->Finalize(); } |
| 435 | 438 |
| 436 private: | 439 private: |
| 437 Reducer* const reducer_; | 440 Reducer* const reducer_; |
| 438 SourcePositionTable* const table_; | 441 SourcePositionTable* const table_; |
| 439 | 442 |
| 440 DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper); | 443 DISALLOW_COPY_AND_ASSIGN(SourcePositionWrapper); |
| (...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 } | 1567 } |
| 1565 | 1568 |
| 1566 data->DeleteRegisterAllocationZone(); | 1569 data->DeleteRegisterAllocationZone(); |
| 1567 } | 1570 } |
| 1568 | 1571 |
| 1569 Isolate* Pipeline::isolate() const { return info()->isolate(); } | 1572 Isolate* Pipeline::isolate() const { return info()->isolate(); } |
| 1570 | 1573 |
| 1571 } // namespace compiler | 1574 } // namespace compiler |
| 1572 } // namespace internal | 1575 } // namespace internal |
| 1573 } // namespace v8 | 1576 } // namespace v8 |
| OLD | NEW |