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