Revision: 22966
Author:   [email protected]
Date:     Thu Aug  7 09:14:37 2014 UTC
Log:      Delegate node properties to operator properties.

* Move logic from NodeProperties to OperatorProperties when possible
* Make NodeProperties delegeate to OperatorProperties
http://code.google.com/p/v8/source/detail?r=22966

Modified:
 /branches/bleeding_edge/src/compiler/node-properties-inl.h
 /branches/bleeding_edge/src/compiler/node-properties.h
 /branches/bleeding_edge/src/compiler/operator-properties-inl.h
 /branches/bleeding_edge/src/compiler/operator-properties.h

=======================================
--- /branches/bleeding_edge/src/compiler/node-properties-inl.h Mon Aug 4 11:34:54 2014 UTC +++ /branches/bleeding_edge/src/compiler/node-properties-inl.h Thu Aug 7 09:14:37 2014 UTC
@@ -24,7 +24,7 @@
 //     0 [ values, context, effects, control ] node->InputCount()

 inline bool NodeProperties::HasValueInput(Node* node) {
-  return OperatorProperties::GetValueInputCount(node->op()) > 0;
+  return OperatorProperties::HasValueInput(node->op());
 }

 inline bool NodeProperties::HasContextInput(Node* node) {
@@ -32,11 +32,11 @@
 }

 inline bool NodeProperties::HasEffectInput(Node* node) {
-  return OperatorProperties::GetEffectInputCount(node->op()) > 0;
+  return OperatorProperties::HasEffectInput(node->op());
 }

 inline bool NodeProperties::HasControlInput(Node* node) {
-  return OperatorProperties::GetControlInputCount(node->op()) > 0;
+  return OperatorProperties::HasControlInput(node->op());
 }


@@ -45,7 +45,7 @@
 }

 inline int NodeProperties::GetContextInputCount(Node* node) {
-  return OperatorProperties::HasContextInput(node->op()) ? 1 : 0;
+  return OperatorProperties::GetContextInputCount(node->op());
 }

 inline int NodeProperties::GetEffectInputCount(Node* node) {
@@ -57,11 +57,12 @@
 }


