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

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

Issue 1220823004: [turbofan]: Add a context relaxation Reducer (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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/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/context-relaxation.h"
18 #include "src/compiler/control-flow-optimizer.h" 19 #include "src/compiler/control-flow-optimizer.h"
19 #include "src/compiler/dead-code-elimination.h" 20 #include "src/compiler/dead-code-elimination.h"
20 #include "src/compiler/frame-elider.h" 21 #include "src/compiler/frame-elider.h"
21 #include "src/compiler/graph-replay.h" 22 #include "src/compiler/graph-replay.h"
22 #include "src/compiler/graph-trimmer.h" 23 #include "src/compiler/graph-trimmer.h"
23 #include "src/compiler/graph-visualizer.h" 24 #include "src/compiler/graph-visualizer.h"
24 #include "src/compiler/greedy-allocator.h" 25 #include "src/compiler/greedy-allocator.h"
25 #include "src/compiler/instruction.h" 26 #include "src/compiler/instruction.h"
26 #include "src/compiler/instruction-selector.h" 27 #include "src/compiler/instruction-selector.h"
27 #include "src/compiler/js-builtin-reducer.h" 28 #include "src/compiler/js-builtin-reducer.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 code_(Handle<Code>::null()), 74 code_(Handle<Code>::null()),
74 graph_zone_scope_(zone_pool_), 75 graph_zone_scope_(zone_pool_),
75 graph_zone_(graph_zone_scope_.zone()), 76 graph_zone_(graph_zone_scope_.zone()),
76 graph_(nullptr), 77 graph_(nullptr),
77 loop_assignment_(nullptr), 78 loop_assignment_(nullptr),
78 machine_(nullptr), 79 machine_(nullptr),
79 common_(nullptr), 80 common_(nullptr),
80 javascript_(nullptr), 81 javascript_(nullptr),
81 jsgraph_(nullptr), 82 jsgraph_(nullptr),
82 js_type_feedback_(nullptr), 83 js_type_feedback_(nullptr),
84 relaxed_context_(nullptr),
83 schedule_(nullptr), 85 schedule_(nullptr),
84 instruction_zone_scope_(zone_pool_), 86 instruction_zone_scope_(zone_pool_),
85 instruction_zone_(instruction_zone_scope_.zone()), 87 instruction_zone_(instruction_zone_scope_.zone()),
86 sequence_(nullptr), 88 sequence_(nullptr),
87 frame_(nullptr), 89 frame_(nullptr),
88 register_allocation_zone_scope_(zone_pool_), 90 register_allocation_zone_scope_(zone_pool_),
89 register_allocation_zone_(register_allocation_zone_scope_.zone()), 91 register_allocation_zone_(register_allocation_zone_scope_.zone()),
90 register_allocation_data_(nullptr) { 92 register_allocation_data_(nullptr) {
91 PhaseScope scope(pipeline_statistics, "init pipeline data"); 93 PhaseScope scope(pipeline_statistics, "init pipeline data");
92 graph_ = new (graph_zone_) Graph(graph_zone_); 94 graph_ = new (graph_zone_) Graph(graph_zone_);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 return source_positions_.get(); 186 return source_positions_.get();
185 } 187 }
186 MachineOperatorBuilder* machine() const { return machine_; } 188 MachineOperatorBuilder* machine() const { return machine_; }
187 CommonOperatorBuilder* common() const { return common_; } 189 CommonOperatorBuilder* common() const { return common_; }
188 JSOperatorBuilder* javascript() const { return javascript_; } 190 JSOperatorBuilder* javascript() const { return javascript_; }
189 JSGraph* jsgraph() const { return jsgraph_; } 191 JSGraph* jsgraph() const { return jsgraph_; }
190 JSTypeFeedbackTable* js_type_feedback() { return js_type_feedback_; } 192 JSTypeFeedbackTable* js_type_feedback() { return js_type_feedback_; }
191 void set_js_type_feedback(JSTypeFeedbackTable* js_type_feedback) { 193 void set_js_type_feedback(JSTypeFeedbackTable* js_type_feedback) {
192 js_type_feedback_ = js_type_feedback; 194 js_type_feedback_ = js_type_feedback;
193 } 195 }
196 Node* relaxed_context() const { return relaxed_context_; }
197 void set_relaxed_context(Node* relaxed_context) {
198 relaxed_context_ = relaxed_context;
199 }
194 200
195 LoopAssignmentAnalysis* loop_assignment() const { return loop_assignment_; } 201 LoopAssignmentAnalysis* loop_assignment() const { return loop_assignment_; }
196 void set_loop_assignment(LoopAssignmentAnalysis* loop_assignment) { 202 void set_loop_assignment(LoopAssignmentAnalysis* loop_assignment) {
197 DCHECK(!loop_assignment_); 203 DCHECK(!loop_assignment_);
198 loop_assignment_ = loop_assignment; 204 loop_assignment_ = loop_assignment;
199 } 205 }
200 206
201 Schedule* schedule() const { return schedule_; } 207 Schedule* schedule() const { return schedule_; }
202 void set_schedule(Schedule* schedule) { 208 void set_schedule(Schedule* schedule) {
203 DCHECK(!schedule_); 209 DCHECK(!schedule_);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 Zone* graph_zone_; 285 Zone* graph_zone_;
280 Graph* graph_; 286 Graph* graph_;
281 // TODO(dcarney): make this into a ZoneObject. 287 // TODO(dcarney): make this into a ZoneObject.
282 SmartPointer<SourcePositionTable> source_positions_; 288 SmartPointer<SourcePositionTable> source_positions_;
283 LoopAssignmentAnalysis* loop_assignment_; 289 LoopAssignmentAnalysis* loop_assignment_;
284 MachineOperatorBuilder* machine_; 290 MachineOperatorBuilder* machine_;
285 CommonOperatorBuilder* common_; 291 CommonOperatorBuilder* common_;
286 JSOperatorBuilder* javascript_; 292 JSOperatorBuilder* javascript_;
287 JSGraph* jsgraph_; 293 JSGraph* jsgraph_;
288 JSTypeFeedbackTable* js_type_feedback_; 294 JSTypeFeedbackTable* js_type_feedback_;
295 Node* relaxed_context_;
Michael Starzinger 2015/07/02 10:29:26 nit: Please reset this to {nullptr} in PipelineDat
289 Schedule* schedule_; 296 Schedule* schedule_;
290 297
291 // All objects in the following group of fields are allocated in 298 // All objects in the following group of fields are allocated in
292 // instruction_zone_. They are all set to NULL when the instruction_zone_ is 299 // instruction_zone_. They are all set to NULL when the instruction_zone_ is
293 // destroyed. 300 // destroyed.
294 ZonePool::Scope instruction_zone_scope_; 301 ZonePool::Scope instruction_zone_scope_;
295 Zone* instruction_zone_; 302 Zone* instruction_zone_;
296 InstructionSequence* sequence_; 303 InstructionSequence* sequence_;
297 Frame* frame_; 304 Frame* frame_;
298 305
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 379
373 #define DEF_VISIT(type) \ 380 #define DEF_VISIT(type) \
374 void Visit##type(type* node) override { \ 381 void Visit##type(type* node) override { \
375 SourcePositionTable::Scope pos(source_positions_, \ 382 SourcePositionTable::Scope pos(source_positions_, \
376 SourcePosition(node->position())); \ 383 SourcePosition(node->position())); \
377 AstGraphBuilder::Visit##type(node); \ 384 AstGraphBuilder::Visit##type(node); \
378 } 385 }
379 AST_NODE_LIST(DEF_VISIT) 386 AST_NODE_LIST(DEF_VISIT)
380 #undef DEF_VISIT 387 #undef DEF_VISIT
381 388
389 using AstGraphBuilder::relaxed_context;
390
382 private: 391 private:
383 SourcePositionTable* const source_positions_; 392 SourcePositionTable* const source_positions_;
384 SourcePosition const start_position_; 393 SourcePosition const start_position_;
385 }; 394 };
386 395
387 396
388 class SourcePositionWrapper final : public Reducer { 397 class SourcePositionWrapper final : public Reducer {
389 public: 398 public:
390 SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table) 399 SourcePositionWrapper(Reducer* reducer, SourcePositionTable* table)
391 : reducer_(reducer), table_(table) {} 400 : reducer_(reducer), table_(table) {}
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 static const char* phase_name() { return "graph builder"; } 484 static const char* phase_name() { return "graph builder"; }
476 485
477 void Run(PipelineData* data, Zone* temp_zone, bool constant_context) { 486 void Run(PipelineData* data, Zone* temp_zone, bool constant_context) {
478 AstGraphBuilderWithPositions graph_builder( 487 AstGraphBuilderWithPositions graph_builder(
479 temp_zone, data->info(), data->jsgraph(), data->loop_assignment(), 488 temp_zone, data->info(), data->jsgraph(), data->loop_assignment(),
480 data->js_type_feedback(), data->source_positions()); 489 data->js_type_feedback(), data->source_positions());
481 bool stack_check = !data->info()->IsStub(); 490 bool stack_check = !data->info()->IsStub();
482 if (!graph_builder.CreateGraph(constant_context, stack_check)) { 491 if (!graph_builder.CreateGraph(constant_context, stack_check)) {
483 data->set_compilation_failed(); 492 data->set_compilation_failed();
484 } 493 }
494 data->set_relaxed_context(graph_builder.relaxed_context());
485 } 495 }
486 }; 496 };
487 497
488 498
489 struct InliningPhase { 499 struct InliningPhase {
490 static const char* phase_name() { return "inlining"; } 500 static const char* phase_name() { return "inlining"; }
491 501
492 void Run(PipelineData* data, Zone* temp_zone) { 502 void Run(PipelineData* data, Zone* temp_zone) {
493 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); 503 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
494 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), 504 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(),
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 } 693 }
684 } 694 }
685 }; 695 };
686 696
687 697
688 struct GenericLoweringPhase { 698 struct GenericLoweringPhase {
689 static const char* phase_name() { return "generic lowering"; } 699 static const char* phase_name() { return "generic lowering"; }
690 700
691 void Run(PipelineData* data, Zone* temp_zone) { 701 void Run(PipelineData* data, Zone* temp_zone) {
692 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone); 702 JSGraphReducer graph_reducer(data->jsgraph(), temp_zone);
703 ContextRelaxation relaxing(data->graph()->start(), data->relaxed_context());
693 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(), 704 DeadCodeElimination dead_code_elimination(&graph_reducer, data->graph(),
694 data->common()); 705 data->common());
695 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(), 706 CommonOperatorReducer common_reducer(&graph_reducer, data->graph(),
696 data->common(), data->machine()); 707 data->common(), data->machine());
697 JSGenericLowering generic_lowering(data->info()->is_typing_enabled(), 708 JSGenericLowering generic_lowering(data->info()->is_typing_enabled(),
698 data->jsgraph()); 709 data->jsgraph());
699 SelectLowering select_lowering(data->jsgraph()->graph(), 710 SelectLowering select_lowering(data->jsgraph()->graph(),
700 data->jsgraph()->common()); 711 data->jsgraph()->common());
701 TailCallOptimization tco(data->common(), data->graph()); 712 TailCallOptimization tco(data->common(), data->graph());
713 AddReducer(data, &graph_reducer, &relaxing);
702 AddReducer(data, &graph_reducer, &dead_code_elimination); 714 AddReducer(data, &graph_reducer, &dead_code_elimination);
703 AddReducer(data, &graph_reducer, &common_reducer); 715 AddReducer(data, &graph_reducer, &common_reducer);
704 AddReducer(data, &graph_reducer, &generic_lowering); 716 AddReducer(data, &graph_reducer, &generic_lowering);
705 AddReducer(data, &graph_reducer, &select_lowering); 717 AddReducer(data, &graph_reducer, &select_lowering);
706 // TODO(turbofan): TCO is currently limited to stubs. 718 // TODO(turbofan): TCO is currently limited to stubs.
707 if (data->info()->IsStub()) AddReducer(data, &graph_reducer, &tco); 719 if (data->info()->IsStub()) AddReducer(data, &graph_reducer, &tco);
708 graph_reducer.ReduceGraph(); 720 graph_reducer.ReduceGraph();
709 } 721 }
710 }; 722 };
711 723
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 tcf << AsC1VRegisterAllocationData("CodeGen", 1368 tcf << AsC1VRegisterAllocationData("CodeGen",
1357 data->register_allocation_data()); 1369 data->register_allocation_data());
1358 } 1370 }
1359 1371
1360 data->DeleteRegisterAllocationZone(); 1372 data->DeleteRegisterAllocationZone();
1361 } 1373 }
1362 1374
1363 } // namespace compiler 1375 } // namespace compiler
1364 } // namespace internal 1376 } // namespace internal
1365 } // namespace v8 1377 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698