| 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-specialization.h" | 28 #include "src/compiler/js-context-specialization.h" |
| 29 #include "src/compiler/js-frame-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" |
| 38 #include "src/compiler/machine-operator-reducer.h" | 39 #include "src/compiler/machine-operator-reducer.h" |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 struct InliningPhase { | 490 struct InliningPhase { |
| 490 static const char* phase_name() { return "inlining"; } | 491 static const char* phase_name() { return "inlining"; } |
| 491 | 492 |
| 492 void Run(PipelineData* data, Zone* temp_zone) { | 493 void Run(PipelineData* data, Zone* temp_zone) { |
| 493 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); | 494 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); |
| 494 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), | 495 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), |
| 495 data->common()); | 496 data->common()); |
| 496 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), | 497 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), |
| 497 data->common(), data->machine()); | 498 data->common(), data->machine()); |
| 498 JSContextSpecializer context_specializer(&graph_reducer, data->jsgraph()); | 499 JSContextSpecializer context_specializer(&graph_reducer, data->jsgraph()); |
| 500 JSFrameSpecialization frame_specialization(data->info()->osr_frame(), |
| 501 data->jsgraph()); |
| 499 JSInliner inliner(&graph_reducer, data->info()->is_inlining_enabled() | 502 JSInliner inliner(&graph_reducer, data->info()->is_inlining_enabled() |
| 500 ? JSInliner::kGeneralInlining | 503 ? JSInliner::kGeneralInlining |
| 501 : JSInliner::kRestrictedInlining, | 504 : JSInliner::kRestrictedInlining, |
| 502 temp_zone, data->info(), data->jsgraph()); | 505 temp_zone, data->info(), data->jsgraph()); |
| 503 AddReducer(data, &graph_reducer, &dead_code_elimination); | 506 AddReducer(data, &graph_reducer, &dead_code_elimination); |
| 504 AddReducer(data, &graph_reducer, &common_reducer); | 507 AddReducer(data, &graph_reducer, &common_reducer); |
| 508 if (data->info()->is_frame_specializing()) { |
| 509 AddReducer(data, &graph_reducer, &frame_specialization); |
| 510 } |
| 505 if (data->info()->is_context_specializing()) { | 511 if (data->info()->is_context_specializing()) { |
| 506 AddReducer(data, &graph_reducer, &context_specializer); | 512 AddReducer(data, &graph_reducer, &context_specializer); |
| 507 } | 513 } |
| 508 AddReducer(data, &graph_reducer, &inliner); | 514 AddReducer(data, &graph_reducer, &inliner); |
| 509 graph_reducer.ReduceGraph(); | 515 graph_reducer.ReduceGraph(); |
| 510 } | 516 } |
| 511 }; | 517 }; |
| 512 | 518 |
| 513 | 519 |
| 514 struct TyperPhase { | 520 struct TyperPhase { |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 data.source_positions()->AddDecorator(); | 1034 data.source_positions()->AddDecorator(); |
| 1029 | 1035 |
| 1030 if (FLAG_loop_assignment_analysis) { | 1036 if (FLAG_loop_assignment_analysis) { |
| 1031 Run<LoopAssignmentAnalysisPhase>(); | 1037 Run<LoopAssignmentAnalysisPhase>(); |
| 1032 } | 1038 } |
| 1033 | 1039 |
| 1034 Run<GraphBuilderPhase>(info()->is_context_specializing()); | 1040 Run<GraphBuilderPhase>(info()->is_context_specializing()); |
| 1035 if (data.compilation_failed()) return Handle<Code>::null(); | 1041 if (data.compilation_failed()) return Handle<Code>::null(); |
| 1036 RunPrintAndVerify("Initial untyped", true); | 1042 RunPrintAndVerify("Initial untyped", true); |
| 1037 | 1043 |
| 1044 // Perform OSR deconstruction. |
| 1045 if (info()->is_osr()) { |
| 1046 Run<OsrDeconstructionPhase>(); |
| 1047 RunPrintAndVerify("OSR deconstruction", true); |
| 1048 } |
| 1049 |
| 1038 // Perform context specialization and inlining (if enabled). | 1050 // Perform context specialization and inlining (if enabled). |
| 1039 Run<InliningPhase>(); | 1051 Run<InliningPhase>(); |
| 1040 RunPrintAndVerify("Inlined", true); | 1052 RunPrintAndVerify("Inlined", true); |
| 1041 | 1053 |
| 1042 // Remove dead->live edges from the graph. | 1054 // Remove dead->live edges from the graph. |
| 1043 Run<EarlyGraphTrimmingPhase>(); | 1055 Run<EarlyGraphTrimmingPhase>(); |
| 1044 RunPrintAndVerify("Early trimmed", true); | 1056 RunPrintAndVerify("Early trimmed", true); |
| 1045 | 1057 |
| 1046 if (FLAG_print_turbo_replay) { | 1058 if (FLAG_print_turbo_replay) { |
| 1047 // Print a replay of the initial graph. | 1059 // Print a replay of the initial graph. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1064 if (info()->is_typing_enabled()) { | 1076 if (info()->is_typing_enabled()) { |
| 1065 // Lower JSOperators where we can determine types. | 1077 // Lower JSOperators where we can determine types. |
| 1066 Run<TypedLoweringPhase>(); | 1078 Run<TypedLoweringPhase>(); |
| 1067 RunPrintAndVerify("Lowered typed"); | 1079 RunPrintAndVerify("Lowered typed"); |
| 1068 | 1080 |
| 1069 if (FLAG_turbo_stress_loop_peeling) { | 1081 if (FLAG_turbo_stress_loop_peeling) { |
| 1070 Run<StressLoopPeelingPhase>(); | 1082 Run<StressLoopPeelingPhase>(); |
| 1071 RunPrintAndVerify("Loop peeled"); | 1083 RunPrintAndVerify("Loop peeled"); |
| 1072 } | 1084 } |
| 1073 | 1085 |
| 1074 if (info()->is_osr()) { | |
| 1075 Run<OsrDeconstructionPhase>(); | |
| 1076 RunPrintAndVerify("OSR deconstruction"); | |
| 1077 } | |
| 1078 | |
| 1079 if (info()->is_type_feedback_enabled()) { | 1086 if (info()->is_type_feedback_enabled()) { |
| 1080 Run<JSTypeFeedbackPhase>(); | 1087 Run<JSTypeFeedbackPhase>(); |
| 1081 RunPrintAndVerify("JSType feedback"); | 1088 RunPrintAndVerify("JSType feedback"); |
| 1082 } | 1089 } |
| 1083 | 1090 |
| 1084 // Lower simplified operators and insert changes. | 1091 // Lower simplified operators and insert changes. |
| 1085 Run<SimplifiedLoweringPhase>(); | 1092 Run<SimplifiedLoweringPhase>(); |
| 1086 RunPrintAndVerify("Lowered simplified"); | 1093 RunPrintAndVerify("Lowered simplified"); |
| 1087 | 1094 |
| 1088 // Optimize control flow. | 1095 // Optimize control flow. |
| 1089 if (FLAG_turbo_cf_optimization) { | 1096 if (FLAG_turbo_cf_optimization) { |
| 1090 Run<ControlFlowOptimizationPhase>(); | 1097 Run<ControlFlowOptimizationPhase>(); |
| 1091 RunPrintAndVerify("Control flow optimized"); | 1098 RunPrintAndVerify("Control flow optimized"); |
| 1092 } | 1099 } |
| 1093 | 1100 |
| 1094 // Lower changes that have been inserted before. | 1101 // Lower changes that have been inserted before. |
| 1095 Run<ChangeLoweringPhase>(); | 1102 Run<ChangeLoweringPhase>(); |
| 1096 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. | 1103 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
| 1097 RunPrintAndVerify("Lowered changes", true); | 1104 RunPrintAndVerify("Lowered changes", true); |
| 1098 } else { | |
| 1099 if (info()->is_osr()) { | |
| 1100 Run<OsrDeconstructionPhase>(); | |
| 1101 if (info()->bailout_reason() != kNoReason) return Handle<Code>::null(); | |
| 1102 RunPrintAndVerify("OSR deconstruction", true); | |
| 1103 } | |
| 1104 } | 1105 } |
| 1105 | 1106 |
| 1106 // Lower any remaining generic JSOperators. | 1107 // Lower any remaining generic JSOperators. |
| 1107 Run<GenericLoweringPhase>(); | 1108 Run<GenericLoweringPhase>(); |
| 1108 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. | 1109 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
| 1109 RunPrintAndVerify("Lowered generic", true); | 1110 RunPrintAndVerify("Lowered generic", true); |
| 1110 | 1111 |
| 1111 Run<LateGraphTrimmingPhase>(); | 1112 Run<LateGraphTrimmingPhase>(); |
| 1112 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. | 1113 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
| 1113 RunPrintAndVerify("Late trimmed", true); | 1114 RunPrintAndVerify("Late trimmed", true); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 tcf << AsC1VRegisterAllocationData("CodeGen", | 1356 tcf << AsC1VRegisterAllocationData("CodeGen", |
| 1356 data->register_allocation_data()); | 1357 data->register_allocation_data()); |
| 1357 } | 1358 } |
| 1358 | 1359 |
| 1359 data->DeleteRegisterAllocationZone(); | 1360 data->DeleteRegisterAllocationZone(); |
| 1360 } | 1361 } |
| 1361 | 1362 |
| 1362 } // namespace compiler | 1363 } // namespace compiler |
| 1363 } // namespace internal | 1364 } // namespace internal |
| 1364 } // namespace v8 | 1365 } // namespace v8 |
| OLD | NEW |