-inline int NodeProperties::FirstValueIndex(Node* node) { return 0; }
-
-inline int NodeProperties::FirstContextIndex(Node* node) {
+inline int NodeProperties::GetContextIndex(Node* node) {
   return PastValueIndex(node);
 }
+
+
+inline int NodeProperties::FirstValueIndex(Node* node) { return 0; }

 inline int NodeProperties::FirstEffectIndex(Node* node) {
   return PastContextIndex(node);
@@ -77,7 +78,7 @@
 }

 inline int NodeProperties::PastContextIndex(Node* node) {
-  return FirstContextIndex(node) + GetContextInputCount(node);
+  return GetContextIndex(node) + GetContextInputCount(node);
 }

 inline int NodeProperties::PastEffectIndex(Node* node) {
@@ -98,8 +99,8 @@
 }

 inline Node* NodeProperties::GetContextInput(Node* node) {
-  DCHECK(GetContextInputCount(node) > 0);
-  return node->InputAt(FirstContextIndex(node));
+  DCHECK(HasContextInput(node));
+  return node->InputAt(GetContextIndex(node));
 }

 inline Node* NodeProperties::GetEffectInput(Node* node, int index) {
@@ -117,17 +118,15 @@
 // Output counts.

 inline bool NodeProperties::HasValueOutput(Node* node) {
-  return GetValueOutputCount(node) > 0;
+  return OperatorProperties::HasValueOutput(node->op());
 }

 inline bool NodeProperties::HasEffectOutput(Node* node) {
-  return node->opcode() == IrOpcode::kStart ||
-         NodeProperties::GetEffectInputCount(node) > 0;
+  return OperatorProperties::HasEffectOutput(node->op());
 }

 inline bool NodeProperties::HasControlOutput(Node* node) {
-  return (node->opcode() != IrOpcode::kEnd && IsControl(node)) ||
-         NodeProperties::CanLazilyDeoptimize(node);
+  return OperatorProperties::HasControlOutput(node->op());
 }


@@ -136,12 +135,11 @@
 }

 inline int NodeProperties::GetEffectOutputCount(Node* node) {
-  return HasEffectOutput(node) ? 1 : 0;
+  return OperatorProperties::GetEffectOutputCount(node->op());
 }

 inline int NodeProperties::GetControlOutputCount(Node* node) {
- return node->opcode() == IrOpcode::kBranch ? 2 : HasControlOutput(node) ? 1 - : 0;
+  return OperatorProperties::GetControlOutputCount(node->op());
 }


@@ -163,8 +161,7 @@

 inline bool NodeProperties::IsContextEdge(Node::Edge edge) {
   Node* node = edge.from();
-  return IsInputRange(edge, FirstContextIndex(node),
-                      GetContextInputCount(node));
+ return IsInputRange(edge, GetContextIndex(node), GetContextInputCount(node));
 }

 inline bool NodeProperties::IsEffectEdge(Node::Edge edge) {
=======================================
--- /branches/bleeding_edge/src/compiler/node-properties.h Wed Jul 30 13:54:45 2014 UTC +++ /branches/bleeding_edge/src/compiler/node-properties.h Thu Aug 7 09:14:37 2014 UTC
@@ -28,6 +28,7 @@
   static inline int GetContextInputCount(Node* node);
   static inline int GetEffectInputCount(Node* node);
   static inline int GetControlInputCount(Node* node);
+  static inline int GetTotalInputCount(Node* node);

   static inline Node* GetValueInput(Node* node, int index);
   static inline Node* GetContextInput(Node* node);
@@ -63,9 +64,10 @@

   static inline bool CanLazilyDeoptimize(Node* node);

+  static inline int GetContextIndex(Node* node);
+
  private:
   static inline int FirstValueIndex(Node* node);
-  static inline int FirstContextIndex(Node* node);
   static inline int FirstEffectIndex(Node* node);
   static inline int FirstControlIndex(Node* node);
   static inline int PastValueIndex(Node* node);
=======================================
--- /branches/bleeding_edge/src/compiler/operator-properties-inl.h Wed Jul 30 13:54:45 2014 UTC +++ /branches/bleeding_edge/src/compiler/operator-properties-inl.h Thu Aug 7 09:14:37 2014 UTC
@@ -14,13 +14,40 @@
 namespace internal {
 namespace compiler {

-inline int OperatorProperties::GetValueOutputCount(Operator* op) {
-  return op->OutputCount();
+inline bool OperatorProperties::HasValueInput(Operator* op) {
+  return OperatorProperties::GetValueInputCount(op) > 0;
 }

+inline bool OperatorProperties::HasContextInput(Operator* op) {
+  IrOpcode::Value opcode = static_cast<IrOpcode::Value>(op->opcode());
+  return IrOpcode::IsJsOpcode(opcode);
+}
+
+inline bool OperatorProperties::HasEffectInput(Operator* op) {
+  return OperatorProperties::GetEffectInputCount(op) > 0;
+}
+
+inline bool OperatorProperties::HasControlInput(Operator* op) {
+  return OperatorProperties::GetControlInputCount(op) > 0;
+}
+
+
 inline int OperatorProperties::GetValueInputCount(Operator* op) {
   return op->InputCount();
 }
+
+inline int OperatorProperties::GetContextInputCount(Operator* op) {
+  return OperatorProperties::HasContextInput(op) ? 1 : 0;
+}
+
+inline int OperatorProperties::GetEffectInputCount(Operator* op) {
+  if (op->opcode() == IrOpcode::kEffectPhi) {
+    return static_cast<Operator1<int>*>(op)->parameter();
+  }
+ if (op->HasProperty(Operator::kNoRead) && op->HasProperty(Operator::kNoWrite))
+    return 0;  // no effects.
+  return 1;
+}

 inline int OperatorProperties::GetControlInputCount(Operator* op) {
   switch (op->opcode()) {
@@ -42,19 +69,42 @@
   return 0;
 }

-inline int OperatorProperties::GetEffectInputCount(Operator* op) {
-  if (op->opcode() == IrOpcode::kEffectPhi) {
-    return static_cast<Operator1<int>*>(op)->parameter();
-  }
- if (op->HasProperty(Operator::kNoRead) && op->HasProperty(Operator::kNoWrite))
-    return 0;  // no effects.
-  return 1;
+inline int OperatorProperties::GetTotalInputCount(Operator* op) {
+  return GetValueInputCount(op) + GetContextInputCount(op) +
+         GetEffectInputCount(op) + GetControlInputCount(op);
+}
+
+// -----------------------------------------------------------------------------
+// Output properties.
+
+inline bool OperatorProperties::HasValueOutput(Operator* op) {
+  return GetValueOutputCount(op) > 0;
+}
+
+inline bool OperatorProperties::HasEffectOutput(Operator* op) {
+  return op->opcode() == IrOpcode::kStart || GetEffectInputCount(op) > 0;
 }

-inline bool OperatorProperties::HasContextInput(Operator* op) {
+inline bool OperatorProperties::HasControlOutput(Operator* op) {
   IrOpcode::Value opcode = static_cast<IrOpcode::Value>(op->opcode());
-  return IrOpcode::IsJsOpcode(opcode);
+  return (opcode != IrOpcode::kEnd && IrOpcode::IsControlOpcode(opcode)) ||
+         CanLazilyDeoptimize(op);
+}
+
+
+inline int OperatorProperties::GetValueOutputCount(Operator* op) {
+  return op->OutputCount();
+}
+
+inline int OperatorProperties::GetEffectOutputCount(Operator* op) {
+  return HasEffectOutput(op) ? 1 : 0;
+}
+
+inline int OperatorProperties::GetControlOutputCount(Operator* node) {
+ return node->opcode() == IrOpcode::kBranch ? 2 : HasControlOutput(node) ? 1 + : 0;
 }
+

 inline bool OperatorProperties::IsBasicBlockBegin(Operator* op) {
   uint8_t opcode = op->opcode();
=======================================
--- /branches/bleeding_edge/src/compiler/operator-properties.h Wed Jul 30 13:54:45 2014 UTC +++ /branches/bleeding_edge/src/compiler/operator-properties.h Thu Aug 7 09:14:37 2014 UTC
@@ -15,19 +15,32 @@

 class OperatorProperties {
  public:
-  static int GetValueOutputCount(Operator* op);
-  static int GetValueInputCount(Operator* op);
-  static bool HasContextInput(Operator* op);
-  static int GetEffectInputCount(Operator* op);
-  static int GetControlInputCount(Operator* op);
+  static inline bool HasValueInput(Operator* node);
+  static inline bool HasContextInput(Operator* node);
+  static inline bool HasEffectInput(Operator* node);
+  static inline bool HasControlInput(Operator* node);
+
+  static inline int GetValueInputCount(Operator* op);
+  static inline int GetContextInputCount(Operator* op);
+  static inline int GetEffectInputCount(Operator* op);
+  static inline int GetControlInputCount(Operator* op);
+  static inline int GetTotalInputCount(Operator* op);
+
+  static inline bool HasValueOutput(Operator* op);
+  static inline bool HasEffectOutput(Operator* op);
+  static inline bool HasControlOutput(Operator* op);
+
+  static inline int GetValueOutputCount(Operator* op);
+  static inline int GetEffectOutputCount(Operator* op);
+  static inline int GetControlOutputCount(Operator* op);

-  static bool IsBasicBlockBegin(Operator* op);
+  static inline bool IsBasicBlockBegin(Operator* op);

-  static bool CanBeScheduled(Operator* op);
-  static bool HasFixedSchedulePosition(Operator* op);
-  static bool IsScheduleRoot(Operator* op);
+  static inline bool CanBeScheduled(Operator* op);
+  static inline bool HasFixedSchedulePosition(Operator* op);
+  static inline bool IsScheduleRoot(Operator* op);

-  static bool CanLazilyDeoptimize(Operator* op);
+  static inline bool CanLazilyDeoptimize(Operator* op);
 };
 }
 }

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