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

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

Issue 931623002: [turbofan] Optimize certain chains of Branch into a Switch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addrssed comments. Created 5 years, 10 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
« no previous file with comments | « src/compiler/operator-properties.cc ('k') | src/compiler/raw-machine-assembler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/platform/elapsed-timer.h" 10 #include "src/base/platform/elapsed-timer.h"
11 #include "src/bootstrapper.h" // TODO(mstarzinger): Only temporary. 11 #include "src/bootstrapper.h" // TODO(mstarzinger): Only temporary.
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-reducer.h" 19 #include "src/compiler/control-reducer.h"
19 #include "src/compiler/graph-replay.h" 20 #include "src/compiler/graph-replay.h"
20 #include "src/compiler/graph-visualizer.h" 21 #include "src/compiler/graph-visualizer.h"
21 #include "src/compiler/instruction.h" 22 #include "src/compiler/instruction.h"
22 #include "src/compiler/instruction-selector.h" 23 #include "src/compiler/instruction-selector.h"
23 #include "src/compiler/js-builtin-reducer.h" 24 #include "src/compiler/js-builtin-reducer.h"
24 #include "src/compiler/js-context-specialization.h" 25 #include "src/compiler/js-context-specialization.h"
25 #include "src/compiler/js-generic-lowering.h" 26 #include "src/compiler/js-generic-lowering.h"
26 #include "src/compiler/js-inlining.h" 27 #include "src/compiler/js-inlining.h"
27 #include "src/compiler/js-intrinsic-lowering.h" 28 #include "src/compiler/js-intrinsic-lowering.h"
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 GraphReducer graph_reducer(data->graph(), temp_zone); 538 GraphReducer graph_reducer(data->graph(), temp_zone);
538 AddReducer(data, &graph_reducer, &vn_reducer); 539 AddReducer(data, &graph_reducer, &vn_reducer);
539 AddReducer(data, &graph_reducer, &simple_reducer); 540 AddReducer(data, &graph_reducer, &simple_reducer);
540 AddReducer(data, &graph_reducer, &machine_reducer); 541 AddReducer(data, &graph_reducer, &machine_reducer);
541 AddReducer(data, &graph_reducer, &common_reducer); 542 AddReducer(data, &graph_reducer, &common_reducer);
542 graph_reducer.ReduceGraph(); 543 graph_reducer.ReduceGraph();
543 } 544 }
544 }; 545 };
545 546
546 547
548 struct ControlFlowOptimizationPhase {
549 static const char* phase_name() { return "control flow optimization"; }
550
551 void Run(PipelineData* data, Zone* temp_zone) {
552 ControlFlowOptimizer optimizer(data->jsgraph(), temp_zone);
553 optimizer.Optimize();
554 }
555 };
556
557
547 struct ChangeLoweringPhase { 558 struct ChangeLoweringPhase {
548 static const char* phase_name() { return "change lowering"; } 559 static const char* phase_name() { return "change lowering"; }
549 560
550 void Run(PipelineData* data, Zone* temp_zone) { 561 void Run(PipelineData* data, Zone* temp_zone) {
551 SourcePositionTable::Scope pos(data->source_positions(), 562 SourcePositionTable::Scope pos(data->source_positions(),
552 SourcePosition::Unknown()); 563 SourcePosition::Unknown());
553 ValueNumberingReducer vn_reducer(temp_zone); 564 ValueNumberingReducer vn_reducer(temp_zone);
554 SimplifiedOperatorReducer simple_reducer(data->jsgraph()); 565 SimplifiedOperatorReducer simple_reducer(data->jsgraph());
555 ChangeLowering lowering(data->jsgraph()); 566 ChangeLowering lowering(data->jsgraph());
556 MachineOperatorReducer machine_reducer(data->jsgraph()); 567 MachineOperatorReducer machine_reducer(data->jsgraph());
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 if (info()->is_osr()) { 965 if (info()->is_osr()) {
955 Run<OsrDeconstructionPhase>(); 966 Run<OsrDeconstructionPhase>();
956 if (info()->bailout_reason() != kNoReason) return Handle<Code>::null(); 967 if (info()->bailout_reason() != kNoReason) return Handle<Code>::null();
957 RunPrintAndVerify("OSR deconstruction"); 968 RunPrintAndVerify("OSR deconstruction");
958 } 969 }
959 970
960 // Lower simplified operators and insert changes. 971 // Lower simplified operators and insert changes.
961 Run<SimplifiedLoweringPhase>(); 972 Run<SimplifiedLoweringPhase>();
962 RunPrintAndVerify("Lowered simplified"); 973 RunPrintAndVerify("Lowered simplified");
963 974
975 // Optimize control flow.
976 if (FLAG_turbo_switch) {
977 Run<ControlFlowOptimizationPhase>();
978 RunPrintAndVerify("Control flow optimized");
979 }
980
964 // Lower changes that have been inserted before. 981 // Lower changes that have been inserted before.
965 Run<ChangeLoweringPhase>(); 982 Run<ChangeLoweringPhase>();
966 // // TODO(jarin, rossberg): Remove UNTYPED once machine typing works. 983 // // TODO(jarin, rossberg): Remove UNTYPED once machine typing works.
967 RunPrintAndVerify("Lowered changes", true); 984 RunPrintAndVerify("Lowered changes", true);
968 985
969 Run<LateControlReductionPhase>(); 986 Run<LateControlReductionPhase>();
970 RunPrintAndVerify("Late Control reduced"); 987 RunPrintAndVerify("Late Control reduced");
971 } else { 988 } else {
972 if (info()->is_osr()) { 989 if (info()->is_osr()) {
973 Run<OsrDeconstructionPhase>(); 990 Run<OsrDeconstructionPhase>();
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 1211
1195 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) { 1212 if (FLAG_trace_turbo && !data->MayHaveUnverifiableGraph()) {
1196 TurboCfgFile tcf(data->isolate()); 1213 TurboCfgFile tcf(data->isolate());
1197 tcf << AsC1VAllocator("CodeGen", data->register_allocator()); 1214 tcf << AsC1VAllocator("CodeGen", data->register_allocator());
1198 } 1215 }
1199 } 1216 }
1200 1217
1201 } // namespace compiler 1218 } // namespace compiler
1202 } // namespace internal 1219 } // namespace internal
1203 } // namespace v8 1220 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/operator-properties.cc ('k') | src/compiler/raw-machine-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698