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

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

Issue 753063004: Switch CFGBuilder to use NodeMarker. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_scheduler-minimal
Patch Set: Rebased. Created 6 years 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/scheduler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <deque> 5 #include <deque>
6 #include <queue> 6 #include <queue>
7 7
8 #include "src/compiler/scheduler.h" 8 #include "src/compiler/scheduler.h"
9 9
10 #include "src/bit-vector.h" 10 #include "src/bit-vector.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 scheduler.ScheduleEarly(); 52 scheduler.ScheduleEarly();
53 scheduler.ScheduleLate(); 53 scheduler.ScheduleLate();
54 54
55 scheduler.SealFinalSchedule(); 55 scheduler.SealFinalSchedule();
56 56
57 return schedule; 57 return schedule;
58 } 58 }
59 59
60 60
61 Scheduler::SchedulerData Scheduler::DefaultSchedulerData() { 61 Scheduler::SchedulerData Scheduler::DefaultSchedulerData() {
62 SchedulerData def = {schedule_->start(), 0, false, kUnknown}; 62 SchedulerData def = {schedule_->start(), 0, kUnknown};
63 return def; 63 return def;
64 } 64 }
65 65
66 66
67 Scheduler::SchedulerData* Scheduler::GetData(Node* node) { 67 Scheduler::SchedulerData* Scheduler::GetData(Node* node) {
68 DCHECK(node->id() < static_cast<int>(node_data_.size())); 68 DCHECK(node->id() < static_cast<int>(node_data_.size()));
69 return &node_data_[node->id()]; 69 return &node_data_[node->id()];
70 } 70 }
71 71
72 72
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 228
229 // Internal class to build a control flow graph (i.e the basic blocks and edges 229 // Internal class to build a control flow graph (i.e the basic blocks and edges
230 // between them within a Schedule) from the node graph. Visits control edges of 230 // between them within a Schedule) from the node graph. Visits control edges of
231 // the graph backwards from an end node in order to find the connected control 231 // the graph backwards from an end node in order to find the connected control
232 // subgraph, needed for scheduling. 232 // subgraph, needed for scheduling.
233 class CFGBuilder : public ZoneObject { 233 class CFGBuilder : public ZoneObject {
234 public: 234 public:
235 CFGBuilder(Zone* zone, Scheduler* scheduler) 235 CFGBuilder(Zone* zone, Scheduler* scheduler)
236 : scheduler_(scheduler), 236 : scheduler_(scheduler),
237 schedule_(scheduler->schedule_), 237 schedule_(scheduler->schedule_),
238 queued_(scheduler->graph_, 2),
238 queue_(zone), 239 queue_(zone),
239 control_(zone), 240 control_(zone),
240 component_entry_(NULL), 241 component_entry_(NULL),
241 component_start_(NULL), 242 component_start_(NULL),
242 component_end_(NULL) {} 243 component_end_(NULL) {}
243 244
244 // Run the control flow graph construction algorithm by walking the graph 245 // Run the control flow graph construction algorithm by walking the graph
245 // backwards from end through control edges, building and connecting the 246 // backwards from end through control edges, building and connecting the
246 // basic blocks for control nodes. 247 // basic blocks for control nodes.
247 void Run() { 248 void Run() {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 // TODO(mstarzinger): Only for Scheduler::FuseFloatingControl. 303 // TODO(mstarzinger): Only for Scheduler::FuseFloatingControl.
303 friend class Scheduler; 304 friend class Scheduler;
304 305
305 void FixNode(BasicBlock* block, Node* node) { 306 void FixNode(BasicBlock* block, Node* node) {
306 schedule_->AddNode(block, node); 307 schedule_->AddNode(block, node);
307 scheduler_->UpdatePlacement(node, Scheduler::kFixed); 308 scheduler_->UpdatePlacement(node, Scheduler::kFixed);
308 } 309 }
309 310
310 void Queue(Node* node) { 311 void Queue(Node* node) {
311 // Mark the connected control nodes as they are queued. 312 // Mark the connected control nodes as they are queued.
312 Scheduler::SchedulerData* data = scheduler_->GetData(node); 313 if (!queued_.Get(node)) {
313 if (!data->is_connected_control_) {
314 data->is_connected_control_ = true;
315 BuildBlocks(node); 314 BuildBlocks(node);
316 queue_.push(node); 315 queue_.push(node);
316 queued_.Set(node, true);
317 control_.push_back(node); 317 control_.push_back(node);
318 } 318 }
319 } 319 }
320 320
321 void BuildBlocks(Node* node) { 321 void BuildBlocks(Node* node) {
322 switch (node->opcode()) { 322 switch (node->opcode()) {
323 case IrOpcode::kEnd: 323 case IrOpcode::kEnd:
324 FixNode(schedule_->end(), node); 324 FixNode(schedule_->end(), node);
325 break; 325 break;
326 case IrOpcode::kStart: 326 case IrOpcode::kStart:
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 } 493 }
494 494
495 void ResetDataStructures() { 495 void ResetDataStructures() {
496 control_.clear(); 496 control_.clear();
497 DCHECK(queue_.empty()); 497 DCHECK(queue_.empty());
498 DCHECK(control_.empty()); 498 DCHECK(control_.empty());
499 } 499 }
500 500
501 Scheduler* scheduler_; 501 Scheduler* scheduler_;
502 Schedule* schedule_; 502 Schedule* schedule_;
503 ZoneQueue<Node*> queue_; 503 NodeMarker<bool> queued_; // Mark indicating whether node is queued.
504 NodeVector control_; 504 ZoneQueue<Node*> queue_; // Queue used for breadth-first traversal.
505 Node* component_entry_; 505 NodeVector control_; // List of encountered control nodes.
506 BasicBlock* component_start_; 506 Node* component_entry_; // Component single-entry node.
507 BasicBlock* component_end_; 507 BasicBlock* component_start_; // Component single-entry block.
508 BasicBlock* component_end_; // Component single-exit block.
508 }; 509 };
509 510
510 511
511 void Scheduler::BuildCFG() { 512 void Scheduler::BuildCFG() {
512 Trace("--- CREATING CFG -------------------------------------------\n"); 513 Trace("--- CREATING CFG -------------------------------------------\n");
513 514
514 // Instantiate a new control equivalence algorithm for the graph. 515 // Instantiate a new control equivalence algorithm for the graph.
515 equivalence_ = new (zone_) ControlEquivalence(zone_, graph_); 516 equivalence_ = new (zone_) ControlEquivalence(zone_, graph_);
516 517
517 // Build a control-flow graph for the main control-connected component that 518 // Build a control-flow graph for the main control-connected component that
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 for (NodeVectorIter i = nodes->begin(); i != nodes->end(); ++i) { 1492 for (NodeVectorIter i = nodes->begin(); i != nodes->end(); ++i) {
1492 schedule_->SetBlockForNode(to, *i); 1493 schedule_->SetBlockForNode(to, *i);
1493 scheduled_nodes_[to->id().ToSize()].push_back(*i); 1494 scheduled_nodes_[to->id().ToSize()].push_back(*i);
1494 } 1495 }
1495 nodes->clear(); 1496 nodes->clear();
1496 } 1497 }
1497 1498
1498 } // namespace compiler 1499 } // namespace compiler
1499 } // namespace internal 1500 } // namespace internal
1500 } // namespace v8 1501 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/scheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698