[turbofan] More const-correctness changes.
authorbmeurer@chromium.org <bmeurer@chromium.org>
Thu, 4 Sep 2014 10:55:58 +0000 (10:55 +0000)
committerbmeurer@chromium.org <bmeurer@chromium.org>
Thu, 4 Sep 2014 10:55:58 +0000 (10:55 +0000)
Also get rid of the DeleteNode and ChangeOperator methods in Graph.

TEST=compiler-unittests,cctest,mjsunit
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/540863002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23684 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/compiler/graph.cc
src/compiler/graph.h
src/compiler/machine-operator-reducer.cc
src/compiler/simplified-operator-reducer.cc

index f49ce34..7b5f228 100644 (file)
@@ -21,7 +21,7 @@ namespace compiler {
 Graph::Graph(Zone* zone) : GenericGraph<Node>(zone), decorators_(zone) {}
 
 
-Node* Graph::NewNode(Operator* op, int input_count, Node** inputs) {
+Node* Graph::NewNode(const Operator* op, int input_count, Node** inputs) {
   DCHECK_LE(op->InputCount(), input_count);
   Node* result = Node::New(this, input_count, inputs);
   result->Initialize(op);
@@ -32,21 +32,6 @@ Node* Graph::NewNode(Operator* op, int input_count, Node** inputs) {
   return result;
 }
 
-
-void Graph::ChangeOperator(Node* node, Operator* op) { node->set_op(op); }
-
-
-void Graph::DeleteNode(Node* node) {
-#if DEBUG
-  // Nodes can't be deleted if they have uses.
-  Node::Uses::iterator use_iterator(node->uses().begin());
-  DCHECK(use_iterator == node->uses().end());
-#endif
-
-#if DEBUG
-  memset(node, 0xDE, sizeof(Node));
-#endif
-}
-}
-}
-}  // namespace v8::internal::compiler
+}  // namespace compiler
+}  // namespace internal
+}  // namespace v8
index e59cc88..07eb02f 100644 (file)
@@ -25,39 +25,36 @@ class Graph : public GenericGraph<Node> {
   explicit Graph(Zone* zone);
 
   // Base implementation used by all factory methods.
-  Node* NewNode(Operator* op, int input_count, Node** inputs);
+  Node* NewNode(const Operator* op, int input_count, Node** inputs);
 
   // Factories for nodes with static input counts.
-  Node* NewNode(Operator* op) {
+  Node* NewNode(const Operator* op) {
     return NewNode(op, 0, static_cast<Node**>(NULL));
   }
-  Node* NewNode(Operator* op, Node* n1) { return NewNode(op, 1, &n1); }
-  Node* NewNode(Operator* op, Node* n1, Node* n2) {
+  Node* NewNode(const Operator* op, Node* n1) { return NewNode(op, 1, &n1); }
+  Node* NewNode(const Operator* op, Node* n1, Node* n2) {
     Node* nodes[] = {n1, n2};
     return NewNode(op, arraysize(nodes), nodes);
   }
-  Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3) {
+  Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3) {
     Node* nodes[] = {n1, n2, n3};
     return NewNode(op, arraysize(nodes), nodes);
   }
-  Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) {
+  Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4) {
     Node* nodes[] = {n1, n2, n3, n4};
     return NewNode(op, arraysize(nodes), nodes);
   }
-  Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
+  Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
                 Node* n5) {
     Node* nodes[] = {n1, n2, n3, n4, n5};
     return NewNode(op, arraysize(nodes), nodes);
   }
-  Node* NewNode(Operator* op, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5,
-                Node* n6) {
+  Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
+                Node* n5, Node* n6) {
     Node* nodes[] = {n1, n2, n3, n4, n5, n6};
     return NewNode(op, arraysize(nodes), nodes);
   }
 
-  void ChangeOperator(Node* node, Operator* op);
-  void DeleteNode(Node* node);
-
   template <class Visitor>
   void VisitNodeUsesFrom(Node* node, Visitor* visitor);
 
@@ -88,8 +85,9 @@ class GraphDecorator : public ZoneObject {
   virtual ~GraphDecorator() {}
   virtual void Decorate(Node* node) = 0;
 };
-}
-}
-}  // namespace v8::internal::compiler
+
+}  // namespace compiler
+}  // namespace internal
+}  // namespace v8
 
 #endif  // V8_COMPILER_GRAPH_H_
