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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 static const char* phase_name() { return "control flow optimization"; } | 715 static const char* phase_name() { return "control flow optimization"; } |
716 | 716 |
717 void Run(PipelineData* data, Zone* temp_zone) { | 717 void Run(PipelineData* data, Zone* temp_zone) { |
718 ControlFlowOptimizer optimizer(data->graph(), data->common(), | 718 ControlFlowOptimizer optimizer(data->graph(), data->common(), |
719 data->machine(), temp_zone); | 719 data->machine(), temp_zone); |
720 optimizer.Optimize(); | 720 optimizer.Optimize(); |
721 } | 721 } |
722 }; | 722 }; |
723 | 723 |
724 | 724 |
| 725 struct ChangeLoweringPhase { |
| 726 static const char* phase_name() { return "change lowering"; } |
| 727 |
| 728 void Run(PipelineData* data, Zone* temp_zone) { |
| 729 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
| 730 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
| 731 data->common()); |
| 732 SimplifiedOperatorReducer simple_reducer(data->jsgraph()); |
| 733 ValueNumberingReducer value_numbering(temp_zone); |
| 734 ChangeLowering lowering(data->jsgraph()); |
| 735 MachineOperatorReducer machine_reducer(data->jsgraph()); |
| 736 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), |
| 737 data->common(), data->machine()); |
| 738 AddReducer(data, &graph_reducer, &dead_code_elimination); |
| 739 AddReducer(data, &graph_reducer, &simple_reducer); |
| 740 AddReducer(data, &graph_reducer, &value_numbering); |
| 741 AddReducer(data, &graph_reducer, &lowering); |
| 742 AddReducer(data, &graph_reducer, &machine_reducer); |
| 743 AddReducer(data, &graph_reducer, &common_reducer); |
| 744 graph_reducer.ReduceGraph(); |
| 745 } |
| 746 }; |
| 747 |
| 748 |
725 struct EarlyGraphTrimmingPhase { | 749 struct EarlyGraphTrimmingPhase { |
726 static const char* phase_name() { return "early graph trimming"; } | 750 static const char* phase_name() { return "early graph trimming"; } |
727 void Run(PipelineData* data, Zone* temp_zone) { | 751 void Run(PipelineData* data, Zone* temp_zone) { |
728 GraphTrimmer trimmer(temp_zone, data->graph()); | 752 GraphTrimmer trimmer(temp_zone, data->graph()); |
729 NodeVector roots(temp_zone); | 753 NodeVector roots(temp_zone); |
730 data->jsgraph()->GetCachedNodes(&roots); | 754 data->jsgraph()->GetCachedNodes(&roots); |
731 trimmer.TrimGraph(roots.begin(), roots.end()); | 755 trimmer.TrimGraph(roots.begin(), roots.end()); |
732 } | 756 } |
733 }; | 757 }; |
734 | 758 |
(...skipping 27 matching lines...) Expand all Loading... |
762 struct GenericLoweringPhase { | 786 struct GenericLoweringPhase { |
763 static const char* phase_name() { return "generic lowering"; } | 787 static const char* phase_name() { return "generic lowering"; } |
764 | 788 |
765 void Run(PipelineData* data, Zone* temp_zone) { | 789 void Run(PipelineData* data, Zone* temp_zone) { |
766 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); | 790 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
767 JSContextRelaxation context_relaxing; | 791 JSContextRelaxation context_relaxing; |
768 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), | 792 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
769 data->common()); | 793 data->common()); |
770 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), | 794 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), |
771 data->common(), data->machine()); | 795 data->common(), data->machine()); |
772 SimplifiedOperatorReducer simple_reducer(data->jsgraph()); | |
773 ValueNumberingReducer value_numbering(temp_zone); | |
774 ChangeLowering change_lowering(data->jsgraph()); | |
775 MachineOperatorReducer machine_reducer(data->jsgraph()); | |
776 JSGenericLowering generic_lowering(data->info()->is_typing_enabled(), | 796 JSGenericLowering generic_lowering(data->info()->is_typing_enabled(), |
777 data->jsgraph()); | 797 data->jsgraph()); |
778 SelectLowering select_lowering(data->jsgraph()->graph(), | 798 SelectLowering select_lowering(data->jsgraph()->graph(), |
779 data->jsgraph()->common()); | 799 data->jsgraph()->common()); |
780 TailCallOptimization tco(data->common(), data->graph()); | 800 TailCallOptimization tco(data->common(), data->graph()); |
781 AddReducer(data, &graph_reducer, &context_relaxing); | 801 AddReducer(data, &graph_reducer, &context_relaxing); |
782 AddReducer(data, &graph_reducer, &dead_code_elimination); | 802 AddReducer(data, &graph_reducer, &dead_code_elimination); |
783 AddReducer(data, &graph_reducer, &common_reducer); | 803 AddReducer(data, &graph_reducer, &common_reducer); |
784 if (data->info()->is_typing_enabled()) { | |
785 AddReducer(data, &graph_reducer, &simple_reducer); | |
786 AddReducer(data, &graph_reducer, &value_numbering); | |
787 AddReducer(data, &graph_reducer, &change_lowering); | |
788 AddReducer(data, &graph_reducer, &machine_reducer); | |
789 } | |
790 AddReducer(data, &graph_reducer, &generic_lowering); | 804 AddReducer(data, &graph_reducer, &generic_lowering); |
791 AddReducer(data, &graph_reducer, &select_lowering); | 805 AddReducer(data, &graph_reducer, &select_lowering); |
792 AddReducer(data, &graph_reducer, &tco); | 806 AddReducer(data, &graph_reducer, &tco); |
793 graph_reducer.ReduceGraph(); | 807 graph_reducer.ReduceGraph(); |
794 } | 808 } |
795 }; | 809 }; |
796 | 810 |
797 | 811 |
798 struct ComputeSchedulePhase { | 812 struct ComputeSchedulePhase { |
799 static const char* phase_name() { return "scheduling"; } | 813 static const char* phase_name() { return "scheduling"; } |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 RunPrintAndVerify("Lowered simplified"); | 1185 RunPrintAndVerify("Lowered simplified"); |
1172 | 1186 |
1173 Run<BranchEliminationPhase>(); | 1187 Run<BranchEliminationPhase>(); |
1174 RunPrintAndVerify("Branch conditions eliminated"); | 1188 RunPrintAndVerify("Branch conditions eliminated"); |
1175 | 1189 |
1176 // Optimize control flow. | 1190 // Optimize control flow. |
1177 if (FLAG_turbo_cf_optimization) { | 1191 if (FLAG_turbo_cf_optimization) { |
1178 Run<ControlFlowOptimizationPhase>(); | 1192 Run<ControlFlowOptimizationPhase>(); |
1179 RunPrintAndVerify("Control flow optimized"); | 1193 RunPrintAndVerify("Control flow optimized"); |
1180 } | 1194 } |
| 1195 |
| 1196 // Lower changes that have been inserted before. |
| 1197 Run<ChangeLoweringPhase>(); |
| 1198 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
| 1199 RunPrintAndVerify("Lowered changes", true); |
1181 } | 1200 } |
1182 | 1201 |
1183 // Lower changes inserted earlier and any remaining generic JSOperators. | 1202 // Lower any remaining generic JSOperators. |
1184 Run<GenericLoweringPhase>(); | 1203 Run<GenericLoweringPhase>(); |
1185 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. | 1204 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
1186 RunPrintAndVerify("Lowered generic", true); | 1205 RunPrintAndVerify("Lowered generic", true); |
1187 | 1206 |
1188 Run<LateGraphTrimmingPhase>(); | 1207 Run<LateGraphTrimmingPhase>(); |
1189 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. | 1208 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
1190 RunPrintAndVerify("Late trimmed", true); | 1209 RunPrintAndVerify("Late trimmed", true); |
1191 | 1210 |
1192 BeginPhaseKind("block building"); | 1211 BeginPhaseKind("block building"); |
1193 | 1212 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 } | 1500 } |
1482 | 1501 |
1483 data->DeleteRegisterAllocationZone(); | 1502 data->DeleteRegisterAllocationZone(); |
1484 } | 1503 } |
1485 | 1504 |
1486 Isolate* Pipeline::isolate() const { return info()->isolate(); } | 1505 Isolate* Pipeline::isolate() const { return info()->isolate(); } |
1487 | 1506 |
1488 } // namespace compiler | 1507 } // namespace compiler |
1489 } // namespace internal | 1508 } // namespace internal |
1490 } // namespace v8 | 1509 } // namespace v8 |
OLD | NEW |