Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: src/compiler/pipeline.cc

Issue 1849603002: [turbofan] Effect linearization after representation inference. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Attempt to fix gn Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/branch-elimination.h" 15 #include "src/compiler/branch-elimination.h"
16 #include "src/compiler/bytecode-graph-builder.h" 16 #include "src/compiler/bytecode-graph-builder.h"
17 #include "src/compiler/change-lowering.h" 17 #include "src/compiler/change-lowering.h"
18 #include "src/compiler/code-generator.h" 18 #include "src/compiler/code-generator.h"
19 #include "src/compiler/common-operator-reducer.h" 19 #include "src/compiler/common-operator-reducer.h"
20 #include "src/compiler/control-flow-optimizer.h" 20 #include "src/compiler/control-flow-optimizer.h"
21 #include "src/compiler/dead-code-elimination.h" 21 #include "src/compiler/dead-code-elimination.h"
22 #include "src/compiler/effect-control-linearizer.h"
22 #include "src/compiler/escape-analysis-reducer.h" 23 #include "src/compiler/escape-analysis-reducer.h"
23 #include "src/compiler/escape-analysis.h" 24 #include "src/compiler/escape-analysis.h"
24 #include "src/compiler/frame-elider.h" 25 #include "src/compiler/frame-elider.h"
25 #include "src/compiler/graph-replay.h" 26 #include "src/compiler/graph-replay.h"
26 #include "src/compiler/graph-trimmer.h" 27 #include "src/compiler/graph-trimmer.h"
27 #include "src/compiler/graph-visualizer.h" 28 #include "src/compiler/graph-visualizer.h"
28 #include "src/compiler/greedy-allocator.h" 29 #include "src/compiler/greedy-allocator.h"
29 #include "src/compiler/instruction-selector.h" 30 #include "src/compiler/instruction-selector.h"
30 #include "src/compiler/instruction.h" 31 #include "src/compiler/instruction.h"
31 #include "src/compiler/js-builtin-reducer.h" 32 #include "src/compiler/js-builtin-reducer.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 void set_type_hint_analysis(TypeHintAnalysis* type_hint_analysis) { 219 void set_type_hint_analysis(TypeHintAnalysis* type_hint_analysis) {
219 DCHECK_NULL(type_hint_analysis_); 220 DCHECK_NULL(type_hint_analysis_);
220 type_hint_analysis_ = type_hint_analysis; 221 type_hint_analysis_ = type_hint_analysis;
221 } 222 }
222 223
223 Schedule* schedule() const { return schedule_; } 224 Schedule* schedule() const { return schedule_; }
224 void set_schedule(Schedule* schedule) { 225 void set_schedule(Schedule* schedule) {
225 DCHECK(!schedule_); 226 DCHECK(!schedule_);
226 schedule_ = schedule; 227 schedule_ = schedule;
227 } 228 }
229 void reset_schedule() { schedule_ = nullptr; }
228 230
229 Zone* instruction_zone() const { return instruction_zone_; } 231 Zone* instruction_zone() const { return instruction_zone_; }
230 InstructionSequence* sequence() const { return sequence_; } 232 InstructionSequence* sequence() const { return sequence_; }
231 Frame* frame() const { return frame_; } 233 Frame* frame() const { return frame_; }
232 234
233 Zone* register_allocation_zone() const { return register_allocation_zone_; } 235 Zone* register_allocation_zone() const { return register_allocation_zone_; }
234 RegisterAllocationData* register_allocation_data() const { 236 RegisterAllocationData* register_allocation_data() const {
235 return register_allocation_data_; 237 return register_allocation_data_;
236 } 238 }
237 239
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 struct ControlFlowOptimizationPhase { 794 struct ControlFlowOptimizationPhase {
793 static const char* phase_name() { return "control flow optimization"; } 795 static const char* phase_name() { return "control flow optimization"; }
794 796
795 void Run(PipelineData* data, Zone* temp_zone) { 797 void Run(PipelineData* data, Zone* temp_zone) {
796 ControlFlowOptimizer optimizer(data->graph(), data->common(), 798 ControlFlowOptimizer optimizer(data->graph(), data->common(),
797 data->machine(), temp_zone); 799 data->machine(), temp_zone);
798 optimizer.Optimize(); 800 optimizer.Optimize();
799 } 801 }
800 }; 802 };
801 803
804 struct FixLowLevelEffectsPhase {
Benedikt Meurer 2016/04/18 04:34:18 Can we have a single ControlEffectLinearizationPha
Jarin 2016/04/18 07:53:33 Done.
805 static const char* phase_name() { return "low-level effect wiring"; }
806
807 void Run(PipelineData* data, Zone* temp_zone) {
808 EffectControlLinearizer introducer(data->jsgraph(), data->schedule(),
809 temp_zone);
810 introducer.Run();
811 }
812 };
802 813
803 struct ChangeLoweringPhase { 814 struct ChangeLoweringPhase {
804 static const char* phase_name() { return "change lowering"; } 815 static const char* phase_name() { return "change lowering"; }
805 816
806 void Run(PipelineData* data, Zone* temp_zone) { 817 void Run(PipelineData* data, Zone* temp_zone) {
807 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); 818 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
808 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), 819 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(),
809 data->common()); 820 data->common());
810 SimplifiedOperatorReducer simple_reducer(data->jsgraph()); 821 SimplifiedOperatorReducer simple_reducer(data->jsgraph());
811 ValueNumberingReducer value_numbering(temp_zone); 822 ValueNumberingReducer value_numbering(temp_zone);
812 ChangeLowering lowering(data->jsgraph()); 823 ChangeLowering lowering(data->jsgraph());
813 MachineOperatorReducer machine_reducer(data->jsgraph()); 824 MachineOperatorReducer machine_reducer(data->jsgraph());
814 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), 825 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(),
815 data->common(), data->machine()); 826 data->common(), data->machine());
816 AddReducer(data, &graph_reducer, &dead_code_elimination); 827 AddReducer(data, &graph_reducer, &dead_code_elimination);
817 AddReducer(data, &graph_reducer, &simple_reducer); 828 AddReducer(data, &graph_reducer, &simple_reducer);
818 AddReducer(data, &graph_reducer, &value_numbering); 829 AddReducer(data, &graph_reducer, &value_numbering);
819 AddReducer(data, &graph_reducer, &lowering); 830 AddReducer(data, &graph_reducer, &lowering);
820 AddReducer(data, &graph_reducer, &machine_reducer); 831 AddReducer(data, &graph_reducer, &machine_reducer);
821 AddReducer(data, &graph_reducer, &common_reducer); 832 AddReducer(data, &graph_reducer, &common_reducer);
822 graph_reducer.ReduceGraph(); 833 graph_reducer.ReduceGraph();
823 } 834 }
824 }; 835 };
825 836
837 struct ComputeEffectSchedulePhase {
838 static const char* phase_name() { return "effect scheduling"; }
839
840 void Run(PipelineData* data, Zone* temp_zone) {
841 Schedule* schedule = Scheduler::ComputeSchedule(temp_zone, data->graph(),
842 Scheduler::kNoFlags);
843 if (FLAG_turbo_verify) ScheduleVerifier::Run(schedule);
844 data->set_schedule(schedule);
845 }
846 };
847
848 struct EffectScheduleTrimmingPhase {
Benedikt Meurer 2016/04/18 04:34:18 Can you put a TODO on this guy, that we only need
Jarin 2016/04/18 07:53:33 Done.
849 static const char* phase_name() { return "effect schedule graph trimming"; }
850 void Run(PipelineData* data, Zone* temp_zone) {
851 GraphTrimmer trimmer(temp_zone, data->graph());
852 NodeVector roots(temp_zone);
853 data->jsgraph()->GetCachedNodes(&roots);
854 trimmer.TrimGraph(roots.begin(), roots.end());
855 }
856 };
826 857
827 struct EarlyGraphTrimmingPhase { 858 struct EarlyGraphTrimmingPhase {
828 static const char* phase_name() { return "early graph trimming"; } 859 static const char* phase_name() { return "early graph trimming"; }
829 void Run(PipelineData* data, Zone* temp_zone) { 860 void Run(PipelineData* data, Zone* temp_zone) {
830 GraphTrimmer trimmer(temp_zone, data->graph()); 861 GraphTrimmer trimmer(temp_zone, data->graph());
831 NodeVector roots(temp_zone); 862 NodeVector roots(temp_zone);
832 data->jsgraph()->GetCachedNodes(&roots); 863 data->jsgraph()->GetCachedNodes(&roots);
833 trimmer.TrimGraph(roots.begin(), roots.end()); 864 trimmer.TrimGraph(roots.begin(), roots.end());
834 } 865 }
835 }; 866 };
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 1275
1245 if (FLAG_turbo_escape) { 1276 if (FLAG_turbo_escape) {
1246 Run<EscapeAnalysisPhase>(); 1277 Run<EscapeAnalysisPhase>();
1247 RunPrintAndVerify("Escape Analysed"); 1278 RunPrintAndVerify("Escape Analysed");
1248 } 1279 }
1249 1280
1250 // Lower simplified operators and insert changes. 1281 // Lower simplified operators and insert changes.
1251 Run<SimplifiedLoweringPhase>(); 1282 Run<SimplifiedLoweringPhase>();
1252 RunPrintAndVerify("Lowered simplified"); 1283 RunPrintAndVerify("Lowered simplified");
1253 1284
1285 if (!info()->shared_info()->asm_function()) {
Benedikt Meurer 2016/04/18 04:34:18 How bad is this actually for asm.js functions?
1286 // TODO(jarin) Run value numbering for the representation changes.
1287
1288 // The scheduler requires the graphs to be trimmed, so trim now.
1289 Run<EffectScheduleTrimmingPhase>();
1290
1291 // Schedule the graph without node splitting so that we can
1292 // fix the effect and control flow for nodes with low-level side
1293 // effects (such as changing representation to tagged or
1294 // 'floating' allocation regions.)
1295 Run<ComputeEffectSchedulePhase>();
1296
1297 // Post-pass for wiring the control/effects
1298 // - connect allocating representation changes into the control&effect
1299 // chains and lower them,
1300 // - get rid of the region markers,
1301 // - introduce effect phis and rewire effects to get SSA again.
1302 Run<FixLowLevelEffectsPhase>();
1303
1304 // Get rid of the schedule.
1305 // TODO(jarin) We should produce the schedule in a temporary zone.
1306 data.reset_schedule();
1307 RunPrintAndVerify("Fixed state flow");
1308 }
1309
1254 Run<BranchEliminationPhase>(); 1310 Run<BranchEliminationPhase>();
1255 RunPrintAndVerify("Branch conditions eliminated"); 1311 RunPrintAndVerify("Branch conditions eliminated");
1256 1312
1257 // Optimize control flow. 1313 // Optimize control flow.
1258 if (FLAG_turbo_cf_optimization) { 1314 if (FLAG_turbo_cf_optimization) {
1259 Run<ControlFlowOptimizationPhase>(); 1315 Run<ControlFlowOptimizationPhase>();
1260 RunPrintAndVerify("Control flow optimized"); 1316 RunPrintAndVerify("Control flow optimized");
1261 } 1317 }
1262 1318
1263 // Lower changes that have been inserted before. 1319 // Lower changes that have been inserted before.
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 } 1620 }
1565 1621
1566 data->DeleteRegisterAllocationZone(); 1622 data->DeleteRegisterAllocationZone();
1567 } 1623 }
1568 1624
1569 Isolate* Pipeline::isolate() const { return info()->isolate(); } 1625 Isolate* Pipeline::isolate() const { return info()->isolate(); }
1570 1626
1571 } // namespace compiler 1627 } // namespace compiler
1572 } // namespace internal 1628 } // namespace internal
1573 } // namespace v8 1629 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698