| 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/branch-elimination.h" | 15 #include "src/compiler/branch-elimination.h" |
| 16 #include "src/compiler/bytecode-graph-builder.h" | 16 #include "src/compiler/bytecode-graph-builder.h" |
| 17 #include "src/compiler/change-lowering.h" | |
| 18 #include "src/compiler/code-generator.h" | 17 #include "src/compiler/code-generator.h" |
| 19 #include "src/compiler/common-operator-reducer.h" | 18 #include "src/compiler/common-operator-reducer.h" |
| 20 #include "src/compiler/control-flow-optimizer.h" | 19 #include "src/compiler/control-flow-optimizer.h" |
| 21 #include "src/compiler/dead-code-elimination.h" | 20 #include "src/compiler/dead-code-elimination.h" |
| 22 #include "src/compiler/effect-control-linearizer.h" | 21 #include "src/compiler/effect-control-linearizer.h" |
| 23 #include "src/compiler/escape-analysis-reducer.h" | 22 #include "src/compiler/escape-analysis-reducer.h" |
| 24 #include "src/compiler/escape-analysis.h" | 23 #include "src/compiler/escape-analysis.h" |
| 25 #include "src/compiler/frame-elider.h" | 24 #include "src/compiler/frame-elider.h" |
| 26 #include "src/compiler/graph-replay.h" | 25 #include "src/compiler/graph-replay.h" |
| 27 #include "src/compiler/graph-trimmer.h" | 26 #include "src/compiler/graph-trimmer.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 39 #include "src/compiler/js-inlining-heuristic.h" | 38 #include "src/compiler/js-inlining-heuristic.h" |
| 40 #include "src/compiler/js-intrinsic-lowering.h" | 39 #include "src/compiler/js-intrinsic-lowering.h" |
| 41 #include "src/compiler/js-native-context-specialization.h" | 40 #include "src/compiler/js-native-context-specialization.h" |
| 42 #include "src/compiler/js-typed-lowering.h" | 41 #include "src/compiler/js-typed-lowering.h" |
| 43 #include "src/compiler/jump-threading.h" | 42 #include "src/compiler/jump-threading.h" |
| 44 #include "src/compiler/live-range-separator.h" | 43 #include "src/compiler/live-range-separator.h" |
| 45 #include "src/compiler/load-elimination.h" | 44 #include "src/compiler/load-elimination.h" |
| 46 #include "src/compiler/loop-analysis.h" | 45 #include "src/compiler/loop-analysis.h" |
| 47 #include "src/compiler/loop-peeling.h" | 46 #include "src/compiler/loop-peeling.h" |
| 48 #include "src/compiler/machine-operator-reducer.h" | 47 #include "src/compiler/machine-operator-reducer.h" |
| 48 #include "src/compiler/memory-optimizer.h" |
| 49 #include "src/compiler/move-optimizer.h" | 49 #include "src/compiler/move-optimizer.h" |
| 50 #include "src/compiler/osr.h" | 50 #include "src/compiler/osr.h" |
| 51 #include "src/compiler/pipeline-statistics.h" | 51 #include "src/compiler/pipeline-statistics.h" |
| 52 #include "src/compiler/register-allocator-verifier.h" | 52 #include "src/compiler/register-allocator-verifier.h" |
| 53 #include "src/compiler/register-allocator.h" | 53 #include "src/compiler/register-allocator.h" |
| 54 #include "src/compiler/schedule.h" | 54 #include "src/compiler/schedule.h" |
| 55 #include "src/compiler/scheduler.h" | 55 #include "src/compiler/scheduler.h" |
| 56 #include "src/compiler/select-lowering.h" | 56 #include "src/compiler/select-lowering.h" |
| 57 #include "src/compiler/simplified-lowering.h" | 57 #include "src/compiler/simplified-lowering.h" |
| 58 #include "src/compiler/simplified-operator-reducer.h" | 58 #include "src/compiler/simplified-operator-reducer.h" |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 // Post-pass for wiring the control/effects | 1012 // Post-pass for wiring the control/effects |
| 1013 // - connect allocating representation changes into the control&effect | 1013 // - connect allocating representation changes into the control&effect |
| 1014 // chains and lower them, | 1014 // chains and lower them, |
| 1015 // - get rid of the region markers, | 1015 // - get rid of the region markers, |
| 1016 // - introduce effect phis and rewire effects to get SSA again. | 1016 // - introduce effect phis and rewire effects to get SSA again. |
| 1017 EffectControlLinearizer linearizer(data->jsgraph(), schedule, temp_zone); | 1017 EffectControlLinearizer linearizer(data->jsgraph(), schedule, temp_zone); |
| 1018 linearizer.Run(); | 1018 linearizer.Run(); |
| 1019 } | 1019 } |
| 1020 }; | 1020 }; |
| 1021 | 1021 |
| 1022 struct MemoryOptimizationPhase { |
| 1023 static const char* phase_name() { return "memory optimization"; } |
| 1024 |
| 1025 void Run(PipelineData* data, Zone* temp_zone) { |
| 1026 MemoryOptimizer optimizer(data->jsgraph(), temp_zone); |
| 1027 optimizer.Optimize(); |
| 1028 } |
| 1029 }; |
| 1030 |
| 1022 struct LateOptimizationPhase { | 1031 struct LateOptimizationPhase { |
| 1023 static const char* phase_name() { return "late optimization"; } | 1032 static const char* phase_name() { return "late optimization"; } |
| 1024 | 1033 |
| 1025 void Run(PipelineData* data, Zone* temp_zone) { | 1034 void Run(PipelineData* data, Zone* temp_zone) { |
| 1026 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); | 1035 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
| 1027 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), | 1036 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
| 1028 data->common()); | 1037 data->common()); |
| 1029 ValueNumberingReducer value_numbering(temp_zone); | 1038 ValueNumberingReducer value_numbering(temp_zone); |
| 1030 ChangeLowering lowering(&graph_reducer, data->jsgraph()); | |
| 1031 MachineOperatorReducer machine_reducer(data->jsgraph()); | 1039 MachineOperatorReducer machine_reducer(data->jsgraph()); |
| 1032 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), | 1040 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), |
| 1033 data->common(), data->machine()); | 1041 data->common(), data->machine()); |
| 1034 SelectLowering select_lowering(data->jsgraph()->graph(), | 1042 SelectLowering select_lowering(data->jsgraph()->graph(), |
| 1035 data->jsgraph()->common()); | 1043 data->jsgraph()->common()); |
| 1036 TailCallOptimization tco(data->common(), data->graph()); | 1044 TailCallOptimization tco(data->common(), data->graph()); |
| 1037 AddReducer(data, &graph_reducer, &dead_code_elimination); | 1045 AddReducer(data, &graph_reducer, &dead_code_elimination); |
| 1038 AddReducer(data, &graph_reducer, &value_numbering); | 1046 AddReducer(data, &graph_reducer, &value_numbering); |
| 1039 AddReducer(data, &graph_reducer, &lowering); | |
| 1040 AddReducer(data, &graph_reducer, &machine_reducer); | 1047 AddReducer(data, &graph_reducer, &machine_reducer); |
| 1041 AddReducer(data, &graph_reducer, &common_reducer); | 1048 AddReducer(data, &graph_reducer, &common_reducer); |
| 1042 AddReducer(data, &graph_reducer, &select_lowering); | 1049 AddReducer(data, &graph_reducer, &select_lowering); |
| 1043 AddReducer(data, &graph_reducer, &tco); | 1050 AddReducer(data, &graph_reducer, &tco); |
| 1044 graph_reducer.ReduceGraph(); | 1051 graph_reducer.ReduceGraph(); |
| 1045 } | 1052 } |
| 1046 }; | 1053 }; |
| 1047 | 1054 |
| 1048 struct EarlyGraphTrimmingPhase { | 1055 struct EarlyGraphTrimmingPhase { |
| 1049 static const char* phase_name() { return "early graph trimming"; } | 1056 static const char* phase_name() { return "early graph trimming"; } |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 | 1458 |
| 1452 Run<BranchEliminationPhase>(); | 1459 Run<BranchEliminationPhase>(); |
| 1453 RunPrintAndVerify("Branch conditions eliminated", true); | 1460 RunPrintAndVerify("Branch conditions eliminated", true); |
| 1454 | 1461 |
| 1455 // Optimize control flow. | 1462 // Optimize control flow. |
| 1456 if (FLAG_turbo_cf_optimization) { | 1463 if (FLAG_turbo_cf_optimization) { |
| 1457 Run<ControlFlowOptimizationPhase>(); | 1464 Run<ControlFlowOptimizationPhase>(); |
| 1458 RunPrintAndVerify("Control flow optimized", true); | 1465 RunPrintAndVerify("Control flow optimized", true); |
| 1459 } | 1466 } |
| 1460 | 1467 |
| 1468 // Optimize memory access and allocation operations. |
| 1469 Run<MemoryOptimizationPhase>(); |
| 1470 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
| 1471 RunPrintAndVerify("Memory optimized", true); |
| 1472 |
| 1461 // Lower changes that have been inserted before. | 1473 // Lower changes that have been inserted before. |
| 1462 Run<LateOptimizationPhase>(); | 1474 Run<LateOptimizationPhase>(); |
| 1463 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. | 1475 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
| 1464 RunPrintAndVerify("Late optimized", true); | 1476 RunPrintAndVerify("Late optimized", true); |
| 1465 | 1477 |
| 1466 Run<LateGraphTrimmingPhase>(); | 1478 Run<LateGraphTrimmingPhase>(); |
| 1467 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. | 1479 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
| 1468 RunPrintAndVerify("Late trimmed", true); | 1480 RunPrintAndVerify("Late trimmed", true); |
| 1469 | 1481 |
| 1470 data->source_positions()->RemoveDecorator(); | 1482 data->source_positions()->RemoveDecorator(); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1799 data->DeleteRegisterAllocationZone(); | 1811 data->DeleteRegisterAllocationZone(); |
| 1800 } | 1812 } |
| 1801 | 1813 |
| 1802 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1814 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
| 1803 | 1815 |
| 1804 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1816 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
| 1805 | 1817 |
| 1806 } // namespace compiler | 1818 } // namespace compiler |
| 1807 } // namespace internal | 1819 } // namespace internal |
| 1808 } // namespace v8 | 1820 } // namespace v8 |
| OLD | NEW |