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/all-nodes.h" | |
12 #include "src/compiler/ast-graph-builder.h" | 13 #include "src/compiler/ast-graph-builder.h" |
13 #include "src/compiler/ast-loop-assignment-analyzer.h" | 14 #include "src/compiler/ast-loop-assignment-analyzer.h" |
14 #include "src/compiler/basic-block-instrumentor.h" | 15 #include "src/compiler/basic-block-instrumentor.h" |
15 #include "src/compiler/branch-elimination.h" | 16 #include "src/compiler/branch-elimination.h" |
16 #include "src/compiler/bytecode-graph-builder.h" | 17 #include "src/compiler/bytecode-graph-builder.h" |
17 #include "src/compiler/checkpoint-elimination.h" | 18 #include "src/compiler/checkpoint-elimination.h" |
18 #include "src/compiler/code-generator.h" | 19 #include "src/compiler/code-generator.h" |
19 #include "src/compiler/common-operator-reducer.h" | 20 #include "src/compiler/common-operator-reducer.h" |
20 #include "src/compiler/control-flow-optimizer.h" | 21 #include "src/compiler/control-flow-optimizer.h" |
21 #include "src/compiler/dead-code-elimination.h" | 22 #include "src/compiler/dead-code-elimination.h" |
(...skipping 28 matching lines...) Expand all Loading... | |
50 #include "src/compiler/osr.h" | 51 #include "src/compiler/osr.h" |
51 #include "src/compiler/pipeline-statistics.h" | 52 #include "src/compiler/pipeline-statistics.h" |
52 #include "src/compiler/register-allocator-verifier.h" | 53 #include "src/compiler/register-allocator-verifier.h" |
53 #include "src/compiler/register-allocator.h" | 54 #include "src/compiler/register-allocator.h" |
54 #include "src/compiler/schedule.h" | 55 #include "src/compiler/schedule.h" |
55 #include "src/compiler/scheduler.h" | 56 #include "src/compiler/scheduler.h" |
56 #include "src/compiler/select-lowering.h" | 57 #include "src/compiler/select-lowering.h" |
57 #include "src/compiler/simplified-lowering.h" | 58 #include "src/compiler/simplified-lowering.h" |
58 #include "src/compiler/simplified-operator-reducer.h" | 59 #include "src/compiler/simplified-operator-reducer.h" |
59 #include "src/compiler/simplified-operator.h" | 60 #include "src/compiler/simplified-operator.h" |
61 #include "src/compiler/store-store-elimination.h" | |
60 #include "src/compiler/tail-call-optimization.h" | 62 #include "src/compiler/tail-call-optimization.h" |
61 #include "src/compiler/type-hint-analyzer.h" | 63 #include "src/compiler/type-hint-analyzer.h" |
62 #include "src/compiler/typer.h" | 64 #include "src/compiler/typer.h" |
63 #include "src/compiler/value-numbering-reducer.h" | 65 #include "src/compiler/value-numbering-reducer.h" |
64 #include "src/compiler/verifier.h" | 66 #include "src/compiler/verifier.h" |
65 #include "src/compiler/zone-pool.h" | 67 #include "src/compiler/zone-pool.h" |
66 #include "src/isolate-inl.h" | 68 #include "src/isolate-inl.h" |
67 #include "src/ostreams.h" | 69 #include "src/ostreams.h" |
68 #include "src/parsing/parser.h" | 70 #include "src/parsing/parser.h" |
69 #include "src/register-configuration.h" | 71 #include "src/register-configuration.h" |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1021 // Post-pass for wiring the control/effects | 1023 // Post-pass for wiring the control/effects |
1022 // - connect allocating representation changes into the control&effect | 1024 // - connect allocating representation changes into the control&effect |
1023 // chains and lower them, | 1025 // chains and lower them, |
1024 // - get rid of the region markers, | 1026 // - get rid of the region markers, |
1025 // - introduce effect phis and rewire effects to get SSA again. | 1027 // - introduce effect phis and rewire effects to get SSA again. |
1026 EffectControlLinearizer linearizer(data->jsgraph(), schedule, temp_zone); | 1028 EffectControlLinearizer linearizer(data->jsgraph(), schedule, temp_zone); |
1027 linearizer.Run(); | 1029 linearizer.Run(); |
1028 } | 1030 } |
1029 }; | 1031 }; |
1030 | 1032 |
1033 struct StoreStoreEliminationPhase { | |
1034 static const char* phase_name() { return "Store-store elimination"; } | |
1035 | |
1036 void Run(PipelineData* data, Zone* temp_zone) { | |
1037 StoreStoreElimination store_store_elimination(data->jsgraph(), temp_zone); | |
1038 | |
1039 // The store-store elimination does work on chains of certain types of | |
1040 // nodes. The elimination must be invoked on the lowest node in such a | |
1041 // chain; we have a helper function IsEligibleNode that returns true | |
1042 // precisely on the lowest node in such a chain. | |
1043 // | |
1044 // Because the elimination removes nodes from the graph, even remove nodes | |
1045 // that the elimination was not invoked on, we cannot use a normal | |
1046 // AdvancedReducer but we manually find which nodes to invoke the | |
1047 // elimination on. Then in a next step, we invoke the elimination for each | |
1048 // node that was eligible. | |
1049 | |
1050 NodeVector eligible(temp_zone); | |
Jarin
2016/06/21 13:28:32
Could we move this code into the StoreStoreElimina
bgeron
2016/06/21 17:48:58
Done.
| |
1051 | |
1052 for (Node* node : MarkingPreDFS(data->jsgraph()->graph())) { | |
1053 if (StoreStoreElimination::IsEligibleNode(node)) { | |
1054 eligible.push_back(node); | |
1055 } | |
1056 } | |
1057 | |
1058 for (Node* node : eligible) { | |
1059 store_store_elimination.ReduceEligibleNode(node); | |
1060 } | |
1061 } | |
1062 }; | |
1063 | |
1031 struct MemoryOptimizationPhase { | 1064 struct MemoryOptimizationPhase { |
1032 static const char* phase_name() { return "memory optimization"; } | 1065 static const char* phase_name() { return "memory optimization"; } |
1033 | 1066 |
1034 void Run(PipelineData* data, Zone* temp_zone) { | 1067 void Run(PipelineData* data, Zone* temp_zone) { |
1035 MemoryOptimizer optimizer(data->jsgraph(), temp_zone); | 1068 MemoryOptimizer optimizer(data->jsgraph(), temp_zone); |
1036 optimizer.Optimize(); | 1069 optimizer.Optimize(); |
1037 } | 1070 } |
1038 }; | 1071 }; |
1039 | 1072 |
1040 struct LateOptimizationPhase { | 1073 struct LateOptimizationPhase { |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1457 } | 1490 } |
1458 | 1491 |
1459 bool PipelineImpl::OptimizeGraph(Linkage* linkage) { | 1492 bool PipelineImpl::OptimizeGraph(Linkage* linkage) { |
1460 PipelineData* data = this->data_; | 1493 PipelineData* data = this->data_; |
1461 | 1494 |
1462 data->BeginPhaseKind("block building"); | 1495 data->BeginPhaseKind("block building"); |
1463 | 1496 |
1464 Run<EffectControlLinearizationPhase>(); | 1497 Run<EffectControlLinearizationPhase>(); |
1465 RunPrintAndVerify("Effect and control linearized", true); | 1498 RunPrintAndVerify("Effect and control linearized", true); |
1466 | 1499 |
1500 Run<StoreStoreEliminationPhase>(); | |
1501 RunPrintAndVerify("Store-store elimination", true); | |
1502 | |
1467 Run<BranchEliminationPhase>(); | 1503 Run<BranchEliminationPhase>(); |
1468 RunPrintAndVerify("Branch conditions eliminated", true); | 1504 RunPrintAndVerify("Branch conditions eliminated", true); |
1469 | 1505 |
1470 // Optimize control flow. | 1506 // Optimize control flow. |
1471 if (FLAG_turbo_cf_optimization) { | 1507 if (FLAG_turbo_cf_optimization) { |
1472 Run<ControlFlowOptimizationPhase>(); | 1508 Run<ControlFlowOptimizationPhase>(); |
1473 RunPrintAndVerify("Control flow optimized", true); | 1509 RunPrintAndVerify("Control flow optimized", true); |
1474 } | 1510 } |
1475 | 1511 |
1476 // Optimize memory access and allocation operations. | 1512 // Optimize memory access and allocation operations. |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1805 data->DeleteRegisterAllocationZone(); | 1841 data->DeleteRegisterAllocationZone(); |
1806 } | 1842 } |
1807 | 1843 |
1808 CompilationInfo* PipelineImpl::info() const { return data_->info(); } | 1844 CompilationInfo* PipelineImpl::info() const { return data_->info(); } |
1809 | 1845 |
1810 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } | 1846 Isolate* PipelineImpl::isolate() const { return info()->isolate(); } |
1811 | 1847 |
1812 } // namespace compiler | 1848 } // namespace compiler |
1813 } // namespace internal | 1849 } // namespace internal |
1814 } // namespace v8 | 1850 } // namespace v8 |
OLD | NEW |