Delegate node properties to operator properties.
authorsigurds@chromium.org <sigurds@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 7 Aug 2014 09:14:37 +0000 (09:14 +0000)
committersigurds@chromium.org <sigurds@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 7 Aug 2014 09:14:37 +0000 (09:14 +0000)
* Move logic from NodeProperties to OperatorProperties when possible
* Make NodeProperties delegeate to OperatorProperties

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

src/compiler/node-properties-inl.h
src/compiler/node-properties.h
src/compiler/operator-properties-inl.h
src/compiler/operator-properties.h

index f76bc5f..8c80945 100644 (file)
@@ -24,7 +24,7 @@ namespace compiler {
 //     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::HasContextInput(Node* node) {
 }
 
 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::GetValueInputCount(Node* node) {
 }
 
 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,12 +57,13 @@ inline int NodeProperties::GetControlInputCount(Node* node) {
 }
 
 
-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::PastValueIndex(Node* node) {
 }
 
 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::GetValueInput(Node* node, int index) {
 }
 
 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 @@ inline Node* NodeProperties::GetControlInput(Node* node, int index) {
 // 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::GetValueOutputCount(Node* node) {
 }
 
 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::IsValueEdge(Node::Edge edge) {
 
 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) {
index 7afcf4e..5a1348c 100644 (file)
@@ -28,6 +28,7 @@ class NodeProperties {
   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 @@ class NodeProperties {
 
   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);
index 2147f2f..fc9149d 100644 (file)
@@ -14,14 +14,41 @@ namespace v8 {
 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()) {
     case IrOpcode::kPhi:
@@ -42,20 +69,43 @@ inline int OperatorProperties::GetControlInputCount(Operator* op) {
   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);
 }
 
-inline bool OperatorProperties::HasContextInput(Operator* 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::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();
   return opcode == IrOpcode::kStart || opcode == IrOpcode::kEnd ||
index a2d220d..cbc8ed9 100644 (file)
@@ -15,19 +15,32 @@ class Operator;
 
 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 bool IsBasicBlockBegin(Operator* op);
+  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 bool CanBeScheduled(Operator* op);
-  static bool HasFixedSchedulePosition(Operator* op);
-  static bool IsScheduleRoot(Operator* op);
+  static inline bool HasValueOutput(Operator* op);
+  static inline bool HasEffectOutput(Operator* op);
+  static inline bool HasControlOutput(Operator* op);
 
-  static bool CanLazilyDeoptimize(Operator* op);
+  static inline int GetValueOutputCount(Operator* op);
+  static inline int GetEffectOutputCount(Operator* op);
+  static inline int GetControlOutputCount(Operator* op);
+
+  static inline bool IsBasicBlockBegin(Operator* op);
+
+  static inline bool CanBeScheduled(Operator* op);
+  static inline bool HasFixedSchedulePosition(Operator* op);
+  static inline bool IsScheduleRoot(Operator* op);
+
+  static inline bool CanLazilyDeoptimize(Operator* op);
 };
 }
 }