Reviewers: Benedikt Meurer,

Description:
Allow use of phase-local zone in GenericGraphVisit.

[email protected]

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

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+24, -21 lines):
  M src/compiler/generic-algorithm.h
  M src/compiler/graph-inl.h
  M src/compiler/graph-visualizer.cc
  M src/compiler/scheduler.h
  M src/compiler/scheduler.cc


Index: src/compiler/generic-algorithm.h
diff --git a/src/compiler/generic-algorithm.h b/src/compiler/generic-algorithm.h index 607d339ae40d9b58e6104a9710acec06f9412c12..c4681f95139447805eb9df5ab1fa64990379e81c 100644
--- a/src/compiler/generic-algorithm.h
+++ b/src/compiler/generic-algorithm.h
@@ -38,10 +38,9 @@ class GenericGraphVisit {
   //   void PostEdge(Traits::Node* from, int index, Traits::Node* to);
   // }
   template <class Visitor, class Traits, class RootIterator>
-  static void Visit(GenericGraphBase* graph, RootIterator root_begin,
-                    RootIterator root_end, Visitor* visitor) {
-    // TODO(bmeurer): Pass "local" zone as parameter.
-    Zone* zone = graph->zone();
+  static void Visit(GenericGraphBase* graph, Zone* zone,
+                    RootIterator root_begin, RootIterator root_end,
+                    Visitor* visitor) {
     typedef typename Traits::Node Node;
     typedef typename Traits::Iterator Iterator;
     typedef std::pair<Iterator, Iterator> NodeState;
@@ -97,10 +96,10 @@ class GenericGraphVisit {
   }

   template <class Visitor, class Traits>
- static void Visit(GenericGraphBase* graph, typename Traits::Node* current,
-                    Visitor* visitor) {
+  static void Visit(GenericGraphBase* graph, Zone* zone,
+                    typename Traits::Node* current, Visitor* visitor) {
     typename Traits::Node* array[] = {current};
-    Visit<Visitor, Traits>(graph, &array[0], &array[1], visitor);
+    Visit<Visitor, Traits>(graph, zone, &array[0], &array[1], visitor);
   }

   template <class B, class S>
Index: src/compiler/graph-inl.h
diff --git a/src/compiler/graph-inl.h b/src/compiler/graph-inl.h
index f8423c3f89305d5e2f51ed28f21725bcb9b9cd26..571ffb3c5b6f114d571ebf387f2235da516f271c 100644
--- a/src/compiler/graph-inl.h
+++ b/src/compiler/graph-inl.h
@@ -14,8 +14,8 @@ namespace compiler {

 template <class Visitor>
 void Graph::VisitNodeUsesFrom(Node* node, Visitor* visitor) {
- GenericGraphVisit::Visit<Visitor, NodeUseIterationTraits<Node> >(this, node, - visitor);
+  GenericGraphVisit::Visit<Visitor, NodeUseIterationTraits<Node> >(
+      this, zone(), node, visitor);
 }


@@ -28,7 +28,7 @@ void Graph::VisitNodeUsesFromStart(Visitor* visitor) {
 template <class Visitor>
 void Graph::VisitNodeInputsFromEnd(Visitor* visitor) {
   GenericGraphVisit::Visit<Visitor, NodeInputIterationTraits<Node> >(
-      this, end(), visitor);
+      this, zone(), end(), visitor);
 }
 }
 }
Index: src/compiler/graph-visualizer.cc
diff --git a/src/compiler/graph-visualizer.cc b/src/compiler/graph-visualizer.cc index 144512ad0de040f13475853b11d7bcf398e98919..b39e95022b43914310f7e9954c4d30978b43d0ce 100644
--- a/src/compiler/graph-visualizer.cc
+++ b/src/compiler/graph-visualizer.cc
@@ -24,7 +24,7 @@ namespace compiler {

 class GraphVisualizer : public NullNodeVisitor {
  public:
-  GraphVisualizer(OStream& os, const Graph* graph);  // NOLINT
+  GraphVisualizer(OStream& os, Zone* zone, const Graph* graph);  // NOLINT

   void Print();

@@ -35,6 +35,7 @@ class GraphVisualizer : public NullNodeVisitor {
   void AnnotateNode(Node* node);
   void PrintEdge(Node* from, int index, Node* to);

+  Zone* zone_;
   NodeSet all_nodes_;
   NodeSet white_nodes_;
   bool use_to_def_;
@@ -225,8 +226,8 @@ void GraphVisualizer::Print() {
   // Visit all uses of white nodes.
   use_to_def_ = false;
   GenericGraphVisit::Visit<GraphVisualizer, NodeUseIterationTraits<Node> >(
-      const_cast<Graph*>(graph_), white_nodes_.begin(), white_nodes_.end(),
-      this);
+      const_cast<Graph*>(graph_), zone_, white_nodes_.begin(),
+      white_nodes_.end(), this);

   os_ << "  DEAD_INPUT [\n"
       << "    style=\"filled\" \n"
@@ -246,18 +247,19 @@ void GraphVisualizer::Print() {
 }


-GraphVisualizer::GraphVisualizer(OStream& os, const Graph* graph) // NOLINT
-    : all_nodes_(NodeSet::key_compare(),
-                 NodeSet::allocator_type(graph->zone())),
-      white_nodes_(NodeSet::key_compare(),
-                   NodeSet::allocator_type(graph->zone())),
+GraphVisualizer::GraphVisualizer(OStream& os, Zone* zone,
+                                 const Graph* graph)  // NOLINT
+    : zone_(zone),
+      all_nodes_(NodeSet::key_compare(), NodeSet::allocator_type(zone)),
+      white_nodes_(NodeSet::key_compare(), NodeSet::allocator_type(zone)),
       use_to_def_(true),
       os_(os),
       graph_(graph) {}


 OStream& operator<<(OStream& os, const AsDOT& ad) {
-  GraphVisualizer(os, &ad.graph).Print();
+  Zone tmp_zone(ad.graph.zone()->isolate());
+  GraphVisualizer(os, &tmp_zone, &ad.graph).Print();
   return os;
 }
 }
Index: src/compiler/scheduler.cc
diff --git a/src/compiler/scheduler.cc b/src/compiler/scheduler.cc
index 6a40091698c88d80f42f68694c767b7e2b29c61a..1dd0631679137e6a5c3504951b6ead881d8760b3 100644
--- a/src/compiler/scheduler.cc
+++ b/src/compiler/scheduler.cc
@@ -16,7 +16,8 @@ namespace internal {
 namespace compiler {

 Scheduler::Scheduler(Zone* zone, Graph* graph, Schedule* schedule)
-    : graph_(graph),
+    : zone_(zone),
+      graph_(graph),
       schedule_(schedule),
       branches_(NodeVector::allocator_type(zone)),
       calls_(NodeVector::allocator_type(zone)),
@@ -624,7 +625,7 @@ void Scheduler::ScheduleLate() {
        i != schedule_root_nodes_.end(); ++i) {
     GenericGraphVisit::Visit<ScheduleLateNodeVisitor,
                              NodeInputIterationTraits<Node> >(
-        graph_, *i, &schedule_late_visitor);
+        graph_, zone_, *i, &schedule_late_visitor);
   }

// Add collected nodes for basic blocks to their blocks in the right order.
Index: src/compiler/scheduler.h
diff --git a/src/compiler/scheduler.h b/src/compiler/scheduler.h
index db620edb55c27d5b0651de74e6441709e3b5ec9e..dabffff53947216f60dfe9a18b3fd8d033c44383 100644
--- a/src/compiler/scheduler.h
+++ b/src/compiler/scheduler.h
@@ -29,6 +29,7 @@ class Scheduler {
   static BasicBlockVector* ComputeSpecialRPO(Schedule* schedule);

  private:
+  Zone* zone_;
   Graph* graph_;
   Schedule* schedule_;
   NodeVector branches_;


--
--
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