Reviewers: Benedikt Meurer,

Description:
Reuse CFGBuilder in the scheduler to save memory.

[email protected]

Please review this at https://codereview.chromium.org/755353003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+16, -7 lines):
  M src/compiler/scheduler.h
  M src/compiler/scheduler.cc


Index: src/compiler/scheduler.cc
diff --git a/src/compiler/scheduler.cc b/src/compiler/scheduler.cc
index 8c169368e54d5e8883e6184d542d7b02e5a34c18..3c90d9826ed763630e5b15d219b9a7813f4a954f 100644
--- a/src/compiler/scheduler.cc
+++ b/src/compiler/scheduler.cc
@@ -234,7 +234,7 @@ BasicBlock* Scheduler::GetCommonDominator(BasicBlock* b1, BasicBlock* b2) { // between them within a Schedule) from the node graph. Visits control edges of // the graph backwards from an end node in order to find the connected control
 // subgraph, needed for scheduling.
-class CFGBuilder {
+class CFGBuilder : public ZoneObject {
  public:
   CFGBuilder(Zone* zone, Scheduler* scheduler)
       : scheduler_(scheduler),
@@ -249,6 +249,7 @@ class CFGBuilder {
   // backwards from end through control edges, building and connecting the
   // basic blocks for control nodes.
   void Run() {
+    ResetDataStructures();
     Queue(scheduler_->graph_->end());

     while (!queue_.empty()) {  // Breadth-first backwards traversal.
@@ -269,6 +270,7 @@ class CFGBuilder {
   // component ending in {node} and merge that component into an existing
   // control flow graph at the bottom of {block}.
   void Run(BasicBlock* block, Node* node) {
+    ResetDataStructures();
     Queue(node);

     component_start_ = block;
@@ -484,6 +486,12 @@ class CFGBuilder {
             node == scheduler_->graph_->end()->InputAt(0));
   }

+  void ResetDataStructures() {
+    control_.clear();
+    DCHECK(queue_.empty());
+    DCHECK(control_.empty());
+  }
+
   Scheduler* scheduler_;
   Schedule* schedule_;
   ZoneQueue<Node*> queue_;
@@ -499,8 +507,8 @@ void Scheduler::BuildCFG() {

// Build a control-flow graph for the main control-connected component that
   // is being spanned by the graph's start and end nodes.
-  CFGBuilder cfg_builder(zone_, this);
-  cfg_builder.Run();
+  control_flow_builder_ = new (zone_) CFGBuilder(zone_, this);
+  control_flow_builder_->Run();

   // Initialize per-block data.
   scheduled_nodes_.resize(schedule_->BasicBlockCount(), NodeVector(zone_));
@@ -1449,8 +1457,7 @@ void Scheduler::FuseFloatingControl(BasicBlock* block, Node* node) {
   }

   // Iterate on phase 1: Build control-flow graph.
-  CFGBuilder cfg_builder(zone_, this);
-  cfg_builder.Run(block, node);
+  control_flow_builder_->Run(block, node);

   // Iterate on phase 2: Compute special RPO and dominator tree.
   special_rpo_->UpdateSpecialRPO(block, schedule_->block(node));
@@ -1465,8 +1472,8 @@ void Scheduler::FuseFloatingControl(BasicBlock* block, Node* node) { // TODO(mstarzinger): The following loop gathering the propagation roots is a // temporary solution and should be merged into the rest of the scheduler as
   // soon as the approach settled for all floating loops.
-  NodeVector propagation_roots(cfg_builder.control_);
-  for (Node* node : cfg_builder.control_) {
+  NodeVector propagation_roots(control_flow_builder_->control_);
+  for (Node* node : control_flow_builder_->control_) {
     for (Node* use : node->uses()) {
       if (use->opcode() == IrOpcode::kPhi ||
           use->opcode() == IrOpcode::kEffectPhi) {
Index: src/compiler/scheduler.h
diff --git a/src/compiler/scheduler.h b/src/compiler/scheduler.h
index e75469090f75ae3736f1adf47cbf9b547bd3d8b2..196215956f4b7f42c57c05015483c0ea61223b85 100644
--- a/src/compiler/scheduler.h
+++ b/src/compiler/scheduler.h
@@ -16,6 +16,7 @@ namespace v8 {
 namespace internal {
 namespace compiler {

+class CFGBuilder;
 class SpecialRPONumberer;

 // Computes a schedule from a graph, placing nodes into basic blocks and
@@ -61,6 +62,7 @@ class Scheduler {
NodeVector schedule_root_nodes_; // Fixed root nodes seed the worklist.
   ZoneQueue<Node*> schedule_queue_;      // Worklist of schedulable nodes.
   ZoneVector<SchedulerData> node_data_;  // Per-node data for all nodes.
+ CFGBuilder* control_flow_builder_; // Builds basic blocks for controls. SpecialRPONumberer* special_rpo_; // Special RPO numbering of blocks.

   Scheduler(Zone* zone, Graph* graph, Schedule* schedule);


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to