index 4a7bff9..6f2e28e 100644 (file)
@@ -66,7 +66,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
             Int32BinopMatcher mrightright(mright.right().node());
             if (mrightright.left().Is(32) &&
                 mrightright.right().node() == mleft.right().node()) {
-              graph()->ChangeOperator(node, machine()->Word32Ror());
+              node->set_op(machine()->Word32Ror());
               node->ReplaceInput(0, mleft.left().node());
               node->ReplaceInput(1, mleft.right().node());
               return Changed(node);
@@ -75,7 +75,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
           // (x << K) | (x >> (32 - K)) => x ror K
           if (mleft.right().IsInRange(0, 31) &&
               mright.right().Is(32 - mleft.right().Value())) {
-            graph()->ChangeOperator(node, machine()->Word32Ror());
+            node->set_op(machine()->Word32Ror());
             node->ReplaceInput(0, mleft.left().node());
             node->ReplaceInput(1, mleft.right().node());
             return Changed(node);
@@ -91,7 +91,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
             Int32BinopMatcher mleftright(mleft.right().node());
             if (mleftright.left().Is(32) &&
                 mleftright.right().node() == mright.right().node()) {
-              graph()->ChangeOperator(node, machine()->Word32Ror());
+              node->set_op(machine()->Word32Ror());
               node->ReplaceInput(0, mright.left().node());
               node->ReplaceInput(1, mright.right().node());
               return Changed(node);
@@ -100,7 +100,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
           // (x >> (32 - K)) | (x << K) => x ror K
           if (mright.right().IsInRange(0, 31) &&
               mleft.right().Is(32 - mright.right().Value())) {
-            graph()->ChangeOperator(node, machine()->Word32Ror());
+            node->set_op(machine()->Word32Ror());
             node->ReplaceInput(0, mright.left().node());
             node->ReplaceInput(1, mright.right().node());
             return Changed(node);
@@ -193,13 +193,13 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
         return ReplaceInt32(m.left().Value() * m.right().Value());
       }
       if (m.right().Is(-1)) {  // x * -1 => 0 - x
-        graph()->ChangeOperator(node, machine()->Int32Sub());
+        node->set_op(machine()->Int32Sub());
         node->ReplaceInput(0, Int32Constant(0));
         node->ReplaceInput(1, m.left().node());
         return Changed(node);
       }
       if (m.right().IsPowerOf2()) {  // x * 2^n => x << n
-        graph()->ChangeOperator(node, machine()->Word32Shl());
+        node->set_op(machine()->Word32Shl());
         node->ReplaceInput(1, Int32Constant(WhichPowerOf2(m.right().Value())));
         return Changed(node);
       }
@@ -217,7 +217,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
         return ReplaceInt32(m.left().Value() / m.right().Value());
       }
       if (m.right().Is(-1)) {  // x / -1 => 0 - x
-        graph()->ChangeOperator(node, machine()->Int32Sub());
+        node->set_op(machine()->Int32Sub());
         node->ReplaceInput(0, Int32Constant(0));
         node->ReplaceInput(1, m.left().node());
         return Changed(node);
@@ -234,7 +234,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
         return ReplaceInt32(m.left().Value() / m.right().Value());
       }
       if (m.right().IsPowerOf2()) {  // x / 2^n => x >> n
-        graph()->ChangeOperator(node, machine()->Word32Shr());
+        node->set_op(machine()->Word32Shr());
         node->ReplaceInput(1, Int32Constant(WhichPowerOf2(m.right().Value())));
         return Changed(node);
       }
@@ -263,7 +263,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
         return ReplaceInt32(m.left().Value() % m.right().Value());
       }
       if (m.right().IsPowerOf2()) {  // x % 2^n => x & 2^n-1
-        graph()->ChangeOperator(node, machine()->Word32And());
+        node->set_op(machine()->Word32And());
         node->ReplaceInput(1, Int32Constant(m.right().Value() - 1));
         return Changed(node);
       }
index ac6153e..f05c345 100644 (file)
@@ -99,7 +99,7 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
 
 
 Reduction SimplifiedOperatorReducer::Change(Node* node, Operator* op, Node* a) {
-  graph()->ChangeOperator(node, op);
+  node->set_op(op);
   node->ReplaceInput(0, a);
   return Changed(node);
 }