| 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" |
| 11 #include "src/base/platform/elapsed-timer.h" | 11 #include "src/base/platform/elapsed-timer.h" |
| 12 #include "src/compiler/ast-graph-builder.h" | 12 #include "src/compiler/ast-graph-builder.h" |
| 13 #include "src/compiler/ast-loop-assignment-analyzer.h" | 13 #include "src/compiler/ast-loop-assignment-analyzer.h" |
| 14 #include "src/compiler/basic-block-instrumentor.h" | 14 #include "src/compiler/basic-block-instrumentor.h" |
| 15 #include "src/compiler/change-lowering.h" | 15 #include "src/compiler/change-lowering.h" |
| 16 #include "src/compiler/code-generator.h" | 16 #include "src/compiler/code-generator.h" |
| 17 #include "src/compiler/common-operator-reducer.h" | 17 #include "src/compiler/common-operator-reducer.h" |
| 18 #include "src/compiler/control-flow-optimizer.h" | 18 #include "src/compiler/control-flow-optimizer.h" |
| 19 #include "src/compiler/dead-code-elimination.h" | 19 #include "src/compiler/dead-code-elimination.h" |
| 20 #include "src/compiler/frame-elider.h" | 20 #include "src/compiler/frame-elider.h" |
| 21 #include "src/compiler/graph-replay.h" | 21 #include "src/compiler/graph-replay.h" |
| 22 #include "src/compiler/graph-trimmer.h" | 22 #include "src/compiler/graph-trimmer.h" |
| 23 #include "src/compiler/graph-visualizer.h" | 23 #include "src/compiler/graph-visualizer.h" |
| 24 #include "src/compiler/greedy-allocator.h" | 24 #include "src/compiler/greedy-allocator.h" |
| 25 #include "src/compiler/instruction.h" | 25 #include "src/compiler/instruction.h" |
| 26 #include "src/compiler/instruction-selector.h" | 26 #include "src/compiler/instruction-selector.h" |
| 27 #include "src/compiler/js-builtin-reducer.h" | 27 #include "src/compiler/js-builtin-reducer.h" |
| 28 #include "src/compiler/js-context-relaxation.h" |
| 28 #include "src/compiler/js-context-specialization.h" | 29 #include "src/compiler/js-context-specialization.h" |
| 29 #include "src/compiler/js-generic-lowering.h" | 30 #include "src/compiler/js-generic-lowering.h" |
| 30 #include "src/compiler/js-inlining.h" | 31 #include "src/compiler/js-inlining.h" |
| 31 #include "src/compiler/js-intrinsic-lowering.h" | 32 #include "src/compiler/js-intrinsic-lowering.h" |
| 32 #include "src/compiler/js-type-feedback.h" | 33 #include "src/compiler/js-type-feedback.h" |
| 33 #include "src/compiler/js-typed-lowering.h" | 34 #include "src/compiler/js-typed-lowering.h" |
| 34 #include "src/compiler/jump-threading.h" | 35 #include "src/compiler/jump-threading.h" |
| 35 #include "src/compiler/load-elimination.h" | 36 #include "src/compiler/load-elimination.h" |
| 36 #include "src/compiler/loop-analysis.h" | 37 #include "src/compiler/loop-analysis.h" |
| 37 #include "src/compiler/loop-peeling.h" | 38 #include "src/compiler/loop-peeling.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 code_(Handle<Code>::null()), | 74 code_(Handle<Code>::null()), |
| 74 graph_zone_scope_(zone_pool_), | 75 graph_zone_scope_(zone_pool_), |
| 75 graph_zone_(graph_zone_scope_.zone()), | 76 graph_zone_(graph_zone_scope_.zone()), |
| 76 graph_(nullptr), | 77 graph_(nullptr), |
| 77 loop_assignment_(nullptr), | 78 loop_assignment_(nullptr), |
| 78 machine_(nullptr), | 79 machine_(nullptr), |
| 79 common_(nullptr), | 80 common_(nullptr), |
| 80 javascript_(nullptr), | 81 javascript_(nullptr), |
| 81 jsgraph_(nullptr), | 82 jsgraph_(nullptr), |
| 82 js_type_feedback_(nullptr), | 83 js_type_feedback_(nullptr), |
| 84 relaxed_context_(nullptr), |
| 83 schedule_(nullptr), | 85 schedule_(nullptr), |
| 84 instruction_zone_scope_(zone_pool_), | 86 instruction_zone_scope_(zone_pool_), |
| 85 instruction_zone_(instruction_zone_scope_.zone()), | 87 instruction_zone_(instruction_zone_scope_.zone()), |
| 86 sequence_(nullptr), | 88 sequence_(nullptr), |
| 87 frame_(nullptr), | 89 frame_(nullptr), |
| 88 register_allocation_zone_scope_(zone_pool_), | 90 register_allocation_zone_scope_(zone_pool_), |
| 89 register_allocation_zone_(register_allocation_zone_scope_.zone()), | 91 register_allocation_zone_(register_allocation_zone_scope_.zone()), |
| 90 register_allocation_data_(nullptr) { | 92 register_allocation_data_(nullptr) { |
| 91 PhaseScope scope(pipeline_statistics, "init pipeline data"); | 93 PhaseScope scope(pipeline_statistics, "init pipeline data"); |
| 92 graph_ = new (graph_zone_) Graph(graph_zone_); | 94 graph_ = new (graph_zone_) Graph(graph_zone_); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 return source_positions_.get(); | 186 return source_positions_.get(); |
| 185 } | 187 } |
| 186 MachineOperatorBuilder* machine() const { return machine_; } | 188 MachineOperatorBuilder* machine() const { return machine_; } |
| 187 CommonOperatorBuilder* common() const { return common_; } | 189 CommonOperatorBuilder* common() const { return common_; } |
| 188 JSOperatorBuilder* javascript() const { return javascript_; } | 190 JSOperatorBuilder* javascript() const { return javascript_; } |
| 189 JSGraph* jsgraph() const { return jsgraph_; } | 191 JSGraph* jsgraph() const { return jsgraph_; } |
| 190 JSTypeFeedbackTable* js_type_feedback() { return js_type_feedback_; } | 192 JSTypeFeedbackTable* js_type_feedback() { return js_type_feedback_; } |
| 191 void set_js_type_feedback(JSTypeFeedbackTable* js_type_feedback) { | 193 void set_js_type_feedback(JSTypeFeedbackTable* js_type_feedback) { |
| 192 js_type_feedback_ = js_type_feedback; | 194 js_type_feedback_ = js_type_feedback; |
| 193 } | 195 } |
| 196 Node* relaxed_context() const { return relaxed_context_; } |
| 197 void set_relaxed_context(Node* relaxed_context) { |
| 198 relaxed_context_ = relaxed_context; |
| 199 } |
| 194 | 200 |
| 195 LoopAssignmentAnalysis* loop_assignment() const { return loop_assignment_; } | 201 LoopAssignmentAnalysis* loop_assignment() const { return loop_assignment_; } |
| 196 void set_loop_assignment(LoopAssignmentAnalysis* loop_assignment) { | 202 void set_loop_assignment(LoopAssignmentAnalysis* loop_assignment) { |
| 197 DCHECK(!loop_assignment_); | 203 DCHECK(!loop_assignment_); |
| 198 loop_assignment_ = loop_assignment; | 204 loop_assignment_ = loop_assignment; |
| 199 } | 205 } |
| 200 | 206 |
| 201 Schedule* schedule() const { return schedule_; } | 207 Schedule* schedule() const { return schedule_; } |
| 202 void set_schedule(Schedule* schedule) { | 208 void set_schedule(Schedule* schedule) { |
| 203 DCHECK(!schedule_); | 209 DCHECK(!schedule_); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 221 graph_zone_scope_.Destroy(); | 227 graph_zone_scope_.Destroy(); |
| 222 graph_zone_ = nullptr; | 228 graph_zone_ = nullptr; |
| 223 graph_ = nullptr; | 229 graph_ = nullptr; |
| 224 loop_assignment_ = nullptr; | 230 loop_assignment_ = nullptr; |
| 225 machine_ = nullptr; | 231 machine_ = nullptr; |
| 226 common_ = nullptr; | 232 common_ = nullptr; |
| 227 javascript_ = nullptr; | 233 javascript_ = nullptr; |
| 228 jsgraph_ = nullptr; | 234 jsgraph_ = nullptr; |
| 229 js_type_feedback_ = nullptr; | 235 js_type_feedback_ = nullptr; |
| 230 schedule_ = nullptr; | 236 schedule_ = nullptr; |
| 237 relaxed_context_ = nullptr; |
| 231 } | 238 } |
| 232 | 239 |
| 233 void DeleteInstructionZone() { | 240 void DeleteInstructionZone() { |
| 234 if (instruction_zone_ == nullptr) return; | 241 if (instruction_zone_ == nullptr) return; |
| 235 instruction_zone_scope_.Destroy(); | 242 instruction_zone_scope_.Destroy(); |
| 236 instruction_zone_ = nullptr; | 243 instruction_zone_ = nullptr; |
| 237 sequence_ = nullptr; | 244 sequence_ = nullptr; |
| 238 frame_ = nullptr; | 245 frame_ = nullptr; |
| 239 } | 246 } |
| 240 | 247 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 Zone* graph_zone_; | 286 Zone* graph_zone_; |
| 280 Graph* graph_; | 287 Graph* graph_; |
| 281 // TODO(dcarney): make this into a ZoneObject. | 288 // TODO(dcarney): make this into a ZoneObject. |
| 282 SmartPointer<SourcePositionTable> source_positions_; | 289 SmartPointer<SourcePositionTable> source_positions_; |
| 283 LoopAssignmentAnalysis* loop_assignment_; | 290 LoopAssignmentAnalysis* loop_assignment_; |
| 284 MachineOperatorBuilder* machine_; | 291 MachineOperatorBuilder* machine_; |
| 285 CommonOperatorBuilder* common_; | 292 CommonOperatorBuilder* common_; |
| 286 JSOperatorBuilder* javascript_; | 293 JSOperatorBuilder* javascript_; |
| 287 JSGraph* jsgraph_; | 294 JSGraph* jsgraph_; |
| 288 JSTypeFeedbackTable* js_type_feedback_; | 295 JSTypeFeedbackTable* js_type_feedback_; |
| 296 Node* relaxed_context_; |
| 289 Schedule* schedule_; | 297 Schedule* schedule_; |
| 290 | 298 |
| 291 // All objects in the following group of fields are allocated in | 299 // All objects in the following group of fields are allocated in |
| 292 // instruction_zone_. They are all set to NULL when the instruction_zone_ is | 300 // instruction_zone_. They are all set to NULL when the instruction_zone_ is |
| 293 // destroyed. | 301 // destroyed. |
| 294 ZonePool::Scope instruction_zone_scope_; | 302 ZonePool::Scope instruction_zone_scope_; |
| 295 Zone* instruction_zone_; | 303 Zone* instruction_zone_; |
| 296 InstructionSequence* sequence_; | 304 InstructionSequence* sequence_; |
| 297 Frame* frame_; | 305 Frame* frame_; |
| 298 | 306 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 | 380 |
| 373 #define DEF_VISIT(type) \ | 381 #define DEF_VISIT(type) \ |
| 374 void Visit##type(type* node) override { \ | 382 void Visit##type(type* node) override { \ |
| 375 SourcePositionTable::Scope pos(source_positions_, \ | 383 SourcePositionTable::Scope pos(source_positions_, \ |
| 376 SourcePosition(node->position())); \ | 384 SourcePosition(node->position())); \ |
| 377 AstGraphBuilder::Visit##type(node); \ | 385 AstGraphBuilder::Visit##type(node); \ |
| 378 } | 386 } |
| 379 AST_NODE_LIST(DEF_VISIT) | 387 AST_NODE_LIST(DEF_VISIT) |
| 380 #undef DEF_VISIT | 388 #undef DEF_VISIT |
| 381 | 389 |
| 390 using AstGraphBuilder::relaxed_context; |
| 391 |
| 382 private: | 392 private: |
| 383 SourcePositionTable* const source_positions_; | 393 SourcePositionTable* const source_positions_; |
| 384 SourcePosition const start_position_; | 394 SourcePosition const start_position_; |
| 385 }; | 395 }; |
| 386 | 396 |
| 387 | 397 |
| 388 class SourcePositionWrapper final : public Reducer { | 398 class SourcePositionWrapper final : public Reducer { |
| 389 public: | 399 public: |
| 390 SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) | 400 SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) |
| 391 : reducer_(reducer), table_(table) {} | 401 : reducer_(reducer), table_(table) {} |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 static const char* phase_name() { return "graph builder"; } | 485 static const char* phase_name() { return "graph builder"; } |
| 476 | 486 |
| 477 void Run(PipelineData* data, Zone* temp_zone, bool constant_context) { | 487 void Run(PipelineData* data, Zone* temp_zone, bool constant_context) { |
| 478 AstGraphBuilderWithPositions graph_builder( | 488 AstGraphBuilderWithPositions graph_builder( |
| 479 temp_zone, data->info(), data->jsgraph(), data->loop_assignment(), | 489 temp_zone, data->info(), data->jsgraph(), data->loop_assignment(), |
| 480 data->js_type_feedback(), data->source_positions()); | 490 data->js_type_feedback(), data->source_positions()); |
| 481 bool stack_check = !data->info()->IsStub(); | 491 bool stack_check = !data->info()->IsStub(); |
| 482 if (!graph_builder.CreateGraph(constant_context, stack_check)) { | 492 if (!graph_builder.CreateGraph(constant_context, stack_check)) { |
| 483 data->set_compilation_failed(); | 493 data->set_compilation_failed(); |
| 484 } | 494 } |
| 495 data->set_relaxed_context(graph_builder.relaxed_context()); |
| 485 } | 496 } |
| 486 }; | 497 }; |
| 487 | 498 |
| 488 | 499 |
| 489 struct InliningPhase { | 500 struct InliningPhase { |
| 490 static const char* phase_name() { return "inlining"; } | 501 static const char* phase_name() { return "inlining"; } |
| 491 | 502 |
| 492 void Run(PipelineData* data, Zone* temp_zone) { | 503 void Run(PipelineData* data, Zone* temp_zone) { |
| 493 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); | 504 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
| 494 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), | 505 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 } | 694 } |
| 684 } | 695 } |
| 685 }; | 696 }; |
| 686 | 697 |
| 687 | 698 |
| 688 struct GenericLoweringPhase { | 699 struct GenericLoweringPhase { |
| 689 static const char* phase_name() { return "generic lowering"; } | 700 static const char* phase_name() { return "generic lowering"; } |
| 690 | 701 |
| 691 void Run(PipelineData* data, Zone* temp_zone) { | 702 void Run(PipelineData* data, Zone* temp_zone) { |
| 692 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); | 703 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
| 704 JSContextRelaxation relaxing(data->graph()->start(), |
| 705 data->relaxed_context()); |
| 693 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), | 706 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
| 694 data->common()); | 707 data->common()); |
| 695 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), | 708 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), |
| 696 data->common(), data->machine()); | 709 data->common(), data->machine()); |
| 697 JSGenericLowering generic_lowering(data->info()->is_typing_enabled(), | 710 JSGenericLowering generic_lowering(data->info()->is_typing_enabled(), |
| 698 data->jsgraph()); | 711 data->jsgraph()); |
| 699 SelectLowering select_lowering(data->jsgraph()->graph(), | 712 SelectLowering select_lowering(data->jsgraph()->graph(), |
| 700 data->jsgraph()->common()); | 713 data->jsgraph()->common()); |
| 701 TailCallOptimization tco(data->common(), data->graph()); | 714 TailCallOptimization tco(data->common(), data->graph()); |
| 715 AddReducer(data, &graph_reducer, &relaxing); |
| 702 AddReducer(data, &graph_reducer, &dead_code_elimination); | 716 AddReducer(data, &graph_reducer, &dead_code_elimination); |
| 703 AddReducer(data, &graph_reducer, &common_reducer); | 717 AddReducer(data, &graph_reducer, &common_reducer); |
| 704 AddReducer(data, &graph_reducer, &generic_lowering); | 718 AddReducer(data, &graph_reducer, &generic_lowering); |
| 705 AddReducer(data, &graph_reducer, &select_lowering); | 719 AddReducer(data, &graph_reducer, &select_lowering); |
| 706 AddReducer(data, &graph_reducer, &tco); | 720 AddReducer(data, &graph_reducer, &tco); |
| 707 graph_reducer.ReduceGraph(); | 721 graph_reducer.ReduceGraph(); |
| 708 } | 722 } |
| 709 }; | 723 }; |
| 710 | 724 |
| 711 | 725 |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 tcf << AsC1VRegisterAllocationData("CodeGen", | 1369 tcf << AsC1VRegisterAllocationData("CodeGen", |
| 1356 data->register_allocation_data()); | 1370 data->register_allocation_data()); |
| 1357 } | 1371 } |
| 1358 | 1372 |
| 1359 data->DeleteRegisterAllocationZone(); | 1373 data->DeleteRegisterAllocationZone(); |
| 1360 } | 1374 } |
| 1361 | 1375 |
| 1362 } // namespace compiler | 1376 } // namespace compiler |
| 1363 } // namespace internal | 1377 } // namespace internal |
| 1364 } // namespace v8 | 1378 } // namespace v8 |
| OLD | NEW |