| 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/control-reducer.h" | 19 #include "src/compiler/control-reducer.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-visualizer.h" | 23 #include "src/compiler/graph-visualizer.h" |
| 23 #include "src/compiler/greedy-allocator.h" | 24 #include "src/compiler/greedy-allocator.h" |
| 24 #include "src/compiler/instruction.h" | 25 #include "src/compiler/instruction.h" |
| 25 #include "src/compiler/instruction-selector.h" | 26 #include "src/compiler/instruction-selector.h" |
| 26 #include "src/compiler/js-builtin-reducer.h" | 27 #include "src/compiler/js-builtin-reducer.h" |
| 27 #include "src/compiler/js-context-specialization.h" | 28 #include "src/compiler/js-context-specialization.h" |
| 28 #include "src/compiler/js-generic-lowering.h" | 29 #include "src/compiler/js-generic-lowering.h" |
| 29 #include "src/compiler/js-inlining.h" | 30 #include "src/compiler/js-inlining.h" |
| 30 #include "src/compiler/js-intrinsic-lowering.h" | 31 #include "src/compiler/js-intrinsic-lowering.h" |
| 31 #include "src/compiler/js-type-feedback.h" | 32 #include "src/compiler/js-type-feedback.h" |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 | 647 |
| 647 | 648 |
| 648 struct LateControlReductionPhase { | 649 struct LateControlReductionPhase { |
| 649 static const char* phase_name() { return "late control reduction"; } | 650 static const char* phase_name() { return "late control reduction"; } |
| 650 void Run(PipelineData* data, Zone* temp_zone) { | 651 void Run(PipelineData* data, Zone* temp_zone) { |
| 651 ControlReducer::ReduceGraph(temp_zone, data->jsgraph(), 0); | 652 ControlReducer::ReduceGraph(temp_zone, data->jsgraph(), 0); |
| 652 } | 653 } |
| 653 }; | 654 }; |
| 654 | 655 |
| 655 | 656 |
| 657 struct EarlyGraphTrimmingPhase { |
| 658 static const char* phase_name() { return "early graph trimming"; } |
| 659 void Run(PipelineData* data, Zone* temp_zone) { |
| 660 GraphTrimmer trimmer(temp_zone, data->graph()); |
| 661 NodeVector roots(temp_zone); |
| 662 data->jsgraph()->GetCachedNodes(&roots); |
| 663 trimmer.TrimGraph(roots.begin(), roots.end()); |
| 664 } |
| 665 }; |
| 666 |
| 667 |
| 668 struct LateGraphTrimmingPhase { |
| 669 static const char* phase_name() { return "late graph trimming"; } |
| 670 void Run(PipelineData* data, Zone* temp_zone) { |
| 671 GraphTrimmer trimmer(temp_zone, data->graph()); |
| 672 NodeVector roots(temp_zone); |
| 673 data->jsgraph()->GetCachedNodes(&roots); |
| 674 trimmer.TrimGraph(roots.begin(), roots.end()); |
| 675 } |
| 676 }; |
| 677 |
| 678 |
| 656 struct StressLoopPeelingPhase { | 679 struct StressLoopPeelingPhase { |
| 657 static const char* phase_name() { return "stress loop peeling"; } | 680 static const char* phase_name() { return "stress loop peeling"; } |
| 658 | 681 |
| 659 void Run(PipelineData* data, Zone* temp_zone) { | 682 void Run(PipelineData* data, Zone* temp_zone) { |
| 660 // Peel the first outer loop for testing. | 683 // Peel the first outer loop for testing. |
| 661 // TODO(titzer): peel all loops? the N'th loop? Innermost loops? | 684 // TODO(titzer): peel all loops? the N'th loop? Innermost loops? |
| 662 LoopTree* loop_tree = LoopFinder::BuildLoopTree(data->graph(), temp_zone); | 685 LoopTree* loop_tree = LoopFinder::BuildLoopTree(data->graph(), temp_zone); |
| 663 if (loop_tree != NULL && loop_tree->outer_loops().size() > 0) { | 686 if (loop_tree != NULL && loop_tree->outer_loops().size() > 0) { |
| 664 LoopPeeler::Peel(data->graph(), data->common(), loop_tree, | 687 LoopPeeler::Peel(data->graph(), data->common(), loop_tree, |
| 665 loop_tree->outer_loops()[0], temp_zone); | 688 loop_tree->outer_loops()[0], temp_zone); |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 | 1040 |
| 1018 if (info()->is_context_specializing()) { | 1041 if (info()->is_context_specializing()) { |
| 1019 // Specialize the code to the context as aggressively as possible. | 1042 // Specialize the code to the context as aggressively as possible. |
| 1020 Run<ContextSpecializerPhase>(); | 1043 Run<ContextSpecializerPhase>(); |
| 1021 RunPrintAndVerify("Context specialized", true); | 1044 RunPrintAndVerify("Context specialized", true); |
| 1022 } | 1045 } |
| 1023 | 1046 |
| 1024 Run<InliningPhase>(); | 1047 Run<InliningPhase>(); |
| 1025 RunPrintAndVerify("Inlined", true); | 1048 RunPrintAndVerify("Inlined", true); |
| 1026 | 1049 |
| 1050 Run<EarlyGraphTrimmingPhase>(); |
| 1051 RunPrintAndVerify("Early trimmed", true); |
| 1052 |
| 1027 if (FLAG_print_turbo_replay) { | 1053 if (FLAG_print_turbo_replay) { |
| 1028 // Print a replay of the initial graph. | 1054 // Print a replay of the initial graph. |
| 1029 GraphReplayPrinter::PrintReplay(data.graph()); | 1055 GraphReplayPrinter::PrintReplay(data.graph()); |
| 1030 } | 1056 } |
| 1031 | 1057 |
| 1032 // Bailout here in case target architecture is not supported. | 1058 // Bailout here in case target architecture is not supported. |
| 1033 if (!SupportedTarget()) return Handle<Code>::null(); | 1059 if (!SupportedTarget()) return Handle<Code>::null(); |
| 1034 | 1060 |
| 1035 if (info()->is_typing_enabled()) { | 1061 if (info()->is_typing_enabled()) { |
| 1036 // Type the graph. | 1062 // Type the graph. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 if (info()->bailout_reason() != kNoReason) return Handle<Code>::null(); | 1109 if (info()->bailout_reason() != kNoReason) return Handle<Code>::null(); |
| 1084 RunPrintAndVerify("OSR deconstruction"); | 1110 RunPrintAndVerify("OSR deconstruction"); |
| 1085 } | 1111 } |
| 1086 } | 1112 } |
| 1087 | 1113 |
| 1088 // Lower any remaining generic JSOperators. | 1114 // Lower any remaining generic JSOperators. |
| 1089 Run<GenericLoweringPhase>(); | 1115 Run<GenericLoweringPhase>(); |
| 1090 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. | 1116 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
| 1091 RunPrintAndVerify("Lowered generic", true); | 1117 RunPrintAndVerify("Lowered generic", true); |
| 1092 | 1118 |
| 1119 Run<LateGraphTrimmingPhase>(); |
| 1120 // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. |
| 1121 RunPrintAndVerify("Late trimmed", true); |
| 1122 |
| 1093 BeginPhaseKind("block building"); | 1123 BeginPhaseKind("block building"); |
| 1094 | 1124 |
| 1095 data.source_positions()->RemoveDecorator(); | 1125 data.source_positions()->RemoveDecorator(); |
| 1096 | 1126 |
| 1097 return ScheduleAndGenerateCode( | 1127 return ScheduleAndGenerateCode( |
| 1098 Linkage::ComputeIncoming(data.instruction_zone(), info())); | 1128 Linkage::ComputeIncoming(data.instruction_zone(), info())); |
| 1099 } | 1129 } |
| 1100 | 1130 |
| 1101 | 1131 |
| 1102 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, | 1132 Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info, |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 tcf << AsC1VRegisterAllocationData("CodeGen", | 1360 tcf << AsC1VRegisterAllocationData("CodeGen", |
| 1331 data->register_allocation_data()); | 1361 data->register_allocation_data()); |
| 1332 } | 1362 } |
| 1333 | 1363 |
| 1334 data->DeleteRegisterAllocationZone(); | 1364 data->DeleteRegisterAllocationZone(); |
| 1335 } | 1365 } |
| 1336 | 1366 |
| 1337 } // namespace compiler | 1367 } // namespace compiler |
| 1338 } // namespace internal | 1368 } // namespace internal |
| 1339 } // namespace v8 | 1369 } // namespace v8 |
| OLD | NEW |